diff --git a/android-aac-enc/README.md b/android-aac-enc/README.md deleted file mode 100644 index 2e93ef936..000000000 --- a/android-aac-enc/README.md +++ /dev/null @@ -1,32 +0,0 @@ -Android AAC Encoder project -============================ - -Extraction of Android Stagefright VO AAC encoder with a nice Java API. - -In addition, includes a patched [MP4Parser](http://code.google.com/p/mp4parser) Java library for wrapping AAC files in an MP4 container to produce M4A audio files playable by Google Chrome and Apple QuickTime. - -This project is set up as a single Eclipse project with a Main.java example activity. AAC encoding logic is found in jni/aac-enc.c, which needs to be built with the [Android NDK](http://developer.android.com/sdk/ndk/index.html). I used NDK r7c, but any version should work. - -Why? ----- - -- smaller code footprint than FFmpeg (< 500k compared to > 2M) -- less native code to compile = less work to support new architectures -- easiest way to make an M4A file - - -License -------- - -This project is released under the [Apache License, version 2](http://www.apache.org/licenses/LICENSE-2.0) - -Patents -------- - -This project grants you no rights to any of the patents this technology may require. However, since Android version 4.0 and up ship with the Stagefright VO AAC encoder, it is my understanding that you can release code that depends on these libraries for any version of Android. Please note that I am not a lawyer. - - -Have changes? -------------- - -Pull requests are accepted! \ No newline at end of file diff --git a/android-aac-enc/build.gradle b/android-aac-enc/build.gradle deleted file mode 100644 index a73cd175e..000000000 --- a/android-aac-enc/build.gradle +++ /dev/null @@ -1,33 +0,0 @@ -buildscript { - repositories { - mavenCentral() - } - dependencies { - classpath 'com.android.tools.build:gradle:0.10.+' - } -} - -apply plugin: 'android-library' - -repositories { - mavenCentral() -} - -android { - compileSdkVersion 19 - buildToolsVersion "19.0.3" - - compileOptions { - sourceCompatibility JavaVersion.VERSION_1_7 - targetCompatibility JavaVersion.VERSION_1_7 - } - - defaultConfig { - minSdkVersion 7 - targetSdkVersion 19 - } -} - -dependencies { - compile group: 'com.android.support', name: 'support-v4', version: '19.1.+' -} diff --git a/android-aac-enc/jni/Android.mk b/android-aac-enc/jni/Android.mk deleted file mode 100644 index 46e25c4c4..000000000 --- a/android-aac-enc/jni/Android.mk +++ /dev/null @@ -1,85 +0,0 @@ -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) -include $(LOCAL_PATH)/Config.mk - -LOCAL_MODULE := aac-encoder - -ENC_SRC := src - -LOCAL_C_INCLUDES := $(LOCAL_PATH)/inc - -LOCAL_SRC_FILES = \ - aac-enc.c \ - $(ENC_SRC)/cmnMemory.c \ - basic_op/basicop2.c \ - basic_op/oper_32b.c \ - $(ENC_SRC)/aac_rom.c \ - $(ENC_SRC)/aacenc.c \ - $(ENC_SRC)/aacenc_core.c \ - $(ENC_SRC)/adj_thr.c \ - $(ENC_SRC)/band_nrg.c \ - $(ENC_SRC)/bit_cnt.c \ - $(ENC_SRC)/bitbuffer.c \ - $(ENC_SRC)/bitenc.c \ - $(ENC_SRC)/block_switch.c \ - $(ENC_SRC)/channel_map.c \ - $(ENC_SRC)/dyn_bits.c \ - $(ENC_SRC)/grp_data.c \ - $(ENC_SRC)/interface.c \ - $(ENC_SRC)/line_pe.c \ - $(ENC_SRC)/memalign.c \ - $(ENC_SRC)/ms_stereo.c \ - $(ENC_SRC)/pre_echo_control.c \ - $(ENC_SRC)/psy_configuration.c \ - $(ENC_SRC)/psy_main.c \ - $(ENC_SRC)/qc_main.c \ - $(ENC_SRC)/quantize.c \ - $(ENC_SRC)/sf_estim.c \ - $(ENC_SRC)/spreading.c \ - $(ENC_SRC)/stat_bits.c \ - $(ENC_SRC)/tns.c \ - $(ENC_SRC)/transform.c - -ifeq ($(VOTT), v5) -LOCAL_SRC_FILES += \ - $(ENC_SRC)/asm/ARMV5E/AutoCorrelation_v5.s \ - $(ENC_SRC)/asm/ARMV5E/band_nrg_v5.s \ - $(ENC_SRC)/asm/ARMV5E/CalcWindowEnergy_v5.s \ - $(ENC_SRC)/asm/ARMV5E/PrePostMDCT_v5.s \ - $(ENC_SRC)/asm/ARMV5E/R4R8First_v5.s \ - $(ENC_SRC)/asm/ARMV5E/Radix4FFT_v5.s -endif - -ifeq ($(VOTT), v7) -LOCAL_SRC_FILES += \ - $(ENC_SRC)/asm/ARMV5E/AutoCorrelation_v5.s \ - $(ENC_SRC)/asm/ARMV5E/band_nrg_v5.s \ - $(ENC_SRC)/asm/ARMV5E/CalcWindowEnergy_v5.s \ - $(ENC_SRC)/asm/ARMV7/PrePostMDCT_v7.s \ - $(ENC_SRC)/asm/ARMV7/R4R8First_v7.s \ - $(ENC_SRC)/asm/ARMV7/Radix4FFT_v7.s -endif - -LOCAL_ARM_MODE := arm - -LOCAL_LDLIBS := -llog - -LOCAL_STATIC_LIBRARIES := -LOCAL_SHARED_LIBRARIES := - -LOCAL_CFLAGS := $(VO_CFLAGS) - -ifeq ($(VOTT), v5) -LOCAL_CFLAGS += -DARMV5E -DARM_INASM -DARMV5_INASM -LOCAL_C_INCLUDES += $(ENC_SRC)/asm/ARMV5E -endif - -ifeq ($(VOTT), v7) -LOCAL_CFLAGS += -DARMV5E -DARMV7Neon -DARM_INASM -DARMV5_INASM -DARMV6_INASM -LOCAL_C_INCLUDES += $(ENC_SRC)/asm/ARMV5E -LOCAL_C_INCLUDES += $(ENC_SRC)/asm/ARMV7 -endif - -include $(BUILD_SHARED_LIBRARY) - diff --git a/android-aac-enc/jni/Config.mk b/android-aac-enc/jni/Config.mk deleted file mode 100644 index 187f25cc1..000000000 --- a/android-aac-enc/jni/Config.mk +++ /dev/null @@ -1,24 +0,0 @@ -# -# This configure file is just for Linux projects against Android -# - -VOPRJ := -VONJ := - -# WARNING: -# Using v7 breaks generic build -ifeq ($(TARGET_ARCH),arm) -VOTT := v5 -else -VOTT := pc -endif - -# Do we also need to check on ARCH_ARM_HAVE_ARMV7A? - probably not -ifeq ($(ARCH_ARM_HAVE_NEON),true) -VOTT := v7 -endif - -VOTEST := 0 - -VO_CFLAGS:=-DLINUX - diff --git a/android-aac-enc/jni/aac-enc.c b/android-aac-enc/jni/aac-enc.c deleted file mode 100644 index c2322b72f..000000000 --- a/android-aac-enc/jni/aac-enc.c +++ /dev/null @@ -1,154 +0,0 @@ -#include -#include -#include -#include -#include -#include - -#define DEBUG 0 - -#if DEBUG -#define LOG(msg, args...) __android_log_print(ANDROID_LOG_ERROR, "aac-enc", msg, ## args) -#else -#define LOG(msg, args...) -#endif - -/* utility functions */ - -void throwException(JNIEnv* env, const char *name, const char *msg) -{ - jclass cls = (*env)->FindClass(env, name); - /* if cls is NULL, an exception has already been thrown */ - if (cls != NULL) { - (*env)->ThrowNew(env, cls, msg); - } - /* free the local ref */ - (*env)->DeleteLocalRef(env, cls); -} - -/* internal storage */ - -FILE* outfile; - -VO_AUDIO_CODECAPI codec_api; -VO_HANDLE handle = 0; -VO_AUDIO_CODECAPI codec_api = { 0 }; -VO_MEM_OPERATOR mem_operator = { 0 }; -VO_CODEC_INIT_USERDATA user_data; -AACENC_PARAM params = { 0 }; - -/* java native functions */ - -void -Java_com_todoroo_aacenc_AACEncoder_init( JNIEnv* env, - jobject thiz, - int bitrate, - int channels, - int sampleRate, - int bitsPerSample, - jstring outputFile) -{ - - if (bitsPerSample != 16) { - throwException(env, "java/lang/IllegalArgumentException", - "Unsupported sample depth. Only 16 bits per sample is supported"); - return; - } - - voGetAACEncAPI(&codec_api); - - mem_operator.Alloc = cmnMemAlloc; - mem_operator.Copy = cmnMemCopy; - mem_operator.Free = cmnMemFree; - mem_operator.Set = cmnMemSet; - mem_operator.Check = cmnMemCheck; - user_data.memflag = VO_IMF_USERMEMOPERATOR; - user_data.memData = &mem_operator; - codec_api.Init(&handle, VO_AUDIO_CodingAAC, &user_data); - - params.sampleRate = sampleRate; - params.bitRate = bitrate; - params.nChannels = channels; - params.adtsUsed = 1; - - if (codec_api.SetParam(handle, VO_PID_AAC_ENCPARAM, ¶ms) != VO_ERR_NONE) { - throwException(env, "java/lang/IllegalArgumentException", - "Unable to set encoding parameters"); - return; - } - - const char* output_file = (*env)->GetStringUTFChars(env, outputFile, (jboolean) 0); - outfile = fopen(output_file, "wb"); - LOG("writing to %s", output_file); - (*env)->ReleaseStringUTFChars(env, outputFile, output_file); - - LOG("initialized handle: %x", handle); - -} - -void -Java_com_todoroo_aacenc_AACEncoder_encode( JNIEnv* env, - jobject thiz, - jbyteArray inputArray) -{ - - LOG("writing to handle: %x", handle); - - jbyte* buffer = (*env)->GetByteArrayElements(env, inputArray, (jboolean) 0); - int inputSize = (*env)->GetArrayLength(env, inputArray); - - VO_CODECBUFFER input = { 0 }, output = { 0 }; - VO_AUDIO_OUTPUTINFO output_info = { 0 }; - - int readSize = params.nChannels * 2 * 1024; - uint16_t* outbuf = (uint16_t*) malloc(readSize * 2); - - LOG("input buffer: %d", inputSize); - - /* GET OUTPUT DATA */ - int i; - for(i = 0; i < inputSize; i += readSize) { - - input.Buffer = buffer + i; - input.Length = readSize; - codec_api.SetInputData(handle, &input); - - output.Buffer = outbuf; - output.Length = readSize * 2; - - int status = codec_api.GetOutputData(handle, &output, &output_info); - if (status == VO_ERR_INPUT_BUFFER_SMALL) - break; - - if (status == VO_ERR_OUTPUT_BUFFER_SMALL) { - LOG("output buffer was too small, read %d", output_info.InputUsed); - } else if (status != VO_ERR_NONE) { - char message[100]; - sprintf(message, "Unable to encode frame: %x", status); - throwException(env, "java/lang/RuntimeException", message); - return; - } - - fwrite(outbuf, 1, output.Length, outfile); - } - - LOG("finished output"); - (*env)->ReleaseByteArrayElements(env, inputArray, buffer, JNI_ABORT); - free(outbuf); -} - -void -Java_com_todoroo_aacenc_AACEncoder_uninit( JNIEnv* env, - jobject thiz) -{ - - fclose(outfile); - codec_api.Uninit(handle); - -} - -JNIEXPORT jint JNICALL -JNI_OnLoad (JavaVM * vm, void * reserved) -{ - return JNI_VERSION_1_6; -} diff --git a/android-aac-enc/jni/basic_op/basicop2.c b/android-aac-enc/jni/basic_op/basicop2.c deleted file mode 100644 index d43bbd99e..000000000 --- a/android-aac-enc/jni/basic_op/basicop2.c +++ /dev/null @@ -1,1624 +0,0 @@ -/* - ** Copyright 2003-2010, VisualOn, Inc. - ** - ** Licensed under the Apache License, Version 2.0 (the "License"); - ** you may not use this file except in compliance with the License. - ** You may obtain a copy of the License at - ** - ** http://www.apache.org/licenses/LICENSE-2.0 - ** - ** Unless required by applicable law or agreed to in writing, software - ** distributed under the License is distributed on an "AS IS" BASIS, - ** WITHOUT 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: basicop2.c - - Content: Basic arithmetic operators. - -*******************************************************************************/ - -#include "typedef.h" -#include "basic_op.h" - - -/*___________________________________________________________________________ - | | - | Functions | - |___________________________________________________________________________| -*/ - -/*___________________________________________________________________________ - | | - | Function Name : saturate | - | | - | Purpose : | - | | - | Limit the 32 bit input to the range of a 16 bit word. | - | | - | Inputs : | - | | - | L_var1 | - | 32 bit long signed integer (Word32) whose value falls in the | - | range : 0x8000 0000 <= L_var1 <= 0x7fff ffff. | - | | - | Outputs : | - | | - | none | - | | - | Return Value : | - | | - | var_out | - | 16 bit short signed integer (Word16) whose value falls in the | - | range : 0xffff 8000 <= var_out <= 0x0000 7fff. | - |___________________________________________________________________________| -*/ - -#if (!SATRUATE_IS_INLINE) -Word16 saturate(Word32 L_var1) -{ - Word16 var_out; - - if (L_var1 > 0X00007fffL) - { - var_out = MAX_16; - } - else if (L_var1 < (Word32) 0xffff8000L) - { - var_out = MIN_16; - } - else - { - var_out = extract_l(L_var1); - } - - return (var_out); -} -#endif - -/*___________________________________________________________________________ - | | - | Function Name : add | - | | - | Purpose : | - | | - | Performs the addition (var1+var2) with overflow control and saturation;| - | the 16 bit result is set at +32767 when overflow occurs or at -32768 | - | when underflow occurs. | - | | - | Complexity weight : 1 | - | | - | Inputs : | - | | - | var1 | - | 16 bit short signed integer (Word16) whose value falls in the | - | range : 0xffff 8000 <= var1 <= 0x0000 7fff. | - | | - | var2 | - | 16 bit short signed integer (Word16) whose value falls in the | - | range : 0xffff 8000 <= var1 <= 0x0000 7fff. | - | | - | Outputs : | - | | - | none | - | | - | Return Value : | - | | - | var_out | - | 16 bit short signed integer (Word16) whose value falls in the | - | range : 0xffff 8000 <= var_out <= 0x0000 7fff. | - |___________________________________________________________________________| -*/ - -#if (!ADD_IS_INLINE) -Word16 add (Word16 var1, Word16 var2) -{ - Word16 var_out; - Word32 L_sum; - - L_sum = (Word32)var1 + (Word32)var2; - var_out = saturate(L_sum); - - return (var_out); -} -#endif - -/*___________________________________________________________________________ - | | - | Function Name : sub | - | | - | Purpose : | - | | - | Performs the subtraction (var1+var2) with overflow control and satu- | - | ration; the 16 bit result is set at +32767 when overflow occurs or at | - | -32768 when underflow occurs. | - | | - | Complexity weight : 1 | - | | - | Inputs : | - | | - | var1 | - | 16 bit short signed integer (Word16) whose value falls in the | - | range : 0xffff 8000 <= var1 <= 0x0000 7fff. | - | | - | var2 | - | 16 bit short signed integer (Word16) whose value falls in the | - | range : 0xffff 8000 <= var1 <= 0x0000 7fff. | - | | - | Outputs : | - | | - | none | - | | - | Return Value : | - | | - | var_out | - | 16 bit short signed integer (Word16) whose value falls in the | - | range : 0xffff 8000 <= var_out <= 0x0000 7fff. | - |___________________________________________________________________________| -*/ -#if (!SUB_IS_INLINE) -Word16 sub(Word16 var1, Word16 var2) -{ - Word16 var_out; - Word32 L_diff; - - L_diff = (Word32) var1 - var2; - var_out = saturate(L_diff); - - return (var_out); -} -#endif - -/*___________________________________________________________________________ - | | - | Function Name : abs_s | - | | - | Purpose : | - | | - | Absolute value of var1; abs_s(-32768) = 32767. | - | | - | Complexity weight : 1 | - | | - | Inputs : | - | | - | var1 | - | 16 bit short signed integer (Word16) whose value falls in the | - | range : 0xffff 8000 <= var1 <= 0x0000 7fff. | - | | - | Outputs : | - | | - | none | - | | - | Return Value : | - | | - | var_out | - | 16 bit short signed integer (Word16) whose value falls in the | - | range : 0x0000 0000 <= var_out <= 0x0000 7fff. | - |___________________________________________________________________________| -*/ -//Word16 abs_s (Word16 var1) -//{ -// Word16 var_out; -// -// if (var1 == MIN_16) -// { -// var_out = MAX_16; -// } -// else -// { -// if (var1 < 0) -// { -// var_out = (Word16)-var1; -// } -// else -// { -// var_out = var1; -// } -// } -// -// return (var_out); -//} - - -/*___________________________________________________________________________ - | | - | Function Name : shl | - | | - | Purpose : | - | | - | Arithmetically shift the 16 bit input var1 left var2 positions.Zero fill| - | the var2 LSB of the result. If var2 is negative, arithmetically shift | - | var1 right by -var2 with sign extension. Saturate the result in case of | - | underflows or overflows. | - | | - | Complexity weight : 1 | - | | - | Inputs : | - | | - | var1 | - | 16 bit short signed integer (Word16) whose value falls in the | - | range : 0xffff 8000 <= var1 <= 0x0000 7fff. | - | | - | var2 | - | 16 bit short signed integer (Word16) whose value falls in the | - | range : 0xffff 8000 <= var1 <= 0x0000 7fff. | - | | - | Outputs : | - | | - | none | - | | - | Return Value : | - | | - | var_out | - | 16 bit short signed integer (Word16) whose value falls in the | - | range : 0xffff 8000 <= var_out <= 0x0000 7fff. | - |___________________________________________________________________________| -*/ - -#if (!SHL_IS_INLINE) -Word16 shl (Word16 var1, Word16 var2) -{ - Word16 var_out; - Word32 result; - - if (var2 < 0) - { - if (var2 < -16) - var2 = -16; - var_out = shr (var1, (Word16)-var2); - } - else - { - result = (Word32) var1 *((Word32) 1 << var2); - - if ((var2 > 15 && var1 != 0) || (result != (Word32) ((Word16) result))) - { - //Overflow = 1; - var_out = (Word16)((var1 > 0) ? MAX_16 : MIN_16); - } - else - { - var_out = extract_l(result); - } - } - - return (var_out); -} -#endif -// end - -/*___________________________________________________________________________ - | | - | Function Name : shr | - | | - | Purpose : | - | | - | Arithmetically shift the 16 bit input var1 right var2 positions with | - | sign extension. If var2 is negative, arithmetically shift var1 left by | - | -var2 with sign extension. Saturate the result in case of underflows or | - | overflows. | - | | - | Complexity weight : 1 | - | | - | Inputs : | - | | - | var1 | - | 16 bit short signed integer (Word16) whose value falls in the | - | range : 0xffff 8000 <= var1 <= 0x0000 7fff. | - | | - | var2 | - | 16 bit short signed integer (Word16) whose value falls in the | - | range : 0xffff 8000 <= var1 <= 0x0000 7fff. | - | | - | Outputs : | - | | - | none | - | | - | Return Value : | - | | - | var_out | - | 16 bit short signed integer (Word16) whose value falls in the | - | range : 0xffff 8000 <= var_out <= 0x0000 7fff. | - |___________________________________________________________________________| -*/ - -#if (!SHR_IS_INLINE) -Word16 shr (Word16 var1, Word16 var2) -{ - Word16 var_out; - - if (var2 < 0) - { - if (var2 < -16) - var2 = -16; - var_out = shl (var1, (Word16)-var2); - } - else - { - if (var2 >= 15) - { - var_out = (Word16)((var1 < 0) ? -1 : 0); - } - else - { - if (var1 < 0) - { - var_out = (Word16)(~((~var1) >> var2)); - } - else - { - var_out = (Word16)(var1 >> var2); - } - } - } - - return (var_out); -} -#endif - - -/*___________________________________________________________________________ - | | - | Function Name : mult | - | | - | Purpose : | - | | - | Performs the multiplication of var1 by var2 and gives a 16 bit result | - | which is scaled i.e.: | - | mult(var1,var2) = extract_l(L_shr((var1 times var2),15)) and | - | mult(-32768,-32768) = 32767. | - | | - | Complexity weight : 1 | - | | - | Inputs : | - | | - | var1 | - | 16 bit short signed integer (Word16) whose value falls in the | - | range : 0xffff 8000 <= var1 <= 0x0000 7fff. | - | | - | var2 | - | 16 bit short signed integer (Word16) whose value falls in the | - | range : 0xffff 8000 <= var1 <= 0x0000 7fff. | - | | - | Outputs : | - | | - | none | - | | - | Return Value : | - | | - | var_out | - | 16 bit short signed integer (Word16) whose value falls in the | - | range : 0xffff 8000 <= var_out <= 0x0000 7fff. | - |___________________________________________________________________________| -*/ -#if (!MULT_IS_INLINE) -Word16 mult (Word16 var1, Word16 var2) -{ - Word16 var_out; - Word32 L_product; - - L_product = (Word32) var1 *(Word32) var2; - - L_product = (L_product & (Word32) 0xffff8000L) >> 15; - - if (L_product & (Word32) 0x00010000L) - L_product = L_product | (Word32) 0xffff0000L; - - var_out = saturate(L_product); - - return (var_out); -} -#endif - -/*___________________________________________________________________________ - | | - | Function Name : L_mult | - | | - | Purpose : | - | | - | L_mult is the 32 bit result of the multiplication of var1 times var2 | - | with one shift left i.e.: | - | L_mult(var1,var2) = L_shl((var1 times var2),1) and | - | L_mult(-32768,-32768) = 2147483647. | - | | - | Complexity weight : 1 | - | | - | Inputs : | - | | - | var1 | - | 16 bit short signed integer (Word16) whose value falls in the | - | range : 0xffff 8000 <= var1 <= 0x0000 7fff. | - | | - | var2 | - | 16 bit short signed integer (Word16) whose value falls in the | - | range : 0xffff 8000 <= var1 <= 0x0000 7fff. | - | | - | Outputs : | - | | - | none | - | | - | Return Value : | - | | - | L_var_out | - | 32 bit long signed integer (Word32) whose value falls in the | - | range : 0x8000 0000 <= L_var_out <= 0x7fff ffff. | - |___________________________________________________________________________| -*/ - -#if (!L_MULT_IS_INLINE) -Word32 L_mult(Word16 var1, Word16 var2) -{ - Word32 L_var_out; - - L_var_out = (Word32) var1 *(Word32) var2; - - if (L_var_out != (Word32) 0x40000000L) - { - L_var_out <<= 1; - } - else - { - L_var_out = MAX_32; - } - - return (L_var_out); -} -#endif -// end - -/*___________________________________________________________________________ - | | - | Function Name : negate | - | | - | Purpose : | - | | - | Negate var1 with saturation, saturate in the case where input is -32768:| - | negate(var1) = sub(0,var1). | - | | - | Complexity weight : 1 | - | | - | Inputs : | - | | - | var1 | - | 16 bit short signed integer (Word16) whose value falls in the | - | range : 0xffff 8000 <= var1 <= 0x0000 7fff. | - | | - | Outputs : | - | | - | none | - | | - | Return Value : | - | | - | var_out | - | 16 bit short signed integer (Word16) whose value falls in the | - | range : 0xffff 8000 <= var_out <= 0x0000 7fff. | - |___________________________________________________________________________| -*/ -//Word16 negate (Word16 var1) -//{ -// Word16 var_out; -// -// var_out = (Word16)((var1 == MIN_16) ? MAX_16 : -var1); -// -// return (var_out); -//} - - -/*___________________________________________________________________________ - | | - | Function Name : extract_h | - | | - | Purpose : | - | | - | Return the 16 MSB of L_var1. | - | | - | Complexity weight : 1 | - | | - | Inputs : | - | | - | L_var1 | - | 32 bit long signed integer (Word32 ) whose value falls in the | - | range : 0x8000 0000 <= L_var1 <= 0x7fff ffff. | - | | - | Outputs : | - | | - | none | - | | - | Return Value : | - | | - | var_out | - | 16 bit short signed integer (Word16) whose value falls in the | - | range : 0xffff 8000 <= var_out <= 0x0000 7fff. | - |___________________________________________________________________________| -*/ -#if (!EXTRACT_H_IS_INLINE) -Word16 extract_h (Word32 L_var1) -{ - Word16 var_out; - - var_out = (Word16) (L_var1 >> 16); - - return (var_out); -} -#endif - -/*___________________________________________________________________________ - | | - | Function Name : extract_l | - | | - | Purpose : | - | | - | Return the 16 LSB of L_var1. | - | | - | Complexity weight : 1 | - | | - | Inputs : | - | | - | L_var1 | - | 32 bit long signed integer (Word32 ) whose value falls in the | - | range : 0x8000 0000 <= L_var1 <= 0x7fff ffff. | - | | - | Outputs : | - | | - | none | - | | - | Return Value : | - | | - | var_out | - | 16 bit short signed integer (Word16) whose value falls in the | - | range : 0xffff 8000 <= var_out <= 0x0000 7fff. | - |___________________________________________________________________________| -*/ -#if (!EXTRACT_L_IS_INLINE) -Word16 extract_l(Word32 L_var1) -{ - Word16 var_out; - - var_out = (Word16) L_var1; - - return (var_out); -} -#endif - -/*___________________________________________________________________________ - | | - | Function Name : round | - | | - | Purpose : | - | | - | Round the lower 16 bits of the 32 bit input number into the MS 16 bits | - | with saturation. Shift the resulting bits right by 16 and return the 16 | - | bit number: | - | round(L_var1) = extract_h(L_add(L_var1,32768)) | - | | - | Complexity weight : 1 | - | | - | Inputs : | - | | - | L_var1 | - | 32 bit long signed integer (Word32 ) whose value falls in the | - | range : 0x8000 0000 <= L_var1 <= 0x7fff ffff. | - | | - | Outputs : | - | | - | none | - | | - | Return Value : | - | | - | var_out | - | 16 bit short signed integer (Word16) whose value falls in the | - | range : 0xffff 8000 <= var_out <= 0x0000 7fff. | - |___________________________________________________________________________| -*/ - -#if (!ROUND_IS_INLINE) -Word16 round16(Word32 L_var1) -{ - Word16 var_out; - Word32 L_rounded; - - L_rounded = L_add (L_var1, (Word32) 0x00008000L); - var_out = extract_h (L_rounded); - - return (var_out); -} -#endif -// end - -/*___________________________________________________________________________ - | | - | Function Name : L_mac | - | | - | Purpose : | - | | - | Multiply var1 by var2 and shift the result left by 1. Add the 32 bit | - | result to L_var3 with saturation, return a 32 bit result: | - | L_mac(L_var3,var1,var2) = L_add(L_var3,L_mult(var1,var2)). | - | | - | Complexity weight : 1 | - | | - | Inputs : | - | | - | L_var3 32 bit long signed integer (Word32) whose value falls in the | - | range : 0x8000 0000 <= L_var3 <= 0x7fff ffff. | - | | - | var1 | - | 16 bit short signed integer (Word16) whose value falls in the | - | range : 0xffff 8000 <= var1 <= 0x0000 7fff. | - | | - | var2 | - | 16 bit short signed integer (Word16) whose value falls in the | - | range : 0xffff 8000 <= var1 <= 0x0000 7fff. | - | | - | Outputs : | - | | - | none | - | | - | Return Value : | - | | - | L_var_out | - | 32 bit long signed integer (Word32) whose value falls in the | - | range : 0x8000 0000 <= L_var_out <= 0x7fff ffff. | - |___________________________________________________________________________| -*/ -#if (!L_MSU_IS_INLINE) -Word32 L_mac (Word32 L_var3, Word16 var1, Word16 var2) -{ - Word32 L_var_out; - Word32 L_product; - - L_product = L_mult(var1, var2); - L_var_out = L_add (L_var3, L_product); - - return (L_var_out); -} -#endif - -/*___________________________________________________________________________ - | | - | Function Name : L_msu | - | | - | Purpose : | - | | - | Multiply var1 by var2 and shift the result left by 1. Subtract the 32 | - | bit result to L_var3 with saturation, return a 32 bit result: | - | L_msu(L_var3,var1,var2) = L_sub(L_var3,L_mult(var1,var2)). | - | | - | Complexity weight : 1 | - | | - | Inputs : | - | | - | L_var3 32 bit long signed integer (Word32) whose value falls in the | - | range : 0x8000 0000 <= L_var3 <= 0x7fff ffff. | - | | - | var1 | - | 16 bit short signed integer (Word16) whose value falls in the | - | range : 0xffff 8000 <= var1 <= 0x0000 7fff. | - | | - | var2 | - | 16 bit short signed integer (Word16) whose value falls in the | - | range : 0xffff 8000 <= var1 <= 0x0000 7fff. | - | | - | Outputs : | - | | - | none | - | | - | Return Value : | - | | - | L_var_out | - | 32 bit long signed integer (Word32) whose value falls in the | - | range : 0x8000 0000 <= L_var_out <= 0x7fff ffff. | - |___________________________________________________________________________| -*/ - -#if (!L_MSU_IS_INLINE) -Word32 L_msu (Word32 L_var3, Word16 var1, Word16 var2) -{ - Word32 L_var_out; - Word32 L_product; - - L_product = L_mult(var1, var2); - L_var_out = L_sub (L_var3, L_product); - - return (L_var_out); -} -#endif - - -/*___________________________________________________________________________ - | | - | Function Name : L_add | - | | - | Purpose : | - | | - | 32 bits addition of the two 32 bits variables (L_var1+L_var2) with | - | overflow control and saturation; the result is set at +2147483647 when | - | overflow occurs or at -2147483648 when underflow occurs. | - | | - | Complexity weight : 2 | - | | - | Inputs : | - | | - | L_var1 32 bit long signed integer (Word32) whose value falls in the | - | range : 0x8000 0000 <= L_var3 <= 0x7fff ffff. | - | | - | L_var2 32 bit long signed integer (Word32) whose value falls in the | - | range : 0x8000 0000 <= L_var3 <= 0x7fff ffff. | - | | - | Outputs : | - | | - | none | - | | - | Return Value : | - | | - | L_var_out | - | 32 bit long signed integer (Word32) whose value falls in the | - | range : 0x8000 0000 <= L_var_out <= 0x7fff ffff. | - |___________________________________________________________________________| -*/ -#if (!L_ADD_IS_INLINE) -Word32 L_add (Word32 L_var1, Word32 L_var2) -{ - Word32 L_var_out; - - L_var_out = L_var1 + L_var2; - - if (((L_var1 ^ L_var2) & MIN_32) == 0) - { - if ((L_var_out ^ L_var1) & MIN_32) - { - L_var_out = (L_var1 < 0) ? MIN_32 : MAX_32; - //Overflow = 1; - } - } - - return (L_var_out); -} -#endif - -/*___________________________________________________________________________ - | | - | Function Name : L_sub | - | | - | Purpose : | - | | - | 32 bits subtraction of the two 32 bits variables (L_var1-L_var2) with | - | overflow control and saturation; the result is set at +2147483647 when | - | overflow occurs or at -2147483648 when underflow occurs. | - | | - | Complexity weight : 2 | - | | - | Inputs : | - | | - | L_var1 32 bit long signed integer (Word32) whose value falls in the | - | range : 0x8000 0000 <= L_var3 <= 0x7fff ffff. | - | | - | L_var2 32 bit long signed integer (Word32) whose value falls in the | - | range : 0x8000 0000 <= L_var3 <= 0x7fff ffff. | - | | - | Outputs : | - | | - | none | - | | - | Return Value : | - | | - | L_var_out | - | 32 bit long signed integer (Word32) whose value falls in the | - | range : 0x8000 0000 <= L_var_out <= 0x7fff ffff. | - |___________________________________________________________________________| -*/ -#if (!L_SUB_IS_INLINE) -Word32 L_sub(Word32 L_var1, Word32 L_var2) -{ - Word32 L_var_out; - - L_var_out = L_var1 - L_var2; - - if (((L_var1 ^ L_var2) & MIN_32) != 0) - { - if ((L_var_out ^ L_var1) & MIN_32) - { - L_var_out = (L_var1 < 0L) ? MIN_32 : MAX_32; - //Overflow = 1; - } - } - - return (L_var_out); -} -#endif - - -/*___________________________________________________________________________ - | | - | Function Name : L_negate | - | | - | Purpose : | - | | - | Negate the 32 bit variable L_var1 with saturation; saturate in the case | - | where input is -2147483648 (0x8000 0000). | - | | - | Complexity weight : 2 | - | | - | Inputs : | - | | - | L_var1 32 bit long signed integer (Word32) whose value falls in the | - | range : 0x8000 0000 <= L_var3 <= 0x7fff ffff. | - | | - | Outputs : | - | | - | none | - | | - | Return Value : | - | | - | L_var_out | - | 32 bit long signed integer (Word32) whose value falls in the | - | range : 0x8000 0000 <= L_var_out <= 0x7fff ffff. | - |___________________________________________________________________________| -*/ -//Word32 L_negate (Word32 L_var1) -//{ -// Word32 L_var_out; -// -// L_var_out = (L_var1 == MIN_32) ? MAX_32 : -L_var1; -// -// return (L_var_out); -//} - - -/*___________________________________________________________________________ - | | - | Function Name : mult_r | - | | - | Purpose : | - | | - | Same as mult with rounding, i.e.: | - | mult_r(var1,var2) = extract_l(L_shr(((var1 * var2) + 16384),15)) and | - | mult_r(-32768,-32768) = 32767. | - | | - | Complexity weight : 2 | - | | - | Inputs : | - | | - | var1 | - | 16 bit short signed integer (Word16) whose value falls in the | - | range : 0xffff 8000 <= var1 <= 0x0000 7fff. | - | | - | var2 | - | 16 bit short signed integer (Word16) whose value falls in the | - | range : 0xffff 8000 <= var1 <= 0x0000 7fff. | - | | - | Outputs : | - | | - | none | - | | - | Return Value : | - | | - | var_out | - | 16 bit short signed integer (Word16) whose value falls in the | - | range : 0xffff 8000 <= var_out <= 0x0000 7fff. | - |___________________________________________________________________________| -*/ -#if (!MULT_R_IS_INLINE) -Word16 mult_r (Word16 var1, Word16 var2) -{ - Word16 var_out; - Word32 L_product_arr; - - L_product_arr = (Word32) var1 *(Word32) var2; /* product */ - L_product_arr += (Word32) 0x00004000L; /* round */ - L_product_arr &= (Word32) 0xffff8000L; - L_product_arr >>= 15; /* shift */ - - if (L_product_arr & (Word32) 0x00010000L) /* sign extend when necessary */ - { - L_product_arr |= (Word32) 0xffff0000L; - } - var_out = saturate(L_product_arr); - - return (var_out); -} -#endif - -/*___________________________________________________________________________ - | | - | Function Name : L_shl | - | | - | Purpose : | - | | - | Arithmetically shift the 32 bit input L_var1 left var2 positions. Zero | - | fill the var2 LSB of the result. If var2 is negative, arithmetically | - | shift L_var1 right by -var2 with sign extension. Saturate the result in | - | case of underflows or overflows. | - | | - | Complexity weight : 2 | - | | - | Inputs : | - | | - | L_var1 32 bit long signed integer (Word32) whose value falls in the | - | range : 0x8000 0000 <= L_var3 <= 0x7fff ffff. | - | | - | var2 | - | 16 bit short signed integer (Word16) whose value falls in the | - | range : 0xffff 8000 <= var1 <= 0x0000 7fff. | - | | - | Outputs : | - | | - | none | - | | - | Return Value : | - | | - | L_var_out | - | 32 bit long signed integer (Word32) whose value falls in the | - | range : 0x8000 0000 <= L_var_out <= 0x7fff ffff. | - |___________________________________________________________________________| -*/ - -#if (!L_SHL_IS_INLINE) -Word32 L_shl (Word32 L_var1, Word16 var2) -{ - Word32 L_var_out = 0L; - - if (var2 <= 0) - { - L_var1 = L_shr(L_var1, (Word16)-var2); - } - else - { - for (; var2 > 0; var2--) - { - if (L_var1 > (Word32) 0X3fffffffL) - { - return MAX_32; - } - else - { - if (L_var1 < (Word32) 0xc0000000L) - { - return MIN_32; - } - } - L_var1 <<= 1; - } - } - return (L_var1); -} -#endif - -/*___________________________________________________________________________ - | | - | Function Name : L_shr | - | | - | Purpose : | - | | - | Arithmetically shift the 32 bit input L_var1 right var2 positions with | - | sign extension. If var2 is negative, arithmetically shift L_var1 left | - | by -var2 and zero fill the -var2 LSB of the result. Saturate the result | - | in case of underflows or overflows. | - | | - | Complexity weight : 2 | - | | - | Inputs : | - | | - | L_var1 32 bit long signed integer (Word32) whose value falls in the | - | range : 0x8000 0000 <= L_var3 <= 0x7fff ffff. | - | | - | var2 | - | 16 bit short signed integer (Word16) whose value falls in the | - | range : 0xffff 8000 <= var1 <= 0x0000 7fff. | - | | - | Outputs : | - | | - | none | - | | - | Return Value : | - | | - | L_var_out | - | 32 bit long signed integer (Word32) whose value falls in the | - | range : 0x8000 0000 <= L_var_out <= 0x7fff ffff. | - |___________________________________________________________________________| -*/ - -#if (!L_SHR_IS_INLINE) -Word32 L_shr (Word32 L_var1, Word16 var2) -{ - Word32 L_var_out; - - if (var2 < 0) - { - L_var_out = L_shl (L_var1, (Word16)-var2); - } - else - { - if (var2 >= 31) - { - L_var_out = (L_var1 < 0L) ? -1 : 0; - } - else - { - if (L_var1 < 0) - { - L_var_out = ~((~L_var1) >> var2); - } - else - { - L_var_out = L_var1 >> var2; - } - } - } - return (L_var_out); -} -#endif - -/*___________________________________________________________________________ - | | - | Function Name : shr_r | - | | - | Purpose : | - | | - | Same as shr(var1,var2) but with rounding. Saturate the result in case of| - | underflows or overflows : | - | - If var2 is greater than zero : | - | if (sub(shl(shr(var1,var2),1),shr(var1,sub(var2,1)))) | - | is equal to zero | - | then | - | shr_r(var1,var2) = shr(var1,var2) | - | else | - | shr_r(var1,var2) = add(shr(var1,var2),1) | - | - If var2 is less than or equal to zero : | - | shr_r(var1,var2) = shr(var1,var2). | - | | - | Complexity weight : 2 | - | | - | Inputs : | - | | - | var1 | - | 16 bit short signed integer (Word16) whose value falls in the | - | range : 0xffff 8000 <= var1 <= 0x0000 7fff. | - | | - | var2 | - | 16 bit short signed integer (Word16) whose value falls in the | - | range : 0xffff 8000 <= var1 <= 0x0000 7fff. | - | | - | Outputs : | - | | - | none | - | | - | Return Value : | - | | - | var_out | - | 16 bit short signed integer (Word16) whose value falls in the | - | range : 0xffff 8000 <= var_out <= 0x0000 7fff. | - |___________________________________________________________________________| -*/ -#if (!SHR_R_IS_INLINE) -Word16 shr_r (Word16 var1, Word16 var2) -{ - Word16 var_out; - - if (var2 > 15) - { - var_out = 0; - } - else - { - var_out = shr (var1, var2); - - if (var2 > 0) - { - if ((var1 & ((Word16) 1 << (var2 - 1))) != 0) - { - var_out++; - } - } - } - - return (var_out); -} -#endif - -/*___________________________________________________________________________ - | | - | Function Name : mac_r | - | | - | Purpose : | - | | - | Multiply var1 by var2 and shift the result left by 1. Add the 32 bit | - | result to L_var3 with saturation. Round the LS 16 bits of the result | - | into the MS 16 bits with saturation and shift the result right by 16. | - | Return a 16 bit result. | - | mac_r(L_var3,var1,var2) = round(L_mac(L_var3,var1,var2)) | - | | - | Complexity weight : 2 | - | | - | Inputs : | - | | - | L_var3 32 bit long signed integer (Word32) whose value falls in the | - | range : 0x8000 0000 <= L_var3 <= 0x7fff ffff. | - | | - | var1 | - | 16 bit short signed integer (Word16) whose value falls in the | - | range : 0xffff 8000 <= var1 <= 0x0000 7fff. | - | | - | var2 | - | 16 bit short signed integer (Word16) whose value falls in the | - | range : 0xffff 8000 <= var1 <= 0x0000 7fff. | - | | - | Outputs : | - | | - | none | - | | - | Return Value : | - | | - | var_out | - | 16 bit short signed integer (Word16) whose value falls in the | - | range : 0x0000 8000 <= L_var_out <= 0x0000 7fff. | - |___________________________________________________________________________| -*/ -#if (!MAC_R_IS_INLINE) -Word16 mac_r (Word32 L_var3, Word16 var1, Word16 var2) -{ - Word16 var_out; - - L_var3 = L_mac (L_var3, var1, var2); - L_var3 = L_add (L_var3, (Word32) 0x00008000L); - var_out = extract_h (L_var3); - - return (var_out); -} -#endif - -/*___________________________________________________________________________ - | | - | Function Name : msu_r | - | | - | Purpose : | - | | - | Multiply var1 by var2 and shift the result left by 1. Subtract the 32 | - | bit result to L_var3 with saturation. Round the LS 16 bits of the res- | - | ult into the MS 16 bits with saturation and shift the result right by | - | 16. Return a 16 bit result. | - | msu_r(L_var3,var1,var2) = round(L_msu(L_var3,var1,var2)) | - | | - | Complexity weight : 2 | - | | - | Inputs : | - | | - | L_var3 32 bit long signed integer (Word32) whose value falls in the | - | range : 0x8000 0000 <= L_var3 <= 0x7fff ffff. | - | | - | var1 | - | 16 bit short signed integer (Word16) whose value falls in the | - | range : 0xffff 8000 <= var1 <= 0x0000 7fff. | - | | - | var2 | - | 16 bit short signed integer (Word16) whose value falls in the | - | range : 0xffff 8000 <= var1 <= 0x0000 7fff. | - | | - | Outputs : | - | | - | none | - | | - | Return Value : | - | | - | var_out | - | 16 bit short signed integer (Word16) whose value falls in the | - | range : 0x0000 8000 <= L_var_out <= 0x0000 7fff. | - |___________________________________________________________________________| -*/ -#if (!MSU_R_IS_INLINE) -Word16 msu_r (Word32 L_var3, Word16 var1, Word16 var2) -{ - Word16 var_out; - - L_var3 = L_msu (L_var3, var1, var2); - L_var3 = L_add (L_var3, (Word32) 0x00008000L); - var_out = extract_h (L_var3); - - return (var_out); -} -#endif - -/*___________________________________________________________________________ - | | - | Function Name : L_deposit_h | - | | - | Purpose : | - | | - | Deposit the 16 bit var1 into the 16 MS bits of the 32 bit output. The | - | 16 LS bits of the output are zeroed. | - | | - | Complexity weight : 2 | - | | - | Inputs : | - | | - | var1 | - | 16 bit short signed integer (Word16) whose value falls in the | - | range : 0xffff 8000 <= var1 <= 0x0000 7fff. | - | | - | Outputs : | - | | - | none | - | | - | Return Value : | - | | - | L_var_out | - | 32 bit long signed integer (Word32) whose value falls in the | - | range : 0x8000 0000 <= var_out <= 0x7fff 0000. | - |___________________________________________________________________________| -*/ -//Word32 L_deposit_h (Word16 var1) -//{ -// Word32 L_var_out; -// -// L_var_out = (Word32) var1 << 16; -// -// return (L_var_out); -//} - - -/*___________________________________________________________________________ - | | - | Function Name : L_deposit_l | - | | - | Purpose : | - | | - | Deposit the 16 bit var1 into the 16 LS bits of the 32 bit output. The | - | 16 MS bits of the output are sign extended. | - | | - | Complexity weight : 2 | - | | - | Inputs : | - | | - | var1 | - | 16 bit short signed integer (Word16) whose value falls in the | - | range : 0xffff 8000 <= var1 <= 0x0000 7fff. | - | | - | Outputs : | - | | - | none | - | | - | Return Value : | - | | - | L_var_out | - | 32 bit long signed integer (Word32) whose value falls in the | - | range : 0xFFFF 8000 <= var_out <= 0x0000 7fff. | - |___________________________________________________________________________| -*/ -//Word32 L_deposit_l (Word16 var1) -//{ -// Word32 L_var_out; -// -// L_var_out = (Word32) var1; -// -// return (L_var_out); -//} - - -/*___________________________________________________________________________ - | | - | Function Name : L_shr_r | - | | - | Purpose : | - | | - | Same as L_shr(L_var1,var2) but with rounding. Saturate the result in | - | case of underflows or overflows : | - | - If var2 is greater than zero : | - | if (L_sub(L_shl(L_shr(L_var1,var2),1),L_shr(L_var1,sub(var2,1))))| - | is equal to zero | - | then | - | L_shr_r(L_var1,var2) = L_shr(L_var1,var2) | - | else | - | L_shr_r(L_var1,var2) = L_add(L_shr(L_var1,var2),1) | - | - If var2 is less than or equal to zero : | - | L_shr_r(L_var1,var2) = L_shr(L_var1,var2). | - | | - | Complexity weight : 3 | - | | - | Inputs : | - | | - | L_var1 | - | 32 bit long signed integer (Word32) whose value falls in the | - | range : 0x8000 0000 <= var1 <= 0x7fff ffff. | - | | - | var2 | - | 16 bit short signed integer (Word16) whose value falls in the | - | range : 0xffff 8000 <= var1 <= 0x0000 7fff. | - | | - | Outputs : | - | | - | none | - | | - | Return Value : | - | | - | L_var_out | - | 32 bit long signed integer (Word32) whose value falls in the | - | range : 0x8000 0000 <= var_out <= 0x7fff ffff. | - |___________________________________________________________________________| -*/ -#if (!L_SHR_R_IS_INLINE) -Word32 L_shr_r (Word32 L_var1, Word16 var2) -{ - Word32 L_var_out; - - if (var2 > 31) - { - L_var_out = 0; - } - else - { - L_var_out = L_shr (L_var1, var2); - - if (var2 > 0) - { - if ((L_var1 & ((Word32) 1 << (var2 - 1))) != 0) - { - L_var_out++; - } - } - } - - return (L_var_out); -} -#endif - -/*___________________________________________________________________________ - | | - | Function Name : L_abs | - | | - | Purpose : | - | | - | Absolute value of L_var1; Saturate in case where the input is | - | -214783648 | - | | - | Complexity weight : 3 | - | | - | Inputs : | - | | - | L_var1 | - | 32 bit long signed integer (Word32) whose value falls in the | - | range : 0x8000 0000 <= var1 <= 0x7fff ffff. | - | | - | Outputs : | - | | - | none | - | | - | Return Value : | - | | - | L_var_out | - | 32 bit long signed integer (Word32) whose value falls in the | - | range : 0x0000 0000 <= var_out <= 0x7fff ffff. | - |___________________________________________________________________________| -*/ -//Word32 L_abs (Word32 L_var1) -//{ -// Word32 L_var_out; -// -// if (L_var1 == MIN_32) -// { -// L_var_out = MAX_32; -// } -// else -// { -// if (L_var1 < 0) -// { -// L_var_out = -L_var1; -// } -// else -// { -// L_var_out = L_var1; -// } -// } -// -// return (L_var_out); -//} - -/*___________________________________________________________________________ - | | - | Function Name : norm_s | - | | - | Purpose : | - | | - | Produces the number of left shift needed to normalize the 16 bit varia- | - | ble var1 for positive values on the interval with minimum of 16384 and | - | maximum of 32767, and for negative values on the interval with minimum | - | of -32768 and maximum of -16384; in order to normalize the result, the | - | following operation must be done : | - | norm_var1 = shl(var1,norm_s(var1)). | - | | - | Complexity weight : 15 | - | | - | Inputs : | - | | - | var1 | - | 16 bit short signed integer (Word16) whose value falls in the | - | range : 0xffff 8000 <= var1 <= 0x0000 7fff. | - | | - | Outputs : | - | | - | none | - | | - | Return Value : | - | | - | var_out | - | 16 bit short signed integer (Word16) whose value falls in the | - | range : 0x0000 0000 <= var_out <= 0x0000 000f. | - |___________________________________________________________________________| -*/ - -#if (!NORM_S_IS_INLINE) -Word16 norm_s (Word16 var1) -{ - Word16 var_out; - - if (var1 == 0) - { - var_out = 0; - } - else - { - if (var1 == -1) - { - var_out = 15; - } - else - { - if (var1 < 0) - { - var1 = (Word16)~var1; - } - for (var_out = 0; var1 < 0x4000; var_out++) - { - var1 <<= 1; - } - } - } - - return (var_out); -} -#endif - -/*___________________________________________________________________________ - | | - | Function Name : div_s | - | | - | Purpose : | - | | - | Produces a result which is the fractional integer division of var1 by | - | var2; var1 and var2 must be positive and var2 must be greater or equal | - | to var1; the result is positive (leading bit equal to 0) and truncated | - | to 16 bits. | - | If var1 = var2 then div(var1,var2) = 32767. | - | | - | Complexity weight : 18 | - | | - | Inputs : | - | | - | var1 | - | 16 bit short signed integer (Word16) whose value falls in the | - | range : 0x0000 0000 <= var1 <= var2 and var2 != 0. | - | | - | var2 | - | 16 bit short signed integer (Word16) whose value falls in the | - | range : var1 <= var2 <= 0x0000 7fff and var2 != 0. | - | | - | Outputs : | - | | - | none | - | | - | Return Value : | - | | - | var_out | - | 16 bit short signed integer (Word16) whose value falls in the | - | range : 0x0000 0000 <= var_out <= 0x0000 7fff. | - | It's a Q15 value (point between b15 and b14). | - |___________________________________________________________________________| -*/ - -#if (!DIV_S_IS_INLINE) -Word16 div_s (Word16 var1, Word16 var2) -{ - Word16 var_out = 0; - Word16 iteration; - Word32 L_num; - Word32 L_denom; - - if (var1 == 0) - { - var_out = 0; - } - else - { - if (var1 == var2) - { - var_out = MAX_16; - } - else - { - L_num = L_deposit_l (var1); - L_denom = L_deposit_l (var2); - - for (iteration = 0; iteration < 15; iteration++) - { - var_out <<= 1; - L_num <<= 1; - - if (L_num >= L_denom) - { - L_num = L_sub(L_num, L_denom); - var_out = add (var_out, 1); - } - } - } - } - - return (var_out); -} -#endif - -/*___________________________________________________________________________ - | | - | Function Name : norm_l | - | | - | Purpose : | - | | - | Produces the number of left shifts needed to normalize the 32 bit varia-| - | ble L_var1 for positive values on the interval with minimum of | - | 1073741824 and maximum of 2147483647, and for negative values on the in-| - | terval with minimum of -2147483648 and maximum of -1073741824; in order | - | to normalize the result, the following operation must be done : | - | norm_L_var1 = L_shl(L_var1,norm_l(L_var1)). | - | | - | Complexity weight : 30 | - | | - | Inputs : | - | | - | L_var1 | - | 32 bit long signed integer (Word32) whose value falls in the | - | range : 0x8000 0000 <= var1 <= 0x7fff ffff. | - | | - | Outputs : | - | | - | none | - | | - | Return Value : | - | | - | var_out | - | 16 bit short signed integer (Word16) whose value falls in the | - | range : 0x0000 0000 <= var_out <= 0x0000 001f. | - |___________________________________________________________________________| -*/ - -#if (!NORM_L_IS_INLINE) -Word16 norm_l (Word32 L_var1) -{ - Word16 var_out; - - if (L_var1 == 0) - { - var_out = 0; - } - else - { - if (L_var1 == (Word32) 0xffffffffL) - { - var_out = 31; - } - else - { - if (L_var1 < 0) - { - L_var1 = ~L_var1; - } - for (var_out = 0; L_var1 < (Word32) 0x40000000L; var_out++) - { - L_var1 <<= 1; - } - } - } - - return (var_out); -} -#endif - diff --git a/android-aac-enc/jni/basic_op/oper_32b.c b/android-aac-enc/jni/basic_op/oper_32b.c deleted file mode 100644 index 982f4fd44..000000000 --- a/android-aac-enc/jni/basic_op/oper_32b.c +++ /dev/null @@ -1,361 +0,0 @@ -/* - ** Copyright 2003-2010, VisualOn, Inc. - ** - ** Licensed under the Apache License, Version 2.0 (the "License"); - ** you may not use this file except in compliance with the License. - ** You may obtain a copy of the License at - ** - ** http://www.apache.org/licenses/LICENSE-2.0 - ** - ** Unless required by applicable law or agreed to in writing, software - ** distributed under the License is distributed on an "AS IS" BASIS, - ** WITHOUT 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: oper_32b.c - - Content: This file contains operations in double precision. - -*******************************************************************************/ - -#include "typedef.h" -#include "basic_op.h" -#include "oper_32b.h" - -/***************************************************************************** - * * - * Function L_Extract() * - * * - * Extract from a 32 bit integer two 16 bit DPF. * - * * - * Arguments: * - * * - * L_32 : 32 bit integer. * - * 0x8000 0000 <= L_32 <= 0x7fff ffff. * - * hi : b16 to b31 of L_32 * - * lo : (L_32 - hi<<16)>>1 * - ***************************************************************************** -*/ - -void L_Extract (Word32 L_32, Word16 *hi, Word16 *lo) -{ - *hi = extract_h (L_32); - *lo = extract_l (L_msu (L_shr (L_32, 1), *hi, 16384)); - return; -} - -/***************************************************************************** - * * - * Function L_Comp() * - * * - * Compose from two 16 bit DPF a 32 bit integer. * - * * - * L_32 = hi<<16 + lo<<1 * - * * - * Arguments: * - * * - * hi msb * - * lo lsf (with sign) * - * * - * Return Value : * - * * - * 32 bit long signed integer (Word32) whose value falls in the * - * range : 0x8000 0000 <= L_32 <= 0x7fff fff0. * - * * - ***************************************************************************** -*/ - -Word32 L_Comp (Word16 hi, Word16 lo) -{ - Word32 L_32; - - L_32 = L_deposit_h (hi); - return (L_mac (L_32, lo, 1)); /* = hi<<16 + lo<<1 */ -} - -/***************************************************************************** - * Function Mpy_32() * - * * - * Multiply two 32 bit integers (DPF). The result is divided by 2**31 * - * * - * L_32 = (hi1*hi2)<<1 + ( (hi1*lo2)>>15 + (lo1*hi2)>>15 )<<1 * - * * - * This operation can also be viewed as the multiplication of two Q31 * - * number and the result is also in Q31. * - * * - * Arguments: * - * * - * hi1 hi part of first number * - * lo1 lo part of first number * - * hi2 hi part of second number * - * lo2 lo part of second number * - * * - ***************************************************************************** -*/ - -Word32 Mpy_32 (Word16 hi1, Word16 lo1, Word16 hi2, Word16 lo2) -{ - Word32 L_32; - - L_32 = L_mult (hi1, hi2); - L_32 = L_mac (L_32, mult (hi1, lo2), 1); - L_32 = L_mac (L_32, mult (lo1, hi2), 1); - - return (L_32); -} - -/***************************************************************************** - * Function Mpy_32_16() * - * * - * Multiply a 16 bit integer by a 32 bit (DPF). The result is divided * - * by 2**15 * - * * - * * - * L_32 = (hi1*lo2)<<1 + ((lo1*lo2)>>15)<<1 * - * * - * Arguments: * - * * - * hi hi part of 32 bit number. * - * lo lo part of 32 bit number. * - * n 16 bit number. * - * * - ***************************************************************************** -*/ - -Word32 Mpy_32_16 (Word16 hi, Word16 lo, Word16 n) -{ - Word32 L_32; - - L_32 = L_mult (hi, n); - L_32 = L_mac (L_32, mult (lo, n), 1); - - return (L_32); -} - -/***************************************************************************** - * * - * Function Name : Div_32 * - * * - * Purpose : * - * Fractional integer division of two 32 bit numbers. * - * L_num / L_denom. * - * L_num and L_denom must be positive and L_num < L_denom. * - * L_denom = denom_hi<<16 + denom_lo<<1 * - * denom_hi is a normalize number. * - * * - * Inputs : * - * * - * L_num * - * 32 bit long signed integer (Word32) whose value falls in the * - * range : 0x0000 0000 < L_num < L_denom * - * * - * L_denom = denom_hi<<16 + denom_lo<<1 (DPF) * - * * - * denom_hi * - * 16 bit positive normalized integer whose value falls in the * - * range : 0x4000 < hi < 0x7fff * - * denom_lo * - * 16 bit positive integer whose value falls in the * - * range : 0 < lo < 0x7fff * - * * - * Return Value : * - * * - * L_div * - * 32 bit long signed integer (Word32) whose value falls in the * - * range : 0x0000 0000 <= L_div <= 0x7fff ffff. * - * * - * Algorithm: * - * * - * - find = 1/L_denom. * - * First approximation: approx = 1 / denom_hi * - * 1/L_denom = approx * (2.0 - L_denom * approx ) * - * * - * - result = L_num * (1/L_denom) * - ***************************************************************************** -*/ - -Word32 Div_32 (Word32 L_num, Word32 denom) -{ - Word16 approx; - Word32 L_32; - /* First approximation: 1 / L_denom = 1/denom_hi */ - - approx = div_s ((Word16) 0x3fff, denom >> 16); - - /* 1/L_denom = approx * (2.0 - L_denom * approx) */ - - L_32 = L_mpy_ls (denom, approx); - - L_32 = L_sub ((Word32) 0x7fffffffL, L_32); - - L_32 = L_mpy_ls (L_32, approx); - /* L_num * (1/L_denom) */ - - L_32 = MULHIGH(L_32, L_num); - L_32 = L_shl (L_32, 3); - - return (L_32); -} - -/*! - - \brief calculates the log dualis times 4 of argument - iLog4(x) = (Word32)(4 * log(value)/log(2.0)) - - \return ilog4 value - -*/ -Word16 iLog4(Word32 value) -{ - Word16 iLog4; - - if(value != 0){ - Word32 tmp; - Word16 tmp16; - iLog4 = norm_l(value); - tmp = (value << iLog4); - tmp16 = round16(tmp); - tmp = L_mult(tmp16, tmp16); - tmp16 = round16(tmp); - tmp = L_mult(tmp16, tmp16); - tmp16 = round16(tmp); - - iLog4 = (-(iLog4 << 2) - norm_s(tmp16)) - 1; - } - else { - iLog4 = -128; /* -(INT_BITS*4); */ - } - - return iLog4; -} - -#define step(shift) \ - if ((0x40000000l >> shift) + root <= value) \ - { \ - value -= (0x40000000l >> shift) + root; \ - root = (root >> 1) | (0x40000000l >> shift); \ - } else { \ - root = root >> 1; \ - } - -Word32 rsqrt(Word32 value, /*!< Operand to square root (0.0 ... 1) */ - Word32 accuracy) /*!< Number of valid bits that will be calculated */ -{ - Word32 root = 0; - Word32 scale; - - if(value < 0) - return 0; - - scale = norm_l(value); - if(scale & 1) scale--; - - value <<= scale; - - step( 0); step( 2); step( 4); step( 6); - step( 8); step(10); step(12); step(14); - step(16); step(18); step(20); step(22); - step(24); step(26); step(28); step(30); - - scale >>= 1; - if (root < value) - ++root; - - root >>= scale; - return root* 46334; -} - -static const Word32 pow2Table[POW2_TABLE_SIZE] = { -0x7fffffff, 0x7fa765ad, 0x7f4f08ae, 0x7ef6e8da, -0x7e9f0606, 0x7e476009, 0x7deff6b6, 0x7d98c9e6, -0x7d41d96e, 0x7ceb2523, 0x7c94acde, 0x7c3e7073, -0x7be86fb9, 0x7b92aa88, 0x7b3d20b6, 0x7ae7d21a, -0x7a92be8b, 0x7a3de5df, 0x79e947ef, 0x7994e492, -0x7940bb9e, 0x78ecccec, 0x78991854, 0x78459dac, -0x77f25cce, 0x779f5591, 0x774c87cc, 0x76f9f359, -0x76a7980f, 0x765575c8, 0x76038c5b, 0x75b1dba2, -0x75606374, 0x750f23ab, 0x74be1c20, 0x746d4cac, -0x741cb528, 0x73cc556d, 0x737c2d55, 0x732c3cba, -0x72dc8374, 0x728d015d, 0x723db650, 0x71eea226, -0x719fc4b9, 0x71511de4, 0x7102ad80, 0x70b47368, -0x70666f76, 0x7018a185, 0x6fcb096f, 0x6f7da710, -0x6f307a41, 0x6ee382de, 0x6e96c0c3, 0x6e4a33c9, -0x6dfddbcc, 0x6db1b8a8, 0x6d65ca38, 0x6d1a1057, -0x6cce8ae1, 0x6c8339b2, 0x6c381ca6, 0x6bed3398, -0x6ba27e66, 0x6b57fce9, 0x6b0daeff, 0x6ac39485, -0x6a79ad56, 0x6a2ff94f, 0x69e6784d, 0x699d2a2c, -0x69540ec9, 0x690b2601, 0x68c26fb1, 0x6879ebb6, -0x683199ed, 0x67e97a34, 0x67a18c68, 0x6759d065, -0x6712460b, 0x66caed35, 0x6683c5c3, 0x663ccf92, -0x65f60a80, 0x65af766a, 0x6569132f, 0x6522e0ad, -0x64dcdec3, 0x64970d4f, 0x64516c2e, 0x640bfb41, -0x63c6ba64, 0x6381a978, 0x633cc85b, 0x62f816eb, -0x62b39509, 0x626f4292, 0x622b1f66, 0x61e72b65, -0x61a3666d, 0x615fd05f, 0x611c6919, 0x60d9307b, -0x60962665, 0x60534ab7, 0x60109d51, 0x5fce1e12, -0x5f8bccdb, 0x5f49a98c, 0x5f07b405, 0x5ec5ec26, -0x5e8451d0, 0x5e42e4e3, 0x5e01a540, 0x5dc092c7, -0x5d7fad59, 0x5d3ef4d7, 0x5cfe6923, 0x5cbe0a1c, -0x5c7dd7a4, 0x5c3dd19c, 0x5bfdf7e5, 0x5bbe4a61, -0x5b7ec8f2, 0x5b3f7377, 0x5b0049d4, 0x5ac14bea, -0x5a82799a, 0x5a43d2c6, 0x5a055751, 0x59c7071c, -0x5988e209, 0x594ae7fb, 0x590d18d3, 0x58cf7474, -0x5891fac1, 0x5854ab9b, 0x581786e6, 0x57da8c83, -0x579dbc57, 0x57611642, 0x57249a29, 0x56e847ef, -0x56ac1f75, 0x567020a0, 0x56344b52, 0x55f89f70, -0x55bd1cdb, 0x5581c378, 0x55469329, 0x550b8bd4, -0x54d0ad5b, 0x5495f7a1, 0x545b6a8b, 0x542105fd, -0x53e6c9db, 0x53acb607, 0x5372ca68, 0x533906e0, -0x52ff6b55, 0x52c5f7aa, 0x528cabc3, 0x52538786, -0x521a8ad7, 0x51e1b59a, 0x51a907b4, 0x5170810b, -0x51382182, 0x50ffe8fe, 0x50c7d765, 0x508fec9c, -0x50582888, 0x50208b0e, 0x4fe91413, 0x4fb1c37c, -0x4f7a9930, 0x4f439514, 0x4f0cb70c, 0x4ed5ff00, -0x4e9f6cd4, 0x4e69006e, 0x4e32b9b4, 0x4dfc988c, -0x4dc69cdd, 0x4d90c68b, 0x4d5b157e, 0x4d25899c, -0x4cf022ca, 0x4cbae0ef, 0x4c85c3f1, 0x4c50cbb8, -0x4c1bf829, 0x4be7492b, 0x4bb2bea5, 0x4b7e587d, -0x4b4a169c, 0x4b15f8e6, 0x4ae1ff43, 0x4aae299b, -0x4a7a77d5, 0x4a46e9d6, 0x4a137f88, 0x49e038d0, -0x49ad1598, 0x497a15c4, 0x4947393f, 0x49147fee, -0x48e1e9ba, 0x48af768a, 0x487d2646, 0x484af8d6, -0x4818ee22, 0x47e70611, 0x47b5408c, 0x47839d7b, -0x47521cc6, 0x4720be55, 0x46ef8210, 0x46be67e0, -0x468d6fae, 0x465c9961, 0x462be4e2, 0x45fb521a, -0x45cae0f2, 0x459a9152, 0x456a6323, 0x453a564d, -0x450a6abb, 0x44daa054, 0x44aaf702, 0x447b6ead, -0x444c0740, 0x441cc0a3, 0x43ed9ac0, 0x43be9580, -0x438fb0cb, 0x4360ec8d, 0x433248ae, 0x4303c517, -0x42d561b4, 0x42a71e6c, 0x4278fb2b, 0x424af7da, -0x421d1462, 0x41ef50ae, 0x41c1aca8, 0x41942839, -0x4166c34c, 0x41397dcc, 0x410c57a2, 0x40df50b8, -0x40b268fa, 0x4085a051, 0x4058f6a8, 0x402c6be9 -}; - -/*! - - \brief calculates 2 ^ (x/y) for x<=0, y > 0, x <= 32768 * y - - avoids integer division - - \return -*/ -Word32 pow2_xy(Word32 x, Word32 y) -{ - Word32 iPart; - Word32 fPart; - Word32 res; - Word32 tmp, tmp2; - Word32 shift, shift2; - - tmp2 = -x; - iPart = tmp2 / y; - fPart = tmp2 - iPart*y; - iPart = min(iPart,INT_BITS-1); - - res = pow2Table[(POW2_TABLE_SIZE*fPart)/y] >> iPart; - - return(res); -} diff --git a/android-aac-enc/jni/doc/voAACEncoderSDK.pdf b/android-aac-enc/jni/doc/voAACEncoderSDK.pdf deleted file mode 100644 index 874d0f7fc..000000000 Binary files a/android-aac-enc/jni/doc/voAACEncoderSDK.pdf and /dev/null differ diff --git a/android-aac-enc/jni/inc/aac_rom.h b/android-aac-enc/jni/inc/aac_rom.h deleted file mode 100644 index 8e206b7fb..000000000 --- a/android-aac-enc/jni/inc/aac_rom.h +++ /dev/null @@ -1,117 +0,0 @@ -/* - ** Copyright 2003-2010, VisualOn, Inc. - ** - ** Licensed under the Apache License, Version 2.0 (the "License"); - ** you may not use this file except in compliance with the License. - ** You may obtain a copy of the License at - ** - ** http://www.apache.org/licenses/LICENSE-2.0 - ** - ** Unless required by applicable law or agreed to in writing, software - ** distributed under the License is distributed on an "AS IS" BASIS, - ** WITHOUT 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: aac_rom.h - - Content: constant tables - -*******************************************************************************/ - -#ifndef ROM_H -#define ROM_H - -#include "config.h" -#include "psy_const.h" -#include "tns_param.h" - -/* - mdct -*/ -extern const int ShortWindowSine[FRAME_LEN_SHORT/2]; -extern const int LongWindowKBD[FRAME_LEN_LONG/2]; - -extern const unsigned char bitrevTab[17 + 129]; -extern const int cossintab[128 + 1024]; - -#if defined (ARMV5E) && !defined (ARMV7Neon) -extern const int twidTab64[(4*6 + 16*6)/2]; -extern const int twidTab512[(8*6 + 32*6 + 128*6)/2]; -#else -extern const int twidTab64[4*6 + 16*6]; -extern const int twidTab512[8*6 + 32*6 + 128*6]; -#endif - -/* - form factor -*/ -extern const Word32 formfac_sqrttable[96]; - -/* - quantizer -*/ -extern const Word32 mTab_3_4[512]; -extern const Word32 mTab_4_3[512]; -/*! $2^{-\frac{n}{16}}$ table */ -extern const Word16 pow2tominusNover16[17] ; - -extern Word32 specExpMantTableComb_enc[4][14]; -extern const UWord8 specExpTableComb_enc[4][14]; - -extern const Word16 quantBorders[4][4]; -//extern const Word16 quantRecon[3][4]; -extern const Word16 quantRecon[4][3]; - -/* - huffman -*/ -extern const UWord16 huff_ltab1_2[3][3][3][3]; -extern const UWord16 huff_ltab3_4[3][3][3][3]; -extern const UWord16 huff_ltab5_6[9][9]; -extern const UWord16 huff_ltab7_8[8][8]; -extern const UWord16 huff_ltab9_10[13][13]; -extern const UWord16 huff_ltab11[17][17]; -extern const UWord16 huff_ltabscf[121]; -extern const UWord16 huff_ctab1[3][3][3][3]; -extern const UWord16 huff_ctab2[3][3][3][3]; -extern const UWord16 huff_ctab3[3][3][3][3]; -extern const UWord16 huff_ctab4[3][3][3][3]; -extern const UWord16 huff_ctab5[9][9]; -extern const UWord16 huff_ctab6[9][9]; -extern const UWord16 huff_ctab7[8][8]; -extern const UWord16 huff_ctab8[8][8]; -extern const UWord16 huff_ctab9[13][13]; -extern const UWord16 huff_ctab10[13][13]; -extern const UWord16 huff_ctab11[17][17]; -extern const UWord32 huff_ctabscf[121]; - - - -/* - misc -*/ -extern const int sampRateTab[NUM_SAMPLE_RATES]; -extern const int BandwithCoefTab[8][NUM_SAMPLE_RATES]; -extern const int rates[8]; -extern const UWord8 sfBandTotalShort[NUM_SAMPLE_RATES]; -extern const UWord8 sfBandTotalLong[NUM_SAMPLE_RATES]; -extern const int sfBandTabShortOffset[NUM_SAMPLE_RATES]; -extern const short sfBandTabShort[76]; -extern const int sfBandTabLongOffset[NUM_SAMPLE_RATES]; -extern const short sfBandTabLong[325]; - -extern const Word32 m_log2_table[INT_BITS]; - -/* - TNS -*/ -extern const Word32 tnsCoeff3[8]; -extern const Word32 tnsCoeff3Borders[8]; -extern const Word32 tnsCoeff4[16]; -extern const Word32 tnsCoeff4Borders[16]; -extern const Word32 invSBF[24]; -extern const Word16 sideInfoTabLong[MAX_SFB_LONG + 1]; -extern const Word16 sideInfoTabShort[MAX_SFB_SHORT + 1]; -#endif diff --git a/android-aac-enc/jni/inc/aacenc_core.h b/android-aac-enc/jni/inc/aacenc_core.h deleted file mode 100644 index bb75b6dc4..000000000 --- a/android-aac-enc/jni/inc/aacenc_core.h +++ /dev/null @@ -1,117 +0,0 @@ -/* - ** Copyright 2003-2010, VisualOn, Inc. - ** - ** Licensed under the Apache License, Version 2.0 (the "License"); - ** you may not use this file except in compliance with the License. - ** You may obtain a copy of the License at - ** - ** http://www.apache.org/licenses/LICENSE-2.0 - ** - ** Unless required by applicable law or agreed to in writing, software - ** distributed under the License is distributed on an "AS IS" BASIS, - ** WITHOUT 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: aacenc_core.h - - Content: aac encoder interface functions - -*******************************************************************************/ - -#ifndef _aacenc_core_h_ -#define _aacenc_core_h_ - - -#include "typedef.h" -#include "config.h" -#include "bitenc.h" - -#include "psy_configuration.h" -#include "psy_main.h" -#include "qc_main.h" -#include "psy_main.h" -/*-------------------------- defines --------------------------------------*/ - - -/*-------------------- structure definitions ------------------------------*/ -typedef struct { - Word32 sampleRate; /* audio file sample rate */ - Word32 bitRate; /* encoder bit rate in bits/sec */ - Word16 nChannelsIn; /* number of channels on input (1,2) */ - Word16 nChannelsOut; /* number of channels on output (1,2) */ - Word16 bandWidth; /* targeted audio bandwidth in Hz */ - Word16 adtsUsed; /* whether write adts header */ -} AACENC_CONFIG; - - -typedef struct { - - AACENC_CONFIG config; /* Word16 size: 8 */ - - ELEMENT_INFO elInfo; /* Word16 size: 4 */ - - QC_STATE qcKernel; /* Word16 size: 6 + 5(PADDING) + 7(ELEMENT_BITS) + 54(ADJ_THR_STATE) = 72 */ - QC_OUT qcOut; /* Word16 size: MAX_CHANNELS*920(QC_OUT_CHANNEL) + 5(QC_OUT_ELEMENT) + 7 = 932 / 1852 */ - - PSY_OUT psyOut; /* Word16 size: MAX_CHANNELS*186 + 2 = 188 / 374 */ - PSY_KERNEL psyKernel; /* Word16 size: 2587 / 4491 */ - - struct BITSTREAMENCODER_INIT bseInit; /* Word16 size: 6 */ - struct BIT_BUF bitStream; /* Word16 size: 8 */ - HANDLE_BIT_BUF hBitStream; - int initOK; - - short *intbuf; - short *encbuf; - short *inbuf; - int enclen; - int inlen; - int intlen; - int uselength; - - void *hCheck; - VO_MEM_OPERATOR *voMemop; - VO_MEM_OPERATOR voMemoprator; - -}AAC_ENCODER; /* Word16 size: 3809 / 6851 */ - -/*----------------------------------------------------------------------------- - -functionname: AacInitDefaultConfig -description: gives reasonable default configuration -returns: --- - -------------------------------------------------------------------------------*/ -void AacInitDefaultConfig(AACENC_CONFIG *config); - -/*--------------------------------------------------------------------------- - -functionname:AacEncOpen -description: allocate and initialize a new encoder instance -returns: AACENC_OK if success - ----------------------------------------------------------------------------*/ - -Word16 AacEncOpen (AAC_ENCODER *hAacEnc, /* pointer to an encoder handle, initialized on return */ - const AACENC_CONFIG config); /* pre-initialized config struct */ - -Word16 AacEncEncode(AAC_ENCODER *hAacEnc, - Word16 *timeSignal, - const UWord8 *ancBytes, /*!< pointer to ancillary data bytes */ - Word16 *numAncBytes, /*!< number of ancillary Data Bytes, send as fill element */ - UWord8 *outBytes, /*!< pointer to output buffer */ - VO_U32 *numOutBytes /*!< number of bytes in output buffer */ - ); - -/*--------------------------------------------------------------------------- - -functionname:AacEncClose -description: deallocate an encoder instance - ----------------------------------------------------------------------------*/ - -void AacEncClose (AAC_ENCODER* hAacEnc, VO_MEM_OPERATOR *pMemOP); /* an encoder handle */ - -#endif /* _aacenc_h_ */ diff --git a/android-aac-enc/jni/inc/adj_thr.h b/android-aac-enc/jni/inc/adj_thr.h deleted file mode 100644 index 0f4bb5e6c..000000000 --- a/android-aac-enc/jni/inc/adj_thr.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - ** Copyright 2003-2010, VisualOn, Inc. - ** - ** Licensed under the Apache License, Version 2.0 (the "License"); - ** you may not use this file except in compliance with the License. - ** You may obtain a copy of the License at - ** - ** http://www.apache.org/licenses/LICENSE-2.0 - ** - ** Unless required by applicable law or agreed to in writing, software - ** distributed under the License is distributed on an "AS IS" BASIS, - ** WITHOUT 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: adj_thr.h - - Content: Threshold compensation function - -*******************************************************************************/ - -#ifndef __ADJ_THR_H -#define __ADJ_THR_H - -#include "adj_thr_data.h" -#include "qc_data.h" -#include "interface.h" - -Word16 bits2pe(const Word16 bits); - -Word32 AdjThrNew(ADJ_THR_STATE** phAdjThr, - Word32 nElements); - -void AdjThrDelete(ADJ_THR_STATE *hAdjThr); - -void AdjThrInit(ADJ_THR_STATE *hAdjThr, - const Word32 peMean, - Word32 chBitrate); - -void AdjustThresholds(ADJ_THR_STATE *adjThrState, - ATS_ELEMENT* AdjThrStateElement, - PSY_OUT_CHANNEL psyOutChannel[MAX_CHANNELS], - PSY_OUT_ELEMENT *psyOutElement, - Word16 *chBitDistribution, - Word16 logSfbEnergy[MAX_CHANNELS][MAX_GROUPED_SFB], - Word16 sfbNRelevantLines[MAX_CHANNELS][MAX_GROUPED_SFB], - QC_OUT_ELEMENT* qcOE, - ELEMENT_BITS* elBits, - const Word16 nChannels, - const Word16 maxBitFac); - -void AdjThrUpdate(ATS_ELEMENT *AdjThrStateElement, - const Word16 dynBitsUsed); - - -#endif diff --git a/android-aac-enc/jni/inc/adj_thr_data.h b/android-aac-enc/jni/inc/adj_thr_data.h deleted file mode 100644 index 30132d854..000000000 --- a/android-aac-enc/jni/inc/adj_thr_data.h +++ /dev/null @@ -1,69 +0,0 @@ -/* - ** Copyright 2003-2010, VisualOn, Inc. - ** - ** Licensed under the Apache License, Version 2.0 (the "License"); - ** you may not use this file except in compliance with the License. - ** You may obtain a copy of the License at - ** - ** http://www.apache.org/licenses/LICENSE-2.0 - ** - ** Unless required by applicable law or agreed to in writing, software - ** distributed under the License is distributed on an "AS IS" BASIS, - ** WITHOUT 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: adj_thr_data.h - - Content: Threshold compensation parameter - -*******************************************************************************/ - -#ifndef __ADJ_THR_DATA_H -#define __ADJ_THR_DATA_H - -#include "typedef.h" -#include "psy_const.h" -#include "line_pe.h" - -typedef struct { - Word16 clipSaveLow, clipSaveHigh; - Word16 minBitSave, maxBitSave; - Word16 clipSpendLow, clipSpendHigh; - Word16 minBitSpend, maxBitSpend; -} BRES_PARAM; - -typedef struct { - UWord8 modifyMinSnr; - Word16 startSfbL, startSfbS; -} AH_PARAM; - -typedef struct { - Word32 maxRed; - Word32 startRatio, maxRatio; - Word32 redRatioFac; - Word32 redOffs; -} MINSNR_ADAPT_PARAM; - -typedef struct { - /* parameters for bitreservoir control */ - Word16 peMin, peMax; - /* constant offset to pe */ - Word16 peOffset; - /* avoid hole parameters */ - AH_PARAM ahParam; - /* paramters for adaptation of minSnr */ - MINSNR_ADAPT_PARAM minSnrAdaptParam; - /* values for correction of pe */ - Word16 peLast; - Word16 dynBitsLast; - Word16 peCorrectionFactor; -} ATS_ELEMENT; - -typedef struct { - BRES_PARAM bresParamLong, bresParamShort; /* Word16 size: 2*8 */ - ATS_ELEMENT adjThrStateElem; /* Word16 size: 19 */ -} ADJ_THR_STATE; - -#endif diff --git a/android-aac-enc/jni/inc/band_nrg.h b/android-aac-enc/jni/inc/band_nrg.h deleted file mode 100644 index 65453c0a3..000000000 --- a/android-aac-enc/jni/inc/band_nrg.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - ** Copyright 2003-2010, VisualOn, Inc. - ** - ** Licensed under the Apache License, Version 2.0 (the "License"); - ** you may not use this file except in compliance with the License. - ** You may obtain a copy of the License at - ** - ** http://www.apache.org/licenses/LICENSE-2.0 - ** - ** Unless required by applicable law or agreed to in writing, software - ** distributed under the License is distributed on an "AS IS" BASIS, - ** WITHOUT 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: band_nrg.h - - Content: Band/Line energy calculations functions - -*******************************************************************************/ - - -#ifndef _BAND_NRG_H -#define _BAND_NRG_H - -#include "typedef.h" - - -void CalcBandEnergy(const Word32 *mdctSpectrum, - const Word16 *bandOffset, - const Word16 numBands, - Word32 *bandEnergy, - Word32 *bandEnergySum); - - -void CalcBandEnergyMS(const Word32 *mdctSpectrumLeft, - const Word32 *mdctSpectrumRight, - const Word16 *bandOffset, - const Word16 numBands, - Word32 *bandEnergyMid, - Word32 *bandEnergyMidSum, - Word32 *bandEnergySide, - Word32 *bandEnergySideSum); - -#endif diff --git a/android-aac-enc/jni/inc/basic_op.h b/android-aac-enc/jni/inc/basic_op.h deleted file mode 100644 index 0755eb7a7..000000000 --- a/android-aac-enc/jni/inc/basic_op.h +++ /dev/null @@ -1,1171 +0,0 @@ -/* - ** Copyright 2003-2010, VisualOn, Inc. - ** - ** Licensed under the Apache License, Version 2.0 (the "License"); - ** you may not use this file except in compliance with the License. - ** You may obtain a copy of the License at - ** - ** http://www.apache.org/licenses/LICENSE-2.0 - ** - ** Unless required by applicable law or agreed to in writing, software - ** distributed under the License is distributed on an "AS IS" BASIS, - ** WITHOUT 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: basicop2.h - - Content: Constants , Globals and Basic arithmetic operators. - -*******************************************************************************/ - -#ifndef __BASIC_OP_H -#define __BASIC_OP_H - -#include "typedef.h" - -#define MAX_32 (Word32)0x7fffffffL -#define MIN_32 (Word32)0x80000000L - -#define MAX_16 (Word16)0x7fff -#define MIN_16 (Word16)0x8000 -#define ABS(a) ((a) >= 0) ? (a) : (-(a)) - -/* Short abs, 1 */ -#define abs_s(x) (((x) != MIN_16) ? (((x) >= 0) ? (x) : (-(x))) : MAX_16) - -/* 16 bit var1 -> MSB, 2 */ -#define L_deposit_h(x) (((Word32)(x)) << 16) - - -/* 16 bit var1 -> LSB, 2 */ -#define L_deposit_l(x) ((Word32)(x)) - - -/* Long abs, 3 */ -#define L_abs(x) (((x) != MIN_32) ? (((x) >= 0) ? (x) : (-(x))) : MAX_32) - - -/* Short negate, 1 */ -#define negate(var1) (((var1) == MIN_16) ? MAX_16 : (-(var1))) - - -/* Long negate, 2 */ -#define L_negate(L_var1) (((L_var1) == (MIN_32)) ? (MAX_32) : (-(L_var1))) - - -#define MULHIGH(A,B) (int)(((Word64)(A)*(Word64)(B)) >> 32) -#define fixmul(a, b) (int)((((Word64)(a)*(Word64)(b)) >> 32) << 1) - - -#if (SATRUATE_IS_INLINE) -__inline Word32 saturate(Word32 L_var1); -#else -Word16 saturate(Word32 L_var1); -#endif - -/* Short shift left, 1 */ -#if (SHL_IS_INLINE) -__inline Word32 shl (Word32 var1, Word32 var2); -#else -Word16 shl (Word16 var1, Word16 var2); -#endif - -/* Short shift right, 1 */ -#if (SHR_IS_INLINE) -__inline Word32 shr (Word32 var1, Word32 var2); -#else -Word16 shr (Word16 var1, Word16 var2); -#endif - -#if (L_MULT_IS_INLINE) -__inline Word32 L_mult(Word32 var1, Word32 var2); -#else -Word32 L_mult(Word16 var1, Word16 var2); -#endif - -/* Msu, 1 */ -#if (L_MSU_IS_INLINE) -__inline Word32 L_msu (Word32 L_var3, Word32 var1, Word32 var2); -#else -Word32 L_msu (Word32 L_var3, Word16 var1, Word16 var2); -#endif - -/* Long sub, 2 */ -#if (L_SUB_IS_INLINE) -__inline Word32 L_sub(Word32 L_var1, Word32 L_var2); -#else -Word32 L_sub(Word32 L_var1, Word32 L_var2); -#endif - -/* Long shift left, 2 */ -#if (L_SHL_IS_INLINE) -__inline Word32 L_shl (Word32 L_var1, Word32 var2); -#else -Word32 L_shl (Word32 L_var1, Word16 var2); -#endif - -/* Long shift right, 2*/ -#if (L_SHR_IS_INLINE) -__inline Word32 L_shr (Word32 L_var1, Word32 var2); -#else -Word32 L_shr (Word32 L_var1, Word16 var2); -#endif - -/* Short add, 1 */ -#if (ADD_IS_INLINE) -__inline Word32 add (Word32 var1, Word32 var2); -#else -Word16 add (Word16 var1, Word16 var2); -#endif - -/* Short sub, 1 */ -#if (SUB_IS_INLINE) -__inline Word32 sub(Word32 var1, Word32 var2); -#else -Word16 sub(Word16 var1, Word16 var2); -#endif - -/* Short division, 18 */ -#if (DIV_S_IS_INLINE) -__inline Word32 div_s (Word32 var1, Word32 var2); -#else -Word16 div_s (Word16 var1, Word16 var2); -#endif - -/* Short mult, 1 */ -#if (MULT_IS_INLINE) -__inline Word32 mult (Word32 var1, Word32 var2); -#else -Word16 mult (Word16 var1, Word16 var2); -#endif - -/* Short norm, 15 */ -#if (NORM_S_IS_INLINE) -__inline Word32 norm_s (Word32 var1); -#else -Word16 norm_s (Word16 var1); -#endif - -/* Long norm, 30 */ -#if (NORM_L_IS_INLINE) -__inline Word32 norm_l (Word32 L_var1); -#else -Word16 norm_l (Word32 L_var1); -#endif - -/* Round, 1 */ -#if (ROUND_IS_INLINE) -__inline Word32 round16(Word32 L_var1); -#else -Word16 round16(Word32 L_var1); -#endif - -/* Mac, 1 */ -#if (L_MAC_IS_INLINE) -__inline Word32 L_mac (Word32 L_var3, Word32 var1, Word32 var2); -#else -Word32 L_mac (Word32 L_var3, Word16 var1, Word16 var2); -#endif - -#if (L_ADD_IS_INLINE) -__inline Word32 L_add (Word32 L_var1, Word32 L_var2); -#else -Word32 L_add (Word32 L_var1, Word32 L_var2); -#endif - -/* Extract high, 1 */ -#if (EXTRACT_H_IS_INLINE) -__inline Word32 extract_h (Word32 L_var1); -#else -Word16 extract_h (Word32 L_var1); -#endif - -/* Extract low, 1 */ -#if (EXTRACT_L_IS_INLINE) -__inline Word32 extract_l(Word32 L_var1); -#else -Word16 extract_l(Word32 L_var1); -#endif - -/* Mult with round, 2 */ -#if (MULT_R_IS_INLINE) -__inline Word32 mult_r(Word32 var1, Word32 var2); -#else -Word16 mult_r(Word16 var1, Word16 var2); -#endif - -/* Shift right with round, 2 */ -#if (SHR_R_IS_INLINE) -__inline Word32 shr_r (Word32 var1, Word32 var2); -#else -Word16 shr_r (Word16 var1, Word16 var2); -#endif - -/* Mac with rounding,2 */ -#if (MAC_R_IS_INLINE) -__inline Word32 mac_r (Word32 L_var3, Word32 var1, Word32 var2); -#else -Word16 mac_r (Word32 L_var3, Word16 var1, Word16 var2); -#endif - -/* Msu with rounding,2 */ -#if (MSU_R_IS_INLINE) -__inline Word32 msu_r (Word32 L_var3, Word32 var1, Word32 var2); -#else -Word16 msu_r (Word32 L_var3, Word16 var1, Word16 var2); -#endif - -/* Long shift right with round, 3 */ -#if (L_SHR_R_IS_INLINE) -__inline Word32 L_shr_r (Word32 L_var1, Word32 var2); -#else -Word32 L_shr_r (Word32 L_var1, Word16 var2); -#endif - -#if ARMV4_INASM -__inline Word32 ASM_L_shr(Word32 L_var1, Word32 var2) -{ - return L_var1 >> var2; -} - -__inline Word32 ASM_L_shl(Word32 L_var1, Word32 var2) -{ - Word32 result; - asm ( - "MOV %[result], %[L_var1], ASL %[var2] \n" - "TEQ %[L_var1], %[result], ASR %[var2]\n" - "EORNE %[result], %[mask], %[L_var1], ASR #31\n" - :[result]"=&r"(result) - :[L_var1]"r"(L_var1), [var2]"r"(var2), [mask]"r"(0x7fffffff) - ); - return result; -} - -__inline Word32 ASM_shr(Word32 L_var1, Word32 var2) -{ - Word32 result; - asm ( - "CMP %[var2], #15\n" - "MOVLT %[result], %[L_var1], ASR %[var2]\n" - "MOVGE %[result], %[L_var1], ASR #15\n" - :[result]"=r"(result) - :[L_var1]"r"(L_var1), [var2]"r"(var2) - ); - return result; -} - -__inline Word32 ASM_shl(Word32 L_var1, Word32 var2) -{ -#if ARMV6_SAT - Word32 result; - asm ( - "CMP %[var2], #16\n" - "MOVLT %[result], %[L_var1], ASL %[var2]\n" - "MOVGE %[result], %[L_var1], ASL #16\n" - "SSAT %[result], #16, %[result]\n" - :[result]"=r"(result) - :[L_var1]"r"(L_var1), [var2]"r"(var2) - ); - return result; -#else - Word32 result; - Word32 tmp; - asm ( - "CMP %[var2], #16\n" - "MOVLT %[result], %[L_var1], ASL %[var2]\n" - "MOVGE %[result], %[L_var1], ASL #16\n" - "MOV %[tmp], %[result], ASR #15\n" - "TEQ %[tmp], %[result], ASR #31 \n" - "EORNE %[result], %[mask], %[result],ASR #31" - :[result]"=&r"(result), [tmp]"=&r"(tmp) - :[L_var1]"r"(L_var1), [var2]"r"(var2), [mask]"r"(0x7fff) - ); - return result; -#endif -} -#endif - -/*___________________________________________________________________________ - | | - | definitions for inline basic arithmetic operators | - |___________________________________________________________________________| -*/ -#if (SATRUATE_IS_INLINE) -__inline Word32 saturate(Word32 L_var1) -{ -#if ARMV6_SAT - Word32 result; - asm ( - "SSAT %[result], #16, %[L_var1]" - : [result]"=r"(result) - : [L_var1]"r"(L_var1) - ); - return result; -#elif ARMV5TE_SAT - Word32 result; - Word32 tmp; - asm volatile ( - "MOV %[tmp], %[L_var1],ASR#15\n" - "TEQ %[tmp], %[L_var1],ASR#31\n" - "EORNE %[result], %[mask],%[L_var1],ASR#31\n" - "MOVEQ %[result], %[L_var1]\n" - :[result]"=&r"(result), [tmp]"=&r"(tmp) - :[L_var1]"r"(L_var1), [mask]"r"(0x7fff) - ); - - return result; -#else - Word32 var_out; - - //var_out = (L_var1 > (Word32)0X00007fffL) ? (MAX_16) : ((L_var1 < (Word32)0xffff8000L) ? (MIN_16) : ((Word16)L_var1)); - - if (L_var1 > 0X00007fffL) - { - var_out = MAX_16; - } - else if (L_var1 < (Word32) 0xffff8000L) - { - var_out = MIN_16; - } - else - { - var_out = extract_l(L_var1); - } - - return (var_out); -#endif -} -#endif - -/* Short shift left, 1 */ -#if (SHL_IS_INLINE) -__inline Word32 shl (Word32 var1, Word32 var2) -{ -#if ARMV5TE_SHL - if(var2>=0) - { - return ASM_shl( var1, var2); - } - else - { - return ASM_shr( var1, -var2); - } -#else - Word32 var_out; - Word32 result; - - if (var2 < 0) - { - var_out = shr (var1, (Word16)-var2); - } - else - { - result = (Word32) var1 *((Word32) 1 << var2); - - if ((var2 > 15 && var1 != 0) || (result != (Word32) ((Word16) result))) - { - var_out = (Word16)((var1 > 0) ? MAX_16 : MIN_16); - } - else - { - var_out = extract_l(result); - } - } - return (var_out); -#endif -} -#endif - -/* Short shift right, 1 */ -#if (SHR_IS_INLINE) -__inline Word32 shr (Word32 var1, Word32 var2) -{ -#if ARMV5TE_SHR - if(var2>=0) - { - return ASM_shr( var1, var2); - } - else - { - return ASM_shl( var1, -var2); - } -#else - Word32 var_out; - - if (var2 < 0) - { - var_out = shl (var1, (Word16)-var2); - } - else - { - if (var2 >= 15) - { - var_out = (Word16)((var1 < 0) ? -1 : 0); - } - else - { - if (var1 < 0) - { - var_out = (Word16)(~((~var1) >> var2)); - } - else - { - var_out = (Word16)(var1 >> var2); - } - } - } - - return (var_out); -#endif -} -#endif - - -#if (L_MULT_IS_INLINE) -__inline Word32 L_mult(Word32 var1, Word32 var2) -{ -#if ARMV5TE_L_MULT - Word32 result; - asm ( - "SMULBB %[result], %[var1], %[var2] \n" - "QADD %[result], %[result], %[result] \n" - :[result]"=r"(result) - :[var1]"r"(var1), [var2]"r"(var2) - ); - return result; -#else - Word32 L_var_out; - - L_var_out = (Word32) var1 *(Word32) var2; - - if (L_var_out != (Word32) 0x40000000L) - { - L_var_out <<= 1; - } - else - { - L_var_out = MAX_32; - } - return (L_var_out); -#endif -} -#endif - -#if (L_MSU_IS_INLINE) -__inline Word32 L_msu (Word32 L_var3, Word32 var1, Word32 var2) -{ -#if ARMV5TE_L_MSU - Word32 result; - asm ( - "SMULBB %[result], %[var1], %[var2] \n" - "QDSUB %[result], %[L_var3], %[result]\n" - :[result]"=&r"(result) - :[L_var3]"r"(L_var3), [var1]"r"(var1), [var2]"r"(var2) - ); - return result; -#else - Word32 L_var_out; - Word32 L_product; - - L_product = L_mult(var1, var2); - L_var_out = L_sub(L_var3, L_product); - return (L_var_out); -#endif -} -#endif - -#if (L_SUB_IS_INLINE) -__inline Word32 L_sub(Word32 L_var1, Word32 L_var2) -{ -#if ARMV5TE_L_SUB - Word32 result; - asm ( - "QSUB %[result], %[L_var1], %[L_var2]\n" - :[result]"=r"(result) - :[L_var1]"r"(L_var1), [L_var2]"r"(L_var2) - ); - return result; -#else - Word32 L_var_out; - - L_var_out = L_var1 - L_var2; - - if (((L_var1 ^ L_var2) & MIN_32) != 0) - { - if ((L_var_out ^ L_var1) & MIN_32) - { - L_var_out = (L_var1 < 0L) ? MIN_32 : MAX_32; - } - } - - return (L_var_out); -#endif -} -#endif - -#if (L_SHL_IS_INLINE) -__inline Word32 L_shl(Word32 L_var1, Word32 var2) -{ -#if ARMV5TE_L_SHL - if(var2>=0) - { - return ASM_L_shl( L_var1, var2); - } - else - { - return ASM_L_shr( L_var1, -var2); - } -#else - Word32 L_var_out = 0L; - - if (var2 <= 0) - { - L_var1 = L_shr(L_var1, (Word16)-var2); - } - else - { - for (; var2 > 0; var2--) - { - if (L_var1 > (Word32) 0X3fffffffL) - { - return MAX_32; - } - else - { - if (L_var1 < (Word32) 0xc0000000L) - { - return MIN_32; - } - } - L_var1 <<= 1; - L_var_out = L_var1; - } - } - return (L_var1); -#endif -} -#endif - -#if (L_SHR_IS_INLINE) -__inline Word32 L_shr (Word32 L_var1, Word32 var2) -{ -#if ARMV5TE_L_SHR - if(var2>=0) - { - return ASM_L_shr( L_var1, var2); - } - else - { - return ASM_L_shl( L_var1, -var2); - } -#else - Word32 L_var_out; - - if (var2 < 0) - { - L_var_out = L_shl (L_var1, (Word16)-var2); - } - else - { - if (var2 >= 31) - { - L_var_out = (L_var1 < 0L) ? -1 : 0; - } - else - { - if (L_var1 < 0) - { - L_var_out = ~((~L_var1) >> var2); - } - else - { - L_var_out = L_var1 >> var2; - } - } - } - return (L_var_out); -#endif -} -#endif - -/* Short add, 1 */ -#if (ADD_IS_INLINE) -__inline Word32 add (Word32 var1, Word32 var2) -{ -#if ARMV5TE_ADD - Word32 result; - Word32 tmp; - asm ( - "ADD %[result], %[var1], %[var2] \n" - "MOV %[tmp], %[result], ASR #15 \n" - "TEQ %[tmp], %[result], ASR #31 \n" - "EORNE %[result], %[mask], %[result], ASR #31" - :[result]"=&r"(result), [tmp]"=&r"(tmp) - :[var1]"r"(var1), [var2]"r"(var2), [mask]"r"(0x7fff) - ); - return result; -#else - Word32 var_out; - Word32 L_sum; - - L_sum = (Word32) var1 + var2; - var_out = saturate(L_sum); - - return (var_out); -#endif -} -#endif - -/* Short sub, 1 */ -#if (SUB_IS_INLINE) -__inline Word32 sub(Word32 var1, Word32 var2) -{ -#if ARMV5TE_SUB - Word32 result; - Word32 tmp; - asm ( - "SUB %[result], %[var1], %[var2] \n" - "MOV %[tmp], %[var1], ASR #15 \n" - "TEQ %[tmp], %[var1], ASR #31 \n" - "EORNE %[result], %[mask], %[result], ASR #31 \n" - :[result]"=&r"(result), [tmp]"=&r"(tmp) - :[var1]"r"(var1), [var2]"r"(var2), [mask]"r"(0x7fff) - ); - return result; -#else - Word32 var_out; - Word32 L_diff; - - L_diff = (Word32) var1 - var2; - var_out = saturate(L_diff); - - return (var_out); -#endif -} -#endif - -/* Short division, 18 */ -#if (DIV_S_IS_INLINE) -__inline Word32 div_s (Word32 var1, Word32 var2) -{ - Word32 var_out = 0; - Word32 iteration; - Word32 L_num; - Word32 L_denom; - - var_out = MAX_16; - if (var1!= var2)//var1!= var2 - { - var_out = 0; - L_num = (Word32) var1; - - L_denom = (Word32) var2; - - //return (L_num<<15)/var2; - - for (iteration = 0; iteration < 15; iteration++) - { - var_out <<= 1; - L_num <<= 1; - - if (L_num >= L_denom) - { - L_num -= L_denom; - var_out++; - } - } - } - return (var_out); -} -#endif - -/* Short mult, 1 */ -#if (MULT_IS_INLINE) -__inline Word32 mult (Word32 var1, Word32 var2) -{ -#if ARMV5TE_MULT && ARMV6_SAT - Word32 result; - asm ( - "SMULBB %[result], %[var1], %[var2] \n" - "SSAT %[result], #16, %[result], ASR #15 \n" - :[result]"=r"(result) - :[var1]"r"(var1), [var2]"r"(var2) - ); - return result; -#elif ARMV5TE_MULT - Word32 result, tmp; - asm ( - "SMULBB %[tmp], %[var1], %[var2] \n" - "MOV %[result], %[tmp], ASR #15\n" - "MOV %[tmp], %[result], ASR #15\n" - "TEQ %[tmp], %[result], ASR #31\n" - "EORNE %[result], %[mask], %[result], ASR #31 \n" - :[result]"=&r"(result), [tmp]"=&r"(tmp) - :[var1]"r"(var1), [var2]"r"(var2), [mask]"r"(0x7fff) - ); - return result; -#else - Word32 var_out; - Word32 L_product; - - L_product = (Word32) var1 *(Word32) var2; - L_product = (L_product & (Word32) 0xffff8000L) >> 15; - if (L_product & (Word32) 0x00010000L) - L_product = L_product | (Word32) 0xffff0000L; - var_out = saturate(L_product); - - return (var_out); -#endif -} -#endif - - -/* Short norm, 15 */ -#if (NORM_S_IS_INLINE) -__inline Word32 norm_s (Word32 var1) -{ -#if ARMV5TE_NORM_S - Word32 result; - Word32 tmp; - asm ( - "RSBS %[tmp], %[var1], #0 \n" - "CLZLT %[result], %[var1]\n" - "CLZGT %[result], %[tmp]\n" - "SUBNE %[result], %[result], #17\n" - "MOVEQ %[result], #0\n" - "CMP %[var1], #-1\n" - "MOVEQ %[result], #15\n" - :[result]"=&r"(result), [tmp]"=&r"(tmp) - :[var1]"r"(var1) - ); - return result; -#else - Word32 var_out; - - if (var1 == 0) - { - var_out = 0; - } - else - { - if (var1 == -1) - { - var_out = 15; - } - else - { - if (var1 < 0) - { - var1 = (Word16)~var1; - } - for (var_out = 0; var1 < 0x4000; var_out++) - { - var1 <<= 1; - } - } - } - return (var_out); -#endif -} -#endif - -/* Long norm, 30 */ -#if (NORM_L_IS_INLINE) -__inline Word32 norm_l (Word32 L_var1) -{ -#if ARMV5TE_NORM_L - Word32 result; - asm volatile( - "CMP %[L_var1], #0\n" - "CLZNE %[result], %[L_var1]\n" - "SUBNE %[result], %[result], #1\n" - "MOVEQ %[result], #0\n" - :[result]"=r"(result) - :[L_var1]"r"(L_var1) - ); - return result; -#else - //Word16 var_out; - - //if (L_var1 == 0) - //{ - // var_out = 0; - //} - //else - //{ - // if (L_var1 == (Word32) 0xffffffffL) - // { - // var_out = 31; - // } - // else - // { - // if (L_var1 < 0) - // { - // L_var1 = ~L_var1; - // } - // for (var_out = 0; L_var1 < (Word32) 0x40000000L; var_out++) - // { - // L_var1 <<= 1; - // } - // } - //} - //return (var_out); - Word16 a16; - Word16 r = 0 ; - - - if ( L_var1 < 0 ) { - L_var1 = ~L_var1; - } - - if (0 == (L_var1 & 0x7fff8000)) { - a16 = extract_l(L_var1); - r += 16; - - if (0 == (a16 & 0x7f80)) { - r += 8; - - if (0 == (a16 & 0x0078)) { - r += 4; - - if (0 == (a16 & 0x0006)) { - r += 2; - - if (0 == (a16 & 0x0001)) { - r += 1; - } - } - else { - - if (0 == (a16 & 0x0004)) { - r += 1; - } - } - } - else { - - if (0 == (a16 & 0x0060)) { - r += 2; - - if (0 == (a16 & 0x0010)) { - r += 1; - } - } - else { - - if (0 == (a16 & 0x0040)) { - r += 1; - } - } - } - } - else { - - if (0 == (a16 & 0x7800)) { - r += 4; - - if (0 == (a16 & 0x0600)) { - r += 2; - - if (0 == (a16 & 0x0100)) { - r += 1; - } - } - else { - - if (0 == (a16 & 0x0400)) { - r += 1; - } - } - } - else { - - if (0 == (a16 & 0x6000)) { - r += 2; - - if (0 == (a16 & 0x1000)) { - r += 1; - } - } - else { - - if (0 == (a16 & 0x4000)) { - r += 1; - } - } - } - } - } - else { - a16 = extract_h(L_var1); - - if (0 == (a16 & 0x7f80)) { - r += 8; - - if (0 == (a16 & 0x0078)) { - r += 4 ; - - if (0 == (a16 & 0x0006)) { - r += 2; - - if (0 == (a16 & 0x0001)) { - r += 1; - } - } - else { - - if (0 == (a16 & 0x0004)) { - r += 1; - } - } - } - else { - - if (0 == (a16 & 0x0060)) { - r += 2; - - if (0 == (a16 & 0x0010)) { - r += 1; - } - } - else { - - if (0 == (a16 & 0x0040)) { - r += 1; - } - } - } - } - else { - - if (0 == (a16 & 0x7800)) { - r += 4; - - if (0 == (a16 & 0x0600)) { - r += 2; - - if (0 == (a16 & 0x0100)) { - r += 1; - } - } - else { - - if (0 == (a16 & 0x0400)) { - r += 1; - } - } - } - else { - - if (0 == (a16 & 0x6000)) { - r += 2; - - if (0 == (a16 & 0x1000)) { - r += 1; - } - } - else { - - if (0 == (a16 & 0x4000)) { - return 1; - } - } - } - } - } - - return r ; -#endif -} -#endif - -/* Round, 1 */ -#if (ROUND_IS_INLINE) -__inline Word32 round16(Word32 L_var1) -{ -#if ARMV5TE_ROUND - Word32 result; - asm ( - "QADD %[result], %[L_var1], %[bias]\n" - "MOV %[result], %[result], ASR #16 \n" - :[result]"=r"(result) - :[L_var1]"r"(L_var1), [bias]"r"(0x8000) - ); - return result; -#else - Word32 var_out; - Word32 L_rounded; - - L_rounded = L_add (L_var1, (Word32) 0x00008000L); - var_out = extract_h (L_rounded); - return (var_out); -#endif -} -#endif - -/* Mac, 1 */ -#if (L_MAC_IS_INLINE) -__inline Word32 L_mac (Word32 L_var3, Word32 var1, Word32 var2) -{ -#if ARMV5TE_L_MAC - Word32 result; - asm ( - "SMULBB %[result], %[var1], %[var2]\n" - "QDADD %[result], %[L_var3], %[result]\n" - :[result]"=&r"(result) - : [L_var3]"r"(L_var3), [var1]"r"(var1), [var2]"r"(var2) - ); - return result; -#else - Word32 L_var_out; - Word32 L_product; - - L_product = L_mult(var1, var2); - L_var_out = L_add (L_var3, L_product); - return (L_var_out); -#endif -} -#endif - -#if (L_ADD_IS_INLINE) -__inline Word32 L_add (Word32 L_var1, Word32 L_var2) -{ -#if ARMV5TE_L_ADD - Word32 result; - asm ( - "QADD %[result], %[L_var1], %[L_var2]\n" - :[result]"=r"(result) - :[L_var1]"r"(L_var1), [L_var2]"r"(L_var2) - ); - return result; -#else - Word32 L_var_out; - - L_var_out = L_var1 + L_var2; - if (((L_var1 ^ L_var2) & MIN_32) == 0) - { - if ((L_var_out ^ L_var1) & MIN_32) - { - L_var_out = (L_var1 < 0) ? MIN_32 : MAX_32; - } - } - return (L_var_out); -#endif -} -#endif - - - -#if (MULT_R_IS_INLINE) -__inline Word32 mult_r (Word32 var1, Word32 var2) -{ - Word32 var_out; - Word32 L_product_arr; - - L_product_arr = (Word32)var1 *(Word32)var2; /* product */ - L_product_arr += (Word32)0x00004000L; /* round */ - L_product_arr >>= 15; /* shift */ - - var_out = saturate(L_product_arr); - - return (var_out); -} -#endif - -#if (SHR_R_IS_INLINE) -__inline Word32 shr_r (Word32 var1, Word32 var2) -{ - Word32 var_out; - - if (var2 > 15) - { - var_out = 0; - } - else - { - var_out = shr(var1, var2); - - if (var2 > 0) - { - if ((var1 & ((Word16) 1 << (var2 - 1))) != 0) - { - var_out++; - } - } - } - - return (var_out); -} -#endif - -#if (MAC_R_IS_INLINE) -__inline Word32 mac_r (Word32 L_var3, Word32 var1, Word32 var2) -{ - Word32 var_out; - - L_var3 = L_mac (L_var3, var1, var2); - var_out = (Word16)((L_var3 + 0x8000L) >> 16); - - return (var_out); -} -#endif - -#if (MSU_R_IS_INLINE) -__inline Word32 msu_r (Word32 L_var3, Word32 var1, Word32 var2) -{ - Word32 var_out; - - L_var3 = L_msu (L_var3, var1, var2); - var_out = (Word16)((L_var3 + 0x8000L) >> 16); - - return (var_out); -} -#endif - -#if (L_SHR_R_IS_INLINE) -__inline Word32 L_shr_r (Word32 L_var1, Word32 var2) -{ - Word32 L_var_out; - - if (var2 > 31) - { - L_var_out = 0; - } - else - { - L_var_out = L_shr(L_var1, var2); - - if (var2 > 0) - { - if ((L_var1 & ((Word32) 1 << (var2 - 1))) != 0) - { - L_var_out++; - } - } - } - - return (L_var_out); -} -#endif - -#if (EXTRACT_H_IS_INLINE) -__inline Word32 extract_h (Word32 L_var1) -{ - Word32 var_out; - - var_out = (L_var1 >> 16); - - return (var_out); -} -#endif - -#if (EXTRACT_L_IS_INLINE) -__inline Word32 extract_l(Word32 L_var1) -{ - return (Word16) L_var1; -} -#endif - -#endif diff --git a/android-aac-enc/jni/inc/bit_cnt.h b/android-aac-enc/jni/inc/bit_cnt.h deleted file mode 100644 index 266a21944..000000000 --- a/android-aac-enc/jni/inc/bit_cnt.h +++ /dev/null @@ -1,106 +0,0 @@ -/* - ** Copyright 2003-2010, VisualOn, Inc. - ** - ** Licensed under the Apache License, Version 2.0 (the "License"); - ** you may not use this file except in compliance with the License. - ** You may obtain a copy of the License at - ** - ** http://www.apache.org/licenses/LICENSE-2.0 - ** - ** Unless required by applicable law or agreed to in writing, software - ** distributed under the License is distributed on an "AS IS" BASIS, - ** WITHOUT 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: bit_cnt.h - - Content: Huffman Bitcounter & coder structure and functions - -*******************************************************************************/ - -#ifndef __BITCOUNT_H -#define __BITCOUNT_H - -#include "bitbuffer.h" -#include "basic_op.h" -#define INVALID_BITCOUNT (MAX_16/4) - -/* - code book number table -*/ - -enum codeBookNo{ - CODE_BOOK_ZERO_NO= 0, - CODE_BOOK_1_NO= 1, - CODE_BOOK_2_NO= 2, - CODE_BOOK_3_NO= 3, - CODE_BOOK_4_NO= 4, - CODE_BOOK_5_NO= 5, - CODE_BOOK_6_NO= 6, - CODE_BOOK_7_NO= 7, - CODE_BOOK_8_NO= 8, - CODE_BOOK_9_NO= 9, - CODE_BOOK_10_NO= 10, - CODE_BOOK_ESC_NO= 11, - CODE_BOOK_RES_NO= 12, - CODE_BOOK_PNS_NO= 13 -}; - -/* - code book index table -*/ - -enum codeBookNdx{ - CODE_BOOK_ZERO_NDX=0, - CODE_BOOK_1_NDX, - CODE_BOOK_2_NDX, - CODE_BOOK_3_NDX, - CODE_BOOK_4_NDX, - CODE_BOOK_5_NDX, - CODE_BOOK_6_NDX, - CODE_BOOK_7_NDX, - CODE_BOOK_8_NDX, - CODE_BOOK_9_NDX, - CODE_BOOK_10_NDX, - CODE_BOOK_ESC_NDX, - CODE_BOOK_RES_NDX, - CODE_BOOK_PNS_NDX, - NUMBER_OF_CODE_BOOKS -}; - -/* - code book lav table -*/ - -enum codeBookLav{ - CODE_BOOK_ZERO_LAV=0, - CODE_BOOK_1_LAV=1, - CODE_BOOK_2_LAV=1, - CODE_BOOK_3_LAV=2, - CODE_BOOK_4_LAV=2, - CODE_BOOK_5_LAV=4, - CODE_BOOK_6_LAV=4, - CODE_BOOK_7_LAV=7, - CODE_BOOK_8_LAV=7, - CODE_BOOK_9_LAV=12, - CODE_BOOK_10_LAV=12, - CODE_BOOK_ESC_LAV=16, - CODE_BOOK_SCF_LAV=60, - CODE_BOOK_PNS_LAV=60 -}; - -Word16 bitCount(const Word16 *aQuantSpectrum, - const Word16 noOfSpecLines, - Word16 maxVal, - Word16 *bitCountLut); - -Word16 codeValues(Word16 *values, Word16 width, Word16 codeBook, HANDLE_BIT_BUF hBitstream); - -Word16 bitCountScalefactorDelta(Word16 delta); -Word16 codeScalefactorDelta(Word16 scalefactor, HANDLE_BIT_BUF hBitstream); - - - -#endif diff --git a/android-aac-enc/jni/inc/bitbuffer.h b/android-aac-enc/jni/inc/bitbuffer.h deleted file mode 100644 index 7c79f07ec..000000000 --- a/android-aac-enc/jni/inc/bitbuffer.h +++ /dev/null @@ -1,89 +0,0 @@ -/* - ** Copyright 2003-2010, VisualOn, Inc. - ** - ** Licensed under the Apache License, Version 2.0 (the "License"); - ** you may not use this file except in compliance with the License. - ** You may obtain a copy of the License at - ** - ** http://www.apache.org/licenses/LICENSE-2.0 - ** - ** Unless required by applicable law or agreed to in writing, software - ** distributed under the License is distributed on an "AS IS" BASIS, - ** WITHOUT 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: bitbuffer.h - - Content: Bit Buffer Management structure and functions - -*******************************************************************************/ - -#ifndef BITBUFFER_H -#define BITBUFFER_H - -#include "typedef.h" - - -enum direction -{ - forwardDirection, - backwardDirection -}; - - -/*! - The pointer 'pReadNext' points to the next available word, where bits can be read from. The pointer - 'pWriteNext' points to the next available word, where bits can be written to. The pointer pBitBufBase - points to the start of the bitstream buffer and the pointer pBitBufEnd points to the end of the bitstream - buffer. The two pointers are used as lower-bound respectively upper-bound address for the modulo addressing - mode. - - The element cntBits contains the currently available bits in the bit buffer. It will be incremented when - bits are written to the bitstream buffer and decremented when bits are read from the bitstream buffer. -*/ -struct BIT_BUF -{ - UWord8 *pBitBufBase; /*!< pointer points to first position in bitstream buffer */ - UWord8 *pBitBufEnd; /*!< pointer points to last position in bitstream buffer */ - - UWord8 *pWriteNext; /*!< pointer points to next available word in bitstream buffer to write */ - - UWord32 cache; - - Word16 wBitPos; /*!< 31<=wBitPos<=0*/ - Word16 cntBits; /*!< number of available bits in the bitstream buffer - write bits to bitstream buffer => increment cntBits - read bits from bitstream buffer => decrement cntBits */ - Word16 size; /*!< size of bitbuffer in bits */ - Word16 isValid; /*!< indicates whether the instance has been initialized */ -}; /* size Word16: 8 */ - -/*! Define pointer to bit buffer structure */ -typedef struct BIT_BUF *HANDLE_BIT_BUF; - - -HANDLE_BIT_BUF CreateBitBuffer(HANDLE_BIT_BUF hBitBuf, - UWord8 *pBitBufBase, - Word16 bitBufSize); - - -void DeleteBitBuffer(HANDLE_BIT_BUF *hBitBuf); - - -Word16 GetBitsAvail(HANDLE_BIT_BUF hBitBuf); - - -Word16 WriteBits(HANDLE_BIT_BUF hBitBuf, - UWord32 writeValue, - Word16 noBitsToWrite); - -void ResetBitBuf(HANDLE_BIT_BUF hBitBuf, - UWord8 *pBitBufBase, - Word16 bitBufSize); - -#define GetNrBitsAvailable(hBitBuf) ( (hBitBuf)->cntBits) -#define GetNrBitsRead(hBitBuf) ((hBitBuf)->size-(hBitBuf)->cntBits) - -#endif /* BITBUFFER_H */ diff --git a/android-aac-enc/jni/inc/bitenc.h b/android-aac-enc/jni/inc/bitenc.h deleted file mode 100644 index 6a58aebe9..000000000 --- a/android-aac-enc/jni/inc/bitenc.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - ** Copyright 2003-2010, VisualOn, Inc. - ** - ** Licensed under the Apache License, Version 2.0 (the "License"); - ** you may not use this file except in compliance with the License. - ** You may obtain a copy of the License at - ** - ** http://www.apache.org/licenses/LICENSE-2.0 - ** - ** Unless required by applicable law or agreed to in writing, software - ** distributed under the License is distributed on an "AS IS" BASIS, - ** WITHOUT 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: bitenc.h - - Content: Bitstream encoder structure and functions - -*******************************************************************************/ - -#ifndef _BITENC_H -#define _BITENC_H - -#include "qc_data.h" -#include "tns.h" -#include "channel_map.h" -#include "interface.h" - -struct BITSTREAMENCODER_INIT -{ - Word16 nChannels; - Word32 bitrate; - Word32 sampleRate; - Word16 profile; -}; - - - -Word16 WriteBitstream (HANDLE_BIT_BUF hBitstream, - ELEMENT_INFO elInfo, - QC_OUT *qcOut, - PSY_OUT *psyOut, - Word16 *globUsedBits, - const UWord8 *ancBytes, - Word16 samplerate - ); - -#endif /* _BITENC_H */ diff --git a/android-aac-enc/jni/inc/block_switch.h b/android-aac-enc/jni/inc/block_switch.h deleted file mode 100644 index a4d3e8fd4..000000000 --- a/android-aac-enc/jni/inc/block_switch.h +++ /dev/null @@ -1,72 +0,0 @@ -/* - ** Copyright 2003-2010, VisualOn, Inc. - ** - ** Licensed under the Apache License, Version 2.0 (the "License"); - ** you may not use this file except in compliance with the License. - ** You may obtain a copy of the License at - ** - ** http://www.apache.org/licenses/LICENSE-2.0 - ** - ** Unless required by applicable law or agreed to in writing, software - ** distributed under the License is distributed on an "AS IS" BASIS, - ** WITHOUT 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: block_switch.h - - Content: Block switching structure and functions - -*******************************************************************************/ - -#ifndef _BLOCK_SWITCH_H -#define _BLOCK_SWITCH_H - -#include "typedef.h" - - -/****************** Defines ******************************/ -#define BLOCK_SWITCHING_IIR_LEN 2 /* Length of HighPass-FIR-Filter for Attack-Detection */ -#define BLOCK_SWITCH_WINDOWS TRANS_FAC /* number of windows for energy calculation */ -#define BLOCK_SWITCH_WINDOW_LEN FRAME_LEN_SHORT /* minimal granularity of energy calculation */ - - - -/****************** Structures ***************************/ -typedef struct{ - Word32 invAttackRatio; - Word16 windowSequence; - Word16 nextwindowSequence; - Flag attack; - Flag lastattack; - Word16 attackIndex; - Word16 lastAttackIndex; - Word16 noOfGroups; - Word16 groupLen[TRANS_FAC]; - Word32 windowNrg[2][BLOCK_SWITCH_WINDOWS]; /* time signal energy in Subwindows (last and current) */ - Word32 windowNrgF[2][BLOCK_SWITCH_WINDOWS]; /* filtered time signal energy in segments (last and current) */ - Word32 iirStates[BLOCK_SWITCHING_IIR_LEN]; /* filter delay-line */ - Word32 maxWindowNrg; /* max energy in subwindows */ - Word32 accWindowNrg; /* recursively accumulated windowNrgF */ -}BLOCK_SWITCHING_CONTROL; - - - - - -Word16 InitBlockSwitching(BLOCK_SWITCHING_CONTROL *blockSwitchingControl, - const Word32 bitRate, const Word16 nChannels); - -Word16 BlockSwitching(BLOCK_SWITCHING_CONTROL *blockSwitchingControl, - Word16 *timeSignal, - Word32 sampleRate, - Word16 chIncrement); - -Word16 SyncBlockSwitching(BLOCK_SWITCHING_CONTROL *blockSwitchingControlLeft, - BLOCK_SWITCHING_CONTROL *blockSwitchingControlRight, - const Word16 noOfChannels); - - - -#endif /* #ifndef _BLOCK_SWITCH_H */ diff --git a/android-aac-enc/jni/inc/channel_map.h b/android-aac-enc/jni/inc/channel_map.h deleted file mode 100644 index c361feb89..000000000 --- a/android-aac-enc/jni/inc/channel_map.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - ** Copyright 2003-2010, VisualOn, Inc. - ** - ** Licensed under the Apache License, Version 2.0 (the "License"); - ** you may not use this file except in compliance with the License. - ** You may obtain a copy of the License at - ** - ** http://www.apache.org/licenses/LICENSE-2.0 - ** - ** Unless required by applicable law or agreed to in writing, software - ** distributed under the License is distributed on an "AS IS" BASIS, - ** WITHOUT 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: channel_map.h - - Content: channel mapping functions - -*******************************************************************************/ - -#ifndef _CHANNEL_MAP_H -#define _CHANNEL_MAP_H - -#include "psy_const.h" -#include "qc_data.h" - -Word16 InitElementInfo (Word16 nChannels, ELEMENT_INFO* elInfo); - -Word16 InitElementBits(ELEMENT_BITS *elementBits, - ELEMENT_INFO elInfo, - Word32 bitrateTot, - Word16 averageBitsTot, - Word16 staticBitsTot); - -#endif /* CHANNEL_MAP_H */ diff --git a/android-aac-enc/jni/inc/cmnMemory.h b/android-aac-enc/jni/inc/cmnMemory.h deleted file mode 100644 index e1751033e..000000000 --- a/android-aac-enc/jni/inc/cmnMemory.h +++ /dev/null @@ -1,106 +0,0 @@ -/* - ** Copyright 2003-2010, VisualOn, Inc. - ** - ** Licensed under the Apache License, Version 2.0 (the "License"); - ** you may not use this file except in compliance with the License. - ** You may obtain a copy of the License at - ** - ** http://www.apache.org/licenses/LICENSE-2.0 - ** - ** Unless required by applicable law or agreed to in writing, software - ** distributed under the License is distributed on an "AS IS" BASIS, - ** WITHOUT 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: cmnMemory.h - - Content: memory operator implementation header file - -*******************************************************************************/ - -#ifndef __cmnMemory_H__ -#define __cmnMemory_H__ - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -#include "voMem.h" - -//extern VO_MEM_OPERATOR g_memOP; - -/** - * Allocate memory - * \param uID [in] module ID - * \param uSize [in] size of memory - * \return value is the allocated memory address. NULL is failed. - */ -VO_U32 cmnMemAlloc (VO_S32 uID, VO_MEM_INFO * pMemInfo); - -/** - * Free up memory - * \param uID [in] module ID - * \param pMem [in] address of memory - * \return value 0, if succeeded. - */ -VO_U32 cmnMemFree (VO_S32 uID, VO_PTR pBuffer); - -/** - * memory set function - * \param uID [in] module ID - * \param pBuff [in/out] address of memory - * \param uValue [in] the value to be set - * \param uSize [in] the size to be set - * \return value 0, if succeeded. - */ -VO_U32 cmnMemSet (VO_S32 uID, VO_PTR pBuff, VO_U8 uValue, VO_U32 uSize); - -/** - * memory copy function - * \param uID [in] module ID - * \param pDest [in/out] address of destination memory - * \param pSource [in] address of source memory - * \param uSize [in] the size to be copied - * \return value 0, if succeeded. - */ -VO_U32 cmnMemCopy (VO_S32 uID, VO_PTR pDest, VO_PTR pSource, VO_U32 uSize); - -/** - * memory check function - * \param uID [in] module ID - * \param pBuff [in] address of buffer to be checked - * \param uSize [in] the size to be checked - * \return value 0, if succeeded. - */ -VO_U32 cmnMemCheck (VO_S32 uID, VO_PTR pBuffer, VO_U32 uSize); - -/** - * memory compare function - * \param uID [in] module ID - * \param pBuffer1 [in] address of buffer 1 to be compared - * \param pBuffer2 [in] address of buffer 2 to be compared - * \param uSize [in] the size to be compared - * \return value: same as standard C run-time memcmp() function. - */ -VO_S32 cmnMemCompare (VO_S32 uID, VO_PTR pBuffer1, VO_PTR pBuffer2, VO_U32 uSize); - -/** - * memory move function - * \param uID [in] module ID - * \param pDest [in/out] address of destination memory - * \param pSource [in] address of source memory - * \param uSize [in] the size to be moved - * \return value 0, if succeeded. - */ -VO_U32 cmnMemMove (VO_S32 uID, VO_PTR pDest, VO_PTR pSource, VO_U32 uSize); - - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif // __cmnMemory_H__ - - diff --git a/android-aac-enc/jni/inc/config.h b/android-aac-enc/jni/inc/config.h deleted file mode 100644 index b0b4c26f8..000000000 --- a/android-aac-enc/jni/inc/config.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - ** Copyright 2003-2010, VisualOn, Inc. - ** - ** Licensed under the Apache License, Version 2.0 (the "License"); - ** you may not use this file except in compliance with the License. - ** You may obtain a copy of the License at - ** - ** http://www.apache.org/licenses/LICENSE-2.0 - ** - ** Unless required by applicable law or agreed to in writing, software - ** distributed under the License is distributed on an "AS IS" BASIS, - ** WITHOUT 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: config.h - - Content: aac encoder parameter - -*******************************************************************************/ - -#ifndef _AACENC_CONFIG_H_ -#define _AACENC_CONFIG_H_ - -#define MAX_CHANNELS 2 - -#define AACENC_BLOCKSIZE 1024 /*! encoder only takes BLOCKSIZE samples at a time */ -#define AACENC_TRANS_FAC 8 /*! encoder short long ratio */ - - -#define MAXBITS_COEF 6144 -#define MINBITS_COEF 744 - - -#endif diff --git a/android-aac-enc/jni/inc/dyn_bits.h b/android-aac-enc/jni/inc/dyn_bits.h deleted file mode 100644 index d3a8a6714..000000000 --- a/android-aac-enc/jni/inc/dyn_bits.h +++ /dev/null @@ -1,82 +0,0 @@ -/* - ** Copyright 2003-2010, VisualOn, Inc. - ** - ** Licensed under the Apache License, Version 2.0 (the "License"); - ** you may not use this file except in compliance with the License. - ** You may obtain a copy of the License at - ** - ** http://www.apache.org/licenses/LICENSE-2.0 - ** - ** Unless required by applicable law or agreed to in writing, software - ** distributed under the License is distributed on an "AS IS" BASIS, - ** WITHOUT 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: dyn_bits.h - - Content: Noiseless coder module structure and functions - -*******************************************************************************/ - -#ifndef __DYN_BITS_H -#define __DYN_BITS_H - -#include "psy_const.h" -#include "tns.h" -#include "bit_cnt.h" - - - -#define MAX_SECTIONS MAX_GROUPED_SFB -#define SECT_ESC_VAL_LONG 31 -#define SECT_ESC_VAL_SHORT 7 -#define CODE_BOOK_BITS 4 -#define SECT_BITS_LONG 5 -#define SECT_BITS_SHORT 3 - -typedef struct -{ - Word16 codeBook; - Word16 sfbStart; - Word16 sfbCnt; - Word16 sectionBits; -} -SECTION_INFO; - - - - -typedef struct -{ - Word16 blockType; - Word16 noOfGroups; - Word16 sfbCnt; - Word16 maxSfbPerGroup; - Word16 sfbPerGroup; - Word16 noOfSections; - SECTION_INFO sectionInfo[MAX_SECTIONS]; - Word16 sideInfoBits; /* sectioning bits */ - Word16 huffmanBits; /* huffman coded bits */ - Word16 scalefacBits; /* scalefac coded bits */ - Word16 firstScf; /* first scf to be coded */ - Word16 bitLookUp[MAX_SFB_LONG*(CODE_BOOK_ESC_NDX+1)]; - Word16 mergeGainLookUp[MAX_SFB_LONG]; -} -SECTION_DATA; /* Word16 size: 10 + 60(MAX_SECTIONS)*4(SECTION_INFO) + 51(MAX_SFB_LONG)*12(CODE_BOOK_ESC_NDX+1) + 51(MAX_SFB_LONG) = 913 */ - - -Word16 BCInit(void); - -Word16 dynBitCount(const Word16 *quantSpectrum, - const UWord16 *maxValueInSfb, - const Word16 *scalefac, - const Word16 blockType, - const Word16 sfbCnt, - const Word16 maxSfbPerGroup, - const Word16 sfbPerGroup, - const Word16 *sfbOffset, - SECTION_DATA *sectionData); - -#endif diff --git a/android-aac-enc/jni/inc/grp_data.h b/android-aac-enc/jni/inc/grp_data.h deleted file mode 100644 index 4c1b2cbab..000000000 --- a/android-aac-enc/jni/inc/grp_data.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - ** Copyright 2003-2010, VisualOn, Inc. - ** - ** Licensed under the Apache License, Version 2.0 (the "License"); - ** you may not use this file except in compliance with the License. - ** You may obtain a copy of the License at - ** - ** http://www.apache.org/licenses/LICENSE-2.0 - ** - ** Unless required by applicable law or agreed to in writing, software - ** distributed under the License is distributed on an "AS IS" BASIS, - ** WITHOUT 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: grp_data.h - - Content: Short block grouping function - -*******************************************************************************/ - -#ifndef __GRP_DATA_H__ -#define __GRP_DATA_H__ -#include "psy_data.h" -#include "typedefs.h" - -void -groupShortData(Word32 *mdctSpectrum, - Word32 *tmpSpectrum, - SFB_THRESHOLD *sfbThreshold, - SFB_ENERGY *sfbEnergy, - SFB_ENERGY *sfbEnergyMS, - SFB_ENERGY *sfbSpreadedEnergy, - const Word16 sfbCnt, - const Word16 *sfbOffset, - const Word16 *sfbMinSnr, - Word16 *groupedSfbOffset, - Word16 *maxSfbPerGroup, - Word16 *groupedSfbMinSnr, - const Word16 noOfGroups, - const Word16 *groupLen); - -#endif /* _INTERFACE_H */ diff --git a/android-aac-enc/jni/inc/interface.h b/android-aac-enc/jni/inc/interface.h deleted file mode 100644 index a42e6a9cd..000000000 --- a/android-aac-enc/jni/inc/interface.h +++ /dev/null @@ -1,106 +0,0 @@ -/* - ** Copyright 2003-2010, VisualOn, Inc. - ** - ** Licensed under the Apache License, Version 2.0 (the "License"); - ** you may not use this file except in compliance with the License. - ** You may obtain a copy of the License at - ** - ** http://www.apache.org/licenses/LICENSE-2.0 - ** - ** Unless required by applicable law or agreed to in writing, software - ** distributed under the License is distributed on an "AS IS" BASIS, - ** WITHOUT 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: interface.h - - Content: psychoaccoustic/quantizer structures and interface - -*******************************************************************************/ - -#ifndef _INTERFACE_H -#define _INTERFACE_H - -#include "config.h" -#include "psy_const.h" -#include "psy_data.h" -#include "typedefs.h" - - -enum -{ - MS_NONE = 0, - MS_SOME = 1, - MS_ALL = 2 -}; - -enum -{ - MS_ON = 1 -}; - -struct TOOLSINFO { - Word16 msDigest; - Word16 msMask[MAX_GROUPED_SFB]; -}; - - -typedef struct { - Word16 sfbCnt; - Word16 sfbPerGroup; - Word16 maxSfbPerGroup; - Word16 windowSequence; - Word16 windowShape; - Word16 groupingMask; - Word16 sfbOffsets[MAX_GROUPED_SFB+1]; - Word16 mdctScale; - Word32 *sfbEnergy; - Word32 *sfbSpreadedEnergy; - Word32 *sfbThreshold; - Word32 *mdctSpectrum; - Word32 sfbEnSumLR; - Word32 sfbEnSumMS; - Word32 sfbDist[MAX_GROUPED_SFB]; - Word32 sfbDistNew[MAX_GROUPED_SFB]; - Word16 sfbMinSnr[MAX_GROUPED_SFB]; - Word16 minSfMaxQuant[MAX_GROUPED_SFB]; - Word16 minScfCalculated[MAX_GROUPED_SFB]; - Word16 prevScfLast[MAX_GROUPED_SFB]; - Word16 prevScfNext[MAX_GROUPED_SFB]; - Word16 deltaPeLast[MAX_GROUPED_SFB]; - TNS_INFO tnsInfo; -} PSY_OUT_CHANNEL; /* Word16 size: 14 + 60(MAX_GROUPED_SFB) + 112(TNS_INFO) = 186 */ - -typedef struct { - struct TOOLSINFO toolsInfo; - Word16 groupedSfbOffset[MAX_CHANNELS][MAX_GROUPED_SFB+1]; /* plus one for last dummy offset ! */ - Word16 groupedSfbMinSnr[MAX_CHANNELS][MAX_GROUPED_SFB]; -} PSY_OUT_ELEMENT; - -typedef struct { - /* information shared by both channels */ - PSY_OUT_ELEMENT psyOutElement; - /* information specific to each channel */ - PSY_OUT_CHANNEL psyOutChannel[MAX_CHANNELS]; -}PSY_OUT; - -void BuildInterface(Word32 *mdctSpectrum, - const Word16 mdctScale, - SFB_THRESHOLD *sfbThreshold, - SFB_ENERGY *sfbEnergy, - SFB_ENERGY *sfbSpreadedEnergy, - const SFB_ENERGY_SUM sfbEnergySumLR, - const SFB_ENERGY_SUM sfbEnergySumMS, - const Word16 windowSequence, - const Word16 windowShape, - const Word16 sfbCnt, - const Word16 *sfbOffset, - const Word16 maxSfbPerGroup, - const Word16 *groupedSfbMinSnr, - const Word16 noOfGroups, - const Word16 *groupLen, - PSY_OUT_CHANNEL *psyOutCh); - -#endif /* _INTERFACE_H */ diff --git a/android-aac-enc/jni/inc/line_pe.h b/android-aac-enc/jni/inc/line_pe.h deleted file mode 100644 index 116d5a8c4..000000000 --- a/android-aac-enc/jni/inc/line_pe.h +++ /dev/null @@ -1,75 +0,0 @@ -/* - ** Copyright 2003-2010, VisualOn, Inc. - ** - ** Licensed under the Apache License, Version 2.0 (the "License"); - ** you may not use this file except in compliance with the License. - ** You may obtain a copy of the License at - ** - ** http://www.apache.org/licenses/LICENSE-2.0 - ** - ** Unless required by applicable law or agreed to in writing, software - ** distributed under the License is distributed on an "AS IS" BASIS, - ** WITHOUT 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: line_pe.h - - Content: Perceptual entropie module structure and functions - -*******************************************************************************/ - -#ifndef __LINE_PE_H -#define __LINE_PE_H - - -#include "psy_const.h" -#include "interface.h" - - -typedef struct { - Word16 sfbLdEnergy[MAX_GROUPED_SFB]; /* 4*log(sfbEnergy)/log(2) */ - Word16 sfbNLines4[MAX_GROUPED_SFB]; /* 4*number of relevant lines in sfb */ - Word16 sfbPe[MAX_GROUPED_SFB]; /* pe for each sfb */ - Word16 sfbConstPart[MAX_GROUPED_SFB]; /* constant part for each sfb */ - Word16 sfbNActiveLines[MAX_GROUPED_SFB]; /* number of active lines in sfb */ - Word16 pe; /* sum of sfbPe */ - Word16 constPart; /* sum of sfbConstPart */ - Word16 nActiveLines; /* sum of sfbNActiveLines */ -} PE_CHANNEL_DATA; /* size Word16: 303 */ - - -typedef struct { - PE_CHANNEL_DATA peChannelData[MAX_CHANNELS]; - Word16 pe; - Word16 constPart; - Word16 nActiveLines; - Word16 offset; - Word16 ahFlag[MAX_CHANNELS][MAX_GROUPED_SFB]; - Word32 thrExp[MAX_CHANNELS][MAX_GROUPED_SFB]; - Word32 sfbPeFactors[MAX_CHANNELS][MAX_GROUPED_SFB]; -} PE_DATA; /* size Word16: 303 + 4 + 120 + 240 = 667 */ - - - - -void prepareSfbPe(PE_DATA *peData, - PSY_OUT_CHANNEL psyOutChannel[MAX_CHANNELS], - Word16 logSfbEnergy[MAX_CHANNELS][MAX_GROUPED_SFB], - Word16 sfbNRelevantLines[MAX_CHANNELS][MAX_GROUPED_SFB], - const Word16 nChannels, - const Word16 peOffset); - - - - - -void calcSfbPe(PE_DATA *peData, - PSY_OUT_CHANNEL psyOutChannel[MAX_CHANNELS], - const Word16 nChannels); - - - - -#endif diff --git a/android-aac-enc/jni/inc/memalign.h b/android-aac-enc/jni/inc/memalign.h deleted file mode 100644 index 30bbf4501..000000000 --- a/android-aac-enc/jni/inc/memalign.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - ** Copyright 2003-2010, VisualOn, Inc. - ** - ** Licensed under the Apache License, Version 2.0 (the "License"); - ** you may not use this file except in compliance with the License. - ** You may obtain a copy of the License at - ** - ** http://www.apache.org/licenses/LICENSE-2.0 - ** - ** Unless required by applicable law or agreed to in writing, software - ** distributed under the License is distributed on an "AS IS" BASIS, - ** WITHOUT 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: memalign.h - - Content: Memory alloc alignments functions - -*******************************************************************************/ - -#ifndef __VO_AACENC_MEM_ALIGN_H__ -#define __VO_AACENC_MEM_ALIGN_H__ - -#include "voMem.h" -#include "typedef.h" - -extern void *mem_malloc(VO_MEM_OPERATOR *pMemop, unsigned int size, unsigned char alignment, unsigned int CodecID); -extern void mem_free(VO_MEM_OPERATOR *pMemop, void *mem_ptr, unsigned int CodecID); - -#endif /* __VO_MEM_ALIGN_H__ */ - - - diff --git a/android-aac-enc/jni/inc/ms_stereo.h b/android-aac-enc/jni/inc/ms_stereo.h deleted file mode 100644 index 3c03dea44..000000000 --- a/android-aac-enc/jni/inc/ms_stereo.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - ** Copyright 2003-2010, VisualOn, Inc. - ** - ** Licensed under the Apache License, Version 2.0 (the "License"); - ** you may not use this file except in compliance with the License. - ** You may obtain a copy of the License at - ** - ** http://www.apache.org/licenses/LICENSE-2.0 - ** - ** Unless required by applicable law or agreed to in writing, software - ** distributed under the License is distributed on an "AS IS" BASIS, - ** WITHOUT 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: ms_stereo.h - - Content: Declaration MS stereo processing structure and functions - -*******************************************************************************/ - -#ifndef __MS_STEREO_H__ -#define __MS_STEREO_H__ -#include "typedef.h" - -void MsStereoProcessing(Word32 *sfbEnergyLeft, - Word32 *sfbEnergyRight, - const Word32 *sfbEnergyMid, - const Word32 *sfbEnergySide, - Word32 *mdctSpectrumLeft, - Word32 *mdctSpectrumRight, - Word32 *sfbThresholdLeft, - Word32 *sfbThresholdRight, - Word32 *sfbSpreadedEnLeft, - Word32 *sfbSpreadedEnRight, - Word16 *msDigest, - Word16 *msMask, - const Word16 sfbCnt, - const Word16 sfbPerGroup, - const Word16 maxSfbPerGroup, - const Word16 *sfbOffset); - - -#endif diff --git a/android-aac-enc/jni/inc/oper_32b.h b/android-aac-enc/jni/inc/oper_32b.h deleted file mode 100644 index 6e5844faa..000000000 --- a/android-aac-enc/jni/inc/oper_32b.h +++ /dev/null @@ -1,89 +0,0 @@ -/* - ** Copyright 2003-2010, VisualOn, Inc. - ** - ** Licensed under the Apache License, Version 2.0 (the "License"); - ** you may not use this file except in compliance with the License. - ** You may obtain a copy of the License at - ** - ** http://www.apache.org/licenses/LICENSE-2.0 - ** - ** Unless required by applicable law or agreed to in writing, software - ** distributed under the License is distributed on an "AS IS" BASIS, - ** WITHOUT 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: oper_32b.h - - Content: Double precision operations - -*******************************************************************************/ - -#ifndef __OPER_32b_H -#define __OPER_32b_H - -#include "typedef.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#define POW2_TABLE_BITS 8 -#define POW2_TABLE_SIZE (1<> 16); - - l_var_out = (long)swLow1 * (long)var1 >> 15; - - l_var_out += swHigh1 * var1 << 1; - - return(l_var_out); -} - -__inline Word32 L_mpy_wx(Word32 L_var2, Word16 var1) -{ -#if ARMV5TE_L_MPY_LS - Word32 result; - asm volatile( - "SMULWB %[result], %[L_var2], %[var1] \n" - :[result]"=r"(result) - :[L_var2]"r"(L_var2), [var1]"r"(var1) - ); - return result; -#else - unsigned short swLow1; - Word16 swHigh1; - Word32 l_var_out; - - swLow1 = (unsigned short)(L_var2); - swHigh1 = (Word16)(L_var2 >> 16); - - l_var_out = (long)swLow1 * (long)var1 >> 16; - l_var_out += swHigh1 * var1; - - return(l_var_out); -#endif -} - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/android-aac-enc/jni/inc/pre_echo_control.h b/android-aac-enc/jni/inc/pre_echo_control.h deleted file mode 100644 index e719ba72a..000000000 --- a/android-aac-enc/jni/inc/pre_echo_control.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - ** Copyright 2003-2010, VisualOn, Inc. - ** - ** Licensed under the Apache License, Version 2.0 (the "License"); - ** you may not use this file except in compliance with the License. - ** You may obtain a copy of the License at - ** - ** http://www.apache.org/licenses/LICENSE-2.0 - ** - ** Unless required by applicable law or agreed to in writing, software - ** distributed under the License is distributed on an "AS IS" BASIS, - ** WITHOUT 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: pre_echo_control.h - - Content: Pre echo control functions - -*******************************************************************************/ - -#ifndef __PRE_ECHO_CONTROL_H -#define __PRE_ECHO_CONTROL_H - -#include "typedefs.h" - -void InitPreEchoControl(Word32 *pbThresholdnm1, - Word16 numPb, - Word32 *pbThresholdQuiet); - - -void PreEchoControl(Word32 *pbThresholdNm1, - Word16 numPb, - Word32 maxAllowedIncreaseFactor, - Word16 minRemainingThresholdFactor, - Word32 *pbThreshold, - Word16 mdctScale, - Word16 mdctScalenm1); - -#endif - diff --git a/android-aac-enc/jni/inc/psy_configuration.h b/android-aac-enc/jni/inc/psy_configuration.h deleted file mode 100644 index f6981faff..000000000 --- a/android-aac-enc/jni/inc/psy_configuration.h +++ /dev/null @@ -1,107 +0,0 @@ -/* - ** Copyright 2003-2010, VisualOn, Inc. - ** - ** Licensed under the Apache License, Version 2.0 (the "License"); - ** you may not use this file except in compliance with the License. - ** You may obtain a copy of the License at - ** - ** http://www.apache.org/licenses/LICENSE-2.0 - ** - ** Unless required by applicable law or agreed to in writing, software - ** distributed under the License is distributed on an "AS IS" BASIS, - ** WITHOUT 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: psy_configuration.h - - Content: Psychoaccoustic configuration structure and functions - -*******************************************************************************/ - -#ifndef _PSY_CONFIGURATION_H -#define _PSY_CONFIGURATION_H - -#include "typedefs.h" -#include "psy_const.h" -#include "tns.h" - -typedef struct{ - - Word16 sfbCnt; - Word16 sfbActive; /* number of sf bands containing energy after lowpass */ - const Word16 *sfbOffset; - - Word32 sfbThresholdQuiet[MAX_SFB_LONG]; - - Word16 maxAllowedIncreaseFactor; /* preecho control */ - Word16 minRemainingThresholdFactor; - - Word16 lowpassLine; - Word16 sampRateIdx; - Word32 clipEnergy; /* for level dependend tmn */ - - Word16 ratio; - Word16 sfbMaskLowFactor[MAX_SFB_LONG]; - Word16 sfbMaskHighFactor[MAX_SFB_LONG]; - - Word16 sfbMaskLowFactorSprEn[MAX_SFB_LONG]; - Word16 sfbMaskHighFactorSprEn[MAX_SFB_LONG]; - - - Word16 sfbMinSnr[MAX_SFB_LONG]; /* minimum snr (formerly known as bmax) */ - - TNS_CONFIG tnsConf; - -}PSY_CONFIGURATION_LONG; /*Word16 size: 8 + 52 + 102 + 51 + 51 + 51 + 51 + 47 = 515 */ - - -typedef struct{ - - Word16 sfbCnt; - Word16 sfbActive; /* number of sf bands containing energy after lowpass */ - const Word16 *sfbOffset; - - Word32 sfbThresholdQuiet[MAX_SFB_SHORT]; - - Word16 maxAllowedIncreaseFactor; /* preecho control */ - Word16 minRemainingThresholdFactor; - - Word16 lowpassLine; - Word16 sampRateIdx; - Word32 clipEnergy; /* for level dependend tmn */ - - Word16 ratio; - Word16 sfbMaskLowFactor[MAX_SFB_SHORT]; - Word16 sfbMaskHighFactor[MAX_SFB_SHORT]; - - Word16 sfbMaskLowFactorSprEn[MAX_SFB_SHORT]; - Word16 sfbMaskHighFactorSprEn[MAX_SFB_SHORT]; - - - Word16 sfbMinSnr[MAX_SFB_SHORT]; /* minimum snr (formerly known as bmax) */ - - TNS_CONFIG tnsConf; - -}PSY_CONFIGURATION_SHORT; /*Word16 size: 8 + 16 + 16 + 16 + 16 + 16 + 16 + 16 + 47 = 167 */ - - -/* Returns the sample rate index */ -Word32 GetSRIndex(Word32 sampleRate); - - -Word16 InitPsyConfigurationLong(Word32 bitrate, - Word32 samplerate, - Word16 bandwidth, - PSY_CONFIGURATION_LONG *psyConf); - -Word16 InitPsyConfigurationShort(Word32 bitrate, - Word32 samplerate, - Word16 bandwidth, - PSY_CONFIGURATION_SHORT *psyConf); - -#endif /* _PSY_CONFIGURATION_H */ - - - diff --git a/android-aac-enc/jni/inc/psy_const.h b/android-aac-enc/jni/inc/psy_const.h deleted file mode 100644 index 19fb9b2e1..000000000 --- a/android-aac-enc/jni/inc/psy_const.h +++ /dev/null @@ -1,80 +0,0 @@ -/* - ** Copyright 2003-2010, VisualOn, Inc. - ** - ** Licensed under the Apache License, Version 2.0 (the "License"); - ** you may not use this file except in compliance with the License. - ** You may obtain a copy of the License at - ** - ** http://www.apache.org/licenses/LICENSE-2.0 - ** - ** Unless required by applicable law or agreed to in writing, software - ** distributed under the License is distributed on an "AS IS" BASIS, - ** WITHOUT 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: psy_const.h - - Content: Global psychoacoustic constants structures - -*******************************************************************************/ - -#ifndef _PSYCONST_H -#define _PSYCONST_H - -#include "config.h" - -#define TRUE 1 -#define FALSE 0 - -#define FRAME_LEN_LONG AACENC_BLOCKSIZE -#define TRANS_FAC 8 -#define FRAME_LEN_SHORT (FRAME_LEN_LONG/TRANS_FAC) - - - -/* Block types */ -enum -{ - LONG_WINDOW = 0, - START_WINDOW, - SHORT_WINDOW, - STOP_WINDOW -}; - -/* Window shapes */ -enum -{ - SINE_WINDOW = 0, - KBD_WINDOW = 1 -}; - -/* - MS stuff -*/ -enum -{ - SI_MS_MASK_NONE = 0, - SI_MS_MASK_SOME = 1, - SI_MS_MASK_ALL = 2 -}; - -#define MAX_NO_OF_GROUPS 4 -#define MAX_SFB_SHORT 15 /* 15 for a memory optimized implementation, maybe 16 for convenient debugging */ -#define MAX_SFB_LONG 51 /* 51 for a memory optimized implementation, maybe 64 for convenient debugging */ -#define MAX_SFB (MAX_SFB_SHORT > MAX_SFB_LONG ? MAX_SFB_SHORT : MAX_SFB_LONG) /* = MAX_SFB_LONG */ -#define MAX_GROUPED_SFB (MAX_NO_OF_GROUPS*MAX_SFB_SHORT > MAX_SFB_LONG ? \ - MAX_NO_OF_GROUPS*MAX_SFB_SHORT : MAX_SFB_LONG) - -#define BLOCK_SWITCHING_OFFSET (1*1024+3*128+64+128) -#define BLOCK_SWITCHING_DATA_SIZE FRAME_LEN_LONG - -#define TRANSFORM_OFFSET_LONG 0 -#define TRANSFORM_OFFSET_SHORT 448 - -#define LOG_NORM_PCM -15 - -#define NUM_SAMPLE_RATES 12 - -#endif /* _PSYCONST_H */ diff --git a/android-aac-enc/jni/inc/psy_data.h b/android-aac-enc/jni/inc/psy_data.h deleted file mode 100644 index 3ea6a84d4..000000000 --- a/android-aac-enc/jni/inc/psy_data.h +++ /dev/null @@ -1,66 +0,0 @@ -/* - ** Copyright 2003-2010, VisualOn, Inc. - ** - ** Licensed under the Apache License, Version 2.0 (the "License"); - ** you may not use this file except in compliance with the License. - ** You may obtain a copy of the License at - ** - ** http://www.apache.org/licenses/LICENSE-2.0 - ** - ** Unless required by applicable law or agreed to in writing, software - ** distributed under the License is distributed on an "AS IS" BASIS, - ** WITHOUT 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: psy_data.h - - Content: Psychoacoustic data and structures - -*******************************************************************************/ - -#ifndef _PSY_DATA_H -#define _PSY_DATA_H - -#include "block_switch.h" -#include "tns.h" - -/* - the structs can be implemented as unions -*/ - -typedef struct{ - Word32 sfbLong[MAX_GROUPED_SFB]; - Word32 sfbShort[TRANS_FAC][MAX_SFB_SHORT]; -}SFB_THRESHOLD; /* Word16 size: 260 */ - -typedef struct{ - Word32 sfbLong[MAX_GROUPED_SFB]; - Word32 sfbShort[TRANS_FAC][MAX_SFB_SHORT]; -}SFB_ENERGY; /* Word16 size: 260 */ - -typedef struct{ - Word32 sfbLong; - Word32 sfbShort[TRANS_FAC]; -}SFB_ENERGY_SUM; /* Word16 size: 18 */ - - -typedef struct{ - BLOCK_SWITCHING_CONTROL blockSwitchingControl; /* block switching */ - Word16 *mdctDelayBuffer; /* mdct delay buffer [BLOCK_SWITCHING_OFFSET]*/ - Word32 sfbThresholdnm1[MAX_SFB]; /* PreEchoControl */ - Word16 mdctScalenm1; /* scale of last block's mdct (PreEchoControl) */ - - SFB_THRESHOLD sfbThreshold; /* adapt */ - SFB_ENERGY sfbEnergy; /* sfb Energy */ - SFB_ENERGY sfbEnergyMS; - SFB_ENERGY_SUM sfbEnergySum; - SFB_ENERGY_SUM sfbEnergySumMS; - SFB_ENERGY sfbSpreadedEnergy; - - Word32 *mdctSpectrum; /* mdct spectrum [FRAME_LEN_LONG] */ - Word16 mdctScale; /* scale of mdct */ -}PSY_DATA; /* Word16 size: 4 + 87 + 102 + 360 + 360 + 360 + 18 + 18 + 360 = 1669 */ - -#endif /* _PSY_DATA_H */ diff --git a/android-aac-enc/jni/inc/psy_main.h b/android-aac-enc/jni/inc/psy_main.h deleted file mode 100644 index 2ccac60b3..000000000 --- a/android-aac-enc/jni/inc/psy_main.h +++ /dev/null @@ -1,69 +0,0 @@ -/* - ** Copyright 2003-2010, VisualOn, Inc. - ** - ** Licensed under the Apache License, Version 2.0 (the "License"); - ** you may not use this file except in compliance with the License. - ** You may obtain a copy of the License at - ** - ** http://www.apache.org/licenses/LICENSE-2.0 - ** - ** Unless required by applicable law or agreed to in writing, software - ** distributed under the License is distributed on an "AS IS" BASIS, - ** WITHOUT 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: psy_main.h - - Content: Psychoacoustic major function block - -*******************************************************************************/ - -#ifndef _PSYMAIN_H -#define _PSYMAIN_H - -#include "psy_configuration.h" -#include "qc_data.h" -#include "memalign.h" - -/* - psy kernel -*/ -typedef struct { - PSY_CONFIGURATION_LONG psyConfLong; /* Word16 size: 515 */ - PSY_CONFIGURATION_SHORT psyConfShort; /* Word16 size: 167 */ - PSY_DATA psyData[MAX_CHANNELS]; /* Word16 size: MAX_CHANNELS*1669*/ - TNS_DATA tnsData[MAX_CHANNELS]; /* Word16 size: MAX_CHANNELS*235 */ - Word32* pScratchTns; - Word16 sampleRateIdx; -}PSY_KERNEL; /* Word16 size: 2587 / 4491 */ - - -Word16 PsyNew( PSY_KERNEL *hPsy, Word32 nChan, VO_MEM_OPERATOR *pMemOP); -Word16 PsyDelete( PSY_KERNEL *hPsy, VO_MEM_OPERATOR *pMemOP); - -Word16 PsyOutNew( PSY_OUT *hPsyOut, VO_MEM_OPERATOR *pMemOP); -Word16 PsyOutDelete( PSY_OUT *hPsyOut, VO_MEM_OPERATOR *pMemOP); - -Word16 psyMainInit( PSY_KERNEL *hPsy, - Word32 sampleRate, - Word32 bitRate, - Word16 channels, - Word16 tnsMask, - Word16 bandwidth); - - -Word16 psyMain(Word16 nChannels, /*!< total number of channels */ - ELEMENT_INFO *elemInfo, - Word16 *timeSignal, /*!< interleaved time signal */ - PSY_DATA psyData[MAX_CHANNELS], - TNS_DATA tnsData[MAX_CHANNELS], - PSY_CONFIGURATION_LONG* psyConfLong, - PSY_CONFIGURATION_SHORT* psyConfShort, - PSY_OUT_CHANNEL psyOutChannel[MAX_CHANNELS], - PSY_OUT_ELEMENT *psyOutElement, - Word32 *pScratchTns, - Word32 sampleRate); - -#endif /* _PSYMAIN_H */ diff --git a/android-aac-enc/jni/inc/qc_data.h b/android-aac-enc/jni/inc/qc_data.h deleted file mode 100644 index 109922df0..000000000 --- a/android-aac-enc/jni/inc/qc_data.h +++ /dev/null @@ -1,143 +0,0 @@ -/* - ** Copyright 2003-2010, VisualOn, Inc. - ** - ** Licensed under the Apache License, Version 2.0 (the "License"); - ** you may not use this file except in compliance with the License. - ** You may obtain a copy of the License at - ** - ** http://www.apache.org/licenses/LICENSE-2.0 - ** - ** Unless required by applicable law or agreed to in writing, software - ** distributed under the License is distributed on an "AS IS" BASIS, - ** WITHOUT 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: qc_data.h - - Content: Quantizing & coding structures - -*******************************************************************************/ - -#ifndef _QC_DATA_H -#define _QC_DATA_H - -#include "psy_const.h" -#include "dyn_bits.h" -#include "adj_thr_data.h" - - -#define MAX_MODES 10 - -typedef enum { - MODE_INVALID = 0, - MODE_1, /* mono */ - MODE_1_1, /* dual mono */ - MODE_2 /* stereo */ -} ENCODER_MODE; - -typedef enum { - ID_SCE=0, /* Single Channel Element */ - ID_CPE=1, /* Channel Pair Element */ - ID_CCE=2, /* Coupling Channel Element */ - ID_LFE=3, /* LFE Channel Element */ - ID_DSE=4, /* current one DSE element for ancillary is supported */ - ID_PCE=5, - ID_FIL=6, - ID_END=7 -}ELEMENT_TYPE; - -typedef struct { - ELEMENT_TYPE elType; - Word16 instanceTag; - Word16 nChannelsInEl; - Word16 ChannelIndex[MAX_CHANNELS]; -} ELEMENT_INFO; - -typedef struct { - Word32 paddingRest; -} PADDING; - - -/* Quantizing & coding stage */ - -struct QC_INIT{ - ELEMENT_INFO *elInfo; - Word16 maxBits; /* maximum number of bits in reservoir */ - Word16 averageBits; /* average number of bits we should use */ - Word16 bitRes; - Word16 meanPe; - Word32 chBitrate; - Word16 maxBitFac; - Word32 bitrate; - - PADDING padding; -}; - -typedef struct -{ - Word16 *quantSpec; /* [FRAME_LEN_LONG]; */ - UWord16 *maxValueInSfb; /* [MAX_GROUPED_SFB]; */ - Word16 *scf; /* [MAX_GROUPED_SFB]; */ - Word16 globalGain; - Word16 mdctScale; - Word16 groupingMask; - SECTION_DATA sectionData; - Word16 windowShape; -} QC_OUT_CHANNEL; - -typedef struct -{ - Word16 adtsUsed; - Word16 staticBitsUsed; /* for verification purposes */ - Word16 dynBitsUsed; /* for verification purposes */ - Word16 pe; - Word16 ancBitsUsed; - Word16 fillBits; -} QC_OUT_ELEMENT; - -typedef struct -{ - QC_OUT_CHANNEL qcChannel[MAX_CHANNELS]; - QC_OUT_ELEMENT qcElement; - Word16 totStaticBitsUsed; /* for verification purposes */ - Word16 totDynBitsUsed; /* for verification purposes */ - Word16 totAncBitsUsed; /* for verification purposes */ - Word16 totFillBits; - Word16 alignBits; - Word16 bitResTot; - Word16 averageBitsTot; -} QC_OUT; - -typedef struct { - Word32 chBitrate; - Word16 averageBits; /* brutto -> look ancillary.h */ - Word16 maxBits; - Word16 bitResLevel; - Word16 maxBitResBits; - Word16 relativeBits; /* Bits relative to total Bits scaled down by 2 */ -} ELEMENT_BITS; - -typedef struct -{ - /* this is basically struct QC_INIT */ - Word16 averageBitsTot; - Word16 maxBitsTot; - Word16 globStatBits; - Word16 nChannels; - Word16 bitResTot; - - Word16 maxBitFac; - - PADDING padding; - - ELEMENT_BITS elementBits; - ADJ_THR_STATE adjThr; - - Word16 logSfbFormFactor[MAX_CHANNELS][MAX_GROUPED_SFB]; - Word16 sfbNRelevantLines[MAX_CHANNELS][MAX_GROUPED_SFB]; - Word16 logSfbEnergy[MAX_CHANNELS][MAX_GROUPED_SFB]; -} QC_STATE; - -#endif /* _QC_DATA_H */ diff --git a/android-aac-enc/jni/inc/qc_main.h b/android-aac-enc/jni/inc/qc_main.h deleted file mode 100644 index 8f8397304..000000000 --- a/android-aac-enc/jni/inc/qc_main.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - ** Copyright 2003-2010, VisualOn, Inc. - ** - ** Licensed under the Apache License, Version 2.0 (the "License"); - ** you may not use this file except in compliance with the License. - ** You may obtain a copy of the License at - ** - ** http://www.apache.org/licenses/LICENSE-2.0 - ** - ** Unless required by applicable law or agreed to in writing, software - ** distributed under the License is distributed on an "AS IS" BASIS, - ** WITHOUT 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: qc_main.h - - Content: Quantizing & coding functions - -*******************************************************************************/ - -#ifndef _QC_MAIN_H -#define _QC_MAIN_H - -#include "qc_data.h" -#include "interface.h" -#include "memalign.h" - -/* Quantizing & coding stage */ - -Word16 QCOutNew(QC_OUT *hQC, Word16 nChannels, VO_MEM_OPERATOR *pMemOP); - -void QCOutDelete(QC_OUT *hQC, VO_MEM_OPERATOR *pMemOP); - -Word16 QCNew(QC_STATE *hQC, VO_MEM_OPERATOR *pMemOP); - -Word16 QCInit(QC_STATE *hQC, - struct QC_INIT *init); - -void QCDelete(QC_STATE *hQC, VO_MEM_OPERATOR *pMemOP); - - -Word16 QCMain(QC_STATE *hQC, - ELEMENT_BITS* elBits, - ATS_ELEMENT* adjThrStateElement, - PSY_OUT_CHANNEL psyOutChannel[MAX_CHANNELS], /* may be modified in-place */ - PSY_OUT_ELEMENT* psyOutElement, - QC_OUT_CHANNEL qcOutChannel[MAX_CHANNELS], /* out */ - QC_OUT_ELEMENT* qcOutElement, - Word16 nChannels, - Word16 ancillaryDataBytes); /* returns error code */ - -void updateBitres(QC_STATE* qcKernel, - QC_OUT* qcOut); - -Word16 FinalizeBitConsumption(QC_STATE *hQC, - QC_OUT* qcOut); - -Word16 AdjustBitrate(QC_STATE *hQC, - Word32 bitRate, - Word32 sampleRate); - -#endif /* _QC_MAIN_H */ diff --git a/android-aac-enc/jni/inc/quantize.h b/android-aac-enc/jni/inc/quantize.h deleted file mode 100644 index 1cafef69c..000000000 --- a/android-aac-enc/jni/inc/quantize.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - ** Copyright 2003-2010, VisualOn, Inc. - ** - ** Licensed under the Apache License, Version 2.0 (the "License"); - ** you may not use this file except in compliance with the License. - ** You may obtain a copy of the License at - ** - ** http://www.apache.org/licenses/LICENSE-2.0 - ** - ** Unless required by applicable law or agreed to in writing, software - ** distributed under the License is distributed on an "AS IS" BASIS, - ** WITHOUT 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: quantize.h - - Content: Quantization functions - -*******************************************************************************/ - -#ifndef _QUANTIZE_H_ -#define _QUANTIZE_H_ -#include "typedefs.h" - -/* quantizing */ - -#define MAX_QUANT 8191 - -void QuantizeSpectrum(Word16 sfbCnt, - Word16 maxSfbPerGroup, - Word16 sfbPerGroup, - Word16 *sfbOffset, Word32 *mdctSpectrum, - Word16 globalGain, Word16 *scalefactors, - Word16 *quantizedSpectrum); - -Word32 calcSfbDist(const Word32 *spec, - Word16 sfbWidth, - Word16 gain); - -#endif /* _QUANTIZE_H_ */ diff --git a/android-aac-enc/jni/inc/sf_estim.h b/android-aac-enc/jni/inc/sf_estim.h deleted file mode 100644 index 997eba5b8..000000000 --- a/android-aac-enc/jni/inc/sf_estim.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - ** Copyright 2003-2010, VisualOn, Inc. - ** - ** Licensed under the Apache License, Version 2.0 (the "License"); - ** you may not use this file except in compliance with the License. - ** You may obtain a copy of the License at - ** - ** http://www.apache.org/licenses/LICENSE-2.0 - ** - ** Unless required by applicable law or agreed to in writing, software - ** distributed under the License is distributed on an "AS IS" BASIS, - ** WITHOUT 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: sf_estim.h - - Content: Scale factor estimation functions - -*******************************************************************************/ - -#ifndef __SF_ESTIM_H__ -#define __SF_ESTIM_H__ -/* - Scale factor estimation - */ -#include "psy_const.h" -#include "interface.h" -#include "qc_data.h" - -void -CalcFormFactor(Word16 logSfbFormFactor[MAX_CHANNELS][MAX_GROUPED_SFB], - Word16 sfbNRelevantLines[MAX_CHANNELS][MAX_GROUPED_SFB], - Word16 logSfbEnergy[MAX_CHANNELS][MAX_GROUPED_SFB], - PSY_OUT_CHANNEL psyOutChannel[MAX_CHANNELS], - const Word16 nChannels); - -void -EstimateScaleFactors(PSY_OUT_CHANNEL psyOutChannel[MAX_CHANNELS], - QC_OUT_CHANNEL qcOutChannel[MAX_CHANNELS], - Word16 logSfbEnergy[MAX_CHANNELS][MAX_GROUPED_SFB], - Word16 logSfbFormFactor[MAX_CHANNELS][MAX_GROUPED_SFB], - Word16 sfbNRelevantLines[MAX_CHANNELS][MAX_GROUPED_SFB], - const Word16 nChannels); -#endif diff --git a/android-aac-enc/jni/inc/spreading.h b/android-aac-enc/jni/inc/spreading.h deleted file mode 100644 index 0c96fc750..000000000 --- a/android-aac-enc/jni/inc/spreading.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - ** Copyright 2003-2010, VisualOn, Inc. - ** - ** Licensed under the Apache License, Version 2.0 (the "License"); - ** you may not use this file except in compliance with the License. - ** You may obtain a copy of the License at - ** - ** http://www.apache.org/licenses/LICENSE-2.0 - ** - ** Unless required by applicable law or agreed to in writing, software - ** distributed under the License is distributed on an "AS IS" BASIS, - ** WITHOUT 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: spreading.h - - Content: Spreading of energy functions - -*******************************************************************************/ - -#ifndef _SPREADING_H -#define _SPREADING_H -#include "typedefs.h" - - -void SpreadingMax(const Word16 pbCnt, - const Word16 *maskLowFactor, - const Word16 *maskHighFactor, - Word32 *pbSpreadedEnergy); - -#endif /* #ifndef _SPREADING_H */ diff --git a/android-aac-enc/jni/inc/stat_bits.h b/android-aac-enc/jni/inc/stat_bits.h deleted file mode 100644 index 9cddc1d54..000000000 --- a/android-aac-enc/jni/inc/stat_bits.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - ** Copyright 2003-2010, VisualOn, Inc. - ** - ** Licensed under the Apache License, Version 2.0 (the "License"); - ** you may not use this file except in compliance with the License. - ** You may obtain a copy of the License at - ** - ** http://www.apache.org/licenses/LICENSE-2.0 - ** - ** Unless required by applicable law or agreed to in writing, software - ** distributed under the License is distributed on an "AS IS" BASIS, - ** WITHOUT 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: stat_bits.h - - Content: Static bit counter functions - -*******************************************************************************/ - -#ifndef __STAT_BITS_H -#define __STAT_BITS_H - -#include "psy_const.h" -#include "interface.h" - -Word16 countStaticBitdemand(PSY_OUT_CHANNEL psyOutChannel[MAX_CHANNELS], - PSY_OUT_ELEMENT *psyOutElement, - Word16 nChannels, - Word16 adtsUsed); - -#endif /* __STAT_BITS_H */ diff --git a/android-aac-enc/jni/inc/tns.h b/android-aac-enc/jni/inc/tns.h deleted file mode 100644 index 40cfaee79..000000000 --- a/android-aac-enc/jni/inc/tns.h +++ /dev/null @@ -1,108 +0,0 @@ -/* - ** Copyright 2003-2010, VisualOn, Inc. - ** - ** Licensed under the Apache License, Version 2.0 (the "License"); - ** you may not use this file except in compliance with the License. - ** You may obtain a copy of the License at - ** - ** http://www.apache.org/licenses/LICENSE-2.0 - ** - ** Unless required by applicable law or agreed to in writing, software - ** distributed under the License is distributed on an "AS IS" BASIS, - ** WITHOUT 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: tns.h - - Content: TNS structures - -*******************************************************************************/ - -#ifndef _TNS_H -#define _TNS_H - -#include "typedef.h" -#include "psy_const.h" - - - -#define TNS_MAX_ORDER 12 -#define TNS_MAX_ORDER_SHORT 5 - -#define FILTER_DIRECTION 0 - -typedef struct{ /*stuff that is tabulated dependent on bitrate etc. */ - Word16 threshOn; /* min. prediction gain for using tns TABUL * 100*/ - Word32 lpcStartFreq; /* lowest freq for lpc TABUL*/ - Word32 lpcStopFreq; /* TABUL */ - Word32 tnsTimeResolution; -}TNS_CONFIG_TABULATED; - - -typedef struct { /*assigned at InitTime*/ - Word16 tnsActive; - Word16 tnsMaxSfb; - - Word16 maxOrder; /* max. order of tns filter */ - Word16 tnsStartFreq; /* lowest freq. for tns filtering */ - Word16 coefRes; - - TNS_CONFIG_TABULATED confTab; - - Word32 acfWindow[TNS_MAX_ORDER+1]; - - Word16 tnsStartBand; - Word16 tnsStartLine; - - Word16 tnsStopBand; - Word16 tnsStopLine; - - Word16 lpcStartBand; - Word16 lpcStartLine; - - Word16 lpcStopBand; - Word16 lpcStopLine; - - Word16 tnsRatioPatchLowestCb; - Word16 tnsModifyBeginCb; - - Word16 threshold; /* min. prediction gain for using tns TABUL * 100 */ - -}TNS_CONFIG; - - -typedef struct { - Word16 tnsActive; - Word32 parcor[TNS_MAX_ORDER]; - Word16 predictionGain; -} TNS_SUBBLOCK_INFO; /* Word16 size: 26 */ - -typedef struct{ - TNS_SUBBLOCK_INFO subBlockInfo[TRANS_FAC]; -} TNS_DATA_SHORT; - -typedef struct{ - TNS_SUBBLOCK_INFO subBlockInfo; -} TNS_DATA_LONG; - -typedef struct{ - TNS_DATA_LONG tnsLong; - TNS_DATA_SHORT tnsShort; -}TNS_DATA_RAW; - -typedef struct{ - Word16 numOfSubblocks; - TNS_DATA_RAW dataRaw; -}TNS_DATA; /* Word16 size: 1 + 8*26 + 26 = 235 */ - -typedef struct{ - Word16 tnsActive[TRANS_FAC]; - Word16 coefRes[TRANS_FAC]; - Word16 length[TRANS_FAC]; - Word16 order[TRANS_FAC]; - Word16 coef[TRANS_FAC*TNS_MAX_ORDER_SHORT]; -}TNS_INFO; /* Word16 size: 72 */ - -#endif /* _TNS_H */ diff --git a/android-aac-enc/jni/inc/tns_func.h b/android-aac-enc/jni/inc/tns_func.h deleted file mode 100644 index 02df24de5..000000000 --- a/android-aac-enc/jni/inc/tns_func.h +++ /dev/null @@ -1,75 +0,0 @@ -/* - ** Copyright 2003-2010, VisualOn, Inc. - ** - ** Licensed under the Apache License, Version 2.0 (the "License"); - ** you may not use this file except in compliance with the License. - ** You may obtain a copy of the License at - ** - ** http://www.apache.org/licenses/LICENSE-2.0 - ** - ** Unless required by applicable law or agreed to in writing, software - ** distributed under the License is distributed on an "AS IS" BASIS, - ** WITHOUT 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: tns_func.h - - Content: TNS functions - -*******************************************************************************/ - -/* - Temporal noise shaping - */ -#ifndef _TNS_FUNC_H -#define _TNS_FUNC_H -#include "typedef.h" -#include "psy_configuration.h" - -Word16 InitTnsConfigurationLong(Word32 bitrate, - Word32 samplerate, - Word16 channels, - TNS_CONFIG *tnsConfig, - PSY_CONFIGURATION_LONG *psyConfig, - Word16 active); - -Word16 InitTnsConfigurationShort(Word32 bitrate, - Word32 samplerate, - Word16 channels, - TNS_CONFIG *tnsConfig, - PSY_CONFIGURATION_SHORT *psyConfig, - Word16 active); - -Word32 TnsDetect(TNS_DATA* tnsData, - TNS_CONFIG tC, - Word32* pScratchTns, - const Word16 sfbOffset[], - Word32* spectrum, - Word16 subBlockNumber, - Word16 blockType, - Word32 * sfbEnergy); - -void TnsSync(TNS_DATA *tnsDataDest, - const TNS_DATA *tnsDataSrc, - const TNS_CONFIG tC, - const Word16 subBlockNumber, - const Word16 blockType); - -Word16 TnsEncode(TNS_INFO* tnsInfo, - TNS_DATA* tnsData, - Word16 numOfSfb, - TNS_CONFIG tC, - Word16 lowPassLine, - Word32* spectrum, - Word16 subBlockNumber, - Word16 blockType); - -void ApplyTnsMultTableToRatios(Word16 startCb, - Word16 stopCb, - TNS_SUBBLOCK_INFO subInfo, - Word32 *thresholds); - - -#endif /* _TNS_FUNC_H */ diff --git a/android-aac-enc/jni/inc/tns_param.h b/android-aac-enc/jni/inc/tns_param.h deleted file mode 100644 index 0aa33c353..000000000 --- a/android-aac-enc/jni/inc/tns_param.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - ** Copyright 2003-2010, VisualOn, Inc. - ** - ** Licensed under the Apache License, Version 2.0 (the "License"); - ** you may not use this file except in compliance with the License. - ** You may obtain a copy of the License at - ** - ** http://www.apache.org/licenses/LICENSE-2.0 - ** - ** Unless required by applicable law or agreed to in writing, software - ** distributed under the License is distributed on an "AS IS" BASIS, - ** WITHOUT 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: tns_param.h - - Content: TNS parameters - -*******************************************************************************/ - -/* - TNS parameters - */ -#ifndef _TNS_PARAM_H -#define _TNS_PARAM_H - -#include "tns.h" - -typedef struct{ - Word32 samplingRate; - Word16 maxBandLong; - Word16 maxBandShort; -}TNS_MAX_TAB_ENTRY; - -typedef struct{ - Word32 bitRateFrom; - Word32 bitRateTo; - const TNS_CONFIG_TABULATED *paramMono_Long; /* contains TNS parameters */ - const TNS_CONFIG_TABULATED *paramMono_Short; - const TNS_CONFIG_TABULATED *paramStereo_Long; - const TNS_CONFIG_TABULATED *paramStereo_Short; -}TNS_INFO_TAB; - - -void GetTnsParam(TNS_CONFIG_TABULATED *tnsConfigTab, - Word32 bitRate, Word16 channels, Word16 blockType); - -void GetTnsMaxBands(Word32 samplingRate, Word16 blockType, Word16* tnsMaxSfb); - -#endif /* _TNS_PARAM_H */ diff --git a/android-aac-enc/jni/inc/transform.h b/android-aac-enc/jni/inc/transform.h deleted file mode 100644 index 311cef5e1..000000000 --- a/android-aac-enc/jni/inc/transform.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - ** Copyright 2003-2010, VisualOn, Inc. - ** - ** Licensed under the Apache License, Version 2.0 (the "License"); - ** you may not use this file except in compliance with the License. - ** You may obtain a copy of the License at - ** - ** http://www.apache.org/licenses/LICENSE-2.0 - ** - ** Unless required by applicable law or agreed to in writing, software - ** distributed under the License is distributed on an "AS IS" BASIS, - ** WITHOUT 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: transform.h - - Content: MDCT Transform functions - -*******************************************************************************/ - -#ifndef __TRANSFORM_H__ -#define __TRANSFORM_H__ - -#include "typedef.h" - -void Transform_Real(Word16 *mdctDelayBuffer, - Word16 *timeSignal, - Word16 chIncrement, /*! channel increment */ - Word32 *realOut, - Word16 *mdctScale, - Word16 windowSequence - ); - -#endif diff --git a/android-aac-enc/jni/inc/typedef.h b/android-aac-enc/jni/inc/typedef.h deleted file mode 100644 index b1f8225e4..000000000 --- a/android-aac-enc/jni/inc/typedef.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - ** Copyright 2003-2010, VisualOn, Inc. - ** - ** Licensed under the Apache License, Version 2.0 (the "License"); - ** you may not use this file except in compliance with the License. - ** You may obtain a copy of the License at - ** - ** http://www.apache.org/licenses/LICENSE-2.0 - ** - ** Unless required by applicable law or agreed to in writing, software - ** distributed under the License is distributed on an "AS IS" BASIS, - ** WITHOUT 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: typedef.h - - Content: type defined for defferent paltform - -*******************************************************************************/ - -#ifndef typedef_h -#define typedef_h "$Id $" - -#undef ORIGINAL_TYPEDEF_H /* define to get "original" ETSI version - of typedef.h */ - -#ifdef ORIGINAL_TYPEDEF_H -/* - * this is the original code from the ETSI file typedef.h - */ - -#if defined(__BORLANDC__) || defined(__WATCOMC__) || defined(_MSC_VER) || defined(__ZTC__) -typedef signed char Word8; -typedef short Word16; -typedef long Word32; -typedef int Flag; - -#elif defined(__sun) -typedef signed char Word8; -typedef short Word16; -typedef long Word32; -typedef int Flag; - -#elif defined(__unix__) || defined(__unix) -typedef signed char Word8; -typedef short Word16; -typedef int Word32; -typedef int Flag; - -#endif -#else /* not original typedef.h */ - -/* - * use (improved) type definition file typdefs.h and add a "Flag" type - */ -#include "typedefs.h" -typedef int Flag; - -#endif - -#endif diff --git a/android-aac-enc/jni/inc/typedefs.h b/android-aac-enc/jni/inc/typedefs.h deleted file mode 100644 index 29ff1e98f..000000000 --- a/android-aac-enc/jni/inc/typedefs.h +++ /dev/null @@ -1,187 +0,0 @@ -/* - ** Copyright 2003-2010, VisualOn, Inc. - ** - ** Licensed under the Apache License, Version 2.0 (the "License"); - ** you may not use this file except in compliance with the License. - ** You may obtain a copy of the License at - ** - ** http://www.apache.org/licenses/LICENSE-2.0 - ** - ** Unless required by applicable law or agreed to in writing, software - ** distributed under the License is distributed on an "AS IS" BASIS, - ** WITHOUT 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: typedefs.h - - Content: type defined or const defined - -*******************************************************************************/ - -#ifndef typedefs_h -#define typedefs_h "$Id $" - -#ifndef CHAR_BIT -#define CHAR_BIT 8 /* number of bits in a char */ -#endif - -#ifndef VOAAC_SHRT_MAX -#define VOAAC_SHRT_MAX (32767) /* maximum (signed) short value */ -#endif - -#ifndef VOAAC_SHRT_MIN -#define VOAAC_SHRT_MIN (-32768) /* minimum (signed) short value */ -#endif - -/* Define NULL pointer value */ -#ifndef NULL -#ifdef __cplusplus -#define NULL 0 -#else -#define NULL ((void *)0) -#endif -#endif - -#ifndef assert -#define assert(_Expression) ((void)0) -#endif - -#define __inline static __inline - -#define INT_BITS 32 -/* -******************************************************************************** -* DEFINITION OF CONSTANTS -******************************************************************************** -*/ -/* - ********* define char type - */ -typedef char Char; - -/* - ********* define 8 bit signed/unsigned types & constants - */ -typedef signed char Word8; -typedef unsigned char UWord8; -/* - ********* define 16 bit signed/unsigned types & constants - */ -typedef short Word16; -typedef unsigned short UWord16; - -/* - ********* define 32 bit signed/unsigned types & constants - */ -typedef int Word32; -typedef unsigned int UWord32; - - - -#ifndef _MSC_VER -typedef long long Word64; -typedef unsigned long long UWord64; -#else -typedef __int64 Word64; -typedef unsigned __int64 UWord64; -#endif - -#ifndef min -#define min(a,b) ( a < b ? a : b) -#endif - -#ifndef max -#define max(a,b) ( a > b ? a : b) -#endif - -#ifdef ARM_INASM -#ifdef ARMV5_INASM -#define ARMV5E_INASM 1 -#endif -#define ARMV4_INASM 1 -#endif - -#if ARMV4_INASM - #define ARMV5TE_SAT 1 - #define ARMV5TE_ADD 1 - #define ARMV5TE_SUB 1 - #define ARMV5TE_SHL 1 - #define ARMV5TE_SHR 1 - #define ARMV5TE_L_SHL 1 - #define ARMV5TE_L_SHR 1 -#endif//ARMV4 -#if ARMV5E_INASM - #define ARMV5TE_L_ADD 1 - #define ARMV5TE_L_SUB 1 - #define ARMV5TE_L_MULT 1 - #define ARMV5TE_L_MAC 1 - #define ARMV5TE_L_MSU 1 - - - #define ARMV5TE_DIV_S 1 - #define ARMV5TE_ROUND 1 - #define ARMV5TE_MULT 1 - - #define ARMV5TE_NORM_S 1 - #define ARMV5TE_NORM_L 1 - #define ARMV5TE_L_MPY_LS 1 -#endif -#if ARMV6_INASM - #undef ARMV5TE_ADD - #define ARMV5TE_ADD 0 - #undef ARMV5TE_SUB - #define ARMV5TE_SUB 0 - #define ARMV6_SAT 1 -#endif - -//basic operation functions optimization flags -#define SATRUATE_IS_INLINE 1 //define saturate as inline function -#define SHL_IS_INLINE 1 //define shl as inline function -#define SHR_IS_INLINE 1 //define shr as inline function -#define L_MULT_IS_INLINE 1 //define L_mult as inline function -#define L_MSU_IS_INLINE 1 //define L_msu as inline function -#define L_SUB_IS_INLINE 1 //define L_sub as inline function -#define L_SHL_IS_INLINE 1 //define L_shl as inline function -#define L_SHR_IS_INLINE 1 //define L_shr as inline function -#define ADD_IS_INLINE 1 //define add as inline function //add, inline is the best -#define SUB_IS_INLINE 1 //define sub as inline function //sub, inline is the best -#define DIV_S_IS_INLINE 1 //define div_s as inline function -#define MULT_IS_INLINE 1 //define mult as inline function -#define NORM_S_IS_INLINE 1 //define norm_s as inline function -#define NORM_L_IS_INLINE 1 //define norm_l as inline function -#define ROUND_IS_INLINE 1 //define round as inline function -#define L_MAC_IS_INLINE 1 //define L_mac as inline function -#define L_ADD_IS_INLINE 1 //define L_add as inline function -#define EXTRACT_H_IS_INLINE 1 //define extract_h as inline function -#define EXTRACT_L_IS_INLINE 1 //define extract_l as inline function //??? -#define MULT_R_IS_INLINE 1 //define mult_r as inline function -#define SHR_R_IS_INLINE 1 //define shr_r as inline function -#define MAC_R_IS_INLINE 1 //define mac_r as inline function -#define MSU_R_IS_INLINE 1 //define msu_r as inline function -#define L_SHR_R_IS_INLINE 1 //define L_shr_r as inline function - -#define PREFIX voAACEnc -#define LINK0(x, y, z) LINK1(x,y,z) -#define LINK1(x,y,z) x##y##z -#define ADD_PREFIX(func) LINK0(PREFIX, _, func) - -#define L_Extract ADD_PREFIX(L_Extract) -#define L_Comp ADD_PREFIX(L_Comp) -#define Mpy_32 ADD_PREFIX(Mpy_32) -#define Mpy_32_16 ADD_PREFIX(Mpy_32_16) -#define Div_32 ADD_PREFIX(Div_32) -#define iLog4 ADD_PREFIX(iLog4) -#define rsqrt ADD_PREFIX(rsqrt) -#define pow2_xy ADD_PREFIX(pow2_xy) -#define L_mpy_ls ADD_PREFIX(L_mpy_ls) -#define L_mpy_wx ADD_PREFIX(L_mpy_wx) -#define TnsEncode ADD_PREFIX(TnsEncode) -#define GetSRIndex ADD_PREFIX(GetSRIndex) -#define WriteBitstream ADD_PREFIX(WriteBitstream) - -#define mem_malloc ADD_PREFIX(mem_malloc) -#define mem_free ADD_PREFIX(mem_free) - -#endif diff --git a/android-aac-enc/jni/inc/voAAC.h b/android-aac-enc/jni/inc/voAAC.h deleted file mode 100644 index 9ecb14246..000000000 --- a/android-aac-enc/jni/inc/voAAC.h +++ /dev/null @@ -1,74 +0,0 @@ -/* - ** Copyright 2003-2010, VisualOn, Inc. - ** - ** Licensed under the Apache License, Version 2.0 (the "License"); - ** you may not use this file except in compliance with the License. - ** You may obtain a copy of the License at - ** - ** http://www.apache.org/licenses/LICENSE-2.0 - ** - ** Unless required by applicable law or agreed to in writing, software - ** distributed under the License is distributed on an "AS IS" BASIS, - ** WITHOUT 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: voAAC.h - - Content: AAC codec APIs & data types - -*******************************************************************************/ - -#ifndef __voAAC_H__ -#define __voAAC_H__ - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -#include "voAudio.h" - -/*! - * the frame type that the decoder supports - */ -typedef enum { - VOAAC_RAWDATA = 0, /*! */ - VOAMRWB_N_MODES = 9, /*!< Invalid mode */ - VOAMRWB_MODE_MAX = VO_MAX_ENUM_VALUE - -}VOAMRWBMODE; - -/*!* the frame format the codec supports*/ -typedef enum { - VOAMRWB_DEFAULT = 0, /*!< the frame type is the header (defined in RFC3267) + rawdata*/ - /*One word (2-byte) for sync word (0x6b21)*/ - /*One word (2-byte) for frame length N.*/ - /*N words (2-byte) containing N bits (bit 0 = 0x007f, bit 1 = 0x0081).*/ - VOAMRWB_ITU = 1, - /*One word (2-byte) for sync word (0x6b21).*/ - /*One word (2-byte) to indicate the frame type.*/ - /*One word (2-byte) to indicate the mode.*/ - /*N words (2-byte) containing N bits (bit 0 = 0xff81, bit 1 = 0x007f).*/ - VOAMRWB_RFC3267 = 2, /* see RFC 3267 */ - VOAMRWB_TMAX = VO_MAX_ENUM_VALUE -}VOAMRWBFRAMETYPE; - - -#define VO_PID_AMRWB_Module 0x42261000 -#define VO_PID_AMRWB_FORMAT (VO_PID_AMRWB_Module | 0x0002) -#define VO_PID_AMRWB_CHANNELS (VO_PID_AMRWB_Module | 0x0003) -#define VO_PID_AMRWB_SAMPLERATE (VO_PID_AMRWB_Module | 0x0004) -#define VO_PID_AMRWB_FRAMETYPE (VO_PID_AMRWB_Module | 0x0005) -#define VO_PID_AMRWB_MODE (VO_PID_AMRWB_Module | 0x0006) -#define VO_PID_AMRWB_DTX (VO_PID_AMRWB_Module | 0x0007) - -/** - * Get audio codec API interface - * \param pEncHandle [out] Return the AMRWB Encoder handle. - * \retval VO_ERR_OK Succeeded. - */ -VO_S32 VO_API voGetAMRWBEncAPI(VO_AUDIO_CODECAPI *pEncHandle); - - -#pragma pack(pop) -#ifdef __cplusplus -} /* extern "C" */ -#endif /* __cplusplus */ - - -#endif //__VOAMRWB_H__ - diff --git a/android-aac-enc/jni/inc/voAudio.h b/android-aac-enc/jni/inc/voAudio.h deleted file mode 100644 index d8628eeae..000000000 --- a/android-aac-enc/jni/inc/voAudio.h +++ /dev/null @@ -1,173 +0,0 @@ -/* - ** Copyright 2003-2010, VisualOn, Inc. - ** - ** Licensed under the Apache License, Version 2.0 (the "License"); - ** you may not use this file except in compliance with the License. - ** You may obtain a copy of the License at - ** - ** http://www.apache.org/licenses/LICENSE-2.0 - ** - ** Unless required by applicable law or agreed to in writing, software - ** distributed under the License is distributed on an "AS IS" BASIS, - ** WITHOUT 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: voAudio.h - - Content: Audio types and functions - -*******************************************************************************/ - -#ifndef __voAudio_H__ -#define __voAudio_H__ - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -#include "voIndex.h" -#include "voMem.h" - -#define VO_PID_AUDIO_BASE 0x42000000 /*!< The base param ID for AUDIO codec */ -#define VO_PID_AUDIO_FORMAT (VO_PID_AUDIO_BASE | 0X0001) /*!< The format data of audio in track */ -#define VO_PID_AUDIO_SAMPLEREATE (VO_PID_AUDIO_BASE | 0X0002) /*!< The sample rate of audio */ -#define VO_PID_AUDIO_CHANNELS (VO_PID_AUDIO_BASE | 0X0003) /*!< The channel of audio */ -#define VO_PID_AUDIO_BITRATE (VO_PID_AUDIO_BASE | 0X0004) /*!< The bit rate of audio */ -#define VO_PID_AUDIO_CHANNELMODE (VO_PID_AUDIO_BASE | 0X0005) /*!< The channel mode of audio */ - -#define VO_ERR_AUDIO_BASE 0x82000000 -#define VO_ERR_AUDIO_UNSCHANNEL VO_ERR_AUDIO_BASE | 0x0001 -#define VO_ERR_AUDIO_UNSSAMPLERATE VO_ERR_AUDIO_BASE | 0x0002 -#define VO_ERR_AUDIO_UNSFEATURE VO_ERR_AUDIO_BASE | 0x0003 - - -/** - *Enumeration used to define the possible audio coding formats. - */ -typedef enum VO_AUDIO_CODINGTYPE { - VO_AUDIO_CodingUnused = 0, /**< Placeholder value when coding is N/A */ - VO_AUDIO_CodingPCM, /**< Any variant of PCM coding */ - VO_AUDIO_CodingADPCM, /**< Any variant of ADPCM encoded data */ - VO_AUDIO_CodingAMRNB, /**< Any variant of AMR encoded data */ - VO_AUDIO_CodingAMRWB, /**< Any variant of AMR encoded data */ - VO_AUDIO_CodingAMRWBP, /**< Any variant of AMR encoded data */ - VO_AUDIO_CodingQCELP13, /**< Any variant of QCELP 13kbps encoded data */ - VO_AUDIO_CodingEVRC, /**< Any variant of EVRC encoded data */ - VO_AUDIO_CodingAAC, /**< Any variant of AAC encoded data, 0xA106 - ISO/MPEG-4 AAC, 0xFF - AAC */ - VO_AUDIO_CodingAC3, /**< Any variant of AC3 encoded data */ - VO_AUDIO_CodingFLAC, /**< Any variant of FLAC encoded data */ - VO_AUDIO_CodingMP1, /**< Any variant of MP1 encoded data */ - VO_AUDIO_CodingMP3, /**< Any variant of MP3 encoded data */ - VO_AUDIO_CodingOGG, /**< Any variant of OGG encoded data */ - VO_AUDIO_CodingWMA, /**< Any variant of WMA encoded data */ - VO_AUDIO_CodingRA, /**< Any variant of RA encoded data */ - VO_AUDIO_CodingMIDI, /**< Any variant of MIDI encoded data */ - VO_AUDIO_CodingDRA, /**< Any variant of dra encoded data */ - VO_AUDIO_CodingG729, /**< Any variant of dra encoded data */ - VO_AUDIO_Coding_MAX = VO_MAX_ENUM_VALUE -} VO_AUDIO_CODINGTYPE; - -/*! -* the channel type value -*/ -typedef enum { - VO_CHANNEL_CENTER = 1, /*!
InputUsed is total used input data size in byte. - * \retval VO_ERR_NONE Succeeded. - * VO_ERR_INPUT_BUFFER_SMALL. The input was finished or the input data was not enought. Continue to input - * data before next call. - */ - VO_U32 (VO_API * GetOutputData) (VO_HANDLE hCodec, VO_CODECBUFFER * pOutBuffer, VO_AUDIO_OUTPUTINFO * pOutInfo); - - /** - * Set the parameter for the specified param ID. - * \param hCodec [IN]] The codec handle which was created by Init function. - * \param uParamID [IN] The param ID. - * \param pData [IN] The param value. - * \retval VO_ERR_NONE Succeeded. - */ - VO_U32 (VO_API * SetParam) (VO_HANDLE hCodec, VO_S32 uParamID, VO_PTR pData); - - /** - * Get the parameter for the specified param ID. - * \param hCodec [IN]] The codec handle which was created by Init function. - * \param uParamID [IN] The param ID. - * \param pData [IN] The param value. - * \retval VO_ERR_NONE Succeeded. - */ - VO_U32 (VO_API * GetParam) (VO_HANDLE hCodec, VO_S32 uParamID, VO_PTR pData); - - /** - * Uninit the Codec. - * \param hCodec [IN]] The codec handle which was created by Init function. - * \retval VO_ERR_NONE Succeeded. - */ - VO_U32 (VO_API * Uninit) (VO_HANDLE hCodec); -} VO_AUDIO_CODECAPI; - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif // __voAudio_H__ diff --git a/android-aac-enc/jni/inc/voIndex.h b/android-aac-enc/jni/inc/voIndex.h deleted file mode 100644 index 320a2f82f..000000000 --- a/android-aac-enc/jni/inc/voIndex.h +++ /dev/null @@ -1,193 +0,0 @@ -/* - ** Copyright 2003-2010, VisualOn, Inc. - ** - ** Licensed under the Apache License, Version 2.0 (the "License"); - ** you may not use this file except in compliance with the License. - ** You may obtain a copy of the License at - ** - ** http://www.apache.org/licenses/LICENSE-2.0 - ** - ** Unless required by applicable law or agreed to in writing, software - ** distributed under the License is distributed on an "AS IS" BASIS, - ** WITHOUT 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: voIndex.h - - Content: module and ID definition - -*******************************************************************************/ - -#ifndef __voIndex_H__ -#define __voIndex_H__ - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -#include "voType.h" - -/* Define the module ID */ -#define _MAKE_SOURCE_ID(id, name) \ -VO_INDEX_SRC_##name = _VO_INDEX_SOURCE | id, - -#define _MAKE_CODEC_ID(id, name) \ -VO_INDEX_DEC_##name = _VO_INDEX_DEC | id, \ -VO_INDEX_ENC_##name = _VO_INDEX_ENC | id, - -#define _MAKE_EFFECT_ID(id, name) \ -VO_INDEX_EFT_##name = _VO_INDEX_EFFECT | id, - -#define _MAKE_SINK_ID(id, name) \ -VO_INDEX_SNK_##name = _VO_INDEX_SINK | id, - -#define _MAKE_FILTER_ID(id, name) \ -VO_INDEX_FLT_##name = _VO_INDEX_FILTER | id, - -#define _MAKE_OMX_ID(id, name) \ -VO_INDEX_OMX_##name = _VO_INDEX_OMX | id, - -#define _MAKE_MFW_ID(id, name) \ -VO_INDEX_MFW_##name = _VO_INDEX_MFW | id, - -enum -{ - _VO_INDEX_SOURCE = 0x01000000, - _VO_INDEX_DEC = 0x02000000, - _VO_INDEX_ENC = 0x03000000, - _VO_INDEX_EFFECT = 0x04000000, - _VO_INDEX_SINK = 0x05000000, - _VO_INDEX_FILTER = 0x06000000, - _VO_INDEX_OMX = 0x07000000, - _VO_INDEX_MFW = 0x08000000, - - // define file parser modules - _MAKE_SOURCE_ID (0x010000, MP4) - _MAKE_SOURCE_ID (0x020000, AVI) - _MAKE_SOURCE_ID (0x030000, ASF) - _MAKE_SOURCE_ID (0x040000, REAL) - _MAKE_SOURCE_ID (0x050000, AUDIO) - _MAKE_SOURCE_ID (0x060000, FLASH) - _MAKE_SOURCE_ID (0x070000, OGG) - _MAKE_SOURCE_ID (0x080000, MKV) - - // define network source modules - _MAKE_SOURCE_ID (0x110000, RTSP) - _MAKE_SOURCE_ID (0x120000, HTTP) - - // define CMMB source modules - _MAKE_SOURCE_ID (0x200000, CMMB) - _MAKE_SOURCE_ID (0x210000, CMMB_INNO) - _MAKE_SOURCE_ID (0x220000, CMMB_TELE) - _MAKE_SOURCE_ID (0x230000, CMMB_SIANO) - - // define DVBT source modules - _MAKE_SOURCE_ID (0x300000, DVBT) - _MAKE_SOURCE_ID (0x310000, DVBT_DIBCOM) - - // define other source modules - _MAKE_SOURCE_ID (0x400000, ID3) - - // define video codec modules - _MAKE_CODEC_ID (0x010000, H264) - _MAKE_CODEC_ID (0x020000, MPEG4) - _MAKE_CODEC_ID (0x030000, H263) - _MAKE_CODEC_ID (0x040000, S263) - _MAKE_CODEC_ID (0x050000, RV) - _MAKE_CODEC_ID (0x060000, WMV) - _MAKE_CODEC_ID (0x070000, DIVX3) - _MAKE_CODEC_ID (0x080000, MJPEG) - _MAKE_CODEC_ID (0x090000, MPEG2) - _MAKE_CODEC_ID (0x0A0000, VP6) - - // define audio codec modules - _MAKE_CODEC_ID (0x210000, AAC) - _MAKE_CODEC_ID (0x220000, MP3) - _MAKE_CODEC_ID (0x230000, WMA) - _MAKE_CODEC_ID (0x240000, RA) - _MAKE_CODEC_ID (0x250000, AMRNB) - _MAKE_CODEC_ID (0x260000, AMRWB) - _MAKE_CODEC_ID (0x270000, AMRWBP) - _MAKE_CODEC_ID (0x280000, QCELP) - _MAKE_CODEC_ID (0x290000, EVRC) - _MAKE_CODEC_ID (0x2A0000, ADPCM) - _MAKE_CODEC_ID (0x2B0000, MIDI) - _MAKE_CODEC_ID (0x2C0000, AC3) - _MAKE_CODEC_ID (0x2D0000, FLAC) - _MAKE_CODEC_ID (0x2E0000, DRA) - _MAKE_CODEC_ID (0x2F0000, OGG) - _MAKE_CODEC_ID (0x300000, G729) - - // define image codec modules - _MAKE_CODEC_ID (0x410000, JPEG) - _MAKE_CODEC_ID (0x420000, GIF) - _MAKE_CODEC_ID (0x430000, PNG) - _MAKE_CODEC_ID (0x440000, TIF) - - // define effect modules - _MAKE_EFFECT_ID (0x010000, EQ) - - // define sink modules - _MAKE_SINK_ID (0x010000, VIDEO) - _MAKE_SINK_ID (0x020000, AUDIO) - _MAKE_SINK_ID (0x030000, CCRRR) - _MAKE_SINK_ID (0x040000, CCRRV) - - _MAKE_SINK_ID (0x110000, MP4) - _MAKE_SINK_ID (0x120000, AVI) - _MAKE_SINK_ID (0x130000, AFW) - - // define media frame module ID - _MAKE_MFW_ID (0x010000, VOMMPLAY) - _MAKE_MFW_ID (0x020000, VOMMREC) - _MAKE_MFW_ID (0x030000, VOME) -}; - - -/* define the error ID */ -#define VO_ERR_NONE 0x00000000 -#define VO_ERR_FINISH 0x00000001 -#define VO_ERR_BASE 0X80000000 -#define VO_ERR_FAILED 0x80000001 -#define VO_ERR_OUTOF_MEMORY 0x80000002 -#define VO_ERR_NOT_IMPLEMENT 0x80000003 -#define VO_ERR_INVALID_ARG 0x80000004 -#define VO_ERR_INPUT_BUFFER_SMALL 0x80000005 -#define VO_ERR_OUTPUT_BUFFER_SMALL 0x80000006 -#define VO_ERR_WRONG_STATUS 0x80000007 -#define VO_ERR_WRONG_PARAM_ID 0x80000008 -#define VO_ERR_LICENSE_ERROR 0x80000009 - -/* xxx is the module ID -#define VO_ERR_FAILED 0x8xxx0001 -#define VO_ERR_OUTOF_MEMORY 0x8xxx0002 -#define VO_ERR_NOT_IMPLEMENT 0x8xxx0003 -#define VO_ERR_INVALID_ARG 0x8xxx0004 -#define VO_ERR_INPUT_BUFFER_SMALL 0x8xxx0005 -#define VO_ERR_OUTPUT_BUFFER_SMALL 0x8xxx0006 -#define VO_ERR_WRONG_STATUS 0x8xxx0007 -#define VO_ERR_WRONG_PARAM_ID 0x8xxx0008 -#define VO_ERR_LICENSE_ERROR 0x8xxx0009 -// Module own error ID -#define VO_ERR_Module 0x8xxx0X00 -*/ - -#define VO_PID_COMMON_BASE 0x40000000 /*!< The base of common param ID */ -#define VO_PID_COMMON_QUERYMEM (VO_PID_COMMON_BASE | 0X0001) /*!< Query the memory needed; Reserved. */ -#define VO_PID_COMMON_INPUTTYPE (VO_PID_COMMON_BASE | 0X0002) /*!< Set or get the input buffer type. VO_INPUT_TYPE */ -#define VO_PID_COMMON_HASRESOURCE (VO_PID_COMMON_BASE | 0X0003) /*!< Query it has resource to be used. VO_U32 *, 1 have, 0 No */ -#define VO_PID_COMMON_HEADDATA (VO_PID_COMMON_BASE | 0X0004) /*!< Decoder track header data. VO_CODECBUFFER * */ -#define VO_PID_COMMON_FLUSH (VO_PID_COMMON_BASE | 0X0005) /*!< Flush the codec buffer. VO_U32 *, 1 Flush, 0 No * */ - -/* -// Module Param ID -#define VO_ID_Mdoule 0x0xxx1000 -*/ - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif // __voIndex_H__ diff --git a/android-aac-enc/jni/inc/voMem.h b/android-aac-enc/jni/inc/voMem.h deleted file mode 100644 index 8dfb634d5..000000000 --- a/android-aac-enc/jni/inc/voMem.h +++ /dev/null @@ -1,65 +0,0 @@ -/* - ** Copyright 2003-2010, VisualOn, Inc. - ** - ** Licensed under the Apache License, Version 2.0 (the "License"); - ** you may not use this file except in compliance with the License. - ** You may obtain a copy of the License at - ** - ** http://www.apache.org/licenses/LICENSE-2.0 - ** - ** Unless required by applicable law or agreed to in writing, software - ** distributed under the License is distributed on an "AS IS" BASIS, - ** WITHOUT 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: voMem.h - - Content: memory functions & data structures - -*******************************************************************************/ - -#ifndef __voMem_H__ -#define __voMem_H__ - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -#include "voIndex.h" - -typedef struct -{ - VO_S32 Size; /*!< Buffer stride */ - VO_S32 Flag; - VO_PTR VBuffer; /*!< user data pointer */ - VO_PTR PBuffer; /*!< user data pointer */ -} -VO_MEM_INFO; - -typedef struct VO_MEM_OPERATOR -{ - VO_U32 (VO_API * Alloc) (VO_S32 uID, VO_MEM_INFO * pMemInfo); - VO_U32 (VO_API * Free) (VO_S32 uID, VO_PTR pBuff); - VO_U32 (VO_API * Set) (VO_S32 uID, VO_PTR pBuff, VO_U8 uValue, VO_U32 uSize); - VO_U32 (VO_API * Copy) (VO_S32 uID, VO_PTR pDest, VO_PTR pSource, VO_U32 uSize); - VO_U32 (VO_API * Check) (VO_S32 uID, VO_PTR pBuffer, VO_U32 uSize); - VO_S32 (VO_API * Compare) (VO_S32 uID, VO_PTR pBuffer1, VO_PTR pBuffer2, VO_U32 uSize); - VO_U32 (VO_API * Move) (VO_S32 uID, VO_PTR pDest, VO_PTR pSource, VO_U32 uSize); -} VO_MEM_OPERATOR; - -#define voMemAlloc(pBuff, pMemOP, ID, nSize) \ -{ \ - VO_MEM_INFO voMemInfo; \ - voMemInfo.Size=nSize; \ - pMemOP->Alloc(ID, &voMemInfo); \ - pBuff=(VO_PBYTE)voMemInfo.VBuffer; \ -} - - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif // __voMem_H__ diff --git a/android-aac-enc/jni/inc/voType.h b/android-aac-enc/jni/inc/voType.h deleted file mode 100644 index 5f659ab05..000000000 --- a/android-aac-enc/jni/inc/voType.h +++ /dev/null @@ -1,221 +0,0 @@ -/* - ** Copyright 2003-2010, VisualOn, Inc. - ** - ** Licensed under the Apache License, Version 2.0 (the "License"); - ** you may not use this file except in compliance with the License. - ** You may obtain a copy of the License at - ** - ** http://www.apache.org/licenses/LICENSE-2.0 - ** - ** Unless required by applicable law or agreed to in writing, software - ** distributed under the License is distributed on an "AS IS" BASIS, - ** WITHOUT 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: voType.h - - Content: data type definition - -*******************************************************************************/ -#ifndef __voType_H__ -#define __voType_H__ - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -#ifdef _WIN32 -# define VO_API __cdecl -# define VO_CBI __stdcall -#else -# define VO_API -# define VO_CBI -#endif //_WIN32 - -/** VO_IN is used to identify inputs to an VO function. This designation - will also be used in the case of a pointer that points to a parameter - that is used as an output. */ -#ifndef VO_IN -#define VO_IN -#endif - -/** VO_OUT is used to identify outputs from an VO function. This - designation will also be used in the case of a pointer that points - to a parameter that is used as an input. */ -#ifndef VO_OUT -#define VO_OUT -#endif - -/** VO_INOUT is used to identify parameters that may be either inputs or - outputs from an VO function at the same time. This designation will - also be used in the case of a pointer that points to a parameter that - is used both as an input and an output. */ -#ifndef VO_INOUT -#define VO_INOUT -#endif - -#define VO_MAX_ENUM_VALUE 0X7FFFFFFF - -/** VO_VOID */ -typedef void VO_VOID; - -/** VO_U8 is an 8 bit unsigned quantity that is byte aligned */ -typedef unsigned char VO_U8; - -/** VO_BYTE is an 8 bit unsigned quantity that is byte aligned */ -typedef unsigned char VO_BYTE; - -/** VO_S8 is an 8 bit signed quantity that is byte aligned */ -typedef signed char VO_S8; - -/** VO_CHAR is an 8 bit signed quantity that is byte aligned */ -typedef char VO_CHAR; - -/** VO_U16 is a 16 bit unsigned quantity that is 16 bit word aligned */ -typedef unsigned short VO_U16; - -/** VO_WCHAR is a 16 bit unsigned quantity that is 16 bit word aligned */ -#if defined _WIN32 -typedef unsigned short VO_WCHAR; -typedef unsigned short* VO_PWCHAR; -#elif defined LINUX -typedef unsigned char VO_WCHAR; -typedef unsigned char* VO_PWCHAR; -#endif - -/** VO_S16 is a 16 bit signed quantity that is 16 bit word aligned */ -typedef signed short VO_S16; - -/** VO_U32 is a 32 bit unsigned quantity that is 32 bit word aligned */ -typedef unsigned long VO_U32; - -/** VO_S32 is a 32 bit signed quantity that is 32 bit word aligned */ -typedef signed long VO_S32; - -/* Users with compilers that cannot accept the "long long" designation should - define the VO_SKIP64BIT macro. It should be noted that this may cause - some components to fail to compile if the component was written to require - 64 bit integral types. However, these components would NOT compile anyway - since the compiler does not support the way the component was written. -*/ -#ifndef VO_SKIP64BIT -#ifdef _MSC_VER -/** VO_U64 is a 64 bit unsigned quantity that is 64 bit word aligned */ -typedef unsigned __int64 VO_U64; -/** VO_S64 is a 64 bit signed quantity that is 64 bit word aligned */ -typedef signed __int64 VO_S64; -#else // WIN32 -/** VO_U64 is a 64 bit unsigned quantity that is 64 bit word aligned */ -typedef unsigned long long VO_U64; -/** VO_S64 is a 64 bit signed quantity that is 64 bit word aligned */ -typedef signed long long VO_S64; -#endif // WIN32 -#endif // VO_SKIP64BIT - -/** The VO_BOOL type is intended to be used to represent a true or a false - value when passing parameters to and from the VO core and components. The - VO_BOOL is a 32 bit quantity and is aligned on a 32 bit word boundary. - */ -typedef enum VO_BOOL { - VO_FALSE = 0, - VO_TRUE = !VO_FALSE, - VO_BOOL_MAX = VO_MAX_ENUM_VALUE -} VO_BOOL; - -/** The VO_PTR type is intended to be used to pass pointers between the VO - applications and the VO Core and components. This is a 32 bit pointer and - is aligned on a 32 bit boundary. - */ -typedef void* VO_PTR; - -/** The VO_HANDLE type is intended to be used to pass pointers between the VO - applications and the VO Core and components. This is a 32 bit pointer and - is aligned on a 32 bit boundary. - */ -typedef void* VO_HANDLE; - -/** The VO_STRING type is intended to be used to pass "C" type strings between - the application and the core and component. The VO_STRING type is a 32 - bit pointer to a zero terminated string. The pointer is word aligned and - the string is byte aligned. - */ -typedef char* VO_PCHAR; - -/** The VO_PBYTE type is intended to be used to pass arrays of bytes such as - buffers between the application and the component and core. The VO_PBYTE - type is a 32 bit pointer to a zero terminated string. The pointer is word - aligned and the string is byte aligned. - */ -typedef unsigned char* VO_PBYTE; - -/** The VO_PTCHAR type is intended to be used to pass arrays of wchar such as - unicode char between the application and the component and core. The VO_PTCHAR - type is a 32 bit pointer to a zero terminated string. The pointer is word - aligned and the string is byte aligned. - */ -/* -#if !defined LINUX -typedef unsigned short* VO_PTCHAR; -typedef unsigned short* VO_TCHAR; -#else -typedef char* VO_PTCHAR; -typedef char VO_TCHAR; -#endif -*/ - -#ifndef NULL -#ifdef __cplusplus -#define NULL 0 -#else -#define NULL ((void *)0) -#endif -#endif - -/** - * Input stream format, Frame or Stream.. - */ -typedef enum { - VO_INPUT_FRAME = 1, /*!< Input contains completely frame(s) data. */ - VO_INPUT_STREAM, /*!< Input is stream data. */ - VO_INPUT_STREAM_MAX = VO_MAX_ENUM_VALUE -} VO_INPUT_TYPE; - - -/** - * General data buffer, used as input or output. - */ -typedef struct { - VO_PBYTE Buffer; /*!< Buffer pointer */ - VO_U32 Length; /*!< Buffer size in byte */ - VO_S64 Time; /*!< The time of the buffer */ -} VO_CODECBUFFER; - - -/** - * The init memdata flag. - */ -typedef enum{ - VO_IMF_USERMEMOPERATOR =0, /*!< memData is the pointer of memoperator function*/ - VO_IMF_PREALLOCATEDBUFFER =1, /*!< memData is preallocated memory*/ - VO_IMF_MAX = VO_MAX_ENUM_VALUE -}VO_INIT_MEM_FlAG; - - -/** - * The init memory structure.. - */ -typedef struct{ - VO_INIT_MEM_FlAG memflag; /*!memflag != VO_IMF_USERMEMOPERATOR || pUserData->memData == NULL ) - { -#ifdef USE_DEAULT_MEM - voMemoprator.Alloc = cmnMemAlloc; - voMemoprator.Copy = cmnMemCopy; - voMemoprator.Free = cmnMemFree; - voMemoprator.Set = cmnMemSet; - voMemoprator.Check = cmnMemCheck; - - interMem = 1; - - pMemOP = &voMemoprator; -#else - *phCodec = NULL; - return VO_ERR_INVALID_ARG; -#endif - } - else - { - pMemOP = (VO_MEM_OPERATOR *)pUserData->memData; - } - - /* init the aac encoder handle */ - hAacEnc = (AAC_ENCODER*)mem_malloc(pMemOP, sizeof(AAC_ENCODER), 32, VO_INDEX_ENC_AAC); - if(NULL == hAacEnc) - { - error = 1; - } - - if(!error) - { - /* init the aac encoder intra memory */ - hAacEnc->intbuf = (short *)mem_malloc(pMemOP, AACENC_BLOCKSIZE*MAX_CHANNELS*sizeof(short), 32, VO_INDEX_ENC_AAC); - if(NULL == hAacEnc->intbuf) - { - error = 1; - } - } - - if (!error) { - /* init the aac encoder psychoacoustic */ - error = (PsyNew(&hAacEnc->psyKernel, MAX_CHANNELS, pMemOP) || - PsyOutNew(&hAacEnc->psyOut, pMemOP)); - } - - if (!error) { - /* init the aac encoder quantization elements */ - error = QCOutNew(&hAacEnc->qcOut,MAX_CHANNELS, pMemOP); - } - - if (!error) { - /* init the aac encoder quantization state */ - error = QCNew(&hAacEnc->qcKernel, pMemOP); - } - - /* uninit the aac encoder if error is nozero */ - if(error) - { - AacEncClose(hAacEnc, pMemOP); - if(hAacEnc) - { - mem_free(pMemOP, hAacEnc, VO_INDEX_ENC_AAC); - hAacEnc = NULL; - } - *phCodec = NULL; - return VO_ERR_OUTOF_MEMORY; - } - - /* init the aac encoder memory operator */ -#ifdef USE_DEAULT_MEM - if(interMem) - { - hAacEnc->voMemoprator.Alloc = cmnMemAlloc; - hAacEnc->voMemoprator.Copy = cmnMemCopy; - hAacEnc->voMemoprator.Free = cmnMemFree; - hAacEnc->voMemoprator.Set = cmnMemSet; - hAacEnc->voMemoprator.Check = cmnMemCheck; - - pMemOP = &hAacEnc->voMemoprator; - } -#endif - /* init the aac encoder default parameter */ - if(hAacEnc->initOK == 0) - { - AACENC_CONFIG config; - config.adtsUsed = 1; - config.bitRate = 128000; - config.nChannelsIn = 2; - config.nChannelsOut = 2; - config.sampleRate = 44100; - config.bandWidth = 20000; - - AacEncOpen(hAacEnc, config); - } - - hAacEnc->voMemop = pMemOP; - - *phCodec = hAacEnc; - - return VO_ERR_NONE; -} - -/** -* Set input audio data. -* \param hCodec [IN]] The Codec Handle which was created by Init function. -* \param pInput [IN] The input buffer param. -* \param pOutBuffer [OUT] The output buffer info. -* \retval VO_ERR_NONE Succeeded. -*/ -VO_U32 VO_API voAACEncSetInputData(VO_HANDLE hCodec, VO_CODECBUFFER * pInput) -{ - AAC_ENCODER *hAacEnc; - int length; - - if(NULL == hCodec || NULL == pInput || NULL == pInput->Buffer) - { - return VO_ERR_INVALID_ARG; - } - - hAacEnc = (AAC_ENCODER *)hCodec; - - /* init input pcm buffer and length*/ - hAacEnc->inbuf = (short *)pInput->Buffer; - hAacEnc->inlen = pInput->Length / sizeof(short); - hAacEnc->uselength = 0; - - hAacEnc->encbuf = hAacEnc->inbuf; - hAacEnc->enclen = hAacEnc->inlen; - - /* rebuild intra pcm buffer and length*/ - if(hAacEnc->intlen) - { - length = min(hAacEnc->config.nChannelsIn*AACENC_BLOCKSIZE - hAacEnc->intlen, hAacEnc->inlen); - hAacEnc->voMemop->Copy(VO_INDEX_ENC_AAC, hAacEnc->intbuf + hAacEnc->intlen, - hAacEnc->inbuf, length*sizeof(short)); - - hAacEnc->encbuf = hAacEnc->intbuf; - hAacEnc->enclen = hAacEnc->intlen + length; - - hAacEnc->inbuf += length; - hAacEnc->inlen -= length; - } - - return VO_ERR_NONE; -} - -/** -* Get the outut audio data -* \param hCodec [IN]] The Codec Handle which was created by Init function. -* \param pOutBuffer [OUT] The output audio data -* \param pOutInfo [OUT] The dec module filled audio format and used the input size. -* pOutInfo->InputUsed is total used the input size. -* \retval VO_ERR_NONE Succeeded. -* VO_ERR_INPUT_BUFFER_SMALL. The input was finished or the input data was not enought. -*/ -VO_U32 VO_API voAACEncGetOutputData(VO_HANDLE hCodec, VO_CODECBUFFER * pOutput, VO_AUDIO_OUTPUTINFO * pOutInfo) -{ - AAC_ENCODER* hAacEnc = (AAC_ENCODER*)hCodec; - Word16 numAncDataBytes=0; - Word32 inbuflen; - int ret, length; - if(NULL == hAacEnc) - return VO_ERR_INVALID_ARG; - - inbuflen = AACENC_BLOCKSIZE*hAacEnc->config.nChannelsIn; - - /* check the input pcm buffer and length*/ - if(NULL == hAacEnc->encbuf || hAacEnc->enclen < inbuflen) - { - length = hAacEnc->enclen; - if(hAacEnc->intlen == 0) - { - hAacEnc->voMemop->Copy(VO_INDEX_ENC_AAC, hAacEnc->intbuf, - hAacEnc->encbuf, length*sizeof(short)); - hAacEnc->uselength += length*sizeof(short); - } - else - { - hAacEnc->uselength += (length - hAacEnc->intlen)*sizeof(short); - } - - hAacEnc->intlen = length; - - pOutput->Length = 0; - if(pOutInfo) - pOutInfo->InputUsed = hAacEnc->uselength; - return VO_ERR_INPUT_BUFFER_SMALL; - } - - /* check the output aac buffer and length*/ - if(NULL == pOutput || NULL == pOutput->Buffer || pOutput->Length < (6144/8)*hAacEnc->config.nChannelsOut/(sizeof(Word32))) - return VO_ERR_OUTPUT_BUFFER_SMALL; - - /* aac encoder core function */ - AacEncEncode( hAacEnc, - (Word16*)hAacEnc->encbuf, - NULL, - &numAncDataBytes, - pOutput->Buffer, - &pOutput->Length); - - /* update the input pcm buffer and length*/ - if(hAacEnc->intlen) - { - length = inbuflen - hAacEnc->intlen; - hAacEnc->encbuf = hAacEnc->inbuf; - hAacEnc->enclen = hAacEnc->inlen; - hAacEnc->uselength += length*sizeof(short); - hAacEnc->intlen = 0; - } - else - { - hAacEnc->encbuf = hAacEnc->encbuf + inbuflen; - hAacEnc->enclen = hAacEnc->enclen - inbuflen; - hAacEnc->uselength += inbuflen*sizeof(short); - } - - /* update the output aac information */ - if(pOutInfo) - { - pOutInfo->Format.Channels = hAacEnc->config.nChannelsOut; - pOutInfo->Format.SampleRate = hAacEnc->config.sampleRate; - pOutInfo->Format.SampleBits = 16; - pOutInfo->InputUsed = hAacEnc->uselength; - } - - return VO_ERR_NONE; -} - -/** -* Uninit the Codec. -* \param hCodec [IN]] The Codec Handle which was created by Init function. -* \retval VO_ERR_NONE Succeeded. -*/ -VO_U32 VO_API voAACEncUninit(VO_HANDLE hCodec) -{ - AAC_ENCODER* hAacEnc = (AAC_ENCODER*)hCodec; - - if(NULL != hAacEnc) - { - /* close the aac encoder */ - AacEncClose(hAacEnc, hAacEnc->voMemop); - - /* free the aac encoder handle*/ - mem_free(hAacEnc->voMemop, hAacEnc, VO_INDEX_ENC_AAC); - hAacEnc = NULL; - } - - return VO_ERR_NONE; -} - -/** -* Set the param for special target. -* \param hCodec [IN]] The Codec Handle which was created by Init function. -* \param uParamID [IN] The param ID. -* \param pData [IN] The param value depend on the ID> -* \retval VO_ERR_NONE Succeeded. -*/ -VO_U32 VO_API voAACEncSetParam(VO_HANDLE hCodec, VO_S32 uParamID, VO_PTR pData) -{ - AACENC_CONFIG config; - AACENC_PARAM* pAAC_param; - VO_AUDIO_FORMAT *pWAV_Format; - AAC_ENCODER* hAacEnc = (AAC_ENCODER*)hCodec; - int ret, i, bitrate, tmp; - int SampleRateIdx; - - if(NULL == hAacEnc) - return VO_ERR_INVALID_ARG; - - switch(uParamID) - { - case VO_PID_AAC_ENCPARAM: /* init aac encoder parameter*/ - AacInitDefaultConfig(&config); - if(pData == NULL) - return VO_ERR_INVALID_ARG; - pAAC_param = (AACENC_PARAM*)pData; - config.adtsUsed = pAAC_param->adtsUsed; - config.bitRate = pAAC_param->bitRate; - config.nChannelsIn = pAAC_param->nChannels; - config.nChannelsOut = pAAC_param->nChannels; - config.sampleRate = pAAC_param->sampleRate; - - /* check the channel */ - if(config.nChannelsIn< 1 || config.nChannelsIn > MAX_CHANNELS || - config.nChannelsOut < 1 || config.nChannelsOut > MAX_CHANNELS || config.nChannelsIn < config.nChannelsOut) - return VO_ERR_AUDIO_UNSCHANNEL; - - /* check the samplerate */ - ret = -1; - for(i = 0; i < NUM_SAMPLE_RATES; i++) - { - if(config.sampleRate == sampRateTab[i]) - { - ret = 0; - break; - } - } - if(ret < 0) - return VO_ERR_AUDIO_UNSSAMPLERATE; - - SampleRateIdx = i; - - tmp = 441; - if(config.sampleRate%8000 == 0) - tmp =480; - /* check the bitrate */ - if(config.bitRate!=0 && (config.bitRate/config.nChannelsOut < 4000) || - (config.bitRate/config.nChannelsOut > 160000) || - (config.bitRate > config.sampleRate*6*config.nChannelsOut)) - { - config.bitRate = 640*config.sampleRate/tmp*config.nChannelsOut; - - if(config.bitRate/config.nChannelsOut < 4000) - config.bitRate = 4000 * config.nChannelsOut; - else if(config.bitRate > config.sampleRate*6*config.nChannelsOut) - config.bitRate = config.sampleRate*6*config.nChannelsOut; - else if(config.bitRate/config.nChannelsOut > 160000) - config.bitRate = config.nChannelsOut*160000; - } - - /* check the bandwidth */ - bitrate = config.bitRate / config.nChannelsOut; - bitrate = bitrate * tmp / config.sampleRate; - - for (i = 0; rates[i]; i++) - { - if (rates[i] >= bitrate) - break; - } - - config.bandWidth = BandwithCoefTab[i][SampleRateIdx]; - - /* init aac encoder core */ - ret = AacEncOpen(hAacEnc, config); - if(ret) - return VO_ERR_AUDIO_UNSFEATURE; - break; - case VO_PID_AUDIO_FORMAT: /* init pcm channel and samplerate*/ - AacInitDefaultConfig(&config); - if(pData == NULL) - return VO_ERR_INVALID_ARG; - pWAV_Format = (VO_AUDIO_FORMAT*)pData; - config.adtsUsed = 1; - config.nChannelsIn = pWAV_Format->Channels; - config.nChannelsOut = pWAV_Format->Channels; - config.sampleRate = pWAV_Format->SampleRate; - - /* check the channel */ - if(config.nChannelsIn< 1 || config.nChannelsIn > MAX_CHANNELS || - config.nChannelsOut < 1 || config.nChannelsOut > MAX_CHANNELS || config.nChannelsIn < config.nChannelsOut) - return VO_ERR_AUDIO_UNSCHANNEL; - - /* check the samplebits */ - if(pWAV_Format->SampleBits != 16) - { - return VO_ERR_AUDIO_UNSFEATURE; - } - - /* check the samplerate */ - ret = -1; - for(i = 0; i < NUM_SAMPLE_RATES; i++) - { - if(config.sampleRate == sampRateTab[i]) - { - ret = 0; - break; - } - } - if(ret < 0) - return VO_ERR_AUDIO_UNSSAMPLERATE; - - SampleRateIdx = i; - - /* update the bitrates */ - tmp = 441; - if(config.sampleRate%8000 == 0) - tmp =480; - - config.bitRate = 640*config.sampleRate/tmp*config.nChannelsOut; - - if(config.bitRate/config.nChannelsOut < 4000) - config.bitRate = 4000 * config.nChannelsOut; - else if(config.bitRate > config.sampleRate*6*config.nChannelsOut) - config.bitRate = config.sampleRate*6*config.nChannelsOut; - else if(config.bitRate/config.nChannelsOut > 160000) - config.bitRate = config.nChannelsOut*160000; - - /* check the bandwidth */ - bitrate = config.bitRate / config.nChannelsOut; - bitrate = bitrate * tmp / config.sampleRate; - - for (i = 0; rates[i]; i++) - { - if (rates[i] >= bitrate) - break; - } - - config.bandWidth = BandwithCoefTab[i][SampleRateIdx]; - - /* init aac encoder core */ - ret = AacEncOpen(hAacEnc, config); - if(ret) - return VO_ERR_AUDIO_UNSFEATURE; - break; - default: - return VO_ERR_WRONG_PARAM_ID; - } - - return VO_ERR_NONE; -} - -/** -* Get the param for special target. -* \param hCodec [IN]] The Codec Handle which was created by Init function. -* \param uParamID [IN] The param ID. -* \param pData [IN] The param value depend on the ID> -* \retval VO_ERR_NONE Succeeded. -*/ -VO_U32 VO_API voAACEncGetParam(VO_HANDLE hCodec, VO_S32 uParamID, VO_PTR pData) -{ - return VO_ERR_NONE; -} - -/** - * Get audio codec API interface - * \param pEncHandle [out] Return the AAC Encoder handle. - * \retval VO_ERR_OK Succeeded. - */ -VO_S32 VO_API voGetAACEncAPI(VO_AUDIO_CODECAPI * pDecHandle) -{ - if(pDecHandle == NULL) - return VO_ERR_INVALID_ARG; - - pDecHandle->Init = voAACEncInit; - pDecHandle->SetInputData = voAACEncSetInputData; - pDecHandle->GetOutputData = voAACEncGetOutputData; - pDecHandle->SetParam = voAACEncSetParam; - pDecHandle->GetParam = voAACEncGetParam; - pDecHandle->Uninit = voAACEncUninit; - - return VO_ERR_NONE; -} diff --git a/android-aac-enc/jni/src/aacenc_core.c b/android-aac-enc/jni/src/aacenc_core.c deleted file mode 100644 index cecbc8f10..000000000 --- a/android-aac-enc/jni/src/aacenc_core.c +++ /dev/null @@ -1,239 +0,0 @@ -/* - ** Copyright 2003-2010, VisualOn, Inc. - ** - ** Licensed under the Apache License, Version 2.0 (the "License"); - ** you may not use this file except in compliance with the License. - ** You may obtain a copy of the License at - ** - ** http://www.apache.org/licenses/LICENSE-2.0 - ** - ** Unless required by applicable law or agreed to in writing, software - ** distributed under the License is distributed on an "AS IS" BASIS, - ** WITHOUT 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: aacenc_core.c - - Content: aac encoder core functions - -*******************************************************************************/ - -#include "typedef.h" -#include "aacenc_core.h" -#include "bitenc.h" - -#include "psy_configuration.h" -#include "psy_main.h" -#include "qc_main.h" -#include "psy_main.h" -#include "channel_map.h" -#include "aac_rom.h" - -/******************************************************************************** -* -* function name: AacInitDefaultConfig -* description: gives reasonable default configuration -* -**********************************************************************************/ -void AacInitDefaultConfig(AACENC_CONFIG *config) -{ - /* default configurations */ - config->adtsUsed = 1; - config->nChannelsIn = 2; - config->nChannelsOut = 2; - config->bitRate = 128000; - config->bandWidth = 0; -} - -/******************************************************************************** -* -* function name: AacEncOpen -* description: allocate and initialize a new encoder instance -* returns: 0 if success -* -**********************************************************************************/ -Word16 AacEncOpen( AAC_ENCODER* hAacEnc, /* pointer to an encoder handle, initialized on return */ - const AACENC_CONFIG config /* pre-initialized config struct */ - ) -{ - Word32 i; - Word32 error = 0; - Word16 profile = 1; - - ELEMENT_INFO *elInfo = NULL; - - if (hAacEnc==0) { - error=1; - } - - if (!error) { - hAacEnc->config = config; - } - - if (!error) { - error = InitElementInfo (config.nChannelsOut, - &hAacEnc->elInfo); - } - - if (!error) { - elInfo = &hAacEnc->elInfo; - } - - if (!error) { - /* use or not tns tool for long and short block */ - Word16 tnsMask=3; - - /* init encoder psychoacoustic */ - error = psyMainInit(&hAacEnc->psyKernel, - config.sampleRate, - config.bitRate, - elInfo->nChannelsInEl, - tnsMask, - hAacEnc->config.bandWidth); - } - - /* use or not adts header */ - if(!error) { - hAacEnc->qcOut.qcElement.adtsUsed = config.adtsUsed; - } - - /* init encoder quantization */ - if (!error) { - struct QC_INIT qcInit; - - /*qcInit.channelMapping = &hAacEnc->channelMapping;*/ - qcInit.elInfo = &hAacEnc->elInfo; - - qcInit.maxBits = (Word16) (MAXBITS_COEF*elInfo->nChannelsInEl); - qcInit.bitRes = qcInit.maxBits; - qcInit.averageBits = (Word16) ((config.bitRate * FRAME_LEN_LONG) / config.sampleRate); - - qcInit.padding.paddingRest = config.sampleRate; - - qcInit.meanPe = (Word16) ((10 * FRAME_LEN_LONG * hAacEnc->config.bandWidth) / - (config.sampleRate>>1)); - - qcInit.maxBitFac = (Word16) ((100 * (MAXBITS_COEF-MINBITS_COEF)* elInfo->nChannelsInEl)/ - (qcInit.averageBits?qcInit.averageBits:1)); - - qcInit.bitrate = config.bitRate; - - error = QCInit(&hAacEnc->qcKernel, &qcInit); - } - - /* init bitstream encoder */ - if (!error) { - hAacEnc->bseInit.nChannels = elInfo->nChannelsInEl; - hAacEnc->bseInit.bitrate = config.bitRate; - hAacEnc->bseInit.sampleRate = config.sampleRate; - hAacEnc->bseInit.profile = profile; - } - - return error; -} - -/******************************************************************************** -* -* function name: AacEncEncode -* description: encode pcm to aac data core function -* returns: 0 if success -* -**********************************************************************************/ -Word16 AacEncEncode(AAC_ENCODER *aacEnc, /*!< an encoder handle */ - Word16 *timeSignal, /*!< BLOCKSIZE*nChannels audio samples, interleaved */ - const UWord8 *ancBytes, /*!< pointer to ancillary data bytes */ - Word16 *numAncBytes, /*!< number of ancillary Data Bytes */ - UWord8 *outBytes, /*!< pointer to output buffer (must be large MINBITS_COEF/8*MAX_CHANNELS bytes) */ - VO_U32 *numOutBytes /*!< number of bytes in output buffer after processing */ - ) -{ - ELEMENT_INFO *elInfo = &aacEnc->elInfo; - Word16 globUsedBits; - Word16 ancDataBytes, ancDataBytesLeft; - - ancDataBytes = ancDataBytesLeft = *numAncBytes; - - /* init output aac data buffer and length */ - aacEnc->hBitStream = CreateBitBuffer(&aacEnc->bitStream, outBytes, *numOutBytes); - - /* psychoacoustic process */ - psyMain(aacEnc->config.nChannelsOut, - elInfo, - timeSignal, - &aacEnc->psyKernel.psyData[elInfo->ChannelIndex[0]], - &aacEnc->psyKernel.tnsData[elInfo->ChannelIndex[0]], - &aacEnc->psyKernel.psyConfLong, - &aacEnc->psyKernel.psyConfShort, - &aacEnc->psyOut.psyOutChannel[elInfo->ChannelIndex[0]], - &aacEnc->psyOut.psyOutElement, - aacEnc->psyKernel.pScratchTns, - aacEnc->config.sampleRate); - - /* adjust bitrate and frame length */ - AdjustBitrate(&aacEnc->qcKernel, - aacEnc->config.bitRate, - aacEnc->config.sampleRate); - - /* quantization and coding process */ - QCMain(&aacEnc->qcKernel, - &aacEnc->qcKernel.elementBits, - &aacEnc->qcKernel.adjThr.adjThrStateElem, - &aacEnc->psyOut.psyOutChannel[elInfo->ChannelIndex[0]], - &aacEnc->psyOut.psyOutElement, - &aacEnc->qcOut.qcChannel[elInfo->ChannelIndex[0]], - &aacEnc->qcOut.qcElement, - elInfo->nChannelsInEl, - min(ancDataBytesLeft,ancDataBytes)); - - ancDataBytesLeft = ancDataBytesLeft - ancDataBytes; - - globUsedBits = FinalizeBitConsumption(&aacEnc->qcKernel, - &aacEnc->qcOut); - - /* write bitstream process */ - WriteBitstream(aacEnc->hBitStream, - *elInfo, - &aacEnc->qcOut, - &aacEnc->psyOut, - &globUsedBits, - ancBytes, - aacEnc->psyKernel.sampleRateIdx); - - updateBitres(&aacEnc->qcKernel, - &aacEnc->qcOut); - - /* write out the bitstream */ - *numOutBytes = GetBitsAvail(aacEnc->hBitStream) >> 3; - - return 0; -} - - -/******************************************************************************** -* -* function name:AacEncClose -* description: deallocate an encoder instance -* -**********************************************************************************/ -void AacEncClose (AAC_ENCODER* hAacEnc, VO_MEM_OPERATOR *pMemOP) -{ - if (hAacEnc) { - QCDelete(&hAacEnc->qcKernel, pMemOP); - - QCOutDelete(&hAacEnc->qcOut, pMemOP); - - PsyDelete(&hAacEnc->psyKernel, pMemOP); - - PsyOutDelete(&hAacEnc->psyOut, pMemOP); - - DeleteBitBuffer(&hAacEnc->hBitStream); - - if(hAacEnc->intbuf) - { - mem_free(pMemOP, hAacEnc->intbuf, VO_INDEX_ENC_AAC); - hAacEnc->intbuf = NULL; - } - } -} diff --git a/android-aac-enc/jni/src/adj_thr.c b/android-aac-enc/jni/src/adj_thr.c deleted file mode 100644 index 07b33b7ff..000000000 --- a/android-aac-enc/jni/src/adj_thr.c +++ /dev/null @@ -1,1225 +0,0 @@ -/* - ** Copyright 2003-2010, VisualOn, Inc. - ** - ** Licensed under the Apache License, Version 2.0 (the "License"); - ** you may not use this file except in compliance with the License. - ** You may obtain a copy of the License at - ** - ** http://www.apache.org/licenses/LICENSE-2.0 - ** - ** Unless required by applicable law or agreed to in writing, software - ** distributed under the License is distributed on an "AS IS" BASIS, - ** WITHOUT 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: adj_thr.c - - Content: Threshold compensation functions - -*******************************************************************************/ - -#include "basic_op.h" -#include "oper_32b.h" -#include "adj_thr_data.h" -#include "adj_thr.h" -#include "qc_data.h" -#include "line_pe.h" -#include - - -#define minSnrLimit 0x6666 /* 1 dB */ -#define PEBITS_COEF 0x170a /* 0.18*(1 << 15)*/ - -#define HOLE_THR_LONG 0x2873 /* 0.316*(1 << 15) */ -#define HOLE_THR_SHORT 0x4000 /* 0.5 *(1 << 15) */ - -#define MS_THRSPREAD_COEF 0x7333 /* 0.9 * (1 << 15) */ - -#define MIN_SNR_COEF 0x651f /* 3.16* (1 << (15 - 2)) */ - -/* values for avoid hole flag */ -enum _avoid_hole_state { - NO_AH =0, - AH_INACTIVE =1, - AH_ACTIVE =2 -}; - -/******************************************************************************** -* -* function name:bits2pe -* description: convert from bits to pe -* pe = 1.18*desiredBits -* -**********************************************************************************/ -Word16 bits2pe(const Word16 bits) { - return (bits + ((PEBITS_COEF * bits) >> 15)); -} - -/******************************************************************************** -* -* function name:calcThreshExp -* description: loudness calculation (threshold to the power of redExp) -* thr(n)^0.25 -* -**********************************************************************************/ -static void calcThreshExp(Word32 thrExp[MAX_CHANNELS][MAX_GROUPED_SFB], - PSY_OUT_CHANNEL psyOutChannel[MAX_CHANNELS], - const Word16 nChannels) -{ - Word16 ch, sfb, sfbGrp; - Word32 *pthrExp, *psfbThre; - for (ch=0; chsfbCnt; sfbGrp+= psyOutChan->sfbPerGroup) - pthrExp = &(thrExp[ch][sfbGrp]); - psfbThre = psyOutChan->sfbThreshold + sfbGrp; - for (sfb=0; sfbmaxSfbPerGroup; sfb++) { - *pthrExp = rsqrt(rsqrt(*psfbThre,INT_BITS),INT_BITS); - pthrExp++; psfbThre++; - } - } -} - -/******************************************************************************** -* -* function name:adaptMinSnr -* description: reduce minSnr requirements for bands with relative low energies -* -**********************************************************************************/ -static void adaptMinSnr(PSY_OUT_CHANNEL psyOutChannel[MAX_CHANNELS], - Word16 logSfbEnergy[MAX_CHANNELS][MAX_GROUPED_SFB], - MINSNR_ADAPT_PARAM *msaParam, - const Word16 nChannels) -{ - Word16 ch, sfb, sfbOffs, shift; - Word32 nSfb, avgEn; - Word16 log_avgEn = 0; - Word32 startRatio_x_avgEn = 0; - - - for (ch=0; chsfbCnt; sfbOffs+=psyOutChan->sfbPerGroup) { - for (sfb=0; sfbmaxSfbPerGroup; sfb++) { - avgEn = L_add(avgEn, psyOutChan->sfbEnergy[sfbOffs+sfb]); - nSfb = nSfb + 1; - } - } - - if (nSfb > 0) { - avgEn = avgEn / nSfb; - - log_avgEn = iLog4(avgEn); - startRatio_x_avgEn = fixmul(msaParam->startRatio, avgEn); - } - - - /* reduce minSnr requirement by minSnr^minSnrRed dependent on avgEn/sfbEn */ - for (sfbOffs=0; sfbOffssfbCnt; sfbOffs+=psyOutChan->sfbPerGroup) { - for (sfb=0; sfbmaxSfbPerGroup; sfb++) { - if (psyOutChan->sfbEnergy[sfbOffs+sfb] < startRatio_x_avgEn) { - Word16 dbRatio, minSnrRed; - Word32 snrRed; - Word16 newMinSnr; - - dbRatio = log_avgEn - logSfbEnergy[ch][sfbOffs+sfb]; - dbRatio = dbRatio + (dbRatio << 1); - - minSnrRed = 110 - ((dbRatio + (dbRatio << 1)) >> 2); - minSnrRed = max(minSnrRed, 20); /* 110: (0.375(redOffs)+1)*80, - 3: 0.00375(redRatioFac)*80 - 20: 0.25(maxRed) * 80 */ - - snrRed = minSnrRed * iLog4((psyOutChan->sfbMinSnr[sfbOffs+sfb] << 16)); - /* - snrRedI si now scaled by 80 (minSnrRed) and 4 (ffr_iLog4) - */ - - newMinSnr = round16(pow2_xy(snrRed,80*4)); - - psyOutChan->sfbMinSnr[sfbOffs+sfb] = min(newMinSnr, minSnrLimit); - } - } - } - } - -} - - -/******************************************************************************** -* -* function name:initAvoidHoleFlag -* description: determine bands where avoid hole is not necessary resp. possible -* -**********************************************************************************/ -static void initAvoidHoleFlag(Word16 ahFlag[MAX_CHANNELS][MAX_GROUPED_SFB], - PSY_OUT_CHANNEL psyOutChannel[MAX_CHANNELS], - PSY_OUT_ELEMENT* psyOutElement, - const Word16 nChannels, - AH_PARAM *ahParam) -{ - Word16 ch, sfb, sfbGrp, shift; - Word32 threshold; - Word32* psfbSpreadEn; - - for (ch=0; chwindowSequence != SHORT_WINDOW) { - for(sfbGrp = 0;sfbGrp < psyOutChan->sfbCnt;sfbGrp+= psyOutChan->sfbPerGroup){ - psfbSpreadEn = psyOutChan->sfbSpreadedEnergy + sfbGrp; - for (sfb=0; sfbmaxSfbPerGroup; sfb++) { - *psfbSpreadEn = *psfbSpreadEn >> 1; /* 0.5 */ - ++psfbSpreadEn; - } - } - } - else { - for(sfbGrp = 0;sfbGrp < psyOutChan->sfbCnt;sfbGrp+= psyOutChan->sfbPerGroup){ - psfbSpreadEn = psyOutChan->sfbSpreadedEnergy + sfbGrp; - for (sfb=0; sfbmaxSfbPerGroup; sfb++) { - *psfbSpreadEn = (*psfbSpreadEn >> 1) + (*psfbSpreadEn >> 3); /* 0.63 */ - ++psfbSpreadEn; - } - } - } - } - - /* increase minSnr for local peaks, decrease it for valleys */ - if (ahParam->modifyMinSnr) { - for(ch=0; chwindowSequence != SHORT_WINDOW) - threshold = HOLE_THR_LONG; - else - threshold = HOLE_THR_SHORT; - - for(sfbGrp = 0;sfbGrp < psyOutChan->sfbCnt;sfbGrp+= psyOutChan->sfbPerGroup){ - Word16 *psfbMinSnr = psyOutChan->sfbMinSnr + sfbGrp; - for (sfb=0; sfbmaxSfbPerGroup; sfb++) { - Word32 sfbEn, sfbEnm1, sfbEnp1, avgEn; - - if (sfb > 0) - sfbEnm1 = psyOutChan->sfbEnergy[sfbGrp+sfb-1]; - else - sfbEnm1 = psyOutChan->sfbEnergy[sfbGrp]; - - if (sfb < (psyOutChan->maxSfbPerGroup-1)) - sfbEnp1 = psyOutChan->sfbEnergy[sfbGrp+sfb+1]; - else - sfbEnp1 = psyOutChan->sfbEnergy[sfbGrp+sfb]; - avgEn = (sfbEnm1 + sfbEnp1) >> 1; - sfbEn = psyOutChan->sfbEnergy[sfbGrp+sfb]; - - if (sfbEn > avgEn && avgEn > 0) { - Word32 tmpMinSnr; - shift = norm_l(sfbEn); - tmpMinSnr = Div_32(L_mpy_ls(avgEn, minSnrLimit) << shift, sfbEn << shift ); - tmpMinSnr = max(tmpMinSnr, HOLE_THR_LONG); - tmpMinSnr = max(tmpMinSnr, threshold); - *psfbMinSnr = min(*psfbMinSnr, tmpMinSnr); - } - /* valley ? */ - - if ((sfbEn < (avgEn >> 1)) && (sfbEn > 0)) { - Word32 tmpMinSnr; - Word32 minSnrEn = L_mpy_wx(avgEn, *psfbMinSnr); - - if(minSnrEn < sfbEn) { - shift = norm_l(sfbEn); - tmpMinSnr = Div_32( minSnrEn << shift, sfbEn<> 2), mult(*psfbMinSnr, MIN_SNR_COEF)) << 2); - } - psfbMinSnr++; - } - } - } - } - - /* stereo: adapt the minimum requirements sfbMinSnr of mid and - side channels */ - - if (nChannels == 2) { - PSY_OUT_CHANNEL *psyOutChanM = &psyOutChannel[0]; - PSY_OUT_CHANNEL *psyOutChanS = &psyOutChannel[1]; - for (sfb=0; sfbsfbCnt; sfb++) { - if (psyOutElement->toolsInfo.msMask[sfb]) { - Word32 sfbEnM = psyOutChanM->sfbEnergy[sfb]; - Word32 sfbEnS = psyOutChanS->sfbEnergy[sfb]; - Word32 maxSfbEn = max(sfbEnM, sfbEnS); - Word32 maxThr = L_mpy_wx(maxSfbEn, psyOutChanM->sfbMinSnr[sfb]) >> 1; - - if(maxThr >= sfbEnM) { - psyOutChanM->sfbMinSnr[sfb] = MAX_16; - } - else { - shift = norm_l(sfbEnM); - psyOutChanM->sfbMinSnr[sfb] = min(max(psyOutChanM->sfbMinSnr[sfb], - round16(Div_32(maxThr<= sfbEnS) { - psyOutChanS->sfbMinSnr[sfb] = MAX_16; - } - else { - shift = norm_l(sfbEnS); - psyOutChanS->sfbMinSnr[sfb] = min(max(psyOutChanS->sfbMinSnr[sfb], - round16(Div_32(maxThr << shift, sfbEnS << shift))), minSnrLimit); - } - - - if (sfbEnM > psyOutChanM->sfbSpreadedEnergy[sfb]) - psyOutChanS->sfbSpreadedEnergy[sfb] = L_mpy_ls(sfbEnS, MS_THRSPREAD_COEF); - - if (sfbEnS > psyOutChanS->sfbSpreadedEnergy[sfb]) - psyOutChanM->sfbSpreadedEnergy[sfb] = L_mpy_ls(sfbEnM, MS_THRSPREAD_COEF); - } - } - } - - - /* init ahFlag (0: no ah necessary, 1: ah possible, 2: ah active */ - for(ch=0; chsfbCnt;sfbGrp+= psyOutChan->sfbPerGroup){ - Word16 *pahFlag = ahFlag[ch] + sfbGrp; - for (sfb=0; sfbmaxSfbPerGroup; sfb++) { - - if ((psyOutChan->sfbSpreadedEnergy[sfbGrp+sfb] > psyOutChan->sfbEnergy[sfbGrp+sfb]) || - (psyOutChan->sfbEnergy[sfbGrp+sfb] <= psyOutChan->sfbThreshold[sfbGrp+sfb]) || - (psyOutChan->sfbMinSnr[sfbGrp+sfb] == MAX_16)) { - *pahFlag++ = NO_AH; - } - else { - *pahFlag++ = AH_INACTIVE; - } - } - for (sfb=psyOutChan->maxSfbPerGroup; sfbsfbPerGroup; sfb++) { - *pahFlag++ = NO_AH; - } - } - } -} - -/******************************************************************************** -* -* function name:calcPeNoAH -* description: sum the pe data only for bands where avoid hole is inactive -* -**********************************************************************************/ -static void calcPeNoAH(Word16 *pe, - Word16 *constPart, - Word16 *nActiveLines, - PE_DATA *peData, - Word16 ahFlag[MAX_CHANNELS][MAX_GROUPED_SFB], - PSY_OUT_CHANNEL psyOutChannel[MAX_CHANNELS], - const Word16 nChannels) -{ - Word16 ch, sfb, sfbGrp; - int ipe, iconstPart, inActiveLines; - - ipe = 0; - iconstPart = 0; - inActiveLines = 0; - for(ch=0; chpeChannelData[ch]; - for(sfbGrp = 0;sfbGrp < psyOutChan->sfbCnt;sfbGrp+= psyOutChan->sfbPerGroup){ - for (sfb=0; sfbmaxSfbPerGroup; sfb++) { - - if (ahFlag[ch][sfbGrp+sfb] < AH_ACTIVE) { - ipe = ipe + peChanData->sfbPe[sfbGrp+sfb]; - iconstPart = iconstPart + peChanData->sfbConstPart[sfbGrp+sfb]; - inActiveLines = inActiveLines + peChanData->sfbNActiveLines[sfbGrp+sfb]; - } - } - } - } - - *pe = saturate(ipe); - *constPart = saturate(iconstPart); - *nActiveLines = saturate(inActiveLines); -} - -/******************************************************************************** -* -* function name:reduceThresholds -* description: apply reduction formula -* -**********************************************************************************/ -static void reduceThresholds(PSY_OUT_CHANNEL psyOutChannel[MAX_CHANNELS], - Word16 ahFlag[MAX_CHANNELS][MAX_GROUPED_SFB], - Word32 thrExp[MAX_CHANNELS][MAX_GROUPED_SFB], - const Word16 nChannels, - const Word32 redVal) -{ - Word32 sfbThrReduced; - Word32 *psfbEn, *psfbThr; - Word16 ch, sfb, sfbGrp; - - for(ch=0; chsfbCnt; sfbGrp+=psyOutChan->sfbPerGroup) { - psfbEn = psyOutChan->sfbEnergy + sfbGrp; - psfbThr = psyOutChan->sfbThreshold + sfbGrp; - for (sfb=0; sfbmaxSfbPerGroup; sfb++) { - - if (*psfbEn > *psfbThr) { - /* threshold reduction formula */ - Word32 tmp = thrExp[ch][sfbGrp+sfb] + redVal; - tmp = fixmul(tmp, tmp); - sfbThrReduced = fixmul(tmp, tmp); - /* avoid holes */ - tmp = L_mpy_ls(*psfbEn, psyOutChan->sfbMinSnr[sfbGrp+sfb]); - - if ((sfbThrReduced > tmp) && - (ahFlag[ch][sfbGrp+sfb] != NO_AH)){ - sfbThrReduced = max(tmp, *psfbThr); - ahFlag[ch][sfbGrp+sfb] = AH_ACTIVE; - } - *psfbThr = sfbThrReduced; - } - - psfbEn++; psfbThr++; - } - } - } -} - - -/******************************************************************************** -* -* function name:correctThresh -* description: if pe difference deltaPe between desired pe and real pe is small enough, -* the difference can be distributed among the scale factor bands. -* -**********************************************************************************/ -static void correctThresh(PSY_OUT_CHANNEL psyOutChannel[MAX_CHANNELS], - Word16 ahFlag[MAX_CHANNELS][MAX_GROUPED_SFB], - PE_DATA *peData, - Word32 thrExp[MAX_CHANNELS][MAX_GROUPED_SFB], - const Word32 redVal, - const Word16 nChannels, - const Word32 deltaPe) -{ - Word16 ch, sfb, sfbGrp,shift; - PSY_OUT_CHANNEL *psyOutChan; - PE_CHANNEL_DATA *peChanData; - Word32 deltaSfbPe; - Word32 normFactor; - Word32 *psfbPeFactors; - Word16 *psfbNActiveLines, *pahFlag; - Word32 sfbEn, sfbThr; - Word32 sfbThrReduced; - - /* for each sfb calc relative factors for pe changes */ - normFactor = 1; - for(ch=0; chpeChannelData[ch]; - for(sfbGrp = 0;sfbGrp < psyOutChan->sfbCnt;sfbGrp+= psyOutChan->sfbPerGroup){ - psfbPeFactors = peData->sfbPeFactors[ch] + sfbGrp; - psfbNActiveLines = peChanData->sfbNActiveLines + sfbGrp; - pahFlag = ahFlag[ch] + sfbGrp; - for (sfb=0; sfbmaxSfbPerGroup; sfb++) { - Word32 redThrExp = thrExp[ch][sfbGrp+sfb] + redVal; - - if (((*pahFlag < AH_ACTIVE) || (deltaPe > 0)) && (redThrExp > 0) && (redThrExp >= *psfbNActiveLines)) { - - *psfbPeFactors = (*psfbNActiveLines) * (0x7fffffff / redThrExp); - normFactor = L_add(normFactor, *psfbPeFactors); - } - else { - *psfbPeFactors = 0; - } - psfbPeFactors++; - pahFlag++; psfbNActiveLines++; - } - } - } - - - /* calculate new thresholds */ - for(ch=0; chpeChannelData[ch]; - for(sfbGrp = 0;sfbGrp < psyOutChan->sfbCnt;sfbGrp+= psyOutChan->sfbPerGroup){ - psfbPeFactors = peData->sfbPeFactors[ch] + sfbGrp; - psfbNActiveLines = peChanData->sfbNActiveLines + sfbGrp; - pahFlag = ahFlag[ch] + sfbGrp; - for (sfb=0; sfbmaxSfbPerGroup; sfb++) { - /* pe difference for this sfb */ - deltaSfbPe = *psfbPeFactors * deltaPe; - - /* thr3(n) = thr2(n)*2^deltaSfbPe/b(n) */ - if (*psfbNActiveLines > 0 && (normFactor* (*psfbNActiveLines)) != 0) { - /* new threshold */ - Word32 thrFactor; - sfbEn = psyOutChan->sfbEnergy[sfbGrp+sfb]; - sfbThr = psyOutChan->sfbThreshold[sfbGrp+sfb]; - - if(deltaSfbPe >= 0){ - /* - reduce threshold - */ - thrFactor = pow2_xy(L_negate(deltaSfbPe), (normFactor* (*psfbNActiveLines))); - - sfbThrReduced = L_mpy_ls(sfbThr, round16(thrFactor)); - } - else { - /* - increase threshold - */ - thrFactor = pow2_xy(deltaSfbPe, (normFactor * (*psfbNActiveLines))); - - - if(thrFactor > sfbThr) { - shift = norm_l(thrFactor); - sfbThrReduced = Div_32( sfbThr << shift, thrFactor<sfbMinSnr[sfbGrp+sfb]); - - if ((sfbThrReduced > sfbEn) && - (*pahFlag == AH_INACTIVE)) { - sfbThrReduced = max(sfbEn, sfbThr); - *pahFlag = AH_ACTIVE; - } - - psyOutChan->sfbThreshold[sfbGrp+sfb] = sfbThrReduced; - } - - pahFlag++; psfbNActiveLines++; psfbPeFactors++; - } - } - } -} - - -/******************************************************************************** -* -* function name:reduceMinSnr -* description: if the desired pe can not be reached, reduce pe by reducing minSnr -* -**********************************************************************************/ -static void reduceMinSnr(PSY_OUT_CHANNEL psyOutChannel[MAX_CHANNELS], - PE_DATA *peData, - Word16 ahFlag[MAX_CHANNELS][MAX_GROUPED_SFB], - const Word16 nChannels, - const Word16 desiredPe) -{ - Word16 ch, sfb, sfbSubWin; - Word16 deltaPe; - - /* start at highest freq down to 0 */ - sfbSubWin = psyOutChannel[0].maxSfbPerGroup; - while (peData->pe > desiredPe && sfbSubWin > 0) { - - sfbSubWin = sfbSubWin - 1; - /* loop over all subwindows */ - for (sfb=sfbSubWin; sfbpeChannelData; - PSY_OUT_CHANNEL* psyOutCh = psyOutChannel; - for (ch=0; chsfbMinSnr[sfb] < minSnrLimit) { - psyOutCh->sfbMinSnr[sfb] = minSnrLimit; - psyOutCh->sfbThreshold[sfb] = - L_mpy_ls(psyOutCh->sfbEnergy[sfb], psyOutCh->sfbMinSnr[sfb]); - - /* calc new pe */ - deltaPe = ((peChan->sfbNLines4[sfb] + (peChan->sfbNLines4[sfb] >> 1)) >> 2) - - peChan->sfbPe[sfb]; - peData->pe = peData->pe + deltaPe; - peChan->pe = peChan->pe + deltaPe; - } - peChan += 1; psyOutCh += 1; - } - /* stop if enough has been saved */ - - if (peData->pe <= desiredPe) - break; - } - } -} - -/******************************************************************************** -* -* function name:allowMoreHoles -* description: if the desired pe can not be reached, some more scalefactor bands -* have to be quantized to zero -* -**********************************************************************************/ -static void allowMoreHoles(PSY_OUT_CHANNEL psyOutChannel[MAX_CHANNELS], - PSY_OUT_ELEMENT *psyOutElement, - PE_DATA *peData, - Word16 ahFlag[MAX_CHANNELS][MAX_GROUPED_SFB], - const AH_PARAM *ahParam, - const Word16 nChannels, - const Word16 desiredPe) -{ - Word16 ch, sfb; - Word16 actPe, shift; - - actPe = peData->pe; - - /* for MS allow hole in the channel with less energy */ - - if (nChannels==2 && - psyOutChannel[0].windowSequence==psyOutChannel[1].windowSequence) { - PSY_OUT_CHANNEL *psyOutChanL = &psyOutChannel[0]; - PSY_OUT_CHANNEL *psyOutChanR = &psyOutChannel[1]; - for (sfb=0; sfbsfbCnt; sfb++) { - Word32 minEn; - - if (psyOutElement->toolsInfo.msMask[sfb]) { - /* allow hole in side channel ? */ - minEn = L_mpy_ls(psyOutChanL->sfbEnergy[sfb], (minSnrLimit * psyOutChanL->sfbMinSnr[sfb]) >> 16); - - if (ahFlag[1][sfb] != NO_AH && - minEn > psyOutChanR->sfbEnergy[sfb]) { - ahFlag[1][sfb] = NO_AH; - psyOutChanR->sfbThreshold[sfb] = L_add(psyOutChanR->sfbEnergy[sfb], psyOutChanR->sfbEnergy[sfb]); - actPe = actPe - peData->peChannelData[1].sfbPe[sfb]; - } - /* allow hole in mid channel ? */ - else { - minEn = L_mpy_ls(psyOutChanR->sfbEnergy[sfb], (minSnrLimit * psyOutChanR->sfbMinSnr[sfb]) >> 16); - - if (ahFlag[0][sfb]!= NO_AH && - minEn > psyOutChanL->sfbEnergy[sfb]) { - ahFlag[0][sfb] = NO_AH; - psyOutChanL->sfbThreshold[sfb] = L_add(psyOutChanL->sfbEnergy[sfb], psyOutChanL->sfbEnergy[sfb]); - actPe = actPe - peData->peChannelData[0].sfbPe[sfb]; - } - } - - if (actPe < desiredPe) - break; - } - } - } - - /* subsequently erase bands */ - if (actPe > desiredPe) { - Word16 startSfb[2]; - Word32 avgEn, minEn; - Word16 ahCnt; - Word16 enIdx; - Word16 enDiff; - Word32 en[4]; - Word16 minSfb, maxSfb; - Flag done; - - /* do not go below startSfb */ - for (ch=0; chstartSfbL; - else - startSfb[ch] = ahParam->startSfbS; - } - - avgEn = 0; - minEn = MAX_32; - ahCnt = 0; - for (ch=0; chsfbCnt; sfb++) { - - if ((ahFlag[ch][sfb] != NO_AH) && - (psyOutChan->sfbEnergy[sfb] > psyOutChan->sfbThreshold[sfb])) { - minEn = min(minEn, psyOutChan->sfbEnergy[sfb]); - avgEn = L_add(avgEn, psyOutChan->sfbEnergy[sfb]); - ahCnt++; - } - } - } - - if(ahCnt) { - Word32 iahCnt; - shift = norm_l(ahCnt); - iahCnt = Div_32( 1 << shift, ahCnt << shift ); - avgEn = fixmul(avgEn, iahCnt); - } - - enDiff = iLog4(avgEn) - iLog4(minEn); - /* calc some energy borders between minEn and avgEn */ - for (enIdx=0; enIdx<4; enIdx++) { - Word32 enFac; - enFac = ((6-(enIdx << 1)) * enDiff); - en[enIdx] = fixmul(avgEn, pow2_xy(L_negate(enFac),7*4)); - } - - /* start with lowest energy border at highest sfb */ - maxSfb = psyOutChannel[0].sfbCnt - 1; - minSfb = startSfb[0]; - - if (nChannels == 2) { - maxSfb = max(maxSfb, (psyOutChannel[1].sfbCnt - 1)); - minSfb = min(minSfb, startSfb[1]); - } - - sfb = maxSfb; - enIdx = 0; - done = 0; - while (!done) { - - for (ch=0; ch=startSfb[ch] && sfbsfbCnt) { - /* sfb energy below border ? */ - - if (ahFlag[ch][sfb] != NO_AH && psyOutChan->sfbEnergy[sfb] < en[enIdx]){ - /* allow hole */ - ahFlag[ch][sfb] = NO_AH; - psyOutChan->sfbThreshold[sfb] = L_add(psyOutChan->sfbEnergy[sfb], psyOutChan->sfbEnergy[sfb]); - actPe = actPe - peData->peChannelData[ch].sfbPe[sfb]; - } - - if (actPe < desiredPe) { - done = 1; - break; - } - } - } - sfb = sfb - 1; - - if (sfb < minSfb) { - /* restart with next energy border */ - sfb = maxSfb; - enIdx = enIdx + 1; - - if (enIdx - 4 >= 0) - done = 1; - } - } - } -} - -/******************************************************************************** -* -* function name:adaptThresholdsToPe -* description: two guesses for the reduction value and one final correction of the -* thresholds -* -**********************************************************************************/ -static void adaptThresholdsToPe(PSY_OUT_CHANNEL psyOutChannel[MAX_CHANNELS], - PSY_OUT_ELEMENT *psyOutElement, - Word16 logSfbEnergy[MAX_CHANNELS][MAX_GROUPED_SFB], - PE_DATA *peData, - const Word16 nChannels, - const Word16 desiredPe, - AH_PARAM *ahParam, - MINSNR_ADAPT_PARAM *msaParam) -{ - Word16 noRedPe, redPe, redPeNoAH; - Word16 constPart, constPartNoAH; - Word16 nActiveLines, nActiveLinesNoAH; - Word16 desiredPeNoAH; - Word32 redVal, avgThrExp; - Word32 iter; - - calcThreshExp(peData->thrExp, psyOutChannel, nChannels); - - adaptMinSnr(psyOutChannel, logSfbEnergy, msaParam, nChannels); - - initAvoidHoleFlag(peData->ahFlag, psyOutChannel, psyOutElement, nChannels, ahParam); - - noRedPe = peData->pe; - constPart = peData->constPart; - nActiveLines = peData->nActiveLines; - - /* first guess of reduction value t^0.25 = 2^((a-pen)/4*b) */ - avgThrExp = pow2_xy((constPart - noRedPe), (nActiveLines << 2)); - - /* r1 = 2^((a-per)/4*b) - t^0.25 */ - redVal = pow2_xy((constPart - desiredPe), (nActiveLines << 2)) - avgThrExp; - - /* reduce thresholds */ - reduceThresholds(psyOutChannel, peData->ahFlag, peData->thrExp, nChannels, redVal); - - /* pe after first guess */ - calcSfbPe(peData, psyOutChannel, nChannels); - redPe = peData->pe; - - iter = 0; - do { - /* pe for bands where avoid hole is inactive */ - calcPeNoAH(&redPeNoAH, &constPartNoAH, &nActiveLinesNoAH, - peData, peData->ahFlag, psyOutChannel, nChannels); - - desiredPeNoAH = desiredPe -(redPe - redPeNoAH); - - if (desiredPeNoAH < 0) { - desiredPeNoAH = 0; - } - - /* second guess */ - - if (nActiveLinesNoAH > 0) { - - avgThrExp = pow2_xy((constPartNoAH - redPeNoAH), (nActiveLinesNoAH << 2)); - - redVal = (redVal + pow2_xy((constPartNoAH - desiredPeNoAH), (nActiveLinesNoAH << 2))) - avgThrExp; - - /* reduce thresholds */ - reduceThresholds(psyOutChannel, peData->ahFlag, peData->thrExp, nChannels, redVal); - } - - calcSfbPe(peData, psyOutChannel, nChannels); - redPe = peData->pe; - - iter = iter+1; - - } while ((20 * abs_s(redPe - desiredPe) > desiredPe) && (iter < 2)); - - - if ((100 * redPe < 115 * desiredPe)) { - correctThresh(psyOutChannel, peData->ahFlag, peData, peData->thrExp, redVal, - nChannels, desiredPe - redPe); - } - else { - Word16 desiredPe105 = (105 * desiredPe) / 100; - reduceMinSnr(psyOutChannel, peData, peData->ahFlag, - nChannels, desiredPe105); - allowMoreHoles(psyOutChannel, psyOutElement, peData, peData->ahFlag, - ahParam, nChannels, desiredPe105); - } -} - - -/***************************************************************************** -* -* function name: calcBitSave -* description: Calculates percentage of bit save, see figure below -* returns: -* input: parameters and bitres-fullness -* output: percentage of bit save -* -*****************************************************************************/ -static Word16 calcBitSave(Word16 fillLevel, - const Word16 clipLow, - const Word16 clipHigh, - const Word16 minBitSave, - const Word16 maxBitSave) -{ - Word16 bitsave = 0; - - fillLevel = max(fillLevel, clipLow); - fillLevel = min(fillLevel, clipHigh); - - if(clipHigh-clipLow) - bitsave = (maxBitSave - (((maxBitSave-minBitSave)*(fillLevel-clipLow))/ - (clipHigh-clipLow))); - - return (bitsave); -} - - - -/***************************************************************************** -* -* function name: calcBitSpend -* description: Calculates percentage of bit spend, see figure below -* returns: -* input: parameters and bitres-fullness -* output: percentage of bit spend -* -*****************************************************************************/ -static Word16 calcBitSpend(Word16 fillLevel, - const Word16 clipLow, - const Word16 clipHigh, - const Word16 minBitSpend, - const Word16 maxBitSpend) -{ - Word16 bitspend = 1; - - fillLevel = max(fillLevel, clipLow); - fillLevel = min(fillLevel, clipHigh); - - if(clipHigh-clipLow) - bitspend = (minBitSpend + ((maxBitSpend - minBitSpend)*(fillLevel - clipLow) / - (clipHigh-clipLow))); - - return (bitspend); -} - - -/***************************************************************************** -* -* function name: adjustPeMinMax() -* description: adjusts peMin and peMax parameters over time -* returns: -* input: current pe, peMin, peMax -* output: adjusted peMin/peMax -* -*****************************************************************************/ -static void adjustPeMinMax(const Word16 currPe, - Word16 *peMin, - Word16 *peMax) -{ - Word16 minFacHi, maxFacHi, minFacLo, maxFacLo; - Word16 diff; - Word16 minDiff = extract_l(currPe / 6); - minFacHi = 30; - maxFacHi = 100; - minFacLo = 14; - maxFacLo = 7; - - diff = currPe - *peMax ; - - if (diff > 0) { - *peMin = *peMin + ((diff * minFacHi) / 100); - *peMax = *peMax + ((diff * maxFacHi) / 100); - } else { - diff = *peMin - currPe; - - if (diff > 0) { - *peMin = *peMin - ((diff * minFacLo) / 100); - *peMax = *peMax - ((diff * maxFacLo) / 100); - } else { - *peMin = *peMin + ((currPe - *peMin) * minFacHi / 100); - *peMax = *peMax - ((*peMax - currPe) * maxFacLo / 100); - } - } - - - if ((*peMax - *peMin) < minDiff) { - Word16 partLo, partHi; - - partLo = max(0, (currPe - *peMin)); - partHi = max(0, (*peMax - currPe)); - - *peMax = currPe + ((partHi * minDiff) / (partLo + partHi)); - *peMin = currPe - ((partLo * minDiff) / (partLo + partHi)); - *peMin = max(0, *peMin); - } -} - - -/***************************************************************************** -* -* function name: BitresCalcBitFac -* description: calculates factor of spending bits for one frame -* 1.0 : take all frame dynpart bits -* >1.0 : take all frame dynpart bits + bitres -* <1.0 : put bits in bitreservoir -* returns: BitFac*100 -* input: bitres-fullness, pe, blockType, parameter-settings -* output: -* -*****************************************************************************/ -static Word16 bitresCalcBitFac( const Word16 bitresBits, - const Word16 maxBitresBits, - const Word16 pe, - const Word16 windowSequence, - const Word16 avgBits, - const Word16 maxBitFac, - ADJ_THR_STATE *AdjThr, - ATS_ELEMENT *adjThrChan) -{ - BRES_PARAM *bresParam; - Word16 pex; - Word16 fillLevel; - Word16 bitSave, bitSpend, bitresFac; - - fillLevel = extract_l((100* bitresBits) / maxBitresBits); - - if (windowSequence != SHORT_WINDOW) - bresParam = &(AdjThr->bresParamLong); - else - bresParam = &(AdjThr->bresParamShort); - - pex = max(pe, adjThrChan->peMin); - pex = min(pex,adjThrChan->peMax); - - bitSave = calcBitSave(fillLevel, - bresParam->clipSaveLow, bresParam->clipSaveHigh, - bresParam->minBitSave, bresParam->maxBitSave); - - bitSpend = calcBitSpend(fillLevel, - bresParam->clipSpendLow, bresParam->clipSpendHigh, - bresParam->minBitSpend, bresParam->maxBitSpend); - - if(adjThrChan->peMax != adjThrChan->peMin) - bitresFac = (100 - bitSave) + extract_l(((bitSpend + bitSave) * (pex - adjThrChan->peMin)) / - (adjThrChan->peMax - adjThrChan->peMin)); - else - bitresFac = 0x7fff; - - bitresFac = min(bitresFac, - (100-30 + extract_l((100 * bitresBits) / avgBits))); - - bitresFac = min(bitresFac, maxBitFac); - - adjustPeMinMax(pe, &adjThrChan->peMin, &adjThrChan->peMax); - - return bitresFac; -} - -/***************************************************************************** -* -* function name: AdjThrInit -* description: init thresholds parameter -* -*****************************************************************************/ -void AdjThrInit(ADJ_THR_STATE *hAdjThr, - const Word32 meanPe, - Word32 chBitrate) -{ - ATS_ELEMENT* atsElem = &hAdjThr->adjThrStateElem; - MINSNR_ADAPT_PARAM *msaParam = &atsElem->minSnrAdaptParam; - - /* common for all elements: */ - /* parameters for bitres control */ - hAdjThr->bresParamLong.clipSaveLow = 20; - hAdjThr->bresParamLong.clipSaveHigh = 95; - hAdjThr->bresParamLong.minBitSave = -5; - hAdjThr->bresParamLong.maxBitSave = 30; - hAdjThr->bresParamLong.clipSpendLow = 20; - hAdjThr->bresParamLong.clipSpendHigh = 95; - hAdjThr->bresParamLong.minBitSpend = -10; - hAdjThr->bresParamLong.maxBitSpend = 40; - - hAdjThr->bresParamShort.clipSaveLow = 20; - hAdjThr->bresParamShort.clipSaveHigh = 75; - hAdjThr->bresParamShort.minBitSave = 0; - hAdjThr->bresParamShort.maxBitSave = 20; - hAdjThr->bresParamShort.clipSpendLow = 20; - hAdjThr->bresParamShort.clipSpendHigh = 75; - hAdjThr->bresParamShort.minBitSpend = -5; - hAdjThr->bresParamShort.maxBitSpend = 50; - - /* specific for each element: */ - - /* parameters for bitres control */ - atsElem->peMin = extract_l(((80*meanPe) / 100)); - atsElem->peMax = extract_l(((120*meanPe) / 100)); - - /* additional pe offset to correct pe2bits for low bitrates */ - atsElem->peOffset = 0; - if (chBitrate < 32000) { - atsElem->peOffset = max(50, (100 - extract_l((100 * chBitrate) / 32000))); - } - - /* avoid hole parameters */ - if (chBitrate > 20000) { - atsElem->ahParam.modifyMinSnr = TRUE; - atsElem->ahParam.startSfbL = 15; - atsElem->ahParam.startSfbS = 3; - } - else { - atsElem->ahParam.modifyMinSnr = FALSE; - atsElem->ahParam.startSfbL = 0; - atsElem->ahParam.startSfbS = 0; - } - - /* minSnr adaptation */ - /* maximum reduction of minSnr goes down to minSnr^maxRed */ - msaParam->maxRed = 0x20000000; /* *0.25f */ - /* start adaptation of minSnr for avgEn/sfbEn > startRatio */ - msaParam->startRatio = 0x0ccccccd; /* 10 */ - /* maximum minSnr reduction to minSnr^maxRed is reached for - avgEn/sfbEn >= maxRatio */ - msaParam->maxRatio = 0x0020c49c; /* 1000 */ - /* helper variables to interpolate minSnr reduction for - avgEn/sfbEn between startRatio and maxRatio */ - - msaParam->redRatioFac = 0xfb333333; /* -0.75/20 */ - - msaParam->redOffs = 0x30000000; /* msaParam->redRatioFac * 10*log10(msaParam->startRatio) */ - - - /* pe correction */ - atsElem->peLast = 0; - atsElem->dynBitsLast = 0; - atsElem->peCorrectionFactor = 100; /* 1.0 */ - -} - -/***************************************************************************** -* -* function name: calcPeCorrection -* description: calculates the desired perceptual entropy factor -* It is between 0.85 and 1.15 -* -*****************************************************************************/ -static void calcPeCorrection(Word16 *correctionFac, - const Word16 peAct, - const Word16 peLast, - const Word16 bitsLast) -{ - Word32 peAct100 = 100 * peAct; - Word32 peLast100 = 100 * peLast; - Word16 peBitsLast = bits2pe(bitsLast); - - if ((bitsLast > 0) && - (peAct100 < (150 * peLast)) && (peAct100 > (70 * peLast)) && - ((120 * peBitsLast) > peLast100 ) && (( 65 * peBitsLast) < peLast100)) - { - Word16 newFac = (100 * peLast) / peBitsLast; - /* dead zone */ - - if (newFac < 100) { - newFac = min(((110 * newFac) / 100), 100); - newFac = max(newFac, 85); - } - else { - newFac = max(((90 * newFac) / 100), 100); - newFac = min(newFac, 115); - } - - if ((newFac > 100 && *correctionFac < 100) || - (newFac < 100 && *correctionFac > 100)) { - *correctionFac = 100; - } - /* faster adaptation towards 1.0, slower in the other direction */ - - if ((*correctionFac < 100 && newFac < *correctionFac) || - (*correctionFac > 100 && newFac > *correctionFac)) - *correctionFac = (85 * *correctionFac + 15 * newFac) / 100; - else - *correctionFac = (70 * *correctionFac + 30 * newFac) / 100; - *correctionFac = min(*correctionFac, 115); - *correctionFac = max(*correctionFac, 85); - } - else { - *correctionFac = 100; - } -} - -/******************************************************************************** -* -* function name: AdjustThresholds -* description: Adjust thresholds to the desired bitrate -* -**********************************************************************************/ -void AdjustThresholds(ADJ_THR_STATE *adjThrState, - ATS_ELEMENT *AdjThrStateElement, - PSY_OUT_CHANNEL psyOutChannel[MAX_CHANNELS], - PSY_OUT_ELEMENT *psyOutElement, - Word16 *chBitDistribution, - Word16 logSfbEnergy[MAX_CHANNELS][MAX_GROUPED_SFB], - Word16 sfbNRelevantLines[MAX_CHANNELS][MAX_GROUPED_SFB], - QC_OUT_ELEMENT *qcOE, - ELEMENT_BITS *elBits, - const Word16 nChannels, - const Word16 maxBitFac) -{ - PE_DATA peData; - Word16 noRedPe, grantedPe, grantedPeCorr; - Word16 curWindowSequence; - Word16 bitFactor; - Word16 avgBits = (elBits->averageBits - (qcOE->staticBitsUsed + qcOE->ancBitsUsed)); - Word16 bitresBits = elBits->bitResLevel; - Word16 maxBitresBits = elBits->maxBits; - Word16 sideInfoBits = (qcOE->staticBitsUsed + qcOE->ancBitsUsed); - Word16 ch; - memset(&peData, 0, sizeof(peData)); - - prepareSfbPe(&peData, psyOutChannel, logSfbEnergy, sfbNRelevantLines, nChannels, AdjThrStateElement->peOffset); - - /* pe without reduction */ - calcSfbPe(&peData, psyOutChannel, nChannels); - noRedPe = peData.pe; - - - curWindowSequence = LONG_WINDOW; - - if (nChannels == 2) { - - if ((psyOutChannel[0].windowSequence == SHORT_WINDOW) || - (psyOutChannel[1].windowSequence == SHORT_WINDOW)) { - curWindowSequence = SHORT_WINDOW; - } - } - else { - curWindowSequence = psyOutChannel[0].windowSequence; - } - - - /* bit factor */ - bitFactor = bitresCalcBitFac(bitresBits, maxBitresBits, noRedPe+5*sideInfoBits, - curWindowSequence, avgBits, maxBitFac, - adjThrState, - AdjThrStateElement); - - /* desired pe */ - grantedPe = ((bitFactor * bits2pe(avgBits)) / 100); - - /* correction of pe value */ - calcPeCorrection(&(AdjThrStateElement->peCorrectionFactor), - min(grantedPe, noRedPe), - AdjThrStateElement->peLast, - AdjThrStateElement->dynBitsLast); - grantedPeCorr = (grantedPe * AdjThrStateElement->peCorrectionFactor) / 100; - - - if (grantedPeCorr < noRedPe && noRedPe > peData.offset) { - /* calc threshold necessary for desired pe */ - adaptThresholdsToPe(psyOutChannel, - psyOutElement, - logSfbEnergy, - &peData, - nChannels, - grantedPeCorr, - &AdjThrStateElement->ahParam, - &AdjThrStateElement->minSnrAdaptParam); - } - - /* calculate relative distribution */ - for (ch=0; ch 0) { - Word32 temp = 1000 - (nChannels * 200); - chBitDistribution[ch] = chBitDistribution[ch] + - (temp * peData.peChannelData[ch].pe) / peOffsDiff; - } - } - - /* store pe */ - qcOE->pe = noRedPe; - - /* update last pe */ - AdjThrStateElement->peLast = grantedPe; -} - -/******************************************************************************** -* -* function name: AdjThrUpdate -* description: save dynBitsUsed for correction of bits2pe relation -* -**********************************************************************************/ -void AdjThrUpdate(ATS_ELEMENT *AdjThrStateElement, - const Word16 dynBitsUsed) -{ - AdjThrStateElement->dynBitsLast = dynBitsUsed; -} - - diff --git a/android-aac-enc/jni/src/asm/ARMV5E/AutoCorrelation_v5.s b/android-aac-enc/jni/src/asm/ARMV5E/AutoCorrelation_v5.s deleted file mode 100644 index e7051975f..000000000 --- a/android-aac-enc/jni/src/asm/ARMV5E/AutoCorrelation_v5.s +++ /dev/null @@ -1,167 +0,0 @@ -@/* -@ ** Copyright 2003-2010, VisualOn, Inc. -@ ** -@ ** Licensed under the Apache License, Version 2.0 (the "License"); -@ ** you may not use this file except in compliance with the License. -@ ** You may obtain a copy of the License at -@ ** -@ ** http://www.apache.org/licenses/LICENSE-2.0 -@ ** -@ ** Unless required by applicable law or agreed to in writing, software -@ ** distributed under the License is distributed on an "AS IS" BASIS, -@ ** WITHOUT 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: AutoCorrelation_v5.s -@ -@ Content: AutoCorrelation function armv5 assemble -@ -@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ - - - .section .text - .global AutoCorrelation - -AutoCorrelation: - stmdb sp!, {r4 - r11, lr} - - sub r13, r13, #20 - - mov r5, r0 - mov r7, r1 - mov r9, r3 - mov r2, r2, lsl #16 - mov r0, #0 - mov r4, r2, asr #16 - mov r8, #0 - cmp r4, #0 - ble L136 - - cmp r4, #8 - mov r2, #0 - blt L133 - - sub r12, r4, #8 -L132: - ldr r6, [r5, r2] - add r2, r2, #4 - smulbb r3, r6, r6 - ldr r1, [r5, r2] - smultt r10, r6, r6 - mov r3, r3, asr #9 - smulbb r6, r1, r1 - mov r10, r10, asr #9 - qadd r0, r0, r3 - smultt r11, r1, r1 - add r2, r2, #4 - qadd r0, r0, r10 - mov r6, r6, asr #9 - mov r11, r11, asr #9 - ldr r1, [r5, r2] - qadd r0, r0, r6 - smulbb r10, r1, r1 - smultt r6, r1, r1 - qadd r0, r0, r11 - mov r10, r10, asr #9 - mov r6, r6, asr #9 - qadd r0, r0, r10 - add r2, r2, #4 - add r8, r8, #6 - - qadd r0, r0, r6 - cmp r8, r12 - blt L132 -L133: - ldrsh r6, [r5, r2] - mul r10, r6, r6 - add r2, r2, #2 - mov r1, r10, asr #9 - qadd r0, r0, r1 -L134: - add r8, r8, #1 - cmp r8, r4 - blt L133 -L135: -L136: - str r0, [r7, #0] - cmp r0, #0 - beq L1320 -L137: - mov r2, r9, lsl #16 - mov r8, #1 - mov r2, r2, asr #16 - cmp r2, #1 - ble L1319 -L138: -L139: - sub r4, r4, #1 - mov r14, #0 - mov r3, #0 - cmp r4, #0 - ble L1317 -L1310: - cmp r4, #6 - addlt r6, r5, r8, lsl #1 - blt L1314 -L1311: - add r6, r5, r8, lsl #1 - sub r12, r4, #6 - str r8, [r13, #8] - str r7, [r13, #4] -L1312: - mov r1, r3, lsl #1 - ldrsh r7, [r6, r1] - ldrsh r10, [r5, r1] - add r8, r1, r6 - add r9, r5, r1 - mul r7, r10, r7 - ldrsh r1, [r8, #2] - ldrsh r10, [r8, #4] - add r7, r14, r7, asr #9 - ldrsh r0, [r9, #2] - ldrsh r11, [r9, #4] - mul r1, r0, r1 - ldrsh r14, [r8, #6] - mul r10, r11, r10 - add r7, r7, r1, asr #9 - ldrsh r8, [r8, #8] - add r3, r3, #5 - ldrsh r11, [r9, #6] - ldrsh r1, [r9, #8] - mul r14, r11, r14 - add r7, r7, r10, asr #9 - mul r1, r1, r8 - add r14, r7, r14, asr #9 - cmp r3, r12 - add r14, r14, r1, asr #9 - ble L1312 -L1313: - ldr r8, [r13, #8] - ldr r7, [r13, #4] -L1314: -L1315: - mov r12, r3, lsl #1 - ldrsh r9, [r6, r12] - ldrsh r12, [r5, r12] - add r3, r3, #1 - cmp r3, r4 - mul r12, r12, r9 - add r14, r14, r12, asr #9 - blt L1315 -L1316: -L1317: - str r14, [r7, +r8, lsl #2] - add r8, r8, #1 - cmp r8, r2 - blt L139 - -L1319: -L1320: - add r13, r13, #20 - ldmia sp!, {r4 - r11, pc} - - @ENDP @ |AutoCorrelation| - .end diff --git a/android-aac-enc/jni/src/asm/ARMV5E/CalcWindowEnergy_v5.s b/android-aac-enc/jni/src/asm/ARMV5E/CalcWindowEnergy_v5.s deleted file mode 100644 index b30e8cb81..000000000 --- a/android-aac-enc/jni/src/asm/ARMV5E/CalcWindowEnergy_v5.s +++ /dev/null @@ -1,112 +0,0 @@ -@/* -@ ** Copyright 2003-2010, VisualOn, Inc. -@ ** -@ ** Licensed under the Apache License, Version 2.0 (the "License"); -@ ** you may not use this file except in compliance with the License. -@ ** You may obtain a copy of the License at -@ ** -@ ** http://www.apache.org/licenses/LICENSE-2.0 -@ ** -@ ** Unless required by applicable law or agreed to in writing, software -@ ** distributed under the License is distributed on an "AS IS" BASIS, -@ ** WITHOUT 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: CalcWindowEnergy_v5.s -@ -@ Content: CalcWindowEnergy function armv5 assemble -@ -@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ - - .section .text - - .global CalcWindowEnergy - -CalcWindowEnergy: - stmdb sp!, {r4 - r11, lr} - sub r13, r13, #20 - - mov r3, r3, lsl #16 - ldr r10, [r0, #168] @ states0 = blockSwitchingControl->iirStates[0]; - mov r3, r3, asr #16 - ldr r11, [r0, #172] @ states1 = blockSwitchingControl->iirStates[1]; - - mov r2, r2, lsl #16 - ldr r12, hiPassCoeff @ Coeff0 = hiPassCoeff[0]; - mov r2, r2, asr #16 - ldr r14, hiPassCoeff + 4 @ Coeff1 = hiPassCoeff[1]; - - mov r8, #0 @ w=0 - mov r5, #0 @ wOffset = 0; - -BLOCK_BEGIN: - mov r6, #0 @ accuUE = 0; - mov r7, #0 @ accuFE = 0; - mov r4, #0 @ i=0 - - str r8, [r13, #4] - str r0, [r13, #8] - str r3, [r13, #12] - -ENERGY_BEG: - mov r9, r5, lsl #1 - ldrsh r9, [r1, r9] @ tempUnfiltered = timeSignal[tidx]; - - add r5, r5, r2 @ tidx = tidx + chIncrement; - - smulwb r3, r14, r9 @ accu1 = L_mpy_ls(Coeff1, tempUnfiltered); - smull r0, r8, r12, r11 @ accu2 = fixmul( Coeff0, states1 ); - - mov r3, r3, lsl #1 - mov r8, r8, lsl #1 - - sub r0, r3, r10 @ accu3 = accu1 - states0; - sub r8, r0, r8 @ out = accu3 - accu2; - - mov r10, r3 @ states0 = accu1; - mov r11, r8 @ states1 = out; - - mul r3, r9, r9 - mov r8, r8, asr #16 - - add r4, r4, #1 - add r6, r6, r3, asr #7 - - mul r9, r8, r8 - ldr r3, [r13, #12] - - add r7, r7, r9, asr #7 - - cmp r4, r3 - blt ENERGY_BEG - - ldr r0, [r13, #8] - ldr r8, [r13, #4] - -ENERGY_END: - add r4, r0, r8, lsl #2 - - str r6, [r4, #72] - add r8, r8, #1 - str r7, [r4, #136] - - cmp r8, #8 - blt BLOCK_BEGIN - -BLOCK_END: - str r10, [r0, #168] - str r11, [r0, #172] - mov r0, #1 - - add r13, r13, #20 - ldmia sp!, {r4 - r11, pc} - -hiPassCoeff: - .word 0xbec8b439 - .word 0x609d4952 - - @ENDP - .end diff --git a/android-aac-enc/jni/src/asm/ARMV5E/PrePostMDCT_v5.s b/android-aac-enc/jni/src/asm/ARMV5E/PrePostMDCT_v5.s deleted file mode 100644 index da21d5faf..000000000 --- a/android-aac-enc/jni/src/asm/ARMV5E/PrePostMDCT_v5.s +++ /dev/null @@ -1,131 +0,0 @@ -@/* -@ ** Copyright 2003-2010, VisualOn, Inc. -@ ** -@ ** Licensed under the Apache License, Version 2.0 (the "License"); -@ ** you may not use this file except in compliance with the License. -@ ** You may obtain a copy of the License at -@ ** -@ ** http://www.apache.org/licenses/LICENSE-2.0 -@ ** -@ ** Unless required by applicable law or agreed to in writing, software -@ ** distributed under the License is distributed on an "AS IS" BASIS, -@ ** WITHOUT 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: PrePostMDCT_v5.s -@ -@ Content: premdct and postmdct function armv5 assemble -@ -@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ - - .section .text - .global PreMDCT - -PreMDCT: - stmdb sp!, {r4 - r11, lr} - - add r9, r0, r1, lsl #2 - sub r3, r9, #8 - - movs r1, r1, asr #2 - beq PreMDCT_END - -PreMDCT_LOOP: - ldr r8, [r2], #4 - ldr r9, [r2], #4 - - ldrd r4, [r0] - ldrd r6, [r3] - - smull r14, r11, r4, r8 @ MULHIGH(tr1, cosa) - smull r10, r12, r7, r8 @ MULHIGH(ti1, cosa) - - smull r14, r8, r7, r9 @ MULHIGH(ti1, sina) - smull r7, r10, r4, r9 @ MULHIGH(tr1, sina) - - add r11, r11, r8 @ MULHIGH(cosa, tr1) + MULHIGH(sina, ti1)@ - sub r7, r12, r10 @ MULHIGH(ti1, cosa) - MULHIGH(tr1, sina) - - ldr r8, [r2], #4 - ldr r9, [r2], #4 - - smull r14, r4, r6, r8 @ MULHIGH(tr2, cosa) - smull r10, r12, r5, r8 @ MULHIGH(ti2, cosa) - - smull r14, r8, r5, r9 @ MULHIGH(ti2, sina) - smull r5, r10, r6, r9 @ MULHIGH(tr2, sina) - - add r8, r8, r4 - sub r9, r12, r10 - - mov r6, r11 - - strd r6, [r0] - strd r8, [r3] - - subs r1, r1, #1 - sub r3, r3, #8 - add r0, r0, #8 - bne PreMDCT_LOOP - -PreMDCT_END: - ldmia sp!, {r4 - r11, pc} - @ENDP @ |PreMDCT| - - .section .text - .global PostMDCT - -PostMDCT: - stmdb sp!, {r4 - r11, lr} - - add r9, r0, r1, lsl #2 - sub r3, r9, #8 - - movs r1, r1, asr #2 - beq PostMDCT_END - -PostMDCT_LOOP: - ldr r8, [r2], #4 - ldr r9, [r2], #4 - - ldrd r4, [r0] - ldrd r6, [r3] - - smull r14, r11, r4, r8 @ MULHIGH(tr1, cosa) - smull r10, r12, r5, r8 @ MULHIGH(ti1, cosa) - - smull r14, r8, r5, r9 @ MULHIGH(ti1, sina) - smull r5, r10, r4, r9 @ MULHIGH(tr1, sina) - - add r4, r11, r8 @ MULHIGH(cosa, tr1) + MULHIGH(sina, ti1)@ - sub r11, r10, r12 @ MULHIGH(ti1, cosa) - MULHIGH(tr1, sina)@ - - ldr r8, [r2], #4 @ - ldr r9, [r2], #4 - - smull r14, r5, r6, r8 @ MULHIGH(tr2, cosa) - smull r10, r12, r7, r8 @ MULHIGH(ti2, cosa) - - smull r14, r8, r7, r9 @ MULHIGH(ti2, sina) - smull r7, r10, r6, r9 @ MULHIGH(tr2, sina) - - add r6, r8, r5 @ MULHIGH(cosb, tr2) + MULHIGH(sinb, ti2)@ - sub r5, r10, r12 @ MULHIGH(sinb, tr2) - MULHIGH(cosb, ti2)@ - - mov r7, r11 - - strd r4, [r0] - strd r6, [r3] - - subs r1, r1, #1 - sub r3, r3, #8 - add r0, r0, #8 - bne PostMDCT_LOOP - -PostMDCT_END: - ldmia sp!, {r4 - r11, pc} - @ENDP @ |PostMDCT| - .end diff --git a/android-aac-enc/jni/src/asm/ARMV5E/R4R8First_v5.s b/android-aac-enc/jni/src/asm/ARMV5E/R4R8First_v5.s deleted file mode 100644 index 4ca4f3110..000000000 --- a/android-aac-enc/jni/src/asm/ARMV5E/R4R8First_v5.s +++ /dev/null @@ -1,252 +0,0 @@ -@/* -@ ** Copyright 2003-2010, VisualOn, Inc. -@ ** -@ ** Licensed under the Apache License, Version 2.0 (the "License"); -@ ** you may not use this file except in compliance with the License. -@ ** You may obtain a copy of the License at -@ ** -@ ** http://www.apache.org/licenses/LICENSE-2.0 -@ ** -@ ** Unless required by applicable law or agreed to in writing, software -@ ** distributed under the License is distributed on an "AS IS" BASIS, -@ ** WITHOUT 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: R4R8First_v5.s -@ -@ Content: Radix8First and Radix4First function armv5 assemble -@ -@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ - - .section .text - .global Radix4First - -Radix4First: - stmdb sp!, {r4 - r11, lr} - - movs r10, r1 - mov r11, r0 - beq Radix4First_END - -Radix4First_LOOP: - ldrd r0, [r11] - ldrd r2, [r11, #8] - ldrd r4, [r11, #16] - ldrd r6, [r11, #24] - - add r8, r0, r2 - add r9, r1, r3 - - sub r0, r0, r2 - sub r1, r1, r3 - - add r2, r4, r6 - add r3, r5, r7 - - sub r4, r4, r6 - sub r5, r5, r7 - - add r6, r8, r2 - add r7, r9, r3 - - sub r8, r8, r2 - sub r9, r9, r3 - - add r2, r0, r5 - sub r3, r1, r4 - - sub r0, r0, r5 - add r1, r1, r4 - - strd r6, [r11] - strd r2, [r11, #8] - strd r8, [r11, #16] - strd r0, [r11, #24] - - subs r10, r10, #1 - add r11, r11, #32 - bne Radix4First_LOOP - -Radix4First_END: - ldmia sp!, {r4 - r11, pc} - @ENDP @ |Radix4First| - - .section .text - .global Radix8First - -Radix8First: - stmdb sp!, {r4 - r11, lr} - sub sp, sp, #0x24 - - mov r12, r1 - mov r14, r0 - cmp r12, #0 - beq Radix8First_END - -Radix8First_LOOP: - ldrd r0, [r14] - ldrd r2, [r14, #8] - ldrd r4, [r14, #16] - ldrd r6, [r14, #24] - - add r8, r0, r2 @ r0 = buf[0] + buf[2]@ - add r9, r1, r3 @ i0 = buf[1] + buf[3]@ - - sub r0, r0, r2 @ r1 = buf[0] - buf[2]@ - sub r1, r1, r3 @ i1 = buf[1] - buf[3]@ - - add r2, r4, r6 @ r2 = buf[4] + buf[6]@ - add r3, r5, r7 @ i2 = buf[5] + buf[7]@ - - sub r4, r4, r6 @ r3 = buf[4] - buf[6]@ - sub r5, r5, r7 @ i3 = buf[5] - buf[7]@ - - add r6, r8, r2 @ r4 = (r0 + r2) >> 1@ - add r7, r9, r3 @ i4 = (i0 + i2) >> 1@ - - sub r8, r8, r2 @ r5 = (r0 - r2) >> 1@ - sub r9, r9, r3 @ i5 = (i0 - i2) >> 1@ - - sub r2, r0, r5 @ r6 = (r1 - i3) >> 1@ - add r3, r1, r4 @ i6 = (i1 + r3) >> 1@ - - add r0, r0, r5 @ r7 = (r1 + i3) >> 1@ - sub r1, r1, r4 @ i7 = (i1 - r3) >> 1@ - - mov r6, r6, asr #1 @ - mov r7, r7, asr #1 @ - - mov r8, r8, asr #1 - mov r9, r9, asr #1 - - mov r2, r2, asr #1 - mov r3, r3, asr #1 - - mov r0, r0, asr #1 - mov r1, r1, asr #1 - - str r6, [sp] - str r7, [sp, #4] - - str r8, [sp, #8] - str r9, [sp, #12] - - str r2, [sp, #16] - str r3, [sp, #20] - - str r0, [sp, #24] - str r1, [sp, #28] - - ldrd r2, [r14, #32] - ldrd r4, [r14, #40] - ldrd r6, [r14, #48] - ldrd r8, [r14, #56] - - add r0, r2, r4 @ r0 = buf[ 8] + buf[10]@ - add r1, r3, r5 @ i0 = buf[ 9] + buf[11]@ - - sub r2, r2, r4 @ r1 = buf[ 8] - buf[10]@ - sub r3, r3, r5 @ i1 = buf[ 9] - buf[11]@ - - add r4, r6, r8 @ r2 = buf[12] + buf[14]@ - add r5, r7, r9 @ i2 = buf[13] + buf[15]@ - - sub r6, r6, r8 @ r3 = buf[12] - buf[14]@ - sub r7, r7, r9 @ i3 = buf[13] - buf[15]@ - - add r8, r0, r4 @ t0 = (r0 + r2) - add r9, r1, r5 @ t1 = (i0 + i2) - - sub r0, r0, r4 @ t2 = (r0 - r2) - sub r1, r1, r5 @ t3 = (i0 - i2) - - mov r8, r8, asr #1 - ldr r4, [sp] - - mov r9, r9, asr #1 - ldr r5, [sp, #4] - - mov r0, r0, asr #1 - mov r1, r1, asr #1 - - add r10, r4, r8 @ buf[ 0] = r4 + t0@ - add r11, r5, r9 @ buf[ 1] = i4 + t1@ - - sub r4, r4, r8 @ buf[ 8] = r4 - t0@ - sub r5, r5, r9 @ buf[ 9] = i4 - t1@ - - strd r10, [r14] - strd r4, [r14, #32] - - ldr r10, [sp, #8] - ldr r11, [sp, #12] - - add r4, r10, r1 @ buf[ 4] = r5 + t3@ - sub r5, r11, r0 @ buf[ 5] = i5 - t2@ - - sub r10, r10, r1 @ buf[12] = r5 - t3@ - add r11, r11, r0 @ buf[13] = i5 + t2@ - - strd r4, [r14, #16] - strd r10, [r14, #48] - - sub r0, r2, r7 @ r0 = r1 - i3@ - add r1, r3, r6 @ i0 = i1 + r3@ - - ldr r11, DATATab - - add r2, r2, r7 @ r2 = r1 + i3@ - sub r3, r3, r6 @ i2 = i1 - r3@ - - sub r4, r0, r1 @ r0 - i0 - add r5, r0, r1 @ r0 + i0 - - sub r0, r2, r3 @ r2 - i2 - add r1, r2, r3 @ r2 + i2 - - smull r8, r6, r4, r11 - smull r9, r7, r5, r11 - - ldr r2, [sp, #16] - ldr r3, [sp, #20] - - smull r8, r4, r0, r11 - smull r9, r5, r1, r11 - - ldr r10, [sp, #24] - ldr r11, [sp, #28] - - sub r8, r2, r6 - sub r9, r3, r7 - - add r2, r2, r6 - add r3, r3, r7 - - add r6, r10, r5 - sub r7, r11, r4 - - sub r0, r10, r5 - add r1, r11, r4 - - strd r6, [r14, #8] - strd r8, [r14, #24] - strd r0, [r14, #40] - strd r2, [r14, #56] - - subs r12, r12, #1 - add r14, r14, #64 - - bne Radix8First_LOOP - -Radix8First_END: - add sp, sp, #0x24 - ldmia sp!, {r4 - r11, pc} - -DATATab: - .word 0x5a82799a - - @ENDP @ |Radix8First| - .end diff --git a/android-aac-enc/jni/src/asm/ARMV5E/Radix4FFT_v5.s b/android-aac-enc/jni/src/asm/ARMV5E/Radix4FFT_v5.s deleted file mode 100644 index b59b967ad..000000000 --- a/android-aac-enc/jni/src/asm/ARMV5E/Radix4FFT_v5.s +++ /dev/null @@ -1,169 +0,0 @@ -@/* -@ ** Copyright 2003-2010, VisualOn, Inc. -@ ** -@ ** Licensed under the Apache License, Version 2.0 (the "License"); -@ ** you may not use this file except in compliance with the License. -@ ** You may obtain a copy of the License at -@ ** -@ ** http://www.apache.org/licenses/LICENSE-2.0 -@ ** -@ ** Unless required by applicable law or agreed to in writing, software -@ ** distributed under the License is distributed on an "AS IS" BASIS, -@ ** WITHOUT 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: Radix4FFT_v5.s -@ -@ Content: Radix4FFT armv5 assemble -@ -@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ - .section .text - .global Radix4FFT - -Radix4FFT: - stmdb sp!, {r4 - r11, lr} - sub sp, sp, #32 - - mov r1, r1, asr #2 - cmp r1, #0 - beq Radix4FFT_END - -Radix4FFT_LOOP1: - mov r14, r0 @ xptr = buf@ - mov r10, r1 @ i = num@ - mov r9, r2, lsl #3 @ step = 2*bgn@ - cmp r10, #0 - str r0, [sp] - str r1, [sp, #4] - str r2, [sp, #8] - str r3, [sp, #12] - beq Radix4FFT_LOOP1_END - -Radix4FFT_LOOP2: - mov r12, r3 @ csptr = twidTab@ - mov r11, r2 @ j = bgn - cmp r11, #0 - str r10, [sp, #16] - beq Radix4FFT_LOOP2_END - -Radix4FFT_LOOP3: - str r11, [sp, #20] - - ldrd r0, [r14, #0] @ r0 = xptr[0]@ r1 = xptr[1]@ - add r14, r14, r9 @ xptr += step@ - - ldrd r10, [r14, #0] @ r2 = xptr[0]@ r3 = xptr[1]@ - ldr r8, [r12], #4 @ cosxsinx = csptr[0]@ - - smulwt r4, r10, r8 @ L_mpy_wx(cosx, t0) - smulwt r3, r11, r8 @ L_mpy_wx(cosx, t1) - - smlawb r2, r11, r8, r4 @ r2 = L_mpy_wx(cosx, t0) + L_mpy_wx(sinx, t1)@ - smulwb r5, r10, r8 @ L_mpy_wx(sinx, t0) - - mov r10, r0, asr #2 @ t0 = r0 >> 2@ - mov r11, r1, asr #2 @ t1 = r1 >> 2@ - - sub r3, r3, r5 @ r3 = L_mpy_wx(cosx, t1) - L_mpy_wx(sinx, t0)@ - add r14, r14, r9 @ xptr += step@ - - sub r0, r10, r2 @ r0 = t0 - r2@ - sub r1, r11, r3 @ r1 = t1 - r3@ - - add r2, r10, r2 @ r2 = t0 + r2@ - add r3, r11, r3 @ r3 = t1 + r3@ - - str r2, [sp, #24] - str r3, [sp, #28] - - ldrd r10, [r14, #0] @ r4 = xptr[0]@ r5 = xptr[1]@ - ldr r8, [r12], #4 @ cosxsinx = csptr[1]@ - - smulwt r6, r10, r8 @ L_mpy_wx(cosx, t0) - smulwt r5, r11, r8 @ L_mpy_wx(cosx, t1) - - smlawb r4, r11, r8, r6 @ r4 = L_mpy_wx(cosx, t0) + L_mpy_wx(sinx, t1)@ - smulwb r7, r10, r8 @ L_mpy_wx(sinx, t0) - - add r14, r14, r9 @ xptr += step@ - sub r5, r5, r7 @ r5 = L_mpy_wx(cosx, t1) - L_mpy_wx(sinx, t0)@ - - ldrd r10, [r14] @ r6 = xptr[0]@ r7 = xptr[1]@ - ldr r8, [r12], #4 @ cosxsinx = csptr[1]@ - - smulwt r2, r10, r8 @ L_mpy_wx(cosx, t0) - smulwt r7, r11, r8 @ L_mpy_wx(cosx, t1) - - smlawb r6, r11, r8, r2 @ r4 = L_mpy_wx(cosx, t0) + L_mpy_wx(sinx, t1)@ - smulwb r3, r10, r8 @ L_mpy_wx(sinx, t0) - - mov r10, r4 @ t0 = r4@ - mov r11, r5 @ t1 = r5@ - - sub r7, r7, r3 @ r5 = L_mpy_wx(cosx, t1) - L_mpy_wx(sinx, t0)@ - - - add r4, r10, r6 @ r4 = t0 + r6@ - sub r5, r7, r11 @ r5 = r7 - t1@ - - sub r6, r10, r6 @ r6 = t0 - r6@ - add r7, r7, r11 @ r7 = r7 + t1@ - - ldr r2, [sp, #24] - ldr r3, [sp, #28] - - add r10, r0, r5 @ xptr[0] = r0 + r5@ - add r11, r1, r6 @ xptr[0] = r1 + r6 - - strd r10, [r14] - sub r14, r14, r9 @ xptr -= step@ - - sub r10, r2, r4 @ xptr[0] = r2 - r4@ - sub r11, r3, r7 @ xptr[1] = r3 - r7@ - - strd r10, [r14] - sub r14, r14, r9 @ xptr -= step@ - - sub r10, r0, r5 @ xptr[0] = r0 - r5@ - sub r11, r1, r6 @ xptr[0] = r1 - r6 - - strd r10, [r14] - sub r14, r14, r9 @ xptr -= step@ - - add r10, r2, r4 @ xptr[0] = r2 - r4@ - add r11, r3, r7 @ xptr[1] = r3 - r7@ - - strd r10, [r14] - add r14, r14, #8 @ xptr += 2@ - - ldr r11, [sp, #20] - subs r11, r11, #1 - bne Radix4FFT_LOOP3 - -Radix4FFT_LOOP2_END: - ldr r10, [sp, #16] - ldr r3, [sp, #12] - ldr r2, [sp, #8] - rsb r8, r9, r9, lsl #2 - sub r10, r10, #1 - add r14, r14, r8 - cmp r10, #0 - bhi Radix4FFT_LOOP2 - -Radix4FFT_LOOP1_END: - ldr r0, [sp] - ldr r1, [sp, #4] - add r3, r3, r8, asr #1 - mov r2, r2, lsl #2 - movs r1, r1, asr #2 - bne Radix4FFT_LOOP1 - -Radix4FFT_END: - add sp, sp, #32 - ldmia sp!, {r4 - r11, pc} - - @ENDP @ |Radix4FFT| - .end diff --git a/android-aac-enc/jni/src/asm/ARMV5E/band_nrg_v5.s b/android-aac-enc/jni/src/asm/ARMV5E/band_nrg_v5.s deleted file mode 100644 index 4789f6d1d..000000000 --- a/android-aac-enc/jni/src/asm/ARMV5E/band_nrg_v5.s +++ /dev/null @@ -1,204 +0,0 @@ -@/* -@ ** Copyright 2003-2010, VisualOn, Inc. -@ ** -@ ** Licensed under the Apache License, Version 2.0 (the "License"); -@ ** you may not use this file except in compliance with the License. -@ ** You may obtain a copy of the License at -@ ** -@ ** http://www.apache.org/licenses/LICENSE-2.0 -@ ** -@ ** Unless required by applicable law or agreed to in writing, software -@ ** distributed under the License is distributed on an "AS IS" BASIS, -@ ** WITHOUT 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: band_nrg_v5.s -@ -@ Content: CalcBandEnergy and CalcBandEnergyMS function armv5 assemble -@ -@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ - - .section .text - - .global CalcBandEnergy - -CalcBandEnergy: - stmdb sp!, {r4 - r11, lr} - - mov r2, r2, lsl #16 - ldr r12, [r13, #36] - mov r9, #0 - mov r5, r2, asr #16 - mov r4, #0 - cmp r5, #0 - ble L212 - -L22: - mov r2, r4, lsl #1 - ldrsh r10, [r1, r2] - add r11, r1, r2 - ldrsh r2, [r11, #2] - mov r14, #0 - cmp r10, r2 - bge L28 - -L23: - ldr r11, [r0, +r10, lsl #2] - add r10, r10, #1 - ldr r6, [r0, +r10, lsl #2] - smull r11, r7, r11, r11 - add r10, r10, #1 - smull r6, r8, r6, r6 - ldr r11, [r0, +r10, lsl #2] - qadd r14, r14, r7 - add r10, r10, #1 - smull r11, r7, r11, r11 - ldr r6, [r0, +r10, lsl #2] - qadd r14, r14, r8 - smull r6, r8, r6, r6 - add r10, r10, #1 - qadd r14, r14, r7 - cmp r10, r2 - qadd r14, r14, r8 - blt L23 - -L28: - qadd r14, r14, r14 - str r14, [r3, +r4, lsl #2] - add r4, r4, #1 - qadd r9, r9, r14 - cmp r4, r5 - - blt L22 - -L212: - str r9, [r12, #0] - ldmia sp!, {r4 - r11, pc} - - @ENDP ; |CalcBandEnergy| - - .global CalcBandEnergyMS - -CalcBandEnergyMS: - stmdb sp!, {r4 - r11, lr} - sub r13, r13, #24 - - mov r12, #0 - mov r3, r3, lsl #16 - mov r14, #0 - mov r3, r3, asr #16 - cmp r3, #0 - mov r4, #0 - ble L315 - -L32: - mov r5, r4, lsl #1 - mov r6, #0 - ldrsh r10, [r2, r5] - add r5, r2, r5 - mov r7, #0 - ldrsh r11, [r5, #2] - cmp r10, r11 - bge L39 - - str r3, [r13, #4] - str r4, [r13, #8] - str r12, [r13, #12] - str r14, [r13, #16] - -L33: - ldr r8, [r0, +r10, lsl #2] - ldr r9, [r1, +r10, lsl #2] - mov r8, r8, asr #1 - add r10, r10, #1 - mov r9, r9, asr #1 - - ldr r12, [r0, +r10, lsl #2] - add r5, r8, r9 - ldr r14, [r1, +r10, lsl #2] - sub r8, r8, r9 - - smull r5, r3, r5, r5 - mov r12, r12, asr #1 - smull r8, r4, r8, r8 - mov r14, r14, asr #1 - - qadd r6, r6, r3 - add r5, r12, r14 - qadd r7, r7, r4 - sub r8, r12, r14 - - smull r5, r3, r5, r5 - add r10, r10, #1 - smull r8, r4, r8, r8 - - qadd r6, r6, r3 - qadd r7, r7, r4 - - ldr r8, [r0, +r10, lsl #2] - ldr r9, [r1, +r10, lsl #2] - mov r8, r8, asr #1 - add r10, r10, #1 - mov r9, r9, asr #1 - - ldr r12, [r0, +r10, lsl #2] - add r5, r8, r9 - ldr r14, [r1, +r10, lsl #2] - sub r8, r8, r9 - - smull r5, r3, r5, r5 - mov r12, r12, asr #1 - smull r8, r4, r8, r8 - mov r14, r14, asr #1 - - qadd r6, r6, r3 - add r5, r12, r14 - qadd r7, r7, r4 - sub r8, r12, r14 - - smull r5, r3, r5, r5 - add r10, r10, #1 - smull r8, r4, r8, r8 - - qadd r6, r6, r3 - qadd r7, r7, r4 - - cmp r10, r11 - - blt L33 - - ldr r3, [r13, #4] - ldr r4, [r13, #8] - ldr r12, [r13, #12] - ldr r14, [r13, #16] -L39: - qadd r6, r6, r6 - qadd r7, r7, r7 - - ldr r8, [r13, #60] - ldr r9, [r13, #68] - - qadd r12, r12, r6 - qadd r14, r14, r7 - - str r6, [r8, +r4, lsl #2] - str r7, [r9, +r4, lsl #2] - - add r4, r4, #1 - cmp r4, r3 - blt L32 - -L315: - ldr r8, [r13, #64] - ldr r9, [r13, #72] - str r12, [r8, #0] - str r14, [r9, #0] - - add r13, r13, #24 - ldmia sp!, {r4 - r11, pc} - @ENDP ; |CalcBandEnergyMS| - - .end diff --git a/android-aac-enc/jni/src/asm/ARMV7/PrePostMDCT_v7.s b/android-aac-enc/jni/src/asm/ARMV7/PrePostMDCT_v7.s deleted file mode 100644 index b2bc9d9b7..000000000 --- a/android-aac-enc/jni/src/asm/ARMV7/PrePostMDCT_v7.s +++ /dev/null @@ -1,135 +0,0 @@ -@/* -@ ** Copyright 2003-2010, VisualOn, Inc. -@ ** -@ ** Licensed under the Apache License, Version 2.0 (the "License"); -@ ** you may not use this file except in compliance with the License. -@ ** You may obtain a copy of the License at -@ ** -@ ** http://www.apache.org/licenses/LICENSE-2.0 -@ ** -@ ** Unless required by applicable law or agreed to in writing, software -@ ** distributed under the License is distributed on an "AS IS" BASIS, -@ ** WITHOUT 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: PrePostMDCT_v7.s -@ -@ Content: premdct and postmdct function armv7 assemble -@ -@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ - - .section .text - .global PreMDCT - -PreMDCT: - stmdb sp!, {r4 - r11, lr} - - add r9, r0, r1, lsl #2 - sub r3, r9, #32 - - movs r1, r1, asr #2 - beq PreMDCT_END - -PreMDCT_LOOP: - VLD4.I32 {d0, d2, d4, d6}, [r2]! @ cosa = *csptr++@ sina = *csptr++@ - VLD4.I32 {d1, d3, d5, d7}, [r2]! @ cosb = *csptr++@ sinb = *csptr++@ - VLD2.I32 {d8, d9, d10, d11}, [r0] @ tr1 = *(buf0 + 0)@ ti2 = *(buf0 + 1)@ - VLD2.I32 {d13, d15}, [r3]! @ tr2 = *(buf1 - 1)@ ti1 = *(buf1 + 0)@ - VLD2.I32 {d12, d14}, [r3]! @ tr2 = *(buf1 - 1)@ ti1 = *(buf1 + 0)@ - - VREV64.32 Q8, Q7 - VREV64.32 Q9, Q6 - - - VQDMULH.S32 Q10, Q0, Q4 @ MULHIGH(cosa, tr1) - VQDMULH.S32 Q11, Q1, Q8 @ MULHIGH(sina, ti1) - VQDMULH.S32 Q12, Q0, Q8 @ MULHIGH(cosa, ti1) - VQDMULH.S32 Q13, Q1, Q4 @ MULHIGH(sina, tr1) - - VADD.S32 Q0, Q10, Q11 @ *buf0++ = MULHIGH(cosa, tr1) + MULHIGH(sina, ti1)@ - VSUB.S32 Q1, Q12, Q13 @ *buf0++ = MULHIGH(cosa, ti1) - MULHIGH(sina, tr1)@ - - VST2.I32 {d0, d1, d2, d3}, [r0]! - sub r3, r3, #32 - - VQDMULH.S32 Q10, Q2, Q9 @ MULHIGH(cosb, tr2) - VQDMULH.S32 Q11, Q3, Q5 @ MULHIGH(sinb, ti2) - VQDMULH.S32 Q12, Q2, Q5 @ MULHIGH(cosb, ti2) - VQDMULH.S32 Q13, Q3, Q9 @ MULHIGH(sinb, tr2) - - VADD.S32 Q0, Q10, Q11 @ MULHIGH(cosa, tr2) + MULHIGH(sina, ti2)@ - VSUB.S32 Q1, Q12, Q13 @ MULHIGH(cosa, ti2) - MULHIGH(sina, tr2)@ - - VREV64.32 Q3, Q1 - VREV64.32 Q2, Q0 - - VST2.I32 {d5, d7}, [r3]! - VST2.I32 {d4, d6}, [r3]! - - subs r1, r1, #4 - sub r3, r3, #64 - bne PreMDCT_LOOP - -PreMDCT_END: - ldmia sp!, {r4 - r11, pc} - @ENDP @ |PreMDCT| - - .section .text - .global PostMDCT - -PostMDCT: - stmdb sp!, {r4 - r11, lr} - - add r9, r0, r1, lsl #2 - sub r3, r9, #32 - - movs r1, r1, asr #2 - beq PostMDCT_END - -PostMDCT_LOOP: - VLD4.I32 {d0, d2, d4, d6}, [r2]! @ cosa = *csptr++@ sina = *csptr++@ - VLD4.I32 {d1, d3, d5, d7}, [r2]! @ cosb = *csptr++@ sinb = *csptr++@ - VLD2.I32 {d8, d9, d10, d11}, [r0] @ tr1 = *(zbuf1 + 0)@ ti1 = *(zbuf1 + 1)@ - VLD2.I32 {d13, d15}, [r3]! @ tr2 = *(zbuf2 - 1)@ ti2 = *(zbuf2 + 0)@ - VLD2.I32 {d12, d14}, [r3]! @ tr2 = *(zbuf2 - 1)@ ti2 = *(zbuf2 + 0)@ - - VREV64.32 Q8, Q6 - VREV64.32 Q9, Q7 - - VQDMULH.S32 Q10, Q0, Q4 @ MULHIGH(cosa, tr1) - VQDMULH.S32 Q11, Q1, Q5 @ MULHIGH(sina, ti1) - VQDMULH.S32 Q12, Q0, Q5 @ MULHIGH(cosa, ti1) - VQDMULH.S32 Q13, Q1, Q4 @ MULHIGH(sina, tr1) - - VADD.S32 Q0, Q10, Q11 @ *buf0++ = MULHIGH(cosa, tr1) + MULHIGH(sina, ti1)@ - VSUB.S32 Q5, Q13, Q12 @ *buf1-- = MULHIGH(sina, tr1) - MULHIGH(cosa, ti1)@ - - VQDMULH.S32 Q10, Q2, Q8 @ MULHIGH(cosb, tr2) - VQDMULH.S32 Q11, Q3, Q9 @ MULHIGH(sinb, ti2) - VQDMULH.S32 Q12, Q2, Q9 @ MULHIGH(cosb, ti2) - VQDMULH.S32 Q13, Q3, Q8 @ MULHIGH(sinb, tr2) - - VADD.S32 Q4, Q10, Q11 @ *buf1-- = MULHIGH(cosa, tr2) + MULHIGH(sina, ti2)@ - VSUB.S32 Q1, Q13, Q12 @ *buf0++ = MULHIGH(sina, tr2) - MULHIGH(cosa, ti2)@ - - VREV64.32 Q2, Q4 - VREV64.32 Q3, Q5 - - sub r3, r3, #32 - VST2.I32 {d0, d1, d2, d3}, [r0]! - - VST2.I32 {d5, d7}, [r3]! - VST2.I32 {d4, d6}, [r3]! - - subs r1, r1, #4 - sub r3, r3, #64 - bne PostMDCT_LOOP - -PostMDCT_END: - ldmia sp!, {r4 - r11, pc} - - @ENDP @ |PostMDCT| - .end diff --git a/android-aac-enc/jni/src/asm/ARMV7/R4R8First_v7.s b/android-aac-enc/jni/src/asm/ARMV7/R4R8First_v7.s deleted file mode 100644 index 3033156a5..000000000 --- a/android-aac-enc/jni/src/asm/ARMV7/R4R8First_v7.s +++ /dev/null @@ -1,146 +0,0 @@ -@/* -@ ** Copyright 2003-2010, VisualOn, Inc. -@ ** -@ ** Licensed under the Apache License, Version 2.0 (the "License"); -@ ** you may not use this file except in compliance with the License. -@ ** You may obtain a copy of the License at -@ ** -@ ** http://www.apache.org/licenses/LICENSE-2.0 -@ ** -@ ** Unless required by applicable law or agreed to in writing, software -@ ** distributed under the License is distributed on an "AS IS" BASIS, -@ ** WITHOUT 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: R4R8First_v7.s -@ -@ Content: Radix8First and Radix4First function armv7 assemble -@ -@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ - - .section .text - .global Radix8First - -Radix8First: - stmdb sp!, {r4 - r11, lr} - - ldr r3, SQRT1_2 - cmp r1, #0 - - VDUP.I32 Q15, r3 - beq Radix8First_END - -Radix8First_LOOP: - VLD1.I32 {d0, d1, d2, d3}, [r0]! - VLD1.I32 {d8, d9, d10, d11}, [r0]! - - VADD.S32 d4, d0, d1 @ r0 = buf[0] + buf[2]@i0 = buf[1] + buf[3]@ - VSUB.S32 d5, d0, d1 @ r1 = buf[0] - buf[2]@i1 = buf[1] - buf[3]@ - VSUB.S32 d7, d2, d3 @ r2 = buf[4] - buf[6]@i2 = buf[5] - buf[7]@ - VADD.S32 d6, d2, d3 @ r3 = buf[4] + buf[6]@i3 = buf[5] + buf[7]@ - VREV64.I32 d7, d7 - - VADD.S32 Q0, Q2, Q3 @ r4 = (r0 + r2)@i4 = (i0 + i2)@i6 = (i1 + r3)@r7 = (r1 + i3) - VSUB.S32 Q1, Q2, Q3 @ r5 = (r0 - r2)@i5 = (i0 - i2)@r6 = (r1 - i3)@i7 = (i1 - r3)@ - - VREV64.I32 d3, d3 - - VADD.S32 d4, d8, d9 @ r0 = buf[ 8] + buf[10]@i0 = buf[ 9] + buf[11]@ - VSUB.S32 d7, d10, d11 @ r1 = buf[12] - buf[14]@i1 = buf[13] - buf[15]@ - VADD.S32 d6, d10, d11 @ r2 = buf[12] + buf[14]@i2 = buf[13] + buf[15]@ - VREV64.I32 d7, d7 - VSUB.S32 d5, d8, d9 @ r3 = buf[ 8] - buf[10]@i3 = buf[ 9] - buf[11]@ - - VTRN.32 d1, d3 - - VADD.S32 Q4, Q2, Q3 @ t0 = (r0 + r2) >> 1@t1 = (i0 + i2) >> 1@i0 = i1 + r3@r2 = r1 + i3@ - VSUB.S32 Q5, Q2, Q3 @ t2 = (r0 - r2) >> 1@t3 = (i0 - i2) >> 1@r0 = r1 - i3@i2 = i1 - r3@ - - VREV64.I32 d3, d3 - - VSHR.S32 d8, d8, #1 - VSHR.S32 Q0, Q0, #1 - VREV64.I32 d10, d10 - VTRN.32 d11, d9 - VSHR.S32 Q1, Q1, #1 - VSHR.S32 d10, d10, #1 - VREV64.I32 d9, d9 - - sub r0, r0, #0x40 - - VADD.S32 d12, d0, d8 - VSUB.S32 d16, d0, d8 - VADD.S32 d14, d2, d10 - VSUB.S32 d18, d2, d10 - - VSUB.S32 d4, d11, d9 - VADD.S32 d5, d11, d9 - - VREV64.I32 d18, d18 - - VQDMULH.S32 Q3, Q2, Q15 - VTRN.32 d14, d18 - VTRN.32 d6, d7 - VREV64.I32 d18, d18 - - VSUB.S32 d15, d3, d6 - VREV64.I32 d7, d7 - VADD.S32 d19, d3, d6 - VADD.S32 d13, d1, d7 - VSUB.S32 d17, d1, d7 - - VREV64.I32 d17, d17 - VTRN.32 d13, d17 - VREV64.I32 d17, d17 - - subs r1, r1, #1 - - VST1.I32 {d12, d13, d14, d15}, [r0]! - VST1.I32 {d16, d17, d18, d19}, [r0]! - bne Radix8First_LOOP - -Radix8First_END: - ldmia sp!, {r4 - r11, pc} -SQRT1_2: - .word 0x2d413ccd - - @ENDP @ |Radix8First| - - .section .text - .global Radix4First - -Radix4First: - stmdb sp!, {r4 - r11, lr} - - cmp r1, #0 - beq Radix4First_END - -Radix4First_LOOP: - VLD1.I32 {d0, d1, d2, d3}, [r0] - - VADD.S32 d4, d0, d1 @ r0 = buf[0] + buf[2]@ r1 = buf[1] + buf[3]@ - VSUB.S32 d5, d0, d1 @ r2 = buf[0] - buf[2]@ r3 = buf[1] - buf[3]@ - VSUB.S32 d7, d2, d3 @ r4 = buf[4] + buf[6]@ r5 = buf[5] + buf[7]@ - VADD.S32 d6, d2, d3 @ r6 = buf[4] - buf[6]@ r7 = buf[5] - buf[7]@ - - VREV64.I32 d7, d7 @ - - VADD.S32 Q4, Q2, Q3 - VSUB.S32 Q5, Q2, Q3 - - VREV64.I32 d11, d11 - VTRN.32 d9, d11 - subs r1, r1, #1 - VREV64.I32 d11, d11 - VST1.I32 {d8, d9, d10, d11}, [r0]! - - bne Radix4First_LOOP - -Radix4First_END: - ldmia sp!, {r4 - r11, pc} - - @ENDP @ |Radix4First| - .end diff --git a/android-aac-enc/jni/src/asm/ARMV7/Radix4FFT_v7.s b/android-aac-enc/jni/src/asm/ARMV7/Radix4FFT_v7.s deleted file mode 100644 index f8748256b..000000000 --- a/android-aac-enc/jni/src/asm/ARMV7/Radix4FFT_v7.s +++ /dev/null @@ -1,143 +0,0 @@ -@/* -@ ** Copyright 2003-2010, VisualOn, Inc. -@ ** -@ ** Licensed under the Apache License, Version 2.0 (the "License"); -@ ** you may not use this file except in compliance with the License. -@ ** You may obtain a copy of the License at -@ ** -@ ** http://www.apache.org/licenses/LICENSE-2.0 -@ ** -@ ** Unless required by applicable law or agreed to in writing, software -@ ** distributed under the License is distributed on an "AS IS" BASIS, -@ ** WITHOUT 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: Radix4FFT_v7.s -@ -@ Content: Radix4FFT armv7 assemble -@ -@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ - - .section .text - .global Radix4FFT - -Radix4FFT: - stmdb sp!, {r4 - r11, lr} - - mov r1, r1, asr #2 - cmp r1, #0 - beq Radix4FFT_END - -Radix4FFT_LOOP1: - mov r5, r2, lsl #1 - mov r8, r0 - mov r7, r1 - mov r5, r5, lsl #2 - cmp r1, #0 - rsbeq r12, r5, r5, lsl #2 - beq Radix4FFT_LOOP1_END - - rsb r12, r5, r5, lsl #2 - -Radix4FFT_LOOP2: - mov r6, r3 - mov r4, r2 - cmp r2, #0 - beq Radix4FFT_LOOP2_END - -Radix4FFT_LOOP3: - @r0 = xptr[0]@ - @r1 = xptr[1]@ - VLD2.I32 {D0, D1, D2, D3}, [r8] - VLD2.I32 {D28, D29, D30, D31}, [r6]! @ cosx = csptr[0]@ sinx = csptr[1]@ - - add r8, r8, r5 @ xptr += step@ - VLD2.I32 {D4, D5, D6,D7}, [r8] @ r2 = xptr[0]@ r3 = xptr[1]@ - - VQDMULH.S32 Q10, Q2, Q14 @ MULHIGH(cosx, t0) - VQDMULH.S32 Q11, Q3, Q15 @ MULHIGH(sinx, t1) - VQDMULH.S32 Q12, Q3, Q14 @ MULHIGH(cosx, t1) - VQDMULH.S32 Q13, Q2, Q15 @ MULHIGH(sinx, t0) - - VADD.S32 Q2, Q10, Q11 @ MULHIGH(cosx, t0) + MULHIGH(sinx, t1) - VSUB.S32 Q3, Q12, Q13 @ MULHIGH(cosx, t1) - MULHIGH(sinx, t0) - - add r8, r8, r5 @ xptr += step@ - VSHR.S32 Q10, Q0, #2 @ t0 = r0 >> 2@ - VSHR.S32 Q11, Q1, #2 @ t1 = r1 >> 2@ - - VSUB.S32 Q0, Q10, Q2 @ r0 = t0 - r2@ - VSUB.S32 Q1, Q11, Q3 @ r1 = t1 - r3@ - VADD.S32 Q2, Q10, Q2 @ r2 = t0 + r2@ - VADD.S32 Q3, Q11, Q3 @ r3 = t1 + r3@ - - VLD2.I32 {D8, D9, D10, D11}, [r8] - VLD2.I32 {D28, D29, D30, D31}, [r6]! - add r8, r8, r5 - - VQDMULH.S32 Q10, Q4, Q14 @ MULHIGH(cosx, t0) - VQDMULH.S32 Q11, Q5, Q15 @ MULHIGH(sinx, t1) - VQDMULH.S32 Q12, Q5, Q14 @ MULHIGH(cosx, t1) - VQDMULH.S32 Q13, Q4, Q15 @ MULHIGH(sinx, t0) - - VADD.S32 Q8, Q10, Q11 @ MULHIGH(cosx, t0) + MULHIGH(sinx, t1) - VSUB.S32 Q9, Q12, Q13 @ MULHIGH(cosx, t1) - MULHIGH(sinx, t0) - - VLD2.I32 {D12, D13, D14, D15}, [r8] - VLD2.I32 {D28, D29, D30, D31}, [r6]! - - VQDMULH.S32 Q10, Q6, Q14 @ MULHIGH(cosx, t0) - VQDMULH.S32 Q11, Q7, Q15 @ MULHIGH(sinx, t1) - VQDMULH.S32 Q12, Q7, Q14 @ MULHIGH(cosx, t1) - VQDMULH.S32 Q13, Q6, Q15 @ MULHIGH(sinx, t0) - - VADD.S32 Q6, Q10, Q11 @ MULHIGH(cosx, t0) + MULHIGH(sinx, t1) - VSUB.S32 Q7, Q12, Q13 @ MULHIGH(cosx, t1) - MULHIGH(sinx, t0) - - VADD.S32 Q4, Q8, Q6 @ r4 = t0 + r6@ - VSUB.S32 Q5, Q7, Q9 @ r5 = r7 - t1@ - VSUB.S32 Q6, Q8, Q6 @ r6 = t0 - r6@ - VADD.S32 Q7, Q7, Q9 @ r7 = r7 + t1@ - - VADD.S32 Q8, Q0, Q5 @ xptr[0] = r0 + r5@ - VADD.S32 Q9, Q1, Q6 @ xptr[1] = r1 + r6@ - VST2.I32 {D16, D17, D18, D19}, [r8] - - VSUB.S32 Q10, Q2, Q4 @ xptr[0] = r2 - r4@ - sub r8, r8, r5 @ xptr -= step@ - VSUB.S32 Q11, Q3, Q7 @ xptr[1] = r3 - r7@ - VST2.I32 {D20, D21, D22, D23}, [r8] - - VSUB.S32 Q8, Q0, Q5 @ xptr[0] = r0 - r5@ - sub r8, r8, r5 @ xptr -= step@ - VSUB.S32 Q9, Q1, Q6 @ xptr[1] = r1 - r6@ - VST2.I32 {D16, D17, D18, D19}, [r8] - - VADD.S32 Q10, Q2, Q4 @ xptr[0] = r2 + r4@ - sub r8, r8, r5 @ xptr -= step@ - VADD.S32 Q11, Q3, Q7 @ xptr[1] = r3 + r7@ - VST2.I32 {D20, D21, D22, D23}, [r8]! - - subs r4, r4, #4 - bne Radix4FFT_LOOP3 - -Radix4FFT_LOOP2_END: - add r8, r8, r12 - sub r7, r7, #1 - cmp r7, #0 - bhi Radix4FFT_LOOP2 - -Radix4FFT_LOOP1_END: - add r3, r12, r3 - mov r2, r2, lsl #2 - movs r1, r1, asr #2 - bne Radix4FFT_LOOP1 - -Radix4FFT_END: - ldmia sp!, {r4 - r11, pc} - - @ENDP @ |Radix4FFT| - .end diff --git a/android-aac-enc/jni/src/band_nrg.c b/android-aac-enc/jni/src/band_nrg.c deleted file mode 100644 index e4034b8a4..000000000 --- a/android-aac-enc/jni/src/band_nrg.c +++ /dev/null @@ -1,102 +0,0 @@ -/* - ** Copyright 2003-2010, VisualOn, Inc. - ** - ** Licensed under the Apache License, Version 2.0 (the "License"); - ** you may not use this file except in compliance with the License. - ** You may obtain a copy of the License at - ** - ** http://www.apache.org/licenses/LICENSE-2.0 - ** - ** Unless required by applicable law or agreed to in writing, software - ** distributed under the License is distributed on an "AS IS" BASIS, - ** WITHOUT 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: band_nrg.c - - Content: Band/Line energy calculations functions - -*******************************************************************************/ - -#include "basic_op.h" -#include "band_nrg.h" - -#ifndef ARMV5E -/******************************************************************************** -* -* function name: CalcBandEnergy -* description: Calc sfb-bandwise mdct-energies for left and right channel -* -**********************************************************************************/ -void CalcBandEnergy(const Word32 *mdctSpectrum, - const Word16 *bandOffset, - const Word16 numBands, - Word32 *bandEnergy, - Word32 *bandEnergySum) -{ - Word32 i, j; - Word32 accuSum = 0; - - for (i=0; i> 1; - r = mdctSpectrumRight[j] >> 1; - specm = l + r; - specs = l - r; - accuMid = L_add(accuMid, MULHIGH(specm, specm)); - accuSide = L_add(accuSide, MULHIGH(specs, specs)); - } - - accuMid = L_add(accuMid, accuMid); - accuSide = L_add(accuSide, accuSide); - bandEnergyMid[i] = accuMid; - accuMidSum = L_add(accuMidSum, accuMid); - bandEnergySide[i] = accuSide; - accuSideSum = L_add(accuSideSum, accuSide); - - } - *bandEnergyMidSum = accuMidSum; - *bandEnergySideSum = accuSideSum; -} - -#endif diff --git a/android-aac-enc/jni/src/bit_cnt.c b/android-aac-enc/jni/src/bit_cnt.c deleted file mode 100644 index 9fe511cd9..000000000 --- a/android-aac-enc/jni/src/bit_cnt.c +++ /dev/null @@ -1,885 +0,0 @@ -/* - ** Copyright 2003-2010, VisualOn, Inc. - ** - ** Licensed under the Apache License, Version 2.0 (the "License"); - ** you may not use this file except in compliance with the License. - ** You may obtain a copy of the License at - ** - ** http://www.apache.org/licenses/LICENSE-2.0 - ** - ** Unless required by applicable law or agreed to in writing, software - ** distributed under the License is distributed on an "AS IS" BASIS, - ** WITHOUT 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: bit_cnt.c - - Content: Huffman Bitcounter & coder functions - -*******************************************************************************/ - -#include "bit_cnt.h" -#include "aac_rom.h" - -#define HI_LTAB(a) (a>>8) -#define LO_LTAB(a) (a & 0xff) - -#define EXPAND(a) ((((Word32)(a&0xff00)) << 8)|(Word32)(a&0xff)) - - -/***************************************************************************** -* -* function name: count1_2_3_4_5_6_7_8_9_10_11 -* description: counts tables 1-11 -* returns: -* input: quantized spectrum -* output: bitCount for tables 1-11 -* -*****************************************************************************/ - -static void count1_2_3_4_5_6_7_8_9_10_11(const Word16 *values, - const Word16 width, - Word16 *bitCount) -{ - Word32 t0,t1,t2,t3,i; - Word32 bc1_2,bc3_4,bc5_6,bc7_8,bc9_10; - Word16 bc11,sc; - - bc1_2=0; - bc3_4=0; - bc5_6=0; - bc7_8=0; - bc9_10=0; - bc11=0; - sc=0; - - for(i=0;i0) + (t1>0) + (t2>0) + (t3>0); - } - - bitCount[1]=extract_h(bc1_2); - bitCount[2]=extract_l(bc1_2); - bitCount[3]=extract_h(bc3_4) + sc; - bitCount[4]=extract_l(bc3_4) + sc; - bitCount[5]=extract_h(bc5_6); - bitCount[6]=extract_l(bc5_6); - bitCount[7]=extract_h(bc7_8) + sc; - bitCount[8]=extract_l(bc7_8) + sc; - bitCount[9]=extract_h(bc9_10) + sc; - bitCount[10]=extract_l(bc9_10) + sc; - bitCount[11]=bc11 + sc; -} - - -/***************************************************************************** -* -* function name: count3_4_5_6_7_8_9_10_11 -* description: counts tables 3-11 -* returns: -* input: quantized spectrum -* output: bitCount for tables 3-11 -* -*****************************************************************************/ - -static void count3_4_5_6_7_8_9_10_11(const Word16 *values, - const Word16 width, - Word16 *bitCount) -{ - Word32 t0,t1,t2,t3, i; - Word32 bc3_4,bc5_6,bc7_8,bc9_10; - Word16 bc11,sc; - - bc3_4=0; - bc5_6=0; - bc7_8=0; - bc9_10=0; - bc11=0; - sc=0; - - for(i=0;i0) + (t1>0) + (t2>0) + (t3>0); - } - - bitCount[1]=INVALID_BITCOUNT; - bitCount[2]=INVALID_BITCOUNT; - bitCount[3]=extract_h(bc3_4) + sc; - bitCount[4]=extract_l(bc3_4) + sc; - bitCount[5]=extract_h(bc5_6); - bitCount[6]=extract_l(bc5_6); - bitCount[7]=extract_h(bc7_8) + sc; - bitCount[8]=extract_l(bc7_8) + sc; - bitCount[9]=extract_h(bc9_10) + sc; - bitCount[10]=extract_l(bc9_10) + sc; - bitCount[11]=bc11 + sc; - -} - - - -/***************************************************************************** -* -* function name: count5_6_7_8_9_10_11 -* description: counts tables 5-11 -* returns: -* input: quantized spectrum -* output: bitCount for tables 5-11 -* -*****************************************************************************/ -static void count5_6_7_8_9_10_11(const Word16 *values, - const Word16 width, - Word16 *bitCount) -{ - - Word32 t0,t1,i; - Word32 bc5_6,bc7_8,bc9_10; - Word16 bc11,sc; - - bc5_6=0; - bc7_8=0; - bc9_10=0; - bc11=0; - sc=0; - - for(i=0;i0) + (t1>0); - } - bitCount[1]=INVALID_BITCOUNT; - bitCount[2]=INVALID_BITCOUNT; - bitCount[3]=INVALID_BITCOUNT; - bitCount[4]=INVALID_BITCOUNT; - bitCount[5]=extract_h(bc5_6); - bitCount[6]=extract_l(bc5_6); - bitCount[7]=extract_h(bc7_8) + sc; - bitCount[8]=extract_l(bc7_8) + sc; - bitCount[9]=extract_h(bc9_10) + sc; - bitCount[10]=extract_l(bc9_10) + sc; - bitCount[11]=bc11 + sc; - -} - - -/***************************************************************************** -* -* function name: count7_8_9_10_11 -* description: counts tables 7-11 -* returns: -* input: quantized spectrum -* output: bitCount for tables 7-11 -* -*****************************************************************************/ - -static void count7_8_9_10_11(const Word16 *values, - const Word16 width, - Word16 *bitCount) -{ - Word32 t0,t1, i; - Word32 bc7_8,bc9_10; - Word16 bc11,sc; - - bc7_8=0; - bc9_10=0; - bc11=0; - sc=0; - - for(i=0;i0) + (t1>0); - } - bitCount[1]=INVALID_BITCOUNT; - bitCount[2]=INVALID_BITCOUNT; - bitCount[3]=INVALID_BITCOUNT; - bitCount[4]=INVALID_BITCOUNT; - bitCount[5]=INVALID_BITCOUNT; - bitCount[6]=INVALID_BITCOUNT; - bitCount[7]=extract_h(bc7_8) + sc; - bitCount[8]=extract_l(bc7_8) + sc; - bitCount[9]=extract_h(bc9_10) + sc; - bitCount[10]=extract_l(bc9_10) + sc; - bitCount[11]=bc11 + sc; - -} - -/***************************************************************************** -* -* function name: count9_10_11 -* description: counts tables 9-11 -* returns: -* input: quantized spectrum -* output: bitCount for tables 9-11 -* -*****************************************************************************/ -static void count9_10_11(const Word16 *values, - const Word16 width, - Word16 *bitCount) -{ - - Word32 t0,t1,i; - Word32 bc9_10; - Word16 bc11,sc; - - bc9_10=0; - bc11=0; - sc=0; - - for(i=0;i0) + (t1>0); - } - bitCount[1]=INVALID_BITCOUNT; - bitCount[2]=INVALID_BITCOUNT; - bitCount[3]=INVALID_BITCOUNT; - bitCount[4]=INVALID_BITCOUNT; - bitCount[5]=INVALID_BITCOUNT; - bitCount[6]=INVALID_BITCOUNT; - bitCount[7]=INVALID_BITCOUNT; - bitCount[8]=INVALID_BITCOUNT; - bitCount[9]=extract_h(bc9_10) + sc; - bitCount[10]=extract_l(bc9_10) + sc; - bitCount[11]=bc11 + sc; - -} - -/***************************************************************************** -* -* function name: count11 -* description: counts table 11 -* returns: -* input: quantized spectrum -* output: bitCount for table 11 -* -*****************************************************************************/ - static void count11(const Word16 *values, - const Word16 width, - Word16 *bitCount) -{ - Word32 t0,t1,i; - Word16 bc11,sc; - - bc11=0; - sc=0; - for(i=0;i0) + (t1>0); - } - - bitCount[1]=INVALID_BITCOUNT; - bitCount[2]=INVALID_BITCOUNT; - bitCount[3]=INVALID_BITCOUNT; - bitCount[4]=INVALID_BITCOUNT; - bitCount[5]=INVALID_BITCOUNT; - bitCount[6]=INVALID_BITCOUNT; - bitCount[7]=INVALID_BITCOUNT; - bitCount[8]=INVALID_BITCOUNT; - bitCount[9]=INVALID_BITCOUNT; - bitCount[10]=INVALID_BITCOUNT; - bitCount[11]=bc11 + sc; -} - -/***************************************************************************** -* -* function name: countEsc -* description: counts table 11 (with Esc) -* returns: -* input: quantized spectrum -* output: bitCount for tables 11 (with Esc) -* -*****************************************************************************/ - -static void countEsc(const Word16 *values, - const Word16 width, - Word16 *bitCount) -{ - Word32 t0,t1,t00,t01,i; - Word16 bc11,ec,sc; - - bc11=0; - sc=0; - ec=0; - for(i=0;i0) + (t1>0); - - t00 = min(t0,16); - t01 = min(t1,16); - bc11 = bc11 + huff_ltab11[t00][t01]; - - - if(t0 >= 16){ - ec = ec + 5; - while(sub(t0=(t0 >> 1), 16) >= 0) { - ec = ec + 2; - } - } - - - if(t1 >= 16){ - ec = ec + 5; - while(sub(t1=(t1 >> 1), 16) >= 0) { - ec = ec + 2; - } - } - } - bitCount[1]=INVALID_BITCOUNT; - bitCount[2]=INVALID_BITCOUNT; - bitCount[3]=INVALID_BITCOUNT; - bitCount[4]=INVALID_BITCOUNT; - bitCount[5]=INVALID_BITCOUNT; - bitCount[6]=INVALID_BITCOUNT; - bitCount[7]=INVALID_BITCOUNT; - bitCount[8]=INVALID_BITCOUNT; - bitCount[9]=INVALID_BITCOUNT; - bitCount[10]=INVALID_BITCOUNT; - bitCount[11]=bc11 + sc + ec; -} - - -typedef void (*COUNT_FUNCTION)(const Word16 *values, - const Word16 width, - Word16 *bitCount); - -static COUNT_FUNCTION countFuncTable[CODE_BOOK_ESC_LAV+1] = - { - - count1_2_3_4_5_6_7_8_9_10_11, /* 0 */ - count1_2_3_4_5_6_7_8_9_10_11, /* 1 */ - count3_4_5_6_7_8_9_10_11, /* 2 */ - count5_6_7_8_9_10_11, /* 3 */ - count5_6_7_8_9_10_11, /* 4 */ - count7_8_9_10_11, /* 5 */ - count7_8_9_10_11, /* 6 */ - count7_8_9_10_11, /* 7 */ - count9_10_11, /* 8 */ - count9_10_11, /* 9 */ - count9_10_11, /* 10 */ - count9_10_11, /* 11 */ - count9_10_11, /* 12 */ - count11, /* 13 */ - count11, /* 14 */ - count11, /* 15 */ - countEsc /* 16 */ - }; - -/***************************************************************************** -* -* function name: bitCount -* description: count bits -* -*****************************************************************************/ -Word16 bitCount(const Word16 *values, - const Word16 width, - Word16 maxVal, - Word16 *bitCount) -{ - /* - check if we can use codebook 0 - */ - - if(maxVal == 0) - bitCount[0] = 0; - else - bitCount[0] = INVALID_BITCOUNT; - - maxVal = min(maxVal, CODE_BOOK_ESC_LAV); - countFuncTable[maxVal](values,width,bitCount); - - return(0); -} - -/***************************************************************************** -* -* function name: codeValues -* description: write huffum bits -* -*****************************************************************************/ -Word16 codeValues(Word16 *values, Word16 width, Word16 codeBook, HANDLE_BIT_BUF hBitstream) -{ - - Word32 i, t0, t1, t2, t3, t00, t01; - UWord16 codeWord, codeLength; - Word16 sign, signLength; - - - switch (codeBook) { - case CODE_BOOK_ZERO_NO: - break; - - case CODE_BOOK_1_NO: - for(i=0; i= 16){ - Word16 n, p; - n=0; - p=t0; - while(sub(p=(p >> 1), 16) >= 0){ - - WriteBits(hBitstream,1,1); - n = n + 1; - } - WriteBits(hBitstream,0,1); - n = n + 4; - WriteBits(hBitstream,(t0 - (1 << n)),n); - } - - if(t1 >= 16){ - Word16 n, p; - n=0; - p=t1; - while(sub(p=(p >> 1), 16) >= 0){ - - WriteBits(hBitstream,1,1); - n = n + 1; - } - WriteBits(hBitstream,0,1); - n = n + 4; - WriteBits(hBitstream,(t1 - (1 << n)),n); - } - } - break; - - default: - break; - } - return(0); -} - -Word16 bitCountScalefactorDelta(Word16 delta) -{ - return(huff_ltabscf[delta+CODE_BOOK_SCF_LAV]); -} - -Word16 codeScalefactorDelta(Word16 delta, HANDLE_BIT_BUF hBitstream) -{ - Word32 codeWord; - Word16 codeLength; - - - if(delta > CODE_BOOK_SCF_LAV || delta < -CODE_BOOK_SCF_LAV) - return(1); - - codeWord = huff_ctabscf[delta + CODE_BOOK_SCF_LAV]; - codeLength = huff_ltabscf[delta + CODE_BOOK_SCF_LAV]; - WriteBits(hBitstream,codeWord,codeLength); - return(0); -} diff --git a/android-aac-enc/jni/src/bitbuffer.c b/android-aac-enc/jni/src/bitbuffer.c deleted file mode 100644 index 0ce93d395..000000000 --- a/android-aac-enc/jni/src/bitbuffer.c +++ /dev/null @@ -1,173 +0,0 @@ -/* - ** Copyright 2003-2010, VisualOn, Inc. - ** - ** Licensed under the Apache License, Version 2.0 (the "License"); - ** you may not use this file except in compliance with the License. - ** You may obtain a copy of the License at - ** - ** http://www.apache.org/licenses/LICENSE-2.0 - ** - ** Unless required by applicable law or agreed to in writing, software - ** distributed under the License is distributed on an "AS IS" BASIS, - ** WITHOUT 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: bitbuffer.c - - Content: Bit Buffer Management functions - -*******************************************************************************/ - -#include "bitbuffer.h" - -/***************************************************************************** -* -* function name: updateBitBufWordPtr -* description: update Bit Buffer pointer -* -*****************************************************************************/ -static void updateBitBufWordPtr(HANDLE_BIT_BUF hBitBuf, - UWord8 **pBitBufWord, - Word16 cnt) -{ - *pBitBufWord += cnt; - - - if(*pBitBufWord > hBitBuf->pBitBufEnd) { - *pBitBufWord -= (hBitBuf->pBitBufEnd - hBitBuf->pBitBufBase + 1); - } - - if(*pBitBufWord < hBitBuf->pBitBufBase) { - *pBitBufWord += (hBitBuf->pBitBufEnd - hBitBuf->pBitBufBase + 1); - } -} - - -/***************************************************************************** -* -* function name: CreateBitBuffer -* description: create and init Bit Buffer Management -* -*****************************************************************************/ -HANDLE_BIT_BUF CreateBitBuffer(HANDLE_BIT_BUF hBitBuf, - UWord8 *pBitBufBase, - Word16 bitBufSize) -{ - assert(bitBufSize*8 <= 32768); - - hBitBuf->pBitBufBase = pBitBufBase; - hBitBuf->pBitBufEnd = pBitBufBase + bitBufSize - 1; - - hBitBuf->pWriteNext = pBitBufBase; - - hBitBuf->cache = 0; - - hBitBuf->wBitPos = 0; - hBitBuf->cntBits = 0; - - hBitBuf->size = (bitBufSize << 3); - hBitBuf->isValid = 1; - - return hBitBuf; -} - -/***************************************************************************** -* -* function name: DeleteBitBuffer -* description: uninit Bit Buffer Management -* -*****************************************************************************/ -void DeleteBitBuffer(HANDLE_BIT_BUF *hBitBuf) -{ - if(*hBitBuf) - (*hBitBuf)->isValid = 0; - *hBitBuf = NULL; -} - -/***************************************************************************** -* -* function name: ResetBitBuf -* description: reset Bit Buffer Management -* -*****************************************************************************/ -void ResetBitBuf(HANDLE_BIT_BUF hBitBuf, - UWord8 *pBitBufBase, - Word16 bitBufSize) -{ - hBitBuf->pBitBufBase = pBitBufBase; - hBitBuf->pBitBufEnd = pBitBufBase + bitBufSize - 1; - - - hBitBuf->pWriteNext = pBitBufBase; - - hBitBuf->wBitPos = 0; - hBitBuf->cntBits = 0; - - hBitBuf->cache = 0; -} - -/***************************************************************************** -* -* function name: CopyBitBuf -* description: copy Bit Buffer Management -* -*****************************************************************************/ -void CopyBitBuf(HANDLE_BIT_BUF hBitBufSrc, - HANDLE_BIT_BUF hBitBufDst) -{ - *hBitBufDst = *hBitBufSrc; -} - -/***************************************************************************** -* -* function name: GetBitsAvail -* description: get available bits -* -*****************************************************************************/ -Word16 GetBitsAvail(HANDLE_BIT_BUF hBitBuf) -{ - return hBitBuf->cntBits; -} - -/***************************************************************************** -* -* function name: WriteBits -* description: write bits to the buffer -* -*****************************************************************************/ -Word16 WriteBits(HANDLE_BIT_BUF hBitBuf, - UWord32 writeValue, - Word16 noBitsToWrite) -{ - Word16 wBitPos; - - assert(noBitsToWrite <= (Word16)sizeof(Word32)*8); - - if(noBitsToWrite == 0) - return noBitsToWrite; - - hBitBuf->cntBits += noBitsToWrite; - - wBitPos = hBitBuf->wBitPos; - wBitPos += noBitsToWrite; - writeValue &= ~(0xffffffff << noBitsToWrite); // Mask out everything except the lowest noBitsToWrite bits - writeValue <<= 32 - wBitPos; - writeValue |= hBitBuf->cache; - - while (wBitPos >= 8) - { - UWord8 tmp; - tmp = (UWord8)((writeValue >> 24) & 0xFF); - - *hBitBuf->pWriteNext++ = tmp; - writeValue <<= 8; - wBitPos -= 8; - } - - hBitBuf->wBitPos = wBitPos; - hBitBuf->cache = writeValue; - - return noBitsToWrite; -} diff --git a/android-aac-enc/jni/src/bitenc.c b/android-aac-enc/jni/src/bitenc.c deleted file mode 100644 index fcc12ddfc..000000000 --- a/android-aac-enc/jni/src/bitenc.c +++ /dev/null @@ -1,690 +0,0 @@ -/* - ** Copyright 2003-2010, VisualOn, Inc. - ** - ** Licensed under the Apache License, Version 2.0 (the "License"); - ** you may not use this file except in compliance with the License. - ** You may obtain a copy of the License at - ** - ** http://www.apache.org/licenses/LICENSE-2.0 - ** - ** Unless required by applicable law or agreed to in writing, software - ** distributed under the License is distributed on an "AS IS" BASIS, - ** WITHOUT 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: bitenc.c - - Content: Bitstream encoder functions - -*******************************************************************************/ - -#include "bitenc.h" -#include "bit_cnt.h" -#include "dyn_bits.h" -#include "qc_data.h" -#include "interface.h" - - -static const Word16 globalGainOffset = 100; -static const Word16 icsReservedBit = 0; - - -/***************************************************************************** -* -* function name: encodeSpectralData -* description: encode spectral data -* returns: spectral bits used -* -*****************************************************************************/ -static Word32 encodeSpectralData(Word16 *sfbOffset, - SECTION_DATA *sectionData, - Word16 *quantSpectrum, - HANDLE_BIT_BUF hBitStream) -{ - Word16 i,sfb; - Word16 dbgVal; - SECTION_INFO* psectioninfo; - dbgVal = GetBitsAvail(hBitStream); - - for(i=0; inoOfSections; i++) { - psectioninfo = &(sectionData->sectionInfo[i]); - /* - huffencode spectral data for this section - */ - for(sfb=psectioninfo->sfbStart; - sfbsfbStart+psectioninfo->sfbCnt; - sfb++) { - codeValues(quantSpectrum+sfbOffset[sfb], - sfbOffset[sfb+1] - sfbOffset[sfb], - psectioninfo->codeBook, - hBitStream); - } - } - - return(GetBitsAvail(hBitStream)-dbgVal); -} - -/***************************************************************************** -* -* function name:encodeGlobalGain -* description: encodes Global Gain (common scale factor) -* returns: none -* -*****************************************************************************/ -static void encodeGlobalGain(Word16 globalGain, - Word16 logNorm, - Word16 scalefac, - HANDLE_BIT_BUF hBitStream) -{ - WriteBits(hBitStream, ((globalGain - scalefac) + globalGainOffset-(logNorm << 2)), 8); -} - - -/***************************************************************************** -* -* function name:encodeIcsInfo -* description: encodes Ics Info -* returns: none -* -*****************************************************************************/ - -static void encodeIcsInfo(Word16 blockType, - Word16 windowShape, - Word16 groupingMask, - SECTION_DATA *sectionData, - HANDLE_BIT_BUF hBitStream) -{ - WriteBits(hBitStream,icsReservedBit,1); - WriteBits(hBitStream,blockType,2); - WriteBits(hBitStream,windowShape,1); - - - switch(blockType){ - case LONG_WINDOW: - case START_WINDOW: - case STOP_WINDOW: - WriteBits(hBitStream,sectionData->maxSfbPerGroup,6); - - /* No predictor data present */ - WriteBits(hBitStream, 0, 1); - break; - - case SHORT_WINDOW: - WriteBits(hBitStream,sectionData->maxSfbPerGroup,4); - - /* - Write grouping bits - */ - WriteBits(hBitStream,groupingMask,TRANS_FAC-1); - break; - } -} - -/***************************************************************************** -* -* function name: encodeSectionData -* description: encode section data (common Huffman codebooks for adjacent -* SFB's) -* returns: none -* -*****************************************************************************/ -static Word32 encodeSectionData(SECTION_DATA *sectionData, - HANDLE_BIT_BUF hBitStream) -{ - Word16 sectEscapeVal=0,sectLenBits=0; - Word16 sectLen; - Word16 i; - Word16 dbgVal=GetBitsAvail(hBitStream); - - - - switch(sectionData->blockType) - { - case LONG_WINDOW: - case START_WINDOW: - case STOP_WINDOW: - sectEscapeVal = SECT_ESC_VAL_LONG; - sectLenBits = SECT_BITS_LONG; - break; - - case SHORT_WINDOW: - sectEscapeVal = SECT_ESC_VAL_SHORT; - sectLenBits = SECT_BITS_SHORT; - break; - } - - for(i=0;inoOfSections;i++) { - WriteBits(hBitStream,sectionData->sectionInfo[i].codeBook,4); - sectLen = sectionData->sectionInfo[i].sfbCnt; - - while(sectLen >= sectEscapeVal) { - - WriteBits(hBitStream,sectEscapeVal,sectLenBits); - sectLen = sectLen - sectEscapeVal; - } - WriteBits(hBitStream,sectLen,sectLenBits); - } - return(GetBitsAvail(hBitStream)-dbgVal); -} - -/***************************************************************************** -* -* function name: encodeScaleFactorData -* description: encode DPCM coded scale factors -* returns: none -* -*****************************************************************************/ -static Word32 encodeScaleFactorData(UWord16 *maxValueInSfb, - SECTION_DATA *sectionData, - Word16 *scalefac, - HANDLE_BIT_BUF hBitStream) -{ - Word16 i,j,lastValScf,deltaScf; - Word16 dbgVal = GetBitsAvail(hBitStream); - SECTION_INFO* psectioninfo; - - lastValScf=scalefac[sectionData->firstScf]; - - for(i=0;inoOfSections;i++){ - psectioninfo = &(sectionData->sectionInfo[i]); - if (psectioninfo->codeBook != CODE_BOOK_ZERO_NO){ - for (j=psectioninfo->sfbStart; - jsfbStart+psectioninfo->sfbCnt; j++){ - - if(maxValueInSfb[j] == 0) { - deltaScf = 0; - } - else { - deltaScf = lastValScf - scalefac[j]; - lastValScf = scalefac[j]; - } - - if(codeScalefactorDelta(deltaScf,hBitStream)){ - return(1); - } - } - } - - } - return(GetBitsAvail(hBitStream)-dbgVal); -} - -/***************************************************************************** -* -* function name:encodeMsInfo -* description: encodes MS-Stereo Info -* returns: none -* -*****************************************************************************/ -static void encodeMSInfo(Word16 sfbCnt, - Word16 grpSfb, - Word16 maxSfb, - Word16 msDigest, - Word16 *jsFlags, - HANDLE_BIT_BUF hBitStream) -{ - Word16 sfb, sfbOff; - - - switch(msDigest) - { - case MS_NONE: - WriteBits(hBitStream,SI_MS_MASK_NONE,2); - break; - - case MS_ALL: - WriteBits(hBitStream,SI_MS_MASK_ALL,2); - break; - - case MS_SOME: - WriteBits(hBitStream,SI_MS_MASK_SOME,2); - for(sfbOff = 0; sfbOff < sfbCnt; sfbOff+=grpSfb) { - for(sfb=0; sfb 3 || - tnsInfo.coef[i*TNS_MAX_ORDER_SHORT+k] < -4) { - coefBits = 4; - break; - } - } - } - else { - coefBits = 2; - for(k=0; k 1 || - tnsInfo.coef[i*TNS_MAX_ORDER_SHORT+k] < -2) { - coefBits = 3; - break; - } - } - } - WriteBits(hBitStream, tnsInfo.coefRes[i] - coefBits, 1); /*coef_compres*/ - for (k=0; kfirstScf], hBitStream); - - - if(!commonWindow) { - encodeIcsInfo(sectionData->blockType, windowShape, groupingMask, sectionData, hBitStream); - } - - encodeSectionData(sectionData, hBitStream); - - encodeScaleFactorData(maxValueInSfb, - sectionData, - scf, - hBitStream); - - encodePulseData(hBitStream); - - encodeTnsData(tnsInfo, sectionData->blockType, hBitStream); - - encodeGainControlData(hBitStream); - - encodeSpectralData(sfbOffset, - sectionData, - quantSpec, - hBitStream); - -} - -/***************************************************************************** -* -* function name: writeSingleChannelElement -* description: write single channel element to bitstream -* returns: none -* -*****************************************************************************/ -static Word16 writeSingleChannelElement(Word16 instanceTag, - Word16 *sfbOffset, - QC_OUT_CHANNEL* qcOutChannel, - HANDLE_BIT_BUF hBitStream, - TNS_INFO tnsInfo) -{ - WriteBits(hBitStream,ID_SCE,3); - WriteBits(hBitStream,instanceTag,4); - writeIndividualChannelStream(0, - qcOutChannel->mdctScale, - qcOutChannel->windowShape, - qcOutChannel->groupingMask, - sfbOffset, - qcOutChannel->scf, - qcOutChannel->maxValueInSfb, - qcOutChannel->globalGain, - qcOutChannel->quantSpec, - &(qcOutChannel->sectionData), - hBitStream, - tnsInfo - ); - return(0); -} - - - -/***************************************************************************** -* -* function name: writeChannelPairElement -* description: -* returns: none -* -*****************************************************************************/ -static Word16 writeChannelPairElement(Word16 instanceTag, - Word16 msDigest, - Word16 msFlags[MAX_GROUPED_SFB], - Word16 *sfbOffset[2], - QC_OUT_CHANNEL qcOutChannel[2], - HANDLE_BIT_BUF hBitStream, - TNS_INFO tnsInfo[2]) -{ - WriteBits(hBitStream,ID_CPE,3); - WriteBits(hBitStream,instanceTag,4); - WriteBits(hBitStream,1,1); /* common window */ - - encodeIcsInfo(qcOutChannel[0].sectionData.blockType, - qcOutChannel[0].windowShape, - qcOutChannel[0].groupingMask, - &(qcOutChannel[0].sectionData), - hBitStream); - - encodeMSInfo(qcOutChannel[0].sectionData.sfbCnt, - qcOutChannel[0].sectionData.sfbPerGroup, - qcOutChannel[0].sectionData.maxSfbPerGroup, - msDigest, - msFlags, - hBitStream); - - writeIndividualChannelStream(1, - qcOutChannel[0].mdctScale, - qcOutChannel[0].windowShape, - qcOutChannel[0].groupingMask, - sfbOffset[0], - qcOutChannel[0].scf, - qcOutChannel[0].maxValueInSfb, - qcOutChannel[0].globalGain, - qcOutChannel[0].quantSpec, - &(qcOutChannel[0].sectionData), - hBitStream, - tnsInfo[0]); - - writeIndividualChannelStream(1, - qcOutChannel[1].mdctScale, - qcOutChannel[1].windowShape, - qcOutChannel[1].groupingMask, - sfbOffset[1], - qcOutChannel[1].scf, - qcOutChannel[1].maxValueInSfb, - qcOutChannel[1].globalGain, - qcOutChannel[1].quantSpec, - &(qcOutChannel[1].sectionData), - hBitStream, - tnsInfo[1]); - - return(0); -} - - - -/***************************************************************************** -* -* function name: writeFillElement -* description: write fill elements to bitstream -* returns: none -* -*****************************************************************************/ -static void writeFillElement( const UWord8 *ancBytes, - Word16 totFillBits, - HANDLE_BIT_BUF hBitStream) -{ - Word16 i; - Word16 cnt,esc_count; - - /* - Write fill Element(s): - amount of a fill element can be 7+X*8 Bits, X element of [0..270] - */ - - while(totFillBits >= (3+4)) { - cnt = min(((totFillBits - (3+4)) >> 3), ((1<<4)-1)); - - WriteBits(hBitStream,ID_FIL,3); - WriteBits(hBitStream,cnt,4); - - totFillBits = totFillBits - (3+4); - - - if ((cnt == (1<<4)-1)) { - - esc_count = min( ((totFillBits >> 3) - ((1<<4)-1)), (1<<8)-1); - WriteBits(hBitStream,esc_count,8); - totFillBits = (totFillBits - 8); - cnt = cnt + (esc_count - 1); - } - - for(i=0;iqcElement.adtsUsed) /* write adts header*/ - { - WriteBits(hBitStream, 0xFFF, 12); /* 12 bit Syncword */ - WriteBits(hBitStream, 1, 1); /* ID == 0 for MPEG4 AAC, 1 for MPEG2 AAC */ - WriteBits(hBitStream, 0, 2); /* layer == 0 */ - WriteBits(hBitStream, 1, 1); /* protection absent */ - WriteBits(hBitStream, 1, 2); /* profile */ - WriteBits(hBitStream, sampindex, 4); /* sampling rate */ - WriteBits(hBitStream, 0, 1); /* private bit */ - WriteBits(hBitStream, elInfo.nChannelsInEl, 3); /* ch. config (must be > 0) */ - /* simply using numChannels only works for - 6 channels or less, else a channel - configuration should be written */ - WriteBits(hBitStream, 0, 1); /* original/copy */ - WriteBits(hBitStream, 0, 1); /* home */ - - /* Variable ADTS header */ - WriteBits(hBitStream, 0, 1); /* copyr. id. bit */ - WriteBits(hBitStream, 0, 1); /* copyr. id. start */ - WriteBits(hBitStream, *globUsedBits >> 3, 13); - WriteBits(hBitStream, 0x7FF, 11); /* buffer fullness (0x7FF for VBR) */ - WriteBits(hBitStream, 0, 2); /* raw data blocks (0+1=1) */ - } - - *globUsedBits=0; - - { - - Word16 *sfbOffset[2]; - TNS_INFO tnsInfo[2]; - elementUsedBits = 0; - - switch (elInfo.elType) { - - case ID_SCE: /* single channel */ - sfbOffset[0] = psyOut->psyOutChannel[elInfo.ChannelIndex[0]].sfbOffsets; - tnsInfo[0] = psyOut->psyOutChannel[elInfo.ChannelIndex[0]].tnsInfo; - - writeSingleChannelElement(elInfo.instanceTag, - sfbOffset[0], - &qcOut->qcChannel[elInfo.ChannelIndex[0]], - hBitStream, - tnsInfo[0]); - break; - - case ID_CPE: /* channel pair */ - { - Word16 msDigest; - Word16 *msFlags = psyOut->psyOutElement.toolsInfo.msMask; - msDigest = psyOut->psyOutElement.toolsInfo.msDigest; - sfbOffset[0] = - psyOut->psyOutChannel[elInfo.ChannelIndex[0]].sfbOffsets; - sfbOffset[1] = - psyOut->psyOutChannel[elInfo.ChannelIndex[1]].sfbOffsets; - - tnsInfo[0]= - psyOut->psyOutChannel[elInfo.ChannelIndex[0]].tnsInfo; - tnsInfo[1]= - psyOut->psyOutChannel[elInfo.ChannelIndex[1]].tnsInfo; - writeChannelPairElement(elInfo.instanceTag, - msDigest, - msFlags, - sfbOffset, - &qcOut->qcChannel[elInfo.ChannelIndex[0]], - hBitStream, - tnsInfo); - } - break; - - default: - return(1); - - } /* switch */ - - elementUsedBits = elementUsedBits - bitMarkUp; - bitMarkUp = GetBitsAvail(hBitStream); - frameBits = frameBits + elementUsedBits + bitMarkUp; - - } - - writeFillElement(NULL, - qcOut->totFillBits, - hBitStream); - - WriteBits(hBitStream,ID_END,3); - - /* byte alignement */ - WriteBits(hBitStream,0, (8 - (hBitStream->cntBits & 7)) & 7); - - *globUsedBits = *globUsedBits- bitMarkUp; - bitMarkUp = GetBitsAvail(hBitStream); - *globUsedBits = *globUsedBits + bitMarkUp; - frameBits = frameBits + *globUsedBits; - - - if (frameBits != (qcOut->totStaticBitsUsed+qcOut->totDynBitsUsed + qcOut->totAncBitsUsed + - qcOut->totFillBits + qcOut->alignBits)) { - return(-1); - } - return(0); -} diff --git a/android-aac-enc/jni/src/block_switch.c b/android-aac-enc/jni/src/block_switch.c deleted file mode 100644 index 47fd15e71..000000000 --- a/android-aac-enc/jni/src/block_switch.c +++ /dev/null @@ -1,431 +0,0 @@ -/* - ** Copyright 2003-2010, VisualOn, Inc. - ** - ** Licensed under the Apache License, Version 2.0 (the "License"); - ** you may not use this file except in compliance with the License. - ** You may obtain a copy of the License at - ** - ** http://www.apache.org/licenses/LICENSE-2.0 - ** - ** Unless required by applicable law or agreed to in writing, software - ** distributed under the License is distributed on an "AS IS" BASIS, - ** WITHOUT 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: block_switch.c - - Content: Block switching functions - -*******************************************************************************/ - -#include "typedef.h" -#include "basic_op.h" -#include "oper_32b.h" -#include "psy_const.h" -#include "block_switch.h" - - -#define ENERGY_SHIFT (8 - 1) - -/**************** internal function prototypes ***********/ -static Word16 -IIRFilter(const Word16 in, const Word32 coeff[], Word32 states[]); - -static Word32 -SrchMaxWithIndex(const Word32 *in, Word16 *index, Word16 n); - - -Word32 -CalcWindowEnergy(BLOCK_SWITCHING_CONTROL *blockSwitchingControl, - Word16 *timeSignal, - Word16 chIncrement, - Word16 windowLen); - - - -/****************** Constants *****************************/ - - -/* - IIR high pass coeffs -*/ -Word32 hiPassCoeff[BLOCK_SWITCHING_IIR_LEN] = { - 0xbec8b439, 0x609d4952 /* -0.5095f, 0.7548f */ -}; - -static const Word32 accWindowNrgFac = 0x26666666; /* factor for accumulating filtered window energies 0.3 */ -static const Word32 oneMinusAccWindowNrgFac = 0x5999999a; /* 0.7 */ -static const Word32 invAttackRatioHighBr = 0x0ccccccd; /* inverted lower ratio limit for attacks 0.1*/ -static const Word32 invAttackRatioLowBr = 0x072b020c; /* 0.056 */ -static const Word32 minAttackNrg = 0x00001e84; /* minimum energy for attacks 1e+6 */ - - -/****************** Routines ****************************/ - - -/***************************************************************************** -* -* function name: InitBlockSwitching -* description: init Block Switching parameter. -* returns: TRUE if success -* -**********************************************************************************/ -Word16 InitBlockSwitching(BLOCK_SWITCHING_CONTROL *blockSwitchingControl, - const Word32 bitRate, const Word16 nChannels) -{ - /* select attackRatio */ - - if ((sub(nChannels,1)==0 && L_sub(bitRate, 24000) > 0) || - (sub(nChannels,1)>0 && bitRate > (nChannels * 16000))) { - blockSwitchingControl->invAttackRatio = invAttackRatioHighBr; - } - else { - blockSwitchingControl->invAttackRatio = invAttackRatioLowBr; - } - - return(TRUE); -} - -static Word16 suggestedGroupingTable[TRANS_FAC][MAX_NO_OF_GROUPS] = { - /* Attack in Window 0 */ {1, 3, 3, 1}, - /* Attack in Window 1 */ {1, 1, 3, 3}, - /* Attack in Window 2 */ {2, 1, 3, 2}, - /* Attack in Window 3 */ {3, 1, 3, 1}, - /* Attack in Window 4 */ {3, 1, 1, 3}, - /* Attack in Window 5 */ {3, 2, 1, 2}, - /* Attack in Window 6 */ {3, 3, 1, 1}, - /* Attack in Window 7 */ {3, 3, 1, 1} -}; - -/***************************************************************************** -* -* function name: BlockSwitching -* description: detect this frame whether there is an attack -* returns: TRUE if success -* -**********************************************************************************/ -Word16 BlockSwitching(BLOCK_SWITCHING_CONTROL *blockSwitchingControl, - Word16 *timeSignal, - Word32 sampleRate, - Word16 chIncrement) -{ - Word32 i, w; - Word32 enM1, enMax; - - /* Reset grouping info */ - for (i=0; igroupLen[i] = 0; - } - - - /* Search for position and amplitude of attack in last frame (1 windows delay) */ - blockSwitchingControl->maxWindowNrg = SrchMaxWithIndex( &blockSwitchingControl->windowNrg[0][BLOCK_SWITCH_WINDOWS-1], - &blockSwitchingControl->attackIndex, - BLOCK_SWITCH_WINDOWS); - - blockSwitchingControl->attackIndex = blockSwitchingControl->lastAttackIndex; - - /* Set grouping info */ - blockSwitchingControl->noOfGroups = MAX_NO_OF_GROUPS; - - for (i=0; igroupLen[i] = suggestedGroupingTable[blockSwitchingControl->attackIndex][i]; - } - - /* if the samplerate is less than 16000, it should be all the short block, avoid pre&post echo */ - if(sampleRate >= 16000) { - /* Save current window energy as last window energy */ - for (w=0; wwindowNrg[0][w] = blockSwitchingControl->windowNrg[1][w]; - blockSwitchingControl->windowNrgF[0][w] = blockSwitchingControl->windowNrgF[1][w]; - } - - - /* Calculate unfiltered and filtered energies in subwindows and combine to segments */ - CalcWindowEnergy(blockSwitchingControl, timeSignal, chIncrement, BLOCK_SWITCH_WINDOW_LEN); - - /* reset attack */ - blockSwitchingControl->attack = FALSE; - - enMax = 0; - enM1 = blockSwitchingControl->windowNrgF[0][BLOCK_SWITCH_WINDOWS-1]; - - for (w=0; waccWindowNrg); - enM1_Shf = norm_l(enM1); - windowNrgF_Shf = norm_l(blockSwitchingControl->windowNrgF[1][w]); - - accWindowNrg_Tmp = blockSwitchingControl->accWindowNrg << accWindowNrg_Shf; - enM1_Tmp = enM1 << enM1_Shf; - windowNrgF_Tmp = blockSwitchingControl->windowNrgF[1][w] << windowNrgF_Shf; - - /* a sliding average of the previous energies */ - blockSwitchingControl->accWindowNrg = (fixmul(oneMinusAccWindowNrgFac, accWindowNrg_Tmp) >> accWindowNrg_Shf) + - (fixmul(accWindowNrgFac, enM1_Tmp) >> enM1_Shf); - - - /* if the energy with the ratio is bigger than the average, and the attack and short block */ - if ((fixmul(windowNrgF_Tmp, blockSwitchingControl->invAttackRatio) >> windowNrgF_Shf) > - blockSwitchingControl->accWindowNrg ) { - blockSwitchingControl->attack = TRUE; - blockSwitchingControl->lastAttackIndex = w; - } - enM1 = blockSwitchingControl->windowNrgF[1][w]; - enMax = max(enMax, enM1); - } - - if (enMax < minAttackNrg) { - blockSwitchingControl->attack = FALSE; - } - } - else - { - blockSwitchingControl->attack = TRUE; - } - - /* Check if attack spreads over frame border */ - if ((!blockSwitchingControl->attack) && (blockSwitchingControl->lastattack)) { - - if (blockSwitchingControl->attackIndex == TRANS_FAC-1) { - blockSwitchingControl->attack = TRUE; - } - - blockSwitchingControl->lastattack = FALSE; - } - else { - blockSwitchingControl->lastattack = blockSwitchingControl->attack; - } - - blockSwitchingControl->windowSequence = blockSwitchingControl->nextwindowSequence; - - - if (blockSwitchingControl->attack) { - blockSwitchingControl->nextwindowSequence = SHORT_WINDOW; - } - else { - blockSwitchingControl->nextwindowSequence = LONG_WINDOW; - } - - /* update short block group */ - if (blockSwitchingControl->nextwindowSequence == SHORT_WINDOW) { - - if (blockSwitchingControl->windowSequence== LONG_WINDOW) { - blockSwitchingControl->windowSequence = START_WINDOW; - } - - if (blockSwitchingControl->windowSequence == STOP_WINDOW) { - blockSwitchingControl->windowSequence = SHORT_WINDOW; - blockSwitchingControl->noOfGroups = 3; - blockSwitchingControl->groupLen[0] = 3; - blockSwitchingControl->groupLen[1] = 3; - blockSwitchingControl->groupLen[2] = 2; - } - } - - /* update block type */ - if (blockSwitchingControl->nextwindowSequence == LONG_WINDOW) { - - if (blockSwitchingControl->windowSequence == SHORT_WINDOW) { - blockSwitchingControl->nextwindowSequence = STOP_WINDOW; - } - } - - return(TRUE); -} - - -/***************************************************************************** -* -* function name: SrchMaxWithIndex -* description: search for the biggest value in an array -* returns: the max value -* -**********************************************************************************/ -static Word32 SrchMaxWithIndex(const Word32 in[], Word16 *index, Word16 n) -{ - Word32 max; - Word32 i, idx; - - /* Search maximum value in array and return index and value */ - max = 0; - idx = 0; - - for (i = 0; i < n; i++) { - - if (in[i+1] > max) { - max = in[i+1]; - idx = i; - } - } - *index = idx; - - return(max); -} - -/***************************************************************************** -* -* function name: CalcWindowEnergy -* description: calculate the energy before iir-filter and after irr-filter -* returns: TRUE if success -* -**********************************************************************************/ -#ifndef ARMV5E -Word32 CalcWindowEnergy(BLOCK_SWITCHING_CONTROL *blockSwitchingControl, - Word16 *timeSignal, - Word16 chIncrement, - Word16 windowLen) -{ - Word32 w, i, wOffset, tidx, ch; - Word32 accuUE, accuFE; - Word32 tempUnfiltered; - Word32 tempFiltered; - Word32 states0, states1; - Word32 Coeff0, Coeff1; - - - states0 = blockSwitchingControl->iirStates[0]; - states1 = blockSwitchingControl->iirStates[1]; - Coeff0 = hiPassCoeff[0]; - Coeff1 = hiPassCoeff[1]; - tidx = 0; - for (w=0; w < BLOCK_SWITCH_WINDOWS; w++) { - - accuUE = 0; - accuFE = 0; - - for(i=0; i> ENERGY_SHIFT; - accuFE += (tempFiltered * tempFiltered) >> ENERGY_SHIFT; - } - - blockSwitchingControl->windowNrg[1][w] = accuUE; - blockSwitchingControl->windowNrgF[1][w] = accuFE; - - } - - blockSwitchingControl->iirStates[0] = states0; - blockSwitchingControl->iirStates[1] = states1; - - return(TRUE); -} -#endif - -/***************************************************************************** -* -* function name: IIRFilter -* description: calculate the iir-filter for an array -* returns: the result after iir-filter -* -**********************************************************************************/ -static Word16 IIRFilter(const Word16 in, const Word32 coeff[], Word32 states[]) -{ - Word32 accu1, accu2, accu3; - Word32 out; - - accu1 = L_mpy_ls(coeff[1], in); - accu3 = accu1 - states[0]; - accu2 = fixmul( coeff[0], states[1] ); - out = accu3 - accu2; - - states[0] = accu1; - states[1] = out; - - return round16(out); -} - - -static Word16 synchronizedBlockTypeTable[4][4] = { - /* LONG_WINDOW START_WINDOW SHORT_WINDOW STOP_WINDOW */ - /* LONG_WINDOW */{LONG_WINDOW, START_WINDOW, SHORT_WINDOW, STOP_WINDOW}, - /* START_WINDOW */{START_WINDOW, START_WINDOW, SHORT_WINDOW, SHORT_WINDOW}, - /* SHORT_WINDOW */{SHORT_WINDOW, SHORT_WINDOW, SHORT_WINDOW, SHORT_WINDOW}, - /* STOP_WINDOW */{STOP_WINDOW, SHORT_WINDOW, SHORT_WINDOW, STOP_WINDOW} -}; - - -/***************************************************************************** -* -* function name: SyncBlockSwitching -* description: update block type and group value -* returns: TRUE if success -* -**********************************************************************************/ -Word16 SyncBlockSwitching(BLOCK_SWITCHING_CONTROL *blockSwitchingControlLeft, - BLOCK_SWITCHING_CONTROL *blockSwitchingControlRight, - const Word16 nChannels) -{ - Word16 i; - Word16 patchType = LONG_WINDOW; - - - if (nChannels == 1) { /* Mono */ - if (blockSwitchingControlLeft->windowSequence != SHORT_WINDOW) { - blockSwitchingControlLeft->noOfGroups = 1; - blockSwitchingControlLeft->groupLen[0] = 1; - - for (i=1; igroupLen[i] = 0; - } - } - } - else { /* Stereo common Window */ - patchType = synchronizedBlockTypeTable[patchType][blockSwitchingControlLeft->windowSequence]; - patchType = synchronizedBlockTypeTable[patchType][blockSwitchingControlRight->windowSequence]; - - /* Set synchronized Blocktype */ - blockSwitchingControlLeft->windowSequence = patchType; - blockSwitchingControlRight->windowSequence = patchType; - - /* Synchronize grouping info */ - if(patchType != SHORT_WINDOW) { /* Long Blocks */ - /* Set grouping info */ - blockSwitchingControlLeft->noOfGroups = 1; - blockSwitchingControlRight->noOfGroups = 1; - blockSwitchingControlLeft->groupLen[0] = 1; - blockSwitchingControlRight->groupLen[0] = 1; - - for (i=1; igroupLen[i] = 0; - blockSwitchingControlRight->groupLen[i] = 0; - } - } - else { - - if (blockSwitchingControlLeft->maxWindowNrg > blockSwitchingControlRight->maxWindowNrg) { - /* Left Channel wins */ - blockSwitchingControlRight->noOfGroups = blockSwitchingControlLeft->noOfGroups; - for (i=0; igroupLen[i] = blockSwitchingControlLeft->groupLen[i]; - } - } - else { - /* Right Channel wins */ - blockSwitchingControlLeft->noOfGroups = blockSwitchingControlRight->noOfGroups; - for (i=0; igroupLen[i] = blockSwitchingControlRight->groupLen[i]; - } - } - } - } /*endif Mono or Stereo */ - - return(TRUE); -} diff --git a/android-aac-enc/jni/src/channel_map.c b/android-aac-enc/jni/src/channel_map.c deleted file mode 100644 index f6552ed42..000000000 --- a/android-aac-enc/jni/src/channel_map.c +++ /dev/null @@ -1,123 +0,0 @@ -/* - ** Copyright 2003-2010, VisualOn, Inc. - ** - ** Licensed under the Apache License, Version 2.0 (the "License"); - ** you may not use this file except in compliance with the License. - ** You may obtain a copy of the License at - ** - ** http://www.apache.org/licenses/LICENSE-2.0 - ** - ** Unless required by applicable law or agreed to in writing, software - ** distributed under the License is distributed on an "AS IS" BASIS, - ** WITHOUT 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: channel_map.c - - Content: channel mapping functions - -*******************************************************************************/ - -#include "channel_map.h" -#include "bitenc.h" -#include "psy_const.h" -#include "qc_data.h" - -static const Word16 maxChannelBits = MAXBITS_COEF; - -static Word16 initElement(ELEMENT_INFO* elInfo, ELEMENT_TYPE elType) -{ - Word16 error=0; - - elInfo->elType=elType; - - switch(elInfo->elType) { - - case ID_SCE: - elInfo->nChannelsInEl=1; - - elInfo->ChannelIndex[0]=0; - - elInfo->instanceTag=0; - break; - - case ID_CPE: - - elInfo->nChannelsInEl=2; - - elInfo->ChannelIndex[0]=0; - elInfo->ChannelIndex[1]=1; - - elInfo->instanceTag=0; - break; - - default: - error=1; - } - - return error; -} - - -Word16 InitElementInfo (Word16 nChannels, ELEMENT_INFO* elInfo) -{ - Word16 error; - error = 0; - - switch(nChannels) { - - case 1: - initElement(elInfo, ID_SCE); - break; - - case 2: - initElement(elInfo, ID_CPE); - break; - - default: - error=4; - } - - return error; -} - - -Word16 InitElementBits(ELEMENT_BITS *elementBits, - ELEMENT_INFO elInfo, - Word32 bitrateTot, - Word16 averageBitsTot, - Word16 staticBitsTot) -{ - Word16 error; - error = 0; - - switch(elInfo.nChannelsInEl) { - case 1: - elementBits->chBitrate = bitrateTot; - elementBits->averageBits = averageBitsTot - staticBitsTot; - elementBits->maxBits = maxChannelBits; - - elementBits->maxBitResBits = maxChannelBits - averageBitsTot; - elementBits->maxBitResBits = elementBits->maxBitResBits - (elementBits->maxBitResBits & 7); - elementBits->bitResLevel = elementBits->maxBitResBits; - elementBits->relativeBits = 0x4000; /* 1.0f/2 */ - break; - - case 2: - elementBits->chBitrate = bitrateTot >> 1; - elementBits->averageBits = averageBitsTot - staticBitsTot; - elementBits->maxBits = maxChannelBits << 1; - - elementBits->maxBitResBits = (maxChannelBits << 1) - averageBitsTot; - elementBits->maxBitResBits = elementBits->maxBitResBits - (elementBits->maxBitResBits & 7); - elementBits->bitResLevel = elementBits->maxBitResBits; - elementBits->relativeBits = 0x4000; /* 1.0f/2 */ - break; - - default: - error = 1; - } - return error; -} diff --git a/android-aac-enc/jni/src/cmnMemory.c b/android-aac-enc/jni/src/cmnMemory.c deleted file mode 100644 index aa52bd98f..000000000 --- a/android-aac-enc/jni/src/cmnMemory.c +++ /dev/null @@ -1,71 +0,0 @@ -/* - ** Copyright 2003-2010, VisualOn, Inc. - ** - ** Licensed under the Apache License, Version 2.0 (the "License"); - ** you may not use this file except in compliance with the License. - ** You may obtain a copy of the License at - ** - ** http://www.apache.org/licenses/LICENSE-2.0 - ** - ** Unless required by applicable law or agreed to in writing, software - ** distributed under the License is distributed on an "AS IS" BASIS, - ** WITHOUT 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: cmnMemory.c - - Content: sample code for memory operator implementation - -*******************************************************************************/ -#include "cmnMemory.h" - -#include -#include - -//VO_MEM_OPERATOR g_memOP; - -VO_U32 cmnMemAlloc (VO_S32 uID, VO_MEM_INFO * pMemInfo) -{ - if (!pMemInfo) - return VO_ERR_INVALID_ARG; - - pMemInfo->VBuffer = malloc (pMemInfo->Size); - return 0; -} - -VO_U32 cmnMemFree (VO_S32 uID, VO_PTR pMem) -{ - free (pMem); - return 0; -} - -VO_U32 cmnMemSet (VO_S32 uID, VO_PTR pBuff, VO_U8 uValue, VO_U32 uSize) -{ - memset (pBuff, uValue, uSize); - return 0; -} - -VO_U32 cmnMemCopy (VO_S32 uID, VO_PTR pDest, VO_PTR pSource, VO_U32 uSize) -{ - memcpy (pDest, pSource, uSize); - return 0; -} - -VO_U32 cmnMemCheck (VO_S32 uID, VO_PTR pBuffer, VO_U32 uSize) -{ - return 0; -} - -VO_S32 cmnMemCompare (VO_S32 uID, VO_PTR pBuffer1, VO_PTR pBuffer2, VO_U32 uSize) -{ - return memcmp(pBuffer1, pBuffer2, uSize); -} - -VO_U32 cmnMemMove (VO_S32 uID, VO_PTR pDest, VO_PTR pSource, VO_U32 uSize) -{ - memmove (pDest, pSource, uSize); - return 0; -} - diff --git a/android-aac-enc/jni/src/dyn_bits.c b/android-aac-enc/jni/src/dyn_bits.c deleted file mode 100644 index 77691884d..000000000 --- a/android-aac-enc/jni/src/dyn_bits.c +++ /dev/null @@ -1,545 +0,0 @@ -/* - ** Copyright 2003-2010, VisualOn, Inc. - ** - ** Licensed under the Apache License, Version 2.0 (the "License"); - ** you may not use this file except in compliance with the License. - ** You may obtain a copy of the License at - ** - ** http://www.apache.org/licenses/LICENSE-2.0 - ** - ** Unless required by applicable law or agreed to in writing, software - ** distributed under the License is distributed on an "AS IS" BASIS, - ** WITHOUT 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: dyn_bits.c - - Content: Noiseless coder module functions - -*******************************************************************************/ - -#include "aac_rom.h" -#include "dyn_bits.h" -#include "bit_cnt.h" -#include "psy_const.h" - - -/***************************************************************************** -* -* function name: buildBitLookUp -* description: count bits using all possible tables -* -*****************************************************************************/ -static void -buildBitLookUp(const Word16 *quantSpectrum, - const Word16 maxSfb, - const Word16 *sfbOffset, - const UWord16 *sfbMax, - Word16 bitLookUp[MAX_SFB_LONG][CODE_BOOK_ESC_NDX + 1], - SECTION_INFO * sectionInfo) -{ - Word32 i; - - for (i=0; i maxMergeGain) { - maxMergeGain = mergeGainLookUp[i]; - *maxNdx = i; - } - } - return extract_l(maxMergeGain); -} - - - -static Word16 -CalcMergeGain(const SECTION_INFO *sectionInfo, - Word16 bitLookUp[MAX_SFB_LONG][CODE_BOOK_ESC_NDX + 1], - const Word16 *sideInfoTab, - const Word16 ndx1, - const Word16 ndx2) -{ - Word32 SplitBits; - Word32 MergeBits; - Word32 MergeGain; - - /* - Bit amount for splitted sections - */ - SplitBits = sectionInfo[ndx1].sectionBits + sectionInfo[ndx2].sectionBits; - - MergeBits = sideInfoTab[sectionInfo[ndx1].sfbCnt + sectionInfo[ndx2].sfbCnt] + - findMinMergeBits(bitLookUp[ndx1], bitLookUp[ndx2]); - MergeGain = (SplitBits - MergeBits); - - return extract_l(MergeGain); -} - -/* - sectioning Stage 0:find minimum codbooks -*/ - -static void -gmStage0(SECTION_INFO * sectionInfo, - Word16 bitLookUp[MAX_SFB_LONG][CODE_BOOK_ESC_NDX + 1], - const Word16 maxSfb) -{ - Word32 i; - - for (i=0; icodeBook != sectionInfo_e->codeBook) - break; - sectionInfo_s->sfbCnt += 1; - sectionInfo_s->sectionBits += sectionInfo_e->sectionBits; - - mergeBitLookUp(bitLookUp[mergeStart], bitLookUp[mergeEnd]); - } - - sectionInfo_s->sectionBits += sideInfoTab[sectionInfo_s->sfbCnt]; - sectionInfo[mergeEnd - 1].sfbStart = sectionInfo_s->sfbStart; /* speed up prev search */ - - mergeStart = mergeEnd; - - - } while (mergeStart - maxSfb < 0); -} - -/* - sectioning Stage 2:greedy merge algorithm, merge connected sections with - maximum bit gain until no more gain is possible -*/ -static void -gmStage2(SECTION_INFO *sectionInfo, - Word16 mergeGainLookUp[MAX_SFB_LONG], - Word16 bitLookUp[MAX_SFB_LONG][CODE_BOOK_ESC_NDX + 1], - const Word16 maxSfb, - const Word16 *sideInfoTab) -{ - Word16 i; - - for (i=0; i+sectionInfo[i].sfbCntnoOfSections = 0; - sectionData->huffmanBits = 0; - sectionData->sideInfoBits = 0; - - - if (sectionData->maxSfbPerGroup == 0) - return; - - /* - loop trough groups - */ - for (grpNdx=0; grpNdxsfbCnt; grpNdx+=sectionData->sfbPerGroup) { - - sectionInfo = sectionData->sectionInfo + sectionData->noOfSections; - - buildBitLookUp(quantSpectrum, - sectionData->maxSfbPerGroup, - sfbOffset + grpNdx, - maxValueInSfb + grpNdx, - bitLookUp, - sectionInfo); - - /* - 0.Stage - */ - gmStage0(sectionInfo, bitLookUp, sectionData->maxSfbPerGroup); - - /* - 1.Stage - */ - gmStage1(sectionInfo, bitLookUp, sectionData->maxSfbPerGroup, sideInfoTab); - - - /* - 2.Stage - */ - gmStage2(sectionInfo, - mergeGainLookUp, - bitLookUp, - sectionData->maxSfbPerGroup, - sideInfoTab); - - - /* - compress output, calculate total huff and side bits - */ - for (i=0; imaxSfbPerGroup; i+=sectionInfo[i].sfbCnt) { - findBestBook(bitLookUp[i], &(sectionInfo[i].codeBook)); - sectionInfo[i].sfbStart = sectionInfo[i].sfbStart + grpNdx; - - sectionData->huffmanBits = (sectionData->huffmanBits + - (sectionInfo[i].sectionBits - sideInfoTab[sectionInfo[i].sfbCnt])); - sectionData->sideInfoBits = (sectionData->sideInfoBits + sideInfoTab[sectionInfo[i].sfbCnt]); - sectionData->sectionInfo[sectionData->noOfSections] = sectionInfo[i]; - sectionData->noOfSections = sectionData->noOfSections + 1; - } - } -} - - -/******************************************************************************* -* -* functionname: scfCount -* returns : --- -* description : count bits used by scalefactors. -* -********************************************************************************/ -static void scfCount(const Word16 *scalefacGain, - const UWord16 *maxValueInSfb, - SECTION_DATA * sectionData) - -{ - SECTION_INFO *psectionInfo; - SECTION_INFO *psectionInfom; - - /* counter */ - Word32 i = 0; /* section counter */ - Word32 j = 0; /* sfb counter */ - Word32 k = 0; /* current section auxiliary counter */ - Word32 m = 0; /* other section auxiliary counter */ - Word32 n = 0; /* other sfb auxiliary counter */ - - /* further variables */ - Word32 lastValScf = 0; - Word32 deltaScf = 0; - Flag found = 0; - Word32 scfSkipCounter = 0; - - - sectionData->scalefacBits = 0; - - - if (scalefacGain == NULL) { - return; - } - - lastValScf = 0; - sectionData->firstScf = 0; - - psectionInfo = sectionData->sectionInfo; - for (i=0; inoOfSections; i++) { - - if (psectionInfo->codeBook != CODE_BOOK_ZERO_NO) { - sectionData->firstScf = psectionInfo->sfbStart; - lastValScf = scalefacGain[sectionData->firstScf]; - break; - } - psectionInfo += 1; - } - - psectionInfo = sectionData->sectionInfo; - for (i=0; inoOfSections; i++, psectionInfo += 1) { - - if (psectionInfo->codeBook != CODE_BOOK_ZERO_NO - && psectionInfo->codeBook != CODE_BOOK_PNS_NO) { - for (j = psectionInfo->sfbStart; - j < (psectionInfo->sfbStart + psectionInfo->sfbCnt); j++) { - /* check if we can repeat the last value to save bits */ - - if (maxValueInSfb[j] == 0) { - found = 0; - - if (scfSkipCounter == 0) { - /* end of section */ - - if (j - ((psectionInfo->sfbStart + psectionInfo->sfbCnt) - 1) == 0) { - found = 0; - } - else { - for (k = j + 1; k < psectionInfo->sfbStart + psectionInfo->sfbCnt; k++) { - - if (maxValueInSfb[k] != 0) { - int tmp = L_abs(scalefacGain[k] - lastValScf); - found = 1; - - if ( tmp < CODE_BOOK_SCF_LAV) { - /* save bits */ - deltaScf = 0; - } - else { - /* do not save bits */ - deltaScf = lastValScf - scalefacGain[j]; - lastValScf = scalefacGain[j]; - scfSkipCounter = 0; - } - break; - } - /* count scalefactor skip */ - scfSkipCounter = scfSkipCounter + 1; - } - } - - psectionInfom = psectionInfo + 1; - /* search for the next maxValueInSfb[] != 0 in all other sections */ - for (m = i + 1; (m < sectionData->noOfSections) && (found == 0); m++) { - - if ((psectionInfom->codeBook != CODE_BOOK_ZERO_NO) && - (psectionInfom->codeBook != CODE_BOOK_PNS_NO)) { - for (n = psectionInfom->sfbStart; - n < (psectionInfom->sfbStart + psectionInfom->sfbCnt); n++) { - - if (maxValueInSfb[n] != 0) { - found = 1; - - if ( (abs_s(scalefacGain[n] - lastValScf) < CODE_BOOK_SCF_LAV)) { - deltaScf = 0; - } - else { - deltaScf = (lastValScf - scalefacGain[j]); - lastValScf = scalefacGain[j]; - scfSkipCounter = 0; - } - break; - } - /* count scalefactor skip */ - scfSkipCounter = scfSkipCounter + 1; - } - } - - psectionInfom += 1; - } - - if (found == 0) { - deltaScf = 0; - scfSkipCounter = 0; - } - } - else { - deltaScf = 0; - scfSkipCounter = scfSkipCounter - 1; - } - } - else { - deltaScf = lastValScf - scalefacGain[j]; - lastValScf = scalefacGain[j]; - } - sectionData->scalefacBits += bitCountScalefactorDelta(deltaScf); - } - } - } -} - - -typedef Word16 (*lookUpTable)[CODE_BOOK_ESC_NDX + 1]; - - -Word16 -dynBitCount(const Word16 *quantSpectrum, - const UWord16 *maxValueInSfb, - const Word16 *scalefac, - const Word16 blockType, - const Word16 sfbCnt, - const Word16 maxSfbPerGroup, - const Word16 sfbPerGroup, - const Word16 *sfbOffset, - SECTION_DATA *sectionData) -{ - sectionData->blockType = blockType; - sectionData->sfbCnt = sfbCnt; - sectionData->sfbPerGroup = sfbPerGroup; - if(sfbPerGroup) - sectionData->noOfGroups = sfbCnt/sfbPerGroup; - else - sectionData->noOfGroups = 0x7fff; - sectionData->maxSfbPerGroup = maxSfbPerGroup; - - noiselessCounter(sectionData, - sectionData->mergeGainLookUp, - (lookUpTable)sectionData->bitLookUp, - quantSpectrum, - maxValueInSfb, - sfbOffset, - blockType); - - scfCount(scalefac, - maxValueInSfb, - sectionData); - - - return (sectionData->huffmanBits + sectionData->sideInfoBits + - sectionData->scalefacBits); -} - diff --git a/android-aac-enc/jni/src/grp_data.c b/android-aac-enc/jni/src/grp_data.c deleted file mode 100644 index 7861e1cdc..000000000 --- a/android-aac-enc/jni/src/grp_data.c +++ /dev/null @@ -1,188 +0,0 @@ -/* - ** Copyright 2003-2010, VisualOn, Inc. - ** - ** Licensed under the Apache License, Version 2.0 (the "License"); - ** you may not use this file except in compliance with the License. - ** You may obtain a copy of the License at - ** - ** http://www.apache.org/licenses/LICENSE-2.0 - ** - ** Unless required by applicable law or agreed to in writing, software - ** distributed under the License is distributed on an "AS IS" BASIS, - ** WITHOUT 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: grp_data.c - - Content: Short block grouping function - -*******************************************************************************/ - -#include "basic_op.h" -#include "psy_const.h" -#include "interface.h" -#include "grp_data.h" - -/***************************************************************************** -* -* function name: groupShortData -* description: group short data for next quantization and coding -* -**********************************************************************************/ -void -groupShortData(Word32 *mdctSpectrum, - Word32 *tmpSpectrum, - SFB_THRESHOLD *sfbThreshold, - SFB_ENERGY *sfbEnergy, - SFB_ENERGY *sfbEnergyMS, - SFB_ENERGY *sfbSpreadedEnergy, - const Word16 sfbCnt, - const Word16 *sfbOffset, - const Word16 *sfbMinSnr, - Word16 *groupedSfbOffset, - Word16 *maxSfbPerGroup, - Word16 *groupedSfbMinSnr, - const Word16 noOfGroups, - const Word16 *groupLen) -{ - Word32 i, j; - Word32 line; - Word32 sfb; - Word32 grp; - Word32 wnd; - Word32 offset; - Word32 highestSfb; - - /* for short: regroup and */ - /* cumulate energies und thresholds group-wise . */ - - /* calculate sfbCnt */ - highestSfb = 0; - for (wnd=0; wnd=highestSfb; sfb--) { - for (line=(sfbOffset[sfb + 1] - 1); line>=sfbOffset[sfb]; line--) { - - if (mdctSpectrum[wnd*FRAME_LEN_SHORT+line] != 0) break; - } - - if (line >= sfbOffset[sfb]) break; - } - highestSfb = max(highestSfb, sfb); - } - - if (highestSfb < 0) { - highestSfb = 0; - } - *maxSfbPerGroup = highestSfb + 1; - - /* calculate sfbOffset */ - i = 0; - offset = 0; - for (grp = 0; grp < noOfGroups; grp++) { - for (sfb = 0; sfb < sfbCnt; sfb++) { - groupedSfbOffset[i] = offset + sfbOffset[sfb] * groupLen[grp]; - i += 1; - } - offset += groupLen[grp] * FRAME_LEN_SHORT; - } - groupedSfbOffset[i] = FRAME_LEN_LONG; - i += 1; - - /* calculate minSnr */ - i = 0; - offset = 0; - for (grp = 0; grp < noOfGroups; grp++) { - for (sfb = 0; sfb < sfbCnt; sfb++) { - groupedSfbMinSnr[i] = sfbMinSnr[sfb]; - i += 1; - } - offset += groupLen[grp] * FRAME_LEN_SHORT; - } - - - /* sum up sfbThresholds */ - wnd = 0; - i = 0; - for (grp = 0; grp < noOfGroups; grp++) { - for (sfb = 0; sfb < sfbCnt; sfb++) { - Word32 thresh = sfbThreshold->sfbShort[wnd][sfb]; - for (j=1; jsfbShort[wnd+j][sfb]); - } - sfbThreshold->sfbLong[i] = thresh; - i += 1; - } - wnd += groupLen[grp]; - } - - /* sum up sfbEnergies left/right */ - wnd = 0; - i = 0; - for (grp = 0; grp < noOfGroups; grp++) { - for (sfb = 0; sfb < sfbCnt; sfb++) { - Word32 energy = sfbEnergy->sfbShort[wnd][sfb]; - for (j=1; jsfbShort[wnd+j][sfb]); - } - sfbEnergy->sfbLong[i] = energy; - i += 1; - } - wnd += groupLen[grp]; - } - - /* sum up sfbEnergies mid/side */ - wnd = 0; - i = 0; - for (grp = 0; grp < noOfGroups; grp++) { - for (sfb = 0; sfb < sfbCnt; sfb++) { - Word32 energy = sfbEnergyMS->sfbShort[wnd][sfb]; - for (j=1; jsfbShort[wnd+j][sfb]); - } - sfbEnergyMS->sfbLong[i] = energy; - i += 1; - } - wnd += groupLen[grp]; - } - - /* sum up sfbSpreadedEnergies */ - wnd = 0; - i = 0; - for (grp = 0; grp < noOfGroups; grp++) { - for (sfb = 0; sfb < sfbCnt; sfb++) { - Word32 energy = sfbSpreadedEnergy->sfbShort[wnd][sfb]; - for (j=1; jsfbShort[wnd+j][sfb]); - } - sfbSpreadedEnergy->sfbLong[i] = energy; - i += 1; - } - wnd += groupLen[grp]; - } - - /* re-group spectrum */ - wnd = 0; - i = 0; - for (grp = 0; grp < noOfGroups; grp++) { - for (sfb = 0; sfb < sfbCnt; sfb++) { - for (j = 0; j < groupLen[grp]; j++) { - Word16 lineOffset = FRAME_LEN_SHORT * (wnd + j); - for (line = lineOffset + sfbOffset[sfb]; line < lineOffset + sfbOffset[sfb+1]; line++) { - tmpSpectrum[i] = mdctSpectrum[line]; - i = i + 1; - } - } - } - wnd += groupLen[grp]; - } - - for(i=0;imaxSfbPerGroup = maxSfbPerGroup; - psyOutCh->sfbCnt = groupedSfbCnt; - if(noOfGroups) - psyOutCh->sfbPerGroup = groupedSfbCnt/ noOfGroups; - else - psyOutCh->sfbPerGroup = 0x7fff; - psyOutCh->windowSequence = windowSequence; - psyOutCh->windowShape = windowShape; - psyOutCh->mdctScale = mdctScale; - psyOutCh->mdctSpectrum = groupedMdctSpectrum; - psyOutCh->sfbEnergy = groupedSfbEnergy->sfbLong; - psyOutCh->sfbThreshold = groupedSfbThreshold->sfbLong; - psyOutCh->sfbSpreadedEnergy = groupedSfbSpreadedEnergy->sfbLong; - - tmpV = psyOutCh->sfbOffsets; - for(j=0; jsfbMinSnr; - for(j=0;jgroupingMask = mask; - - if (windowSequence != SHORT_WINDOW) { - psyOutCh->sfbEnSumLR = sfbEnergySumLR.sfbLong; - psyOutCh->sfbEnSumMS = sfbEnergySumMS.sfbLong; - } - else { - Word32 i; - Word32 accuSumMS=0; - Word32 accuSumLR=0; - const Word32 *pSumMS = sfbEnergySumMS.sfbShort; - const Word32 *pSumLR = sfbEnergySumLR.sfbShort; - - for (i=TRANS_FAC; i; i--) { - accuSumLR = L_add(accuSumLR, *pSumLR); pSumLR++; - accuSumMS = L_add(accuSumMS, *pSumMS); pSumMS++; - } - psyOutCh->sfbEnSumMS = accuSumMS; - psyOutCh->sfbEnSumLR = accuSumLR; - } -} diff --git a/android-aac-enc/jni/src/line_pe.c b/android-aac-enc/jni/src/line_pe.c deleted file mode 100644 index 480dc288b..000000000 --- a/android-aac-enc/jni/src/line_pe.c +++ /dev/null @@ -1,145 +0,0 @@ -/* - ** Copyright 2003-2010, VisualOn, Inc. - ** - ** Licensed under the Apache License, Version 2.0 (the "License"); - ** you may not use this file except in compliance with the License. - ** You may obtain a copy of the License at - ** - ** http://www.apache.org/licenses/LICENSE-2.0 - ** - ** Unless required by applicable law or agreed to in writing, software - ** distributed under the License is distributed on an "AS IS" BASIS, - ** WITHOUT 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: line_pe.c - - Content: Perceptual entropie module functions - -*******************************************************************************/ - -#include "basic_op.h" -#include "oper_32b.h" -#include "typedef.h" -#include "line_pe.h" - - -static const Word16 C1_I = 12; /* log(8.0)/log(2) *4 */ -static const Word32 C2_I = 10830; /* log(2.5)/log(2) * 1024 * 4 * 2 */ -static const Word16 C3_I = 573; /* (1-C2/C1) *1024 */ - - -/***************************************************************************** -* -* function name: prepareSfbPe -* description: constants that do not change during successive pe calculations -* -**********************************************************************************/ -void prepareSfbPe(PE_DATA *peData, - PSY_OUT_CHANNEL psyOutChannel[MAX_CHANNELS], - Word16 logSfbEnergy[MAX_CHANNELS][MAX_GROUPED_SFB], - Word16 sfbNRelevantLines[MAX_CHANNELS][MAX_GROUPED_SFB], - const Word16 nChannels, - const Word16 peOffset) -{ - Word32 sfbGrp, sfb; - Word32 ch; - - for(ch=0; chpeChannelData[ch]; - for(sfbGrp=0;sfbGrpsfbCnt; sfbGrp+=psyOutChan->sfbPerGroup){ - for (sfb=0; sfbmaxSfbPerGroup; sfb++) { - peChanData->sfbNLines4[sfbGrp+sfb] = sfbNRelevantLines[ch][sfbGrp+sfb]; - sfbNRelevantLines[ch][sfbGrp+sfb] = sfbNRelevantLines[ch][sfbGrp+sfb] >> 2; - peChanData->sfbLdEnergy[sfbGrp+sfb] = logSfbEnergy[ch][sfbGrp+sfb]; - } - } - } - peData->offset = peOffset; -} - - -/***************************************************************************** -* -* function name: calcSfbPe -* description: constPart is sfbPe without the threshold part n*ld(thr) or n*C3*ld(thr) -* -**********************************************************************************/ -void calcSfbPe(PE_DATA *peData, - PSY_OUT_CHANNEL psyOutChannel[MAX_CHANNELS], - const Word16 nChannels) -{ - Word32 ch; - Word32 sfbGrp, sfb; - Word32 nLines4; - Word32 ldThr, ldRatio; - Word32 pe, constPart, nActiveLines; - - peData->pe = peData->offset; - peData->constPart = 0; - peData->nActiveLines = 0; - for(ch=0; chpeChannelData[ch]; - const Word32 *sfbEnergy = psyOutChan->sfbEnergy; - const Word32 *sfbThreshold = psyOutChan->sfbThreshold; - - pe = 0; - constPart = 0; - nActiveLines = 0; - - for(sfbGrp=0; sfbGrpsfbCnt; sfbGrp+=psyOutChan->sfbPerGroup) { - for (sfb=0; sfbmaxSfbPerGroup; sfb++) { - Word32 nrg = sfbEnergy[sfbGrp+sfb]; - Word32 thres = sfbThreshold[sfbGrp+sfb]; - Word32 sfbLDEn = peChanData->sfbLdEnergy[sfbGrp+sfb]; - - if (nrg > thres) { - ldThr = iLog4(thres); - - ldRatio = sfbLDEn - ldThr; - - nLines4 = peChanData->sfbNLines4[sfbGrp+sfb]; - - /* sfbPe = nl*log2(en/thr)*/ - if (ldRatio >= C1_I) { - peChanData->sfbPe[sfbGrp+sfb] = (nLines4*ldRatio + 8) >> 4; - peChanData->sfbConstPart[sfbGrp+sfb] = ((nLines4*sfbLDEn)) >> 4; - } - else { - /* sfbPe = nl*(c2 + c3*log2(en/thr))*/ - peChanData->sfbPe[sfbGrp+sfb] = extract_l((L_mpy_wx( - (C2_I + C3_I * ldRatio * 2) << 4, nLines4) + 4) >> 3); - peChanData->sfbConstPart[sfbGrp+sfb] = extract_l(( L_mpy_wx( - (C2_I + C3_I * sfbLDEn * 2) << 4, nLines4) + 4) >> 3); - nLines4 = (nLines4 * C3_I + (1024<<1)) >> 10; - } - peChanData->sfbNActiveLines[sfbGrp+sfb] = nLines4 >> 2; - } - else { - peChanData->sfbPe[sfbGrp+sfb] = 0; - peChanData->sfbConstPart[sfbGrp+sfb] = 0; - peChanData->sfbNActiveLines[sfbGrp+sfb] = 0; - } - pe = pe + peChanData->sfbPe[sfbGrp+sfb]; - constPart = constPart + peChanData->sfbConstPart[sfbGrp+sfb]; - nActiveLines = nActiveLines + peChanData->sfbNActiveLines[sfbGrp+sfb]; - } - } - - peChanData->pe = saturate(pe); - peChanData->constPart = saturate(constPart); - peChanData->nActiveLines = saturate(nActiveLines); - - - pe += peData->pe; - peData->pe = saturate(pe); - constPart += peData->constPart; - peData->constPart = saturate(constPart); - nActiveLines += peData->nActiveLines; - peData->nActiveLines = saturate(nActiveLines); - } -} diff --git a/android-aac-enc/jni/src/memalign.c b/android-aac-enc/jni/src/memalign.c deleted file mode 100644 index bb266dcde..000000000 --- a/android-aac-enc/jni/src/memalign.c +++ /dev/null @@ -1,112 +0,0 @@ -/* - ** Copyright 2003-2010, VisualOn, Inc. - ** - ** Licensed under the Apache License, Version 2.0 (the "License"); - ** you may not use this file except in compliance with the License. - ** You may obtain a copy of the License at - ** - ** http://www.apache.org/licenses/LICENSE-2.0 - ** - ** Unless required by applicable law or agreed to in writing, software - ** distributed under the License is distributed on an "AS IS" BASIS, - ** WITHOUT 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: mem_align.c - - Content: Memory alloc alignments functions - -*******************************************************************************/ - - -#include "memalign.h" -#ifdef _MSC_VER -#include -#else -#include -#endif - -/***************************************************************************** -* -* function name: mem_malloc -* description: malloc the alignments memory -* returns: the point of the memory -* -**********************************************************************************/ -void * -mem_malloc(VO_MEM_OPERATOR *pMemop, unsigned int size, unsigned char alignment, unsigned int CodecID) -{ - int ret; - unsigned char *mem_ptr; - VO_MEM_INFO MemInfo; - - if (!alignment) { - - MemInfo.Flag = 0; - MemInfo.Size = size + 1; - ret = pMemop->Alloc(CodecID, &MemInfo); - if(ret != 0) - return 0; - mem_ptr = (unsigned char *)MemInfo.VBuffer; - - pMemop->Set(CodecID, mem_ptr, 0, size + 1); - - *mem_ptr = (unsigned char)1; - - return ((void *)(mem_ptr+1)); - } else { - unsigned char *tmp; - - MemInfo.Flag = 0; - MemInfo.Size = size + alignment; - ret = pMemop->Alloc(CodecID, &MemInfo); - if(ret != 0) - return 0; - - tmp = (unsigned char *)MemInfo.VBuffer; - - pMemop->Set(CodecID, tmp, 0, size + alignment); - - mem_ptr = - (unsigned char *) ((intptr_t) (tmp + alignment - 1) & - (~((intptr_t) (alignment - 1)))); - - if (mem_ptr == tmp) - mem_ptr += alignment; - - *(mem_ptr - 1) = (unsigned char) (mem_ptr - tmp); - - return ((void *)mem_ptr); - } - - return(0); -} - - -/***************************************************************************** -* -* function name: mem_free -* description: free the memory -* -*******************************************************************************/ -void -mem_free(VO_MEM_OPERATOR *pMemop, void *mem_ptr, unsigned int CodecID) -{ - - unsigned char *ptr; - - if (mem_ptr == 0) - return; - - ptr = mem_ptr; - - ptr -= *(ptr - 1); - - pMemop->Free(CodecID, ptr); -} - - - diff --git a/android-aac-enc/jni/src/ms_stereo.c b/android-aac-enc/jni/src/ms_stereo.c deleted file mode 100644 index 2e34f14b9..000000000 --- a/android-aac-enc/jni/src/ms_stereo.c +++ /dev/null @@ -1,139 +0,0 @@ -/* - ** Copyright 2003-2010, VisualOn, Inc. - ** - ** Licensed under the Apache License, Version 2.0 (the "License"); - ** you may not use this file except in compliance with the License. - ** You may obtain a copy of the License at - ** - ** http://www.apache.org/licenses/LICENSE-2.0 - ** - ** Unless required by applicable law or agreed to in writing, software - ** distributed under the License is distributed on an "AS IS" BASIS, - ** WITHOUT 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: ms_stereo.c - - Content: MS stereo processing function - -*******************************************************************************/ - -#include "basic_op.h" -#include "oper_32b.h" -#include "psy_const.h" -#include "ms_stereo.h" - - -/******************************************************************************** -* -* function name: MsStereoProcessing -* description: detect use ms stereo or not -* if ((min(thrLn, thrRn)*min(thrLn, thrRn))/(enMn*enSn)) -* >= ((thrLn *thrRn)/(enLn*enRn)) then ms stereo -* -**********************************************************************************/ -void MsStereoProcessing(Word32 *sfbEnergyLeft, - Word32 *sfbEnergyRight, - const Word32 *sfbEnergyMid, - const Word32 *sfbEnergySide, - Word32 *mdctSpectrumLeft, - Word32 *mdctSpectrumRight, - Word32 *sfbThresholdLeft, - Word32 *sfbThresholdRight, - Word32 *sfbSpreadedEnLeft, - Word32 *sfbSpreadedEnRight, - Word16 *msDigest, - Word16 *msMask, - const Word16 sfbCnt, - const Word16 sfbPerGroup, - const Word16 maxSfbPerGroup, - const Word16 *sfbOffset) { - Word32 temp; - Word32 sfb,sfboffs, j; - Word32 msMaskTrueSomewhere = 0; - Word32 msMaskFalseSomewhere = 0; - - for (sfb=0; sfb> 8) + 1); - - temp = pnms - pnlr; - if( temp > 0 ){ - - msMask[idx] = 1; - msMaskTrueSomewhere = 1; - - for (j=sfbOffset[idx]; j> 1); - right = (mdctSpectrumRight[j] >> 1); - mdctSpectrumLeft[j] = left + right; - mdctSpectrumRight[j] = left - right; - } - - sfbThresholdLeft[idx] = minThreshold; - sfbThresholdRight[idx] = minThreshold; - sfbEnergyLeft[idx] = sfbEnergyMid[idx]; - sfbEnergyRight[idx] = sfbEnergySide[idx]; - - sfbSpreadedEnRight[idx] = min(sfbSpreadedEnLeft[idx],sfbSpreadedEnRight[idx]) >> 1; - sfbSpreadedEnLeft[idx] = sfbSpreadedEnRight[idx]; - - } - else { - msMask[idx] = 0; - msMaskFalseSomewhere = 1; - } - } - if ( msMaskTrueSomewhere ) { - if(msMaskFalseSomewhere ) { - *msDigest = SI_MS_MASK_SOME; - } else { - *msDigest = SI_MS_MASK_ALL; - } - } else { - *msDigest = SI_MS_MASK_NONE; - } - } - -} diff --git a/android-aac-enc/jni/src/pre_echo_control.c b/android-aac-enc/jni/src/pre_echo_control.c deleted file mode 100644 index 1406e11b0..000000000 --- a/android-aac-enc/jni/src/pre_echo_control.c +++ /dev/null @@ -1,113 +0,0 @@ -/* - ** Copyright 2003-2010, VisualOn, Inc. - ** - ** Licensed under the Apache License, Version 2.0 (the "License"); - ** you may not use this file except in compliance with the License. - ** You may obtain a copy of the License at - ** - ** http://www.apache.org/licenses/LICENSE-2.0 - ** - ** Unless required by applicable law or agreed to in writing, software - ** distributed under the License is distributed on an "AS IS" BASIS, - ** WITHOUT 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: pre_echo_control.c - - Content: Pre echo control functions - -*******************************************************************************/ - -#include "basic_op.h" -#include "oper_32b.h" - -#include "oper_32b.h" -#include "pre_echo_control.h" - - -/***************************************************************************** -* -* function name:InitPreEchoControl -* description: init pre echo control parameter -* -*****************************************************************************/ -void InitPreEchoControl(Word32 *pbThresholdNm1, - Word16 numPb, - Word32 *pbThresholdQuiet) -{ - Word16 pb; - - for(pb=0; pb 0 ) { - for(i = 0; i < numPb; i++) { - tmpThreshold1 = pbThresholdNm1[i] >> (scaling-1); - tmpThreshold2 = L_mpy_ls(pbThreshold[i], minRemainingThresholdFactor); - - /* copy thresholds to internal memory */ - pbThresholdNm1[i] = pbThreshold[i]; - - - if(pbThreshold[i] > tmpThreshold1) { - pbThreshold[i] = tmpThreshold1; - } - - if(tmpThreshold2 > pbThreshold[i]) { - pbThreshold[i] = tmpThreshold2; - } - - } - } - else { - scaling = -scaling; - for(i = 0; i < numPb; i++) { - - tmpThreshold1 = pbThresholdNm1[i] << 1; - tmpThreshold2 = L_mpy_ls(pbThreshold[i], minRemainingThresholdFactor); - - /* copy thresholds to internal memory */ - pbThresholdNm1[i] = pbThreshold[i]; - - - if(((pbThreshold[i] >> scaling) > tmpThreshold1)) { - pbThreshold[i] = tmpThreshold1 << scaling; - } - - if(tmpThreshold2 > pbThreshold[i]) { - pbThreshold[i] = tmpThreshold2; - } - - } - } -} - diff --git a/android-aac-enc/jni/src/psy_configuration.c b/android-aac-enc/jni/src/psy_configuration.c deleted file mode 100644 index dd40f9b24..000000000 --- a/android-aac-enc/jni/src/psy_configuration.c +++ /dev/null @@ -1,505 +0,0 @@ -/* - ** Copyright 2003-2010, VisualOn, Inc. - ** - ** Licensed under the Apache License, Version 2.0 (the "License"); - ** you may not use this file except in compliance with the License. - ** You may obtain a copy of the License at - ** - ** http://www.apache.org/licenses/LICENSE-2.0 - ** - ** Unless required by applicable law or agreed to in writing, software - ** distributed under the License is distributed on an "AS IS" BASIS, - ** WITHOUT 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: psy_configuration.c - - Content: Psychoaccoustic configuration functions - -*******************************************************************************/ - -#include "basic_op.h" -#include "oper_32b.h" -#include "psy_configuration.h" -#include "adj_thr.h" -#include "aac_rom.h" - - - -#define BARC_SCALE 100 /* integer barc values are scaled with 100 */ -#define LOG2_1000 301 /* log2*1000 */ -#define PI2_1000 1571 /* pi/2*1000*/ -#define ATAN_COEF1 3560 /* 1000/0.280872f*/ -#define ATAN_COEF2 281 /* 1000*0.280872f*/ - - -typedef struct{ - Word32 sampleRate; - const UWord8 *paramLong; - const UWord8 *paramShort; -}SFB_INFO_TAB; - -static const Word16 ABS_LEV = 20; -static const Word16 BARC_THR_QUIET[] = {15, 10, 7, 2, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 3, 5, 10, 20, 30}; - - - -static const Word16 max_bark = 24; /* maximum bark-value */ -static const Word16 maskLow = 30; /* in 1dB/bark */ -static const Word16 maskHigh = 15; /* in 1*dB/bark */ -static const Word16 c_ratio = 0x0029; /* pow(10.0f, -(29.0f/10.0f)) */ - -static const Word16 maskLowSprEnLong = 30; /* in 1dB/bark */ -static const Word16 maskHighSprEnLong = 20; /* in 1dB/bark */ -static const Word16 maskHighSprEnLongLowBr = 15; /* in 1dB/bark */ -static const Word16 maskLowSprEnShort = 20; /* in 1dB/bark */ -static const Word16 maskHighSprEnShort = 15; /* in 1dB/bark */ -static const Word16 c_minRemainingThresholdFactor = 0x0148; /* 0.01 *(1 << 15)*/ -static const Word32 c_maxsnr = 0x66666666; /* upper limit is -1 dB */ -static const Word32 c_minsnr = 0x00624dd3; /* lower limit is -25 dB */ - -static const Word32 c_maxClipEnergyLong = 0x77359400; /* 2.0e9f*/ -static const Word32 c_maxClipEnergyShort = 0x01dcd650; /* 2.0e9f/(AACENC_TRANS_FAC*AACENC_TRANS_FAC)*/ - - -Word32 GetSRIndex(Word32 sampleRate) -{ - if (92017 <= sampleRate) return 0; - if (75132 <= sampleRate) return 1; - if (55426 <= sampleRate) return 2; - if (46009 <= sampleRate) return 3; - if (37566 <= sampleRate) return 4; - if (27713 <= sampleRate) return 5; - if (23004 <= sampleRate) return 6; - if (18783 <= sampleRate) return 7; - if (13856 <= sampleRate) return 8; - if (11502 <= sampleRate) return 9; - if (9391 <= sampleRate) return 10; - - return 11; -} - - -/********************************************************************************* -* -* function name: atan_1000 -* description: calculates 1000*atan(x/1000) -* based on atan approx for x > 0 -* atan(x) = x/((float)1.0f+(float)0.280872f*x*x) if x < 1 -* = pi/2 - x/((float)0.280872f +x*x) if x >= 1 -* return: 1000*atan(x/1000) -* -**********************************************************************************/ -static Word16 atan_1000(Word32 val) -{ - Word32 y; - - - if(L_sub(val, 1000) < 0) { - y = extract_l(((1000 * val) / (1000 + ((val * val) / ATAN_COEF1)))); - } - else { - y = PI2_1000 - ((1000 * val) / (ATAN_COEF2 + ((val * val) / 1000))); - } - - return extract_l(y); -} - - -/***************************************************************************** -* -* function name: BarcLineValue -* description: Calculates barc value for one frequency line -* returns: barc value of line * BARC_SCALE -* input: number of lines in transform, index of line to check, Fs -* output: -* -*****************************************************************************/ -static Word16 BarcLineValue(Word16 noOfLines, Word16 fftLine, Word32 samplingFreq) -{ - Word32 center_freq, temp, bvalFFTLine; - - /* center frequency of fft line */ - center_freq = (fftLine * samplingFreq) / (noOfLines << 1); - temp = atan_1000((center_freq << 2) / (3*10)); - bvalFFTLine = - (26600 * atan_1000((center_freq*76) / 100) + 7*temp*temp) / (2*1000*1000 / BARC_SCALE); - - return saturate(bvalFFTLine); -} - -/***************************************************************************** -* -* function name: initThrQuiet -* description: init thredhold in quiet -* -*****************************************************************************/ -static void initThrQuiet(Word16 numPb, - const Word16 *pbOffset, - Word16 *pbBarcVal, - Word32 *pbThresholdQuiet) { - Word16 i; - Word16 barcThrQuiet; - - for(i=0; i0) - bv1 = (pbBarcVal[i] + pbBarcVal[i-1]) >> 1; - else - bv1 = pbBarcVal[i] >> 1; - - - if (i < (numPb - 1)) - bv2 = (pbBarcVal[i] + pbBarcVal[i+1]) >> 1; - else { - bv2 = pbBarcVal[i]; - } - - bv1 = min((bv1 / BARC_SCALE), max_bark); - bv2 = min((bv2 / BARC_SCALE), max_bark); - - barcThrQuiet = min(BARC_THR_QUIET[bv1], BARC_THR_QUIET[bv2]); - - - /* - we calculate - pow(10.0f,(float)(barcThrQuiet - ABS_LEV)*0.1)*(float)ABS_LOW*(pbOffset[i+1] - pbOffset[i]); - */ - - pbThresholdQuiet[i] = pow2_xy((((barcThrQuiet - ABS_LEV) * 100) + - LOG2_1000*(14+2*LOG_NORM_PCM)), LOG2_1000) * (pbOffset[i+1] - pbOffset[i]); - } -} - - -/***************************************************************************** -* -* function name: initSpreading -* description: init energy spreading parameter -* -*****************************************************************************/ -static void initSpreading(Word16 numPb, - Word16 *pbBarcValue, - Word16 *pbMaskLoFactor, - Word16 *pbMaskHiFactor, - Word16 *pbMaskLoFactorSprEn, - Word16 *pbMaskHiFactorSprEn, - const Word32 bitrate, - const Word16 blockType) -{ - Word16 i; - Word16 maskLowSprEn, maskHighSprEn; - - - if (sub(blockType, SHORT_WINDOW) != 0) { - maskLowSprEn = maskLowSprEnLong; - - if (bitrate > 22000) - maskHighSprEn = maskHighSprEnLong; - else - maskHighSprEn = maskHighSprEnLongLowBr; - } - else { - maskLowSprEn = maskLowSprEnShort; - maskHighSprEn = maskHighSprEnShort; - } - - for(i=0; i 0) { - Word32 dbVal; - Word16 dbark = pbBarcValue[i] - pbBarcValue[i-1]; - - /* - we calulate pow(10.0f, -0.1*dbVal/BARC_SCALE) - */ - dbVal = (maskHigh * dbark); - pbMaskHiFactor[i] = round16(pow2_xy(L_negate(dbVal), (Word32)LOG2_1000)); /* 0.301 log10(2) */ - - dbVal = (maskLow * dbark); - pbMaskLoFactor[i-1] = round16(pow2_xy(L_negate(dbVal),(Word32)LOG2_1000)); - - - dbVal = (maskHighSprEn * dbark); - pbMaskHiFactorSprEn[i] = round16(pow2_xy(L_negate(dbVal),(Word32)LOG2_1000)); - dbVal = (maskLowSprEn * dbark); - pbMaskLoFactorSprEn[i-1] = round16(pow2_xy(L_negate(dbVal),(Word32)LOG2_1000)); - } - else { - pbMaskHiFactor[i] = 0; - pbMaskLoFactor[numPb-1] = 0; - - pbMaskHiFactorSprEn[i] = 0; - pbMaskLoFactorSprEn[numPb-1] = 0; - } - } - -} - - -/***************************************************************************** -* -* function name: initBarcValues -* description: init bark value -* -*****************************************************************************/ -static void initBarcValues(Word16 numPb, - const Word16 *pbOffset, - Word16 numLines, - Word32 samplingFrequency, - Word16 *pbBval) -{ - Word16 i; - Word16 pbBval0, pbBval1; - - pbBval0 = 0; - - for(i=0; i> 1; - pbBval0 = pbBval1; - } -} - - -/***************************************************************************** -* -* function name: initMinSnr -* description: calculate min snr parameter -* minSnr(n) = 1/(2^sfbPemin(n)/w(n) - 1.5) -* -*****************************************************************************/ -static void initMinSnr(const Word32 bitrate, - const Word32 samplerate, - const Word16 numLines, - const Word16 *sfbOffset, - const Word16 *pbBarcVal, - const Word16 sfbActive, - Word16 *sfbMinSnr) -{ - Word16 sfb; - Word16 barcWidth; - Word16 pePerWindow; - Word32 pePart; - Word32 snr; - Word16 pbVal0, pbVal1, shift; - - /* relative number of active barks */ - - - pePerWindow = bits2pe(extract_l((bitrate * numLines) / samplerate)); - - pbVal0 = 0; - - for (sfb=0; sfb 0x00008000) - { - shift = norm_l(snr); - snr = Div_32(0x00008000 << shift, snr << shift); - } - else - { - snr = 0x7fffffff; - } - - /* upper limit is -1 dB */ - snr = min(snr, c_maxsnr); - /* lower limit is -25 dB */ - snr = max(snr, c_minsnr); - sfbMinSnr[sfb] = round16(snr); - } - -} - -/***************************************************************************** -* -* function name: InitPsyConfigurationLong -* description: init long block psychoacoustic configuration -* -*****************************************************************************/ -Word16 InitPsyConfigurationLong(Word32 bitrate, - Word32 samplerate, - Word16 bandwidth, - PSY_CONFIGURATION_LONG *psyConf) -{ - Word32 samplerateindex; - Word16 sfbBarcVal[MAX_SFB_LONG]; - Word16 sfb; - - /* - init sfb table - */ - samplerateindex = GetSRIndex(samplerate); - psyConf->sfbCnt = sfBandTotalLong[samplerateindex]; - psyConf->sfbOffset = sfBandTabLong + sfBandTabLongOffset[samplerateindex]; - psyConf->sampRateIdx = samplerateindex; - - /* - calculate barc values for each pb - */ - initBarcValues(psyConf->sfbCnt, - psyConf->sfbOffset, - psyConf->sfbOffset[psyConf->sfbCnt], - samplerate, - sfbBarcVal); - - /* - init thresholds in quiet - */ - initThrQuiet(psyConf->sfbCnt, - psyConf->sfbOffset, - sfbBarcVal, - psyConf->sfbThresholdQuiet); - - /* - calculate spreading function - */ - initSpreading(psyConf->sfbCnt, - sfbBarcVal, - psyConf->sfbMaskLowFactor, - psyConf->sfbMaskHighFactor, - psyConf->sfbMaskLowFactorSprEn, - psyConf->sfbMaskHighFactorSprEn, - bitrate, - LONG_WINDOW); - - /* - init ratio - */ - psyConf->ratio = c_ratio; - - psyConf->maxAllowedIncreaseFactor = 2; - psyConf->minRemainingThresholdFactor = c_minRemainingThresholdFactor; /* 0.01 *(1 << 15)*/ - - psyConf->clipEnergy = c_maxClipEnergyLong; - psyConf->lowpassLine = extract_l((bandwidth<<1) * FRAME_LEN_LONG / samplerate); - - for (sfb = 0; sfb < psyConf->sfbCnt; sfb++) { - if (sub(psyConf->sfbOffset[sfb], psyConf->lowpassLine) >= 0) - break; - } - psyConf->sfbActive = sfb; - - /* - calculate minSnr - */ - initMinSnr(bitrate, - samplerate, - psyConf->sfbOffset[psyConf->sfbCnt], - psyConf->sfbOffset, - sfbBarcVal, - psyConf->sfbActive, - psyConf->sfbMinSnr); - - - return(0); -} - -/***************************************************************************** -* -* function name: InitPsyConfigurationShort -* description: init short block psychoacoustic configuration -* -*****************************************************************************/ -Word16 InitPsyConfigurationShort(Word32 bitrate, - Word32 samplerate, - Word16 bandwidth, - PSY_CONFIGURATION_SHORT *psyConf) -{ - Word32 samplerateindex; - Word16 sfbBarcVal[MAX_SFB_SHORT]; - Word16 sfb; - /* - init sfb table - */ - samplerateindex = GetSRIndex(samplerate); - psyConf->sfbCnt = sfBandTotalShort[samplerateindex]; - psyConf->sfbOffset = sfBandTabShort + sfBandTabShortOffset[samplerateindex]; - psyConf->sampRateIdx = samplerateindex; - /* - calculate barc values for each pb - */ - initBarcValues(psyConf->sfbCnt, - psyConf->sfbOffset, - psyConf->sfbOffset[psyConf->sfbCnt], - samplerate, - sfbBarcVal); - - /* - init thresholds in quiet - */ - initThrQuiet(psyConf->sfbCnt, - psyConf->sfbOffset, - sfbBarcVal, - psyConf->sfbThresholdQuiet); - - /* - calculate spreading function - */ - initSpreading(psyConf->sfbCnt, - sfbBarcVal, - psyConf->sfbMaskLowFactor, - psyConf->sfbMaskHighFactor, - psyConf->sfbMaskLowFactorSprEn, - psyConf->sfbMaskHighFactorSprEn, - bitrate, - SHORT_WINDOW); - - /* - init ratio - */ - psyConf->ratio = c_ratio; - - psyConf->maxAllowedIncreaseFactor = 2; - psyConf->minRemainingThresholdFactor = c_minRemainingThresholdFactor; - - psyConf->clipEnergy = c_maxClipEnergyShort; - - psyConf->lowpassLine = extract_l(((bandwidth << 1) * FRAME_LEN_SHORT) / samplerate); - - for (sfb = 0; sfb < psyConf->sfbCnt; sfb++) { - - if (psyConf->sfbOffset[sfb] >= psyConf->lowpassLine) - break; - } - psyConf->sfbActive = sfb; - - /* - calculate minSnr - */ - initMinSnr(bitrate, - samplerate, - psyConf->sfbOffset[psyConf->sfbCnt], - psyConf->sfbOffset, - sfbBarcVal, - psyConf->sfbActive, - psyConf->sfbMinSnr); - - return(0); -} - diff --git a/android-aac-enc/jni/src/psy_main.c b/android-aac-enc/jni/src/psy_main.c deleted file mode 100644 index 4e9218c81..000000000 --- a/android-aac-enc/jni/src/psy_main.c +++ /dev/null @@ -1,811 +0,0 @@ -/* - ** Copyright 2003-2010, VisualOn, Inc. - ** - ** Licensed under the Apache License, Version 2.0 (the "License"); - ** you may not use this file except in compliance with the License. - ** You may obtain a copy of the License at - ** - ** http://www.apache.org/licenses/LICENSE-2.0 - ** - ** Unless required by applicable law or agreed to in writing, software - ** distributed under the License is distributed on an "AS IS" BASIS, - ** WITHOUT 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: psy_main.c - - Content: Psychoacoustic major functions - -*******************************************************************************/ - -#include "typedef.h" -#include "basic_op.h" -#include "oper_32b.h" -#include "psy_const.h" -#include "block_switch.h" -#include "transform.h" -#include "spreading.h" -#include "pre_echo_control.h" -#include "band_nrg.h" -#include "psy_configuration.h" -#include "psy_data.h" -#include "ms_stereo.h" -#include "interface.h" -#include "psy_main.h" -#include "grp_data.h" -#include "tns_func.h" -#include "memalign.h" - -/* long start short stop */ -static Word16 blockType2windowShape[] = {KBD_WINDOW,SINE_WINDOW,SINE_WINDOW,KBD_WINDOW}; - -/* - forward definitions -*/ -static Word16 advancePsychLong(PSY_DATA* psyData, - TNS_DATA* tnsData, - PSY_CONFIGURATION_LONG *hPsyConfLong, - PSY_OUT_CHANNEL* psyOutChannel, - Word32 *pScratchTns, - const TNS_DATA *tnsData2, - const Word16 ch); - -static Word16 advancePsychLongMS (PSY_DATA psyData[MAX_CHANNELS], - const PSY_CONFIGURATION_LONG *hPsyConfLong); - -static Word16 advancePsychShort(PSY_DATA* psyData, - TNS_DATA* tnsData, - const PSY_CONFIGURATION_SHORT *hPsyConfShort, - PSY_OUT_CHANNEL* psyOutChannel, - Word32 *pScratchTns, - const TNS_DATA *tnsData2, - const Word16 ch); - -static Word16 advancePsychShortMS (PSY_DATA psyData[MAX_CHANNELS], - const PSY_CONFIGURATION_SHORT *hPsyConfShort); - - -/***************************************************************************** -* -* function name: PsyNew -* description: allocates memory for psychoacoustic -* returns: an error code -* input: pointer to a psych handle -* -*****************************************************************************/ -Word16 PsyNew(PSY_KERNEL *hPsy, Word32 nChan, VO_MEM_OPERATOR *pMemOP) -{ - Word16 i; - Word32 *mdctSpectrum; - Word32 *scratchTNS; - Word16 *mdctDelayBuffer; - - mdctSpectrum = (Word32 *)mem_malloc(pMemOP, nChan * FRAME_LEN_LONG * sizeof(Word32), 32, VO_INDEX_ENC_AAC); - if(NULL == mdctSpectrum) - return 1; - - scratchTNS = (Word32 *)mem_malloc(pMemOP, nChan * FRAME_LEN_LONG * sizeof(Word32), 32, VO_INDEX_ENC_AAC); - if(NULL == scratchTNS) - { - return 1; - } - - mdctDelayBuffer = (Word16 *)mem_malloc(pMemOP, nChan * BLOCK_SWITCHING_OFFSET * sizeof(Word16), 32, VO_INDEX_ENC_AAC); - if(NULL == mdctDelayBuffer) - { - return 1; - } - - for (i=0; ipsyData[i].mdctDelayBuffer = mdctDelayBuffer + i*BLOCK_SWITCHING_OFFSET; - hPsy->psyData[i].mdctSpectrum = mdctSpectrum + i*FRAME_LEN_LONG; - } - - hPsy->pScratchTns = scratchTNS; - - return 0; -} - - -/***************************************************************************** -* -* function name: PsyDelete -* description: allocates memory for psychoacoustic -* returns: an error code -* -*****************************************************************************/ -Word16 PsyDelete(PSY_KERNEL *hPsy, VO_MEM_OPERATOR *pMemOP) -{ - Word32 nch; - - if(hPsy) - { - if(hPsy->psyData[0].mdctDelayBuffer) - mem_free(pMemOP, hPsy->psyData[0].mdctDelayBuffer, VO_INDEX_ENC_AAC); - - if(hPsy->psyData[0].mdctSpectrum) - mem_free(pMemOP, hPsy->psyData[0].mdctSpectrum, VO_INDEX_ENC_AAC); - - for (nch=0; nchpsyData[nch].mdctDelayBuffer = NULL; - hPsy->psyData[nch].mdctSpectrum = NULL; - } - - if(hPsy->pScratchTns) - { - mem_free(pMemOP, hPsy->pScratchTns, VO_INDEX_ENC_AAC); - hPsy->pScratchTns = NULL; - } - } - - return 0; -} - - -/***************************************************************************** -* -* function name: PsyOutNew -* description: allocates memory for psyOut struc -* returns: an error code -* input: pointer to a psych handle -* -*****************************************************************************/ -Word16 PsyOutNew(PSY_OUT *hPsyOut, VO_MEM_OPERATOR *pMemOP) -{ - pMemOP->Set(VO_INDEX_ENC_AAC, hPsyOut, 0, sizeof(PSY_OUT)); - /* - alloc some more stuff, tbd - */ - return 0; -} - -/***************************************************************************** -* -* function name: PsyOutDelete -* description: allocates memory for psychoacoustic -* returns: an error code -* -*****************************************************************************/ -Word16 PsyOutDelete(PSY_OUT *hPsyOut, VO_MEM_OPERATOR *pMemOP) -{ - hPsyOut=NULL; - return 0; -} - - -/***************************************************************************** -* -* function name: psyMainInit -* description: initializes psychoacoustic -* returns: an error code -* -*****************************************************************************/ - -Word16 psyMainInit(PSY_KERNEL *hPsy, - Word32 sampleRate, - Word32 bitRate, - Word16 channels, - Word16 tnsMask, - Word16 bandwidth) -{ - Word16 ch, err; - Word32 channelBitRate = bitRate/channels; - - err = InitPsyConfigurationLong(channelBitRate, - sampleRate, - bandwidth, - &(hPsy->psyConfLong)); - - if (!err) { - hPsy->sampleRateIdx = hPsy->psyConfLong.sampRateIdx; - err = InitTnsConfigurationLong(bitRate, sampleRate, channels, - &hPsy->psyConfLong.tnsConf, &hPsy->psyConfLong, tnsMask&2); - } - - if (!err) - err = InitPsyConfigurationShort(channelBitRate, - sampleRate, - bandwidth, - &hPsy->psyConfShort); - if (!err) { - err = InitTnsConfigurationShort(bitRate, sampleRate, channels, - &hPsy->psyConfShort.tnsConf, &hPsy->psyConfShort, tnsMask&1); - } - - if (!err) - for(ch=0;ch < channels;ch++){ - - InitBlockSwitching(&hPsy->psyData[ch].blockSwitchingControl, - bitRate, channels); - - InitPreEchoControl(hPsy->psyData[ch].sfbThresholdnm1, - hPsy->psyConfLong.sfbCnt, - hPsy->psyConfLong.sfbThresholdQuiet); - hPsy->psyData[ch].mdctScalenm1 = 0; - } - - return(err); -} - -/***************************************************************************** -* -* function name: psyMain -* description: psychoacoustic main function -* returns: an error code -* -* This function assumes that enough input data is in the modulo buffer. -* -*****************************************************************************/ - -Word16 psyMain(Word16 nChannels, - ELEMENT_INFO *elemInfo, - Word16 *timeSignal, - PSY_DATA psyData[MAX_CHANNELS], - TNS_DATA tnsData[MAX_CHANNELS], - PSY_CONFIGURATION_LONG *hPsyConfLong, - PSY_CONFIGURATION_SHORT *hPsyConfShort, - PSY_OUT_CHANNEL psyOutChannel[MAX_CHANNELS], - PSY_OUT_ELEMENT *psyOutElement, - Word32 *pScratchTns, - Word32 sampleRate) -{ - Word16 maxSfbPerGroup[MAX_CHANNELS]; - Word16 mdctScalingArray[MAX_CHANNELS]; - - Word16 ch; /* counts through channels */ - Word16 sfb; /* counts through scalefactor bands */ - Word16 line; /* counts through lines */ - Word16 channels; - Word16 maxScale; - - channels = elemInfo->nChannelsInEl; - maxScale = 0; - - /* block switching */ - for(ch = 0; ch < channels; ch++) { - BlockSwitching(&psyData[ch].blockSwitchingControl, - timeSignal+elemInfo->ChannelIndex[ch], - sampleRate, - nChannels); - } - - /* synch left and right block type */ - SyncBlockSwitching(&psyData[0].blockSwitchingControl, - &psyData[1].blockSwitchingControl, - channels); - - /* transform - and get maxScale (max mdctScaling) for all channels */ - for(ch=0; chChannelIndex[ch], - nChannels, - psyData[ch].mdctSpectrum, - &(mdctScalingArray[ch]), - psyData[ch].blockSwitchingControl.windowSequence); - maxScale = max(maxScale, mdctScalingArray[ch]); - } - - /* common scaling for all channels */ - for (ch=0; ch 0) { - Word32 *Spectrum = psyData[ch].mdctSpectrum; - for(line=0; line> scaleDiff; - Spectrum++; - } - } - psyData[ch].mdctScale = maxScale; - } - - for (ch=0; chsfbCnt-1; sfb>=0; sfb--) { - for (line=hPsyConfLong->sfbOffset[sfb+1] - 1; line>=hPsyConfLong->sfbOffset[sfb]; line--) { - - if (psyData[ch].mdctSpectrum[line] != 0) break; - } - if (line >= hPsyConfLong->sfbOffset[sfb]) break; - } - maxSfbPerGroup[ch] = sfb + 1; - - /* Calc bandwise energies for mid and side channel - Do it only if 2 channels exist */ - - if (ch == 1) - advancePsychLongMS(psyData, hPsyConfLong); - } - else { - advancePsychShort(&psyData[ch], - &tnsData[ch], - hPsyConfShort, - &psyOutChannel[ch], - pScratchTns, - &tnsData[1 - ch], - ch); - - /* Calc bandwise energies for mid and side channel - Do it only if 2 channels exist */ - - if (ch == 1) - advancePsychShortMS (psyData, hPsyConfShort); - } - } - - /* group short data */ - for(ch=0; chsfbCnt, - hPsyConfShort->sfbOffset, - hPsyConfShort->sfbMinSnr, - psyOutElement->groupedSfbOffset[ch], - &maxSfbPerGroup[ch], - psyOutElement->groupedSfbMinSnr[ch], - psyData[ch].blockSwitchingControl.noOfGroups, - psyData[ch].blockSwitchingControl.groupLen); - } - } - - -#if (MAX_CHANNELS>1) - /* - stereo Processing - */ - if (channels == 2) { - psyOutElement->toolsInfo.msDigest = MS_NONE; - maxSfbPerGroup[0] = maxSfbPerGroup[1] = max(maxSfbPerGroup[0], maxSfbPerGroup[1]); - - - if (psyData[0].blockSwitchingControl.windowSequence != SHORT_WINDOW) - MsStereoProcessing(psyData[0].sfbEnergy.sfbLong, - psyData[1].sfbEnergy.sfbLong, - psyData[0].sfbEnergyMS.sfbLong, - psyData[1].sfbEnergyMS.sfbLong, - psyData[0].mdctSpectrum, - psyData[1].mdctSpectrum, - psyData[0].sfbThreshold.sfbLong, - psyData[1].sfbThreshold.sfbLong, - psyData[0].sfbSpreadedEnergy.sfbLong, - psyData[1].sfbSpreadedEnergy.sfbLong, - (Word16*)&psyOutElement->toolsInfo.msDigest, - (Word16*)psyOutElement->toolsInfo.msMask, - hPsyConfLong->sfbCnt, - hPsyConfLong->sfbCnt, - maxSfbPerGroup[0], - (const Word16*)hPsyConfLong->sfbOffset); - else - MsStereoProcessing(psyData[0].sfbEnergy.sfbLong, - psyData[1].sfbEnergy.sfbLong, - psyData[0].sfbEnergyMS.sfbLong, - psyData[1].sfbEnergyMS.sfbLong, - psyData[0].mdctSpectrum, - psyData[1].mdctSpectrum, - psyData[0].sfbThreshold.sfbLong, - psyData[1].sfbThreshold.sfbLong, - psyData[0].sfbSpreadedEnergy.sfbLong, - psyData[1].sfbSpreadedEnergy.sfbLong, - (Word16*)&psyOutElement->toolsInfo.msDigest, - (Word16*)psyOutElement->toolsInfo.msMask, - psyData[0].blockSwitchingControl.noOfGroups*hPsyConfShort->sfbCnt, - hPsyConfShort->sfbCnt, - maxSfbPerGroup[0], - (const Word16*)psyOutElement->groupedSfbOffset[0]); - } - -#endif /* (MAX_CHANNELS>1) */ - - /* - build output - */ - for(ch=0;chsfbCnt, - hPsyConfLong->sfbOffset, - maxSfbPerGroup[ch], - hPsyConfLong->sfbMinSnr, - psyData[ch].blockSwitchingControl.noOfGroups, - psyData[ch].blockSwitchingControl.groupLen, - &psyOutChannel[ch]); - else - BuildInterface(psyData[ch].mdctSpectrum, - psyData[ch].mdctScale, - &psyData[ch].sfbThreshold, - &psyData[ch].sfbEnergy, - &psyData[ch].sfbSpreadedEnergy, - psyData[ch].sfbEnergySum, - psyData[ch].sfbEnergySumMS, - SHORT_WINDOW, - SINE_WINDOW, - psyData[0].blockSwitchingControl.noOfGroups*hPsyConfShort->sfbCnt, - psyOutElement->groupedSfbOffset[ch], - maxSfbPerGroup[ch], - psyOutElement->groupedSfbMinSnr[ch], - psyData[ch].blockSwitchingControl.noOfGroups, - psyData[ch].blockSwitchingControl.groupLen, - &psyOutChannel[ch]); - } - - return(0); /* no error */ -} - -/***************************************************************************** -* -* function name: advancePsychLong -* description: psychoacoustic for long blocks -* -*****************************************************************************/ - -static Word16 advancePsychLong(PSY_DATA* psyData, - TNS_DATA* tnsData, - PSY_CONFIGURATION_LONG *hPsyConfLong, - PSY_OUT_CHANNEL* psyOutChannel, - Word32 *pScratchTns, - const TNS_DATA* tnsData2, - const Word16 ch) -{ - Word32 i; - Word32 normEnergyShift = (psyData->mdctScale + 1) << 1; /* in reference code, mdct spectrum must be multipied with 2, so +1 */ - Word32 clipEnergy = hPsyConfLong->clipEnergy >> normEnergyShift; - Word32 *data0, *data1, tdata; - - /* low pass */ - data0 = psyData->mdctSpectrum + hPsyConfLong->lowpassLine; - for(i=hPsyConfLong->lowpassLine; imdctSpectrum, - hPsyConfLong->sfbOffset, - hPsyConfLong->sfbActive, - psyData->sfbEnergy.sfbLong, - &psyData->sfbEnergySum.sfbLong); - - /* - TNS detect - */ - TnsDetect(tnsData, - hPsyConfLong->tnsConf, - pScratchTns, - (const Word16*)hPsyConfLong->sfbOffset, - psyData->mdctSpectrum, - 0, - psyData->blockSwitchingControl.windowSequence, - psyData->sfbEnergy.sfbLong); - - /* TnsSync */ - if (ch == 1) { - TnsSync(tnsData, - tnsData2, - hPsyConfLong->tnsConf, - 0, - psyData->blockSwitchingControl.windowSequence); - } - - /* Tns Encoder */ - TnsEncode(&psyOutChannel->tnsInfo, - tnsData, - hPsyConfLong->sfbCnt, - hPsyConfLong->tnsConf, - hPsyConfLong->lowpassLine, - psyData->mdctSpectrum, - 0, - psyData->blockSwitchingControl.windowSequence); - - /* first part of threshold calculation */ - data0 = psyData->sfbEnergy.sfbLong; - data1 = psyData->sfbThreshold.sfbLong; - for (i=hPsyConfLong->sfbCnt; i; i--) { - tdata = L_mpy_ls(*data0++, hPsyConfLong->ratio); - *data1++ = min(tdata, clipEnergy); - } - - /* Calc sfb-bandwise mdct-energies for left and right channel again */ - if (tnsData->dataRaw.tnsLong.subBlockInfo.tnsActive!=0) { - Word16 tnsStartBand = hPsyConfLong->tnsConf.tnsStartBand; - CalcBandEnergy( psyData->mdctSpectrum, - hPsyConfLong->sfbOffset+tnsStartBand, - hPsyConfLong->sfbActive - tnsStartBand, - psyData->sfbEnergy.sfbLong+tnsStartBand, - &psyData->sfbEnergySum.sfbLong); - - data0 = psyData->sfbEnergy.sfbLong; - tdata = psyData->sfbEnergySum.sfbLong; - for (i=0; isfbEnergySum.sfbLong = tdata; - } - - - /* spreading energy */ - SpreadingMax(hPsyConfLong->sfbCnt, - hPsyConfLong->sfbMaskLowFactor, - hPsyConfLong->sfbMaskHighFactor, - psyData->sfbThreshold.sfbLong); - - /* threshold in quiet */ - data0 = psyData->sfbThreshold.sfbLong; - data1 = hPsyConfLong->sfbThresholdQuiet; - for (i=hPsyConfLong->sfbCnt; i; i--) - { - *data0 = max(*data0, (*data1 >> normEnergyShift)); - data0++; data1++; - } - - /* preecho control */ - if (psyData->blockSwitchingControl.windowSequence == STOP_WINDOW) { - data0 = psyData->sfbThresholdnm1; - for (i=hPsyConfLong->sfbCnt; i; i--) { - *data0++ = MAX_32; - } - psyData->mdctScalenm1 = 0; - } - - PreEchoControl( psyData->sfbThresholdnm1, - hPsyConfLong->sfbCnt, - hPsyConfLong->maxAllowedIncreaseFactor, - hPsyConfLong->minRemainingThresholdFactor, - psyData->sfbThreshold.sfbLong, - psyData->mdctScale, - psyData->mdctScalenm1); - psyData->mdctScalenm1 = psyData->mdctScale; - - - if (psyData->blockSwitchingControl.windowSequence== START_WINDOW) { - data0 = psyData->sfbThresholdnm1; - for (i=hPsyConfLong->sfbCnt; i; i--) { - *data0++ = MAX_32; - } - psyData->mdctScalenm1 = 0; - } - - /* apply tns mult table on cb thresholds */ - ApplyTnsMultTableToRatios(hPsyConfLong->tnsConf.tnsRatioPatchLowestCb, - hPsyConfLong->tnsConf.tnsStartBand, - tnsData->dataRaw.tnsLong.subBlockInfo, - psyData->sfbThreshold.sfbLong); - - - /* spreaded energy */ - data0 = psyData->sfbSpreadedEnergy.sfbLong; - data1 = psyData->sfbEnergy.sfbLong; - for (i=hPsyConfLong->sfbCnt; i; i--) { - //psyData->sfbSpreadedEnergy.sfbLong[i] = psyData->sfbEnergy.sfbLong[i]; - *data0++ = *data1++; - } - - /* spreading energy */ - SpreadingMax(hPsyConfLong->sfbCnt, - hPsyConfLong->sfbMaskLowFactorSprEn, - hPsyConfLong->sfbMaskHighFactorSprEn, - psyData->sfbSpreadedEnergy.sfbLong); - - return 0; -} - -/***************************************************************************** -* -* function name: advancePsychLongMS -* description: update mdct-energies for left add or minus right channel -* for long block -* -*****************************************************************************/ -static Word16 advancePsychLongMS (PSY_DATA psyData[MAX_CHANNELS], - const PSY_CONFIGURATION_LONG *hPsyConfLong) -{ - CalcBandEnergyMS(psyData[0].mdctSpectrum, - psyData[1].mdctSpectrum, - hPsyConfLong->sfbOffset, - hPsyConfLong->sfbActive, - psyData[0].sfbEnergyMS.sfbLong, - &psyData[0].sfbEnergySumMS.sfbLong, - psyData[1].sfbEnergyMS.sfbLong, - &psyData[1].sfbEnergySumMS.sfbLong); - - return 0; -} - - -/***************************************************************************** -* -* function name: advancePsychShort -* description: psychoacoustic for short blocks -* -*****************************************************************************/ - -static Word16 advancePsychShort(PSY_DATA* psyData, - TNS_DATA* tnsData, - const PSY_CONFIGURATION_SHORT *hPsyConfShort, - PSY_OUT_CHANNEL* psyOutChannel, - Word32 *pScratchTns, - const TNS_DATA *tnsData2, - const Word16 ch) -{ - Word32 w; - Word32 normEnergyShift = (psyData->mdctScale + 1) << 1; /* in reference code, mdct spectrum must be multipied with 2, so +1 */ - Word32 clipEnergy = hPsyConfShort->clipEnergy >> normEnergyShift; - Word32 wOffset = 0; - Word32 *data0; - const Word32 *data1; - - for(w = 0; w < TRANS_FAC; w++) { - Word32 i, tdata; - - /* low pass */ - data0 = psyData->mdctSpectrum + wOffset + hPsyConfShort->lowpassLine; - for(i=hPsyConfShort->lowpassLine; imdctSpectrum+wOffset, - hPsyConfShort->sfbOffset, - hPsyConfShort->sfbActive, - psyData->sfbEnergy.sfbShort[w], - &psyData->sfbEnergySum.sfbShort[w]); - /* - TNS - */ - TnsDetect(tnsData, - hPsyConfShort->tnsConf, - pScratchTns, - (const Word16*)hPsyConfShort->sfbOffset, - psyData->mdctSpectrum+wOffset, - w, - psyData->blockSwitchingControl.windowSequence, - psyData->sfbEnergy.sfbShort[w]); - - /* TnsSync */ - if (ch == 1) { - TnsSync(tnsData, - tnsData2, - hPsyConfShort->tnsConf, - w, - psyData->blockSwitchingControl.windowSequence); - } - - TnsEncode(&psyOutChannel->tnsInfo, - tnsData, - hPsyConfShort->sfbCnt, - hPsyConfShort->tnsConf, - hPsyConfShort->lowpassLine, - psyData->mdctSpectrum+wOffset, - w, - psyData->blockSwitchingControl.windowSequence); - - /* first part of threshold calculation */ - data0 = psyData->sfbThreshold.sfbShort[w]; - data1 = psyData->sfbEnergy.sfbShort[w]; - for (i=hPsyConfShort->sfbCnt; i; i--) { - tdata = L_mpy_ls(*data1++, hPsyConfShort->ratio); - *data0++ = min(tdata, clipEnergy); - } - - /* Calc sfb-bandwise mdct-energies for left and right channel again */ - if (tnsData->dataRaw.tnsShort.subBlockInfo[w].tnsActive != 0) { - Word16 tnsStartBand = hPsyConfShort->tnsConf.tnsStartBand; - CalcBandEnergy( psyData->mdctSpectrum+wOffset, - hPsyConfShort->sfbOffset+tnsStartBand, - (hPsyConfShort->sfbActive - tnsStartBand), - psyData->sfbEnergy.sfbShort[w]+tnsStartBand, - &psyData->sfbEnergySum.sfbShort[w]); - - tdata = psyData->sfbEnergySum.sfbShort[w]; - data0 = psyData->sfbEnergy.sfbShort[w]; - for (i=tnsStartBand; i; i--) - tdata += *data0++; - - psyData->sfbEnergySum.sfbShort[w] = tdata; - } - - /* spreading */ - SpreadingMax(hPsyConfShort->sfbCnt, - hPsyConfShort->sfbMaskLowFactor, - hPsyConfShort->sfbMaskHighFactor, - psyData->sfbThreshold.sfbShort[w]); - - - /* threshold in quiet */ - data0 = psyData->sfbThreshold.sfbShort[w]; - data1 = hPsyConfShort->sfbThresholdQuiet; - for (i=hPsyConfShort->sfbCnt; i; i--) - { - *data0 = max(*data0, (*data1 >> normEnergyShift)); - - data0++; data1++; - } - - - /* preecho */ - PreEchoControl( psyData->sfbThresholdnm1, - hPsyConfShort->sfbCnt, - hPsyConfShort->maxAllowedIncreaseFactor, - hPsyConfShort->minRemainingThresholdFactor, - psyData->sfbThreshold.sfbShort[w], - psyData->mdctScale, - w==0 ? psyData->mdctScalenm1 : psyData->mdctScale); - - /* apply tns mult table on cb thresholds */ - ApplyTnsMultTableToRatios( hPsyConfShort->tnsConf.tnsRatioPatchLowestCb, - hPsyConfShort->tnsConf.tnsStartBand, - tnsData->dataRaw.tnsShort.subBlockInfo[w], - psyData->sfbThreshold.sfbShort[w]); - - /* spreaded energy */ - data0 = psyData->sfbSpreadedEnergy.sfbShort[w]; - data1 = psyData->sfbEnergy.sfbShort[w]; - for (i=hPsyConfShort->sfbCnt; i; i--) { - *data0++ = *data1++; - } - SpreadingMax(hPsyConfShort->sfbCnt, - hPsyConfShort->sfbMaskLowFactorSprEn, - hPsyConfShort->sfbMaskHighFactorSprEn, - psyData->sfbSpreadedEnergy.sfbShort[w]); - - wOffset += FRAME_LEN_SHORT; - } /* for TRANS_FAC */ - - psyData->mdctScalenm1 = psyData->mdctScale; - - return 0; -} - -/***************************************************************************** -* -* function name: advancePsychShortMS -* description: update mdct-energies for left add or minus right channel -* for short block -* -*****************************************************************************/ -static Word16 advancePsychShortMS (PSY_DATA psyData[MAX_CHANNELS], - const PSY_CONFIGURATION_SHORT *hPsyConfShort) -{ - Word32 w, wOffset; - wOffset = 0; - for(w=0; wsfbOffset, - hPsyConfShort->sfbActive, - psyData[0].sfbEnergyMS.sfbShort[w], - &psyData[0].sfbEnergySumMS.sfbShort[w], - psyData[1].sfbEnergyMS.sfbShort[w], - &psyData[1].sfbEnergySumMS.sfbShort[w]); - wOffset += FRAME_LEN_SHORT; - } - - return 0; -} diff --git a/android-aac-enc/jni/src/qc_main.c b/android-aac-enc/jni/src/qc_main.c deleted file mode 100644 index 48ff30087..000000000 --- a/android-aac-enc/jni/src/qc_main.c +++ /dev/null @@ -1,580 +0,0 @@ -/* - ** Copyright 2003-2010, VisualOn, Inc. - ** - ** Licensed under the Apache License, Version 2.0 (the "License"); - ** you may not use this file except in compliance with the License. - ** You may obtain a copy of the License at - ** - ** http://www.apache.org/licenses/LICENSE-2.0 - ** - ** Unless required by applicable law or agreed to in writing, software - ** distributed under the License is distributed on an "AS IS" BASIS, - ** WITHOUT 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: qc_main.c - - Content: Quantizing & coding functions - -*******************************************************************************/ - -#include "basic_op.h" -#include "oper_32b.h" -#include "qc_main.h" -#include "quantize.h" -#include "interface.h" -#include "adj_thr.h" -#include "sf_estim.h" -#include "stat_bits.h" -#include "bit_cnt.h" -#include "dyn_bits.h" -#include "channel_map.h" -#include "memalign.h" - - -typedef enum{ - FRAME_LEN_BYTES_MODULO = 1, - FRAME_LEN_BYTES_INT = 2 -}FRAME_LEN_RESULT_MODE; - -static const Word16 maxFillElemBits = 7 + 270*8; - -/* forward declarations */ - -static Word16 calcMaxValueInSfb(Word16 sfbCnt, - Word16 maxSfbPerGroup, - Word16 sfbPerGroup, - Word16 sfbOffset[MAX_GROUPED_SFB], - Word16 quantSpectrum[FRAME_LEN_LONG], - UWord16 maxValue[MAX_GROUPED_SFB]); - - -/***************************************************************************** -* -* function name: calcFrameLen -* description: estimate the frame length according the bitrates -* -*****************************************************************************/ -static Word16 calcFrameLen(Word32 bitRate, - Word32 sampleRate, - FRAME_LEN_RESULT_MODE mode) -{ - - Word32 result; - Word32 quot; - - result = (FRAME_LEN_LONG >> 3) * bitRate; - quot = result / sampleRate; - - - if (mode == FRAME_LEN_BYTES_MODULO) { - result -= quot * sampleRate; - } - else { /* FRAME_LEN_BYTES_INT */ - result = quot; - } - - return result; -} - -/***************************************************************************** -* -* function name:framePadding -* description: Calculates if padding is needed for actual frame -* returns: paddingOn or not -* -*****************************************************************************/ -static Word16 framePadding(Word32 bitRate, - Word32 sampleRate, - Word32 *paddingRest) -{ - Word16 paddingOn; - Word16 difference; - - paddingOn = 0; - - difference = calcFrameLen( bitRate, - sampleRate, - FRAME_LEN_BYTES_MODULO ); - *paddingRest = *paddingRest - difference; - - - if (*paddingRest <= 0 ) { - paddingOn = 1; - *paddingRest = *paddingRest + sampleRate; - } - - return paddingOn; -} - - -/********************************************************************************* -* -* function name: QCOutNew -* description: init qcout parameter -* returns: 0 if success -* -**********************************************************************************/ - -Word16 QCOutNew(QC_OUT *hQC, Word16 nChannels, VO_MEM_OPERATOR *pMemOP) -{ - Word32 i; - Word16 *quantSpec; - Word16 *scf; - UWord16 *maxValueInSfb; - - quantSpec = (Word16 *)mem_malloc(pMemOP, nChannels * FRAME_LEN_LONG * sizeof(Word16), 32, VO_INDEX_ENC_AAC); - if(NULL == quantSpec) - return 1; - scf = (Word16 *)mem_malloc(pMemOP, nChannels * MAX_GROUPED_SFB * sizeof(Word16), 32, VO_INDEX_ENC_AAC); - if(NULL == scf) - { - return 1; - } - maxValueInSfb = (UWord16 *)mem_malloc(pMemOP, nChannels * MAX_GROUPED_SFB * sizeof(UWord16), 32, VO_INDEX_ENC_AAC); - if(NULL == maxValueInSfb) - { - return 1; - } - - for (i=0; iqcChannel[i].quantSpec = quantSpec + i*FRAME_LEN_LONG; - - hQC->qcChannel[i].maxValueInSfb = maxValueInSfb + i*MAX_GROUPED_SFB; - - hQC->qcChannel[i].scf = scf + i*MAX_GROUPED_SFB; - } - - return 0; -} - - -/********************************************************************************* -* -* function name: QCOutDelete -* description: unint qcout parameter -* returns: 0 if success -* -**********************************************************************************/ -void QCOutDelete(QC_OUT* hQC, VO_MEM_OPERATOR *pMemOP) -{ - Word32 i; - if(hQC) - { - if(hQC->qcChannel[0].quantSpec) - mem_free(pMemOP, hQC->qcChannel[0].quantSpec, VO_INDEX_ENC_AAC); - - if(hQC->qcChannel[0].maxValueInSfb) - mem_free(pMemOP, hQC->qcChannel[0].maxValueInSfb, VO_INDEX_ENC_AAC); - - if(hQC->qcChannel[0].scf) - mem_free(pMemOP, hQC->qcChannel[0].scf, VO_INDEX_ENC_AAC); - - for (i=0; iqcChannel[i].quantSpec = NULL; - - hQC->qcChannel[i].maxValueInSfb = NULL; - - hQC->qcChannel[i].scf = NULL; - } - } -} - -/********************************************************************************* -* -* function name: QCNew -* description: set QC to zero -* returns: 0 if success -* -**********************************************************************************/ -Word16 QCNew(QC_STATE *hQC, VO_MEM_OPERATOR *pMemOP) -{ - pMemOP->Set(VO_INDEX_ENC_AAC, hQC,0,sizeof(QC_STATE)); - - return (0); -} - -/********************************************************************************* -* -* function name: QCDelete -* description: unint qcout parameter -* -**********************************************************************************/ -void QCDelete(QC_STATE *hQC, VO_MEM_OPERATOR *pMemOP) -{ - - /* - nothing to do - */ - hQC=NULL; -} - -/********************************************************************************* -* -* function name: QCInit -* description: init QD parameter -* returns: 0 if success -* -**********************************************************************************/ -Word16 QCInit(QC_STATE *hQC, - struct QC_INIT *init) -{ - hQC->nChannels = init->elInfo->nChannelsInEl; - hQC->maxBitsTot = init->maxBits; - hQC->bitResTot = sub(init->bitRes, init->averageBits); - hQC->averageBitsTot = init->averageBits; - hQC->maxBitFac = init->maxBitFac; - - hQC->padding.paddingRest = init->padding.paddingRest; - - hQC->globStatBits = 3; /* for ID_END */ - - /* channel elements init */ - InitElementBits(&hQC->elementBits, - *init->elInfo, - init->bitrate, - init->averageBits, - hQC->globStatBits); - - /* threshold parameter init */ - AdjThrInit(&hQC->adjThr, - init->meanPe, - hQC->elementBits.chBitrate); - - return 0; -} - - -/********************************************************************************* -* -* function name: QCMain -* description: quantization and coding the spectrum -* returns: 0 if success -* -**********************************************************************************/ -Word16 QCMain(QC_STATE* hQC, - ELEMENT_BITS* elBits, - ATS_ELEMENT* adjThrStateElement, - PSY_OUT_CHANNEL psyOutChannel[MAX_CHANNELS], /* may be modified in-place */ - PSY_OUT_ELEMENT* psyOutElement, - QC_OUT_CHANNEL qcOutChannel[MAX_CHANNELS], /* out */ - QC_OUT_ELEMENT* qcOutElement, - Word16 nChannels, - Word16 ancillaryDataBytes) -{ - Word16 maxChDynBits[MAX_CHANNELS]; - Word16 chBitDistribution[MAX_CHANNELS]; - Word32 ch; - - if (elBits->bitResLevel < 0) { - return -1; - } - - if (elBits->bitResLevel > elBits->maxBitResBits) { - return -1; - } - - qcOutElement->staticBitsUsed = countStaticBitdemand(psyOutChannel, - psyOutElement, - nChannels, - qcOutElement->adtsUsed); - - - if (ancillaryDataBytes) { - qcOutElement->ancBitsUsed = 7 + (ancillaryDataBytes << 3); - - if (ancillaryDataBytes >= 15) - qcOutElement->ancBitsUsed = qcOutElement->ancBitsUsed + 8; - } - else { - qcOutElement->ancBitsUsed = 0; - } - - CalcFormFactor(hQC->logSfbFormFactor, hQC->sfbNRelevantLines, hQC->logSfbEnergy, psyOutChannel, nChannels); - - /*adjust thresholds for the desired bitrate */ - AdjustThresholds(&hQC->adjThr, - adjThrStateElement, - psyOutChannel, - psyOutElement, - chBitDistribution, - hQC->logSfbEnergy, - hQC->sfbNRelevantLines, - qcOutElement, - elBits, - nChannels, - hQC->maxBitFac); - - /*estimate scale factors */ - EstimateScaleFactors(psyOutChannel, - qcOutChannel, - hQC->logSfbEnergy, - hQC->logSfbFormFactor, - hQC->sfbNRelevantLines, - nChannels); - - /* condition to prevent empty bitreservoir */ - for (ch = 0; ch < nChannels; ch++) { - Word32 maxDynBits; - maxDynBits = elBits->averageBits + elBits->bitResLevel - 7; /* -7 bec. of align bits */ - maxDynBits = maxDynBits - qcOutElement->staticBitsUsed + qcOutElement->ancBitsUsed; - maxChDynBits[ch] = extract_l(chBitDistribution[ch] * maxDynBits / 1000); - } - - qcOutElement->dynBitsUsed = 0; - for (ch = 0; ch < nChannels; ch++) { - Word32 chDynBits; - Flag constraintsFulfilled; - Word32 iter; - iter = 0; - do { - constraintsFulfilled = 1; - - QuantizeSpectrum(psyOutChannel[ch].sfbCnt, - psyOutChannel[ch].maxSfbPerGroup, - psyOutChannel[ch].sfbPerGroup, - psyOutChannel[ch].sfbOffsets, - psyOutChannel[ch].mdctSpectrum, - qcOutChannel[ch].globalGain, - qcOutChannel[ch].scf, - qcOutChannel[ch].quantSpec); - - if (calcMaxValueInSfb(psyOutChannel[ch].sfbCnt, - psyOutChannel[ch].maxSfbPerGroup, - psyOutChannel[ch].sfbPerGroup, - psyOutChannel[ch].sfbOffsets, - qcOutChannel[ch].quantSpec, - qcOutChannel[ch].maxValueInSfb) > MAX_QUANT) { - constraintsFulfilled = 0; - } - - chDynBits = dynBitCount(qcOutChannel[ch].quantSpec, - qcOutChannel[ch].maxValueInSfb, - qcOutChannel[ch].scf, - psyOutChannel[ch].windowSequence, - psyOutChannel[ch].sfbCnt, - psyOutChannel[ch].maxSfbPerGroup, - psyOutChannel[ch].sfbPerGroup, - psyOutChannel[ch].sfbOffsets, - &qcOutChannel[ch].sectionData); - - if (chDynBits >= maxChDynBits[ch]) { - constraintsFulfilled = 0; - } - - if (!constraintsFulfilled) { - qcOutChannel[ch].globalGain = qcOutChannel[ch].globalGain + 1; - } - - iter = iter + 1; - - } while(!constraintsFulfilled); - - qcOutElement->dynBitsUsed = qcOutElement->dynBitsUsed + chDynBits; - - qcOutChannel[ch].mdctScale = psyOutChannel[ch].mdctScale; - qcOutChannel[ch].groupingMask = psyOutChannel[ch].groupingMask; - qcOutChannel[ch].windowShape = psyOutChannel[ch].windowShape; - } - - /* save dynBitsUsed for correction of bits2pe relation */ - AdjThrUpdate(adjThrStateElement, qcOutElement->dynBitsUsed); - - { - Word16 bitResSpace = elBits->maxBitResBits - elBits->bitResLevel; - Word16 deltaBitRes = elBits->averageBits - - (qcOutElement->staticBitsUsed + - qcOutElement->dynBitsUsed + qcOutElement->ancBitsUsed); - - qcOutElement->fillBits = max(0, (deltaBitRes - bitResSpace)); - } - - return 0; /* OK */ -} - - -/********************************************************************************* -* -* function name: calcMaxValueInSfb -* description: search the max Spectrum in one sfb -* -**********************************************************************************/ -static Word16 calcMaxValueInSfb(Word16 sfbCnt, - Word16 maxSfbPerGroup, - Word16 sfbPerGroup, - Word16 sfbOffset[MAX_GROUPED_SFB], - Word16 quantSpectrum[FRAME_LEN_LONG], - UWord16 maxValue[MAX_GROUPED_SFB]) -{ - Word16 sfbOffs, sfb; - Word16 maxValueAll; - - maxValueAll = 0; - - for(sfbOffs=0;sfbOffsbitResTot = 0; - - elBits = &qcKernel->elementBits; - - - if (elBits->averageBits > 0) { - /* constant bitrate */ - Word16 bitsUsed; - bitsUsed = (qcOut->qcElement.staticBitsUsed + qcOut->qcElement.dynBitsUsed) + - (qcOut->qcElement.ancBitsUsed + qcOut->qcElement.fillBits); - elBits->bitResLevel = elBits->bitResLevel + (elBits->averageBits - bitsUsed); - qcKernel->bitResTot = qcKernel->bitResTot + elBits->bitResLevel; - } - else { - /* variable bitrate */ - elBits->bitResLevel = elBits->maxBits; - qcKernel->bitResTot = qcKernel->maxBitsTot; - } -} - -/********************************************************************************* -* -* function name: FinalizeBitConsumption -* description: count bits used -* -**********************************************************************************/ -Word16 FinalizeBitConsumption(QC_STATE *qcKernel, - QC_OUT* qcOut) -{ - Word32 nFullFillElem; - Word32 totFillBits; - Word16 diffBits; - Word16 bitsUsed; - - totFillBits = 0; - - qcOut->totStaticBitsUsed = qcKernel->globStatBits; - qcOut->totStaticBitsUsed += qcOut->qcElement.staticBitsUsed; - qcOut->totDynBitsUsed = qcOut->qcElement.dynBitsUsed; - qcOut->totAncBitsUsed = qcOut->qcElement.ancBitsUsed; - qcOut->totFillBits = qcOut->qcElement.fillBits; - - if (qcOut->qcElement.fillBits) { - totFillBits += qcOut->qcElement.fillBits; - } - - nFullFillElem = (max((qcOut->totFillBits - 1), 0) / maxFillElemBits) * maxFillElemBits; - - qcOut->totFillBits = qcOut->totFillBits - nFullFillElem; - - /* check fill elements */ - - if (qcOut->totFillBits > 0) { - /* minimum Fillelement contains 7 (TAG + byte cnt) bits */ - qcOut->totFillBits = max(7, qcOut->totFillBits); - /* fill element size equals n*8 + 7 */ - qcOut->totFillBits = qcOut->totFillBits + ((8 - ((qcOut->totFillBits - 7) & 0x0007)) & 0x0007); - } - - qcOut->totFillBits = qcOut->totFillBits + nFullFillElem; - - /* now distribute extra fillbits and alignbits over channel elements */ - qcOut->alignBits = 7 - ((qcOut->totDynBitsUsed + qcOut->totStaticBitsUsed + - qcOut->totAncBitsUsed + qcOut->totFillBits - 1) & 0x0007); - - - if ( (qcOut->alignBits + qcOut->totFillBits - totFillBits == 8) && - (qcOut->totFillBits > 8)) - qcOut->totFillBits = qcOut->totFillBits - 8; - - - diffBits = qcOut->alignBits + qcOut->totFillBits - totFillBits; - - if(diffBits>=0) { - qcOut->qcElement.fillBits += diffBits; - } - - bitsUsed = qcOut->totDynBitsUsed + qcOut->totStaticBitsUsed + qcOut->totAncBitsUsed; - bitsUsed = bitsUsed + qcOut->totFillBits + qcOut->alignBits; - - if (bitsUsed > qcKernel->maxBitsTot) { - return -1; - } - return bitsUsed; -} - - -/********************************************************************************* -* -* function name: AdjustBitrate -* description: adjusts framelength via padding on a frame to frame basis, -* to achieve a bitrate that demands a non byte aligned -* framelength -* return: errorcode -* -**********************************************************************************/ -Word16 AdjustBitrate(QC_STATE *hQC, - Word32 bitRate, /* total bitrate */ - Word32 sampleRate) /* output sampling rate */ -{ - Word16 paddingOn; - Word16 frameLen; - Word16 codeBits; - Word16 codeBitsLast; - - /* Do we need a extra padding byte? */ - paddingOn = framePadding(bitRate, - sampleRate, - &hQC->padding.paddingRest); - - /* frame length */ - frameLen = paddingOn + calcFrameLen(bitRate, - sampleRate, - FRAME_LEN_BYTES_INT); - - frameLen = frameLen << 3; - codeBitsLast = hQC->averageBitsTot - hQC->globStatBits; - codeBits = frameLen - hQC->globStatBits; - - /* calculate bits for every channel element */ - if (codeBits != codeBitsLast) { - Word16 totalBits = 0; - - hQC->elementBits.averageBits = (hQC->elementBits.relativeBits * codeBits) >> 16; /* relativeBits was scaled down by 2 */ - totalBits += hQC->elementBits.averageBits; - - hQC->elementBits.averageBits = hQC->elementBits.averageBits + (codeBits - totalBits); - } - - hQC->averageBitsTot = frameLen; - - return 0; -} diff --git a/android-aac-enc/jni/src/quantize.c b/android-aac-enc/jni/src/quantize.c deleted file mode 100644 index 0d0f55040..000000000 --- a/android-aac-enc/jni/src/quantize.c +++ /dev/null @@ -1,445 +0,0 @@ -/* - ** Copyright 2003-2010, VisualOn, Inc. - ** - ** Licensed under the Apache License, Version 2.0 (the "License"); - ** you may not use this file except in compliance with the License. - ** You may obtain a copy of the License at - ** - ** http://www.apache.org/licenses/LICENSE-2.0 - ** - ** Unless required by applicable law or agreed to in writing, software - ** distributed under the License is distributed on an "AS IS" BASIS, - ** WITHOUT 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: quantize.c - - Content: quantization functions - -*******************************************************************************/ - -#include "typedef.h" -#include "basic_op.h" -#include "oper_32b.h" -#include "quantize.h" -#include "aac_rom.h" - -#define MANT_DIGITS 9 -#define MANT_SIZE (1<> (INT_BITS-2-MANT_DIGITS)) & (MANT_SIZE-1)]; -} - - -/***************************************************************************** -* -* function name:quantizeSingleLine -* description: quantizes spectrum -* quaSpectrum = mdctSpectrum^3/4*2^(-(3/16)*gain) -* -*****************************************************************************/ -static Word16 quantizeSingleLine(const Word16 gain, const Word32 absSpectrum) -{ - Word32 e, minusFinalExp, finalShift; - Word32 x; - Word16 qua = 0; - - - if (absSpectrum) { - e = norm_l(absSpectrum); - x = pow34(absSpectrum << e); - - /* calculate the final fractional exponent times 16 (was 3*(4*e + gain) + (INT_BITS-1)*16) */ - minusFinalExp = (e << 2) + gain; - minusFinalExp = (minusFinalExp << 1) + minusFinalExp; - minusFinalExp = minusFinalExp + ((INT_BITS-1) << 4); - - /* separate the exponent into a shift, and a multiply */ - finalShift = minusFinalExp >> 4; - - if (finalShift < INT_BITS) { - x = L_mpy_wx(x, pow2tominusNover16[minusFinalExp & 15]); - - x += XROUND >> (INT_BITS - finalShift); - - /* shift and quantize */ - finalShift--; - - if(finalShift >= 0) - x >>= finalShift; - else - x <<= (-finalShift); - - qua = saturate(x); - } - } - - return qua; -} - -/***************************************************************************** -* -* function name:quantizeLines -* description: quantizes spectrum lines -* quaSpectrum = mdctSpectrum^3/4*2^(-(3/16)*gain) -* input: global gain, number of lines to process, spectral data -* output: quantized spectrum -* -*****************************************************************************/ -static void quantizeLines(const Word16 gain, - const Word16 noOfLines, - const Word32 *mdctSpectrum, - Word16 *quaSpectrum) -{ - Word32 line; - Word32 m = gain&3; - Word32 g = (gain >> 2) + 4; - Word32 mdctSpeL; - const Word16 *pquat; - /* gain&3 */ - - pquat = quantBorders[m]; - - g += 16; - - if(g >= 0) - { - for (line=0; line> g; - - if (saShft > pquat[0]) { - - if (saShft < pquat[1]) { - - qua = mdctSpeL>0 ? 1 : -1; - } - else { - - if (saShft < pquat[2]) { - - qua = mdctSpeL>0 ? 2 : -2; - } - else { - - if (saShft < pquat[3]) { - - qua = mdctSpeL>0 ? 3 : -3; - } - else { - qua = quantizeSingleLine(gain, sa); - /* adjust the sign. Since 0 < qua < 1, this cannot overflow. */ - - if (mdctSpeL < 0) - qua = -qua; - } - } - } - } - } - quaSpectrum[line] = qua ; - } - } - else - { - for (line=0; line pquat[0]) { - - if (saShft < pquat[1]) { - - qua = mdctSpeL>0 ? 1 : -1; - } - else { - - if (saShft < pquat[2]) { - - qua = mdctSpeL>0 ? 2 : -2; - } - else { - - if (saShft < pquat[3]) { - - qua = mdctSpeL>0 ? 3 : -3; - } - else { - qua = quantizeSingleLine(gain, sa); - /* adjust the sign. Since 0 < qua < 1, this cannot overflow. */ - - if (mdctSpeL < 0) - qua = -qua; - } - } - } - } - } - quaSpectrum[line] = qua ; - } - } - -} - - -/***************************************************************************** -* -* function name:iquantizeLines -* description: iquantizes spectrum lines without sign -* mdctSpectrum = iquaSpectrum^4/3 *2^(0.25*gain) -* input: global gain, number of lines to process,quantized spectrum -* output: spectral data -* -*****************************************************************************/ -static void iquantizeLines(const Word16 gain, - const Word16 noOfLines, - const Word16 *quantSpectrum, - Word32 *mdctSpectrum) -{ - Word32 iquantizermod; - Word32 iquantizershift; - Word32 line; - - iquantizermod = gain & 3; - iquantizershift = gain >> 2; - - for (line=0; line> (INT_BITS-2-MANT_DIGITS)) & (~MANT_SIZE); - - /* calculate "mantissa" ^4/3 */ - s = mTab_4_3[tabIndex]; - - /* get approperiate exponent multiplier for specExp^3/4 combined with scfMod */ - t = specExpMantTableComb_enc[iquantizermod][specExp]; - - /* multiply "mantissa" ^4/3 with exponent multiplier */ - accu = MULHIGH(s, t); - - /* get approperiate exponent shifter */ - specExp = specExpTableComb_enc[iquantizermod][specExp]; - - specExp += iquantizershift + 1; - if(specExp >= 0) - mdctSpectrum[line] = accu << specExp; - else - mdctSpectrum[line] = accu >> (-specExp); - } - else { - mdctSpectrum[line] = 0; - } - } -} - -/***************************************************************************** -* -* function name: QuantizeSpectrum -* description: quantizes the entire spectrum -* returns: -* input: number of scalefactor bands to be quantized, ... -* output: quantized spectrum -* -*****************************************************************************/ -void QuantizeSpectrum(Word16 sfbCnt, - Word16 maxSfbPerGroup, - Word16 sfbPerGroup, - Word16 *sfbOffset, - Word32 *mdctSpectrum, - Word16 globalGain, - Word16 *scalefactors, - Word16 *quantizedSpectrum) -{ - Word32 sfbOffs, sfb; - - for(sfbOffs=0;sfbOffs> 2) + 4; - Word32 g2 = (g << 1) + 1; - const Word16 *pquat, *repquat; - /* gain&3 */ - - pquat = quantBorders[m]; - repquat = quantRecon[m]; - - dist = 0; - g += 16; - if(g2 < 0 && g >= 0) - { - g2 = -g2; - for(line=0; line> g; - - if (saShft < pquat[0]) { - distSingle = (saShft * saShft) >> g2; - } - else { - - if (saShft < pquat[1]) { - diff = saShft - repquat[0]; - distSingle = (diff * diff) >> g2; - } - else { - - if (saShft < pquat[2]) { - diff = saShft - repquat[1]; - distSingle = (diff * diff) >> g2; - } - else { - - if (saShft < pquat[3]) { - diff = saShft - repquat[2]; - distSingle = (diff * diff) >> g2; - } - else { - Word16 qua = quantizeSingleLine(gain, sa); - Word32 iqval, diff32; - /* now that we have quantized x, re-quantize it. */ - iquantizeLines(gain, 1, &qua, &iqval); - diff32 = sa - iqval; - distSingle = fixmul(diff32, diff32); - } - } - } - } - - dist = L_add(dist, distSingle); - } - } - } - else - { - for(line=0; line> 1; - preshift = postshift << 1; - postshift = postshift + 8; /* sqrt/256 */ - if(preshift >= 0) - y = x << preshift; /* now 1/4 <= y < 1 */ - else - y = x >> (-preshift); - y = formfac_sqrttable[y-32]; - - if(postshift >= 0) - y = y >> postshift; - else - y = y << (-postshift); - - return y; -} - - -/********************************************************************************* -* -* function name: CalcFormFactorChannel -* description: calculate the form factor one channel -* ffac(n) = sqrt(abs(X(k)) + sqrt(abs(X(k+1)) + .... -* -**********************************************************************************/ -static void -CalcFormFactorChannel(Word16 *logSfbFormFactor, - Word16 *sfbNRelevantLines, - Word16 *logSfbEnergy, - PSY_OUT_CHANNEL *psyOutChan) -{ - Word32 sfbw, sfbw1; - Word32 i, j; - Word32 sfbOffs, sfb, shift; - - sfbw = sfbw1 = 0; - for (sfbOffs=0; sfbOffssfbCnt; sfbOffs+=psyOutChan->sfbPerGroup){ - for (sfb=0; sfbmaxSfbPerGroup; sfb++) { - i = sfbOffs+sfb; - - if (psyOutChan->sfbEnergy[i] > psyOutChan->sfbThreshold[i]) { - Word32 accu, avgFormFactor,iSfbWidth; - Word32 *mdctSpec; - sfbw = psyOutChan->sfbOffsets[i+1] - psyOutChan->sfbOffsets[i]; - iSfbWidth = invSBF[(sfbw >> 2) - 1]; - mdctSpec = psyOutChan->mdctSpectrum + psyOutChan->sfbOffsets[i]; - accu = 0; - /* calc sum of sqrt(spec) */ - for (j=sfbw; j; j--) { - accu += formfac_sqrt(L_abs(*mdctSpec)); mdctSpec++; - } - logSfbFormFactor[i] = iLog4(accu); - logSfbEnergy[i] = iLog4(psyOutChan->sfbEnergy[i]); - avgFormFactor = fixmul(rsqrt(psyOutChan->sfbEnergy[i],INT_BITS), iSfbWidth); - avgFormFactor = rsqrt((Word32)avgFormFactor,INT_BITS) >> 10; - /* result is multiplied by 4 */ - if(avgFormFactor) - sfbNRelevantLines[i] = accu / avgFormFactor; - else - sfbNRelevantLines[i] = 0x7fff; - } - else { - /* set number of lines to zero */ - sfbNRelevantLines[i] = 0; - } - } - } -} - -/********************************************************************************* -* -* function name: improveScf -* description: find better scalefactor with analysis by synthesis -* -**********************************************************************************/ -static Word16 improveScf(Word32 *spec, - Word16 sfbWidth, - Word32 thresh, - Word16 scf, - Word16 minScf, - Word32 *dist, - Word16 *minScfCalculated) -{ - Word32 cnt; - Word32 sfbDist; - Word32 scfBest; - Word32 thresh125 = L_add(thresh, (thresh >> 2)); - - scfBest = scf; - - /* calc real distortion */ - sfbDist = calcSfbDist(spec, sfbWidth, scf); - *minScfCalculated = scf; - if(!sfbDist) - return scfBest; - - if (sfbDist > thresh125) { - Word32 scfEstimated; - Word32 sfbDistBest; - scfEstimated = scf; - sfbDistBest = sfbDist; - - cnt = 0; - while (sfbDist > thresh125 && (cnt < 3)) { - - scf = scf + 1; - sfbDist = calcSfbDist(spec, sfbWidth, scf); - - if (sfbDist < sfbDistBest) { - scfBest = scf; - sfbDistBest = sfbDist; - } - cnt = cnt + 1; - } - cnt = 0; - scf = scfEstimated; - sfbDist = sfbDistBest; - while ((sfbDist > thresh125) && (cnt < 1) && (scf > minScf)) { - - scf = scf - 1; - sfbDist = calcSfbDist(spec, sfbWidth, scf); - - if (sfbDist < sfbDistBest) { - scfBest = scf; - sfbDistBest = sfbDist; - } - *minScfCalculated = scf; - cnt = cnt + 1; - } - *dist = sfbDistBest; - } - else { - Word32 sfbDistBest; - Word32 sfbDistAllowed; - Word32 thresh08 = fixmul(COEF08_31, thresh); - sfbDistBest = sfbDist; - - if (sfbDist < thresh08) - sfbDistAllowed = sfbDist; - else - sfbDistAllowed = thresh08; - for (cnt=0; cnt<3; cnt++) { - scf = scf + 1; - sfbDist = calcSfbDist(spec, sfbWidth, scf); - - if (fixmul(COEF08_31,sfbDist) < sfbDistAllowed) { - *minScfCalculated = scfBest + 1; - scfBest = scf; - sfbDistBest = sfbDist; - } - } - *dist = sfbDistBest; - } - - /* return best scalefactor */ - return scfBest; -} - -/********************************************************************************* -* -* function name: countSingleScfBits -* description: count single scf bits in huffum -* -**********************************************************************************/ -static Word16 countSingleScfBits(Word16 scf, Word16 scfLeft, Word16 scfRight) -{ - Word16 scfBits; - - scfBits = bitCountScalefactorDelta(scfLeft - scf) + - bitCountScalefactorDelta(scf - scfRight); - - return scfBits; -} - -/********************************************************************************* -* -* function name: calcSingleSpecPe -* description: ldRatio = log2(en(n)) - 0,375*scfGain(n) -* nbits = 0.7*nLines*ldRation for ldRation >= c1 -* nbits = 0.7*nLines*(c2 + c3*ldRatio) for ldRation < c1 -* -**********************************************************************************/ -static Word16 calcSingleSpecPe(Word16 scf, Word16 sfbConstPePart, Word16 nLines) -{ - Word32 specPe; - Word32 ldRatio; - Word32 scf3; - - ldRatio = sfbConstPePart << 3; /* (sfbConstPePart -0.375*scf)*8 */ - scf3 = scf + scf + scf; - ldRatio = ldRatio - scf3; - - if (ldRatio < PE_C1_8) { - /* 21 : 2*8*PE_C2, 2*PE_C3 ~ 1*/ - ldRatio = (ldRatio + PE_C2_16) >> 1; - } - specPe = nLines * ldRatio; - specPe = (specPe * PE_SCALE) >> 14; - - return saturate(specPe); -} - - -/********************************************************************************* -* -* function name: countScfBitsDiff -* description: count different scf bits used -* -**********************************************************************************/ -static Word16 countScfBitsDiff(Word16 *scfOld, Word16 *scfNew, - Word16 sfbCnt, Word16 startSfb, Word16 stopSfb) -{ - Word32 scfBitsDiff; - Word32 sfb, sfbLast; - Word32 sfbPrev, sfbNext; - - scfBitsDiff = 0; - sfb = 0; - - /* search for first relevant sfb */ - sfbLast = startSfb; - while (sfbLast < stopSfb && scfOld[sfbLast] == VOAAC_SHRT_MIN) { - - sfbLast = sfbLast + 1; - } - /* search for previous relevant sfb and count diff */ - sfbPrev = startSfb - 1; - while ((sfbPrev>=0) && scfOld[sfbPrev] == VOAAC_SHRT_MIN) { - - sfbPrev = sfbPrev - 1; - } - - if (sfbPrev>=0) { - scfBitsDiff += bitCountScalefactorDelta(scfNew[sfbPrev] - scfNew[sfbLast]) - - bitCountScalefactorDelta(scfOld[sfbPrev] - scfOld[sfbLast]); - } - /* now loop through all sfbs and count diffs of relevant sfbs */ - for (sfb=sfbLast+1; sfb> 2; - } - - - ldRatioOld = sfbConstPePart[sfb] << 3; - scf3 = scfOld[sfb] + scfOld[sfb] + scfOld[sfb]; - ldRatioOld = ldRatioOld - scf3; - ldRatioNew = sfbConstPePart[sfb] << 3; - scf3 = scfNew[sfb] + scfNew[sfb] + scfNew[sfb]; - ldRatioNew = ldRatioNew - scf3; - - if (ldRatioOld < PE_C1_8) { - /* 21 : 2*8*PE_C2, 2*PE_C3 ~ 1*/ - ldRatioOld = (ldRatioOld + PE_C2_16) >> 1; - } - - if (ldRatioNew < PE_C1_8) { - /* 21 : 2*8*PE_C2, 2*PE_C3 ~ 1*/ - ldRatioNew = (ldRatioNew + PE_C2_16) >> 1; - } - - specPeDiff += sfbNRelevantLines[sfb] * (ldRatioNew - ldRatioOld); - } - } - - specPeDiff = (specPeDiff * PE_SCALE) >> 14; - - return saturate(specPeDiff); -} - - -/********************************************************************************* -* -* function name: assimilateSingleScf -* description: searched for single scalefactor bands, where the number of bits gained -* by using a smaller scfgain(n) is greater than the estimated increased -* bit demand -* -**********************************************************************************/ -static void assimilateSingleScf(PSY_OUT_CHANNEL *psyOutChan, - Word16 *scf, - Word16 *minScf, - Word32 *sfbDist, - Word16 *sfbConstPePart, - Word16 *logSfbEnergy, - Word16 *logSfbFormFactor, - Word16 *sfbNRelevantLines, - Word16 *minScfCalculated, - Flag restartOnSuccess) -{ - Word16 sfbLast, sfbAct, sfbNext, scfAct, scfMin; - Word16 *scfLast, *scfNext; - Word32 sfbPeOld, sfbPeNew; - Word32 sfbDistNew; - Word32 j; - Flag success; - Word16 deltaPe, deltaPeNew, deltaPeTmp; - Word16 *prevScfLast = psyOutChan->prevScfLast; - Word16 *prevScfNext = psyOutChan->prevScfNext; - Word16 *deltaPeLast = psyOutChan->deltaPeLast; - Flag updateMinScfCalculated; - - success = 0; - deltaPe = 0; - - for(j=0;jsfbCnt;j++){ - prevScfLast[j] = MAX_16; - prevScfNext[j] = MAX_16; - deltaPeLast[j] = MAX_16; - } - - sfbLast = -1; - sfbAct = -1; - sfbNext = -1; - scfLast = 0; - scfNext = 0; - scfMin = MAX_16; - do { - /* search for new relevant sfb */ - sfbNext = sfbNext + 1; - while (sfbNext < psyOutChan->sfbCnt && scf[sfbNext] == MIN_16) { - - sfbNext = sfbNext + 1; - } - - if ((sfbLast>=0) && (sfbAct>=0) && sfbNext < psyOutChan->sfbCnt) { - /* relevant scfs to the left and to the right */ - scfAct = scf[sfbAct]; - scfLast = scf + sfbLast; - scfNext = scf + sfbNext; - scfMin = min(*scfLast, *scfNext); - } - else { - - if (sfbLast == -1 && (sfbAct>=0) && sfbNext < psyOutChan->sfbCnt) { - /* first relevant scf */ - scfAct = scf[sfbAct]; - scfLast = &scfAct; - scfNext = scf + sfbNext; - scfMin = *scfNext; - } - else { - - if ((sfbLast>=0) && (sfbAct>=0) && sfbNext == psyOutChan->sfbCnt) { - /* last relevant scf */ - scfAct = scf[sfbAct]; - scfLast = scf + sfbLast; - scfNext = &scfAct; - scfMin = *scfLast; - } - } - } - - if (sfbAct>=0) - scfMin = max(scfMin, minScf[sfbAct]); - - if ((sfbAct >= 0) && - (sfbLast>=0 || sfbNext < psyOutChan->sfbCnt) && - scfAct > scfMin && - (*scfLast != prevScfLast[sfbAct] || - *scfNext != prevScfNext[sfbAct] || - deltaPe < deltaPeLast[sfbAct])) { - success = 0; - - /* estimate required bits for actual scf */ - if (sfbConstPePart[sfbAct] == MIN_16) { - sfbConstPePart[sfbAct] = logSfbEnergy[sfbAct] - - logSfbFormFactor[sfbAct] + 11-8*4; /* 4*log2(6.75) - 32 */ - - if (sfbConstPePart[sfbAct] < 0) - sfbConstPePart[sfbAct] = sfbConstPePart[sfbAct] + 3; - sfbConstPePart[sfbAct] = sfbConstPePart[sfbAct] >> 2; - } - - sfbPeOld = calcSingleSpecPe(scfAct, sfbConstPePart[sfbAct], sfbNRelevantLines[sfbAct]) + - countSingleScfBits(scfAct, *scfLast, *scfNext); - deltaPeNew = deltaPe; - updateMinScfCalculated = 1; - do { - scfAct = scfAct - 1; - /* check only if the same check was not done before */ - - if (scfAct < minScfCalculated[sfbAct]) { - sfbPeNew = calcSingleSpecPe(scfAct, sfbConstPePart[sfbAct], sfbNRelevantLines[sfbAct]) + - countSingleScfBits(scfAct, *scfLast, *scfNext); - /* use new scf if no increase in pe and - quantization error is smaller */ - deltaPeTmp = deltaPe + sfbPeNew - sfbPeOld; - - if (deltaPeTmp < 10) { - sfbDistNew = calcSfbDist(psyOutChan->mdctSpectrum+ - psyOutChan->sfbOffsets[sfbAct], - (psyOutChan->sfbOffsets[sfbAct+1] - psyOutChan->sfbOffsets[sfbAct]), - scfAct); - if (sfbDistNew < sfbDist[sfbAct]) { - /* success, replace scf by new one */ - scf[sfbAct] = scfAct; - sfbDist[sfbAct] = sfbDistNew; - deltaPeNew = deltaPeTmp; - success = 1; - } - /* mark as already checked */ - - if (updateMinScfCalculated) { - minScfCalculated[sfbAct] = scfAct; - } - } - else { - updateMinScfCalculated = 0; - } - } - - } while (scfAct > scfMin); - deltaPe = deltaPeNew; - /* save parameters to avoid multiple computations of the same sfb */ - prevScfLast[sfbAct] = *scfLast; - prevScfNext[sfbAct] = *scfNext; - deltaPeLast[sfbAct] = deltaPe; - } - - if (success && restartOnSuccess) { - /* start again at first sfb */ - sfbLast = -1; - sfbAct = -1; - sfbNext = -1; - scfLast = 0; - scfNext = 0; - scfMin = MAX_16; - success = 0; - } - else { - /* shift sfbs for next band */ - sfbLast = sfbAct; - sfbAct = sfbNext; - } - - } while (sfbNext < psyOutChan->sfbCnt); -} - - -/********************************************************************************* -* -* function name: assimilateMultipleScf -* description: scalefactor difference reduction -* -**********************************************************************************/ -static void assimilateMultipleScf(PSY_OUT_CHANNEL *psyOutChan, - Word16 *scf, - Word16 *minScf, - Word32 *sfbDist, - Word16 *sfbConstPePart, - Word16 *logSfbEnergy, - Word16 *logSfbFormFactor, - Word16 *sfbNRelevantLines) -{ - Word32 sfb, startSfb, stopSfb, scfMin, scfMax, scfAct; - Flag possibleRegionFound; - Word32 deltaScfBits; - Word32 deltaSpecPe; - Word32 deltaPe, deltaPeNew; - Word32 sfbCnt; - Word32 *sfbDistNew = psyOutChan->sfbDistNew; - Word16 *scfTmp = psyOutChan->prevScfLast; - - deltaPe = 0; - sfbCnt = psyOutChan->sfbCnt; - - /* calc min and max scalfactors */ - scfMin = MAX_16; - scfMax = MIN_16; - for (sfb=0; sfb scfAct)) { - sfb = sfb + 1; - } - stopSfb = sfb; - - possibleRegionFound = 0; - - if (startSfb < sfbCnt) { - possibleRegionFound = 1; - for (sfb=startSfb; sfbmdctSpectrum + - psyOutChan->sfbOffsets[sfb], - (psyOutChan->sfbOffsets[sfb+1] - psyOutChan->sfbOffsets[sfb]), - scfAct); - - - if (sfbDistNew[sfb] > psyOutChan->sfbThreshold[sfb]) { - distNewSum = distOldSum << 1; - break; - } - distNewSum = L_add(distNewSum, sfbDistNew[sfb]); - } - } - - if (distNewSum < distOldSum) { - deltaPe = deltaPeNew; - for (sfb=startSfb; sfb scfMin); - } -} - -/********************************************************************************* -* -* function name: EstimateScaleFactorsChannel -* description: estimate scale factors for one channel -* -**********************************************************************************/ -static void -EstimateScaleFactorsChannel(PSY_OUT_CHANNEL *psyOutChan, - Word16 *scf, - Word16 *globalGain, - Word16 *logSfbEnergy, - Word16 *logSfbFormFactor, - Word16 *sfbNRelevantLines) -{ - Word32 i, j; - Word32 thresh, energy; - Word32 energyPart, thresholdPart; - Word32 scfInt, minScf, maxScf, maxAllowedScf, lastSf; - Word32 maxSpec; - Word32 *sfbDist = psyOutChan->sfbDist; - Word16 *minSfMaxQuant = psyOutChan->minSfMaxQuant; - Word16 *minScfCalculated = psyOutChan->minScfCalculated; - - - for (i=0; isfbCnt; i++) { - Word32 sbfwith, sbfStart; - Word32 *mdctSpec; - thresh = psyOutChan->sfbThreshold[i]; - energy = psyOutChan->sfbEnergy[i]; - - sbfStart = psyOutChan->sfbOffsets[i]; - sbfwith = psyOutChan->sfbOffsets[i+1] - sbfStart; - mdctSpec = psyOutChan->mdctSpectrum+sbfStart; - - maxSpec = 0; - /* maximum of spectrum */ - for (j=sbfwith; j; j-- ) { - Word32 absSpec = L_abs(*mdctSpec); mdctSpec++; - maxSpec |= absSpec; - } - - /* scfs without energy or with thresh>energy are marked with MIN_16 */ - scf[i] = MIN_16; - minSfMaxQuant[i] = MIN_16; - - if ((maxSpec > 0) && (energy > thresh)) { - - energyPart = logSfbFormFactor[i]; - thresholdPart = iLog4(thresh); - /* -20 = 4*log2(6.75) - 32 */ - scfInt = ((thresholdPart - energyPart - 20) * SCALE_ESTIMATE_COEF) >> 15; - - minSfMaxQuant[i] = iLog4(maxSpec) - 68; /* 68 -16/3*log(MAX_QUANT+0.5-logCon)/log(2) + 1 */ - - - if (minSfMaxQuant[i] > scfInt) { - scfInt = minSfMaxQuant[i]; - } - - /* find better scalefactor with analysis by synthesis */ - scfInt = improveScf(psyOutChan->mdctSpectrum+sbfStart, - sbfwith, - thresh, scfInt, minSfMaxQuant[i], - &sfbDist[i], &minScfCalculated[i]); - - scf[i] = scfInt; - } - } - - - /* scalefactor differece reduction */ - { - Word16 sfbConstPePart[MAX_GROUPED_SFB]; - for(i=0;isfbCnt;i++) { - sfbConstPePart[i] = MIN_16; - } - - assimilateSingleScf(psyOutChan, scf, - minSfMaxQuant, sfbDist, sfbConstPePart, logSfbEnergy, - logSfbFormFactor, sfbNRelevantLines, minScfCalculated, 1); - - assimilateMultipleScf(psyOutChan, scf, - minSfMaxQuant, sfbDist, sfbConstPePart, logSfbEnergy, - logSfbFormFactor, sfbNRelevantLines); - } - - /* get max scalefac for global gain */ - maxScf = MIN_16; - minScf = MAX_16; - for (i=0; isfbCnt; i++) { - - if (maxScf < scf[i]) { - maxScf = scf[i]; - } - - if ((scf[i] != MIN_16) && (minScf > scf[i])) { - minScf = scf[i]; - } - } - /* limit scf delta */ - maxAllowedScf = minScf + MAX_SCF_DELTA; - for(i=0; isfbCnt; i++) { - - if ((scf[i] != MIN_16) && (maxAllowedScf < scf[i])) { - scf[i] = maxAllowedScf; - } - } - /* new maxScf if any scf has been limited */ - - if (maxAllowedScf < maxScf) { - maxScf = maxAllowedScf; - } - - /* calc loop scalefactors */ - - if (maxScf > MIN_16) { - *globalGain = maxScf; - lastSf = 0; - - for(i=0; isfbCnt; i++) { - - if (scf[i] == MIN_16) { - scf[i] = lastSf; - /* set band explicitely to zero */ - for (j=psyOutChan->sfbOffsets[i]; jsfbOffsets[i+1]; j++) { - psyOutChan->mdctSpectrum[j] = 0; - } - } - else { - scf[i] = maxScf - scf[i]; - lastSf = scf[i]; - } - } - } - else{ - *globalGain = 0; - /* set spectrum explicitely to zero */ - for(i=0; isfbCnt; i++) { - scf[i] = 0; - for (j=psyOutChan->sfbOffsets[i]; jsfbOffsets[i+1]; j++) { - psyOutChan->mdctSpectrum[j] = 0; - } - } - } -} - -/********************************************************************************* -* -* function name: CalcFormFactor -* description: estimate Form factors for all channel -* -**********************************************************************************/ -void -CalcFormFactor(Word16 logSfbFormFactor[MAX_CHANNELS][MAX_GROUPED_SFB], - Word16 sfbNRelevantLines[MAX_CHANNELS][MAX_GROUPED_SFB], - Word16 logSfbEnergy[MAX_CHANNELS][MAX_GROUPED_SFB], - PSY_OUT_CHANNEL psyOutChannel[MAX_CHANNELS], - const Word16 nChannels) -{ - Word16 j; - - for (j=0; j=0; i--) { - pbSpreadedEnergy[i] = max(pbSpreadedEnergy[i], - L_mpy_ls(pbSpreadedEnergy[i+1], maskLowFactor[i])); - } -} diff --git a/android-aac-enc/jni/src/stat_bits.c b/android-aac-enc/jni/src/stat_bits.c deleted file mode 100644 index c2bd8bde6..000000000 --- a/android-aac-enc/jni/src/stat_bits.c +++ /dev/null @@ -1,237 +0,0 @@ -/* - ** Copyright 2003-2010, VisualOn, Inc. - ** - ** Licensed under the Apache License, Version 2.0 (the "License"); - ** you may not use this file except in compliance with the License. - ** You may obtain a copy of the License at - ** - ** http://www.apache.org/licenses/LICENSE-2.0 - ** - ** Unless required by applicable law or agreed to in writing, software - ** distributed under the License is distributed on an "AS IS" BASIS, - ** WITHOUT 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: stat_bits.c - - Content: Static bit counter functions - -*******************************************************************************/ - -#include "stat_bits.h" -#include "bitenc.h" -#include "tns.h" - - -typedef enum { - SI_ID_BITS =(3), - SI_FILL_COUNT_BITS =(4), - SI_FILL_ESC_COUNT_BITS =(8), - SI_FILL_EXTENTION_BITS =(4), - SI_FILL_NIBBLE_BITS =(4), - SI_SCE_BITS =(4), - SI_CPE_BITS =(5), - SI_CPE_MS_MASK_BITS =(2) , - SI_ICS_INFO_BITS_LONG =(1+2+1+6+1), - SI_ICS_INFO_BITS_SHORT =(1+2+1+4+7), - SI_ICS_BITS =(8+1+1+1) -} SI_BITS; - - -/********************************************************************************* -* -* function name: countMsMaskBits -* description: count ms stereo bits demand -* -**********************************************************************************/ -static Word16 countMsMaskBits(Word16 sfbCnt, - Word16 sfbPerGroup, - Word16 maxSfbPerGroup, - struct TOOLSINFO *toolsInfo) -{ - Word16 msBits, sfbOff, sfb; - msBits = 0; - - - switch(toolsInfo->msDigest) { - case MS_NONE: - case MS_ALL: - break; - - case MS_SOME: - for(sfbOff=0; sfbOfftnsActive[i]!=0) { - tnsPresent = 1; - } - } - - if (tnsPresent) { - /* there is data to be written*/ - /*count += 1; */ - for (i=0; itnsActive[i]) { - count += 1; - - if (blockType == 2) { - count += 4; - count += 3; - } - else { - count += 6; - count += 5; - } - - if (tnsInfo->order[i]) { - count += 1; /*direction*/ - count += 1; /*coef_compression */ - - if (tnsInfo->coefRes[i] == 4) { - ptcoef = tnsInfo->coef + i*TNS_MAX_ORDER_SHORT; - coefBits = 3; - for(k=0; korder[i]; k++) { - - if ((ptcoef[k] > 3) || (ptcoef[k] < -4)) { - coefBits = 4; - break; - } - } - } - else { - coefBits = 2; - ptcoef = tnsInfo->coef + i*TNS_MAX_ORDER_SHORT; - for(k=0; korder[i]; k++) { - - if ((ptcoef[k] > 1) || (ptcoef[k] < -2)) { - coefBits = 3; - break; - } - } - } - for (k=0; korder[i]; k++ ) { - count += coefBits; - } - } - } - } - } - - return count; -} - -/********************************************************************************** -* -* function name: countTnsBits -* description: count tns bit demand -* -**********************************************************************************/ -static Word16 countTnsBits(TNS_INFO *tnsInfo,Word16 blockType) -{ - return(tnsCount(tnsInfo, blockType)); -} - -/********************************************************************************* -* -* function name: countStaticBitdemand -* description: count static bit demand include tns -* -**********************************************************************************/ -Word16 countStaticBitdemand(PSY_OUT_CHANNEL psyOutChannel[MAX_CHANNELS], - PSY_OUT_ELEMENT *psyOutElement, - Word16 channels, - Word16 adtsUsed) -{ - Word32 statBits; - Word32 ch; - - statBits = 0; - - /* if adts used, add 56 bits */ - if(adtsUsed) statBits += 56; - - - switch (channels) { - case 1: - statBits += SI_ID_BITS+SI_SCE_BITS+SI_ICS_BITS; - statBits += countTnsBits(&(psyOutChannel[0].tnsInfo), - psyOutChannel[0].windowSequence); - - switch(psyOutChannel[0].windowSequence){ - case LONG_WINDOW: - case START_WINDOW: - case STOP_WINDOW: - statBits += SI_ICS_INFO_BITS_LONG; - break; - case SHORT_WINDOW: - statBits += SI_ICS_INFO_BITS_SHORT; - break; - } - break; - case 2: - statBits += SI_ID_BITS+SI_CPE_BITS+2*SI_ICS_BITS; - - statBits += SI_CPE_MS_MASK_BITS; - statBits += countMsMaskBits(psyOutChannel[0].sfbCnt, - psyOutChannel[0].sfbPerGroup, - psyOutChannel[0].maxSfbPerGroup, - &psyOutElement->toolsInfo); - - switch (psyOutChannel[0].windowSequence) { - case LONG_WINDOW: - case START_WINDOW: - case STOP_WINDOW: - statBits += SI_ICS_INFO_BITS_LONG; - break; - case SHORT_WINDOW: - statBits += SI_ICS_INFO_BITS_SHORT; - break; - } - for(ch=0; ch<2; ch++) - statBits += countTnsBits(&(psyOutChannel[ch].tnsInfo), - psyOutChannel[ch].windowSequence); - break; - } - - return statBits; -} - diff --git a/android-aac-enc/jni/src/tns.c b/android-aac-enc/jni/src/tns.c deleted file mode 100644 index 455a864cb..000000000 --- a/android-aac-enc/jni/src/tns.c +++ /dev/null @@ -1,932 +0,0 @@ -/* - ** Copyright 2003-2010, VisualOn, Inc. - ** - ** Licensed under the Apache License, Version 2.0 (the "License"); - ** you may not use this file except in compliance with the License. - ** You may obtain a copy of the License at - ** - ** http://www.apache.org/licenses/LICENSE-2.0 - ** - ** Unless required by applicable law or agreed to in writing, software - ** distributed under the License is distributed on an "AS IS" BASIS, - ** WITHOUT 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: tns.c - - Content: Definition TNS tools functions - -*******************************************************************************/ - -#include "basic_op.h" -#include "oper_32b.h" -#include "assert.h" -#include "aac_rom.h" -#include "psy_const.h" -#include "tns.h" -#include "tns_param.h" -#include "psy_configuration.h" -#include "tns_func.h" - -#define TNS_MODIFY_BEGIN 2600 /* Hz */ -#define RATIO_PATCH_LOWER_BORDER 380 /* Hz */ -#define TNS_GAIN_THRESH 141 /* 1.41*100 */ -#define NORM_COEF 0x028f5c28 - -static const Word32 TNS_PARCOR_THRESH = 0x0ccccccd; /* 0.1*(1 << 31) */ -/* Limit bands to > 2.0 kHz */ -static unsigned short tnsMinBandNumberLong[12] = -{ 11, 12, 15, 16, 17, 20, 25, 26, 24, 28, 30, 31 }; -static unsigned short tnsMinBandNumberShort[12] = -{ 2, 2, 2, 3, 3, 4, 6, 6, 8, 10, 10, 12 }; - -/**************************************/ -/* Main/Low Profile TNS Parameters */ -/**************************************/ -static unsigned short tnsMaxBandsLongMainLow[12] = -{ 31, 31, 34, 40, 42, 51, 46, 46, 42, 42, 42, 39 }; - -static unsigned short tnsMaxBandsShortMainLow[12] = -{ 9, 9, 10, 14, 14, 14, 14, 14, 14, 14, 14, 14 }; - - -static void CalcWeightedSpectrum(const Word32 spectrum[], - Word16 weightedSpectrum[], - Word32* sfbEnergy, - const Word16* sfbOffset, Word16 lpcStartLine, - Word16 lpcStopLine, Word16 lpcStartBand,Word16 lpcStopBand, - Word32 *pWork32); - - - -void AutoCorrelation(const Word16 input[], Word32 corr[], - Word16 samples, Word16 corrCoeff); -static Word16 AutoToParcor(Word32 workBuffer[], Word32 reflCoeff[], Word16 numOfCoeff); - -static Word16 CalcTnsFilter(const Word16* signal, const Word32 window[], Word16 numOfLines, - Word16 tnsOrder, Word32 parcor[]); - - -static void Parcor2Index(const Word32 parcor[], Word16 index[], Word16 order, - Word16 bitsPerCoeff); - -static void Index2Parcor(const Word16 index[], Word32 parcor[], Word16 order, - Word16 bitsPerCoeff); - - - -static void AnalysisFilterLattice(const Word32 signal[], Word16 numOfLines, - const Word32 parCoeff[], Word16 order, - Word32 output[]); - - -/** -* -* function name: FreqToBandWithRounding -* description: Retrieve index of nearest band border -* returnt: index -* -*/ -static Word16 FreqToBandWithRounding(Word32 freq, /*!< frequency in Hertz */ - Word32 fs, /*!< Sampling frequency in Hertz */ - Word16 numOfBands, /*!< total number of bands */ - const Word16 *bandStartOffset) /*!< table of band borders */ -{ - Word32 lineNumber, band; - Word32 temp, shift; - - /* assert(freq >= 0); */ - shift = norm_l(fs); - lineNumber = (extract_l(fixmul((bandStartOffset[numOfBands] << 2),Div_32(freq << shift,fs << shift))) + 1) >> 1; - - /* freq > fs/2 */ - temp = lineNumber - bandStartOffset[numOfBands] ; - if (temp >= 0) - return numOfBands; - - /* find band the line number lies in */ - for (band=0; band 0) break; - } - - temp = (lineNumber - bandStartOffset[band]); - temp = (temp - (bandStartOffset[band + 1] - lineNumber)); - if ( temp > 0 ) - { - band = band + 1; - } - - return extract_l(band); -} - - -/** -* -* function name: InitTnsConfigurationLong -* description: Fill TNS_CONFIG structure with sensible content for long blocks -* returns: 0 if success -* -*/ -Word16 InitTnsConfigurationLong(Word32 bitRate, /*!< bitrate */ - Word32 sampleRate, /*!< Sampling frequency */ - Word16 channels, /*!< number of channels */ - TNS_CONFIG *tC, /*!< TNS Config struct (modified) */ - PSY_CONFIGURATION_LONG *pC, /*!< psy config struct */ - Word16 active) /*!< tns active flag */ -{ - - Word32 bitratePerChannel; - tC->maxOrder = TNS_MAX_ORDER; - tC->tnsStartFreq = 1275; - tC->coefRes = 4; - - /* to avoid integer division */ - if ( sub(channels,2) == 0 ) { - bitratePerChannel = bitRate >> 1; - } - else { - bitratePerChannel = bitRate; - } - - tC->tnsMaxSfb = tnsMaxBandsLongMainLow[pC->sampRateIdx]; - - tC->tnsActive = active; - - /* now calc band and line borders */ - tC->tnsStopBand = min(pC->sfbCnt, tC->tnsMaxSfb); - tC->tnsStopLine = pC->sfbOffset[tC->tnsStopBand]; - - tC->tnsStartBand = FreqToBandWithRounding(tC->tnsStartFreq, sampleRate, - pC->sfbCnt, (const Word16*)pC->sfbOffset); - - tC->tnsModifyBeginCb = FreqToBandWithRounding(TNS_MODIFY_BEGIN, - sampleRate, - pC->sfbCnt, - (const Word16*)pC->sfbOffset); - - tC->tnsRatioPatchLowestCb = FreqToBandWithRounding(RATIO_PATCH_LOWER_BORDER, - sampleRate, - pC->sfbCnt, - (const Word16*)pC->sfbOffset); - - - tC->tnsStartLine = pC->sfbOffset[tC->tnsStartBand]; - - tC->lpcStopBand = tnsMaxBandsLongMainLow[pC->sampRateIdx]; - tC->lpcStopBand = min(tC->lpcStopBand, pC->sfbActive); - - tC->lpcStopLine = pC->sfbOffset[tC->lpcStopBand]; - - tC->lpcStartBand = tnsMinBandNumberLong[pC->sampRateIdx]; - - tC->lpcStartLine = pC->sfbOffset[tC->lpcStartBand]; - - tC->threshold = TNS_GAIN_THRESH; - - - return(0); -} - -/** -* -* function name: InitTnsConfigurationShort -* description: Fill TNS_CONFIG structure with sensible content for short blocks -* returns: 0 if success -* -*/ -Word16 InitTnsConfigurationShort(Word32 bitRate, /*!< bitrate */ - Word32 sampleRate, /*!< Sampling frequency */ - Word16 channels, /*!< number of channels */ - TNS_CONFIG *tC, /*!< TNS Config struct (modified) */ - PSY_CONFIGURATION_SHORT *pC, /*!< psy config struct */ - Word16 active) /*!< tns active flag */ -{ - Word32 bitratePerChannel; - tC->maxOrder = TNS_MAX_ORDER_SHORT; - tC->tnsStartFreq = 2750; - tC->coefRes = 3; - - /* to avoid integer division */ - if ( sub(channels,2) == 0 ) { - bitratePerChannel = L_shr(bitRate,1); - } - else { - bitratePerChannel = bitRate; - } - - tC->tnsMaxSfb = tnsMaxBandsShortMainLow[pC->sampRateIdx]; - - tC->tnsActive = active; - - /* now calc band and line borders */ - tC->tnsStopBand = min(pC->sfbCnt, tC->tnsMaxSfb); - tC->tnsStopLine = pC->sfbOffset[tC->tnsStopBand]; - - tC->tnsStartBand=FreqToBandWithRounding(tC->tnsStartFreq, sampleRate, - pC->sfbCnt, (const Word16*)pC->sfbOffset); - - tC->tnsModifyBeginCb = FreqToBandWithRounding(TNS_MODIFY_BEGIN, - sampleRate, - pC->sfbCnt, - (const Word16*)pC->sfbOffset); - - tC->tnsRatioPatchLowestCb = FreqToBandWithRounding(RATIO_PATCH_LOWER_BORDER, - sampleRate, - pC->sfbCnt, - (const Word16*)pC->sfbOffset); - - - tC->tnsStartLine = pC->sfbOffset[tC->tnsStartBand]; - - tC->lpcStopBand = tnsMaxBandsShortMainLow[pC->sampRateIdx]; - - tC->lpcStopBand = min(tC->lpcStopBand, pC->sfbActive); - - tC->lpcStopLine = pC->sfbOffset[tC->lpcStopBand]; - - tC->lpcStartBand = tnsMinBandNumberShort[pC->sampRateIdx]; - - tC->lpcStartLine = pC->sfbOffset[tC->lpcStartBand]; - - tC->threshold = TNS_GAIN_THRESH; - - return(0); -} - -/** -* -* function name: TnsDetect -* description: Calculate TNS filter and decide on TNS usage -* returns: 0 if success -* -*/ -Word32 TnsDetect(TNS_DATA* tnsData, /*!< tns data structure (modified) */ - TNS_CONFIG tC, /*!< tns config structure */ - Word32* pScratchTns, /*!< pointer to scratch space */ - const Word16 sfbOffset[], /*!< scalefactor size and table */ - Word32* spectrum, /*!< spectral data */ - Word16 subBlockNumber, /*!< subblock num */ - Word16 blockType, /*!< blocktype (long or short) */ - Word32 * sfbEnergy) /*!< sfb-wise energy */ -{ - - Word32 predictionGain; - Word32 temp; - Word32* pWork32 = &pScratchTns[subBlockNumber >> 8]; - Word16* pWeightedSpectrum = (Word16 *)&pScratchTns[subBlockNumber >> 8]; - - - if (tC.tnsActive) { - CalcWeightedSpectrum(spectrum, - pWeightedSpectrum, - sfbEnergy, - sfbOffset, - tC.lpcStartLine, - tC.lpcStopLine, - tC.lpcStartBand, - tC.lpcStopBand, - pWork32); - - temp = blockType - SHORT_WINDOW; - if ( temp != 0 ) { - predictionGain = CalcTnsFilter( &pWeightedSpectrum[tC.lpcStartLine], - tC.acfWindow, - tC.lpcStopLine - tC.lpcStartLine, - tC.maxOrder, - tnsData->dataRaw.tnsLong.subBlockInfo.parcor); - - - temp = predictionGain - tC.threshold; - if ( temp > 0 ) { - tnsData->dataRaw.tnsLong.subBlockInfo.tnsActive = 1; - } - else { - tnsData->dataRaw.tnsLong.subBlockInfo.tnsActive = 0; - } - - tnsData->dataRaw.tnsLong.subBlockInfo.predictionGain = predictionGain; - } - else{ - - predictionGain = CalcTnsFilter( &pWeightedSpectrum[tC.lpcStartLine], - tC.acfWindow, - tC.lpcStopLine - tC.lpcStartLine, - tC.maxOrder, - tnsData->dataRaw.tnsShort.subBlockInfo[subBlockNumber].parcor); - - temp = predictionGain - tC.threshold; - if ( temp > 0 ) { - tnsData->dataRaw.tnsShort.subBlockInfo[subBlockNumber].tnsActive = 1; - } - else { - tnsData->dataRaw.tnsShort.subBlockInfo[subBlockNumber].tnsActive = 0; - } - - tnsData->dataRaw.tnsShort.subBlockInfo[subBlockNumber].predictionGain = predictionGain; - } - - } - else{ - - temp = blockType - SHORT_WINDOW; - if ( temp != 0 ) { - tnsData->dataRaw.tnsLong.subBlockInfo.tnsActive = 0; - tnsData->dataRaw.tnsLong.subBlockInfo.predictionGain = 0; - } - else { - tnsData->dataRaw.tnsShort.subBlockInfo[subBlockNumber].tnsActive = 0; - tnsData->dataRaw.tnsShort.subBlockInfo[subBlockNumber].predictionGain = 0; - } - } - - return(0); -} - - -/***************************************************************************** -* -* function name: TnsSync -* description: update tns parameter -* -*****************************************************************************/ -void TnsSync(TNS_DATA *tnsDataDest, - const TNS_DATA *tnsDataSrc, - const TNS_CONFIG tC, - const Word16 subBlockNumber, - const Word16 blockType) -{ - TNS_SUBBLOCK_INFO *sbInfoDest; - const TNS_SUBBLOCK_INFO *sbInfoSrc; - Word32 i, temp; - - temp = blockType - SHORT_WINDOW; - if ( temp != 0 ) { - sbInfoDest = &tnsDataDest->dataRaw.tnsLong.subBlockInfo; - sbInfoSrc = &tnsDataSrc->dataRaw.tnsLong.subBlockInfo; - } - else { - sbInfoDest = &tnsDataDest->dataRaw.tnsShort.subBlockInfo[subBlockNumber]; - sbInfoSrc = &tnsDataSrc->dataRaw.tnsShort.subBlockInfo[subBlockNumber]; - } - - if (100*abs_s(sbInfoDest->predictionGain - sbInfoSrc->predictionGain) < - (3 * sbInfoDest->predictionGain)) { - sbInfoDest->tnsActive = sbInfoSrc->tnsActive; - for ( i=0; i< tC.maxOrder; i++) { - sbInfoDest->parcor[i] = sbInfoSrc->parcor[i]; - } - } -} - -/***************************************************************************** -* -* function name: TnsEncode -* description: do TNS filtering -* returns: 0 if success -* -*****************************************************************************/ -Word16 TnsEncode(TNS_INFO* tnsInfo, /*!< tns info structure (modified) */ - TNS_DATA* tnsData, /*!< tns data structure (modified) */ - Word16 numOfSfb, /*!< number of scale factor bands */ - TNS_CONFIG tC, /*!< tns config structure */ - Word16 lowPassLine, /*!< lowpass line */ - Word32* spectrum, /*!< spectral data (modified) */ - Word16 subBlockNumber, /*!< subblock num */ - Word16 blockType) /*!< blocktype (long or short) */ -{ - Word32 i; - Word32 temp_s; - Word32 temp; - TNS_SUBBLOCK_INFO *psubBlockInfo; - - temp_s = blockType - SHORT_WINDOW; - if ( temp_s != 0) { - psubBlockInfo = &tnsData->dataRaw.tnsLong.subBlockInfo; - if (psubBlockInfo->tnsActive == 0) { - tnsInfo->tnsActive[subBlockNumber] = 0; - return(0); - } - else { - - Parcor2Index(psubBlockInfo->parcor, - tnsInfo->coef, - tC.maxOrder, - tC.coefRes); - - Index2Parcor(tnsInfo->coef, - psubBlockInfo->parcor, - tC.maxOrder, - tC.coefRes); - - for (i=tC.maxOrder - 1; i>=0; i--) { - temp = psubBlockInfo->parcor[i] - TNS_PARCOR_THRESH; - if ( temp > 0 ) - break; - temp = psubBlockInfo->parcor[i] + TNS_PARCOR_THRESH; - if ( temp < 0 ) - break; - } - tnsInfo->order[subBlockNumber] = i + 1; - - - tnsInfo->tnsActive[subBlockNumber] = 1; - for (i=subBlockNumber+1; itnsActive[i] = 0; - } - tnsInfo->coefRes[subBlockNumber] = tC.coefRes; - tnsInfo->length[subBlockNumber] = numOfSfb - tC.tnsStartBand; - - - AnalysisFilterLattice(&(spectrum[tC.tnsStartLine]), - (min(tC.tnsStopLine,lowPassLine) - tC.tnsStartLine), - psubBlockInfo->parcor, - tnsInfo->order[subBlockNumber], - &(spectrum[tC.tnsStartLine])); - - } - } /* if (blockType!=SHORT_WINDOW) */ - else /*short block*/ { - psubBlockInfo = &tnsData->dataRaw.tnsShort.subBlockInfo[subBlockNumber]; - if (psubBlockInfo->tnsActive == 0) { - tnsInfo->tnsActive[subBlockNumber] = 0; - return(0); - } - else { - - Parcor2Index(psubBlockInfo->parcor, - &tnsInfo->coef[subBlockNumber*TNS_MAX_ORDER_SHORT], - tC.maxOrder, - tC.coefRes); - - Index2Parcor(&tnsInfo->coef[subBlockNumber*TNS_MAX_ORDER_SHORT], - psubBlockInfo->parcor, - tC.maxOrder, - tC.coefRes); - for (i=(tC.maxOrder - 1); i>=0; i--) { - temp = psubBlockInfo->parcor[i] - TNS_PARCOR_THRESH; - if ( temp > 0 ) - break; - - temp = psubBlockInfo->parcor[i] + TNS_PARCOR_THRESH; - if ( temp < 0 ) - break; - } - tnsInfo->order[subBlockNumber] = i + 1; - - tnsInfo->tnsActive[subBlockNumber] = 1; - tnsInfo->coefRes[subBlockNumber] = tC.coefRes; - tnsInfo->length[subBlockNumber] = numOfSfb - tC.tnsStartBand; - - - AnalysisFilterLattice(&(spectrum[tC.tnsStartLine]), (tC.tnsStopLine - tC.tnsStartLine), - psubBlockInfo->parcor, - tnsInfo->order[subBlockNumber], - &(spectrum[tC.tnsStartLine])); - - } - } - - return(0); -} - - -/***************************************************************************** -* -* function name: m_pow2_cordic -* description: Iterative power function -* -* Calculates pow(2.0,x-1.0*(scale+1)) with INT_BITS bit precision -* using modified cordic algorithm -* returns: the result of pow2 -* -*****************************************************************************/ -static Word32 m_pow2_cordic(Word32 x, Word16 scale) -{ - Word32 k; - - Word32 accu_y = 0x40000000; - accu_y = L_shr(accu_y,scale); - - for(k=1; k= 0) { - - x = L_sub(x, z); - accu_y = L_add(accu_y, (accu_y >> k)); - } - } - return(accu_y); -} - - -/***************************************************************************** -* -* function name: CalcWeightedSpectrum -* description: Calculate weighted spectrum for LPC calculation -* -*****************************************************************************/ -static void CalcWeightedSpectrum(const Word32 spectrum[], /*!< input spectrum */ - Word16 weightedSpectrum[], - Word32 *sfbEnergy, /*!< sfb energies */ - const Word16 *sfbOffset, - Word16 lpcStartLine, - Word16 lpcStopLine, - Word16 lpcStartBand, - Word16 lpcStopBand, - Word32 *pWork32) -{ - #define INT_BITS_SCAL 1<<(INT_BITS/2) - - Word32 i, sfb, shift; - Word32 maxShift; - Word32 tmp_s, tmp2_s; - Word32 tmp, tmp2; - Word32 maxWS; - Word32 tnsSfbMean[MAX_SFB]; /* length [lpcStopBand-lpcStartBand] should be sufficient here */ - - maxWS = 0; - - /* calc 1.0*2^-INT_BITS/2/sqrt(en) */ - for( sfb = lpcStartBand; sfb < lpcStopBand; sfb++) { - - tmp2 = sfbEnergy[sfb] - 2; - if( tmp2 > 0) { - tmp = rsqrt(sfbEnergy[sfb], INT_BITS); - if(tmp > INT_BITS_SCAL) - { - shift = norm_l(tmp); - tmp = Div_32( INT_BITS_SCAL << shift, tmp << shift ); - } - else - { - tmp = 0x7fffffff; - } - } - else { - tmp = 0x7fffffff; - } - tnsSfbMean[sfb] = tmp; - } - - /* spread normalized values from sfbs to lines */ - sfb = lpcStartBand; - tmp = tnsSfbMean[sfb]; - for ( i=lpcStartLine; i=lpcStartLine; i--){ - pWork32[i] = (pWork32[i] + pWork32[i + 1]) >> 1; - } - /* filter up */ - for (i=(lpcStartLine + 1); i> 1; - } - - /* weight and normalize */ - for (i=lpcStartLine; i= 0) - { - for (i=lpcStartLine; i> maxShift; - } - } - else - { - maxShift = -maxShift; - for (i=lpcStartLine; i> scf)); - } - corr[0] = accu; - - /* early termination if all corr coeffs are likely going to be zero */ - if(corr[0] == 0) return ; - - /* calc all other corrCoef: R[j] = sum { t[i] * t[i+j] } ; i = 0..(N-j-1), j=1..p */ - for(i=1; i> scf)); - } - corr[i] = accu; - } -} -#endif - -/***************************************************************************** -* -* function name: AutoToParcor -* description: conversion autocorrelation to reflection coefficients -* returns: prediction gain -* input: input values, no. of output values (=order), -* ptr. to workbuffer (required size: 2*order) -* output: reflection coefficients -* -*****************************************************************************/ -static Word16 AutoToParcor(Word32 workBuffer[], Word32 reflCoeff[], Word16 numOfCoeff) { - - Word32 i, j, shift; - Word32 *pWorkBuffer; /* temp pointer */ - Word32 predictionGain = 0; - Word32 num, denom; - Word32 temp, workBuffer0; - - - num = workBuffer[0]; - temp = workBuffer[numOfCoeff]; - - for(i=0; i 0) - index=i; - } - return extract_l(index - 4); -} - -static Word16 Search4(Word32 parcor) -{ - Word32 index = 0; - Word32 i; - Word32 temp; - - - for (i=0;i<16;i++) { - temp = L_sub(parcor, tnsCoeff4Borders[i]); - if (temp > 0) - index=i; - } - return extract_l(index - 8); -} - - - -/***************************************************************************** -* -* functionname: Parcor2Index -* description: quantization index for reflection coefficients -* -*****************************************************************************/ -static void Parcor2Index(const Word32 parcor[], /*!< parcor coefficients */ - Word16 index[], /*!< quantized coeff indices */ - Word16 order, /*!< filter order */ - Word16 bitsPerCoeff) { /*!< quantizer resolution */ - Word32 i; - Word32 temp; - - for(i=0; i> 1; - tmpSave = x; - - for (i=0; i<(order - 1); i++) { - - tmp = L_add(fixmul(coef_par[i], x), state_par[i]); - x = L_add(fixmul(coef_par[i], state_par[i]), x); - - state_par[i] = tmpSave; - tmpSave = tmp; - } - - /* last stage: only need half operations */ - accu = fixmul(state_par[order - 1], coef_par[(order - 1)]); - state_par[(order - 1)] = tmpSave; - - x = L_add(accu, x); - x = L_add(x, x); - - return x; -} - -/***************************************************************************** -* -* functionname: AnalysisFilterLattice -* description: filters spectral lines with TNS filter -* -*****************************************************************************/ -static void AnalysisFilterLattice(const Word32 signal[], /*!< input spectrum */ - Word16 numOfLines, /*!< no. of lines */ - const Word32 parCoeff[],/*!< PARC coefficients */ - Word16 order, /*!< filter order */ - Word32 output[]) /*!< filtered signal values */ -{ - - Word32 state_par[TNS_MAX_ORDER]; - Word32 j; - - for ( j=0; j> 2); - } - } -} diff --git a/android-aac-enc/jni/src/transform.c b/android-aac-enc/jni/src/transform.c deleted file mode 100644 index a02336f3f..000000000 --- a/android-aac-enc/jni/src/transform.c +++ /dev/null @@ -1,678 +0,0 @@ -/* - ** Copyright 2003-2010, VisualOn, Inc. - ** - ** Licensed under the Apache License, Version 2.0 (the "License"); - ** you may not use this file except in compliance with the License. - ** You may obtain a copy of the License at - ** - ** http://www.apache.org/licenses/LICENSE-2.0 - ** - ** Unless required by applicable law or agreed to in writing, software - ** distributed under the License is distributed on an "AS IS" BASIS, - ** WITHOUT 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: transform.c - - Content: MDCT Transform functionss - -*******************************************************************************/ - -#include "basic_op.h" -#include "psy_const.h" -#include "transform.h" -#include "aac_rom.h" - - -#define LS_TRANS ((FRAME_LEN_LONG-FRAME_LEN_SHORT)/2) /* 448 */ -#define SQRT1_2 0x5a82799a /* sqrt(1/2) in Q31 */ -#define swap2(p0,p1) \ - t = p0; t1 = *(&(p0)+1); \ - p0 = p1; *(&(p0)+1) = *(&(p1)+1); \ - p1 = t; *(&(p1)+1) = t1 - -/********************************************************************************* -* -* function name: Shuffle -* description: Shuffle points prepared function for fft -* -**********************************************************************************/ -static void Shuffle(int *buf, int num, const unsigned char* bitTab) -{ - int *part0, *part1; - int i, j; - int t, t1; - - part0 = buf; - part1 = buf + num; - - while ((i = *bitTab++) != 0) { - j = *bitTab++; - - swap2(part0[4*i+0], part0[4*j+0]); - swap2(part0[4*i+2], part1[4*j+0]); - swap2(part1[4*i+0], part0[4*j+2]); - swap2(part1[4*i+2], part1[4*j+2]); - } - - do { - swap2(part0[4*i+2], part1[4*i+0]); - } while ((i = *bitTab++) != 0); -} - -#if !defined(ARMV5E) && !defined(ARMV7Neon) - -/***************************************************************************** -* -* function name: Radix4First -* description: Radix 4 point prepared function for fft -* -**********************************************************************************/ -static void Radix4First(int *buf, int num) -{ - int r0, r1, r2, r3; - int r4, r5, r6, r7; - - for (; num != 0; num--) - { - r0 = buf[0] + buf[2]; - r1 = buf[1] + buf[3]; - r2 = buf[0] - buf[2]; - r3 = buf[1] - buf[3]; - r4 = buf[4] + buf[6]; - r5 = buf[5] + buf[7]; - r6 = buf[4] - buf[6]; - r7 = buf[5] - buf[7]; - - buf[0] = r0 + r4; - buf[1] = r1 + r5; - buf[4] = r0 - r4; - buf[5] = r1 - r5; - buf[2] = r2 + r7; - buf[3] = r3 - r6; - buf[6] = r2 - r7; - buf[7] = r3 + r6; - - buf += 8; - } -} - -/***************************************************************************** -* -* function name: Radix8First -* description: Radix 8 point prepared function for fft -* -**********************************************************************************/ -static void Radix8First(int *buf, int num) -{ - int r0, r1, r2, r3; - int i0, i1, i2, i3; - int r4, r5, r6, r7; - int i4, i5, i6, i7; - int t0, t1, t2, t3; - - for ( ; num != 0; num--) - { - r0 = buf[0] + buf[2]; - i0 = buf[1] + buf[3]; - r1 = buf[0] - buf[2]; - i1 = buf[1] - buf[3]; - r2 = buf[4] + buf[6]; - i2 = buf[5] + buf[7]; - r3 = buf[4] - buf[6]; - i3 = buf[5] - buf[7]; - - r4 = (r0 + r2) >> 1; - i4 = (i0 + i2) >> 1; - r5 = (r0 - r2) >> 1; - i5 = (i0 - i2) >> 1; - r6 = (r1 - i3) >> 1; - i6 = (i1 + r3) >> 1; - r7 = (r1 + i3) >> 1; - i7 = (i1 - r3) >> 1; - - r0 = buf[ 8] + buf[10]; - i0 = buf[ 9] + buf[11]; - r1 = buf[ 8] - buf[10]; - i1 = buf[ 9] - buf[11]; - r2 = buf[12] + buf[14]; - i2 = buf[13] + buf[15]; - r3 = buf[12] - buf[14]; - i3 = buf[13] - buf[15]; - - t0 = (r0 + r2) >> 1; - t1 = (i0 + i2) >> 1; - t2 = (r0 - r2) >> 1; - t3 = (i0 - i2) >> 1; - - buf[ 0] = r4 + t0; - buf[ 1] = i4 + t1; - buf[ 8] = r4 - t0; - buf[ 9] = i4 - t1; - buf[ 4] = r5 + t3; - buf[ 5] = i5 - t2; - buf[12] = r5 - t3; - buf[13] = i5 + t2; - - r0 = r1 - i3; - i0 = i1 + r3; - r2 = r1 + i3; - i2 = i1 - r3; - - t0 = MULHIGH(SQRT1_2, r0 - i0); - t1 = MULHIGH(SQRT1_2, r0 + i0); - t2 = MULHIGH(SQRT1_2, r2 - i2); - t3 = MULHIGH(SQRT1_2, r2 + i2); - - buf[ 6] = r6 - t0; - buf[ 7] = i6 - t1; - buf[14] = r6 + t0; - buf[15] = i6 + t1; - buf[ 2] = r7 + t3; - buf[ 3] = i7 - t2; - buf[10] = r7 - t3; - buf[11] = i7 + t2; - - buf += 16; - } -} - -/***************************************************************************** -* -* function name: Radix4FFT -* description: Radix 4 point fft core function -* -**********************************************************************************/ -static void Radix4FFT(int *buf, int num, int bgn, int *twidTab) -{ - int r0, r1, r2, r3; - int r4, r5, r6, r7; - int t0, t1; - int sinx, cosx; - int i, j, step; - int *xptr, *csptr; - - for (num >>= 2; num != 0; num >>= 2) - { - step = 2*bgn; - xptr = buf; - - for (i = num; i != 0; i--) - { - csptr = twidTab; - - for (j = bgn; j != 0; j--) - { - r0 = xptr[0]; - r1 = xptr[1]; - xptr += step; - - t0 = xptr[0]; - t1 = xptr[1]; - cosx = csptr[0]; - sinx = csptr[1]; - r2 = MULHIGH(cosx, t0) + MULHIGH(sinx, t1); /* cos*br + sin*bi */ - r3 = MULHIGH(cosx, t1) - MULHIGH(sinx, t0); /* cos*bi - sin*br */ - xptr += step; - - t0 = r0 >> 2; - t1 = r1 >> 2; - r0 = t0 - r2; - r1 = t1 - r3; - r2 = t0 + r2; - r3 = t1 + r3; - - t0 = xptr[0]; - t1 = xptr[1]; - cosx = csptr[2]; - sinx = csptr[3]; - r4 = MULHIGH(cosx, t0) + MULHIGH(sinx, t1); /* cos*cr + sin*ci */ - r5 = MULHIGH(cosx, t1) - MULHIGH(sinx, t0); /* cos*ci - sin*cr */ - xptr += step; - - t0 = xptr[0]; - t1 = xptr[1]; - cosx = csptr[4]; - sinx = csptr[5]; - r6 = MULHIGH(cosx, t0) + MULHIGH(sinx, t1); /* cos*cr + sin*ci */ - r7 = MULHIGH(cosx, t1) - MULHIGH(sinx, t0); /* cos*ci - sin*cr */ - csptr += 6; - - t0 = r4; - t1 = r5; - r4 = t0 + r6; - r5 = r7 - t1; - r6 = t0 - r6; - r7 = r7 + t1; - - xptr[0] = r0 + r5; - xptr[1] = r1 + r6; - xptr -= step; - - xptr[0] = r2 - r4; - xptr[1] = r3 - r7; - xptr -= step; - - xptr[0] = r0 - r5; - xptr[1] = r1 - r6; - xptr -= step; - - xptr[0] = r2 + r4; - xptr[1] = r3 + r7; - xptr += 2; - } - xptr += 3*step; - } - twidTab += 3*step; - bgn <<= 2; - } -} - -/********************************************************************************* -* -* function name: PreMDCT -* description: prepare MDCT process for next FFT compute -* -**********************************************************************************/ -static void PreMDCT(int *buf0, int num, const int *csptr) -{ - int i; - int tr1, ti1, tr2, ti2; - int cosa, sina, cosb, sinb; - int *buf1; - - buf1 = buf0 + num - 1; - - for(i = num >> 2; i != 0; i--) - { - cosa = *csptr++; - sina = *csptr++; - cosb = *csptr++; - sinb = *csptr++; - - tr1 = *(buf0 + 0); - ti2 = *(buf0 + 1); - tr2 = *(buf1 - 1); - ti1 = *(buf1 + 0); - - *buf0++ = MULHIGH(cosa, tr1) + MULHIGH(sina, ti1); - *buf0++ = MULHIGH(cosa, ti1) - MULHIGH(sina, tr1); - - *buf1-- = MULHIGH(cosb, ti2) - MULHIGH(sinb, tr2); - *buf1-- = MULHIGH(cosb, tr2) + MULHIGH(sinb, ti2); - } -} - -/********************************************************************************* -* -* function name: PostMDCT -* description: post MDCT process after next FFT for MDCT -* -**********************************************************************************/ -static void PostMDCT(int *buf0, int num, const int *csptr) -{ - int i; - int tr1, ti1, tr2, ti2; - int cosa, sina, cosb, sinb; - int *buf1; - - buf1 = buf0 + num - 1; - - for(i = num >> 2; i != 0; i--) - { - cosa = *csptr++; - sina = *csptr++; - cosb = *csptr++; - sinb = *csptr++; - - tr1 = *(buf0 + 0); - ti1 = *(buf0 + 1); - ti2 = *(buf1 + 0); - tr2 = *(buf1 - 1); - - *buf0++ = MULHIGH(cosa, tr1) + MULHIGH(sina, ti1); - *buf1-- = MULHIGH(sina, tr1) - MULHIGH(cosa, ti1); - - *buf0++ = MULHIGH(sinb, tr2) - MULHIGH(cosb, ti2); - *buf1-- = MULHIGH(cosb, tr2) + MULHIGH(sinb, ti2); - } -} -#else -void Radix4First(int *buf, int num); -void Radix8First(int *buf, int num); -void Radix4FFT(int *buf, int num, int bgn, int *twidTab); -void PreMDCT(int *buf0, int num, const int *csptr); -void PostMDCT(int *buf0, int num, const int *csptr); -#endif - - -/********************************************************************************** -* -* function name: Mdct_Long -* description: the long block mdct, include long_start block, end_long block -* -**********************************************************************************/ -void Mdct_Long(int *buf) -{ - PreMDCT(buf, 1024, cossintab + 128); - - Shuffle(buf, 512, bitrevTab + 17); - Radix8First(buf, 512 >> 3); - Radix4FFT(buf, 512 >> 3, 8, (int *)twidTab512); - - PostMDCT(buf, 1024, cossintab + 128); -} - - -/********************************************************************************** -* -* function name: Mdct_Short -* description: the short block mdct -* -**********************************************************************************/ -void Mdct_Short(int *buf) -{ - PreMDCT(buf, 128, cossintab); - - Shuffle(buf, 64, bitrevTab); - Radix4First(buf, 64 >> 2); - Radix4FFT(buf, 64 >> 2, 4, (int *)twidTab64); - - PostMDCT(buf, 128, cossintab); -} - - -/***************************************************************************** -* -* function name: shiftMdctDelayBuffer -* description: the mdct delay buffer has a size of 1600, -* so the calculation of LONG,STOP must be spilt in two -* passes with 1024 samples and a mid shift, -* the SHORT transforms can be completed in the delay buffer, -* and afterwards a shift -* -**********************************************************************************/ -static void shiftMdctDelayBuffer(Word16 *mdctDelayBuffer, /*! start of mdct delay buffer */ - Word16 *timeSignal, /*! pointer to new time signal samples, interleaved */ - Word16 chIncrement /*! number of channels */ - ) -{ - Word32 i; - Word16 *srBuf = mdctDelayBuffer; - Word16 *dsBuf = mdctDelayBuffer+FRAME_LEN_LONG; - - for(i = 0; i < BLOCK_SWITCHING_OFFSET-FRAME_LEN_LONG; i+= 8) - { - *srBuf++ = *dsBuf++; *srBuf++ = *dsBuf++; - *srBuf++ = *dsBuf++; *srBuf++ = *dsBuf++; - *srBuf++ = *dsBuf++; *srBuf++ = *dsBuf++; - *srBuf++ = *dsBuf++; *srBuf++ = *dsBuf++; - } - - srBuf = mdctDelayBuffer + BLOCK_SWITCHING_OFFSET-FRAME_LEN_LONG; - dsBuf = timeSignal; - - for(i=0; i> 16); - timeSignalSample = (*dctIn1--) << minSf; - ws2 = timeSignalSample * (*winPtr & 0xffff); - winPtr ++; - /* shift 2 to avoid overflow next */ - *outData0++ = (ws1 >> 2) - (ws2 >> 2); - } - - shiftMdctDelayBuffer(mdctDelayBuffer,timeSignal,chIncrement); - - /* add windows and pre add for mdct to new buffer*/ - dctIn0 = mdctDelayBuffer; - dctIn1 = mdctDelayBuffer + FRAME_LEN_LONG - 1; - outData0 = realOut + FRAME_LEN_LONG/2 - 1; - winPtr = (int *)LongWindowKBD; - for(i=0;i> 16); - winPtr++; - /* shift 2 to avoid overflow next */ - *outData0-- = -((ws1 >> 2) + (ws2 >> 2)); - } - - Mdct_Long(realOut); - /* update scale factor */ - minSf = 14 - minSf; - *mdctScale=minSf; - break; - - case START_WINDOW: - /* - we access BLOCK_SWITCHING_OFFSET (1600 ) delay buffer samples + no timeSignal samples - and get the biggest scale factor for next calculate more precise - */ - minSf = getScalefactorOfShortVectorStride(mdctDelayBuffer,BLOCK_SWITCHING_OFFSET,1); - minSf = min(minSf,14); - - dctIn0 = mdctDelayBuffer; - dctIn1 = mdctDelayBuffer + FRAME_LEN_LONG - 1; - outData0 = realOut + FRAME_LEN_LONG/2; - winPtr = (int *)LongWindowKBD; - - /* add windows and pre add for mdct to last buffer*/ - for(i=0;i> 16); - timeSignalSample = (*dctIn1--) << minSf; - ws2 = timeSignalSample * (*winPtr & 0xffff); - winPtr ++; - *outData0++ = (ws1 >> 2) - (ws2 >> 2); /* shift 2 to avoid overflow next */ - } - - shiftMdctDelayBuffer(mdctDelayBuffer,timeSignal,chIncrement); - - outData0 = realOut + FRAME_LEN_LONG/2 - 1; - for(i=0;i> 16); - winPtr++; - *outData0-- = -((ws1 >> 2) + (ws2 >> 2)); /* shift 2 to avoid overflow next */ - } - - Mdct_Long(realOut); - /* update scale factor */ - minSf = 14 - minSf; - *mdctScale= minSf; - break; - - case STOP_WINDOW: - /* - we access BLOCK_SWITCHING_OFFSET-LS_TRANS (1600-448 ) delay buffer samples + 448 new timeSignal samples - and get the biggest scale factor for next calculate more precise - */ - delayBufferSf = getScalefactorOfShortVectorStride(mdctDelayBuffer+LS_TRANS,BLOCK_SWITCHING_OFFSET-LS_TRANS,1); - timeSignalSf = getScalefactorOfShortVectorStride(timeSignal,2*FRAME_LEN_LONG-BLOCK_SWITCHING_OFFSET,chIncrement); - minSf = min(delayBufferSf,timeSignalSf); - minSf = min(minSf,13); - - outData0 = realOut + FRAME_LEN_LONG/2; - dctIn1 = mdctDelayBuffer + FRAME_LEN_LONG - 1; - for(i=0;i> 16); - timeSignalSample= (*dctIn1--) << minSf; - ws2 = timeSignalSample * (*winPtr & 0xffff); - winPtr++; - *outData0++ = (ws1 >> 2) - (ws2 >> 2); /* shift 2 to avoid overflow next */ - } - - shiftMdctDelayBuffer(mdctDelayBuffer,timeSignal,chIncrement); - - /* add windows and pre add for mdct to new buffer*/ - dctIn0 = mdctDelayBuffer; - dctIn1 = mdctDelayBuffer + FRAME_LEN_LONG - 1; - outData0 = realOut + FRAME_LEN_LONG/2 - 1; - winPtr = (int *)LongWindowKBD; - for(i=0;i> 16); - *outData0-- = -((ws1 >> 2) + (ws2 >> 2)); /* shift 2 to avoid overflow next */ - winPtr++; - } - - Mdct_Long(realOut); - minSf = 14 - minSf; - *mdctScale= minSf; /* update scale factor */ - break; - - case SHORT_WINDOW: - /* - we access BLOCK_SWITCHING_OFFSET (1600 ) delay buffer samples + no new timeSignal samples - and get the biggest scale factor for next calculate more precise - */ - minSf = getScalefactorOfShortVectorStride(mdctDelayBuffer+TRANSFORM_OFFSET_SHORT,9*FRAME_LEN_SHORT,1); - minSf = min(minSf,10); - - - for(w=0;w> 16); - timeSignalSample= *dctIn1 << minSf; - ws2 = timeSignalSample * (*winPtr & 0xffff); - *outData0++ = (ws1 >> 2) - (ws2 >> 2); /* shift 2 to avoid overflow next */ - - timeSignalSample= *(dctIn0 + FRAME_LEN_SHORT) << minSf; - ws1 = timeSignalSample * (*winPtr & 0xffff); - timeSignalSample= *(dctIn1 + FRAME_LEN_SHORT) << minSf; - ws2 = timeSignalSample * (*winPtr >> 16); - *outData1-- = -((ws1 >> 2) + (ws2 >> 2)); /* shift 2 to avoid overflow next */ - - winPtr++; - dctIn0++; - dctIn1--; - } - - Mdct_Short(realOut); - realOut += FRAME_LEN_SHORT; - } - - minSf = 11 - minSf; - *mdctScale = minSf; /* update scale factor */ - - shiftMdctDelayBuffer(mdctDelayBuffer,timeSignal,chIncrement); - break; - } -} - diff --git a/android-aac-enc/project.properties b/android-aac-enc/project.properties deleted file mode 100644 index 8e4bc5fdc..000000000 --- a/android-aac-enc/project.properties +++ /dev/null @@ -1,12 +0,0 @@ -# This file is automatically generated by Android Tools. -# Do not modify this file -- YOUR CHANGES WILL BE ERASED! -# -# This file must be checked in Version Control Systems. -# -# To customize properties used by the Ant build system use, -# "ant.properties", and override values to adapt the script to your -# project structure. - -# Project target. -target=android-19 -android.library=true diff --git a/android-aac-enc/src/main/AndroidManifest.xml b/android-aac-enc/src/main/AndroidManifest.xml deleted file mode 100644 index b4749979d..000000000 --- a/android-aac-enc/src/main/AndroidManifest.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/AbstractBoxParser.java b/android-aac-enc/src/main/java/com/coremedia/iso/AbstractBoxParser.java deleted file mode 100644 index 6d92acd1a..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/AbstractBoxParser.java +++ /dev/null @@ -1,130 +0,0 @@ -/* - * Copyright 2012 Sebastian Annies, Hamburg - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.coremedia.iso; - -import com.coremedia.iso.boxes.Box; -import com.coremedia.iso.boxes.ContainerBox; -import com.coremedia.iso.boxes.UserBox; - -import java.io.IOException; -import java.nio.ByteBuffer; -import java.nio.channels.FileChannel; -import java.nio.channels.ReadableByteChannel; -import java.util.logging.Logger; - -import static com.googlecode.mp4parser.util.CastUtils.l2i; - -/** - * This BoxParser handles the basic stuff like reading size and extracting box type. - */ -public abstract class AbstractBoxParser implements BoxParser { - - private static Logger LOG = Logger.getLogger(AbstractBoxParser.class.getName()); - - public abstract Box createBox(String type, byte[] userType, String parent); - - /** - * Parses the next size and type, creates a box instance and parses the box's content. - * - * @param byteChannel the FileChannel pointing to the ISO file - * @param parent the current box's parent (null if no parent) - * @return the box just parsed - * @throws java.io.IOException if reading from in fails - */ - public Box parseBox(ReadableByteChannel byteChannel, ContainerBox parent) throws IOException { - - - ByteBuffer header = ChannelHelper.readFully(byteChannel, 8); - - long size = IsoTypeReader.readUInt32(header); - // do plausibility check - if (size < 8 && size > 1) { - LOG.severe("Plausibility check failed: size < 8 (size = " + size + "). Stop parsing!"); - return null; - } - - - String type = IsoTypeReader.read4cc(header); - byte[] usertype = null; - long contentSize; - - if (size == 1) { - ByteBuffer bb = ByteBuffer.allocate(8); - byteChannel.read(bb); - bb.rewind(); - size = IsoTypeReader.readUInt64(bb); - contentSize = size - 16; - } else if (size == 0) { - if (byteChannel instanceof FileChannel) { - size = ((FileChannel) byteChannel).size() - ((FileChannel) byteChannel).position() - 8; - } else { - throw new RuntimeException("Only FileChannel inputs may use size == 0 (box reaches to the end of file)"); - } - contentSize = size - 8; - } else { - contentSize = size - 8; - } - if (UserBox.TYPE.equals(type)) { - ByteBuffer bb = ByteBuffer.allocate(16); - byteChannel.read(bb); - bb.rewind(); - usertype = bb.array(); - contentSize -= 16; - } - Box box = createBox(type, usertype, parent.getType()); - box.setParent(parent); - LOG.finest("Parsing " + box.getType()); - // System.out.println("parsing " + Arrays.toString(box.getType()) + " " + box.getClass().getName() + " size=" + size); - - - if (l2i(size - contentSize) == 8) { - // default - no large box - no uuid - // do nothing header's already correct - header.rewind(); - } else if (l2i(size - contentSize) == 16) { - header = ByteBuffer.allocate(16); - IsoTypeWriter.writeUInt32(header, 1); - header.put(IsoFile.fourCCtoBytes(type)); - IsoTypeWriter.writeUInt64(header, size); - } else if (l2i(size - contentSize) == 24) { - header = ByteBuffer.allocate(24); - IsoTypeWriter.writeUInt32(header, size); - header.put(IsoFile.fourCCtoBytes(type)); - header.put(usertype); - } else if (l2i(size - contentSize) == 32) { - header = ByteBuffer.allocate(32); - IsoTypeWriter.writeUInt32(header, size); - header.put(IsoFile.fourCCtoBytes(type)); - IsoTypeWriter.writeUInt64(header, size); - header.put(usertype); - } else { - throw new RuntimeException("I didn't expect that"); - } - - - box.parse(byteChannel, header, contentSize, this); - // System.out.println("box = " + box); - - - assert size == box.getSize() : - "Reconstructed Size is not x to the number of parsed bytes! (" + - box.getType() + ")" - + " Actual Box size: " + size + " Calculated size: " + box.getSize(); - return box; - } - - -} diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/Ascii.java b/android-aac-enc/src/main/java/com/coremedia/iso/Ascii.java deleted file mode 100644 index 2a659d7c7..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/Ascii.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright 2012 Sebastian Annies, Hamburg - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.coremedia.iso; - -import java.io.UnsupportedEncodingException; - -/** - * Converts byte[] -> String and vice versa. - */ -public final class Ascii { - public static byte[] convert(String s) { - try { - if (s != null) { - return s.getBytes("us-ascii"); - } else { - return null; - } - } catch (UnsupportedEncodingException e) { - throw new Error(e); - } - } - - public static String convert(byte[] b) { - try { - if (b != null) { - return new String(b, "us-ascii"); - } else { - return null; - } - } catch (UnsupportedEncodingException e) { - throw new Error(e); - } - } -} \ No newline at end of file diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/BoxParser.java b/android-aac-enc/src/main/java/com/coremedia/iso/BoxParser.java deleted file mode 100644 index cbe9a6f85..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/BoxParser.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright 2012 Sebastian Annies, Hamburg - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.coremedia.iso; - -import com.coremedia.iso.boxes.Box; -import com.coremedia.iso.boxes.ContainerBox; - -import java.io.IOException; -import java.nio.channels.ReadableByteChannel; - -/** - * Basic interface to create boxes from a IsoBufferWrapper and its parent. - */ -public interface BoxParser { - Class getClassForFourCc(String type, byte[] userType, String parent); - - Box parseBox(ReadableByteChannel in, ContainerBox parent) throws IOException; -} diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/ChannelHelper.java b/android-aac-enc/src/main/java/com/coremedia/iso/ChannelHelper.java deleted file mode 100644 index 2ec1d05d4..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/ChannelHelper.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright 2012 Sebastian Annies, Hamburg - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.coremedia.iso; - -import java.io.EOFException; -import java.io.IOException; -import java.nio.ByteBuffer; -import java.nio.channels.FileChannel; -import java.nio.channels.ReadableByteChannel; -import java.nio.channels.SelectionKey; -import java.nio.channels.WritableByteChannel; - -import static com.googlecode.mp4parser.util.CastUtils.l2i; - - -public class ChannelHelper { - public static ByteBuffer readFully(final ReadableByteChannel channel, long size) throws IOException { - - if (channel instanceof FileChannel && size > 1024 * 1024) { - ByteBuffer bb = ((FileChannel) channel).map(FileChannel.MapMode.READ_ONLY, ((FileChannel) channel).position(), size); - ((FileChannel) channel).position(((FileChannel) channel).position() + size); - return bb; - } else { - ByteBuffer buf = ByteBuffer.allocate(l2i(size)); - readFully(channel, buf, buf.limit()); - buf.rewind(); - assert buf.limit() == size; - - return buf; - } - - } - - - public static void readFully(final ReadableByteChannel channel, final ByteBuffer buf) - throws IOException { - readFully(channel, buf, buf.remaining()); - } - - public static int readFully(final ReadableByteChannel channel, final ByteBuffer buf, final int length) - throws IOException { - int n, count = 0; - while (-1 != (n = channel.read(buf))) { - count += n; - if (count == length) { - break; - } - } - if (n == -1) { - throw new EOFException("End of file. No more boxes."); - } - return count; - } - - - public static void writeFully(final WritableByteChannel channel, final ByteBuffer buf) - throws IOException { - do { - int written = channel.write(buf); - if (written < 0) { - throw new EOFException(); - } - } while (buf.hasRemaining()); - } - - - public static void close(SelectionKey key) { - try { - key.channel().close(); - } catch (IOException e) { - // nop - } - - } - - -} \ No newline at end of file diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/Hex.java b/android-aac-enc/src/main/java/com/coremedia/iso/Hex.java deleted file mode 100644 index d8df0c511..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/Hex.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* -Extracted from commons-codec - */ -package com.coremedia.iso; - -import java.io.ByteArrayOutputStream; - -/** - * Converts hexadecimal Strings. - */ -public class Hex { - private static final char[] DIGITS = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'}; - - public static String encodeHex(byte[] data) { - int l = data.length; - char[] out = new char[l << 1]; - // two characters form the hex value. - for (int i = 0, j = 0; i < l; i++) { - out[j++] = DIGITS[(0xF0 & data[i]) >>> 4]; - out[j++] = DIGITS[0x0F & data[i]]; - } - return new String(out); - } - - public static byte[] decodeHex(String hexString) { - ByteArrayOutputStream bas = new ByteArrayOutputStream(); - for (int i = 0; i < hexString.length(); i += 2) { - int b = Integer.parseInt(hexString.substring(i, i + 2), 16); - bas.write(b); - } - return bas.toByteArray(); - } -} diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/IsoFile.java b/android-aac-enc/src/main/java/com/coremedia/iso/IsoFile.java deleted file mode 100644 index edfece079..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/IsoFile.java +++ /dev/null @@ -1,186 +0,0 @@ -/* - * Copyright 2008 CoreMedia AG, Hamburg - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coremedia.iso; - -import com.googlecode.mp4parser.AbstractContainerBox; -import com.coremedia.iso.boxes.Box; -import com.coremedia.iso.boxes.MovieBox; -import com.googlecode.mp4parser.annotations.DoNotParseDetail; - -import java.io.EOFException; -import java.io.IOException; -import java.io.UnsupportedEncodingException; -import java.nio.ByteBuffer; -import java.nio.channels.FileChannel; -import java.nio.channels.ReadableByteChannel; -import java.nio.channels.WritableByteChannel; - -/** - * The most upper container for ISO Boxes. It is a container box that is a file. - * Uses IsoBufferWrapper to access the underlying file. - */ -@DoNotParseDetail -public class IsoFile extends AbstractContainerBox { - protected BoxParser boxParser = new PropertyBoxParserImpl(); - ReadableByteChannel byteChannel; - - public IsoFile() { - super(""); - } - - public IsoFile(ReadableByteChannel byteChannel) throws IOException { - super(""); - this.byteChannel = byteChannel; - boxParser = createBoxParser(); - parse(); - } - - public IsoFile(ReadableByteChannel byteChannel, BoxParser boxParser) throws IOException { - super(""); - this.byteChannel = byteChannel; - this.boxParser = boxParser; - parse(); - - - } - - protected BoxParser createBoxParser() { - return new PropertyBoxParserImpl(); - } - - - @Override - public void _parseDetails(ByteBuffer content) { - // there are no details to parse we should be just file - } - - public void parse(ReadableByteChannel inFC, ByteBuffer header, long contentSize, AbstractBoxParser abstractBoxParser) throws IOException { - throw new IOException("This method is not meant to be called. Use #parse() directly."); - } - - private void parse() throws IOException { - - boolean done = false; - while (!done) { - try { - Box box = boxParser.parseBox(byteChannel, this); - if (box != null) { - // System.err.println(box.getType()); - boxes.add(box); - } else { - done = true; - } - } catch (EOFException e) { - done = true; - } - } - } - - @DoNotParseDetail - public String toString() { - StringBuilder buffer = new StringBuilder(); - buffer.append("IsoFile["); - if (boxes == null) { - buffer.append("unparsed"); - } else { - for (int i = 0; i < boxes.size(); i++) { - if (i > 0) { - buffer.append(";"); - } - buffer.append(boxes.get(i).toString()); - } - } - buffer.append("]"); - return buffer.toString(); - } - - @DoNotParseDetail - public static byte[] fourCCtoBytes(String fourCC) { - byte[] result = new byte[4]; - if (fourCC != null) { - for (int i = 0; i < Math.min(4, fourCC.length()); i++) { - result[i] = (byte) fourCC.charAt(i); - } - } - return result; - } - - @DoNotParseDetail - public static String bytesToFourCC(byte[] type) { - byte[] result = new byte[]{0, 0, 0, 0}; - if (type != null) { - System.arraycopy(type, 0, result, 0, Math.min(type.length, 4)); - } - try { - return new String(result, "ISO-8859-1"); - } catch (UnsupportedEncodingException e) { - throw new Error("Required character encoding is missing", e); - } - } - - - @Override - public long getNumOfBytesToFirstChild() { - return 0; - } - - @Override - public long getSize() { - long size = 0; - for (Box box : boxes) { - size += box.getSize(); - } - return size; - } - - @Override - public IsoFile getIsoFile() { - return this; - } - - - /** - * Shortcut to get the MovieBox since it is often needed and present in - * nearly all ISO 14496 files (at least if they are derived from MP4 ). - * - * @return the MovieBox or null - */ - @DoNotParseDetail - public MovieBox getMovieBox() { - for (Box box : boxes) { - if (box instanceof MovieBox) { - return (MovieBox) box; - } - } - return null; - } - - public void getBox(WritableByteChannel os) throws IOException { - for (Box box : boxes) { - - if (os instanceof FileChannel) { - long startPos = ((FileChannel) os).position(); - box.getBox(os); - long size = ((FileChannel) os).position() - startPos; - assert size == box.getSize(); - } else { - box.getBox(os); - } - - } - } -} diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/IsoFileConvenienceHelper.java b/android-aac-enc/src/main/java/com/coremedia/iso/IsoFileConvenienceHelper.java deleted file mode 100644 index b76ff100b..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/IsoFileConvenienceHelper.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright 2012 Sebastian Annies, Hamburg - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.coremedia.iso; - -import com.coremedia.iso.boxes.Box; -import com.coremedia.iso.boxes.ContainerBox; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -/** - * A fine selection of useful methods. - * - * @author Andre John Mas - * @author Sebastian Annies - * @deprecated please use {@link com.googlecode.mp4parser.util.Path}. I will remove that class before 1.0. - */ -public class IsoFileConvenienceHelper { - - - public static Box get(ContainerBox containerBox, String path) { - - String[] parts = path.split("/"); - if (parts.length == 0) { - return null; - } - - List partList = new ArrayList(Arrays.asList(parts)); - - if ("".equals(partList.get(0))) { - partList.remove(0); - } - - if (partList.size() > 0) { - return get((List) containerBox.getBoxes(), partList); - } - return null; - } - - private static Box get(List boxes, List path) { - - - String typeInPath = path.remove(0); - - for (Box box : boxes) { - if (box instanceof ContainerBox) { - ContainerBox boxContainer = (ContainerBox) box; - String type = boxContainer.getType(); - - if (typeInPath.equals(type)) { - List children = boxContainer.getBoxes(); - if (path.size() > 0) { - if (children.size() > 0) { - return get(children, path); - } - } else { - return box; - } - } - - } else { - String type = box.getType(); - - if (path.size() == 0 && typeInPath.equals(type)) { - return box; - } - - } - - } - - return null; - } -} - diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/IsoTypeReader.java b/android-aac-enc/src/main/java/com/coremedia/iso/IsoTypeReader.java deleted file mode 100644 index f6ff7a953..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/IsoTypeReader.java +++ /dev/null @@ -1,148 +0,0 @@ -/* - * Copyright 2012 Sebastian Annies, Hamburg - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.coremedia.iso; - -import java.io.ByteArrayOutputStream; -import java.nio.ByteBuffer; - -public final class IsoTypeReader { - - - public static long readUInt32BE(ByteBuffer bb) { - long ch1 = readUInt8(bb); - long ch2 = readUInt8(bb); - long ch3 = readUInt8(bb); - long ch4 = readUInt8(bb); - return ((ch4 << 24) + (ch3 << 16) + (ch2 << 8) + (ch1 << 0)); - - } - - - public static long readUInt32(ByteBuffer bb) { - long ch1 = readUInt8(bb); - long ch2 = readUInt8(bb); - long ch3 = readUInt8(bb); - long ch4 = readUInt8(bb); - return ((ch1 << 24) + (ch2 << 16) + (ch3 << 8) + (ch4 << 0)); - - } - - public static int readUInt24(ByteBuffer bb) { - int result = 0; - result += readUInt16(bb) << 8; - result += byte2int(bb.get()); - return result; - } - - - public static int readUInt16(ByteBuffer bb) { - int result = 0; - result += byte2int(bb.get()) << 8; - result += byte2int(bb.get()); - return result; - } - - public static int readUInt16BE(ByteBuffer bb) { - int result = 0; - result += byte2int(bb.get()); - result += byte2int(bb.get()) << 8; - return result; - } - - public static int readUInt8(ByteBuffer bb) { - return byte2int(bb.get()); - } - - public static int byte2int(byte b) { - return b < 0 ? b + 256 : b; - } - - - /** - * Reads a zero terminated UTF-8 string. - * - * @param byteBuffer the data source - * @return the string readByte - * @throws Error in case of an error in the underlying stream - */ - public static String readString(ByteBuffer byteBuffer) { - - ByteArrayOutputStream out = new ByteArrayOutputStream(); - int read; - while ((read = byteBuffer.get()) != 0) { - out.write(read); - } - return Utf8.convert(out.toByteArray()); - } - - public static String readString(ByteBuffer byteBuffer, int length) { - byte[] buffer = new byte[length]; - byteBuffer.get(buffer); - return Utf8.convert(buffer); - - } - - public static long readUInt64(ByteBuffer byteBuffer) { - long result = 0; - // thanks to Erik Nicolas for finding a bug! Cast to long is definitivly needed - result += readUInt32(byteBuffer) << 32; - if (result < 0) { - throw new RuntimeException("I don't know how to deal with UInt64! long is not sufficient and I don't want to use BigInt"); - } - result += readUInt32(byteBuffer); - - return result; - } - - public static double readFixedPoint1616(ByteBuffer bb) { - byte[] bytes = new byte[4]; - bb.get(bytes); - - int result = 0; - result |= ((bytes[0] << 24) & 0xFF000000); - result |= ((bytes[1] << 16) & 0xFF0000); - result |= ((bytes[2] << 8) & 0xFF00); - result |= ((bytes[3]) & 0xFF); - return ((double) result) / 65536; - - } - - public static float readFixedPoint88(ByteBuffer bb) { - byte[] bytes = new byte[2]; - bb.get(bytes); - short result = 0; - result |= ((bytes[0] << 8) & 0xFF00); - result |= ((bytes[1]) & 0xFF); - return ((float) result) / 256; - } - - public static String readIso639(ByteBuffer bb) { - int bits = readUInt16(bb); - StringBuilder result = new StringBuilder(); - for (int i = 0; i < 3; i++) { - int c = (bits >> (2 - i) * 5) & 0x1f; - result.append((char) (c + 0x60)); - } - return result.toString(); - } - - public static String read4cc(ByteBuffer bb) { - byte[] b = new byte[4]; - bb.get(b); - return IsoFile.bytesToFourCC(b); - } - -} diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/IsoTypeReaderVariable.java b/android-aac-enc/src/main/java/com/coremedia/iso/IsoTypeReaderVariable.java deleted file mode 100644 index a2e4681a5..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/IsoTypeReaderVariable.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright 2012 Sebastian Annies, Hamburg - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.coremedia.iso; - -import java.nio.ByteBuffer; - -public final class IsoTypeReaderVariable { - - public static long read(ByteBuffer bb, int bytes) { - switch (bytes) { - case 1: - return IsoTypeReader.readUInt8(bb); - case 2: - return IsoTypeReader.readUInt16(bb); - case 3: - return IsoTypeReader.readUInt24(bb); - case 4: - return IsoTypeReader.readUInt32(bb); - case 8: - return IsoTypeReader.readUInt64(bb); - default: - throw new RuntimeException("I don't know how to read " + bytes + " bytes"); - } - - } -} diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/IsoTypeWriter.java b/android-aac-enc/src/main/java/com/coremedia/iso/IsoTypeWriter.java deleted file mode 100644 index 78f4b9101..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/IsoTypeWriter.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Copyright 2012 Sebastian Annies, Hamburg - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.coremedia.iso; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.nio.ByteBuffer; - -public final class IsoTypeWriter { - - public static void writeUInt64(ByteBuffer bb, long u) { - - writeUInt32(bb, ((u >> 32) & 0xFFFFFFFFl)); - writeUInt32(bb, u & 0xFFFFFFFFl); - - } - - public static void writeUInt32(ByteBuffer bb, long u) { - assert u >= 0 && u <= 1L << 32 : "The given long is not in the range of uint32 (" + u + ")"; - writeUInt16(bb, (int) ((u >> 16) & 0xFFFF)); - writeUInt16(bb, (int) u & 0xFFFF); - - } - - public static void writeUInt32BE(ByteBuffer bb, long u) { - assert u >= 0 && u <= 1L << 32 : "The given long is not in the range of uint32 (" + u + ")"; - writeUInt16BE(bb, (int) u & 0xFFFF); - writeUInt16BE(bb, (int) ((u >> 16) & 0xFFFF)); - - } - - - public static void writeUInt24(ByteBuffer bb, int i) { - i = i & 0xFFFFFF; - writeUInt16(bb, i >> 8); - writeUInt8(bb, i); - - } - - - public static void writeUInt16(ByteBuffer bb, int i) { - i = i & 0xFFFF; - writeUInt8(bb, i >> 8); - writeUInt8(bb, i & 0xFF); - } - - public static void writeUInt16BE(ByteBuffer bb, int i) { - i = i & 0xFFFF; - writeUInt8(bb, i & 0xFF); - writeUInt8(bb, i >> 8); - } - - public static void writeUInt8(ByteBuffer bb, int i) { - bb.put(int2byte(i)); - } - - - public static void writeFixedPont1616(ByteBuffer bb, double v) { - int result = (int) (v * 65536); - bb.put((byte) ((result & 0xFF000000) >> 24)); - bb.put((byte) ((result & 0x00FF0000) >> 16)); - bb.put((byte) ((result & 0x0000FF00) >> 8)); - bb.put((byte) ((result & 0x000000FF))); - } - - public static void writeFixedPont88(ByteBuffer bb, double v) { - short result = (short) (v * 256); - bb.put((byte) ((result & 0xFF00) >> 8)); - bb.put((byte) ((result & 0x00FF))); - } - - public static byte int2byte(int i) { - i = i & 0xFF; - return (byte) (i > 127 ? i - 256 : i); - } - - public static void writeIso639(ByteBuffer bb, String language) { - int bits = 0; - for (int i = 0; i < 3; i++) { - bits += (language.getBytes()[i] - 0x60) << (2 - i) * 5; - } - writeUInt16(bb, bits); - } - - public static void writeUtf8String(ByteBuffer bb, String string) { - - bb.put(Utf8.convert(string)); - writeUInt8(bb, 0); - } -} diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/IsoTypeWriterVariable.java b/android-aac-enc/src/main/java/com/coremedia/iso/IsoTypeWriterVariable.java deleted file mode 100644 index 3b3bdd4f1..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/IsoTypeWriterVariable.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright 2012 Sebastian Annies, Hamburg - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.coremedia.iso; - -import java.io.IOException; -import java.nio.ByteBuffer; - -public final class IsoTypeWriterVariable { - - public static void write(long v, ByteBuffer bb, int bytes) { - switch (bytes) { - case 1: - IsoTypeWriter.writeUInt8(bb, (int) (v & 0xff)); - break; - case 2: - IsoTypeWriter.writeUInt16(bb, (int) (v & 0xffff)); - break; - case 3: - IsoTypeWriter.writeUInt24(bb, (int) (v & 0xffffff)); - break; - case 4: - IsoTypeWriter.writeUInt32(bb, v); - break; - case 8: - IsoTypeWriter.writeUInt64(bb, v); - break; - default: - throw new RuntimeException("I don't know how to read " + bytes + " bytes"); - } - - } -} diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/PropertyBoxParserImpl.java b/android-aac-enc/src/main/java/com/coremedia/iso/PropertyBoxParserImpl.java deleted file mode 100644 index 423be5dac..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/PropertyBoxParserImpl.java +++ /dev/null @@ -1,207 +0,0 @@ -/* - * Copyright 2012 Sebastian Annies, Hamburg - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.coremedia.iso; - -import java.io.BufferedInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.lang.reflect.Constructor; -import java.lang.reflect.InvocationTargetException; -import java.net.URL; -import java.util.Enumeration; -import java.util.Properties; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import android.content.Context; - -import com.coremedia.iso.boxes.Box; -import com.googlecode.mp4parser.AbstractBox; -import com.todoroo.aacenc.AACToM4A; -import com.todoroo.aacenc.R; - -/** - * A Property file based BoxFactory - */ -public class PropertyBoxParserImpl extends AbstractBoxParser { - Properties mapping; - - public PropertyBoxParserImpl(String... customProperties) { - Context context = AACToM4A.getContext(); - InputStream raw = null, is = null; - mapping = new Properties(); - try { - raw = context.getResources().openRawResource(R.raw.isoparser); - is = new BufferedInputStream(raw); - mapping.load(is); - Enumeration enumeration = Thread.currentThread().getContextClassLoader().getResources("isoparser-custom.properties"); - - while (enumeration.hasMoreElements()) { - URL url = enumeration.nextElement(); - InputStream customIS = new BufferedInputStream(url.openStream()); - try { - mapping.load(customIS); - } finally { - customIS.close(); - } - } - for (String customProperty : customProperties) { - mapping.load(new BufferedInputStream(getClass().getResourceAsStream(customProperty))); - } - } catch (IOException e) { - throw new RuntimeException(e); - } finally { - try { - if(raw != null) - raw.close(); - if(is != null) - is.close(); - } catch (IOException e) { - e.printStackTrace(); - // ignore - I can't help - } - } - } - - public PropertyBoxParserImpl(Properties mapping) { - this.mapping = mapping; - } - - Pattern p = Pattern.compile("(.*)\\((.*?)\\)"); - - @SuppressWarnings("unchecked") - public Class getClassForFourCc(String type, byte[] userType, String parent) { - FourCcToBox fourCcToBox = new FourCcToBox(type, userType, parent).invoke(); - try { - return (Class) Class.forName(fourCcToBox.clazzName); - } catch (ClassNotFoundException e) { - throw new RuntimeException(e); - } - } - - @Override - public Box createBox(String type, byte[] userType, String parent) { - - FourCcToBox fourCcToBox = new FourCcToBox(type, userType, parent).invoke(); - String[] param = fourCcToBox.getParam(); - String clazzName = fourCcToBox.getClazzName(); - try { - if (param[0].trim().length() == 0) { - param = new String[]{}; - } - Class clazz = Class.forName(clazzName); - - Class[] constructorArgsClazz = new Class[param.length]; - Object[] constructorArgs = new Object[param.length]; - for (int i = 0; i < param.length; i++) { - - if ("userType".equals(param[i])) { - constructorArgs[i] = userType; - constructorArgsClazz[i] = byte[].class; - } else if ("type".equals(param[i])) { - constructorArgs[i] = type; - constructorArgsClazz[i] = String.class; - } else if ("parent".equals(param[i])) { - constructorArgs[i] = parent; - constructorArgsClazz[i] = String.class; - } else { - throw new InternalError("No such param: " + param[i]); - } - - - } - Constructor constructorObject; - try { - if (param.length > 0) { - constructorObject = clazz.getConstructor(constructorArgsClazz); - } else { - constructorObject = clazz.getConstructor(); - } - - return constructorObject.newInstance(constructorArgs); - } catch (NoSuchMethodException e) { - throw new RuntimeException(e); - } catch (InvocationTargetException e) { - throw new RuntimeException(e); - } catch (InstantiationException e) { - throw new RuntimeException(e); - } catch (IllegalAccessException e) { - throw new RuntimeException(e); - } - - - } catch (ClassNotFoundException e) { - throw new RuntimeException(e); - } - } - - private class FourCcToBox { - private String type; - private byte[] userType; - private String parent; - private String clazzName; - private String[] param; - - public FourCcToBox(String type, byte[] userType, String parent) { - this.type = type; - this.parent = parent; - this.userType = userType; - } - - public String getClazzName() { - return clazzName; - } - - public String[] getParam() { - return param; - } - - public FourCcToBox invoke() { - String constructor; - if (userType != null) { - if (!"uuid".equals((type))) { - throw new RuntimeException("we have a userType but no uuid box type. Something's wrong"); - } - constructor = mapping.getProperty((parent) + "-uuid[" + Hex.encodeHex(userType).toUpperCase() + "]"); - if (constructor == null) { - constructor = mapping.getProperty("uuid[" + Hex.encodeHex(userType).toUpperCase() + "]"); - } - if (constructor == null) { - constructor = mapping.getProperty("uuid"); - } - } else { - constructor = mapping.getProperty((parent) + "-" + (type)); - if (constructor == null) { - constructor = mapping.getProperty((type)); - } - } - if (constructor == null) { - constructor = mapping.getProperty("default"); - } - if (constructor == null) { - throw new RuntimeException("No box object found for " + type); - } - Matcher m = p.matcher(constructor); - boolean matches = m.matches(); - if (!matches) { - throw new RuntimeException("Cannot work with that constructor: " + constructor); - } - clazzName = m.group(1); - param = m.group(2).split(","); - return this; - } - } -} diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/Utf8.java b/android-aac-enc/src/main/java/com/coremedia/iso/Utf8.java deleted file mode 100644 index a30497e4f..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/Utf8.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright 2012 Sebastian Annies, Hamburg - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.coremedia.iso; - -import java.io.UnsupportedEncodingException; - -/** - * Converts byte[] -> String and vice versa. - */ -public final class Utf8 { - public static byte[] convert(String s) { - try { - if (s != null) { - return s.getBytes("UTF-8"); - } else { - return null; - } - } catch (UnsupportedEncodingException e) { - throw new Error(e); - } - } - - public static String convert(byte[] b) { - try { - if (b != null) { - return new String(b, "UTF-8"); - } else { - return null; - } - } catch (UnsupportedEncodingException e) { - throw new Error(e); - } - } - - public static int utf8StringLengthInBytes(String utf8) { - try { - if (utf8 != null) { - return utf8.getBytes("UTF-8").length; - } else { - return 0; - } - } catch (UnsupportedEncodingException e) { - throw new RuntimeException(); - } - } -} diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/AbstractMediaHeaderBox.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/AbstractMediaHeaderBox.java deleted file mode 100644 index cc141ae0c..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/AbstractMediaHeaderBox.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright 2011 Sebastian Annies, Hamburg, Germany - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coremedia.iso.boxes; - -import com.googlecode.mp4parser.AbstractFullBox; - -/** - * A common superclass for all MediaInformationHeaderBoxes. E.g. - * VideoMediaHeaderBox, SoundMediaHeaderBox & HintMediaHeaderBox - */ -public abstract class AbstractMediaHeaderBox extends AbstractFullBox { - protected AbstractMediaHeaderBox(String type) { - super(type); - } -} diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/AlbumBox.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/AlbumBox.java deleted file mode 100644 index d66680691..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/AlbumBox.java +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Copyright 2008 CoreMedia AG, Hamburg - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coremedia.iso.boxes; - -import com.coremedia.iso.IsoTypeReader; -import com.coremedia.iso.IsoTypeWriter; -import com.coremedia.iso.Utf8; -import com.googlecode.mp4parser.AbstractFullBox; - -import java.nio.ByteBuffer; - -/** - * Meta information in a 'udta' box about a track. - * Defined in 3GPP 26.244. - * - * @see com.coremedia.iso.boxes.UserDataBox - */ -public class AlbumBox extends AbstractFullBox { - public static final String TYPE = "albm"; - - private String language; - private String albumTitle; - private int trackNumber; - - public AlbumBox() { - super(TYPE); - } - - /** - * Declares the language code for the {@link #getAlbumTitle()} return value. See ISO 639-2/T for the set of three - * character codes.Each character is packed as the difference between its ASCII value and 0x60. The code is - * confined to being three lower-case letters, so these values are strictly positive. - * - * @return the language code - */ - public String getLanguage() { - return language; - } - - public String getAlbumTitle() { - return albumTitle; - } - - public int getTrackNumber() { - return trackNumber; - } - - public void setLanguage(String language) { - this.language = language; - } - - public void setAlbumTitle(String albumTitle) { - this.albumTitle = albumTitle; - } - - public void setTrackNumber(int trackNumber) { - this.trackNumber = trackNumber; - } - - protected long getContentSize() { - return 6 + Utf8.utf8StringLengthInBytes(albumTitle) + 1 + (trackNumber == -1 ? 0 : 1); - } - - @Override - public void _parseDetails(ByteBuffer content) { - parseVersionAndFlags(content); - language = IsoTypeReader.readIso639(content); - albumTitle = IsoTypeReader.readString(content); - - if (content.remaining() > 0) { - trackNumber = IsoTypeReader.readUInt8(content); - } else { - trackNumber = -1; - } - } - - @Override - protected void getContent(ByteBuffer byteBuffer) { - writeVersionAndFlags(byteBuffer); - IsoTypeWriter.writeIso639(byteBuffer, language); - byteBuffer.put(Utf8.convert(albumTitle)); - byteBuffer.put((byte) 0); - if (trackNumber != -1) { - IsoTypeWriter.writeUInt8(byteBuffer, trackNumber); - } - } - - public String toString() { - StringBuilder buffer = new StringBuilder(); - buffer.append("AlbumBox[language=").append(getLanguage()).append(";"); - buffer.append("albumTitle=").append(getAlbumTitle()); - if (trackNumber >= 0) { - buffer.append(";trackNumber=").append(getTrackNumber()); - } - buffer.append("]"); - return buffer.toString(); - } -} diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/AuthorBox.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/AuthorBox.java deleted file mode 100644 index 672cde26a..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/AuthorBox.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright 2008 CoreMedia AG, Hamburg - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coremedia.iso.boxes; - - -import com.coremedia.iso.IsoTypeReader; -import com.coremedia.iso.IsoTypeWriter; -import com.coremedia.iso.Utf8; -import com.googlecode.mp4parser.AbstractFullBox; - -import java.nio.ByteBuffer; - -/** - * Meta information in a 'udta' box about a track. - * Defined in 3GPP 26.244. - * - * @see com.coremedia.iso.boxes.UserDataBox - */ -public class AuthorBox extends AbstractFullBox { - public static final String TYPE = "auth"; - - private String language; - private String author; - - public AuthorBox() { - super(TYPE); - } - - /** - * Declares the language code for the {@link #getAuthor()} return value. See ISO 639-2/T for the set of three - * character codes.Each character is packed as the difference between its ASCII value and 0x60. The code is - * confined to being three lower-case letters, so these values are strictly positive. - * - * @return the language code - */ - public String getLanguage() { - return language; - } - - /** - * Author information. - * - * @return the author - */ - public String getAuthor() { - return author; - } - - public void setLanguage(String language) { - this.language = language; - } - - public void setAuthor(String author) { - this.author = author; - } - - protected long getContentSize() { - return 7 + Utf8.utf8StringLengthInBytes(author); - } - - @Override - public void _parseDetails(ByteBuffer content) { - parseVersionAndFlags(content); - language = IsoTypeReader.readIso639(content); - author = IsoTypeReader.readString(content); - } - - @Override - protected void getContent(ByteBuffer byteBuffer) { - writeVersionAndFlags(byteBuffer); - IsoTypeWriter.writeIso639(byteBuffer, language); - byteBuffer.put(Utf8.convert(author)); - byteBuffer.put((byte) 0); - } - - - public String toString() { - return "AuthorBox[language=" + getLanguage() + ";author=" + getAuthor() + "]"; - } -} diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/BitRateBox.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/BitRateBox.java deleted file mode 100644 index 6c4b0e655..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/BitRateBox.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright 2008 CoreMedia AG, Hamburg - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coremedia.iso.boxes; - -import com.coremedia.iso.IsoTypeReader; -import com.coremedia.iso.IsoTypeWriter; -import com.googlecode.mp4parser.AbstractBox; - -import java.nio.ByteBuffer; - -/** - * class BitRateBox extends Box('btrt') {
- * unsigned int(32) bufferSizeDB;
- * // gives the size of the decoding buffer for
- * // the elementary stream in bytes.
- * unsigned int(32) maxBitrate;
- * // gives the maximum rate in bits/second
- * // over any window of one second.
- * unsigned int(32) avgBitrate;
- * // avgBitrate gives the average rate in
- * // bits/second over the entire presentation.
- * }
- */ - -public final class BitRateBox extends AbstractBox { - public static final String TYPE = "btrt"; - - private long bufferSizeDb; - private long maxBitrate; - private long avgBitrate; - - public BitRateBox() { - super(TYPE); - } - - protected long getContentSize() { - return 12; - } - - @Override - public void _parseDetails(ByteBuffer content) { - bufferSizeDb = IsoTypeReader.readUInt32(content); - maxBitrate = IsoTypeReader.readUInt32(content); - avgBitrate = IsoTypeReader.readUInt32(content); - } - - @Override - protected void getContent(ByteBuffer byteBuffer) { - IsoTypeWriter.writeUInt32(byteBuffer, bufferSizeDb); - IsoTypeWriter.writeUInt32(byteBuffer, maxBitrate); - IsoTypeWriter.writeUInt32(byteBuffer, avgBitrate); - } - - public long getBufferSizeDb() { - return bufferSizeDb; - } - - public void setBufferSizeDb(long bufferSizeDb) { - this.bufferSizeDb = bufferSizeDb; - } - - public long getMaxBitrate() { - return maxBitrate; - } - - public void setMaxBitrate(long maxBitrate) { - this.maxBitrate = maxBitrate; - } - - public long getAvgBitrate() { - return avgBitrate; - } - - public void setAvgBitrate(long avgBitrate) { - this.avgBitrate = avgBitrate; - } -} diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/Box.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/Box.java deleted file mode 100644 index f6ca30265..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/Box.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright 2008 CoreMedia AG, Hamburg - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coremedia.iso.boxes; - -import com.coremedia.iso.BoxParser; -import com.coremedia.iso.boxes.ContainerBox; - -import java.io.IOException; -import java.nio.ByteBuffer; -import java.nio.channels.ReadableByteChannel; -import java.nio.channels.WritableByteChannel; - -/** - * Defines basic interaction possibilities for any ISO box. Each box has a parent box and a type. - */ -public interface Box { - ContainerBox getParent(); - - void setParent(ContainerBox parent); - - long getSize(); - - /** - * The box's 4-cc type. - * @return the 4 character type of the box - */ - String getType(); - - /** - * Writes the complete box - size | 4-cc | content - to the given writableByteChannel. - * @param writableByteChannel the box's sink - * @throws IOException in case of problems with the Channel - */ - void getBox(WritableByteChannel writableByteChannel) throws IOException; - - void parse(ReadableByteChannel readableByteChannel, ByteBuffer header, long contentSize, BoxParser boxParser) throws IOException; -} diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/ChunkOffset64BitBox.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/ChunkOffset64BitBox.java deleted file mode 100755 index f2340b95b..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/ChunkOffset64BitBox.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.coremedia.iso.boxes; - -import com.coremedia.iso.IsoTypeReader; -import com.coremedia.iso.IsoTypeWriter; - -import java.nio.ByteBuffer; - -import static com.googlecode.mp4parser.util.CastUtils.l2i; - -/** - * Abstract Chunk Offset Box - */ -public class ChunkOffset64BitBox extends ChunkOffsetBox { - public static final String TYPE = "co64"; - private long[] chunkOffsets; - - public ChunkOffset64BitBox() { - super(TYPE); - } - - @Override - public long[] getChunkOffsets() { - return chunkOffsets; - } - - @Override - protected long getContentSize() { - return 8 + 8 * chunkOffsets.length; - } - - @Override - public void _parseDetails(ByteBuffer content) { - parseVersionAndFlags(content); - int entryCount = l2i(IsoTypeReader.readUInt32(content)); - chunkOffsets = new long[entryCount]; - for (int i = 0; i < entryCount; i++) { - chunkOffsets[i] = IsoTypeReader.readUInt64(content); - } - } - - @Override - protected void getContent(ByteBuffer byteBuffer) { - writeVersionAndFlags(byteBuffer); - IsoTypeWriter.writeUInt32(byteBuffer, chunkOffsets.length); - for (long chunkOffset : chunkOffsets) { - IsoTypeWriter.writeUInt64(byteBuffer, chunkOffset); - } - } - - -} diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/ChunkOffsetBox.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/ChunkOffsetBox.java deleted file mode 100755 index 01f5ae45a..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/ChunkOffsetBox.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.coremedia.iso.boxes; - -import com.googlecode.mp4parser.AbstractFullBox; - -/** - * Abstract Chunk Offset Box - */ -public abstract class ChunkOffsetBox extends AbstractFullBox { - - public ChunkOffsetBox(String type) { - super(type); - } - - public abstract long[] getChunkOffsets(); - - - public String toString() { - return this.getClass().getSimpleName() + "[entryCount=" + getChunkOffsets().length + "]"; - } - -} diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/ClassificationBox.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/ClassificationBox.java deleted file mode 100644 index a20fecaf9..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/ClassificationBox.java +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright 2008 CoreMedia AG, Hamburg - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coremedia.iso.boxes; - -import com.coremedia.iso.IsoFile; -import com.coremedia.iso.IsoTypeReader; -import com.coremedia.iso.IsoTypeWriter; -import com.coremedia.iso.Utf8; -import com.googlecode.mp4parser.AbstractFullBox; - -import java.nio.ByteBuffer; - -/** - * Classification of the media according to 3GPP 26.244. - */ -public class ClassificationBox extends AbstractFullBox { - public static final String TYPE = "clsf"; - - - private String classificationEntity; - private int classificationTableIndex; - private String language; - private String classificationInfo; - - public ClassificationBox() { - super(TYPE); - } - - public String getLanguage() { - return language; - } - - public String getClassificationEntity() { - return classificationEntity; - } - - public int getClassificationTableIndex() { - return classificationTableIndex; - } - - public String getClassificationInfo() { - return classificationInfo; - } - - public void setClassificationEntity(String classificationEntity) { - this.classificationEntity = classificationEntity; - } - - public void setClassificationTableIndex(int classificationTableIndex) { - this.classificationTableIndex = classificationTableIndex; - } - - public void setLanguage(String language) { - this.language = language; - } - - public void setClassificationInfo(String classificationInfo) { - this.classificationInfo = classificationInfo; - } - - protected long getContentSize() { - return 4 + 2 + 2 + Utf8.utf8StringLengthInBytes(classificationInfo) + 1; - } - - @Override - public void _parseDetails(ByteBuffer content) { - parseVersionAndFlags(content); - byte[] cE = new byte[4]; - content.get(cE); - classificationEntity = IsoFile.bytesToFourCC(cE); - classificationTableIndex = IsoTypeReader.readUInt16(content); - language = IsoTypeReader.readIso639(content); - classificationInfo = IsoTypeReader.readString(content); - } - - @Override - protected void getContent(ByteBuffer byteBuffer) { - byteBuffer.put(IsoFile.fourCCtoBytes(classificationEntity)); - IsoTypeWriter.writeUInt16(byteBuffer, classificationTableIndex); - IsoTypeWriter.writeIso639(byteBuffer, language); - byteBuffer.put(Utf8.convert(classificationInfo)); - byteBuffer.put((byte) 0); - } - - - public String toString() { - StringBuilder buffer = new StringBuilder(); - buffer.append("ClassificationBox[language=").append(getLanguage()); - buffer.append("classificationEntity=").append(getClassificationEntity()); - buffer.append(";classificationTableIndex=").append(getClassificationTableIndex()); - buffer.append(";language=").append(getLanguage()); - buffer.append(";classificationInfo=").append(getClassificationInfo()); - buffer.append("]"); - return buffer.toString(); - } -} diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/CompositionShiftLeastGreatestAtom.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/CompositionShiftLeastGreatestAtom.java deleted file mode 100644 index 3534b7ffd..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/CompositionShiftLeastGreatestAtom.java +++ /dev/null @@ -1,101 +0,0 @@ -package com.coremedia.iso.boxes; - -import com.googlecode.mp4parser.AbstractFullBox; - -import java.nio.ByteBuffer; - -/** - * The optional composition shift least greatest atom summarizes the calculated - * minimum and maximum offsets between decode and composition time, as well as - * the start and end times, for all samples. This allows a reader to determine - * the minimum required time for decode to obtain proper presentation order without - * needing to scan the sample table for the range of offsets. The type of the - * composition shift least greatest atom is ‘cslg’. - */ -public class CompositionShiftLeastGreatestAtom extends AbstractFullBox { - public CompositionShiftLeastGreatestAtom() { - super("cslg"); - } - - // A 32-bit unsigned integer that specifies the calculated value. - int compositionOffsetToDisplayOffsetShift; - - // A 32-bit signed integer that specifies the calculated value. - int leastDisplayOffset; - - // A 32-bit signed integer that specifies the calculated value. - int greatestDisplayOffset; - - //A 32-bit signed integer that specifies the calculated value. - int displayStartTime; - - //A 32-bit signed integer that specifies the calculated value. - int displayEndTime; - - - @Override - protected long getContentSize() { - return 24; - } - - @Override - public void _parseDetails(ByteBuffer content) { - parseVersionAndFlags(content); - compositionOffsetToDisplayOffsetShift = content.getInt(); - leastDisplayOffset = content.getInt(); - greatestDisplayOffset = content.getInt(); - displayStartTime = content.getInt(); - displayEndTime = content.getInt(); - } - - @Override - protected void getContent(ByteBuffer byteBuffer) { - writeVersionAndFlags(byteBuffer); - byteBuffer.putInt(compositionOffsetToDisplayOffsetShift); - byteBuffer.putInt(leastDisplayOffset); - byteBuffer.putInt(greatestDisplayOffset); - byteBuffer.putInt(displayStartTime); - byteBuffer.putInt(displayEndTime); - } - - - public int getCompositionOffsetToDisplayOffsetShift() { - return compositionOffsetToDisplayOffsetShift; - } - - public void setCompositionOffsetToDisplayOffsetShift(int compositionOffsetToDisplayOffsetShift) { - this.compositionOffsetToDisplayOffsetShift = compositionOffsetToDisplayOffsetShift; - } - - public int getLeastDisplayOffset() { - return leastDisplayOffset; - } - - public void setLeastDisplayOffset(int leastDisplayOffset) { - this.leastDisplayOffset = leastDisplayOffset; - } - - public int getGreatestDisplayOffset() { - return greatestDisplayOffset; - } - - public void setGreatestDisplayOffset(int greatestDisplayOffset) { - this.greatestDisplayOffset = greatestDisplayOffset; - } - - public int getDisplayStartTime() { - return displayStartTime; - } - - public void setDisplayStartTime(int displayStartTime) { - this.displayStartTime = displayStartTime; - } - - public int getDisplayEndTime() { - return displayEndTime; - } - - public void setDisplayEndTime(int displayEndTime) { - this.displayEndTime = displayEndTime; - } -} diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/CompositionTimeToSample.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/CompositionTimeToSample.java deleted file mode 100644 index 411bfe916..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/CompositionTimeToSample.java +++ /dev/null @@ -1,150 +0,0 @@ -package com.coremedia.iso.boxes; - -import com.coremedia.iso.IsoTypeReader; -import com.coremedia.iso.IsoTypeWriter; -import com.googlecode.mp4parser.AbstractFullBox; - -import java.nio.ByteBuffer; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -import static com.googlecode.mp4parser.util.CastUtils.l2i; - -/** - *
- * aligned(8) class CompositionOffsetBox
- * extends FullBox(‘ctts’, version = 0, 0) {
- *  unsigned int(32) entry_count;
- *  int i;
- *  if (version==0) {
- *   for (i=0; i < entry_count; i++) {
- *    unsigned int(32) sample_count;
- *    unsigned int(32) sample_offset;
- *   }
- *  }
- *  else if (version == 1) {
- *   for (i=0; i < entry_count; i++) {
- *    unsigned int(32) sample_count;
- *    signed int(32) sample_offset;
- *   }
- *  }
- * }
- * 
- *

- * This box provides the offset between decoding time and composition time. - * In version 0 of this box the decoding time must be less than the composition time, and - * the offsets are expressed as unsigned numbers such that - * CT(n) = DT(n) + CTTS(n) where CTTS(n) is the (uncompressed) table entry for sample n. - *

- * In version 1 of this box, the composition timeline and the decoding timeline are - * still derived from each other, but the offsets are signed. - * It is recommended that for the computed composition timestamps, there is - * exactly one with the value 0 (zero). - */ -public class CompositionTimeToSample extends AbstractFullBox { - public static final String TYPE = "ctts"; - - List entries = Collections.emptyList(); - - public CompositionTimeToSample() { - super(TYPE); - } - - protected long getContentSize() { - return 8 + 8 * entries.size(); - } - - public List getEntries() { - return entries; - } - - public void setEntries(List entries) { - this.entries = entries; - } - - @Override - public void _parseDetails(ByteBuffer content) { - parseVersionAndFlags(content); - int numberOfEntries = l2i(IsoTypeReader.readUInt32(content)); - entries = new ArrayList(numberOfEntries); - for (int i = 0; i < numberOfEntries; i++) { - Entry e = new Entry(l2i(IsoTypeReader.readUInt32(content)), content.getInt()); - entries.add(e); - } - } - - @Override - protected void getContent(ByteBuffer byteBuffer) { - writeVersionAndFlags(byteBuffer); - IsoTypeWriter.writeUInt32(byteBuffer, entries.size()); - - for (Entry entry : entries) { - IsoTypeWriter.writeUInt32(byteBuffer, entry.getCount()); - byteBuffer.putInt(entry.getOffset()); - } - - } - - - public static class Entry { - int count; - int offset; - - public Entry(int count, int offset) { - this.count = count; - this.offset = offset; - } - - public int getCount() { - return count; - } - - public int getOffset() { - return offset; - } - - public void setCount(int count) { - this.count = count; - } - - public void setOffset(int offset) { - this.offset = offset; - } - - @Override - public String toString() { - return "Entry{" + - "count=" + count + - ", offset=" + offset + - '}'; - } - } - - - /** - * Decompresses the list of entries and returns the list of composition times. - * - * @return decoding time per sample - */ - public static int[] blowupCompositionTimes(List entries) { - long numOfSamples = 0; - for (CompositionTimeToSample.Entry entry : entries) { - numOfSamples += entry.getCount(); - } - assert numOfSamples <= Integer.MAX_VALUE; - int[] decodingTime = new int[(int) numOfSamples]; - - int current = 0; - - - for (CompositionTimeToSample.Entry entry : entries) { - for (int i = 0; i < entry.getCount(); i++) { - decodingTime[current++] = entry.getOffset(); - } - } - - return decodingTime; - } - -} diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/ContainerBox.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/ContainerBox.java deleted file mode 100644 index a01637420..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/ContainerBox.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright 2008 CoreMedia AG, Hamburg - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coremedia.iso.boxes; - -import com.coremedia.iso.IsoFile; - -import java.util.List; - -/** - * Interface for all ISO boxes that may contain other boxes. - */ -public interface ContainerBox extends Box { - - /** - * Gets all child boxes. May not return null. - * - * @return an array of boxes, empty array in case of no children. - */ - List getBoxes(); - - /** - * Sets all boxes and removes all previous child boxes. - * @param boxes the new list of children - */ - void setBoxes(List boxes); - - /** - * Gets all child boxes of the given type. May not return null. - * - * @param clazz child box's type - * @return an array of boxes, empty array in case of no children. - */ - List getBoxes(Class clazz); - - /** - * Gets all child boxes of the given type. May not return null. - * - * @param clazz child box's type - * @param recursive step down the tree - * @return an array of boxes, empty array in case of no children. - */ - List getBoxes(Class clazz, boolean recursive); - - /** - * Gets the parent box. May be null in case of the - * {@link com.coremedia.iso.IsoFile} itself. - * - * @return a ContainerBox that contains this - */ - ContainerBox getParent(); - - /** - * Returns the number of bytes from the start of the box to start of the first child. - * - * @return offset of first child from box start - */ - long getNumOfBytesToFirstChild(); - - IsoFile getIsoFile(); -} diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/CopyrightBox.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/CopyrightBox.java deleted file mode 100644 index 86bc2152b..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/CopyrightBox.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright 2008 CoreMedia AG, Hamburg - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coremedia.iso.boxes; - - -import com.coremedia.iso.IsoTypeReader; -import com.coremedia.iso.IsoTypeWriter; -import com.coremedia.iso.Utf8; -import com.googlecode.mp4parser.AbstractFullBox; - -import java.nio.ByteBuffer; - -/** - * The copyright box contains a copyright declaration which applies to the entire presentation, when contained - * within the MovieBox, or, when contained in a track, to that entire track. There may be multple boxes using - * different language codes. - * - * @see MovieBox - * @see TrackBox - */ -public class CopyrightBox extends AbstractFullBox { - public static final String TYPE = "cprt"; - - private String language; - private String copyright; - - public CopyrightBox() { - super(TYPE); - } - - public String getLanguage() { - return language; - } - - public String getCopyright() { - return copyright; - } - - public void setLanguage(String language) { - this.language = language; - } - - public void setCopyright(String copyright) { - this.copyright = copyright; - } - - protected long getContentSize() { - return 7 + Utf8.utf8StringLengthInBytes(copyright); - } - - @Override - public void _parseDetails(ByteBuffer content) { - parseVersionAndFlags(content); - language = IsoTypeReader.readIso639(content); - copyright = IsoTypeReader.readString(content); - } - - @Override - protected void getContent(ByteBuffer byteBuffer) { - writeVersionAndFlags(byteBuffer); - IsoTypeWriter.writeIso639(byteBuffer, language); - byteBuffer.put(Utf8.convert(copyright)); - byteBuffer.put((byte) 0); - } - - public String toString() { - return "CopyrightBox[language=" + getLanguage() + ";copyright=" + getCopyright() + "]"; - } - - - -} diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/DataEntryUrlBox.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/DataEntryUrlBox.java deleted file mode 100644 index b58608dc2..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/DataEntryUrlBox.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright 2008 CoreMedia AG, Hamburg - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coremedia.iso.boxes; - -import com.googlecode.mp4parser.AbstractFullBox; - -import java.nio.ByteBuffer; - -/** - * Only used within the DataReferenceBox. Find more information there. - * - * @see com.coremedia.iso.boxes.DataReferenceBox - */ -public class DataEntryUrlBox extends AbstractFullBox { - public static final String TYPE = "url "; - - public DataEntryUrlBox() { - super(TYPE); - } - - @Override - public void _parseDetails(ByteBuffer content) { - parseVersionAndFlags(content); - } - - - @Override - protected void getContent(ByteBuffer byteBuffer) { - writeVersionAndFlags(byteBuffer); - } - - protected long getContentSize() { - return 4; - } - - public String toString() { - return "DataEntryUrlBox[]"; - } -} diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/DataEntryUrnBox.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/DataEntryUrnBox.java deleted file mode 100644 index 042a972d7..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/DataEntryUrnBox.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright 2008 CoreMedia AG, Hamburg - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coremedia.iso.boxes; - -import com.coremedia.iso.IsoTypeReader; -import com.coremedia.iso.Utf8; -import com.googlecode.mp4parser.AbstractFullBox; - -import java.nio.ByteBuffer; - -/** - * Only used within the DataReferenceBox. Find more information there. - * - * @see com.coremedia.iso.boxes.DataReferenceBox - */ -public class DataEntryUrnBox extends AbstractFullBox { - private String name; - private String location; - public static final String TYPE = "urn "; - - public DataEntryUrnBox() { - super(TYPE); - } - - public String getName() { - return name; - } - - public String getLocation() { - return location; - } - - protected long getContentSize() { - return Utf8.utf8StringLengthInBytes(name) + 1 + Utf8.utf8StringLengthInBytes(location) + 1; - } - - @Override - public void _parseDetails(ByteBuffer content) { - name = IsoTypeReader.readString(content); - location = IsoTypeReader.readString(content); - - } - - @Override - protected void getContent(ByteBuffer byteBuffer) { - byteBuffer.put(Utf8.convert(name)); - byteBuffer.put((byte) 0); - byteBuffer.put(Utf8.convert(location)); - byteBuffer.put((byte) 0); - } - - public String toString() { - return "DataEntryUrlBox[name=" + getName() + ";location=" + getLocation() + "]"; - } -} diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/DataInformationBox.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/DataInformationBox.java deleted file mode 100644 index 7f058ebb2..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/DataInformationBox.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2008 CoreMedia AG, Hamburg - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coremedia.iso.boxes; - -import com.googlecode.mp4parser.AbstractContainerBox; - -/** - * - * Box Type: 'dinf'
- * Container: {@link com.coremedia.iso.boxes.MediaInformationBox} ('minf')
- * Mandatory: Yes
- * Quantity: Exactly one

- * The data information box contains objects that declare the location of the media information in a track. - */ -public class DataInformationBox extends AbstractContainerBox { - public static final String TYPE = "dinf"; - - public DataInformationBox() { - super(TYPE); - } - -} diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/DataReferenceBox.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/DataReferenceBox.java deleted file mode 100644 index 8156d3f63..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/DataReferenceBox.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright 2008 CoreMedia AG, Hamburg - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coremedia.iso.boxes; - - -import com.coremedia.iso.IsoTypeWriter; -import com.googlecode.mp4parser.FullContainerBox; - -import java.nio.ByteBuffer; - -/** - * The data reference object contains a table of data references (normally URLs) that declare the location(s) of - * the media data used within the presentation. The data reference index in the sample description ties entries in - * this table to the samples in the track. A track may be split over several sources in this way. - * If the flag is set indicating that the data is in the same file as this box, then no string (not even an empty one) - * shall be supplied in the entry field. - * The DataEntryBox within the DataReferenceBox shall be either a DataEntryUrnBox or a DataEntryUrlBox. - * - * @see com.coremedia.iso.boxes.DataEntryUrlBox - * @see com.coremedia.iso.boxes.DataEntryUrnBox - */ -public class DataReferenceBox extends FullContainerBox { - - public static final String TYPE = "dref"; - - public DataReferenceBox() { - super(TYPE); - - } - - @Override - protected long getContentSize() { - return super.getContentSize() + 4; - } - - @Override - public void _parseDetails(ByteBuffer content) { - parseVersionAndFlags(content); - content.get(new byte[4]); // basically a skip of 4 bytes signaling the number of child boxes - parseChildBoxes(content); - } - - - @Override - protected void getContent(ByteBuffer byteBuffer) { - writeVersionAndFlags(byteBuffer); - IsoTypeWriter.writeUInt32(byteBuffer, getBoxes().size()); - writeChildBoxes(byteBuffer); - } - -} diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/DescriptionBox.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/DescriptionBox.java deleted file mode 100644 index 83520512a..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/DescriptionBox.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright 2008 CoreMedia AG, Hamburg - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coremedia.iso.boxes; - -import com.coremedia.iso.IsoTypeReader; -import com.coremedia.iso.IsoTypeWriter; -import com.coremedia.iso.Utf8; -import com.googlecode.mp4parser.AbstractFullBox; - -import java.nio.ByteBuffer; - -/** - * Gives a language dependent description of the media contained in the ISO file. - */ -public class DescriptionBox extends AbstractFullBox { - public static final String TYPE = "dscp"; - - private String language; - private String description; - - public DescriptionBox() { - super(TYPE); - } - - public String getLanguage() { - return language; - } - - public String getDescription() { - return description; - } - - protected long getContentSize() { - return 7 + Utf8.utf8StringLengthInBytes(description); - } - - @Override - public void _parseDetails(ByteBuffer content) { - parseVersionAndFlags(content); - language = IsoTypeReader.readIso639(content); - description = IsoTypeReader.readString(content); - } - - @Override - protected void getContent(ByteBuffer byteBuffer) { - writeVersionAndFlags(byteBuffer); - IsoTypeWriter.writeIso639(byteBuffer, language); - byteBuffer.put(Utf8.convert(description)); - byteBuffer.put((byte) 0); - } - - public String toString() { - return "DescriptionBox[language=" + getLanguage() + ";description=" + getDescription() + "]"; - } - - public void setLanguage(String language) { - this.language = language; - } - - public void setDescription(String description) { - this.description = description; - } -} diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/EditBox.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/EditBox.java deleted file mode 100644 index db3bc2549..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/EditBox.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright 2008 CoreMedia AG, Hamburg - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coremedia.iso.boxes; - -import com.googlecode.mp4parser.AbstractContainerBox; - -/** - * An Edit Box maps the presentation time-line to the media time-line as it is stored in the file. - * The Edit Box is a container fpr the edit lists. Defined in ISO/IEC 14496-12. - * - * @see EditListBox - */ -public class EditBox extends AbstractContainerBox { - public static final String TYPE = "edts"; - - public EditBox() { - super(TYPE); - } - -} diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/EditListBox.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/EditListBox.java deleted file mode 100644 index 231f8beea..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/EditListBox.java +++ /dev/null @@ -1,248 +0,0 @@ -/* - * Copyright 2008 CoreMedia AG, Hamburg - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coremedia.iso.boxes; - - -import com.coremedia.iso.IsoTypeReader; -import com.coremedia.iso.IsoTypeWriter; -import com.googlecode.mp4parser.AbstractFullBox; - -import java.io.IOException; -import java.nio.ByteBuffer; -import java.util.LinkedList; -import java.util.List; - -import static com.googlecode.mp4parser.util.CastUtils.l2i; - -/** - * - * Box Type : 'elst'
- * Container: {@link EditBox}('edts')
- * Mandatory: No
- * Quantity : Zero or one


- * This box contains an explicit timeline map. Each entry defines part of the track time-line: by mapping part of - * the media time-line, or by indicating 'empty' time, or by defining a 'dwell', where a single time-point in the - * media is held for a period.
- * Note that edits are not restricted to fall on sample times. This means that when entering an edit, it can be - * necessary to (a) back up to a sync point, and pre-roll from there and then (b) be careful about the duration of - * the first sample - it might have been truncated if the edit enters it during its normal duration. If this is audio, - * that frame might need to be decoded, and then the final slicing done. Likewise, the duration of the last sample - * in an edit might need slicing.
- * Starting offsets for tracks (streams) are represented by an initial empty edit. For example, to play a track from - * its start for 30 seconds, but at 10 seconds into the presentation, we have the following edit list:
- *

- *

  • Entry-count = 2
  • - *
  • Segment-duration = 10 seconds
  • - *
  • Media-Time = -1
  • - *
  • Media-Rate = 1
  • - *
  • Segment-duration = 30 seconds (could be the length of the whole track)
  • - *
  • Media-Time = 0 seconds
  • - *
  • Media-Rate = 1
  • - */ -public class EditListBox extends AbstractFullBox { - private List entries = new LinkedList(); - public static final String TYPE = "elst"; - - public EditListBox() { - super(TYPE); - } - - - public List getEntries() { - return entries; - } - - public void setEntries(List entries) { - this.entries = entries; - } - - protected long getContentSize() { - long contentSize = 8; - if (getVersion() == 1) { - contentSize += entries.size() * 20; - } else { - contentSize += entries.size() * 12; - } - - return contentSize; - } - - @Override - public void _parseDetails(ByteBuffer content) { - parseVersionAndFlags(content); - int entryCount = l2i(IsoTypeReader.readUInt32(content)); - entries = new LinkedList(); - for (int i = 0; i < entryCount; i++) { - entries.add(new Entry(this, content)); - - } - } - - @Override - protected void getContent(ByteBuffer byteBuffer) { - writeVersionAndFlags(byteBuffer); - IsoTypeWriter.writeUInt32(byteBuffer, entries.size()); - for (Entry entry : entries) { - entry.getContent(byteBuffer); - } - } - - @Override - public String toString() { - return "EditListBox{" + - "entries=" + entries + - '}'; - } - - public static class Entry { - private long segmentDuration; - private long mediaTime; - private double mediaRate; - EditListBox editListBox; - - /** - * Creates a new Entry with all values set. - * - * @param segmentDuration duration in movie timescale - * @param mediaTime starting time - * @param mediaRate relative play rate - */ - public Entry(EditListBox editListBox, long segmentDuration, long mediaTime, double mediaRate) { - this.segmentDuration = segmentDuration; - this.mediaTime = mediaTime; - this.mediaRate = mediaRate; - this.editListBox = editListBox; - } - - public Entry(EditListBox editListBox, ByteBuffer bb) { - if (editListBox.getVersion() == 1) { - segmentDuration = IsoTypeReader.readUInt64(bb); - mediaTime = IsoTypeReader.readUInt64(bb); - mediaRate = IsoTypeReader.readFixedPoint1616(bb); - } else { - segmentDuration = IsoTypeReader.readUInt32(bb); - mediaTime = IsoTypeReader.readUInt32(bb); - mediaRate = IsoTypeReader.readFixedPoint1616(bb); - } - this.editListBox = editListBox; - } - - /** - * The segment duration is an integer that specifies the duration - * of this edit segment in units of the timescale in the Movie - * Header Box - * - * @return segment duration in movie timescale - */ - public long getSegmentDuration() { - return segmentDuration; - } - - /** - * The segment duration is an integer that specifies the duration - * of this edit segment in units of the timescale in the Movie - * Header Box - * - * @param segmentDuration new segment duration in movie timescale - */ - public void setSegmentDuration(long segmentDuration) { - this.segmentDuration = segmentDuration; - } - - /** - * The media time is an integer containing the starting time - * within the media of a specific edit segment(in media time - * scale units, in composition time) - * - * @return starting time - */ - public long getMediaTime() { - return mediaTime; - } - - /** - * The media time is an integer containing the starting time - * within the media of a specific edit segment(in media time - * scale units, in composition time) - * - * @param mediaTime starting time - */ - public void setMediaTime(long mediaTime) { - this.mediaTime = mediaTime; - } - - /** - * The media rate specifies the relative rate at which to play the - * media corresponding to a specific edit segment. - * - * @return relative play rate - */ - public double getMediaRate() { - return mediaRate; - } - - /** - * The media rate specifies the relative rate at which to play the - * media corresponding to a specific edit segment. - * - * @param mediaRate new relative play rate - */ - public void setMediaRate(double mediaRate) { - this.mediaRate = mediaRate; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - Entry entry = (Entry) o; - - if (mediaTime != entry.mediaTime) return false; - if (segmentDuration != entry.segmentDuration) return false; - - return true; - } - - @Override - public int hashCode() { - int result = (int) (segmentDuration ^ (segmentDuration >>> 32)); - result = 31 * result + (int) (mediaTime ^ (mediaTime >>> 32)); - return result; - } - - public void getContent(ByteBuffer bb) { - if (editListBox.getVersion() == 1) { - IsoTypeWriter.writeUInt64(bb, segmentDuration); - IsoTypeWriter.writeUInt64(bb, mediaTime); - } else { - IsoTypeWriter.writeUInt32(bb, l2i(segmentDuration)); - bb.putInt(l2i(mediaTime)); - } - IsoTypeWriter.writeFixedPont1616(bb, mediaRate); - } - - @Override - public String toString() { - return "Entry{" + - "segmentDuration=" + segmentDuration + - ", mediaTime=" + mediaTime + - ", mediaRate=" + mediaRate + - '}'; - } - } -} diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/FileTypeBox.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/FileTypeBox.java deleted file mode 100644 index e6eed202b..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/FileTypeBox.java +++ /dev/null @@ -1,144 +0,0 @@ -/* - * Copyright 2008 CoreMedia AG, Hamburg - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coremedia.iso.boxes; - -import com.coremedia.iso.IsoFile; -import com.coremedia.iso.IsoTypeReader; -import com.coremedia.iso.IsoTypeWriter; -import com.googlecode.mp4parser.AbstractBox; -import com.googlecode.mp4parser.annotations.DoNotParseDetail; - -import java.nio.ByteBuffer; -import java.util.Collection; -import java.util.Collections; -import java.util.LinkedList; -import java.util.List; - -/** - * This box identifies the specifications to which this file complies.
    - * Each brand is a printable four-character code, registered with ISO, that - * identifies a precise specification. - */ -public class FileTypeBox extends AbstractBox { - public static final String TYPE = "ftyp"; - - private String majorBrand; - private long minorVersion; - private List compatibleBrands = Collections.emptyList(); - - public FileTypeBox() { - super(TYPE); - } - - public FileTypeBox(String majorBrand, long minorVersion, List compatibleBrands) { - super(TYPE); - this.majorBrand = majorBrand; - this.minorVersion = minorVersion; - this.compatibleBrands = compatibleBrands; - } - - protected long getContentSize() { - return 8 + compatibleBrands.size() * 4; - - } - - @Override - public void _parseDetails(ByteBuffer content) { - majorBrand = IsoTypeReader.read4cc(content); - minorVersion = IsoTypeReader.readUInt32(content); - int compatibleBrandsCount = content.remaining() / 4; - compatibleBrands = new LinkedList(); - for (int i = 0; i < compatibleBrandsCount; i++) { - compatibleBrands.add(IsoTypeReader.read4cc(content)); - } - } - - @Override - protected void getContent(ByteBuffer byteBuffer) { - byteBuffer.put(IsoFile.fourCCtoBytes(majorBrand)); - IsoTypeWriter.writeUInt32(byteBuffer, minorVersion); - for (String compatibleBrand : compatibleBrands) { - byteBuffer.put(IsoFile.fourCCtoBytes(compatibleBrand)); - } - - } - - /** - * Gets the brand identifier. - * - * @return the brand identifier - */ - public String getMajorBrand() { - return majorBrand; - } - - /** - * Sets the major brand of the file used to determine an appropriate reader. - * - * @param majorBrand the new major brand - */ - public void setMajorBrand(String majorBrand) { - this.majorBrand = majorBrand; - } - - /** - * Sets the "informative integer for the minor version of the major brand". - * - * @param minorVersion the version number of the major brand - */ - public void setMinorVersion(int minorVersion) { - this.minorVersion = minorVersion; - } - - /** - * Gets an informative integer for the minor version of the major brand. - * - * @return an informative integer - * @see FileTypeBox#getMajorBrand() - */ - public long getMinorVersion() { - return minorVersion; - } - - /** - * Gets an array of 4-cc brands. - * - * @return the compatible brands - */ - public List getCompatibleBrands() { - return compatibleBrands; - } - - public void setCompatibleBrands(List compatibleBrands) { - this.compatibleBrands = compatibleBrands; - } - - @DoNotParseDetail - public String toString() { - StringBuilder result = new StringBuilder(); - result.append("FileTypeBox["); - result.append("majorBrand=").append(getMajorBrand()); - result.append(";"); - result.append("minorVersion=").append(getMinorVersion()); - for (String compatibleBrand : compatibleBrands) { - result.append(";"); - result.append("compatibleBrand=").append(compatibleBrand); - } - result.append("]"); - return result.toString(); - } -} diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/FreeBox.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/FreeBox.java deleted file mode 100644 index 6ce4e8af8..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/FreeBox.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright 2008 CoreMedia AG, Hamburg - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coremedia.iso.boxes; - - -import com.googlecode.mp4parser.AbstractBox; - -import java.nio.ByteBuffer; - -/** - * A free box. Just a placeholder to enable editing without rewriting the whole file. - */ -public class FreeBox extends AbstractBox { - public static final String TYPE = "free"; - ByteBuffer data; - - public FreeBox() { - super(TYPE); - } - - public FreeBox(int size) { - super(TYPE); - this.data = ByteBuffer.allocate(size); - } - - @Override - protected long getContentSize() { - return data.limit(); - } - - @Override - public void _parseDetails(ByteBuffer content) { - data = content; - data.position(data.position() + data.remaining()); - } - - @Override - protected void getContent(ByteBuffer byteBuffer) { - data.rewind(); - byteBuffer.put(data); - } - - public ByteBuffer getData() { - return data; - } - - public void setData(ByteBuffer data) { - this.data = data; - } -} \ No newline at end of file diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/FreeSpaceBox.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/FreeSpaceBox.java deleted file mode 100644 index ed42bf96c..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/FreeSpaceBox.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright 2008 CoreMedia AG, Hamburg - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coremedia.iso.boxes; - -import com.googlecode.mp4parser.AbstractBox; - -import java.nio.ByteBuffer; - -/** - * The contents of a free-space box are irrelevant and may be ignored, or the object deleted, without affecting the - * presentation. Care should be excercized when deleting the object, as this may invalidate the offsets used in the - * sample table. - */ -public class FreeSpaceBox extends AbstractBox { - public static final String TYPE = "skip"; - - byte[] data; - - protected long getContentSize() { - return data.length; - } - - public FreeSpaceBox() { - super(TYPE); - } - - public void setData(byte[] data) { - this.data = data; - } - - public byte[] getData() { - return data; - } - - @Override - public void _parseDetails(ByteBuffer content) { - data = new byte[content.remaining()]; - content.get(data); - } - - @Override - protected void getContent(ByteBuffer byteBuffer) { - byteBuffer.put(data); - } - - public String toString() { - return "FreeSpaceBox[size=" + data.length + ";type=" + getType() + "]"; - } -} diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/FullBox.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/FullBox.java deleted file mode 100644 index 1515d76db..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/FullBox.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.coremedia.iso.boxes; - -import com.coremedia.iso.boxes.Box; - -/** - * The FullBox contains all getters and setters specific - * to a so-called full box according to the ISO/IEC 14496/12 specification. - */ -public interface FullBox extends Box { - int getVersion(); - - void setVersion(int version); - - int getFlags(); - - void setFlags(int flags); -} diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/GenericMediaHeaderBoxImpl.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/GenericMediaHeaderBoxImpl.java deleted file mode 100644 index f1f73a525..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/GenericMediaHeaderBoxImpl.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.coremedia.iso.boxes; - -import java.nio.ByteBuffer; - -public class GenericMediaHeaderBoxImpl extends AbstractMediaHeaderBox { - - ByteBuffer data; - - @Override - protected long getContentSize() { - return 4 + data.limit(); - } - - @Override - public void _parseDetails(ByteBuffer content) { - parseVersionAndFlags(content); - this.data = content.slice(); - content.position(content.remaining() + content.position()); - - } - - @Override - protected void getContent(ByteBuffer byteBuffer) { - writeVersionAndFlags(byteBuffer); - byteBuffer.put((ByteBuffer) data.rewind()); - } - - public GenericMediaHeaderBoxImpl() { - super("gmhd"); - } - - public ByteBuffer getData() { - return data; - } - - public void setData(ByteBuffer data) { - this.data = data; - } -} diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/GenreBox.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/GenreBox.java deleted file mode 100644 index e2d1faf87..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/GenreBox.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright 2008 CoreMedia AG, Hamburg - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coremedia.iso.boxes; - -import com.coremedia.iso.IsoTypeReader; -import com.coremedia.iso.IsoTypeWriter; -import com.coremedia.iso.Utf8; -import com.googlecode.mp4parser.AbstractFullBox; - -import java.nio.ByteBuffer; - -/** - * Containing genre information and contained in the UserDataBox. - * - * @see com.coremedia.iso.boxes.UserDataBox - */ -public class GenreBox extends AbstractFullBox { - public static final String TYPE = "gnre"; - - private String language; - private String genre; - - public GenreBox() { - super(TYPE); - } - - public String getLanguage() { - return language; - } - - public String getGenre() { - return genre; - } - - public void setLanguage(String language) { - this.language = language; - } - - public void setGenre(String genre) { - this.genre = genre; - } - - protected long getContentSize() { - return 7 + Utf8.utf8StringLengthInBytes(genre); - } - - @Override - public void _parseDetails(ByteBuffer content) { - parseVersionAndFlags(content); - language = IsoTypeReader.readIso639(content); - genre = IsoTypeReader.readString(content); - } - - @Override - protected void getContent(ByteBuffer byteBuffer) { - writeVersionAndFlags(byteBuffer); - IsoTypeWriter.writeIso639(byteBuffer, language); - byteBuffer.put(Utf8.convert(genre)); - byteBuffer.put((byte) 0); - } - - public String toString() { - return "GenreBox[language=" + getLanguage() + ";genre=" + getGenre() + "]"; - } - -} diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/HandlerBox.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/HandlerBox.java deleted file mode 100644 index 01dcacaa9..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/HandlerBox.java +++ /dev/null @@ -1,151 +0,0 @@ -/* - * Copyright 2008 CoreMedia AG, Hamburg - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coremedia.iso.boxes; - - -import com.coremedia.iso.IsoFile; -import com.coremedia.iso.IsoTypeReader; -import com.coremedia.iso.IsoTypeWriter; -import com.coremedia.iso.Utf8; -import com.googlecode.mp4parser.AbstractFullBox; - -import java.nio.ByteBuffer; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; - -/** - * This box within a Media Box declares the process by which the media-data in the track is presented, - * and thus, the nature of the media in a track. - * This Box when present in a Meta Box, declares the structure or format of the 'meta' box contents. - * See ISO/IEC 14496-12 for details. - * - * @see MetaBox - * @see MediaBox - */ -public class HandlerBox extends AbstractFullBox { - public static final String TYPE = "hdlr"; - public static final Map readableTypes; - - static { - HashMap hm = new HashMap(); - hm.put("odsm", "ObjectDescriptorStream - defined in ISO/IEC JTC1/SC29/WG11 - CODING OF MOVING PICTURES AND AUDIO"); - hm.put("crsm", "ClockReferenceStream - defined in ISO/IEC JTC1/SC29/WG11 - CODING OF MOVING PICTURES AND AUDIO"); - hm.put("sdsm", "SceneDescriptionStream - defined in ISO/IEC JTC1/SC29/WG11 - CODING OF MOVING PICTURES AND AUDIO"); - hm.put("m7sm", "MPEG7Stream - defined in ISO/IEC JTC1/SC29/WG11 - CODING OF MOVING PICTURES AND AUDIO"); - hm.put("ocsm", "ObjectContentInfoStream - defined in ISO/IEC JTC1/SC29/WG11 - CODING OF MOVING PICTURES AND AUDIO"); - hm.put("ipsm", "IPMP Stream - defined in ISO/IEC JTC1/SC29/WG11 - CODING OF MOVING PICTURES AND AUDIO"); - hm.put("mjsm", "MPEG-J Stream - defined in ISO/IEC JTC1/SC29/WG11 - CODING OF MOVING PICTURES AND AUDIO"); - hm.put("mdir", "Apple Meta Data iTunes Reader"); - hm.put("mp7b", "MPEG-7 binary XML"); - hm.put("mp7t", "MPEG-7 XML"); - hm.put("vide", "Video Track"); - hm.put("soun", "Sound Track"); - hm.put("hint", "Hint Track"); - hm.put("appl", "Apple specific"); - hm.put("meta", "Timed Metadata track - defined in ISO/IEC JTC1/SC29/WG11 - CODING OF MOVING PICTURES AND AUDIO"); - - readableTypes = Collections.unmodifiableMap(hm); - - } - - private String handlerType; - private String name = null; - private long a, b, c; - private boolean zeroTerm = true; - - private long shouldBeZeroButAppleWritesHereSomeValue; - - public HandlerBox() { - super(TYPE); - } - - public String getHandlerType() { - return handlerType; - } - - /** - * You are required to add a '\0' string termination by yourself. - * - * @param name the new human readable name - */ - public void setName(String name) { - this.name = name; - } - - public void setHandlerType(String handlerType) { - this.handlerType = handlerType; - } - - public String getName() { - return name; - } - - public String getHumanReadableTrackType() { - return readableTypes.get(handlerType) != null ? readableTypes.get(handlerType) : "Unknown Handler Type"; - } - - protected long getContentSize() { - if (zeroTerm) { - return 25 + Utf8.utf8StringLengthInBytes(name); - } else { - return 24 + Utf8.utf8StringLengthInBytes(name); - } - - } - - @Override - public void _parseDetails(ByteBuffer content) { - parseVersionAndFlags(content); - shouldBeZeroButAppleWritesHereSomeValue = IsoTypeReader.readUInt32(content); - handlerType = IsoTypeReader.read4cc(content); - a = IsoTypeReader.readUInt32(content); - b = IsoTypeReader.readUInt32(content); - c = IsoTypeReader.readUInt32(content); - if (content.remaining() > 0) { - name = IsoTypeReader.readString(content, content.remaining()); - if (name.endsWith("\0")) { - name = name.substring(0, name.length() - 1); - zeroTerm = true; - } else { - zeroTerm = false; - } - } else { - zeroTerm = false; //No string at all, not even zero term char - } - } - - @Override - protected void getContent(ByteBuffer byteBuffer) { - writeVersionAndFlags(byteBuffer); - IsoTypeWriter.writeUInt32(byteBuffer, shouldBeZeroButAppleWritesHereSomeValue); - byteBuffer.put(IsoFile.fourCCtoBytes(handlerType)); - IsoTypeWriter.writeUInt32(byteBuffer, a); - IsoTypeWriter.writeUInt32(byteBuffer, b); - IsoTypeWriter.writeUInt32(byteBuffer, c); - if (name != null) { - byteBuffer.put(Utf8.convert(name)); - } - if (zeroTerm) { - byteBuffer.put((byte) 0); - } - } - - public String toString() { - return "HandlerBox[handlerType=" + getHandlerType() + ";name=" + getName() + "]"; - } -} diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/HintMediaHeaderBox.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/HintMediaHeaderBox.java deleted file mode 100644 index 347773806..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/HintMediaHeaderBox.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright 2008 CoreMedia AG, Hamburg - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coremedia.iso.boxes; - -import com.coremedia.iso.IsoTypeReader; -import com.coremedia.iso.IsoTypeWriter; - -import java.nio.ByteBuffer; - -/** - * The hint media header contains general information, independent of the protocaol, for hint tracks. Resides - * in Media Information Box. - * - * @see com.coremedia.iso.boxes.MediaInformationBox - */ -public class HintMediaHeaderBox extends AbstractMediaHeaderBox { - private int maxPduSize; - private int avgPduSize; - private long maxBitrate; - private long avgBitrate; - public static final String TYPE = "hmhd"; - - public HintMediaHeaderBox() { - super(TYPE); - } - - public int getMaxPduSize() { - return maxPduSize; - } - - public int getAvgPduSize() { - return avgPduSize; - } - - public long getMaxBitrate() { - return maxBitrate; - } - - public long getAvgBitrate() { - return avgBitrate; - } - - protected long getContentSize() { - return 20; - } - - @Override - public void _parseDetails(ByteBuffer content) { - parseVersionAndFlags(content); - maxPduSize = IsoTypeReader.readUInt16(content); - avgPduSize = IsoTypeReader.readUInt16(content); - maxBitrate = IsoTypeReader.readUInt32(content); - avgBitrate = IsoTypeReader.readUInt32(content); - IsoTypeReader.readUInt32(content); // reserved! - - } - - @Override - protected void getContent(ByteBuffer byteBuffer) { - writeVersionAndFlags(byteBuffer); - IsoTypeWriter.writeUInt16(byteBuffer, maxPduSize); - IsoTypeWriter.writeUInt16(byteBuffer, avgPduSize); - IsoTypeWriter.writeUInt32(byteBuffer, maxBitrate); - IsoTypeWriter.writeUInt32(byteBuffer, avgBitrate); - IsoTypeWriter.writeUInt32(byteBuffer, 0); - } - - @Override - public String toString() { - return "HintMediaHeaderBox{" + - "maxPduSize=" + maxPduSize + - ", avgPduSize=" + avgPduSize + - ", maxBitrate=" + maxBitrate + - ", avgBitrate=" + avgBitrate + - '}'; - } -} diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/ItemDataBox.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/ItemDataBox.java deleted file mode 100644 index 46097cc12..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/ItemDataBox.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.coremedia.iso.boxes; - -import com.googlecode.mp4parser.AbstractBox; - -import java.nio.ByteBuffer; - -/** - * - */ -public class ItemDataBox extends AbstractBox { - ByteBuffer data = ByteBuffer.allocate(0); - public static final String TYPE = "idat"; - - - public ItemDataBox() { - super(TYPE); - } - - public ByteBuffer getData() { - return data; - } - - public void setData(ByteBuffer data) { - this.data = data; - } - - @Override - protected long getContentSize() { - return data.limit(); - } - - - @Override - public void _parseDetails(ByteBuffer content) { - data = content.slice(); - content.position(content.position() + content.remaining()); - } - - @Override - protected void getContent(ByteBuffer byteBuffer) { - byteBuffer.put(data); - } -} diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/ItemLocationBox.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/ItemLocationBox.java deleted file mode 100644 index 6dcee6fa1..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/ItemLocationBox.java +++ /dev/null @@ -1,360 +0,0 @@ -/* - * Copyright 2008 CoreMedia AG, Hamburg - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coremedia.iso.boxes; - - -import com.coremedia.iso.IsoTypeReader; -import com.coremedia.iso.IsoTypeReaderVariable; -import com.coremedia.iso.IsoTypeWriter; -import com.coremedia.iso.IsoTypeWriterVariable; -import com.googlecode.mp4parser.AbstractFullBox; - -import java.io.IOException; -import java.nio.ByteBuffer; -import java.util.LinkedList; -import java.util.List; - -/** - * aligned(8) class ItemLocationBox extends FullBox(‘iloc’, version, 0) { - * unsigned int(4) offset_size; - * unsigned int(4) length_size; - * unsigned int(4) base_offset_size; - * if (version == 1) - * unsigned int(4) index_size; - * else - * unsigned int(4) reserved; - * unsigned int(16) item_count; - * for (i=0; i 0)) { - * unsigned int(index_size*8) extent_index; - * } - * unsigned int(offset_size*8) extent_offset; - * unsigned int(length_size*8) extent_length; - * } - * } - * } - */ -public class ItemLocationBox extends AbstractFullBox { - public int offsetSize = 8; - public int lengthSize = 8; - public int baseOffsetSize = 8; - public int indexSize = 0; - public List items = new LinkedList(); - - public static final String TYPE = "iloc"; - - public ItemLocationBox() { - super(TYPE); - } - - @Override - protected long getContentSize() { - long size = 8; - for (Item item : items) { - size += item.getSize(); - } - return size; - } - - - @Override - protected void getContent(ByteBuffer byteBuffer) { - writeVersionAndFlags(byteBuffer); - IsoTypeWriter.writeUInt8(byteBuffer, ((offsetSize << 4) | lengthSize)); - if (getVersion() == 1) { - IsoTypeWriter.writeUInt8(byteBuffer, (baseOffsetSize << 4 | indexSize)); - } else { - IsoTypeWriter.writeUInt8(byteBuffer, (baseOffsetSize << 4)); - } - IsoTypeWriter.writeUInt16(byteBuffer, items.size()); - for (Item item : items) { - item.getContent(byteBuffer); - } - } - - @Override - public void _parseDetails(ByteBuffer content) { - parseVersionAndFlags(content); - int tmp = IsoTypeReader.readUInt8(content); - offsetSize = tmp >>> 4; - lengthSize = tmp & 0xf; - tmp = IsoTypeReader.readUInt8(content); - baseOffsetSize = tmp >>> 4; - - if (getVersion() == 1) { - indexSize = tmp & 0xf; - } - int itemCount = IsoTypeReader.readUInt16(content); - for (int i = 0; i < itemCount; i++) { - items.add(new Item(content)); - } - } - - - public int getOffsetSize() { - return offsetSize; - } - - public void setOffsetSize(int offsetSize) { - this.offsetSize = offsetSize; - } - - public int getLengthSize() { - return lengthSize; - } - - public void setLengthSize(int lengthSize) { - this.lengthSize = lengthSize; - } - - public int getBaseOffsetSize() { - return baseOffsetSize; - } - - public void setBaseOffsetSize(int baseOffsetSize) { - this.baseOffsetSize = baseOffsetSize; - } - - public int getIndexSize() { - return indexSize; - } - - public void setIndexSize(int indexSize) { - this.indexSize = indexSize; - } - - public List getItems() { - return items; - } - - public void setItems(List items) { - this.items = items; - } - - - public Item createItem(int itemId, int constructionMethod, int dataReferenceIndex, long baseOffset, List extents) { - return new Item(itemId, constructionMethod, dataReferenceIndex, baseOffset, extents); - } - - Item createItem(ByteBuffer bb) { - return new Item(bb); - } - - public class Item { - public int itemId; - public int constructionMethod; - public int dataReferenceIndex; - public long baseOffset; - public List extents = new LinkedList(); - - public Item(ByteBuffer in) { - itemId = IsoTypeReader.readUInt16(in); - - if (getVersion() == 1) { - int tmp = IsoTypeReader.readUInt16(in); - constructionMethod = tmp & 0xf; - } - - dataReferenceIndex = IsoTypeReader.readUInt16(in); - if (baseOffsetSize > 0) { - baseOffset = IsoTypeReaderVariable.read(in, baseOffsetSize); - } else { - baseOffset = 0; - } - int extentCount = IsoTypeReader.readUInt16(in); - - - for (int i = 0; i < extentCount; i++) { - extents.add(new Extent(in)); - } - } - - public Item(int itemId, int constructionMethod, int dataReferenceIndex, long baseOffset, List extents) { - this.itemId = itemId; - this.constructionMethod = constructionMethod; - this.dataReferenceIndex = dataReferenceIndex; - this.baseOffset = baseOffset; - this.extents = extents; - } - - public int getSize() { - int size = 2; - - if (getVersion() == 1) { - size += 2; - } - - size += 2; - size += baseOffsetSize; - size += 2; - - - for (Extent extent : extents) { - size += extent.getSize(); - } - return size; - } - - public void setBaseOffset(long baseOffset) { - this.baseOffset = baseOffset; - } - - public void getContent(ByteBuffer bb) { - IsoTypeWriter.writeUInt16(bb, itemId); - - if (getVersion() == 1) { - IsoTypeWriter.writeUInt16(bb, constructionMethod); - } - - - IsoTypeWriter.writeUInt16(bb, dataReferenceIndex); - if (baseOffsetSize > 0) { - IsoTypeWriterVariable.write(baseOffset, bb, baseOffsetSize); - } - IsoTypeWriter.writeUInt16(bb, extents.size()); - - for (Extent extent : extents) { - extent.getContent(bb); - } - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - Item item = (Item) o; - - if (baseOffset != item.baseOffset) return false; - if (constructionMethod != item.constructionMethod) return false; - if (dataReferenceIndex != item.dataReferenceIndex) return false; - if (itemId != item.itemId) return false; - if (extents != null ? !extents.equals(item.extents) : item.extents != null) return false; - - return true; - } - - @Override - public int hashCode() { - int result = itemId; - result = 31 * result + constructionMethod; - result = 31 * result + dataReferenceIndex; - result = 31 * result + (int) (baseOffset ^ (baseOffset >>> 32)); - result = 31 * result + (extents != null ? extents.hashCode() : 0); - return result; - } - - @Override - public String toString() { - return "Item{" + - "baseOffset=" + baseOffset + - ", itemId=" + itemId + - ", constructionMethod=" + constructionMethod + - ", dataReferenceIndex=" + dataReferenceIndex + - ", extents=" + extents + - '}'; - } - } - - - public Extent createExtent(long extentOffset, long extentLength, long extentIndex) { - return new Extent(extentOffset, extentLength, extentIndex); - } - - Extent createExtent(ByteBuffer bb) { - return new Extent(bb); - } - - - public class Extent { - public long extentOffset; - public long extentLength; - public long extentIndex; - - public Extent(long extentOffset, long extentLength, long extentIndex) { - this.extentOffset = extentOffset; - this.extentLength = extentLength; - this.extentIndex = extentIndex; - } - - - public Extent(ByteBuffer in) { - if ((getVersion() == 1) && indexSize > 0) { - extentIndex = IsoTypeReaderVariable.read(in, indexSize); - } - extentOffset = IsoTypeReaderVariable.read(in, offsetSize); - extentLength = IsoTypeReaderVariable.read(in, lengthSize); - } - - public void getContent(ByteBuffer os) { - if ((getVersion() == 1) && indexSize > 0) { - IsoTypeWriterVariable.write(extentIndex, os, indexSize); - } - IsoTypeWriterVariable.write(extentOffset, os, offsetSize); - IsoTypeWriterVariable.write(extentLength, os, lengthSize); - } - - public int getSize() { - return (indexSize > 0 ? indexSize : 0) + offsetSize + lengthSize; - } - - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - Extent extent = (Extent) o; - - if (extentIndex != extent.extentIndex) return false; - if (extentLength != extent.extentLength) return false; - if (extentOffset != extent.extentOffset) return false; - - return true; - } - - @Override - public int hashCode() { - int result = (int) (extentOffset ^ (extentOffset >>> 32)); - result = 31 * result + (int) (extentLength ^ (extentLength >>> 32)); - result = 31 * result + (int) (extentIndex ^ (extentIndex >>> 32)); - return result; - } - - @Override - public String toString() { - final StringBuilder sb = new StringBuilder(); - sb.append("Extent"); - sb.append("{extentOffset=").append(extentOffset); - sb.append(", extentLength=").append(extentLength); - sb.append(", extentIndex=").append(extentIndex); - sb.append('}'); - return sb.toString(); - } - } - - -} diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/ItemProtectionBox.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/ItemProtectionBox.java deleted file mode 100644 index 7eed79003..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/ItemProtectionBox.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright 2008 CoreMedia AG, Hamburg - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coremedia.iso.boxes; - -import com.coremedia.iso.IsoTypeReader; -import com.coremedia.iso.IsoTypeWriter; -import com.googlecode.mp4parser.FullContainerBox; - -import java.nio.ByteBuffer; - -/** - * The Item Protection Box provides an array of item protection information, for use by the Item Information Box. - * - * @see com.coremedia.iso.boxes.ItemProtectionBox - */ -public class ItemProtectionBox extends FullContainerBox { - - public static final String TYPE = "ipro"; - - public ItemProtectionBox() { - super(TYPE); - } - - public SchemeInformationBox getItemProtectionScheme() { - if (!getBoxes(SchemeInformationBox.class).isEmpty()) { - return getBoxes(SchemeInformationBox.class).get(0); - } else { - return null; - } - } - - @Override - public void _parseDetails(ByteBuffer content) { - parseVersionAndFlags(content); - IsoTypeReader.readUInt16(content); - parseChildBoxes(content); - } - - - @Override - protected void getContent(ByteBuffer byteBuffer) { - writeVersionAndFlags(byteBuffer); - IsoTypeWriter.writeUInt16(byteBuffer, getBoxes().size()); - writeChildBoxes(byteBuffer); - } - -} diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/KeywordsBox.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/KeywordsBox.java deleted file mode 100644 index d9b7c0cf6..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/KeywordsBox.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright 2008 CoreMedia AG, Hamburg - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coremedia.iso.boxes; - -import com.coremedia.iso.IsoTypeReader; -import com.coremedia.iso.IsoTypeWriter; -import com.coremedia.iso.Utf8; -import com.googlecode.mp4parser.AbstractFullBox; - -import java.nio.ByteBuffer; - -/** - * List of keywords according to 3GPP 26.244. - */ -public class KeywordsBox extends AbstractFullBox { - public static final String TYPE = "kywd"; - - private String language; - private String[] keywords; - - public KeywordsBox() { - super(TYPE); - } - - public String getLanguage() { - return language; - } - - public String[] getKeywords() { - return keywords; - } - - public void setLanguage(String language) { - this.language = language; - } - - public void setKeywords(String[] keywords) { - this.keywords = keywords; - } - - protected long getContentSize() { - long contentSize = 7; - for (String keyword : keywords) { - contentSize += 1 + Utf8.utf8StringLengthInBytes(keyword) + 1; - } - return contentSize; - } - - @Override - public void _parseDetails(ByteBuffer content) { - parseVersionAndFlags(content); - language = IsoTypeReader.readIso639(content); - int keywordCount = IsoTypeReader.readUInt8(content); - keywords = new String[keywordCount]; - for (int i = 0; i < keywordCount; i++) { - IsoTypeReader.readUInt8(content); - keywords[i] = IsoTypeReader.readString(content); - } - } - - @Override - protected void getContent(ByteBuffer byteBuffer) { - writeVersionAndFlags(byteBuffer); - IsoTypeWriter.writeIso639(byteBuffer, language); - IsoTypeWriter.writeUInt8(byteBuffer, keywords.length); - for (String keyword : keywords) { - IsoTypeWriter.writeUInt8(byteBuffer, Utf8.utf8StringLengthInBytes(keyword) + 1); - byteBuffer.put(Utf8.convert(keyword)); - } - } - - public String toString() { - StringBuffer buffer = new StringBuffer(); - buffer.append("KeywordsBox[language=").append(getLanguage()); - for (int i = 0; i < keywords.length; i++) { - buffer.append(";keyword").append(i).append("=").append(keywords[i]); - } - buffer.append("]"); - return buffer.toString(); - } -} diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/MediaBox.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/MediaBox.java deleted file mode 100644 index fa5642cb9..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/MediaBox.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright 2008 CoreMedia AG, Hamburg - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coremedia.iso.boxes; - - -import com.googlecode.mp4parser.AbstractContainerBox; - -/** - * The media declaration container contains all the objects that declare information about the media data within a - * track. - */ -public class MediaBox extends AbstractContainerBox { - public static final String TYPE = "mdia"; - - public MediaBox() { - super(TYPE); - } - - public MediaInformationBox getMediaInformationBox() { - for (Box box : boxes) { - if (box instanceof MediaInformationBox) { - return (MediaInformationBox) box; - } - } - return null; - } - - public MediaHeaderBox getMediaHeaderBox() { - for (Box box : boxes) { - if (box instanceof MediaHeaderBox) { - return (MediaHeaderBox) box; - } - } - return null; - } - - public HandlerBox getHandlerBox() { - for (Box box : boxes) { - if (box instanceof HandlerBox) { - return (HandlerBox) box; - } - } - return null; - } - - -} diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/MediaHeaderBox.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/MediaHeaderBox.java deleted file mode 100644 index f9d5a9535..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/MediaHeaderBox.java +++ /dev/null @@ -1,147 +0,0 @@ -/* - * Copyright 2008 CoreMedia AG, Hamburg - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coremedia.iso.boxes; - -import com.coremedia.iso.IsoTypeReader; -import com.coremedia.iso.IsoTypeWriter; -import com.googlecode.mp4parser.AbstractFullBox; - -import java.nio.ByteBuffer; - -/** - * This box defines overall information which is media-independent, and relevant to the entire presentation - * considered as a whole. - */ -public class MediaHeaderBox extends AbstractFullBox { - public static final String TYPE = "mdhd"; - - - private long creationTime; - private long modificationTime; - private long timescale; - private long duration; - private String language; - - public MediaHeaderBox() { - super(TYPE); - } - - public long getCreationTime() { - return creationTime; - } - - public long getModificationTime() { - return modificationTime; - } - - public long getTimescale() { - return timescale; - } - - public long getDuration() { - return duration; - } - - public String getLanguage() { - return language; - } - - protected long getContentSize() { - long contentSize = 4; - if (getVersion() == 1) { - contentSize += 8 + 8 + 4 + 8; - } else { - contentSize += 4 + 4 + 4 + 4; - } - contentSize += 2; - contentSize += 2; - return contentSize; - - } - - public void setCreationTime(long creationTime) { - this.creationTime = creationTime; - } - - public void setModificationTime(long modificationTime) { - this.modificationTime = modificationTime; - } - - public void setTimescale(long timescale) { - this.timescale = timescale; - } - - public void setDuration(long duration) { - this.duration = duration; - } - - public void setLanguage(String language) { - this.language = language; - } - - @Override - public void _parseDetails(ByteBuffer content) { - parseVersionAndFlags(content); - if (getVersion() == 1) { - creationTime = IsoTypeReader.readUInt64(content); - modificationTime = IsoTypeReader.readUInt64(content); - timescale = IsoTypeReader.readUInt32(content); - duration = IsoTypeReader.readUInt64(content); - } else { - creationTime = IsoTypeReader.readUInt32(content); - modificationTime = IsoTypeReader.readUInt32(content); - timescale = IsoTypeReader.readUInt32(content); - duration = IsoTypeReader.readUInt32(content); - } - language = IsoTypeReader.readIso639(content); - IsoTypeReader.readUInt16(content); - } - - - public String toString() { - StringBuilder result = new StringBuilder(); - result.append("MeditHeaderBox["); - result.append("creationTime=").append(getCreationTime()); - result.append(";"); - result.append("modificationTime=").append(getModificationTime()); - result.append(";"); - result.append("timescale=").append(getTimescale()); - result.append(";"); - result.append("duration=").append(getDuration()); - result.append(";"); - result.append("language=").append(getLanguage()); - result.append("]"); - return result.toString(); - } - - protected void getContent(ByteBuffer byteBuffer) { - writeVersionAndFlags(byteBuffer); - if (getVersion() == 1) { - IsoTypeWriter.writeUInt64(byteBuffer, creationTime); - IsoTypeWriter.writeUInt64(byteBuffer, modificationTime); - IsoTypeWriter.writeUInt32(byteBuffer, timescale); - IsoTypeWriter.writeUInt64(byteBuffer, duration); - } else { - IsoTypeWriter.writeUInt32(byteBuffer, creationTime); - IsoTypeWriter.writeUInt32(byteBuffer, modificationTime); - IsoTypeWriter.writeUInt32(byteBuffer, timescale); - IsoTypeWriter.writeUInt32(byteBuffer, duration); - } - IsoTypeWriter.writeIso639(byteBuffer, language); - IsoTypeWriter.writeUInt16(byteBuffer, 0); - } -} diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/MediaInformationBox.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/MediaInformationBox.java deleted file mode 100644 index ed25051d6..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/MediaInformationBox.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright 2008 CoreMedia AG, Hamburg - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coremedia.iso.boxes; - -import com.googlecode.mp4parser.AbstractContainerBox; - -/** - * This box contains all the objects that declare characteristic information of the media in the track. - */ -public class MediaInformationBox extends AbstractContainerBox { - public static final String TYPE = "minf"; - - public MediaInformationBox() { - super(TYPE); - } - - public SampleTableBox getSampleTableBox() { - for (Box box : boxes) { - if (box instanceof SampleTableBox) { - return (SampleTableBox) box; - } - } - return null; - } - - public AbstractMediaHeaderBox getMediaHeaderBox() { - for (Box box : boxes) { - if (box instanceof AbstractMediaHeaderBox) { - return (AbstractMediaHeaderBox) box; - } - } - return null; - } - -} diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/MetaBox.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/MetaBox.java deleted file mode 100644 index 35499ec46..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/MetaBox.java +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Copyright 2008 CoreMedia AG, Hamburg - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coremedia.iso.boxes; - -import com.coremedia.iso.IsoTypeReader; -import com.coremedia.iso.IsoTypeWriter; -import com.googlecode.mp4parser.AbstractContainerBox; -import com.googlecode.mp4parser.util.ByteBufferByteChannel; - -import java.io.IOException; -import java.nio.ByteBuffer; - - -/** - * A common base structure to contain general metadata. See ISO/IEC 14496-12 Ch. 8.44.1. - */ -public class MetaBox extends AbstractContainerBox { - private int version = 0; - private int flags = 0; - - public static final String TYPE = "meta"; - - public MetaBox() { - super(TYPE); - } - - @Override - public long getContentSize() { - if (isMp4Box()) { - // it's a fullbox - return 4 + super.getContentSize(); - } else { - // it's an apple metabox - return super.getContentSize(); - } - } - - @Override - public long getNumOfBytesToFirstChild() { - if (isMp4Box()) { - // it's a fullbox - return 12; - } else { - // it's an apple metabox - return 8; - } - } - - @Override - public void _parseDetails(ByteBuffer content) { - int pos = content.position(); - content.get(new byte[4]); - String isHdlr = IsoTypeReader.read4cc(content); - if ("hdlr".equals(isHdlr)) { - // this is apple bullshit - it's NO FULLBOX - content.position(pos); - version = -1; - flags = -1; - } else { - content.position(pos); - version = IsoTypeReader.readUInt8(content); - flags = IsoTypeReader.readUInt24(content); - } - while (content.remaining() >= 8) { - try { - boxes.add(boxParser.parseBox(new ByteBufferByteChannel(content), this)); - } catch (IOException e) { - throw new RuntimeException("Sebastian needs to fix 7518765283"); - } - } - if (content.remaining() > 0) { - throw new RuntimeException("Sebastian needs to fix it 90732r26537"); - } - } - - @Override - protected void getContent(ByteBuffer byteBuffer) { - if (isMp4Box()) { - IsoTypeWriter.writeUInt8(byteBuffer, version); - IsoTypeWriter.writeUInt24(byteBuffer, flags); - } - writeChildBoxes(byteBuffer); - } - - - public boolean isMp4Box() { - return version != -1 && flags != -1; - } - - public void setMp4Box(boolean mp4) { - if (mp4) { - version = 0; - flags = 0; - } else { - version = -1; - flags = -1; - } - } -} diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/MovieBox.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/MovieBox.java deleted file mode 100644 index 3aff7d837..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/MovieBox.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright 2008 CoreMedia AG, Hamburg - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coremedia.iso.boxes; - - -import com.googlecode.mp4parser.AbstractBox; -import com.googlecode.mp4parser.AbstractContainerBox; - -import java.util.List; - -/** - * The metadata for a presentation is stored in the single Movie Box which occurs at the top-level of a file. - * Normally this box is close to the beginning or end of the file, though this is not required. - */ -public class MovieBox extends AbstractContainerBox { - public static final String TYPE = "moov"; - - public MovieBox() { - super(TYPE); - } - - public int getTrackCount() { - return getBoxes(TrackBox.class).size(); - } - - - /** - * Returns the track numbers associated with this MovieBox. - * - * @return the tracknumbers (IDs) of the tracks in their order of appearance in the file - */ - public long[] getTrackNumbers() { - - List trackBoxes = this.getBoxes(TrackBox.class); - long[] trackNumbers = new long[trackBoxes.size()]; - for (int trackCounter = 0; trackCounter < trackBoxes.size(); trackCounter++) { - AbstractBox trackBoxe = trackBoxes.get(trackCounter); - TrackBox trackBox = (TrackBox) trackBoxe; - trackNumbers[trackCounter] = trackBox.getTrackHeaderBox().getTrackId(); - } - return trackNumbers; - } - - public MovieHeaderBox getMovieHeaderBox() { - for (Box box : boxes) { - if (box instanceof MovieHeaderBox) { - return (MovieHeaderBox) box; - } - } - return null; - } - -} diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/MovieHeaderBox.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/MovieHeaderBox.java deleted file mode 100644 index 9dcc3852f..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/MovieHeaderBox.java +++ /dev/null @@ -1,210 +0,0 @@ -/* - * Copyright 2008 CoreMedia AG, Hamburg - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coremedia.iso.boxes; - -import com.coremedia.iso.IsoTypeReader; -import com.coremedia.iso.IsoTypeWriter; -import com.googlecode.mp4parser.AbstractFullBox; - -import java.nio.ByteBuffer; - -/** - * - * Box Type: 'mvhd'
    - * Container: {@link MovieBox} ('moov')
    - * Mandatory: Yes
    - * Quantity: Exactly one

    - *
    - * This box defines overall information which is media-independent, and relevant to the entire presentation - * considered as a whole. - */ -public class MovieHeaderBox extends AbstractFullBox { - private long creationTime; - private long modificationTime; - private long timescale; - private long duration; - private double rate = 1.0; - private float volume = 1.0f; - private long[] matrix = new long[]{0x00010000, 0, 0, 0, 0x00010000, 0, 0, 0, 0x40000000}; - private long nextTrackId; - public static final String TYPE = "mvhd"; - - public MovieHeaderBox() { - super(TYPE); - } - - public long getCreationTime() { - return creationTime; - } - - public long getModificationTime() { - return modificationTime; - } - - public long getTimescale() { - return timescale; - } - - public long getDuration() { - return duration; - } - - public double getRate() { - return rate; - } - - public float getVolume() { - return volume; - } - - public long[] getMatrix() { - return matrix; - } - - public long getNextTrackId() { - return nextTrackId; - } - - protected long getContentSize() { - long contentSize = 4; - if (getVersion() == 1) { - contentSize += 28; - } else { - contentSize += 16; - } - contentSize += 80; - return contentSize; - } - - @Override - public void _parseDetails(ByteBuffer content) { - parseVersionAndFlags(content); - if (getVersion() == 1) { - creationTime = IsoTypeReader.readUInt64(content); - modificationTime = IsoTypeReader.readUInt64(content); - timescale = IsoTypeReader.readUInt32(content); - duration = IsoTypeReader.readUInt64(content); - } else { - creationTime = IsoTypeReader.readUInt32(content); - modificationTime = IsoTypeReader.readUInt32(content); - timescale = IsoTypeReader.readUInt32(content); - duration = IsoTypeReader.readUInt32(content); - } - rate = IsoTypeReader.readFixedPoint1616(content); - volume = IsoTypeReader.readFixedPoint88(content); - IsoTypeReader.readUInt16(content); - IsoTypeReader.readUInt32(content); - IsoTypeReader.readUInt32(content); - matrix = new long[9]; - for (int i = 0; i < 9; i++) { - matrix[i] = IsoTypeReader.readUInt32(content); - } - for (int i = 0; i < 6; i++) { - IsoTypeReader.readUInt32(content); - } - nextTrackId = IsoTypeReader.readUInt32(content); - - } - - public String toString() { - StringBuilder result = new StringBuilder(); - result.append("MovieHeaderBox["); - result.append("creationTime=").append(getCreationTime()); - result.append(";"); - result.append("modificationTime=").append(getModificationTime()); - result.append(";"); - result.append("timescale=").append(getTimescale()); - result.append(";"); - result.append("duration=").append(getDuration()); - result.append(";"); - result.append("rate=").append(getRate()); - result.append(";"); - result.append("volume=").append(getVolume()); - for (int i = 0; i < matrix.length; i++) { - result.append(";"); - result.append("matrix").append(i).append("=").append(matrix[i]); - } - result.append(";"); - result.append("nextTrackId=").append(getNextTrackId()); - result.append("]"); - return result.toString(); - } - - - @Override - protected void getContent(ByteBuffer byteBuffer) { - writeVersionAndFlags(byteBuffer); - if (getVersion() == 1) { - IsoTypeWriter.writeUInt64(byteBuffer, creationTime); - IsoTypeWriter.writeUInt64(byteBuffer, modificationTime); - IsoTypeWriter.writeUInt32(byteBuffer, timescale); - IsoTypeWriter.writeUInt64(byteBuffer, duration); - } else { - IsoTypeWriter.writeUInt32(byteBuffer, creationTime); - IsoTypeWriter.writeUInt32(byteBuffer, modificationTime); - IsoTypeWriter.writeUInt32(byteBuffer, timescale); - IsoTypeWriter.writeUInt32(byteBuffer, duration); - } - IsoTypeWriter.writeFixedPont1616(byteBuffer, rate); - IsoTypeWriter.writeFixedPont88(byteBuffer, volume); - IsoTypeWriter.writeUInt16(byteBuffer, 0); - IsoTypeWriter.writeUInt32(byteBuffer, 0); - IsoTypeWriter.writeUInt32(byteBuffer, 0); - - - for (int i = 0; i < 9; i++) { - IsoTypeWriter.writeUInt32(byteBuffer, matrix[i]); - } - for (int i = 0; i < 6; i++) { - IsoTypeWriter.writeUInt32(byteBuffer, 0); - } - IsoTypeWriter.writeUInt32(byteBuffer, nextTrackId); - } - - - public void setCreationTime(long creationTime) { - this.creationTime = creationTime; - } - - public void setModificationTime(long modificationTime) { - this.modificationTime = modificationTime; - } - - public void setTimescale(long timescale) { - this.timescale = timescale; - } - - public void setDuration(long duration) { - this.duration = duration; - } - - public void setRate(double rate) { - this.rate = rate; - } - - public void setVolume(float volume) { - this.volume = volume; - } - - public void setMatrix(long[] matrix) { - this.matrix = matrix; - } - - public void setNextTrackId(long nextTrackId) { - this.nextTrackId = nextTrackId; - } -} diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/NullMediaHeaderBox.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/NullMediaHeaderBox.java deleted file mode 100644 index 562f8d4a8..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/NullMediaHeaderBox.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright 2011 Sebastian Annies, Hamburg, Germany - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.coremedia.iso.boxes; - -import java.nio.ByteBuffer; - -/** - * Streams other than visual and audio (e.g., timed metadata streams) may use a - * Null Media Header Box. - */ -public class NullMediaHeaderBox extends AbstractMediaHeaderBox { - public NullMediaHeaderBox() { - super("nmhd"); - } - - @Override - protected long getContentSize() { - return 4; - } - - @Override - public void _parseDetails(ByteBuffer content) { - parseVersionAndFlags(content); - } - - @Override - protected void getContent(ByteBuffer byteBuffer) { - writeVersionAndFlags(byteBuffer); - } -} diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/ObjectDescriptorBox.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/ObjectDescriptorBox.java deleted file mode 100644 index e69de29bb..000000000 diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/OmaDrmAccessUnitFormatBox.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/OmaDrmAccessUnitFormatBox.java deleted file mode 100644 index 020881ba3..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/OmaDrmAccessUnitFormatBox.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright 2008 CoreMedia AG, Hamburg - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coremedia.iso.boxes; - -import com.coremedia.iso.IsoTypeReader; -import com.coremedia.iso.IsoTypeWriter; -import com.googlecode.mp4parser.AbstractFullBox; - -import java.nio.ByteBuffer; - -/** - * Describes the format of media access units in PDCF files. - */ -public final class OmaDrmAccessUnitFormatBox extends AbstractFullBox { - public static final String TYPE = "odaf"; - - private boolean selectiveEncryption; - private byte allBits; - - private int keyIndicatorLength; - private int initVectorLength; - - protected long getContentSize() { - return 7; - } - - public OmaDrmAccessUnitFormatBox() { - super("odaf"); - } - - public boolean isSelectiveEncryption() { - return selectiveEncryption; - } - - public int getKeyIndicatorLength() { - return keyIndicatorLength; - } - - public int getInitVectorLength() { - return initVectorLength; - } - - public void setInitVectorLength(int initVectorLength) { - this.initVectorLength = initVectorLength; - } - - public void setKeyIndicatorLength(int keyIndicatorLength) { - this.keyIndicatorLength = keyIndicatorLength; - } - - public void setAllBits(byte allBits) { - this.allBits = allBits; - selectiveEncryption = (allBits & 0x80) == 0x80; - } - - @Override - public void _parseDetails(ByteBuffer content) { - parseVersionAndFlags(content); - allBits = (byte) IsoTypeReader.readUInt8(content); - selectiveEncryption = (allBits & 0x80) == 0x80; - keyIndicatorLength = IsoTypeReader.readUInt8(content); - initVectorLength = IsoTypeReader.readUInt8(content); - } - - @Override - protected void getContent(ByteBuffer byteBuffer) { - writeVersionAndFlags(byteBuffer); - IsoTypeWriter.writeUInt8(byteBuffer, allBits); - IsoTypeWriter.writeUInt8(byteBuffer, keyIndicatorLength); - IsoTypeWriter.writeUInt8(byteBuffer, initVectorLength); - } - -} diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/OriginalFormatBox.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/OriginalFormatBox.java deleted file mode 100644 index 004c6c2e1..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/OriginalFormatBox.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright 2008 CoreMedia AG, Hamburg - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coremedia.iso.boxes; - -import com.coremedia.iso.IsoFile; -import com.coremedia.iso.IsoTypeReader; -import com.googlecode.mp4parser.AbstractBox; - -import java.nio.ByteBuffer; - -/** - * The Original Format Box contains the four-character-code of the original untransformed sample description. - * See ISO/IEC 14496-12 for details. - * - * @see ProtectionSchemeInformationBox - */ - -public class OriginalFormatBox extends AbstractBox { - public static final String TYPE = "frma"; - - private String dataFormat = " "; - - public OriginalFormatBox() { - super("frma"); - } - - public String getDataFormat() { - return dataFormat; - } - - - public void setDataFormat(String dataFormat) { - assert dataFormat.length() == 4; - this.dataFormat = dataFormat; - } - - protected long getContentSize() { - return 4; - } - - @Override - public void _parseDetails(ByteBuffer content) { - dataFormat = IsoTypeReader.read4cc(content); - } - - @Override - protected void getContent(ByteBuffer byteBuffer) { - byteBuffer.put(IsoFile.fourCCtoBytes(dataFormat)); - } - - - public String toString() { - return "OriginalFormatBox[dataFormat=" + getDataFormat() + "]"; - } -} diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/PerformerBox.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/PerformerBox.java deleted file mode 100644 index cf702dce3..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/PerformerBox.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright 2008 CoreMedia AG, Hamburg - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coremedia.iso.boxes; - -import com.coremedia.iso.IsoTypeReader; -import com.coremedia.iso.IsoTypeWriter; -import com.coremedia.iso.Utf8; -import com.googlecode.mp4parser.AbstractFullBox; - -import java.nio.ByteBuffer; - -/** - * Used to give information about the performer. Mostly used in confunction with music files. - * See 3GPP 26.234 for details. - */ -public class PerformerBox extends AbstractFullBox { - public static final String TYPE = "perf"; - - private String language; - private String performer; - - public PerformerBox() { - super(TYPE); - } - - public String getLanguage() { - return language; - } - - public String getPerformer() { - return performer; - } - - public void setLanguage(String language) { - this.language = language; - } - - public void setPerformer(String performer) { - this.performer = performer; - } - - protected long getContentSize() { - return 6 + Utf8.utf8StringLengthInBytes(performer) + 1; - } - - @Override - protected void getContent(ByteBuffer byteBuffer) { - writeVersionAndFlags(byteBuffer); - IsoTypeWriter.writeIso639(byteBuffer, language); - byteBuffer.put(Utf8.convert(performer)); - byteBuffer.put((byte) 0); - } - - @Override - public void _parseDetails(ByteBuffer content) { - parseVersionAndFlags(content); - language = IsoTypeReader.readIso639(content); - performer = IsoTypeReader.readString(content); - } - - public String toString() { - return "PerformerBox[language=" + getLanguage() + ";performer=" + getPerformer() + "]"; - } -} diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/ProgressiveDownloadInformationBox.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/ProgressiveDownloadInformationBox.java deleted file mode 100644 index 7acd7edcf..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/ProgressiveDownloadInformationBox.java +++ /dev/null @@ -1,95 +0,0 @@ -package com.coremedia.iso.boxes; - -import com.coremedia.iso.IsoTypeReader; -import com.coremedia.iso.IsoTypeWriter; -import com.googlecode.mp4parser.AbstractFullBox; - -import java.nio.ByteBuffer; -import java.util.Collections; -import java.util.LinkedList; -import java.util.List; - -public class ProgressiveDownloadInformationBox extends AbstractFullBox { - - - List entries = Collections.emptyList(); - - public ProgressiveDownloadInformationBox() { - super("pdin"); - } - - @Override - protected long getContentSize() { - return 4 + entries.size() * 8; - } - - @Override - protected void getContent(ByteBuffer byteBuffer) { - writeVersionAndFlags(byteBuffer); - for (Entry entry : entries) { - IsoTypeWriter.writeUInt32(byteBuffer, entry.getRate()); - IsoTypeWriter.writeUInt32(byteBuffer, entry.getInitialDelay()); - } - } - - public List getEntries() { - return entries; - } - - public void setEntries(List entries) { - this.entries = entries; - } - - @Override - public void _parseDetails(ByteBuffer content) { - parseVersionAndFlags(content); - entries = new LinkedList(); - while (content.remaining() >= 8) { - Entry entry = new Entry(IsoTypeReader.readUInt32(content), IsoTypeReader.readUInt32(content)); - entries.add(entry); - } - } - - - public static class Entry { - long rate; - long initialDelay; - - public Entry(long rate, long initialDelay) { - this.rate = rate; - this.initialDelay = initialDelay; - } - - public long getRate() { - return rate; - } - - public void setRate(long rate) { - this.rate = rate; - } - - public long getInitialDelay() { - return initialDelay; - } - - public void setInitialDelay(long initialDelay) { - this.initialDelay = initialDelay; - } - - @Override - public String toString() { - return "Entry{" + - "rate=" + rate + - ", initialDelay=" + initialDelay + - '}'; - } - } - - @Override - public String toString() { - return "ProgressiveDownloadInfoBox{" + - "entries=" + entries + - '}'; - } - -} \ No newline at end of file diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/ProtectionSchemeInformationBox.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/ProtectionSchemeInformationBox.java deleted file mode 100644 index 87069d381..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/ProtectionSchemeInformationBox.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright 2008 CoreMedia AG, Hamburg - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coremedia.iso.boxes; - -import com.googlecode.mp4parser.AbstractContainerBox; - -/** - * The ProtectionSchemeInformationBox contains all the information required both - * to understand the encryption transform applied and its parameters, and also to find other - * information such as the kind and location of the key management system. It also documents the - * the original (unencrypted) format of the media. The ProtectionSchemeInformationBox - * is a container box. It is mandatory in a sample entry that uses a code idicating a - * protected stream. - * - * @see com.coremedia.iso.boxes.odf.OmaDrmKeyManagenentSystemBox - * @see com.coremedia.iso.boxes.sampleentry.AudioSampleEntry#TYPE_ENCRYPTED - * @see com.coremedia.iso.boxes.sampleentry.VisualSampleEntry#TYPE_ENCRYPTED - */ -public class ProtectionSchemeInformationBox extends AbstractContainerBox { - public static final String TYPE = "sinf"; - - public ProtectionSchemeInformationBox() { - super(TYPE); - - } - - -} diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/RatingBox.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/RatingBox.java deleted file mode 100644 index ad327495a..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/RatingBox.java +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Copyright 2008 CoreMedia AG, Hamburg - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coremedia.iso.boxes; - -import com.coremedia.iso.IsoFile; -import com.coremedia.iso.IsoTypeReader; -import com.coremedia.iso.IsoTypeWriter; -import com.coremedia.iso.Utf8; -import com.googlecode.mp4parser.AbstractFullBox; - -import java.nio.ByteBuffer; - - -/** - * Contained a the UserDataBox and containing information about the media's rating. E.g. - * PG13or FSK16. - */ -public class RatingBox extends AbstractFullBox { - public static final String TYPE = "rtng"; - - private String ratingEntity; - private String ratingCriteria; - private String language; - private String ratingInfo; - - public RatingBox() { - super(TYPE); - } - - - public void setRatingEntity(String ratingEntity) { - this.ratingEntity = ratingEntity; - } - - public void setRatingCriteria(String ratingCriteria) { - this.ratingCriteria = ratingCriteria; - } - - public void setLanguage(String language) { - this.language = language; - } - - public void setRatingInfo(String ratingInfo) { - this.ratingInfo = ratingInfo; - } - - public String getLanguage() { - return language; - } - - /** - * Gets a four-character code that indicates the rating entity grading the asset, e.g., 'BBFC'. The values of this - * field should follow common names of worldwide movie rating systems, such as those mentioned in - * [http://www.movie-ratings.net/, October 2002]. - * - * @return the rating organization - */ - public String getRatingEntity() { - return ratingEntity; - } - - /** - * Gets the four-character code that indicates which rating criteria are being used for the corresponding rating - * entity, e.g., 'PG13'. - * - * @return the actual rating - */ - public String getRatingCriteria() { - return ratingCriteria; - } - - public String getRatingInfo() { - return ratingInfo; - } - - protected long getContentSize() { - return 15 + Utf8.utf8StringLengthInBytes(ratingInfo); - } - - @Override - public void _parseDetails(ByteBuffer content) { - parseVersionAndFlags(content); - ratingEntity = IsoTypeReader.read4cc(content); - ratingCriteria = IsoTypeReader.read4cc(content); - language = IsoTypeReader.readIso639(content); - ratingInfo = IsoTypeReader.readString(content); - - } - - @Override - protected void getContent(ByteBuffer byteBuffer) { - writeVersionAndFlags(byteBuffer); - byteBuffer.put(IsoFile.fourCCtoBytes(ratingEntity)); - byteBuffer.put(IsoFile.fourCCtoBytes(ratingCriteria)); - IsoTypeWriter.writeIso639(byteBuffer, language); - byteBuffer.put(Utf8.convert(ratingInfo)); - byteBuffer.put((byte) 0); - } - - public String toString() { - StringBuilder buffer = new StringBuilder(); - buffer.append("RatingBox[language=").append(getLanguage()); - buffer.append("ratingEntity=").append(getRatingEntity()); - buffer.append(";ratingCriteria=").append(getRatingCriteria()); - buffer.append(";language=").append(getLanguage()); - buffer.append(";ratingInfo=").append(getRatingInfo()); - buffer.append("]"); - return buffer.toString(); - } -} diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/RecordingYearBox.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/RecordingYearBox.java deleted file mode 100644 index e2dcbd959..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/RecordingYearBox.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright 2008 CoreMedia AG, Hamburg - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coremedia.iso.boxes; - -import com.coremedia.iso.IsoTypeReader; -import com.coremedia.iso.IsoTypeWriter; -import com.googlecode.mp4parser.AbstractFullBox; - -import java.nio.ByteBuffer; - -/** - * - */ -public class RecordingYearBox extends AbstractFullBox { - public static final String TYPE = "yrrc"; - - int recordingYear; - - public RecordingYearBox() { - super(TYPE); - } - - - protected long getContentSize() { - return 6; - } - - public int getRecordingYear() { - return recordingYear; - } - - public void setRecordingYear(int recordingYear) { - this.recordingYear = recordingYear; - } - - - @Override - public void _parseDetails(ByteBuffer content) { - parseVersionAndFlags(content); - recordingYear = IsoTypeReader.readUInt16(content); - } - - @Override - protected void getContent(ByteBuffer byteBuffer) { - writeVersionAndFlags(byteBuffer); - IsoTypeWriter.writeUInt16(byteBuffer, recordingYear); - } - -} diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/SampleAuxiliaryInformationOffsetsBox.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/SampleAuxiliaryInformationOffsetsBox.java deleted file mode 100644 index 517bc033a..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/SampleAuxiliaryInformationOffsetsBox.java +++ /dev/null @@ -1,127 +0,0 @@ -/* - * Copyright 2009 castLabs GmbH, Berlin - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coremedia.iso.boxes; - -import com.coremedia.iso.IsoTypeReader; -import com.coremedia.iso.IsoTypeWriter; -import com.googlecode.mp4parser.AbstractFullBox; - -import java.nio.ByteBuffer; -import java.util.LinkedList; -import java.util.List; - -import static com.googlecode.mp4parser.util.CastUtils.l2i; - -/* -aligned(8) class SampleAuxiliaryInformationOffsetsBox - extends FullBox(‘saio’, version, flags) -{ - if (flags & 1) { - unsigned int(32) aux_info_type; - unsigned int(32) aux_info_type_parameter; - } - unsigned int(32) entry_count; - if ( version == 0 ) - { - unsigned int(32) offset[ entry_count ]; - } - else - { - unsigned int(64) offset[ entry_count ]; - } -} - */ -public class SampleAuxiliaryInformationOffsetsBox extends AbstractFullBox { - public static final String TYPE = "saio"; - - private List offsets = new LinkedList(); - private long auxInfoType; - private long auxInfoTypeParameter; - - public SampleAuxiliaryInformationOffsetsBox() { - super(TYPE); - } - - @Override - protected long getContentSize() { - return 8 + (getVersion() == 0 ? 4 * offsets.size() : 8 * offsets.size()) + ((getFlags() & 1) == 1 ? 8 : 0); - } - - @Override - protected void getContent(ByteBuffer byteBuffer) { - writeVersionAndFlags(byteBuffer); - if ((getFlags() & 1) == 1) { - IsoTypeWriter.writeUInt32(byteBuffer, auxInfoType); - IsoTypeWriter.writeUInt32(byteBuffer, auxInfoTypeParameter); - } - - IsoTypeWriter.writeUInt32(byteBuffer, offsets.size()); - for (Long offset : offsets) { - if (getVersion() == 0) { - IsoTypeWriter.writeUInt32(byteBuffer, offset); - } else { - IsoTypeWriter.writeUInt64(byteBuffer, offset); - } - } - } - - @Override - public void _parseDetails(ByteBuffer content) { - parseVersionAndFlags(content); - - if ((getFlags() & 1) == 1) { - auxInfoType = IsoTypeReader.readUInt32(content); - auxInfoTypeParameter = IsoTypeReader.readUInt32(content); - } - - int entryCount = l2i(IsoTypeReader.readUInt32(content)); - offsets.clear(); - - for (int i = 0; i < entryCount; i++) { - if (getVersion() == 0) { - offsets.add(IsoTypeReader.readUInt32(content)); - } else { - offsets.add(IsoTypeReader.readUInt64(content)); - } - } - } - - - public long getAuxInfoType() { - return auxInfoType; - } - - public void setAuxInfoType(long auxInfoType) { - this.auxInfoType = auxInfoType; - } - - public long getAuxInfoTypeParameter() { - return auxInfoTypeParameter; - } - - public void setAuxInfoTypeParameter(long auxInfoTypeParameter) { - this.auxInfoTypeParameter = auxInfoTypeParameter; - } - - public List getOffsets() { - return offsets; - } - - public void setOffsets(List offsets) { - this.offsets = offsets; - } -} diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/SampleAuxiliaryInformationSizesBox.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/SampleAuxiliaryInformationSizesBox.java deleted file mode 100644 index 655106200..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/SampleAuxiliaryInformationSizesBox.java +++ /dev/null @@ -1,134 +0,0 @@ -/* - * Copyright 2009 castLabs GmbH, Berlin - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coremedia.iso.boxes; - -import com.coremedia.iso.IsoFile; -import com.coremedia.iso.IsoTypeReader; -import com.coremedia.iso.IsoTypeWriter; -import com.googlecode.mp4parser.AbstractFullBox; - -import java.nio.ByteBuffer; -import java.util.LinkedList; -import java.util.List; - -import static com.googlecode.mp4parser.util.CastUtils.l2i; - -public class SampleAuxiliaryInformationSizesBox extends AbstractFullBox { - public static final String TYPE = "saiz"; - - private int defaultSampleInfoSize; - private List sampleInfoSizes = new LinkedList(); - private int sampleCount; - private String auxInfoType; - private String auxInfoTypeParameter; - - public SampleAuxiliaryInformationSizesBox() { - super(TYPE); - } - - @Override - protected long getContentSize() { - int size = 4; - if ((getFlags() & 1) == 1) { - size += 8; - } - - size += 5; - size += sampleInfoSizes.size(); - return size; - } - - @Override - protected void getContent(ByteBuffer byteBuffer) { - writeVersionAndFlags(byteBuffer); - if ((getFlags() & 1) == 1) { - byteBuffer.put(IsoFile.fourCCtoBytes(auxInfoType)); - byteBuffer.put(IsoFile.fourCCtoBytes(auxInfoTypeParameter)); - } - - IsoTypeWriter.writeUInt8(byteBuffer, defaultSampleInfoSize); - if (defaultSampleInfoSize == 0) { - IsoTypeWriter.writeUInt32(byteBuffer, sampleInfoSizes.size()); - for (short sampleInfoSize : sampleInfoSizes) { - IsoTypeWriter.writeUInt8(byteBuffer, sampleInfoSize); - } - } else { - IsoTypeWriter.writeUInt32(byteBuffer, sampleCount); - } - } - - @Override - public void _parseDetails(ByteBuffer content) { - parseVersionAndFlags(content); - if ((getFlags() & 1) == 1) { - auxInfoType = IsoTypeReader.read4cc(content); - auxInfoTypeParameter = IsoTypeReader.read4cc(content); - } - - defaultSampleInfoSize = (short) IsoTypeReader.readUInt8(content); - int sampleCount = l2i(IsoTypeReader.readUInt32(content)); - - sampleInfoSizes.clear(); - - for (int i = 0; i < sampleCount; i++) { - sampleInfoSizes.add((short) IsoTypeReader.readUInt8(content)); - } - } - - public String getAuxInfoType() { - return auxInfoType; - } - - public void setAuxInfoType(String auxInfoType) { - this.auxInfoType = auxInfoType; - } - - public String getAuxInfoTypeParameter() { - return auxInfoTypeParameter; - } - - public void setAuxInfoTypeParameter(String auxInfoTypeParameter) { - this.auxInfoTypeParameter = auxInfoTypeParameter; - } - - public int getDefaultSampleInfoSize() { - return defaultSampleInfoSize; - } - - public void setDefaultSampleInfoSize(int defaultSampleInfoSize) { - assert defaultSampleInfoSize <= 255; - assert defaultSampleInfoSize > 0; - this.defaultSampleInfoSize = defaultSampleInfoSize; - } - - - public List getSampleInfoSizes() { - return sampleInfoSizes; - } - - public void setSampleInfoSizes(List sampleInfoSizes) { - this.sampleInfoSizes = sampleInfoSizes; - } - - public int getSampleCount() { - return sampleCount; - } - - public void setSampleCount(int sampleCount) { - this.sampleCount = sampleCount; - } -} diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/SampleDependencyTypeBox.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/SampleDependencyTypeBox.java deleted file mode 100644 index bb38d8c70..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/SampleDependencyTypeBox.java +++ /dev/null @@ -1,136 +0,0 @@ -/* - * Copyright 2009 castLabs GmbH, Berlin - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coremedia.iso.boxes; - -import com.coremedia.iso.IsoTypeReader; -import com.coremedia.iso.IsoTypeWriter; -import com.googlecode.mp4parser.AbstractFullBox; - -import java.nio.ByteBuffer; -import java.util.ArrayList; -import java.util.List; - -/** - * aligned(8) class SampleDependencyTypeBox - * extends FullBox('sdtp', version = 0, 0) { - * for (i=0; i < sample_count; i++){ - * unsigned int(2) reserved = 0; - * unsigned int(2) sample_depends_on; - * unsigned int(2) sample_is_depended_on; - * unsigned int(2) sample_has_redundancy; - * } - * } - */ -public class SampleDependencyTypeBox extends AbstractFullBox { - public static final String TYPE = "sdtp"; - - private List entries = new ArrayList(); - - public static class Entry { - - public Entry(int value) { - this.value = value; - } - - private int value; - - - public int getReserved() { - return (value >> 6) & 0x03; - } - - public void setReserved(int res) { - value = (res & 0x03) << 6 | value & 0x3f; - } - - public int getSampleDependsOn() { - return (value >> 4) & 0x03; - } - - public void setSampleDependsOn(int sdo) { - value = (sdo & 0x03) << 4 | value & 0xcf; - } - - public int getSampleIsDependentOn() { - return (value >> 2) & 0x03; - } - - public void setSampleIsDependentOn(int sido) { - value = (sido & 0x03) << 2 | value & 0xf3; - } - - public int getSampleHasRedundancy() { - return value & 0x03; - } - - public void setSampleHasRedundancy(int shr) { - value = shr & 0x03 | value & 0xfc; - } - - @Override - public String toString() { - return "Entry{" + - "reserved=" + getReserved() + - ", sampleDependsOn=" + getSampleDependsOn() + - ", sampleIsDependentOn=" + getSampleIsDependentOn() + - ", sampleHasRedundancy=" + getSampleHasRedundancy() + - '}'; - } - } - - public SampleDependencyTypeBox() { - super(TYPE); - } - - @Override - protected long getContentSize() { - return 4 + entries.size(); - } - - @Override - protected void getContent(ByteBuffer byteBuffer) { - writeVersionAndFlags(byteBuffer); - for (Entry entry : entries) { - IsoTypeWriter.writeUInt8(byteBuffer, entry.value); - } - } - - @Override - public void _parseDetails(ByteBuffer content) { - parseVersionAndFlags(content); - while (content.remaining() > 0) { - entries.add(new Entry(IsoTypeReader.readUInt8(content))); - } - } - - public List getEntries() { - return entries; - } - - public void setEntries(List entries) { - this.entries = entries; - } - - @Override - public String toString() { - final StringBuilder sb = new StringBuilder(); - sb.append("SampleDependencyTypeBox"); - sb.append("{entries=").append(entries); - sb.append('}'); - return sb.toString(); - } -} diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/SampleDescriptionBox.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/SampleDescriptionBox.java deleted file mode 100644 index 662fa9948..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/SampleDescriptionBox.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright 2008 CoreMedia AG, Hamburg - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coremedia.iso.boxes; - -import com.coremedia.iso.IsoTypeWriter; -import com.coremedia.iso.boxes.sampleentry.SampleEntry; -import com.googlecode.mp4parser.FullContainerBox; - -import java.nio.ByteBuffer; - -/** - * The sample description table gives detailed information about the coding type used, and any initialization - * information needed for that coding.
    - * The information stored in the sample description box after the entry-count is both track-type specific as - * documented here, and can also have variants within a track type (e.g. different codings may use different - * specific information after some common fields, even within a video track).
    - * For video tracks, a VisualSampleEntry is used; for audio tracks, an AudioSampleEntry. Hint tracks use an - * entry format specific to their protocol, with an appropriate name. Timed Text tracks use a TextSampleEntry - * For hint tracks, the sample description contains appropriate declarative data for the streaming protocol being - * used, and the format of the hint track. The definition of the sample description is specific to the protocol. - * Multiple descriptions may be used within a track.
    - * The 'protocol' and 'codingname' fields are registered identifiers that uniquely identify the streaming protocol or - * compression format decoder to be used. A given protocol or codingname may have optional or required - * extensions to the sample description (e.g. codec initialization parameters). All such extensions shall be within - * boxes; these boxes occur after the required fields. Unrecognized boxes shall be ignored. - *
    - * Defined in ISO/IEC 14496-12 - * - * @see com.coremedia.iso.boxes.sampleentry.VisualSampleEntry - * @see com.coremedia.iso.boxes.sampleentry.TextSampleEntry - * @see com.coremedia.iso.boxes.sampleentry.AudioSampleEntry - */ -public class SampleDescriptionBox extends FullContainerBox { - public static final String TYPE = "stsd"; - - public SampleDescriptionBox() { - super(TYPE); - } - - @Override - protected long getContentSize() { - return super.getContentSize() + 4; - } - - @Override - public void _parseDetails(ByteBuffer content) { - parseVersionAndFlags(content); - content.get(new byte[4]); - parseChildBoxes(content); - } - - @Override - protected void getContent(ByteBuffer byteBuffer) { - writeVersionAndFlags(byteBuffer); - IsoTypeWriter.writeUInt32(byteBuffer, boxes.size()); - writeChildBoxes(byteBuffer); - } - - public SampleEntry getSampleEntry() { - for (Box box : boxes) { - if (box instanceof SampleEntry) { - return (SampleEntry) box; - } - } - return null; - } -} diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/SampleSizeBox.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/SampleSizeBox.java deleted file mode 100644 index 3bc1df080..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/SampleSizeBox.java +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Copyright 2008 CoreMedia AG, Hamburg - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coremedia.iso.boxes; - - -import com.coremedia.iso.IsoTypeReader; -import com.coremedia.iso.IsoTypeWriter; -import com.googlecode.mp4parser.AbstractFullBox; - -import java.nio.ByteBuffer; - -import static com.googlecode.mp4parser.util.CastUtils.l2i; - -/** - * This box containes the sample count and a table giving the size in bytes of each sample. - * Defined in ISO/IEC 14496-12. - */ -public class SampleSizeBox extends AbstractFullBox { - private long sampleSize; - private long[] sampleSizes = new long[0]; - public static final String TYPE = "stsz"; - int sampleCount; - - public SampleSizeBox() { - super(TYPE); - } - - /** - * Returns the field sample size. - * If sampleSize > 0 every sample has the same size. - * If sampleSize == 0 the samples have different size as stated in the sampleSizes field. - * - * @return the sampleSize field - */ - public long getSampleSize() { - return sampleSize; - } - - public void setSampleSize(long sampleSize) { - this.sampleSize = sampleSize; - } - - - public long getSampleSizeAtIndex(int index) { - if (sampleSize > 0) { - return sampleSize; - } else { - return sampleSizes[index]; - } - } - - public long getSampleCount() { - if (sampleSize > 0) { - return sampleCount; - } else { - return sampleSizes.length; - } - - } - - public long[] getSampleSizes() { - return sampleSizes; - } - - public void setSampleSizes(long[] sampleSizes) { - this.sampleSizes = sampleSizes; - } - - protected long getContentSize() { - return 12 + (sampleSize == 0 ? sampleSizes.length * 4 : 0); - } - - @Override - public void _parseDetails(ByteBuffer content) { - parseVersionAndFlags(content); - sampleSize = IsoTypeReader.readUInt32(content); - sampleCount = l2i(IsoTypeReader.readUInt32(content)); - - if (sampleSize == 0) { - sampleSizes = new long[(int) sampleCount]; - - for (int i = 0; i < sampleCount; i++) { - sampleSizes[i] = IsoTypeReader.readUInt32(content); - } - } - } - - @Override - protected void getContent(ByteBuffer byteBuffer) { - writeVersionAndFlags(byteBuffer); - IsoTypeWriter.writeUInt32(byteBuffer, sampleSize); - - if (sampleSize == 0) { - IsoTypeWriter.writeUInt32(byteBuffer, sampleSizes.length); - for (long sampleSize1 : sampleSizes) { - IsoTypeWriter.writeUInt32(byteBuffer, sampleSize1); - } - } else { - IsoTypeWriter.writeUInt32(byteBuffer, sampleCount); - } - - } - - public String toString() { - return "SampleSizeBox[sampleSize=" + getSampleSize() + ";sampleCount=" + getSampleCount() + "]"; - } -} diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/SampleTableBox.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/SampleTableBox.java deleted file mode 100644 index 33968b350..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/SampleTableBox.java +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Copyright 2008 CoreMedia AG, Hamburg - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coremedia.iso.boxes; - -import com.googlecode.mp4parser.AbstractContainerBox; - -/** - * The sample table contains all the time and data indexing of the media samples in a track. Using the tables - * here, it is possible to locate samples in time, determine their type (e.g. I-frame or not), and determine their - * size, container, and offset into that container.
    - * If the track that contains the Sample Table Box references no data, then the Sample Table Box does not need - * to contain any sub-boxes (this is not a very useful media track).
    - * If the track that the Sample Table Box is contained in does reference data, then the following sub-boxes are - * required: Sample Description, Sample Size, Sample To Chunk, and Chunk Offset. Further, the Sample - * Description Box shall contain at least one entry. A Sample Description Box is required because it contains the - * data reference index field which indicates which Data Reference Box to use to retrieve the media samples. - * Without the Sample Description, it is not possible to determine where the media samples are stored. The Sync - * Sample Box is optional. If the Sync Sample Box is not present, all samples are sync samples.
    - * Annex A provides a narrative description of random access using the structures defined in the Sample Table - * Box. - */ -public class SampleTableBox extends AbstractContainerBox { - public static final String TYPE = "stbl"; - - public SampleTableBox() { - super(TYPE); - } - - public SampleDescriptionBox getSampleDescriptionBox() { - for (Box box : boxes) { - if (box instanceof SampleDescriptionBox) { - return (SampleDescriptionBox) box; - } - } - return null; - } - - public SampleSizeBox getSampleSizeBox() { - for (Box box : boxes) { - if (box instanceof SampleSizeBox) { - return (SampleSizeBox) box; - } - } - return null; - } - - public SampleToChunkBox getSampleToChunkBox() { - for (Box box : boxes) { - if (box instanceof SampleToChunkBox) { - return (SampleToChunkBox) box; - } - } - return null; - } - - public ChunkOffsetBox getChunkOffsetBox() { - for (Box box : boxes) { - if (box instanceof ChunkOffsetBox) { - return (ChunkOffsetBox) box; - } - } - return null; - } - - public void setChunkOffsetBox(ChunkOffsetBox b) { - for (int i = 0; i < boxes.size(); i++) { - Box box = boxes.get(i); - if (box instanceof ChunkOffsetBox) { - boxes.set(i, b); - } - } - } - - public TimeToSampleBox getTimeToSampleBox() { - for (Box box : boxes) { - if (box instanceof TimeToSampleBox) { - return (TimeToSampleBox) box; - } - } - return null; - } - - public SyncSampleBox getSyncSampleBox() { - for (Box box : boxes) { - if (box instanceof SyncSampleBox) { - return (SyncSampleBox) box; - } - } - return null; - } - - public CompositionTimeToSample getCompositionTimeToSample() { - for (Box box : boxes) { - if (box instanceof CompositionTimeToSample) { - return (CompositionTimeToSample) box; - } - } - return null; - } - - public SampleDependencyTypeBox getSampleDependencyTypeBox() { - for (Box box : boxes) { - if (box instanceof SampleDependencyTypeBox) { - return (SampleDependencyTypeBox) box; - } - } - return null; - } - -} diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/SampleToChunkBox.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/SampleToChunkBox.java deleted file mode 100644 index 593504d38..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/SampleToChunkBox.java +++ /dev/null @@ -1,156 +0,0 @@ -/* - * Copyright 2008 CoreMedia AG, Hamburg - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coremedia.iso.boxes; - -import com.coremedia.iso.IsoTypeReader; -import com.coremedia.iso.IsoTypeWriter; -import com.googlecode.mp4parser.AbstractFullBox; - -import java.nio.ByteBuffer; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; - -import static com.googlecode.mp4parser.util.CastUtils.l2i; - -/** - * Samples within the media data are grouped into chunks. Chunks can be of different sizes, and the - * samples within a chunk can have different sizes. This table can be used to find the chunk that - * contains a sample, its position, and the associated sample description. Defined in ISO/IEC 14496-12. - */ -public class SampleToChunkBox extends AbstractFullBox { - List entries = Collections.emptyList(); - - public static final String TYPE = "stsc"; - - public SampleToChunkBox() { - super(TYPE); - } - - public List getEntries() { - return entries; - } - - public void setEntries(List entries) { - this.entries = entries; - } - - protected long getContentSize() { - return entries.size() * 12 + 8; - } - - @Override - public void _parseDetails(ByteBuffer content) { - parseVersionAndFlags(content); - - int entryCount = l2i(IsoTypeReader.readUInt32(content)); - entries = new ArrayList(entryCount); - for (int i = 0; i < entryCount; i++) { - entries.add(new Entry( - IsoTypeReader.readUInt32(content), - IsoTypeReader.readUInt32(content), - IsoTypeReader.readUInt32(content))); - } - } - - @Override - protected void getContent(ByteBuffer byteBuffer) { - writeVersionAndFlags(byteBuffer); - IsoTypeWriter.writeUInt32(byteBuffer, entries.size()); - for (Entry entry : entries) { - IsoTypeWriter.writeUInt32(byteBuffer, entry.getFirstChunk()); - IsoTypeWriter.writeUInt32(byteBuffer, entry.getSamplesPerChunk()); - IsoTypeWriter.writeUInt32(byteBuffer, entry.getSampleDescriptionIndex()); - } - } - - public String toString() { - return "SampleToChunkBox[entryCount=" + entries.size() + "]"; - } - - /** - * Decompresses the list of entries and returns the number of samples per chunk for - * every single chunk. - * - * @param chunkCount overall number of chunks - * @return number of samples per chunk - */ - public long[] blowup(int chunkCount) { - long[] numberOfSamples = new long[chunkCount]; - int j = 0; - List sampleToChunkEntries = new LinkedList(entries); - Collections.reverse(sampleToChunkEntries); - Iterator iterator = sampleToChunkEntries.iterator(); - SampleToChunkBox.Entry currentEntry = iterator.next(); - - for (int i = numberOfSamples.length; i > 1; i--) { - numberOfSamples[i - 1] = currentEntry.getSamplesPerChunk(); - if (i == currentEntry.getFirstChunk()) { - currentEntry = iterator.next(); - } - } - numberOfSamples[0] = currentEntry.getSamplesPerChunk(); - return numberOfSamples; - } - - public static class Entry { - long firstChunk; - long samplesPerChunk; - long sampleDescriptionIndex; - - public Entry(long firstChunk, long samplesPerChunk, long sampleDescriptionIndex) { - this.firstChunk = firstChunk; - this.samplesPerChunk = samplesPerChunk; - this.sampleDescriptionIndex = sampleDescriptionIndex; - } - - public long getFirstChunk() { - return firstChunk; - } - - public void setFirstChunk(long firstChunk) { - this.firstChunk = firstChunk; - } - - public long getSamplesPerChunk() { - return samplesPerChunk; - } - - public void setSamplesPerChunk(long samplesPerChunk) { - this.samplesPerChunk = samplesPerChunk; - } - - public long getSampleDescriptionIndex() { - return sampleDescriptionIndex; - } - - public void setSampleDescriptionIndex(long sampleDescriptionIndex) { - this.sampleDescriptionIndex = sampleDescriptionIndex; - } - - @Override - public String toString() { - return "Entry{" + - "firstChunk=" + firstChunk + - ", samplesPerChunk=" + samplesPerChunk + - ", sampleDescriptionIndex=" + sampleDescriptionIndex + - '}'; - } - } -} diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/SampleToGroupBox.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/SampleToGroupBox.java deleted file mode 100644 index 612b8403d..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/SampleToGroupBox.java +++ /dev/null @@ -1,122 +0,0 @@ -package com.coremedia.iso.boxes; - -import com.coremedia.iso.IsoTypeReader; -import com.coremedia.iso.IsoTypeWriter; -import com.googlecode.mp4parser.AbstractFullBox; - -import java.nio.ByteBuffer; -import java.util.ArrayList; -import java.util.List; - -/** - * aligned(8) class SampleToGroupBox - * extends FullBox('sbgp', version = 0, 0) - * { - * unsigned int(32) grouping_type; - * unsigned int(32) entry_count; - * for (i=1; i <= entry_count; i++) - * { - * unsigned int(32) sample_count; - * unsigned int(32) group_description_index; - * } - * } - */ -public class SampleToGroupBox extends AbstractFullBox { - public static final String TYPE = "sbgp"; - private long groupingType; - private long entryCount; - private long groupingTypeParameter; - private List entries = new ArrayList(); - - public SampleToGroupBox() { - super(TYPE); - } - - @Override - protected long getContentSize() { - return 12 + entryCount * 8; - } - - public long getGroupingTypeParameter() { - return groupingTypeParameter; - } - - /** - * Usage of this parameter requires version == 1. The version must be set manually. - */ - public void setGroupingTypeParameter(long groupingTypeParameter) { - this.groupingTypeParameter = groupingTypeParameter; - } - - public List getEntries() { - return entries; - } - - public void setEntries(List entries) { - this.entries = entries; - } - - public long getGroupingType() { - return groupingType; - } - - - public void setGroupingType(long groupingType) { - this.groupingType = groupingType; - } - - @Override - public void _parseDetails(ByteBuffer content) { - parseVersionAndFlags(content); - groupingType = IsoTypeReader.readUInt32(content); - if (getVersion() == 1) { - groupingTypeParameter = IsoTypeReader.readUInt32(content); - } else { - groupingTypeParameter = -1; - } - entryCount = IsoTypeReader.readUInt32(content); - - for (int i = 0; i < entryCount; i++) { - Entry entry = new Entry(); - entry.setSampleCount(IsoTypeReader.readUInt32(content)); - entry.setGroupDescriptionIndex(IsoTypeReader.readUInt32(content)); - entries.add(entry); - } - } - - @Override - protected void getContent(ByteBuffer byteBuffer) { - writeVersionAndFlags(byteBuffer); - - IsoTypeWriter.writeUInt32(byteBuffer, groupingType); - if (getVersion() == 1) { - IsoTypeWriter.writeUInt32(byteBuffer, groupingTypeParameter); - } - IsoTypeWriter.writeUInt32(byteBuffer, entryCount); - for (Entry entry : entries) { - IsoTypeWriter.writeUInt32(byteBuffer, entry.getSampleCount()); - IsoTypeWriter.writeUInt32(byteBuffer, entry.getGroupDescriptionIndex()); - } - } - - public static class Entry { - private long sampleCount; - private long groupDescriptionIndex; - - public long getSampleCount() { - return sampleCount; - } - - public void setSampleCount(long sampleCount) { - this.sampleCount = sampleCount; - } - - public long getGroupDescriptionIndex() { - return groupDescriptionIndex; - } - - public void setGroupDescriptionIndex(long groupDescriptionIndex) { - this.groupDescriptionIndex = groupDescriptionIndex; - } - } -} diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/SchemeInformationBox.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/SchemeInformationBox.java deleted file mode 100644 index 5e3565e4c..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/SchemeInformationBox.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright 2008 CoreMedia AG, Hamburg - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coremedia.iso.boxes; - -import com.googlecode.mp4parser.AbstractContainerBox; - -/** - * The Scheme Information Box is a container box that is only interpreted by the scheme beeing used. - * Any information the encryption system needs is stored here. The content of this box is a series of - * boxexes whose type annd format are defined by the scheme declared in the {@link com.coremedia.iso.boxes.SchemeTypeBox}. - */ -public class SchemeInformationBox extends AbstractContainerBox { - public static final String TYPE = "schi"; - - public SchemeInformationBox() { - super(TYPE); - } - -} diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/SchemeTypeBox.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/SchemeTypeBox.java deleted file mode 100644 index ed517da2b..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/SchemeTypeBox.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Copyright 2008 CoreMedia AG, Hamburg - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coremedia.iso.boxes; - -import com.coremedia.iso.IsoFile; -import com.coremedia.iso.IsoTypeReader; -import com.coremedia.iso.IsoTypeWriter; -import com.coremedia.iso.Utf8; -import com.googlecode.mp4parser.AbstractFullBox; - -import java.nio.ByteBuffer; - -/** - * The Scheme Type Box identifies the protection scheme. Resides in a Protection Scheme Information Box or - * an SRTP Process Box. - * - * @see com.coremedia.iso.boxes.SchemeInformationBox - */ -public class SchemeTypeBox extends AbstractFullBox { - public static final String TYPE = "schm"; - String schemeType = " "; - long schemeVersion; - String schemeUri = null; - - public SchemeTypeBox() { - super(TYPE); - } - - public String getSchemeType() { - return schemeType; - } - - public long getSchemeVersion() { - return schemeVersion; - } - - public String getSchemeUri() { - return schemeUri; - } - - public void setSchemeType(String schemeType) { - assert schemeType != null && schemeType.length() == 4 : "SchemeType may not be null or not 4 bytes long"; - this.schemeType = schemeType; - } - - public void setSchemeVersion(int schemeVersion) { - this.schemeVersion = schemeVersion; - } - - public void setSchemeUri(String schemeUri) { - this.schemeUri = schemeUri; - } - - protected long getContentSize() { - return 12 + (((getFlags() & 1) == 1) ? Utf8.utf8StringLengthInBytes(schemeUri) + 1 : 0); - } - - @Override - public void _parseDetails(ByteBuffer content) { - parseVersionAndFlags(content); - schemeType = IsoTypeReader.read4cc(content); - schemeVersion = IsoTypeReader.readUInt32(content); - if ((getFlags() & 1) == 1) { - schemeUri = IsoTypeReader.readString(content); - } - } - - @Override - protected void getContent(ByteBuffer byteBuffer) { - writeVersionAndFlags(byteBuffer); - byteBuffer.put(IsoFile.fourCCtoBytes(schemeType)); - IsoTypeWriter.writeUInt32(byteBuffer, schemeVersion); - if ((getFlags() & 1) == 1) { - byteBuffer.put(Utf8.convert(schemeUri)); - } - } - - public String toString() { - StringBuilder buffer = new StringBuilder(); - buffer.append("Schema Type Box["); - buffer.append("schemeUri=").append(schemeUri).append("; "); - buffer.append("schemeType=").append(schemeType).append("; "); - buffer.append("schemeVersion=").append(schemeUri).append("; "); - buffer.append("]"); - return buffer.toString(); - } -} diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/SoundMediaHeaderBox.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/SoundMediaHeaderBox.java deleted file mode 100644 index c5fb88d2c..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/SoundMediaHeaderBox.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright 2008 CoreMedia AG, Hamburg - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coremedia.iso.boxes; - -import com.coremedia.iso.IsoTypeReader; -import com.coremedia.iso.IsoTypeWriter; - -import java.nio.ByteBuffer; - -public class SoundMediaHeaderBox extends AbstractMediaHeaderBox { - - public static final String TYPE = "smhd"; - private float balance; - - public SoundMediaHeaderBox() { - super(TYPE); - } - - public float getBalance() { - return balance; - } - - protected long getContentSize() { - return 8; - } - - @Override - public void _parseDetails(ByteBuffer content) { - parseVersionAndFlags(content); - balance = IsoTypeReader.readFixedPoint88(content); - IsoTypeReader.readUInt16(content); - } - - @Override - protected void getContent(ByteBuffer byteBuffer) { - writeVersionAndFlags(byteBuffer); - IsoTypeWriter.writeFixedPont88(byteBuffer, balance); - IsoTypeWriter.writeUInt16(byteBuffer, 0); - } - - public String toString() { - return "SoundMediaHeaderBox[balance=" + getBalance() + "]"; - } -} diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/StaticChunkOffsetBox.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/StaticChunkOffsetBox.java deleted file mode 100644 index efcdd1455..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/StaticChunkOffsetBox.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright 2008 CoreMedia AG, Hamburg - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coremedia.iso.boxes; - -import com.coremedia.iso.IsoTypeReader; -import com.coremedia.iso.IsoTypeWriter; - -import java.nio.ByteBuffer; - -import static com.googlecode.mp4parser.util.CastUtils.l2i; - -/** - * The chunk offset table gives the index of each chunk into the containing file. Defined in ISO/IEC 14496-12. - */ -public class StaticChunkOffsetBox extends ChunkOffsetBox { - public static final String TYPE = "stco"; - - private long[] chunkOffsets = new long[0]; - - public StaticChunkOffsetBox() { - super(TYPE); - } - - public long[] getChunkOffsets() { - return chunkOffsets; - } - - protected long getContentSize() { - return 8 + chunkOffsets.length * 4; - } - - public void setChunkOffsets(long[] chunkOffsets) { - this.chunkOffsets = chunkOffsets; - } - - @Override - public void _parseDetails(ByteBuffer content) { - parseVersionAndFlags(content); - int entryCount = l2i(IsoTypeReader.readUInt32(content)); - chunkOffsets = new long[entryCount]; - for (int i = 0; i < entryCount; i++) { - chunkOffsets[i] = IsoTypeReader.readUInt32(content); - } - - } - - @Override - protected void getContent(ByteBuffer byteBuffer) { - writeVersionAndFlags(byteBuffer); - IsoTypeWriter.writeUInt32(byteBuffer, chunkOffsets.length); - for (long chunkOffset : chunkOffsets) { - IsoTypeWriter.writeUInt32(byteBuffer, chunkOffset); - } - } - - -} diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/SubSampleInformationBox.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/SubSampleInformationBox.java deleted file mode 100644 index e30aaccf3..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/SubSampleInformationBox.java +++ /dev/null @@ -1,208 +0,0 @@ -package com.coremedia.iso.boxes; - -import com.coremedia.iso.IsoTypeReader; -import com.coremedia.iso.IsoTypeWriter; -import com.googlecode.mp4parser.AbstractFullBox; - -import java.nio.ByteBuffer; -import java.util.ArrayList; -import java.util.List; - -import static com.googlecode.mp4parser.util.CastUtils.l2i; - -/** - * aligned(8) class SubSampleInformationBox - * extends FullBox('subs', version, 0) { - * unsigned int(32) entry_count; - * int i,j; - * for (i=0; i < entry_count; i++) { - * unsigned int(32) sample_delta; - * unsigned int(16) subsample_count; - * if (subsample_count > 0) { - * for (j=0; j < subsample_count; j++) { - * if(version == 1) - * { - * unsigned int(32) subsample_size; - * } - * else - * { - * unsigned int(16) subsample_size; - * } - * unsigned int(8) subsample_priority; - * unsigned int(8) discardable; - * unsigned int(32) reserved = 0; - * } - * } - * } - * } - */ -public class SubSampleInformationBox extends AbstractFullBox { - public static final String TYPE = "subs"; - - private long entryCount; - private List entries = new ArrayList(); - - public SubSampleInformationBox() { - super(TYPE); - } - - public List getEntries() { - return entries; - } - - public void setEntries(List entries) { - this.entries = entries; - entryCount = entries.size(); - } - - @Override - protected long getContentSize() { - long entries = 8 + ((4 + 2) * entryCount); - int subsampleEntries = 0; - for (SampleEntry sampleEntry : this.entries) { - subsampleEntries += sampleEntry.getSubsampleCount() * (((getVersion() == 1) ? 4 : 2) + 1 + 1 + 4); - } - return entries + subsampleEntries; - } - - @Override - public void _parseDetails(ByteBuffer content) { - parseVersionAndFlags(content); - - entryCount = IsoTypeReader.readUInt32(content); - - for (int i = 0; i < entryCount; i++) { - SampleEntry sampleEntry = new SampleEntry(); - sampleEntry.setSampleDelta(IsoTypeReader.readUInt32(content)); - int subsampleCount = IsoTypeReader.readUInt16(content); - for (int j = 0; j < subsampleCount; j++) { - SampleEntry.SubsampleEntry subsampleEntry = new SampleEntry.SubsampleEntry(); - subsampleEntry.setSubsampleSize(getVersion() == 1 ? IsoTypeReader.readUInt32(content) : IsoTypeReader.readUInt16(content)); - subsampleEntry.setSubsamplePriority(IsoTypeReader.readUInt8(content)); - subsampleEntry.setDiscardable(IsoTypeReader.readUInt8(content)); - subsampleEntry.setReserved(IsoTypeReader.readUInt32(content)); - sampleEntry.addSubsampleEntry(subsampleEntry); - } - entries.add(sampleEntry); - } - - } - - @Override - protected void getContent(ByteBuffer byteBuffer) { - writeVersionAndFlags(byteBuffer); - IsoTypeWriter.writeUInt32(byteBuffer, entries.size()); - for (SampleEntry sampleEntry : entries) { - IsoTypeWriter.writeUInt32(byteBuffer, sampleEntry.getSampleDelta()); - IsoTypeWriter.writeUInt16(byteBuffer, sampleEntry.getSubsampleCount()); - List subsampleEntries = sampleEntry.getSubsampleEntries(); - for (SampleEntry.SubsampleEntry subsampleEntry : subsampleEntries) { - if (getVersion() == 1) { - IsoTypeWriter.writeUInt32(byteBuffer, subsampleEntry.getSubsampleSize()); - } else { - IsoTypeWriter.writeUInt16(byteBuffer, l2i(subsampleEntry.getSubsampleSize())); - } - IsoTypeWriter.writeUInt8(byteBuffer, subsampleEntry.getSubsamplePriority()); - IsoTypeWriter.writeUInt8(byteBuffer, subsampleEntry.getDiscardable()); - IsoTypeWriter.writeUInt32(byteBuffer, subsampleEntry.getReserved()); - } - } - } - - @Override - public String toString() { - return "SubSampleInformationBox{" + - "entryCount=" + entryCount + - ", entries=" + entries + - '}'; - } - - public static class SampleEntry { - private long sampleDelta; - private int subsampleCount; - private List subsampleEntries = new ArrayList(); - - public long getSampleDelta() { - return sampleDelta; - } - - public void setSampleDelta(long sampleDelta) { - this.sampleDelta = sampleDelta; - } - - public int getSubsampleCount() { - return subsampleCount; - } - - public void setSubsampleCount(int subsampleCount) { - this.subsampleCount = subsampleCount; - } - - public List getSubsampleEntries() { - return subsampleEntries; - } - - public void addSubsampleEntry(SubsampleEntry subsampleEntry) { - subsampleEntries.add(subsampleEntry); - subsampleCount++; - } - - public static class SubsampleEntry { - private long subsampleSize; - private int subsamplePriority; - private int discardable; - private long reserved; - - public long getSubsampleSize() { - return subsampleSize; - } - - public void setSubsampleSize(long subsampleSize) { - this.subsampleSize = subsampleSize; - } - - public int getSubsamplePriority() { - return subsamplePriority; - } - - public void setSubsamplePriority(int subsamplePriority) { - this.subsamplePriority = subsamplePriority; - } - - public int getDiscardable() { - return discardable; - } - - public void setDiscardable(int discardable) { - this.discardable = discardable; - } - - public long getReserved() { - return reserved; - } - - public void setReserved(long reserved) { - this.reserved = reserved; - } - - @Override - public String toString() { - return "SubsampleEntry{" + - "subsampleSize=" + subsampleSize + - ", subsamplePriority=" + subsamplePriority + - ", discardable=" + discardable + - ", reserved=" + reserved + - '}'; - } - } - - @Override - public String toString() { - return "SampleEntry{" + - "sampleDelta=" + sampleDelta + - ", subsampleCount=" + subsampleCount + - ", subsampleEntries=" + subsampleEntries + - '}'; - } - } -} diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/SubtitleMediaHeaderBox.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/SubtitleMediaHeaderBox.java deleted file mode 100644 index fa25a5c7b..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/SubtitleMediaHeaderBox.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.coremedia.iso.boxes; - -import java.nio.ByteBuffer; - -public class SubtitleMediaHeaderBox extends AbstractMediaHeaderBox { - - public static final String TYPE = "sthd"; - - public SubtitleMediaHeaderBox() { - super(TYPE); - } - - protected long getContentSize() { - return 4; - } - - @Override - public void _parseDetails(ByteBuffer content) { - parseVersionAndFlags(content); - } - - @Override - protected void getContent(ByteBuffer byteBuffer) { - writeVersionAndFlags(byteBuffer); - } - - public String toString() { - return "SubtitleMediaHeaderBox"; - } -} diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/SyncSampleBox.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/SyncSampleBox.java deleted file mode 100644 index 5fc758b40..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/SyncSampleBox.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright 2008 CoreMedia AG, Hamburg - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coremedia.iso.boxes; - -import com.coremedia.iso.IsoTypeReader; -import com.coremedia.iso.IsoTypeWriter; -import com.googlecode.mp4parser.AbstractFullBox; - -import java.nio.ByteBuffer; - -import static com.googlecode.mp4parser.util.CastUtils.l2i; - -/** - * This box provides a compact marking of the random access points withinthe stream. The table is arranged in - * strictly decreasinf order of sample number. Defined in ISO/IEC 14496-12. - */ -public class SyncSampleBox extends AbstractFullBox { - public static final String TYPE = "stss"; - - private long[] sampleNumber; - - public SyncSampleBox() { - super(TYPE); - } - - /** - * Gives the numbers of the samples that are random access points in the stream. - * - * @return random access sample numbers. - */ - public long[] getSampleNumber() { - return sampleNumber; - } - - protected long getContentSize() { - return sampleNumber.length * 4 + 8; - } - - @Override - public void _parseDetails(ByteBuffer content) { - parseVersionAndFlags(content); - int entryCount = l2i(IsoTypeReader.readUInt32(content)); - - sampleNumber = new long[entryCount]; - for (int i = 0; i < entryCount; i++) { - sampleNumber[i] = IsoTypeReader.readUInt32(content); - } - } - - @Override - protected void getContent(ByteBuffer byteBuffer) { - writeVersionAndFlags(byteBuffer); - - IsoTypeWriter.writeUInt32(byteBuffer, sampleNumber.length); - - for (long aSampleNumber : sampleNumber) { - IsoTypeWriter.writeUInt32(byteBuffer, aSampleNumber); - } - - } - - public String toString() { - return "SyncSampleBox[entryCount=" + sampleNumber.length + "]"; - } - - public void setSampleNumber(long[] sampleNumber) { - this.sampleNumber = sampleNumber; - } -} diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/TimeToSampleBox.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/TimeToSampleBox.java deleted file mode 100644 index 8f4f97e23..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/TimeToSampleBox.java +++ /dev/null @@ -1,152 +0,0 @@ -/* - * Copyright 2008 CoreMedia AG, Hamburg - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coremedia.iso.boxes; - - -import com.coremedia.iso.IsoTypeReader; -import com.coremedia.iso.IsoTypeWriter; -import com.googlecode.mp4parser.AbstractFullBox; - -import java.nio.ByteBuffer; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -import static com.googlecode.mp4parser.util.CastUtils.l2i; - -/** - * This box contains a compact version of a table that allows indexing from decoding time to sample number. - * Other tables give sample sizes and pointers, from the sample number. Each entry in the table gives the - * number of consecutive samples with the same time delta, and the delta of those samples. By adding the - * deltas a complete time-to-sample map may be built.
    - * The Decoding Time to Sample Box contains decode time delta's: DT(n+1) = DT(n) + STTS(n) where STTS(n) - * is the (uncompressed) table entry for sample n.
    - * The sample entries are ordered by decoding time stamps; therefore the deltas are all non-negative.
    - * The DT axis has a zero origin; DT(i) = SUM(for j=0 to i-1 of delta(j)), and the sum of all - * deltas gives the length of the media in the track (not mapped to the overall timescale, and not considering - * any edit list).
    - * The Edit List Box provides the initial CT value if it is non-empty (non-zero). - */ -public class TimeToSampleBox extends AbstractFullBox { - public static final String TYPE = "stts"; - - List entries = Collections.emptyList(); - - - public TimeToSampleBox() { - super(TYPE); - } - - protected long getContentSize() { - return 8 + entries.size() * 8; - } - - @Override - public void _parseDetails(ByteBuffer content) { - parseVersionAndFlags(content); - int entryCount = l2i(IsoTypeReader.readUInt32(content)); - entries = new ArrayList(entryCount); - - for (int i = 0; i < entryCount; i++) { - entries.add(new Entry(IsoTypeReader.readUInt32(content), IsoTypeReader.readUInt32(content))); - } - - } - - @Override - protected void getContent(ByteBuffer byteBuffer) { - writeVersionAndFlags(byteBuffer); - IsoTypeWriter.writeUInt32(byteBuffer, entries.size()); - for (Entry entry : entries) { - IsoTypeWriter.writeUInt32(byteBuffer, entry.getCount()); - IsoTypeWriter.writeUInt32(byteBuffer, entry.getDelta()); - } - } - - public List getEntries() { - return entries; - } - - public void setEntries(List entries) { - this.entries = entries; - } - - public String toString() { - return "TimeToSampleBox[entryCount=" + entries.size() + "]"; - } - - public static class Entry { - long count; - long delta; - - public Entry(long count, long delta) { - this.count = count; - this.delta = delta; - } - - public long getCount() { - return count; - } - - public long getDelta() { - return delta; - } - - public void setCount(long count) { - this.count = count; - } - - public void setDelta(long delta) { - this.delta = delta; - } - - @Override - public String toString() { - return "Entry{" + - "count=" + count + - ", delta=" + delta + - '}'; - } - } - - /** - * Decompresses the list of entries and returns the list of decoding times. - * - * @return decoding time per sample - */ - public static long[] blowupTimeToSamples(List entries) { - long numOfSamples = 0; - for (TimeToSampleBox.Entry entry : entries) { - numOfSamples += entry.getCount(); - } - assert numOfSamples <= Integer.MAX_VALUE; - long[] decodingTime = new long[(int) numOfSamples]; - - int current = 0; - - - for (TimeToSampleBox.Entry entry : entries) { - for (int i = 0; i < entry.getCount(); i++) { - decodingTime[current++] = entry.getDelta(); - } - } - - return decodingTime; - } - - -} diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/TitleBox.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/TitleBox.java deleted file mode 100644 index 46ee5eee9..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/TitleBox.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright 2008 CoreMedia AG, Hamburg - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coremedia.iso.boxes; - -import com.coremedia.iso.IsoTypeReader; -import com.coremedia.iso.IsoTypeWriter; -import com.coremedia.iso.Utf8; -import com.googlecode.mp4parser.AbstractFullBox; - -import java.nio.ByteBuffer; - -/** - * - * Box Type: 'titl'
    - * Container: {@link UserDataBox} ('udta')
    - * Mandatory: No
    - * Quantity: Zero or one

    - *
    - *

    - * Title for the media. - */ -public class TitleBox extends AbstractFullBox { - public static final String TYPE = "titl"; - - private String language; - private String title; - - public TitleBox() { - super(TYPE); - } - - public String getLanguage() { - return language; - } - - public String getTitle() { - return title; - } - - /** - * Sets the 3-letter ISO-639 language for this title. - * - * @param language 3-letter ISO-639 code - */ - public void setLanguage(String language) { - this.language = language; - } - - public void setTitle(String title) { - this.title = title; - } - - protected long getContentSize() { - return 7 + Utf8.utf8StringLengthInBytes(title); - } - - - protected void getContent(ByteBuffer byteBuffer) { - writeVersionAndFlags(byteBuffer); - IsoTypeWriter.writeIso639(byteBuffer, language); - byteBuffer.put(Utf8.convert(title)); - byteBuffer.put((byte) 0); - } - - @Override - public void _parseDetails(ByteBuffer content) { - parseVersionAndFlags(content); - language = IsoTypeReader.readIso639(content); - title = IsoTypeReader.readString(content); - } - - public String toString() { - return "TitleBox[language=" + getLanguage() + ";title=" + getTitle() + "]"; - } -} diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/TrackBox.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/TrackBox.java deleted file mode 100644 index c2806b5f1..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/TrackBox.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright 2008 CoreMedia AG, Hamburg - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coremedia.iso.boxes; - -import com.googlecode.mp4parser.AbstractContainerBox; - -/** - * Tracks are used for two purposes: (a) to contain media data (media tracks) and (b) to contain packetization - * information for streaming protocols (hint tracks).
    - * There shall be at least one media track within an ISO file, and all the media tracks that contributed to the hint - * tracks shall remain in the file, even if the media data within them is not referenced by the hint tracks; after - * deleting all hint tracks, the entire un-hinted presentation shall remain. - */ -public class TrackBox extends AbstractContainerBox { - public static final String TYPE = "trak"; - - public TrackBox() { - super(TYPE); - } - - public TrackHeaderBox getTrackHeaderBox() { - for (Box box : boxes) { - if (box instanceof TrackHeaderBox) { - return (TrackHeaderBox) box; - } - } - return null; - } - - /** - * Gets the SampleTableBox at mdia/minf/stbl if existing. - * - * @return the SampleTableBox or null - */ - public SampleTableBox getSampleTableBox() { - MediaBox mdia = getMediaBox(); - if (mdia != null) { - MediaInformationBox minf = mdia.getMediaInformationBox(); - if (minf != null) { - return minf.getSampleTableBox(); - } - } - return null; - - } - - - public MediaBox getMediaBox() { - for (Box box : boxes) { - if (box instanceof MediaBox) { - return (MediaBox) box; - } - } - return null; - } - -} diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/TrackHeaderBox.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/TrackHeaderBox.java deleted file mode 100644 index 8816bb9af..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/TrackHeaderBox.java +++ /dev/null @@ -1,249 +0,0 @@ -/* - * Copyright 2008 CoreMedia AG, Hamburg - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coremedia.iso.boxes; - - -import com.coremedia.iso.IsoTypeReader; -import com.coremedia.iso.IsoTypeWriter; -import com.googlecode.mp4parser.AbstractFullBox; - -import java.nio.ByteBuffer; - -/** - * This box specifies the characteristics of a single track. Exactly one Track Header Box is contained in a track.
    - * In the absence of an edit list, the presentation of a track starts at the beginning of the overall presentation. An - * empty edit is used to offset the start time of a track.
    - * The default value of the track header flags for media tracks is 7 (track_enabled, track_in_movie, - * track_in_preview). If in a presentation all tracks have neither track_in_movie nor track_in_preview set, then all - * tracks shall be treated as if both flags were set on all tracks. Hint tracks should have the track header flags set - * to 0, so that they are ignored for local playback and preview. - */ -public class TrackHeaderBox extends AbstractFullBox { - - public static final String TYPE = "tkhd"; - - private long creationTime; - private long modificationTime; - private long trackId; - private long duration; - private int layer; - private int alternateGroup; - private float volume; - private long[] matrix = new long[]{0x00010000, 0, 0, 0, 0x00010000, 0, 0, 0, 0x40000000}; - private double width; - private double height; - - - public TrackHeaderBox() { - super(TYPE); - - } - - public long getCreationTime() { - return creationTime; - } - - public long getModificationTime() { - return modificationTime; - } - - public long getTrackId() { - return trackId; - } - - public long getDuration() { - return duration; - } - - public int getLayer() { - return layer; - } - - public int getAlternateGroup() { - return alternateGroup; - } - - public float getVolume() { - return volume; - } - - public long[] getMatrix() { - return matrix; - } - - public double getWidth() { - return width; - } - - public double getHeight() { - return height; - } - - protected long getContentSize() { - long contentSize = 4; - if (getVersion() == 1) { - contentSize += 32; - } else { - contentSize += 20; - } - contentSize += 60; - return contentSize; - } - - @Override - public void _parseDetails(ByteBuffer content) { - parseVersionAndFlags(content); - if (getVersion() == 1) { - creationTime = IsoTypeReader.readUInt64(content); - modificationTime = IsoTypeReader.readUInt64(content); - trackId = IsoTypeReader.readUInt32(content); - IsoTypeReader.readUInt32(content); - duration = IsoTypeReader.readUInt64(content); - } else { - creationTime = IsoTypeReader.readUInt32(content); - modificationTime = IsoTypeReader.readUInt32(content); - trackId = IsoTypeReader.readUInt32(content); - IsoTypeReader.readUInt32(content); - duration = IsoTypeReader.readUInt32(content); - } // 196 - IsoTypeReader.readUInt32(content); - IsoTypeReader.readUInt32(content); - layer = IsoTypeReader.readUInt16(content); // 204 - alternateGroup = IsoTypeReader.readUInt16(content); - volume = IsoTypeReader.readFixedPoint88(content); - IsoTypeReader.readUInt16(content); // 212 - matrix = new long[9]; - for (int i = 0; i < 9; i++) { - matrix[i] = IsoTypeReader.readUInt32(content); - } - width = IsoTypeReader.readFixedPoint1616(content); // 248 - height = IsoTypeReader.readFixedPoint1616(content); - } - - public void getContent(ByteBuffer byteBuffer) { - writeVersionAndFlags(byteBuffer); - if (getVersion() == 1) { - IsoTypeWriter.writeUInt64(byteBuffer, creationTime); - IsoTypeWriter.writeUInt64(byteBuffer, modificationTime); - IsoTypeWriter.writeUInt32(byteBuffer, trackId); - IsoTypeWriter.writeUInt32(byteBuffer, 0); - IsoTypeWriter.writeUInt64(byteBuffer, duration); - } else { - IsoTypeWriter.writeUInt32(byteBuffer, creationTime); - IsoTypeWriter.writeUInt32(byteBuffer, modificationTime); - IsoTypeWriter.writeUInt32(byteBuffer, trackId); - IsoTypeWriter.writeUInt32(byteBuffer, 0); - IsoTypeWriter.writeUInt32(byteBuffer, duration); - } // 196 - IsoTypeWriter.writeUInt32(byteBuffer, 0); - IsoTypeWriter.writeUInt32(byteBuffer, 0); - IsoTypeWriter.writeUInt16(byteBuffer, layer); - IsoTypeWriter.writeUInt16(byteBuffer, alternateGroup); - IsoTypeWriter.writeFixedPont88(byteBuffer, volume); - IsoTypeWriter.writeUInt16(byteBuffer, 0); - for (int i = 0; i < 9; i++) { - IsoTypeWriter.writeUInt32(byteBuffer, matrix[i]); - } - IsoTypeWriter.writeFixedPont1616(byteBuffer, width); - IsoTypeWriter.writeFixedPont1616(byteBuffer, height); - } - - public String toString() { - StringBuilder result = new StringBuilder(); - result.append("TrackHeaderBox["); - result.append("creationTime=").append(getCreationTime()); - result.append(";"); - result.append("modificationTime=").append(getModificationTime()); - result.append(";"); - result.append("trackId=").append(getTrackId()); - result.append(";"); - result.append("duration=").append(getDuration()); - result.append(";"); - result.append("layer=").append(getLayer()); - result.append(";"); - result.append("alternateGroup=").append(getAlternateGroup()); - result.append(";"); - result.append("volume=").append(getVolume()); - for (int i = 0; i < matrix.length; i++) { - result.append(";"); - result.append("matrix").append(i).append("=").append(matrix[i]); - } - result.append(";"); - result.append("width=").append(getWidth()); - result.append(";"); - result.append("height=").append(getHeight()); - result.append("]"); - return result.toString(); - } - - public void setCreationTime(long creationTime) { - this.creationTime = creationTime; - } - - public void setModificationTime(long modificationTime) { - this.modificationTime = modificationTime; - } - - public void setTrackId(long trackId) { - this.trackId = trackId; - } - - public void setDuration(long duration) { - this.duration = duration; - } - - public void setLayer(int layer) { - this.layer = layer; - } - - public void setAlternateGroup(int alternateGroup) { - this.alternateGroup = alternateGroup; - } - - public void setVolume(float volume) { - this.volume = volume; - } - - public void setMatrix(long[] matrix) { - this.matrix = matrix; - } - - public void setWidth(double width) { - this.width = width; - } - - public void setHeight(double height) { - this.height = height; - } - - - public boolean isEnabled() { - return (getFlags() & 1) > 0; - } - - public boolean isInMovie() { - return (getFlags() & 2) > 0; - } - - public boolean isInPreview() { - return (getFlags() & 4) > 0; - } - - public boolean isInPoster() { - return (getFlags() & 8) > 0; - } -} diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/TrackReferenceBox.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/TrackReferenceBox.java deleted file mode 100644 index 1b4a7fb33..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/TrackReferenceBox.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright 2008 CoreMedia AG, Hamburg - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coremedia.iso.boxes; - -import com.googlecode.mp4parser.AbstractContainerBox; - -/** - * - * Box Type: 'tref'
    - * Container: {@link TrackBox} ('trak')
    - * Mandatory: No
    - * Quantity: Zero or one

    - *
    - * This box provides a reference from the containing track to another track in the presentation. These references - * are typed. A 'hint' reference links from the containing hint track to the media data that it hints. A content - * description reference 'cdsc' links a descriptive or metadata track to the content which it describes. - * Exactly one Track Reference Box can be contained within the Track Box. - * If this box is not present, the track is not referencing any other track in any way. The reference array is sized - * to fill the reference type box. - */ -public class TrackReferenceBox extends AbstractContainerBox { - public static final String TYPE = "tref"; - - public TrackReferenceBox() { - super(TYPE); - } -} diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/TrackReferenceTypeBox.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/TrackReferenceTypeBox.java deleted file mode 100644 index 297932da6..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/TrackReferenceTypeBox.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright 2008 CoreMedia AG, Hamburg - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coremedia.iso.boxes; - -import com.coremedia.iso.IsoTypeReader; -import com.coremedia.iso.IsoTypeWriter; -import com.googlecode.mp4parser.AbstractBox; - -import java.nio.ByteBuffer; - -/** - * Contains a reference to a track. The type of the box gives the kind of reference. - */ -public class TrackReferenceTypeBox extends AbstractBox { - - public static final String TYPE1 = "hint"; - public static final String TYPE2 = "cdsc"; - - private long[] trackIds; - - public TrackReferenceTypeBox(String type) { - super(type); - } - - public long[] getTrackIds() { - return trackIds; - } - - @Override - public void _parseDetails(ByteBuffer content) { - int count = (int) (content.remaining() / 4); - trackIds = new long[count]; - for (int i = 0; i < count; i++) { - trackIds[i] = IsoTypeReader.readUInt32(content); - } - } - - @Override - protected void getContent(ByteBuffer byteBuffer) { - for (long trackId : trackIds) { - IsoTypeWriter.writeUInt32(byteBuffer, trackId); - } - } - - - protected long getContentSize() { - return trackIds.length * 4; - } - - public String toString() { - StringBuilder buffer = new StringBuilder(); - buffer.append("TrackReferenceTypeBox[type=").append(getType()); - for (int i = 0; i < trackIds.length; i++) { - buffer.append(";trackId"); - buffer.append(i); - buffer.append("="); - buffer.append(trackIds[i]); - } - buffer.append("]"); - return buffer.toString(); - } -} diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/UnknownBox.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/UnknownBox.java deleted file mode 100644 index f76481cfe..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/UnknownBox.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright 2008 CoreMedia AG, Hamburg - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coremedia.iso.boxes; - - -import com.googlecode.mp4parser.AbstractBox; - -import java.nio.ByteBuffer; - -/** - * A box unknown to the ISO Parser. If there is no specific Box implementation for a Box this UnknownBox - * will just hold the box's data. - */ -public class UnknownBox extends AbstractBox { - ByteBuffer data; - - public UnknownBox(String type) { - super(type); - } - - @Override - protected long getContentSize() { - return data.limit(); - } - - @Override - public void _parseDetails(ByteBuffer content) { - data = content; - content.position(content.position() + content.remaining()); - } - - @Override - protected void getContent(ByteBuffer byteBuffer) { - data.rewind(); - byteBuffer.put(data); - } - - public ByteBuffer getData() { - return data; - } - - public void setData(ByteBuffer data) { - this.data = data; - } -} diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/UserBox.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/UserBox.java deleted file mode 100644 index db0e741b4..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/UserBox.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright 2008 CoreMedia AG, Hamburg - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coremedia.iso.boxes; - -import com.googlecode.mp4parser.AbstractBox; - -import java.nio.ByteBuffer; - -/** - * A user specifc box. See ISO/IEC 14496-12 for details. - */ -public class UserBox extends AbstractBox { - byte[] data; - public static final String TYPE = "uuid"; - - public UserBox(byte[] userType) { - super(TYPE, userType); - } - - - protected long getContentSize() { - return data.length; - } - - public String toString() { - return "UserBox[type=" + (getType()) + - ";userType=" + new String(getUserType()) + - ";contentLength=" + data.length + "]"; - } - - - public byte[] getData() { - return data; - } - - public void setData(byte[] data) { - this.data = data; - } - - @Override - public void _parseDetails(ByteBuffer content) { - data = new byte[content.remaining()]; - content.get(data); - } - - @Override - protected void getContent(ByteBuffer byteBuffer) { - byteBuffer.put(data); - } -} diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/UserDataBox.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/UserDataBox.java deleted file mode 100644 index 65c580823..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/UserDataBox.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright 2008 CoreMedia AG, Hamburg - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coremedia.iso.boxes; - -import com.coremedia.iso.BoxParser; -import com.googlecode.mp4parser.AbstractContainerBox; - -import java.io.IOException; -import java.nio.ByteBuffer; -import java.nio.channels.ReadableByteChannel; - -/** - * This box contains objects that declare user information about the containing box and its data (presentation or - * track).
    - * The User Data Box is a container box for informative user-data. This user data is formatted as a set of boxes - * with more specific box types, which declare more precisely their content - */ -public class UserDataBox extends AbstractContainerBox { - public static final String TYPE = "udta"; - - @Override - protected long getContentSize() { - return super.getContentSize(); //To change body of overridden methods use File | Settings | File Templates. - } - - @Override - public void parse(ReadableByteChannel readableByteChannel, ByteBuffer header, long contentSize, BoxParser boxParser) throws IOException { - super.parse(readableByteChannel, header, contentSize, boxParser); //To change body of overridden methods use File | Settings | File Templates. - } - - @Override - public void _parseDetails(ByteBuffer content) { - super._parseDetails(content); //To change body of overridden methods use File | Settings | File Templates. - } - - @Override - protected void getContent(ByteBuffer byteBuffer) { - super.getContent(byteBuffer); //To change body of overridden methods use File | Settings | File Templates. - } - - public UserDataBox() { - super(TYPE); - } - -} diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/VideoMediaHeaderBox.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/VideoMediaHeaderBox.java deleted file mode 100644 index 421a67d9e..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/VideoMediaHeaderBox.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright 2008 CoreMedia AG, Hamburg - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coremedia.iso.boxes; - -import com.coremedia.iso.IsoTypeReader; -import com.coremedia.iso.IsoTypeWriter; - -import java.nio.ByteBuffer; - -/** - * The video media header contains general presentation information, independent of the coding, for video - * media. Note that the flags field has the value 1. - */ -public class VideoMediaHeaderBox extends AbstractMediaHeaderBox { - private int graphicsmode = 0; - private int[] opcolor = new int[]{0, 0, 0}; - public static final String TYPE = "vmhd"; - - public VideoMediaHeaderBox() { - super(TYPE); - setFlags(1); // 1 is default. - } - - public int getGraphicsmode() { - return graphicsmode; - } - - public int[] getOpcolor() { - return opcolor; - } - - protected long getContentSize() { - return 12; - } - - - @Override - public void _parseDetails(ByteBuffer content) { - parseVersionAndFlags(content); - graphicsmode = IsoTypeReader.readUInt16(content); - opcolor = new int[3]; - for (int i = 0; i < 3; i++) { - opcolor[i] = IsoTypeReader.readUInt16(content); - } - } - - @Override - protected void getContent(ByteBuffer byteBuffer) { - writeVersionAndFlags(byteBuffer); - IsoTypeWriter.writeUInt16(byteBuffer, graphicsmode); - for (int anOpcolor : opcolor) { - IsoTypeWriter.writeUInt16(byteBuffer, anOpcolor); - } - } - - public String toString() { - return "VideoMediaHeaderBox[graphicsmode=" + getGraphicsmode() + ";opcolor0=" + getOpcolor()[0] + ";opcolor1=" + getOpcolor()[1] + ";opcolor2=" + getOpcolor()[2] + "]"; - } - - public void setOpcolor(int[] opcolor) { - this.opcolor = opcolor; - } - - public void setGraphicsmode(int graphicsmode) { - this.graphicsmode = graphicsmode; - } -} diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/WriteListener.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/WriteListener.java deleted file mode 100644 index dc22d52bc..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/WriteListener.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.coremedia.iso.boxes; - -/** - * The WriteListener is used to get the offset of - * a box before writing the box. This can be used if a box written - * later needs an offset. - */ -public interface WriteListener { - public void beforeWrite(long offset); -} diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/XmlBox.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/XmlBox.java deleted file mode 100644 index 696a0645e..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/XmlBox.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.coremedia.iso.boxes; - -import com.coremedia.iso.IsoTypeReader; -import com.coremedia.iso.Utf8; -import com.googlecode.mp4parser.AbstractFullBox; - -import java.nio.ByteBuffer; - -/** - * - */ -public class XmlBox extends AbstractFullBox { - String xml = ""; - public static final String TYPE = "xml "; - - public XmlBox() { - super(TYPE); - } - - public String getXml() { - return xml; - } - - public void setXml(String xml) { - this.xml = xml; - } - - @Override - protected long getContentSize() { - return 4 + Utf8.utf8StringLengthInBytes(xml); - } - - @Override - public void _parseDetails(ByteBuffer content) { - parseVersionAndFlags(content); - xml = IsoTypeReader.readString(content, content.remaining()); - } - - @Override - protected void getContent(ByteBuffer byteBuffer) { - writeVersionAndFlags(byteBuffer); - byteBuffer.put(Utf8.convert(xml)); - } -} diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/apple/AbstractAppleMetaDataBox.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/apple/AbstractAppleMetaDataBox.java deleted file mode 100644 index fdb7ac9a9..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/apple/AbstractAppleMetaDataBox.java +++ /dev/null @@ -1,164 +0,0 @@ -package com.coremedia.iso.boxes.apple; - -import com.coremedia.iso.IsoTypeReader; -import com.coremedia.iso.IsoTypeWriter; -import com.coremedia.iso.Utf8; -import com.googlecode.mp4parser.AbstractBox; -import com.coremedia.iso.boxes.Box; -import com.coremedia.iso.boxes.ContainerBox; -import com.googlecode.mp4parser.util.ByteBufferByteChannel; - -import java.io.IOException; -import java.math.BigInteger; -import java.nio.ByteBuffer; -import java.util.Collections; -import java.util.List; -import java.util.logging.Logger; - -/** - * - */ -public abstract class AbstractAppleMetaDataBox extends AbstractBox implements ContainerBox { - private static Logger LOG = Logger.getLogger(AbstractAppleMetaDataBox.class.getName()); - AppleDataBox appleDataBox = new AppleDataBox(); - - public List getBoxes() { - return Collections.singletonList((Box) appleDataBox); - } - - public void setBoxes(List boxes) { - if (boxes.size() == 1 && boxes.get(0) instanceof AppleDataBox) { - appleDataBox = (AppleDataBox) boxes.get(0); - } else { - throw new IllegalArgumentException("This box only accepts one AppleDataBox child"); - } - } - - public List getBoxes(Class clazz) { - return getBoxes(clazz, false); - } - - public List getBoxes(Class clazz, boolean recursive) { - //todo recursive? - if (clazz.isAssignableFrom(appleDataBox.getClass())) { - return (List) Collections.singletonList(appleDataBox); - } - return null; - } - - public AbstractAppleMetaDataBox(String type) { - super(type); - } - - @Override - public void _parseDetails(ByteBuffer content) { - long dataBoxSize = IsoTypeReader.readUInt32(content); - String thisShouldBeData = IsoTypeReader.read4cc(content); - assert "data".equals(thisShouldBeData); - appleDataBox = new AppleDataBox(); - try { - appleDataBox.parse(new ByteBufferByteChannel(content), null, content.remaining(), null); - } catch (IOException e) { - throw new RuntimeException(e); - } - appleDataBox.setParent(this); - } - - - protected long getContentSize() { - return appleDataBox.getSize(); - } - - protected void getContent(ByteBuffer byteBuffer) { - try { - appleDataBox.getBox(new ByteBufferByteChannel(byteBuffer)); - } catch (IOException e) { - throw new RuntimeException("The Channel is based on a ByteBuffer and therefore it shouldn't throw any exception"); - } - } - - public long getNumOfBytesToFirstChild() { - return getSize() - appleDataBox.getSize(); - } - - @Override - public String toString() { - return this.getClass().getSimpleName() + "{" + - "appleDataBox=" + getValue() + - '}'; - } - - static long toLong(byte b) { - return b < 0 ? b + 256 : b; - } - - public void setValue(String value) { - if (appleDataBox.getFlags() == 1) { - appleDataBox = new AppleDataBox(); - appleDataBox.setVersion(0); - appleDataBox.setFlags(1); - appleDataBox.setFourBytes(new byte[4]); - appleDataBox.setData(Utf8.convert(value)); - } else if (appleDataBox.getFlags() == 21) { - byte[] content = appleDataBox.getData(); - appleDataBox = new AppleDataBox(); - appleDataBox.setVersion(0); - appleDataBox.setFlags(21); - appleDataBox.setFourBytes(new byte[4]); - - ByteBuffer bb = ByteBuffer.allocate(content.length); - if (content.length == 1) { - IsoTypeWriter.writeUInt8(bb, (Byte.parseByte(value) & 0xFF)); - } else if (content.length == 2) { - IsoTypeWriter.writeUInt16(bb, Integer.parseInt(value)); - } else if (content.length == 4) { - IsoTypeWriter.writeUInt32(bb, Long.parseLong(value)); - } else if (content.length == 8) { - IsoTypeWriter.writeUInt64(bb, Long.parseLong(value)); - } else { - throw new Error("The content length within the appleDataBox is neither 1, 2, 4 or 8. I can't handle that!"); - } - appleDataBox.setData(bb.array()); - } else if (appleDataBox.getFlags() == 0) { - appleDataBox = new AppleDataBox(); - appleDataBox.setVersion(0); - appleDataBox.setFlags(0); - appleDataBox.setFourBytes(new byte[4]); - appleDataBox.setData(hexStringToByteArray(value)); - - } else { - LOG.warning("Don't know how to handle appleDataBox with flag=" + appleDataBox.getFlags()); - } - } - - public String getValue() { - if (appleDataBox.getFlags() == 1) { - return Utf8.convert(appleDataBox.getData()); - } else if (appleDataBox.getFlags() == 21) { - byte[] content = appleDataBox.getData(); - long l = 0; - int current = 1; - int length = content.length; - for (byte b : content) { - l += toLong(b) << (8 * (length - current++)); - } - return "" + l; - } else if (appleDataBox.getFlags() == 0) { - return String.format("%x", new BigInteger(appleDataBox.getData())); - } else { - return "unknown"; - } - } - - public static byte[] hexStringToByteArray(String s) { - int len = s.length(); - byte[] data = new byte[len / 2]; - for (int i = 0; i < len; i += 2) { - data[i / 2] = (byte) ((Character.digit(s.charAt(i), 16) << 4) - + Character.digit(s.charAt(i + 1), 16)); - } - return data; - } - - -} diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/apple/AppleAlbumArtistBox.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/apple/AppleAlbumArtistBox.java deleted file mode 100755 index 5c258b459..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/apple/AppleAlbumArtistBox.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.coremedia.iso.boxes.apple; - -/** - * itunes MetaData comment box. - */ -public class AppleAlbumArtistBox extends AbstractAppleMetaDataBox { - public static final String TYPE = "aART"; - - - public AppleAlbumArtistBox() { - super(TYPE); - appleDataBox = AppleDataBox.getStringAppleDataBox(); - } - - -} \ No newline at end of file diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/apple/AppleAlbumBox.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/apple/AppleAlbumBox.java deleted file mode 100644 index 9e3d5f7ee..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/apple/AppleAlbumBox.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.coremedia.iso.boxes.apple; - -/** - * - */ -public final class AppleAlbumBox extends AbstractAppleMetaDataBox { - public static final String TYPE = "\u00a9alb"; - - - public AppleAlbumBox() { - super(TYPE); - appleDataBox = AppleDataBox.getStringAppleDataBox(); - } - -} \ No newline at end of file diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/apple/AppleArtistBox.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/apple/AppleArtistBox.java deleted file mode 100644 index 6dbc6d532..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/apple/AppleArtistBox.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.coremedia.iso.boxes.apple; - -/** - * iTunes Artist box. - */ -public final class AppleArtistBox extends AbstractAppleMetaDataBox { - public static final String TYPE = "\u00a9ART"; - - - public AppleArtistBox() { - super(TYPE); - appleDataBox = AppleDataBox.getStringAppleDataBox(); - } - - -} diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/apple/AppleCommentBox.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/apple/AppleCommentBox.java deleted file mode 100755 index b58899fc1..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/apple/AppleCommentBox.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.coremedia.iso.boxes.apple; - -/** - * itunes MetaData comment box. - */ -public final class AppleCommentBox extends AbstractAppleMetaDataBox { - public static final String TYPE = "\u00a9cmt"; - - - public AppleCommentBox() { - super(TYPE); - appleDataBox = AppleDataBox.getStringAppleDataBox(); - } - - -} diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/apple/AppleCompilationBox.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/apple/AppleCompilationBox.java deleted file mode 100644 index 944306f8c..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/apple/AppleCompilationBox.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.coremedia.iso.boxes.apple; - -/** - * Compilation. - */ -public final class AppleCompilationBox extends AbstractAppleMetaDataBox { - public static final String TYPE = "cpil"; - - - public AppleCompilationBox() { - super(TYPE); - appleDataBox = AppleDataBox.getUint8AppleDataBox(); - } - -} \ No newline at end of file diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/apple/AppleCopyrightBox.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/apple/AppleCopyrightBox.java deleted file mode 100755 index ae4428534..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/apple/AppleCopyrightBox.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.coremedia.iso.boxes.apple; - -/** - * itunes MetaData comment box. - */ -public final class AppleCopyrightBox extends AbstractAppleMetaDataBox { - public static final String TYPE = "cprt"; - - - public AppleCopyrightBox() { - super(TYPE); - appleDataBox = AppleDataBox.getStringAppleDataBox(); - } - -} \ No newline at end of file diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/apple/AppleCoverBox.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/apple/AppleCoverBox.java deleted file mode 100644 index 946dd4984..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/apple/AppleCoverBox.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.coremedia.iso.boxes.apple; - -import java.util.logging.Logger; - -/** - * - */ -public final class AppleCoverBox extends AbstractAppleMetaDataBox { - private static Logger LOG = Logger.getLogger(AppleCoverBox.class.getName()); - public static final String TYPE = "covr"; - - - public AppleCoverBox() { - super(TYPE); - } - - - public void setPng(byte[] pngData) { - appleDataBox = new AppleDataBox(); - appleDataBox.setVersion(0); - appleDataBox.setFlags(0xe); - appleDataBox.setFourBytes(new byte[4]); - appleDataBox.setData(pngData); - } - - - public void setJpg(byte[] jpgData) { - appleDataBox = new AppleDataBox(); - appleDataBox.setVersion(0); - appleDataBox.setFlags(0xd); - appleDataBox.setFourBytes(new byte[4]); - appleDataBox.setData(jpgData); - } - - @Override - public void setValue(String value) { - LOG.warning("---"); - } - - @Override - public String getValue() { - return "---"; - } -} \ No newline at end of file diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/apple/AppleCustomGenreBox.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/apple/AppleCustomGenreBox.java deleted file mode 100644 index 0c67f97a1..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/apple/AppleCustomGenreBox.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.coremedia.iso.boxes.apple; - -import com.coremedia.iso.Utf8; - -/** - * - */ -public final class AppleCustomGenreBox extends AbstractAppleMetaDataBox { - public static final String TYPE = "\u00a9gen"; - - - public AppleCustomGenreBox() { - super(TYPE); - appleDataBox = AppleDataBox.getStringAppleDataBox(); - } - - public void setGenre(String genre) { - appleDataBox = new AppleDataBox(); - appleDataBox.setVersion(0); - appleDataBox.setFlags(1); - appleDataBox.setFourBytes(new byte[4]); - appleDataBox.setData(Utf8.convert(genre)); - } - - public String getGenre() { - return Utf8.convert(appleDataBox.getData()); - } -} \ No newline at end of file diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/apple/AppleDataBox.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/apple/AppleDataBox.java deleted file mode 100644 index ba4262963..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/apple/AppleDataBox.java +++ /dev/null @@ -1,92 +0,0 @@ -package com.coremedia.iso.boxes.apple; - -import com.googlecode.mp4parser.AbstractFullBox; - -import java.nio.ByteBuffer; - -/** - * Most stupid box of the world. Encapsulates actual data within - */ -public final class AppleDataBox extends AbstractFullBox { - public static final String TYPE = "data"; - - private byte[] fourBytes = new byte[4]; - private byte[] data; - - private static AppleDataBox getEmpty() { - AppleDataBox appleDataBox = new AppleDataBox(); - appleDataBox.setVersion(0); - appleDataBox.setFourBytes(new byte[4]); - return appleDataBox; - } - - public static AppleDataBox getStringAppleDataBox() { - AppleDataBox appleDataBox = getEmpty(); - appleDataBox.setFlags(1); - appleDataBox.setData(new byte[]{0}); - return appleDataBox; - } - - public static AppleDataBox getUint8AppleDataBox() { - AppleDataBox appleDataBox = new AppleDataBox(); - appleDataBox.setFlags(21); - appleDataBox.setData(new byte[]{0}); - return appleDataBox; - } - - public static AppleDataBox getUint16AppleDataBox() { - AppleDataBox appleDataBox = new AppleDataBox(); - appleDataBox.setFlags(21); - appleDataBox.setData(new byte[]{0, 0}); - return appleDataBox; - } - - public static AppleDataBox getUint32AppleDataBox() { - AppleDataBox appleDataBox = new AppleDataBox(); - appleDataBox.setFlags(21); - appleDataBox.setData(new byte[]{0, 0, 0, 0}); - return appleDataBox; - } - - public AppleDataBox() { - super(TYPE); - } - - protected long getContentSize() { - return data.length + 8; - } - - public void setData(byte[] data) { - this.data = new byte[data.length]; - System.arraycopy(data, 0, this.data, 0, data.length); - } - - public void setFourBytes(byte[] fourBytes) { - System.arraycopy(fourBytes, 0, this.fourBytes, 0, 4); - } - - @Override - public void _parseDetails(ByteBuffer content) { - parseVersionAndFlags(content); - fourBytes = new byte[4]; - content.get(fourBytes); - data = new byte[content.remaining()]; - content.get(data); - } - - - @Override - protected void getContent(ByteBuffer byteBuffer) { - writeVersionAndFlags(byteBuffer); - byteBuffer.put(fourBytes, 0, 4); - byteBuffer.put(data); - } - - public byte[] getFourBytes() { - return fourBytes; - } - - public byte[] getData() { - return data; - } -} diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/apple/AppleDataRateBox.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/apple/AppleDataRateBox.java deleted file mode 100644 index a0d4bc12f..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/apple/AppleDataRateBox.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright 2009 castLabs GmbH, Berlin - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coremedia.iso.boxes.apple; - -import com.coremedia.iso.IsoTypeReader; -import com.coremedia.iso.IsoTypeWriter; -import com.googlecode.mp4parser.AbstractFullBox; - -import java.nio.ByteBuffer; - -public class AppleDataRateBox extends AbstractFullBox { - public static final String TYPE = "rmdr"; - private long dataRate; - - public AppleDataRateBox() { - super(TYPE); - } - - protected long getContentSize() { - return 8; - } - - @Override - public void _parseDetails(ByteBuffer content) { - parseVersionAndFlags(content); - dataRate = IsoTypeReader.readUInt32(content); - } - - @Override - protected void getContent(ByteBuffer byteBuffer) { - writeVersionAndFlags(byteBuffer); - IsoTypeWriter.writeUInt32(byteBuffer, dataRate); - } - - - public long getDataRate() { - return dataRate; - } -} diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/apple/AppleDataReferenceBox.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/apple/AppleDataReferenceBox.java deleted file mode 100644 index f38841a98..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/apple/AppleDataReferenceBox.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright 2009 castLabs GmbH, Berlin - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coremedia.iso.boxes.apple; - -import com.coremedia.iso.IsoFile; -import com.coremedia.iso.IsoTypeReader; -import com.coremedia.iso.IsoTypeWriter; -import com.coremedia.iso.Utf8; -import com.googlecode.mp4parser.AbstractFullBox; - -import java.nio.ByteBuffer; - -import static com.googlecode.mp4parser.util.CastUtils.l2i; - -public class AppleDataReferenceBox extends AbstractFullBox { - public static final String TYPE = "rdrf"; - private int dataReferenceSize; - private String dataReferenceType; - private String dataReference; - - public AppleDataReferenceBox() { - super(TYPE); - } - - - protected long getContentSize() { - return 12 + dataReferenceSize; - } - - @Override - public void _parseDetails(ByteBuffer content) { - parseVersionAndFlags(content); - dataReferenceType = IsoTypeReader.read4cc(content); - dataReferenceSize = l2i(IsoTypeReader.readUInt32(content)); - dataReference = IsoTypeReader.readString(content, dataReferenceSize); - } - - @Override - protected void getContent(ByteBuffer byteBuffer) { - writeVersionAndFlags(byteBuffer); - byteBuffer.put(IsoFile.fourCCtoBytes(dataReferenceType)); - IsoTypeWriter.writeUInt32(byteBuffer, dataReferenceSize); - byteBuffer.put(Utf8.convert(dataReference)); - } - - public long getDataReferenceSize() { - return dataReferenceSize; - } - - public String getDataReferenceType() { - return dataReferenceType; - } - - public String getDataReference() { - return dataReference; - } -} diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/apple/AppleDescriptionBox.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/apple/AppleDescriptionBox.java deleted file mode 100644 index e20e0fcef..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/apple/AppleDescriptionBox.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.coremedia.iso.boxes.apple; - -/** - * - */ -public final class AppleDescriptionBox extends AbstractAppleMetaDataBox { - public static final String TYPE = "desc"; - - - public AppleDescriptionBox() { - super(TYPE); - appleDataBox = AppleDataBox.getStringAppleDataBox(); - } - -} \ No newline at end of file diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/apple/AppleEncoderBox.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/apple/AppleEncoderBox.java deleted file mode 100755 index 5a59e8157..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/apple/AppleEncoderBox.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.coremedia.iso.boxes.apple; - -/** - * itunes MetaData comment box. - */ -public final class AppleEncoderBox extends AbstractAppleMetaDataBox { - public static final String TYPE = "\u00a9too"; - - - public AppleEncoderBox() { - super(TYPE); - appleDataBox = AppleDataBox.getStringAppleDataBox(); - } - -} \ No newline at end of file diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/apple/AppleGaplessPlaybackBox.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/apple/AppleGaplessPlaybackBox.java deleted file mode 100644 index c88babe9e..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/apple/AppleGaplessPlaybackBox.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.coremedia.iso.boxes.apple; - -/** - * Gapless Playback. - */ -public final class AppleGaplessPlaybackBox extends AbstractAppleMetaDataBox { - public static final String TYPE = "pgap"; - - - public AppleGaplessPlaybackBox() { - super(TYPE); - appleDataBox = AppleDataBox.getUint8AppleDataBox(); - } - -} diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/apple/AppleGenericBox.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/apple/AppleGenericBox.java deleted file mode 100644 index 177a25b16..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/apple/AppleGenericBox.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.coremedia.iso.boxes.apple; - -import com.googlecode.mp4parser.AbstractContainerBox; - -/** - * - */ -public final class AppleGenericBox extends AbstractContainerBox { - public static final String TYPE = "----"; - - public AppleGenericBox() { - super(TYPE); - } - -} \ No newline at end of file diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/apple/AppleGroupingBox.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/apple/AppleGroupingBox.java deleted file mode 100755 index 988429805..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/apple/AppleGroupingBox.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.coremedia.iso.boxes.apple; - -/** - * itunes MetaData comment box. - */ -public final class AppleGroupingBox extends AbstractAppleMetaDataBox { - public static final String TYPE = "\u00a9grp"; - - - public AppleGroupingBox() { - super(TYPE); - appleDataBox = AppleDataBox.getStringAppleDataBox(); - } - -} \ No newline at end of file diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/apple/AppleIdBox.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/apple/AppleIdBox.java deleted file mode 100644 index 08c697e84..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/apple/AppleIdBox.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.coremedia.iso.boxes.apple; - -/** - * - */ -public final class AppleIdBox extends AbstractAppleMetaDataBox { - public static final String TYPE = "apID"; - - - public AppleIdBox() { - super(TYPE); - appleDataBox = AppleDataBox.getStringAppleDataBox(); - } - -} \ No newline at end of file diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/apple/AppleItemListBox.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/apple/AppleItemListBox.java deleted file mode 100644 index cd26e810b..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/apple/AppleItemListBox.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.coremedia.iso.boxes.apple; - -import com.googlecode.mp4parser.AbstractContainerBox; - -/** - * undocumented iTunes MetaData Box. - */ -public class AppleItemListBox extends AbstractContainerBox { - public static final String TYPE = "ilst"; - - public AppleItemListBox() { - super(TYPE); - } - -} diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/apple/AppleLosslessSpecificBox.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/apple/AppleLosslessSpecificBox.java deleted file mode 100644 index 03319563f..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/apple/AppleLosslessSpecificBox.java +++ /dev/null @@ -1,163 +0,0 @@ -package com.coremedia.iso.boxes.apple; - -import com.coremedia.iso.IsoTypeReader; -import com.coremedia.iso.IsoTypeWriter; -import com.googlecode.mp4parser.AbstractFullBox; - -import java.nio.ByteBuffer; - -/** - * - */ -public final class AppleLosslessSpecificBox extends AbstractFullBox { - - public static final String TYPE = "alac"; - /* - Extradata: 32bit size 32bit tag (=alac) 32bit zero? - 32bit max sample per frame 8bit ?? (zero?) 8bit sample - size 8bit history mult 8bit initial history 8bit kmodifier - 8bit channels? 16bit ?? 32bit max coded frame size 32bit - bitrate? 32bit samplerate - */ - private long maxSamplePerFrame; // 32bi - private int unknown1; // 8bit - private int sampleSize; // 8bit - private int historyMult; // 8bit - private int initialHistory; // 8bit - private int kModifier; // 8bit - private int channels; // 8bit - private int unknown2; // 16bit - private long maxCodedFrameSize; // 32bit - private long bitRate; // 32bit - private long sampleRate; // 32bit - - public long getMaxSamplePerFrame() { - return maxSamplePerFrame; - } - - public void setMaxSamplePerFrame(int maxSamplePerFrame) { - this.maxSamplePerFrame = maxSamplePerFrame; - } - - public int getUnknown1() { - return unknown1; - } - - public void setUnknown1(int unknown1) { - this.unknown1 = unknown1; - } - - public int getSampleSize() { - return sampleSize; - } - - public void setSampleSize(int sampleSize) { - this.sampleSize = sampleSize; - } - - public int getHistoryMult() { - return historyMult; - } - - public void setHistoryMult(int historyMult) { - this.historyMult = historyMult; - } - - public int getInitialHistory() { - return initialHistory; - } - - public void setInitialHistory(int initialHistory) { - this.initialHistory = initialHistory; - } - - public int getKModifier() { - return kModifier; - } - - public void setKModifier(int kModifier) { - this.kModifier = kModifier; - } - - public int getChannels() { - return channels; - } - - public void setChannels(int channels) { - this.channels = channels; - } - - public int getUnknown2() { - return unknown2; - } - - public void setUnknown2(int unknown2) { - this.unknown2 = unknown2; - } - - public long getMaxCodedFrameSize() { - return maxCodedFrameSize; - } - - public void setMaxCodedFrameSize(int maxCodedFrameSize) { - this.maxCodedFrameSize = maxCodedFrameSize; - } - - public long getBitRate() { - return bitRate; - } - - public void setBitRate(int bitRate) { - this.bitRate = bitRate; - } - - public long getSampleRate() { - return sampleRate; - } - - public void setSampleRate(int sampleRate) { - this.sampleRate = sampleRate; - } - - - @Override - public void _parseDetails(ByteBuffer content) { - parseVersionAndFlags(content); - maxSamplePerFrame = IsoTypeReader.readUInt32(content); - unknown1 = IsoTypeReader.readUInt8(content); - sampleSize = IsoTypeReader.readUInt8(content); - historyMult = IsoTypeReader.readUInt8(content); - initialHistory = IsoTypeReader.readUInt8(content); - kModifier = IsoTypeReader.readUInt8(content); - channels = IsoTypeReader.readUInt8(content); - unknown2 = IsoTypeReader.readUInt16(content); - maxCodedFrameSize = IsoTypeReader.readUInt32(content); - bitRate = IsoTypeReader.readUInt32(content); - sampleRate = IsoTypeReader.readUInt32(content); - } - - @Override - protected void getContent(ByteBuffer byteBuffer) { - writeVersionAndFlags(byteBuffer); - IsoTypeWriter.writeUInt32(byteBuffer, maxSamplePerFrame); - IsoTypeWriter.writeUInt8(byteBuffer, unknown1); - IsoTypeWriter.writeUInt8(byteBuffer, sampleSize); - IsoTypeWriter.writeUInt8(byteBuffer, historyMult); - IsoTypeWriter.writeUInt8(byteBuffer, initialHistory); - IsoTypeWriter.writeUInt8(byteBuffer, kModifier); - IsoTypeWriter.writeUInt8(byteBuffer, channels); - IsoTypeWriter.writeUInt16(byteBuffer, unknown2); - IsoTypeWriter.writeUInt32(byteBuffer, maxCodedFrameSize); - IsoTypeWriter.writeUInt32(byteBuffer, bitRate); - IsoTypeWriter.writeUInt32(byteBuffer, sampleRate); - } - - public AppleLosslessSpecificBox() { - super("alac"); - } - - protected long getContentSize() { - return 28; - } - -} diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/apple/AppleMeanBox.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/apple/AppleMeanBox.java deleted file mode 100644 index c4e52fb6c..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/apple/AppleMeanBox.java +++ /dev/null @@ -1,47 +0,0 @@ -package com.coremedia.iso.boxes.apple; - -import com.coremedia.iso.IsoTypeReader; -import com.coremedia.iso.Utf8; -import com.googlecode.mp4parser.AbstractFullBox; - -import java.nio.ByteBuffer; - -/** - * Apple Meaning box. Allowed as subbox of "----" box. - * - * @see com.coremedia.iso.boxes.apple.AppleGenericBox - */ -public final class AppleMeanBox extends AbstractFullBox { - public static final String TYPE = "mean"; - private String meaning; - - public AppleMeanBox() { - super(TYPE); - } - - protected long getContentSize() { - return 4 + Utf8.utf8StringLengthInBytes(meaning); - } - - @Override - public void _parseDetails(ByteBuffer content) { - parseVersionAndFlags(content); - meaning = IsoTypeReader.readString(content, content.remaining()); - } - - @Override - protected void getContent(ByteBuffer byteBuffer) { - writeVersionAndFlags(byteBuffer); - byteBuffer.put(Utf8.convert(meaning)); - } - - public String getMeaning() { - return meaning; - } - - public void setMeaning(String meaning) { - this.meaning = meaning; - } - - -} diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/apple/AppleMediaTypeBox.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/apple/AppleMediaTypeBox.java deleted file mode 100644 index f4ca98d0b..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/apple/AppleMediaTypeBox.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.coremedia.iso.boxes.apple; - -import java.util.HashMap; -import java.util.Map; - -/** - * itunes MetaData comment box. - */ -public class AppleMediaTypeBox extends AbstractAppleMetaDataBox { - private static Map mediaTypes = new HashMap(); - - static { - mediaTypes.put("0", "Movie (is now 9)"); - mediaTypes.put("1", "Normal (Music)"); - mediaTypes.put("2", "Audiobook"); - mediaTypes.put("6", "Music Video"); - mediaTypes.put("9", "Movie"); - mediaTypes.put("10", "TV Show"); - mediaTypes.put("11", "Booklet"); - mediaTypes.put("14", "Ringtone"); - } - - public static final String TYPE = "stik"; - - - public AppleMediaTypeBox() { - super(TYPE); - appleDataBox = AppleDataBox.getUint8AppleDataBox(); - } - - public String getReadableValue() { - if (mediaTypes.containsKey(getValue())) { - return mediaTypes.get(getValue()); - } else { - return "unknown media type " + getValue(); - } - - } -} \ No newline at end of file diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/apple/AppleNameBox.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/apple/AppleNameBox.java deleted file mode 100644 index a99eeecf3..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/apple/AppleNameBox.java +++ /dev/null @@ -1,45 +0,0 @@ -package com.coremedia.iso.boxes.apple; - -import com.coremedia.iso.IsoTypeReader; -import com.coremedia.iso.Utf8; -import com.googlecode.mp4parser.AbstractFullBox; - -import java.nio.ByteBuffer; - -/** - * Apple Name box. Allowed as subbox of "----" box. - * - * @see AppleGenericBox - */ -public final class AppleNameBox extends AbstractFullBox { - public static final String TYPE = "name"; - private String name; - - public AppleNameBox() { - super(TYPE); - } - - protected long getContentSize() { - return 4 + Utf8.convert(name).length; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - @Override - public void _parseDetails(ByteBuffer content) { - parseVersionAndFlags(content); - name = IsoTypeReader.readString(content, content.remaining()); - } - - @Override - protected void getContent(ByteBuffer byteBuffer) { - writeVersionAndFlags(byteBuffer); - byteBuffer.put(Utf8.convert(name)); - } -} diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/apple/AppleNetworkBox.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/apple/AppleNetworkBox.java deleted file mode 100644 index 07691b339..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/apple/AppleNetworkBox.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.coremedia.iso.boxes.apple; - -/** - * - */ -public final class AppleNetworkBox extends AbstractAppleMetaDataBox { - public static final String TYPE = "tvnn"; - - - public AppleNetworkBox() { - super(TYPE); - appleDataBox = AppleDataBox.getStringAppleDataBox(); - } - - -} \ No newline at end of file diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/apple/ApplePurchaseDateBox.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/apple/ApplePurchaseDateBox.java deleted file mode 100644 index eb9807f46..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/apple/ApplePurchaseDateBox.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.coremedia.iso.boxes.apple; - -/** - * - */ -public final class ApplePurchaseDateBox extends AbstractAppleMetaDataBox { - public static final String TYPE = "purd"; - - - public ApplePurchaseDateBox() { - super(TYPE); - appleDataBox = AppleDataBox.getStringAppleDataBox(); - } - -} \ No newline at end of file diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/apple/AppleRatingBox.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/apple/AppleRatingBox.java deleted file mode 100644 index 71671fc6d..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/apple/AppleRatingBox.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.coremedia.iso.boxes.apple; - -/** - * iTunes Rating Box. - */ -public final class AppleRatingBox extends AbstractAppleMetaDataBox { - public static final String TYPE = "rtng"; - - - public AppleRatingBox() { - super(TYPE); - appleDataBox = AppleDataBox.getUint8AppleDataBox(); - } - - -} diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/apple/AppleRecordingYearBox.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/apple/AppleRecordingYearBox.java deleted file mode 100644 index da1330054..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/apple/AppleRecordingYearBox.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.coremedia.iso.boxes.apple; - -/** - * - */ -public class AppleRecordingYearBox extends AbstractAppleMetaDataBox { - public static final String TYPE = "\u00a9day"; - - - public AppleRecordingYearBox() { - super(TYPE); - appleDataBox = AppleDataBox.getStringAppleDataBox(); - } - - -} \ No newline at end of file diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/apple/AppleReferenceMovieBox.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/apple/AppleReferenceMovieBox.java deleted file mode 100644 index 991eb9ba1..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/apple/AppleReferenceMovieBox.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright 2009 castLabs GmbH, Berlin - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coremedia.iso.boxes.apple; - -import com.googlecode.mp4parser.AbstractContainerBox; - -public class AppleReferenceMovieBox extends AbstractContainerBox { - public static final String TYPE = "rmra"; - - public AppleReferenceMovieBox() { - super(TYPE); - } - -} diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/apple/AppleReferenceMovieDescriptorBox.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/apple/AppleReferenceMovieDescriptorBox.java deleted file mode 100644 index 80199140b..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/apple/AppleReferenceMovieDescriptorBox.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2009 castLabs GmbH, Berlin - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coremedia.iso.boxes.apple; - -import com.googlecode.mp4parser.AbstractContainerBox; - -public class AppleReferenceMovieDescriptorBox extends AbstractContainerBox { - public static final String TYPE = "rmda"; - - public AppleReferenceMovieDescriptorBox() { - super(TYPE); - } -} diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/apple/AppleShowBox.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/apple/AppleShowBox.java deleted file mode 100644 index 66b0d59f3..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/apple/AppleShowBox.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.coremedia.iso.boxes.apple; - -/** - * - */ -public final class AppleShowBox extends AbstractAppleMetaDataBox { - public static final String TYPE = "tvsh"; - - - public AppleShowBox() { - super(TYPE); - appleDataBox = AppleDataBox.getStringAppleDataBox(); - } - -} \ No newline at end of file diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/apple/AppleSortAlbumBox.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/apple/AppleSortAlbumBox.java deleted file mode 100644 index cf740049b..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/apple/AppleSortAlbumBox.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.coremedia.iso.boxes.apple; - -/** - * - */ -public final class AppleSortAlbumBox extends AbstractAppleMetaDataBox { - public static final String TYPE = "soal"; - - - public AppleSortAlbumBox() { - super(TYPE); - appleDataBox = AppleDataBox.getStringAppleDataBox(); - } -} \ No newline at end of file diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/apple/AppleStandardGenreBox.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/apple/AppleStandardGenreBox.java deleted file mode 100644 index 21932fa9b..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/apple/AppleStandardGenreBox.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.coremedia.iso.boxes.apple; - -/** - * - */ -public final class AppleStandardGenreBox extends AbstractAppleMetaDataBox { - public static final String TYPE = "gnre"; - - - public AppleStandardGenreBox() { - super(TYPE); - appleDataBox = AppleDataBox.getUint16AppleDataBox(); - } -} \ No newline at end of file diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/apple/AppleStoreAccountTypeBox.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/apple/AppleStoreAccountTypeBox.java deleted file mode 100755 index 36ecf4e95..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/apple/AppleStoreAccountTypeBox.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.coremedia.iso.boxes.apple; - -/** - * itunes MetaData comment box. - */ -public class AppleStoreAccountTypeBox extends AbstractAppleMetaDataBox { - public static final String TYPE = "akID"; - - - public AppleStoreAccountTypeBox() { - super(TYPE); - appleDataBox = AppleDataBox.getUint8AppleDataBox(); - } - - public String getReadableValue() { - byte value = this.appleDataBox.getData()[0]; - switch (value) { - case 0: - return "iTunes Account"; - case 1: - return "AOL Account"; - default: - return "unknown Account"; - } - - } -} \ No newline at end of file diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/apple/AppleStoreCountryCodeBox.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/apple/AppleStoreCountryCodeBox.java deleted file mode 100644 index 2c4756af9..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/apple/AppleStoreCountryCodeBox.java +++ /dev/null @@ -1,54 +0,0 @@ -package com.coremedia.iso.boxes.apple; - -import java.util.HashMap; -import java.util.Map; - -/** - * itunes MetaData comment box. - */ -public class AppleStoreCountryCodeBox extends AbstractAppleMetaDataBox { - private static Map countryCodes = new HashMap(); - - static { - countryCodes.put("143460", "Australia"); - countryCodes.put("143445", "Austria"); - countryCodes.put("143446", "Belgium"); - countryCodes.put("143455", "Canada"); - countryCodes.put("143458", "Denmark"); - countryCodes.put("143447", "Finland"); - countryCodes.put("143442", "France"); - countryCodes.put("143443", "Germany"); - countryCodes.put("143448", "Greece"); - countryCodes.put("143449", "Ireland"); - countryCodes.put("143450", "Italy"); - countryCodes.put("143462", "Japan"); - countryCodes.put("143451", "Luxembourg"); - countryCodes.put("143452", "Netherlands"); - countryCodes.put("143461", "New Zealand"); - countryCodes.put("143457", "Norway"); - countryCodes.put("143453", "Portugal"); - countryCodes.put("143454", "Spain"); - countryCodes.put("143456", "Sweden"); - countryCodes.put("143459", "Switzerland"); - countryCodes.put("143444", "United Kingdom"); - countryCodes.put("143441", "United States"); - } - - public static final String TYPE = "sfID"; - - - public AppleStoreCountryCodeBox() { - super(TYPE); - appleDataBox = AppleDataBox.getUint32AppleDataBox(); - } - - - public String getReadableValue() { - if (countryCodes.containsKey(getValue())) { - return countryCodes.get(getValue()); - } else { - return "unknown country code " + getValue(); - } - - } -} \ No newline at end of file diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/apple/AppleSynopsisBox.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/apple/AppleSynopsisBox.java deleted file mode 100644 index cd5c2ab17..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/apple/AppleSynopsisBox.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.coremedia.iso.boxes.apple; - -/** - * - */ -public final class AppleSynopsisBox extends AbstractAppleMetaDataBox { - public static final String TYPE = "ldes"; - - - public AppleSynopsisBox() { - super(TYPE); - appleDataBox = AppleDataBox.getStringAppleDataBox(); - } - - -} \ No newline at end of file diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/apple/AppleTempBox.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/apple/AppleTempBox.java deleted file mode 100644 index ebc66cfc3..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/apple/AppleTempBox.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.coremedia.iso.boxes.apple; - -/** - * Beats per minute. - */ -public final class AppleTempBox extends AbstractAppleMetaDataBox { - public static final String TYPE = "tmpo"; - - - public AppleTempBox() { - super(TYPE); - appleDataBox = AppleDataBox.getUint16AppleDataBox(); - } - - - public int getTempo() { - return appleDataBox.getData()[1]; - } - - public void setTempo(int tempo) { - appleDataBox = new AppleDataBox(); - appleDataBox.setVersion(0); - appleDataBox.setFlags(21); - appleDataBox.setFourBytes(new byte[4]); - appleDataBox.setData(new byte[]{0, (byte) (tempo & 0xFF)}); - - } -} \ No newline at end of file diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/apple/AppleTrackAuthorBox.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/apple/AppleTrackAuthorBox.java deleted file mode 100644 index c5b3732b9..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/apple/AppleTrackAuthorBox.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.coremedia.iso.boxes.apple; - -/** - * - */ -public final class AppleTrackAuthorBox extends AbstractAppleMetaDataBox { - public static final String TYPE = "\u00a9wrt"; - - - public AppleTrackAuthorBox() { - super(TYPE); - appleDataBox = AppleDataBox.getStringAppleDataBox(); - } - - -} \ No newline at end of file diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/apple/AppleTrackNumberBox.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/apple/AppleTrackNumberBox.java deleted file mode 100644 index c073c2fdc..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/apple/AppleTrackNumberBox.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.coremedia.iso.boxes.apple; - -/** - * - */ -public final class AppleTrackNumberBox extends AbstractAppleMetaDataBox { - public static final String TYPE = "trkn"; - - - public AppleTrackNumberBox() { - super(TYPE); - } - - - /** - * @param track the actual track number - * @param of number of tracks overall - */ - public void setTrackNumber(byte track, byte of) { - appleDataBox = new AppleDataBox(); - appleDataBox.setVersion(0); - appleDataBox.setFlags(0); - appleDataBox.setFourBytes(new byte[4]); - appleDataBox.setData(new byte[]{0, 0, 0, track, 0, of, 0, 0}); - } - - public byte getTrackNumber() { - return appleDataBox.getData()[3]; - } - - public byte getNumberOfTracks() { - return appleDataBox.getData()[5]; - } - - public void setNumberOfTracks(byte numberOfTracks) { - byte[] content = appleDataBox.getData(); - content[5] = numberOfTracks; - appleDataBox.setData(content); - } - - public void setTrackNumber(byte trackNumber) { - byte[] content = appleDataBox.getData(); - content[3] = trackNumber; - appleDataBox.setData(content); - } - - -} \ No newline at end of file diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/apple/AppleTrackTitleBox.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/apple/AppleTrackTitleBox.java deleted file mode 100644 index 3dd613cd7..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/apple/AppleTrackTitleBox.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.coremedia.iso.boxes.apple; - -/** - * - */ -public final class AppleTrackTitleBox extends AbstractAppleMetaDataBox { - public static final String TYPE = "\u00a9nam"; - - - public AppleTrackTitleBox() { - super(TYPE); - appleDataBox = AppleDataBox.getStringAppleDataBox(); - } - -} diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/apple/AppleTvEpisodeBox.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/apple/AppleTvEpisodeBox.java deleted file mode 100644 index b1e62ec27..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/apple/AppleTvEpisodeBox.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.coremedia.iso.boxes.apple; - -/** - * Tv Episode. - */ -public class AppleTvEpisodeBox extends AbstractAppleMetaDataBox { - public static final String TYPE = "tves"; - - - public AppleTvEpisodeBox() { - super(TYPE); - appleDataBox = AppleDataBox.getUint32AppleDataBox(); - } - -} \ No newline at end of file diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/apple/AppleTvEpisodeNumberBox.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/apple/AppleTvEpisodeNumberBox.java deleted file mode 100644 index 9e446ce71..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/apple/AppleTvEpisodeNumberBox.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.coremedia.iso.boxes.apple; - -/** - * Tv Episode. - */ -public class AppleTvEpisodeNumberBox extends AbstractAppleMetaDataBox { - public static final String TYPE = "tven"; - - - public AppleTvEpisodeNumberBox() { - super(TYPE); - appleDataBox = AppleDataBox.getStringAppleDataBox(); - } - -} \ No newline at end of file diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/apple/AppleTvSeasonBox.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/apple/AppleTvSeasonBox.java deleted file mode 100644 index 8f5c56a55..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/apple/AppleTvSeasonBox.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.coremedia.iso.boxes.apple; - -/** - * Tv Season. - */ -public final class AppleTvSeasonBox extends AbstractAppleMetaDataBox { - public static final String TYPE = "tvsn"; - - - public AppleTvSeasonBox() { - super(TYPE); - appleDataBox = AppleDataBox.getUint32AppleDataBox(); - } - -} \ No newline at end of file diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/apple/AppleWaveBox.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/apple/AppleWaveBox.java deleted file mode 100644 index 65edd38cd..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/apple/AppleWaveBox.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.coremedia.iso.boxes.apple; - -import com.googlecode.mp4parser.AbstractContainerBox; - -/** - * - */ -public final class AppleWaveBox extends AbstractContainerBox { - public static final String TYPE = "wave"; - - public AppleWaveBox() { - super(TYPE); - } - - -} diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/dece/TrickPlayBox.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/dece/TrickPlayBox.java deleted file mode 100644 index 4893813a8..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/dece/TrickPlayBox.java +++ /dev/null @@ -1,108 +0,0 @@ -package com.coremedia.iso.boxes.dece; - -import com.coremedia.iso.IsoTypeReader; -import com.coremedia.iso.IsoTypeWriter; -import com.googlecode.mp4parser.AbstractFullBox; - -import java.nio.ByteBuffer; -import java.util.ArrayList; -import java.util.List; - -/** - * aligned(8) class TrickPlayBox - * extends FullBox(‘trik’, version=0, flags=0) - * { - * for (i=0; I < sample_count; i++) { - * unsigned int(2) pic_type; - * unsigned int(6) dependency_level; - * } - * } - */ -public class TrickPlayBox extends AbstractFullBox { - public static final String TYPE = "trik"; - - private List entries = new ArrayList(); - - public TrickPlayBox() { - super(TYPE); - } - - public void setEntries(List entries) { - this.entries = entries; - } - - public List getEntries() { - return entries; - } - - public static class Entry { - - public Entry() { - } - - public Entry(int value) { - this.value = value; - } - - - private int value; - - public int getPicType() { - return (value >> 6) & 0x03; - } - - public void setPicType(int picType) { - value = value & (0xff >> 3); - value = (picType & 0x03) << 6 | value; - } - - public int getDependencyLevel() { - return value & 0x3f; - } - - public void setDependencyLevel(int dependencyLevel) { - value = (dependencyLevel & 0x3f) | value; - } - - - @Override - public String toString() { - final StringBuilder sb = new StringBuilder(); - sb.append("Entry"); - sb.append("{picType=").append(getPicType()); - sb.append(",dependencyLevel=").append(getDependencyLevel()); - sb.append('}'); - return sb.toString(); - } - } - - @Override - protected long getContentSize() { - return 4 + entries.size(); - } - - @Override - public void _parseDetails(ByteBuffer content) { - parseVersionAndFlags(content); - while (content.remaining() > 0) { - entries.add(new Entry(IsoTypeReader.readUInt8(content))); - } - } - - @Override - protected void getContent(ByteBuffer byteBuffer) { - writeVersionAndFlags(byteBuffer); - for (Entry entry : entries) { - IsoTypeWriter.writeUInt8(byteBuffer, entry.value); - } - } - - @Override - public String toString() { - final StringBuilder sb = new StringBuilder(); - sb.append("TrickPlayBox"); - sb.append("{entries=").append(entries); - sb.append('}'); - return sb.toString(); - } -} diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/fragment/MovieExtendsBox.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/fragment/MovieExtendsBox.java deleted file mode 100644 index 5ecd64298..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/fragment/MovieExtendsBox.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright 2009 castLabs GmbH, Berlin - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coremedia.iso.boxes.fragment; - -import com.googlecode.mp4parser.AbstractContainerBox; - -/** - * aligned(8) class MovieExtendsBox extends Box('mvex'){ - * } - */ -public class MovieExtendsBox extends AbstractContainerBox { - public static final String TYPE = "mvex"; - - public MovieExtendsBox() { - super(TYPE); - } -} diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/fragment/MovieExtendsHeaderBox.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/fragment/MovieExtendsHeaderBox.java deleted file mode 100644 index f630baace..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/fragment/MovieExtendsHeaderBox.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright 2009 castLabs GmbH, Berlin - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coremedia.iso.boxes.fragment; - -import com.coremedia.iso.IsoTypeReader; -import com.coremedia.iso.IsoTypeWriter; -import com.googlecode.mp4parser.AbstractFullBox; - -import java.nio.ByteBuffer; - -/** - * aligned(8) class MovieExtendsHeaderBox extends FullBox('mehd', version, 0) { - * if (version==1) { - * unsigned int(64) fragment_duration; - * } else { // version==0 - * unsigned int(32) fragment_duration; - * } - * } - */ -public class MovieExtendsHeaderBox extends AbstractFullBox { - public static final String TYPE = "mehd"; - private long fragmentDuration; - - public MovieExtendsHeaderBox() { - super(TYPE); - } - - @Override - protected long getContentSize() { - return getVersion() == 1 ? 12 : 8; - } - - @Override - public void _parseDetails(ByteBuffer content) { - parseVersionAndFlags(content); - fragmentDuration = getVersion() == 1 ? IsoTypeReader.readUInt64(content) : IsoTypeReader.readUInt32(content); - } - - - @Override - protected void getContent(ByteBuffer byteBuffer) { - writeVersionAndFlags(byteBuffer); - if (getVersion() == 1) { - IsoTypeWriter.writeUInt64(byteBuffer, fragmentDuration); - } else { - IsoTypeWriter.writeUInt32(byteBuffer, fragmentDuration); - } - } - - public long getFragmentDuration() { - return fragmentDuration; - } -} diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/fragment/MovieFragmentBox.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/fragment/MovieFragmentBox.java deleted file mode 100644 index b7a2f0200..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/fragment/MovieFragmentBox.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright 2009 castLabs GmbH, Berlin - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coremedia.iso.boxes.fragment; - -import com.googlecode.mp4parser.AbstractContainerBox; -import com.coremedia.iso.boxes.Box; -import com.coremedia.iso.boxes.SampleDependencyTypeBox; -import com.googlecode.mp4parser.annotations.DoNotParseDetail; - -import java.util.ArrayList; -import java.util.List; - -/** - * aligned(8) class MovieFragmentBox extends Box(moof){ - * } - */ - -public class MovieFragmentBox extends AbstractContainerBox { - public static final String TYPE = "moof"; - - public MovieFragmentBox() { - super(TYPE); - } - - - public List getSyncSamples(SampleDependencyTypeBox sdtp) { - List result = new ArrayList(); - - final List sampleEntries = sdtp.getEntries(); - long i = 1; - for (SampleDependencyTypeBox.Entry sampleEntry : sampleEntries) { - if (sampleEntry.getSampleDependsOn() == 2) { - result.add(i); - } - i++; - } - - return result; - } - - @DoNotParseDetail - public long getOffset() { - Box b = this; - long offset = 0; - while (b.getParent() != null) { - for (Box box : b.getParent().getBoxes()) { - if (b == box) { - break; - } - offset += box.getSize(); - } - b = b.getParent(); - } - return offset; - } - - - public int getTrackCount() { - return getBoxes(TrackFragmentBox.class, false).size(); - } - - /** - * Returns the track numbers associated with this MovieBox. - * - * @return the tracknumbers (IDs) of the tracks in their order of appearance in the file - */ - - public long[] getTrackNumbers() { - - List trackBoxes = this.getBoxes(TrackFragmentBox.class, false); - long[] trackNumbers = new long[trackBoxes.size()]; - for (int trackCounter = 0; trackCounter < trackBoxes.size(); trackCounter++) { - TrackFragmentBox trackBoxe = trackBoxes.get(trackCounter); - trackNumbers[trackCounter] = trackBoxe.getTrackFragmentHeaderBox().getTrackId(); - } - return trackNumbers; - } - - public List getTrackRunBoxes() { - return getBoxes(TrackRunBox.class, true); - } -} diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/fragment/MovieFragmentHeaderBox.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/fragment/MovieFragmentHeaderBox.java deleted file mode 100644 index e58f7a20f..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/fragment/MovieFragmentHeaderBox.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright 2009 castLabs GmbH, Berlin - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coremedia.iso.boxes.fragment; - -import com.coremedia.iso.IsoTypeReader; -import com.coremedia.iso.IsoTypeWriter; -import com.googlecode.mp4parser.AbstractFullBox; - -import java.nio.ByteBuffer; - -/** - * aligned(8) class MovieFragmentHeaderBox - * extends FullBox('mfhd', 0, 0){ - * unsigned int(32) sequence_number; - * } - */ - -public class MovieFragmentHeaderBox extends AbstractFullBox { - public static final String TYPE = "mfhd"; - private long sequenceNumber; - - public MovieFragmentHeaderBox() { - super(TYPE); - } - - protected long getContentSize() { - return 8; - } - - @Override - protected void getContent(ByteBuffer byteBuffer) { - writeVersionAndFlags(byteBuffer); - IsoTypeWriter.writeUInt32(byteBuffer, sequenceNumber); - } - - - @Override - public void _parseDetails(ByteBuffer content) { - parseVersionAndFlags(content); - sequenceNumber = IsoTypeReader.readUInt32(content); - - } - - public long getSequenceNumber() { - return sequenceNumber; - } - - public void setSequenceNumber(long sequenceNumber) { - this.sequenceNumber = sequenceNumber; - } - - @Override - public String toString() { - return "MovieFragmentHeaderBox{" + - "sequenceNumber=" + sequenceNumber + - '}'; - } -} diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/fragment/MovieFragmentRandomAccessBox.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/fragment/MovieFragmentRandomAccessBox.java deleted file mode 100644 index 86e2c9d43..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/fragment/MovieFragmentRandomAccessBox.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright 2009 castLabs GmbH, Berlin - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coremedia.iso.boxes.fragment; - -import com.googlecode.mp4parser.AbstractContainerBox; - -/** - * aligned(8) class MovieFragmentRandomAccessBox - * extends Box('mfra') - * { - * } - */ -public class MovieFragmentRandomAccessBox extends AbstractContainerBox { - public static final String TYPE = "mfra"; - - public MovieFragmentRandomAccessBox() { - super(TYPE); - } - -} diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/fragment/MovieFragmentRandomAccessOffsetBox.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/fragment/MovieFragmentRandomAccessOffsetBox.java deleted file mode 100644 index edbfd6667..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/fragment/MovieFragmentRandomAccessOffsetBox.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright 2009 castLabs GmbH, Berlin - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coremedia.iso.boxes.fragment; - -import com.coremedia.iso.IsoTypeReader; -import com.coremedia.iso.IsoTypeWriter; -import com.googlecode.mp4parser.AbstractFullBox; - -import java.nio.ByteBuffer; - -/** - * aligned(8) class MovieFragmentRandomAccessOffsetBox - * extends FullBox('mfro', version, 0) { - * unsigned int(32) size; - * } - */ -public class MovieFragmentRandomAccessOffsetBox extends AbstractFullBox { - public static final String TYPE = "mfro"; - private long mfraSize; - - public MovieFragmentRandomAccessOffsetBox() { - super(TYPE); - } - - protected long getContentSize() { - return 8; - } - - @Override - public void _parseDetails(ByteBuffer content) { - parseVersionAndFlags(content); - mfraSize = IsoTypeReader.readUInt32(content); - } - - @Override - protected void getContent(ByteBuffer byteBuffer) { - writeVersionAndFlags(byteBuffer); - IsoTypeWriter.writeUInt32(byteBuffer, mfraSize); - } - - public long getMfraSize() { - return mfraSize; - } - - public void setMfraSize(long mfraSize) { - this.mfraSize = mfraSize; - } -} diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/fragment/SampleFlags.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/fragment/SampleFlags.java deleted file mode 100644 index 6caaf1e4c..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/fragment/SampleFlags.java +++ /dev/null @@ -1,207 +0,0 @@ -/* - * Copyright 2009 castLabs GmbH, Berlin - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coremedia.iso.boxes.fragment; - -import com.googlecode.mp4parser.boxes.mp4.objectdescriptors.BitReaderBuffer; -import com.googlecode.mp4parser.boxes.mp4.objectdescriptors.BitWriterBuffer; - -import java.io.IOException; -import java.nio.ByteBuffer; - -/** - * bit(6) reserved=0; - * unsigned int(2) sample_depends_on; - * unsigned int(2) sample_is_depended_on; - * unsigned int(2) sample_has_redundancy; - * bit(3) sample_padding_value; - * bit(1) sample_is_difference_sample; - * // i.e. when 1 signals a non-key or non-sync sample - * unsigned int(16) sample_degradation_priority; - */ -public class SampleFlags { - private int reserved; - private int sampleDependsOn; - private int sampleIsDependedOn; - private int sampleHasRedundancy; - private int samplePaddingValue; - private boolean sampleIsDifferenceSample; - private int sampleDegradationPriority; - - public SampleFlags() { - - } - - public SampleFlags(ByteBuffer bb) { - BitReaderBuffer brb = new BitReaderBuffer(bb); - reserved = brb.readBits(6); - sampleDependsOn = brb.readBits(2); - sampleIsDependedOn = brb.readBits(2); - sampleHasRedundancy = brb.readBits(2); - samplePaddingValue = brb.readBits(3); - sampleIsDifferenceSample = brb.readBits(1) == 1; - sampleDegradationPriority = brb.readBits(16); - } - - - public void getContent(ByteBuffer os) { - BitWriterBuffer bitWriterBuffer = new BitWriterBuffer(os); - bitWriterBuffer.writeBits(reserved, 6); - bitWriterBuffer.writeBits(sampleDependsOn, 2); - bitWriterBuffer.writeBits(sampleIsDependedOn, 2); - bitWriterBuffer.writeBits(sampleHasRedundancy, 2); - bitWriterBuffer.writeBits(samplePaddingValue, 3); - bitWriterBuffer.writeBits(this.sampleIsDifferenceSample ? 1 : 0, 1); - bitWriterBuffer.writeBits(sampleDegradationPriority, 16); - } - - public int getReserved() { - return reserved; - } - - public void setReserved(int reserved) { - this.reserved = reserved; - } - - /** - * @see #setSampleDependsOn(int) - */ - public int getSampleDependsOn() { - return sampleDependsOn; - } - - /** - * sample_depends_on takes one of the following four values: - *

    -     * 0: the dependency of this sample is unknown;
    -     * 1: this sample does depend on others (not an I picture);
    -     * 2: this sample does not depend on others (I picture);
    -     * 3: reserved
    -     * 
    - * - */ - public void setSampleDependsOn(int sampleDependsOn) { - this.sampleDependsOn = sampleDependsOn; - } - - /** - * @see #setSampleIsDependedOn(int) - */ - public int getSampleIsDependedOn() { - return sampleIsDependedOn; - } - - /** - * sample_is_depended_on takes one of the following four values: - *
    -     * 0: the dependency of other samples on this sample is unknown;
    -     * 1: other samples may depend on this one (not disposable);
    -     * 2: no other sample depends on this one (disposable);
    -     * 3: reserved
    -     * 
    - * - */ - public void setSampleIsDependedOn(int sampleIsDependedOn) { - this.sampleIsDependedOn = sampleIsDependedOn; - } - - /** - * @see #setSampleHasRedundancy(int) - */ - public int getSampleHasRedundancy() { - return sampleHasRedundancy; - } - - /** - * sample_has_redundancy takes one of the following four values: - *
    -     * 0: it is unknown whether there is redundant coding in this sample;
    -     * 1: there is redundant coding in this sample;
    -     * 2: there is no redundant coding in this sample;
    -     * 3: reserved
    -     * 
    - */ - public void setSampleHasRedundancy(int sampleHasRedundancy) { - this.sampleHasRedundancy = sampleHasRedundancy; - } - - public int getSamplePaddingValue() { - return samplePaddingValue; - } - - public void setSamplePaddingValue(int samplePaddingValue) { - this.samplePaddingValue = samplePaddingValue; - } - - public boolean isSampleIsDifferenceSample() { - return sampleIsDifferenceSample; - } - - - public void setSampleIsDifferenceSample(boolean sampleIsDifferenceSample) { - this.sampleIsDifferenceSample = sampleIsDifferenceSample; - } - - public int getSampleDegradationPriority() { - return sampleDegradationPriority; - } - - public void setSampleDegradationPriority(int sampleDegradationPriority) { - this.sampleDegradationPriority = sampleDegradationPriority; - } - - @Override - public String toString() { - return "SampleFlags{" + - "reserved=" + reserved + - ", sampleDependsOn=" + sampleDependsOn + - ", sampleHasRedundancy=" + sampleHasRedundancy + - ", samplePaddingValue=" + samplePaddingValue + - ", sampleIsDifferenceSample=" + sampleIsDifferenceSample + - ", sampleDegradationPriority=" + sampleDegradationPriority + - '}'; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - SampleFlags that = (SampleFlags) o; - - if (reserved != that.reserved) return false; - if (sampleDegradationPriority != that.sampleDegradationPriority) return false; - if (sampleDependsOn != that.sampleDependsOn) return false; - if (sampleHasRedundancy != that.sampleHasRedundancy) return false; - if (sampleIsDependedOn != that.sampleIsDependedOn) return false; - if (sampleIsDifferenceSample != that.sampleIsDifferenceSample) return false; - if (samplePaddingValue != that.samplePaddingValue) return false; - - return true; - } - - @Override - public int hashCode() { - int result = reserved; - result = 31 * result + sampleDependsOn; - result = 31 * result + sampleIsDependedOn; - result = 31 * result + sampleHasRedundancy; - result = 31 * result + samplePaddingValue; - result = 31 * result + (sampleIsDifferenceSample ? 1 : 0); - result = 31 * result + sampleDegradationPriority; - return result; - } -} diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/fragment/TrackExtendsBox.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/fragment/TrackExtendsBox.java deleted file mode 100644 index 8bba7c189..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/fragment/TrackExtendsBox.java +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Copyright 2009 castLabs GmbH, Berlin - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coremedia.iso.boxes.fragment; - -import com.coremedia.iso.IsoTypeReader; -import com.coremedia.iso.IsoTypeWriter; -import com.googlecode.mp4parser.AbstractFullBox; - -import java.nio.ByteBuffer; - -/** - * aligned(8) class TrackExtendsBox extends FullBox('trex', 0, 0){ - * unsigned int(32) track_ID; - * unsigned int(32) default_sample_description_index; - * unsigned int(32) default_sample_duration; - * unsigned int(32) default_sample_size; - * unsigned int(32) default_sample_flags - * } - */ -public class TrackExtendsBox extends AbstractFullBox { - public static final String TYPE = "trex"; - private long trackId; - private long defaultSampleDescriptionIndex; - private long defaultSampleDuration; - private long defaultSampleSize; - private SampleFlags defaultSampleFlags; - - public TrackExtendsBox() { - super(TYPE); - } - - @Override - protected long getContentSize() { - return 5 * 4 + 4; - } - - @Override - protected void getContent(ByteBuffer byteBuffer) { - writeVersionAndFlags(byteBuffer); - IsoTypeWriter.writeUInt32(byteBuffer, trackId); - IsoTypeWriter.writeUInt32(byteBuffer, defaultSampleDescriptionIndex); - IsoTypeWriter.writeUInt32(byteBuffer, defaultSampleDuration); - IsoTypeWriter.writeUInt32(byteBuffer, defaultSampleSize); - defaultSampleFlags.getContent(byteBuffer); - } - - @Override - public void _parseDetails(ByteBuffer content) { - parseVersionAndFlags(content); - trackId = IsoTypeReader.readUInt32(content); - defaultSampleDescriptionIndex = IsoTypeReader.readUInt32(content); - defaultSampleDuration = IsoTypeReader.readUInt32(content); - defaultSampleSize = IsoTypeReader.readUInt32(content); - defaultSampleFlags = new SampleFlags(content); - } - - public long getTrackId() { - return trackId; - } - - public long getDefaultSampleDescriptionIndex() { - return defaultSampleDescriptionIndex; - } - - public long getDefaultSampleDuration() { - return defaultSampleDuration; - } - - public long getDefaultSampleSize() { - return defaultSampleSize; - } - - public SampleFlags getDefaultSampleFlags() { - return defaultSampleFlags; - } - - public String getDefaultSampleFlagsStr() { - return defaultSampleFlags.toString(); - } - - public void setTrackId(long trackId) { - this.trackId = trackId; - } - - public void setDefaultSampleDescriptionIndex(long defaultSampleDescriptionIndex) { - this.defaultSampleDescriptionIndex = defaultSampleDescriptionIndex; - } - - public void setDefaultSampleDuration(long defaultSampleDuration) { - this.defaultSampleDuration = defaultSampleDuration; - } - - public void setDefaultSampleSize(long defaultSampleSize) { - this.defaultSampleSize = defaultSampleSize; - } - - public void setDefaultSampleFlags(SampleFlags defaultSampleFlags) { - this.defaultSampleFlags = defaultSampleFlags; - - } -} diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/fragment/TrackFragmentBaseMediaDecodeTimeBox.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/fragment/TrackFragmentBaseMediaDecodeTimeBox.java deleted file mode 100644 index 06fcf623d..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/fragment/TrackFragmentBaseMediaDecodeTimeBox.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright 2009 castLabs GmbH, Berlin - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coremedia.iso.boxes.fragment; - -import com.coremedia.iso.IsoTypeReader; -import com.coremedia.iso.IsoTypeWriter; -import com.googlecode.mp4parser.AbstractFullBox; - -import java.nio.ByteBuffer; - -public class TrackFragmentBaseMediaDecodeTimeBox extends AbstractFullBox { - public static final String TYPE = "tfdt"; - - private long baseMediaDecodeTime; - - public TrackFragmentBaseMediaDecodeTimeBox() { - super(TYPE); - } - - @Override - protected long getContentSize() { - return getVersion() == 0 ? 8 : 12; - } - - @Override - protected void getContent(ByteBuffer byteBuffer) { - writeVersionAndFlags(byteBuffer); - if (getVersion() == 1) { - IsoTypeWriter.writeUInt64(byteBuffer, baseMediaDecodeTime); - } else { - IsoTypeWriter.writeUInt32(byteBuffer, baseMediaDecodeTime); - } - } - - - @Override - public void _parseDetails(ByteBuffer content) { - parseVersionAndFlags(content); - if (getVersion() == 1) { - baseMediaDecodeTime = IsoTypeReader.readUInt64(content); - } else { - baseMediaDecodeTime = IsoTypeReader.readUInt32(content); - } - - } - - - public long getBaseMediaDecodeTime() { - return baseMediaDecodeTime; - } - - public void setBaseMediaDecodeTime(long baseMediaDecodeTime) { - this.baseMediaDecodeTime = baseMediaDecodeTime; - } - - @Override - public String toString() { - return "TrackFragmentBaseMediaDecodeTimeBox{" + - "baseMediaDecodeTime=" + baseMediaDecodeTime + - '}'; - } -} diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/fragment/TrackFragmentBox.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/fragment/TrackFragmentBox.java deleted file mode 100644 index fde7da583..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/fragment/TrackFragmentBox.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright 2009 castLabs GmbH, Berlin - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coremedia.iso.boxes.fragment; - -import com.googlecode.mp4parser.AbstractContainerBox; -import com.coremedia.iso.boxes.Box; - -/** - * aligned(8) class TrackFragmentBox extends Box('traf'){ - * } - */ -public class TrackFragmentBox extends AbstractContainerBox { - public static final String TYPE = "traf"; - - public TrackFragmentBox() { - super(TYPE); - } - - - public TrackFragmentHeaderBox getTrackFragmentHeaderBox() { - for (Box box : getBoxes()) { - if (box instanceof TrackFragmentHeaderBox) { - return (TrackFragmentHeaderBox) box; - } - } - return null; - } - -} diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/fragment/TrackFragmentHeaderBox.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/fragment/TrackFragmentHeaderBox.java deleted file mode 100644 index d11143d39..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/fragment/TrackFragmentHeaderBox.java +++ /dev/null @@ -1,208 +0,0 @@ -/* - * Copyright 2009 castLabs GmbH, Berlin - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coremedia.iso.boxes.fragment; - -import com.coremedia.iso.IsoTypeReader; -import com.coremedia.iso.IsoTypeWriter; -import com.googlecode.mp4parser.AbstractFullBox; - -import java.nio.ByteBuffer; - -/** - * aligned(8) class TrackFragmentHeaderBox - * extends FullBox('tfhd', 0, tf_flags){ - * unsigned int(32) track_ID; - * // all the following are optional fields - * unsigned int(64) base_data_offset; - * unsigned int(32) sample_description_index; - * unsigned int(32) default_sample_duration; - * unsigned int(32) default_sample_size; - * unsigned int(32) default_sample_flags - * } - */ -public class TrackFragmentHeaderBox extends AbstractFullBox { - public static final String TYPE = "tfhd"; - - private long trackId; - private long baseDataOffset = -1; - private long sampleDescriptionIndex; - private long defaultSampleDuration = -1; - private long defaultSampleSize = -1; - private SampleFlags defaultSampleFlags; - private boolean durationIsEmpty; - - public TrackFragmentHeaderBox() { - super(TYPE); - } - - protected long getContentSize() { - long size = 8; - int flags = getFlags(); - if ((flags & 0x1) == 1) { //baseDataOffsetPresent - size += 8; - } - if ((flags & 0x2) == 0x2) { //sampleDescriptionIndexPresent - size += 4; - } - if ((flags & 0x8) == 0x8) { //defaultSampleDurationPresent - size += 4; - } - if ((flags & 0x10) == 0x10) { //defaultSampleSizePresent - size += 4; - } - if ((flags & 0x20) == 0x20) { //defaultSampleFlagsPresent - size += 4; - } - return size; - } - - - protected void getContent(ByteBuffer byteBuffer) { - writeVersionAndFlags(byteBuffer); - IsoTypeWriter.writeUInt32(byteBuffer, trackId); - - if ((getFlags() & 0x1) == 1) { //baseDataOffsetPresent - IsoTypeWriter.writeUInt64(byteBuffer, getBaseDataOffset()); - } - if ((getFlags() & 0x2) == 0x2) { //sampleDescriptionIndexPresent - IsoTypeWriter.writeUInt32(byteBuffer, getSampleDescriptionIndex()); - } - if ((getFlags() & 0x8) == 0x8) { //defaultSampleDurationPresent - IsoTypeWriter.writeUInt32(byteBuffer, getDefaultSampleDuration()); - } - if ((getFlags() & 0x10) == 0x10) { //defaultSampleSizePresent - IsoTypeWriter.writeUInt32(byteBuffer, getDefaultSampleSize()); - } - if ((getFlags() & 0x20) == 0x20) { //defaultSampleFlagsPresent - defaultSampleFlags.getContent(byteBuffer); - } - } - - @Override - public void _parseDetails(ByteBuffer content) { - parseVersionAndFlags(content); - trackId = IsoTypeReader.readUInt32(content); - if ((getFlags() & 0x1) == 1) { //baseDataOffsetPresent - baseDataOffset = IsoTypeReader.readUInt64(content); - } - if ((getFlags() & 0x2) == 0x2) { //sampleDescriptionIndexPresent - sampleDescriptionIndex = IsoTypeReader.readUInt32(content); - } - if ((getFlags() & 0x8) == 0x8) { //defaultSampleDurationPresent - defaultSampleDuration = IsoTypeReader.readUInt32(content); - } - if ((getFlags() & 0x10) == 0x10) { //defaultSampleSizePresent - defaultSampleSize = IsoTypeReader.readUInt32(content); - } - if ((getFlags() & 0x20) == 0x20) { //defaultSampleFlagsPresent - defaultSampleFlags = new SampleFlags(content); - } - if ((getFlags() & 0x10000) == 0x10000) { //durationIsEmpty - durationIsEmpty = true; - } - } - - public boolean hasBaseDataOffset() { - return (getFlags() & 0x1) != 0; - } - - public long getTrackId() { - return trackId; - } - - public long getBaseDataOffset() { - return baseDataOffset; - } - - public long getSampleDescriptionIndex() { - return sampleDescriptionIndex; - } - - public long getDefaultSampleDuration() { - return defaultSampleDuration; - } - - public long getDefaultSampleSize() { - return defaultSampleSize; - } - - public SampleFlags getDefaultSampleFlags() { - return defaultSampleFlags; - } - - public boolean isDurationIsEmpty() { - return durationIsEmpty; - } - - public void setTrackId(long trackId) { - this.trackId = trackId; - } - - public void setBaseDataOffset(long baseDataOffset) { - if (baseDataOffset == -1) { - setFlags(getFlags() & (Integer.MAX_VALUE ^ 0x1)); - } else { - setFlags(getFlags() | 0x1); // activate the field - } - this.baseDataOffset = baseDataOffset; - } - - public void setSampleDescriptionIndex(long sampleDescriptionIndex) { - if (sampleDescriptionIndex == -1) { - setFlags(getFlags() & (Integer.MAX_VALUE ^ 0x2)); - } else { - setFlags(getFlags() | 0x2); // activate the field - } - this.sampleDescriptionIndex = sampleDescriptionIndex; - } - - public void setDefaultSampleDuration(long defaultSampleDuration) { - setFlags(getFlags() | 0x8); // activate the field - this.defaultSampleDuration = defaultSampleDuration; - } - - public void setDefaultSampleSize(long defaultSampleSize) { - setFlags(getFlags() | 0x10); // activate the field - this.defaultSampleSize = defaultSampleSize; - } - - public void setDefaultSampleFlags(SampleFlags defaultSampleFlags) { - setFlags(getFlags() | 0x20); // activate the field - this.defaultSampleFlags = defaultSampleFlags; - } - - public void setDurationIsEmpty(boolean durationIsEmpty) { - setFlags(getFlags() | 0x10000); // activate the field - this.durationIsEmpty = durationIsEmpty; - } - - @Override - public String toString() { - final StringBuilder sb = new StringBuilder(); - sb.append("TrackFragmentHeaderBox"); - sb.append("{trackId=").append(trackId); - sb.append(", baseDataOffset=").append(baseDataOffset); - sb.append(", sampleDescriptionIndex=").append(sampleDescriptionIndex); - sb.append(", defaultSampleDuration=").append(defaultSampleDuration); - sb.append(", defaultSampleSize=").append(defaultSampleSize); - sb.append(", defaultSampleFlags=").append(defaultSampleFlags); - sb.append(", durationIsEmpty=").append(durationIsEmpty); - sb.append('}'); - return sb.toString(); - } - -} diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/fragment/TrackFragmentRandomAccessBox.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/fragment/TrackFragmentRandomAccessBox.java deleted file mode 100644 index 78a6e6661..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/fragment/TrackFragmentRandomAccessBox.java +++ /dev/null @@ -1,287 +0,0 @@ -/* - * Copyright 2009 castLabs GmbH, Berlin - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coremedia.iso.boxes.fragment; - -import com.coremedia.iso.IsoTypeReader; -import com.coremedia.iso.IsoTypeReaderVariable; -import com.coremedia.iso.IsoTypeWriter; -import com.coremedia.iso.IsoTypeWriterVariable; -import com.googlecode.mp4parser.AbstractFullBox; - -import java.nio.ByteBuffer; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -/** - * aligned(8) class TrackFragmentRandomAccessBox - * extends FullBox('tfra', version, 0) { - * unsigned int(32) track_ID; - * const unsigned int(26) reserved = 0; - * unsigned int(2) length_size_of_traf_num; - * unsigned int(2) length_size_of_trun_num; - * unsigned int(2) length_size_of_sample_num; - * unsigned int(32) number_of_entry; - * for(i=1; i <= number_of_entry; i++){ - * if(version==1){ - * unsigned int(64) time; - * unsigned int(64) moof_offset; - * }else{ - * unsigned int(32) time; - * unsigned int(32) moof_offset; - * } - * unsigned int((length_size_of_traf_num+1) * 8) traf_number; - * unsigned int((length_size_of_trun_num+1) * 8) trun_number; - * unsigned int((length_size_of_sample_num+1) * 8) sample_number; - * } - * } - */ -public class TrackFragmentRandomAccessBox extends AbstractFullBox { - public static final String TYPE = "tfra"; - - private long trackId; - private int reserved; - private int lengthSizeOfTrafNum = 2; - private int lengthSizeOfTrunNum = 2; - private int lengthSizeOfSampleNum = 2; - private List entries = Collections.emptyList(); - - public TrackFragmentRandomAccessBox() { - super(TYPE); - } - - - protected long getContentSize() { - long contentSize = 4; - contentSize += 4 + 4 /*26 + 2 + 2 + 2 */ + 4; - if (getVersion() == 1) { - contentSize += (8 + 8) * entries.size(); - } else { - contentSize += (4 + 4) * entries.size(); - } - contentSize += lengthSizeOfTrafNum * entries.size(); - contentSize += lengthSizeOfTrunNum * entries.size(); - contentSize += lengthSizeOfSampleNum * entries.size(); - return contentSize; - } - - - @Override - public void _parseDetails(ByteBuffer content) { - parseVersionAndFlags(content); - trackId = IsoTypeReader.readUInt32(content); - long temp = IsoTypeReader.readUInt32(content); - reserved = (int) (temp >> 6); - lengthSizeOfTrafNum = ((int) (temp & 0x3F) >> 4) + 1; - lengthSizeOfTrunNum = ((int) (temp & 0xC) >> 2) + 1; - lengthSizeOfSampleNum = ((int) (temp & 0x3)) + 1; - long numberOfEntries = IsoTypeReader.readUInt32(content); - - entries = new ArrayList(); - - for (int i = 0; i < numberOfEntries; i++) { - Entry entry = new Entry(); - if (getVersion() == 1) { - entry.time = IsoTypeReader.readUInt64(content); - entry.moofOffset = IsoTypeReader.readUInt64(content); - } else { - entry.time = IsoTypeReader.readUInt32(content); - entry.moofOffset = IsoTypeReader.readUInt32(content); - } - entry.trafNumber = IsoTypeReaderVariable.read(content, lengthSizeOfTrafNum); - entry.trunNumber = IsoTypeReaderVariable.read(content, lengthSizeOfTrunNum); - entry.sampleNumber = IsoTypeReaderVariable.read(content, lengthSizeOfSampleNum); - - entries.add(entry); - } - - } - - - @Override - protected void getContent(ByteBuffer byteBuffer) { - writeVersionAndFlags(byteBuffer); - IsoTypeWriter.writeUInt32(byteBuffer, trackId); - long temp; - temp = reserved << 6; - temp = temp | (((lengthSizeOfTrafNum - 1) & 0x3) << 4); - temp = temp | (((lengthSizeOfTrunNum - 1) & 0x3) << 2); - temp = temp | ((lengthSizeOfSampleNum - 1) & 0x3); - IsoTypeWriter.writeUInt32(byteBuffer, temp); - IsoTypeWriter.writeUInt32(byteBuffer, entries.size()); - - for (Entry entry : entries) { - if (getVersion() == 1) { - IsoTypeWriter.writeUInt64(byteBuffer, entry.time); - IsoTypeWriter.writeUInt64(byteBuffer, entry.moofOffset); - } else { - IsoTypeWriter.writeUInt32(byteBuffer, entry.time); - IsoTypeWriter.writeUInt32(byteBuffer, entry.moofOffset); - } - IsoTypeWriterVariable.write(entry.trafNumber, byteBuffer, lengthSizeOfTrafNum); - IsoTypeWriterVariable.write(entry.trunNumber, byteBuffer, lengthSizeOfTrunNum); - IsoTypeWriterVariable.write(entry.sampleNumber, byteBuffer, lengthSizeOfSampleNum); - - } - } - - - public void setTrackId(long trackId) { - this.trackId = trackId; - } - - public void setLengthSizeOfTrafNum(int lengthSizeOfTrafNum) { - this.lengthSizeOfTrafNum = lengthSizeOfTrafNum; - } - - public void setLengthSizeOfTrunNum(int lengthSizeOfTrunNum) { - this.lengthSizeOfTrunNum = lengthSizeOfTrunNum; - } - - public void setLengthSizeOfSampleNum(int lengthSizeOfSampleNum) { - this.lengthSizeOfSampleNum = lengthSizeOfSampleNum; - } - - public long getTrackId() { - return trackId; - } - - public int getReserved() { - return reserved; - } - - public int getLengthSizeOfTrafNum() { - return lengthSizeOfTrafNum; - } - - public int getLengthSizeOfTrunNum() { - return lengthSizeOfTrunNum; - } - - public int getLengthSizeOfSampleNum() { - return lengthSizeOfSampleNum; - } - - public long getNumberOfEntries() { - return entries.size(); - } - - public List getEntries() { - return Collections.unmodifiableList(entries); - } - - public void setEntries(List entries) { - this.entries = entries; - } - - public static class Entry { - private long time; - private long moofOffset; - private long trafNumber; - private long trunNumber; - private long sampleNumber; - - public Entry() { - } - - public Entry(long time, long moofOffset, long trafNumber, long trunNumber, long sampleNumber) { - this.moofOffset = moofOffset; - this.sampleNumber = sampleNumber; - this.time = time; - this.trafNumber = trafNumber; - this.trunNumber = trunNumber; - } - - public long getTime() { - return time; - } - - public long getMoofOffset() { - return moofOffset; - } - - public long getTrafNumber() { - return trafNumber; - } - - public long getTrunNumber() { - return trunNumber; - } - - public long getSampleNumber() { - return sampleNumber; - } - - public void setTime(long time) { - this.time = time; - } - - public void setMoofOffset(long moofOffset) { - this.moofOffset = moofOffset; - } - - public void setTrafNumber(long trafNumber) { - this.trafNumber = trafNumber; - } - - public void setTrunNumber(long trunNumber) { - this.trunNumber = trunNumber; - } - - public void setSampleNumber(long sampleNumber) { - this.sampleNumber = sampleNumber; - } - - @Override - public String toString() { - return "Entry{" + - "time=" + time + - ", moofOffset=" + moofOffset + - ", trafNumber=" + trafNumber + - ", trunNumber=" + trunNumber + - ", sampleNumber=" + sampleNumber + - '}'; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - Entry entry = (Entry) o; - - if (moofOffset != entry.moofOffset) return false; - if (sampleNumber != entry.sampleNumber) return false; - if (time != entry.time) return false; - if (trafNumber != entry.trafNumber) return false; - if (trunNumber != entry.trunNumber) return false; - - return true; - } - - @Override - public int hashCode() { - int result = (int) (time ^ (time >>> 32)); - result = 31 * result + (int) (moofOffset ^ (moofOffset >>> 32)); - result = 31 * result + (int) (trafNumber ^ (trafNumber >>> 32)); - result = 31 * result + (int) (trunNumber ^ (trunNumber >>> 32)); - result = 31 * result + (int) (sampleNumber ^ (sampleNumber >>> 32)); - return result; - } - } - -} diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/fragment/TrackRunBox.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/fragment/TrackRunBox.java deleted file mode 100644 index 9e51623b8..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/fragment/TrackRunBox.java +++ /dev/null @@ -1,381 +0,0 @@ -/* - * Copyright 2009 castLabs GmbH, Berlin - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coremedia.iso.boxes.fragment; - -import com.coremedia.iso.IsoTypeReader; -import com.coremedia.iso.IsoTypeWriter; -import com.googlecode.mp4parser.AbstractFullBox; - -import java.nio.ByteBuffer; -import java.util.ArrayList; -import java.util.List; - -import static com.googlecode.mp4parser.util.CastUtils.l2i; - -/** - * aligned(8) class TrackRunBox - * extends FullBox('trun', 0, tr_flags) { - * unsigned int(32) sample_count; - * // the following are optional fields - * signed int(32) data_offset; - * unsigned int(32) first_sample_flags; - * // all fields in the following array are optional - * { - * unsigned int(32) sample_duration; - * unsigned int(32) sample_size; - * unsigned int(32) sample_flags - * unsigned int(32) sample_composition_time_offset; - * }[ sample_count ] - * } - */ - -public class TrackRunBox extends AbstractFullBox { - public static final String TYPE = "trun"; - private int dataOffset; - private SampleFlags firstSampleFlags; - private List entries = new ArrayList(); - - - public List getEntries() { - return entries; - } - - public static class Entry { - private long sampleDuration; - private long sampleSize; - private SampleFlags sampleFlags; - private int sampleCompositionTimeOffset; - - public Entry() { - } - - public Entry(long sampleDuration, long sampleSize, SampleFlags sampleFlags, int sampleCompositionTimeOffset) { - this.sampleDuration = sampleDuration; - this.sampleSize = sampleSize; - this.sampleFlags = sampleFlags; - this.sampleCompositionTimeOffset = sampleCompositionTimeOffset; - } - - public long getSampleDuration() { - return sampleDuration; - } - - public long getSampleSize() { - return sampleSize; - } - - public SampleFlags getSampleFlags() { - return sampleFlags; - } - - public int getSampleCompositionTimeOffset() { - return sampleCompositionTimeOffset; - } - - public void setSampleDuration(long sampleDuration) { - this.sampleDuration = sampleDuration; - } - - public void setSampleSize(long sampleSize) { - this.sampleSize = sampleSize; - } - - public void setSampleFlags(SampleFlags sampleFlags) { - this.sampleFlags = sampleFlags; - } - - public void setSampleCompositionTimeOffset(int sampleCompositionTimeOffset) { - this.sampleCompositionTimeOffset = sampleCompositionTimeOffset; - } - - @Override - public String toString() { - return "Entry{" + - "sampleDuration=" + sampleDuration + - ", sampleSize=" + sampleSize + - ", sampleFlags=" + sampleFlags + - ", sampleCompositionTimeOffset=" + sampleCompositionTimeOffset + - '}'; - } - } - - public void setDataOffset(int dataOffset) { - if (dataOffset == -1) { - setFlags(getFlags() & (0xFFFFFF ^ 1)); - } else { - setFlags(getFlags() | 0x1); // turn on dataoffset - } - this.dataOffset = dataOffset; - } - - public long[] getSampleOffsets() { - long[] result = new long[entries.size()]; - - long offset = 0; - for (int i = 0; i < result.length; i++) { - result[i] = offset; - if (isSampleSizePresent()) { - offset += entries.get(i).getSampleSize(); - } else { - offset += ((TrackFragmentBox) getParent()).getTrackFragmentHeaderBox().getDefaultSampleSize(); - } - } - - return result; - } - - public long[] getSampleSizes() { - long[] result = new long[entries.size()]; - - for (int i = 0; i < result.length; i++) { - if (isSampleSizePresent()) { - result[i] = entries.get(i).getSampleSize(); - } else { - result[i] = ((TrackFragmentBox) getParent()).getTrackFragmentHeaderBox().getDefaultSampleSize(); - } - } - - return result; - } - - public long[] getSampleCompositionTimeOffsets() { - if (isSampleCompositionTimeOffsetPresent()) { - long[] result = new long[entries.size()]; - - for (int i = 0; i < result.length; i++) { - result[i] = entries.get(i).getSampleCompositionTimeOffset(); - } - return result; - } - return null; - } - - public long[] getSampleDurations() { - long[] result = new long[entries.size()]; - - for (int i = 0; i < result.length; i++) { - if (isSampleDurationPresent()) { - result[i] = entries.get(i).getSampleDuration(); - } else { - result[i] = ((TrackFragmentBox) getParent()).getTrackFragmentHeaderBox().getDefaultSampleDuration(); - } - } - - return result; - } - - public TrackRunBox() { - super(TYPE); - } - - protected long getContentSize() { - long size = 8; - int flags = getFlags(); - - if ((flags & 0x1) == 0x1) { //dataOffsetPresent - size += 4; - } - if ((flags & 0x4) == 0x4) { //firstSampleFlagsPresent - size += 4; - } - - long entrySize = 0; - if ((flags & 0x100) == 0x100) { //sampleDurationPresent - entrySize += 4; - } - if ((flags & 0x200) == 0x200) { //sampleSizePresent - entrySize += 4; - } - if ((flags & 0x400) == 0x400) { //sampleFlagsPresent - entrySize += 4; - } - if ((flags & 0x800) == 0x800) { //sampleCompositionTimeOffsetPresent - entrySize += 4; - } - size += entrySize * entries.size(); - return size; - } - - protected void getContent(ByteBuffer byteBuffer) { - writeVersionAndFlags(byteBuffer); - IsoTypeWriter.writeUInt32(byteBuffer, entries.size()); - int flags = getFlags(); - - if ((flags & 0x1) == 1) { //dataOffsetPresent - IsoTypeWriter.writeUInt32(byteBuffer, dataOffset); - } - if ((flags & 0x4) == 0x4) { //firstSampleFlagsPresent - firstSampleFlags.getContent(byteBuffer); - } - - for (Entry entry : entries) { - if ((flags & 0x100) == 0x100) { //sampleDurationPresent - IsoTypeWriter.writeUInt32(byteBuffer, entry.sampleDuration); - } - if ((flags & 0x200) == 0x200) { //sampleSizePresent - IsoTypeWriter.writeUInt32(byteBuffer, entry.sampleSize); - } - if ((flags & 0x400) == 0x400) { //sampleFlagsPresent - entry.sampleFlags.getContent(byteBuffer); - } - if ((flags & 0x800) == 0x800) { //sampleCompositionTimeOffsetPresent - byteBuffer.putInt(entry.sampleCompositionTimeOffset); - } - } - } - - @Override - public void _parseDetails(ByteBuffer content) { - parseVersionAndFlags(content); - long sampleCount = IsoTypeReader.readUInt32(content); - - if ((getFlags() & 0x1) == 1) { //dataOffsetPresent - dataOffset = l2i(IsoTypeReader.readUInt32(content)); - } else { - dataOffset = -1; - } - if ((getFlags() & 0x4) == 0x4) { //firstSampleFlagsPresent - firstSampleFlags = new SampleFlags(content); - } - - for (int i = 0; i < sampleCount; i++) { - Entry entry = new Entry(); - if ((getFlags() & 0x100) == 0x100) { //sampleDurationPresent - entry.sampleDuration = IsoTypeReader.readUInt32(content); - } - if ((getFlags() & 0x200) == 0x200) { //sampleSizePresent - entry.sampleSize = IsoTypeReader.readUInt32(content); - } - if ((getFlags() & 0x400) == 0x400) { //sampleFlagsPresent - entry.sampleFlags = new SampleFlags(content); - } - if ((getFlags() & 0x800) == 0x800) { //sampleCompositionTimeOffsetPresent - entry.sampleCompositionTimeOffset = content.getInt(); - } - entries.add(entry); - } - - } - - public long getSampleCount() { - return entries.size(); - } - - public boolean isDataOffsetPresent() { - return (getFlags() & 0x1) == 1; - } - - public boolean isFirstSampleFlagsPresent() { - return (getFlags() & 0x4) == 0x4; - } - - - public boolean isSampleSizePresent() { - return (getFlags() & 0x200) == 0x200; - } - - public boolean isSampleDurationPresent() { - return (getFlags() & 0x100) == 0x100; - } - - public boolean isSampleFlagsPresent() { - return (getFlags() & 0x400) == 0x400; - } - - public boolean isSampleCompositionTimeOffsetPresent() { - return (getFlags() & 0x800) == 0x800; - } - - public void setDataOffsetPresent(boolean v) { - if (v) { - setFlags(getFlags() | 0x01); - } else { - setFlags(getFlags() & (0xFFFFFF ^ 0x1)); - } - } - - public void setSampleSizePresent(boolean v) { - if (v) { - setFlags(getFlags() | 0x200); - } else { - setFlags(getFlags() & (0xFFFFFF ^ 0x200)); - } - } - - public void setSampleDurationPresent(boolean v) { - - if (v) { - setFlags(getFlags() | 0x100); - } else { - setFlags(getFlags() & (0xFFFFFF ^ 0x100)); - } - } - - public void setSampleFlagsPresent(boolean v) { - if (v) { - setFlags(getFlags() | 0x400); - } else { - setFlags(getFlags() & (0xFFFFFF ^ 0x400)); - } - } - - public void setSampleCompositionTimeOffsetPresent(boolean v) { - if (v) { - setFlags(getFlags() | 0x800); - } else { - setFlags(getFlags() & (0xFFFFFF ^ 0x800)); - } - - } - - public int getDataOffset() { - return dataOffset; - } - - public SampleFlags getFirstSampleFlags() { - return firstSampleFlags; - } - - public void setFirstSampleFlags(SampleFlags firstSampleFlags) { - if (firstSampleFlags == null) { - setFlags(getFlags() & (0xFFFFFF ^ 0x4)); - } else { - setFlags(getFlags() | 0x4); - } - this.firstSampleFlags = firstSampleFlags; - } - - @Override - public String toString() { - final StringBuilder sb = new StringBuilder(); - sb.append("TrackRunBox"); - sb.append("{sampleCount=").append(entries.size()); - sb.append(", dataOffset=").append(dataOffset); - sb.append(", dataOffsetPresent=").append(isDataOffsetPresent()); - sb.append(", sampleSizePresent=").append(isSampleSizePresent()); - sb.append(", sampleDurationPresent=").append(isSampleDurationPresent()); - sb.append(", sampleFlagsPresentPresent=").append(isSampleFlagsPresent()); - sb.append(", sampleCompositionTimeOffsetPresent=").append(isSampleCompositionTimeOffsetPresent()); - sb.append(", firstSampleFlags=").append(firstSampleFlags); - sb.append('}'); - return sb.toString(); - } - - public void setEntries(List entries) { - this.entries = entries; - } -} diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/h264/AvcConfigurationBox.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/h264/AvcConfigurationBox.java deleted file mode 100644 index 2350f901d..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/h264/AvcConfigurationBox.java +++ /dev/null @@ -1,285 +0,0 @@ -/* - * Copyright 2008 CoreMedia AG, Hamburg - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coremedia.iso.boxes.h264; - -import com.coremedia.iso.IsoTypeReader; -import com.coremedia.iso.IsoTypeWriter; -import com.googlecode.mp4parser.AbstractBox; -import com.googlecode.mp4parser.h264.model.PictureParameterSet; -import com.googlecode.mp4parser.h264.model.SeqParameterSet; - -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.nio.ByteBuffer; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -/** - * Defined in ISO/IEC 14496-15:2004. - */ -public final class AvcConfigurationBox extends AbstractBox { - public static final String TYPE = "avcC"; - - private int configurationVersion; - private int avcProfileIndicaation; - private int profileCompatibility; - private int avcLevelIndication; - private int lengthSizeMinusOne; - List sequenceParameterSets = new ArrayList(); - List pictureParameterSets = new ArrayList(); - - boolean hasExts = true; - private int chromaFormat = 1; - private int bitDepthLumaMinus8 = 0; - private int bitDepthChromaMinus8 = 0; - List sequenceParameterSetExts = new ArrayList(); - - public AvcConfigurationBox() { - super(TYPE); - } - - public int getConfigurationVersion() { - return configurationVersion; - } - - public int getAvcProfileIndicaation() { - return avcProfileIndicaation; - } - - public int getProfileCompatibility() { - return profileCompatibility; - } - - public int getAvcLevelIndication() { - return avcLevelIndication; - } - - public int getLengthSizeMinusOne() { - return lengthSizeMinusOne; - } - - public List getSequenceParameterSets() { - return Collections.unmodifiableList(sequenceParameterSets); - } - - public List getPictureParameterSets() { - return Collections.unmodifiableList(pictureParameterSets); - } - - public void setConfigurationVersion(int configurationVersion) { - this.configurationVersion = configurationVersion; - } - - public void setAvcProfileIndicaation(int avcProfileIndicaation) { - this.avcProfileIndicaation = avcProfileIndicaation; - } - - public void setProfileCompatibility(int profileCompatibility) { - this.profileCompatibility = profileCompatibility; - } - - public void setAvcLevelIndication(int avcLevelIndication) { - this.avcLevelIndication = avcLevelIndication; - } - - public void setLengthSizeMinusOne(int lengthSizeMinusOne) { - this.lengthSizeMinusOne = lengthSizeMinusOne; - } - - public void setSequenceParameterSets(List sequenceParameterSets) { - this.sequenceParameterSets = sequenceParameterSets; - } - - public void setPictureParameterSets(List pictureParameterSets) { - this.pictureParameterSets = pictureParameterSets; - } - - public int getChromaFormat() { - return chromaFormat; - } - - public void setChromaFormat(int chromaFormat) { - this.chromaFormat = chromaFormat; - } - - public int getBitDepthLumaMinus8() { - return bitDepthLumaMinus8; - } - - public void setBitDepthLumaMinus8(int bitDepthLumaMinus8) { - this.bitDepthLumaMinus8 = bitDepthLumaMinus8; - } - - public int getBitDepthChromaMinus8() { - return bitDepthChromaMinus8; - } - - public void setBitDepthChromaMinus8(int bitDepthChromaMinus8) { - this.bitDepthChromaMinus8 = bitDepthChromaMinus8; - } - - public List getSequenceParameterSetExts() { - return sequenceParameterSetExts; - } - - public void setSequenceParameterSetExts(List sequenceParameterSetExts) { - this.sequenceParameterSetExts = sequenceParameterSetExts; - } - - public boolean hasExts() { - return hasExts; - } - - public void setHasExts(boolean hasExts) { - this.hasExts = hasExts; - } - - @Override - public void _parseDetails(ByteBuffer content) { - configurationVersion = IsoTypeReader.readUInt8(content); - avcProfileIndicaation = IsoTypeReader.readUInt8(content); - profileCompatibility = IsoTypeReader.readUInt8(content); - avcLevelIndication = IsoTypeReader.readUInt8(content); - int temp = IsoTypeReader.readUInt8(content); - lengthSizeMinusOne = temp & 3; - long numberOfSeuqenceParameterSets = IsoTypeReader.readUInt8(content) & 31; - for (int i = 0; i < numberOfSeuqenceParameterSets; i++) { - int sequenceParameterSetLength = IsoTypeReader.readUInt16(content); - - byte[] sequenceParameterSetNALUnit = new byte[sequenceParameterSetLength]; - content.get(sequenceParameterSetNALUnit); - sequenceParameterSets.add(sequenceParameterSetNALUnit); - } - long numberOfPictureParameterSets = IsoTypeReader.readUInt8(content); - for (int i = 0; i < numberOfPictureParameterSets; i++) { - int pictureParameterSetLength = IsoTypeReader.readUInt16(content); - byte[] pictureParameterSetNALUnit = new byte[pictureParameterSetLength]; - content.get(pictureParameterSetNALUnit); - pictureParameterSets.add(pictureParameterSetNALUnit); - } - if (content.remaining() < 4) { - hasExts = false; - } - if (hasExts && (avcProfileIndicaation == 100 || avcProfileIndicaation == 110 || avcProfileIndicaation == 122 || avcProfileIndicaation == 144)) { - chromaFormat = IsoTypeReader.readUInt8(content) & 3; - bitDepthLumaMinus8 = IsoTypeReader.readUInt8(content) & 7; - bitDepthChromaMinus8 = IsoTypeReader.readUInt8(content) & 7; - long numOfSequenceParameterSetExt = IsoTypeReader.readUInt8(content); - for (int i = 0; i < numOfSequenceParameterSetExt; i++) { - int sequenceParameterSetExtLength = IsoTypeReader.readUInt16(content); - byte[] sequenceParameterSetExtNALUnit = new byte[sequenceParameterSetExtLength]; - content.get(sequenceParameterSetExtNALUnit); - sequenceParameterSetExts.add(sequenceParameterSetExtNALUnit); - } - } else { - chromaFormat = -1; - bitDepthLumaMinus8 = -1; - bitDepthChromaMinus8 = -1; - } - - } - - - public long getContentSize() { - long size = 5; - size += 1; // sequenceParamsetLength - for (byte[] sequenceParameterSetNALUnit : sequenceParameterSets) { - size += 2; //lengthSizeMinusOne field - size += sequenceParameterSetNALUnit.length; - } - size += 1; // pictureParamsetLength - for (byte[] pictureParameterSetNALUnit : pictureParameterSets) { - size += 2; //lengthSizeMinusOne field - size += pictureParameterSetNALUnit.length; - } - if (hasExts && (avcProfileIndicaation == 100 || avcProfileIndicaation == 110 || avcProfileIndicaation == 122 || avcProfileIndicaation == 144)) { - size += 4; - for (byte[] sequenceParameterSetExtNALUnit : sequenceParameterSetExts) { - size += 2; - size += sequenceParameterSetExtNALUnit.length; - } - } - - return size; - } - - - @Override - public void getContent(ByteBuffer byteBuffer) { - IsoTypeWriter.writeUInt8(byteBuffer, configurationVersion); - IsoTypeWriter.writeUInt8(byteBuffer, avcProfileIndicaation); - IsoTypeWriter.writeUInt8(byteBuffer, profileCompatibility); - IsoTypeWriter.writeUInt8(byteBuffer, avcLevelIndication); - IsoTypeWriter.writeUInt8(byteBuffer, lengthSizeMinusOne | (63 << 2)); - IsoTypeWriter.writeUInt8(byteBuffer, (pictureParameterSets.size() & 31) | (7 << 5)); - for (byte[] sequenceParameterSetNALUnit : sequenceParameterSets) { - IsoTypeWriter.writeUInt16(byteBuffer, sequenceParameterSetNALUnit.length); - byteBuffer.put(sequenceParameterSetNALUnit); - } - IsoTypeWriter.writeUInt8(byteBuffer, pictureParameterSets.size()); - for (byte[] pictureParameterSetNALUnit : pictureParameterSets) { - IsoTypeWriter.writeUInt16(byteBuffer, pictureParameterSetNALUnit.length); - byteBuffer.put(pictureParameterSetNALUnit); - } - if (hasExts && (avcProfileIndicaation == 100 || avcProfileIndicaation == 110 || avcProfileIndicaation == 122 || avcProfileIndicaation == 144)) { - IsoTypeWriter.writeUInt8(byteBuffer, chromaFormat | (63 << 2)); - IsoTypeWriter.writeUInt8(byteBuffer, bitDepthLumaMinus8 | (31 << 3)); - IsoTypeWriter.writeUInt8(byteBuffer, bitDepthChromaMinus8 | (31 << 3)); - IsoTypeWriter.writeUInt8(byteBuffer, sequenceParameterSetExts.size()); - for (byte[] sequenceParameterSetExtNALUnit : sequenceParameterSetExts) { - IsoTypeWriter.writeUInt16(byteBuffer, sequenceParameterSetExtNALUnit.length); - byteBuffer.put(sequenceParameterSetExtNALUnit); - } - } - } - - - // just to display sps in isoviewer no practical use - public String[] getPPS() { - ArrayList l = new ArrayList(); - for (byte[] pictureParameterSet : pictureParameterSets) { - String details = "not parsable"; - try { - details = PictureParameterSet.read(pictureParameterSet).toString(); - } catch (IOException e) { - throw new RuntimeException(e); - } - - l.add(details); - } - return l.toArray(new String[l.size()]); - } - - // just to display sps in isoviewer no practical use - public String[] getSPS() { - ArrayList l = new ArrayList(); - for (byte[] sequenceParameterSet : sequenceParameterSets) { - String detail = "not parsable"; - try { - detail = SeqParameterSet.read(new ByteArrayInputStream(sequenceParameterSet)).toString(); - } catch (IOException e) { - - } - l.add(detail); - } - return l.toArray(new String[l.size()]); - } - - -} - diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/mdat/DummyMap.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/mdat/DummyMap.java deleted file mode 100644 index ab960232c..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/mdat/DummyMap.java +++ /dev/null @@ -1,84 +0,0 @@ -package com.coremedia.iso.boxes.mdat; - -import java.util.Collection; -import java.util.Collections; -import java.util.Comparator; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - -/** - * A SortedSet that contains just one value. - */ -public class DummyMap implements Map { - HashSet keys = new HashSet(); - V value; - - public DummyMap(V value) { - this.value = value; - } - - public Comparator comparator() { - return null; // I don't have any - } - - public void addKeys(K[] keys) { - Collections.addAll(this.keys, keys); - - } - - public int size() { - return keys.size(); - } - - public boolean isEmpty() { - return keys.isEmpty(); - } - - public boolean containsKey(Object key) { - return keys.contains(key); - } - - public boolean containsValue(Object value) { - return this.value == value; - } - - public V get(Object key) { - return keys.contains(key) ? value : null; - } - - public V put(K key, V value) { - assert this.value == value; - keys.add(key); - return this.value; - } - - public V remove(Object key) { - V v = get(key); - keys.remove(key); - return v; - } - - public void putAll(Map m) { - for (K k : m.keySet()) { - assert m.get(k) == value; - this.keys.add(k); - } - } - - public void clear() { - keys.clear(); - } - - public Set keySet() { - return keys; - } - - public Collection values() { - throw new UnsupportedOperationException(); - } - - public Set> entrySet() { - throw new UnsupportedOperationException(); - } -} diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/mdat/MediaDataBox.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/mdat/MediaDataBox.java deleted file mode 100644 index 74f9f1838..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/mdat/MediaDataBox.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright 2008 CoreMedia AG, Hamburg - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coremedia.iso.boxes.mdat; - -import com.coremedia.iso.BoxParser; -import com.coremedia.iso.ChannelHelper; -import com.coremedia.iso.boxes.Box; -import com.coremedia.iso.boxes.ContainerBox; - -import java.io.IOException; -import java.nio.ByteBuffer; -import java.nio.channels.FileChannel; -import java.nio.channels.ReadableByteChannel; -import java.nio.channels.WritableByteChannel; - -import static com.googlecode.mp4parser.util.CastUtils.l2i; - -/** - * This box contains the media data. In video tracks, this box would contain video frames. A presentation may - * contain zero or more Media Data Boxes. The actual media data follows the type field; its structure is described - * by the metadata (see {@link com.coremedia.iso.boxes.SampleTableBox}).
    - * In large presentations, it may be desirable to have more data in this box than a 32-bit size would permit. In this - * case, the large variant of the size field is used.
    - * There may be any number of these boxes in the file (including zero, if all the media data is in other files). The - * metadata refers to media data by its absolute offset within the file (see {@link com.coremedia.iso.boxes.StaticChunkOffsetBox}); - * so Media Data Box headers and free space may easily be skipped, and files without any box structure may - * also be referenced and used. - */ -public final class MediaDataBox implements Box { - public static final String TYPE = "mdat"; - ContainerBox parent; - - ByteBuffer header; - ByteBuffer content; - - - public ContainerBox getParent() { - return parent; - } - - public void setParent(ContainerBox parent) { - this.parent = parent; - } - - public String getType() { - return TYPE; - } - - public void getBox(WritableByteChannel writableByteChannel) throws IOException { - header.rewind(); - content.rewind(); - writableByteChannel.write(header); - writableByteChannel.write(content); - } - - public long getSize() { - return header.limit() + content.limit(); - } - - public void parse(ReadableByteChannel readableByteChannel, ByteBuffer header, long contentSize, BoxParser boxParser) throws IOException { - this.header = header; - if (readableByteChannel instanceof FileChannel && contentSize > 1024 * 1024) { - // It's quite expensive to map a file into the memory. Just do it when the box is larger than a MB. - content = ((FileChannel) readableByteChannel).map(FileChannel.MapMode.READ_ONLY, ((FileChannel) readableByteChannel).position(), contentSize); - ((FileChannel) readableByteChannel).position(((FileChannel) readableByteChannel).position() + contentSize); - } else { - content = ChannelHelper.readFully(readableByteChannel, l2i(contentSize)); - } - - - } - - public ByteBuffer getContent() { - return content; - } - - public ByteBuffer getHeader() { - return header; - } -} diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/mdat/SampleList.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/mdat/SampleList.java deleted file mode 100644 index 2ee7becfa..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/mdat/SampleList.java +++ /dev/null @@ -1,194 +0,0 @@ -package com.coremedia.iso.boxes.mdat; - -import com.coremedia.iso.IsoFile; -import com.coremedia.iso.boxes.Box; -import com.coremedia.iso.boxes.ChunkOffsetBox; -import com.coremedia.iso.boxes.SampleSizeBox; -import com.coremedia.iso.boxes.SampleToChunkBox; -import com.coremedia.iso.boxes.TrackBox; -import com.coremedia.iso.boxes.fragment.MovieExtendsBox; -import com.coremedia.iso.boxes.fragment.MovieFragmentBox; -import com.coremedia.iso.boxes.fragment.TrackExtendsBox; -import com.coremedia.iso.boxes.fragment.TrackFragmentBox; -import com.coremedia.iso.boxes.fragment.TrackRunBox; - -import java.nio.ByteBuffer; -import java.util.AbstractList; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import static com.googlecode.mp4parser.util.CastUtils.l2i; - -/** - * Creates a list of ByteBuffers that represent the samples of a given track. - */ -public class SampleList extends AbstractList { - - Map offsets2Sizes; - List offsetKeys = null; - IsoFile isoFile; - HashMap mdatStartCache = new HashMap(); - HashMap mdatEndCache = new HashMap(); - ArrayList mdats = new ArrayList(1); - - /** - * Gets a sorted random access optimized list of all sample offsets. - * Basically it is a map from sample number to sample offset. - * - * @return the sorted list of sample offsets - */ - public List getOffsetKeys() { - if (offsetKeys == null) { - List offsetKeys = new ArrayList(offsets2Sizes.size()); - for (Long aLong : offsets2Sizes.keySet()) { - offsetKeys.add(aLong); - } - Collections.sort(offsetKeys); - this.offsetKeys = offsetKeys; - } - return offsetKeys; - } - - - public SampleList(TrackBox trackBox) { - this.isoFile = trackBox.getIsoFile(); // where are we? - offsets2Sizes = new HashMap(); - - // find all mdats first to be able to use them later with explicitly looking them up - long currentOffset = 0; - for (Box b : isoFile.getBoxes()) { - long currentSize = b.getSize(); - if ("mdat".equals(b.getType())) { - if (b instanceof MediaDataBox) { - long contentOffset = currentOffset + ((MediaDataBox) b).getHeader().limit(); - mdatStartCache.put((MediaDataBox) b, contentOffset); - mdatEndCache.put((MediaDataBox) b, contentOffset + currentSize); - mdats.add((MediaDataBox) b); - } else { - throw new RuntimeException("Sample need to be in mdats and mdats need to be instanceof MediaDataBox"); - } - } - currentOffset += currentSize; - } - - - // first we get all sample from the 'normal' MP4 part. - // if there are none - no problem. - - SampleSizeBox sampleSizeBox = trackBox.getSampleTableBox().getSampleSizeBox(); - ChunkOffsetBox chunkOffsetBox = trackBox.getSampleTableBox().getChunkOffsetBox(); - SampleToChunkBox sampleToChunkBox = trackBox.getSampleTableBox().getSampleToChunkBox(); - - - if (sampleToChunkBox != null && sampleToChunkBox.getEntries().size() > 0 && chunkOffsetBox != null && - chunkOffsetBox.getChunkOffsets().length > 0 && sampleSizeBox != null && sampleSizeBox.getSampleCount() > 0) { - long[] numberOfSamplesInChunk = sampleToChunkBox.blowup(chunkOffsetBox.getChunkOffsets().length); - if (sampleSizeBox.getSampleSize() > 0) { - // Every sample has the same size! - // no need to store each size separately - // this happens when people use raw audio formats in MP4 (are you stupid guys???) - offsets2Sizes = new DummyMap(sampleSizeBox.getSampleSize()); - long sampleSize = sampleSizeBox.getSampleSize(); - for (int i = 0; i < numberOfSamplesInChunk.length; i++) { - long thisChunksNumberOfSamples = numberOfSamplesInChunk[i]; - long sampleOffset = chunkOffsetBox.getChunkOffsets()[i]; - for (int j = 0; j < thisChunksNumberOfSamples; j++) { - offsets2Sizes.put(sampleOffset, sampleSize); - sampleOffset += sampleSize; - } - } - } else { - // the normal case where all samples have different sizes - int sampleIndex = 0; - long sampleSizes[] = sampleSizeBox.getSampleSizes(); - for (int i = 0; i < numberOfSamplesInChunk.length; i++) { - long thisChunksNumberOfSamples = numberOfSamplesInChunk[i]; - long sampleOffset = chunkOffsetBox.getChunkOffsets()[i]; - for (int j = 0; j < thisChunksNumberOfSamples; j++) { - long sampleSize = sampleSizes[sampleIndex]; - offsets2Sizes.put(sampleOffset, sampleSize); - sampleOffset += sampleSize; - sampleIndex++; - } - } - - } - } - - // Next we add all samples from the fragments - // in most cases - I've never seen it different it's either normal or fragmented. - - List movieExtendsBoxes = trackBox.getParent().getBoxes(MovieExtendsBox.class); - - if (movieExtendsBoxes.size() > 0) { - List trackExtendsBoxes = movieExtendsBoxes.get(0).getBoxes(TrackExtendsBox.class); - for (TrackExtendsBox trackExtendsBox : trackExtendsBoxes) { - if (trackExtendsBox.getTrackId() == trackBox.getTrackHeaderBox().getTrackId()) { - for (MovieFragmentBox movieFragmentBox : trackBox.getIsoFile().getBoxes(MovieFragmentBox.class)) { - offsets2Sizes.putAll(getOffsets(movieFragmentBox, trackBox.getTrackHeaderBox().getTrackId())); - } - } - } - } - - - // We have now a map from all sample offsets to their sizes - } - - - @Override - public int size() { - return offsets2Sizes.size(); - } - - - @Override - public ByteBuffer get(int index) { - // it is a two stage lookup: from index to offset to size - Long offset = getOffsetKeys().get(index); - int sampleSize = l2i(offsets2Sizes.get(offset)); - - for (MediaDataBox mediaDataBox : mdats) { - long start = mdatStartCache.get(mediaDataBox); - long end = mdatEndCache.get(mediaDataBox); - if ((start <= offset) && (offset + sampleSize <= end)) { - ByteBuffer bb = mediaDataBox.getContent(); - bb.position(l2i(offset - start)); - ByteBuffer sample = bb.slice(); - sample.limit(sampleSize); - return sample; - } - } - - throw new RuntimeException("The sample with offset " + offset + " and size " + sampleSize + " is NOT located within an mdat"); - } - - Map getOffsets(MovieFragmentBox moof, long trackId) { - Map offsets2Sizes = new HashMap(); - List traf = moof.getBoxes(TrackFragmentBox.class); - for (TrackFragmentBox trackFragmentBox : traf) { - if (trackFragmentBox.getTrackFragmentHeaderBox().getTrackId() == trackId) { - long baseDataOffset; - if (trackFragmentBox.getTrackFragmentHeaderBox().hasBaseDataOffset()) { - baseDataOffset = trackFragmentBox.getTrackFragmentHeaderBox().getBaseDataOffset(); - } else { - baseDataOffset = moof.getOffset(); - } - - for (TrackRunBox trun : trackFragmentBox.getBoxes(TrackRunBox.class)) { - long sampleBaseOffset = baseDataOffset + trun.getDataOffset(); - long[] sampleOffsets = trun.getSampleOffsets(); - long[] sampleSizes = trun.getSampleSizes(); - for (int i = 0; i < sampleSizes.length; i++) { - offsets2Sizes.put(sampleOffsets[i] + sampleBaseOffset, sampleSizes[i]); - } - } - } - } - return offsets2Sizes; - } - -} \ No newline at end of file diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/mdat/Segment.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/mdat/Segment.java deleted file mode 100644 index 5bee554d2..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/mdat/Segment.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.coremedia.iso.boxes.mdat; - -public class Segment { - public Segment(long offset, long size) { - this.offset = offset; - this.size = size; - } - - public long offset; - public long size; - -} \ No newline at end of file diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/odf-boxes.zip b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/odf-boxes.zip deleted file mode 100644 index 04e0e5e1b..000000000 Binary files a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/odf-boxes.zip and /dev/null differ diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/rtp-boxes.zip b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/rtp-boxes.zip deleted file mode 100644 index be1a16761..000000000 Binary files a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/rtp-boxes.zip and /dev/null differ diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/sampleentry/AmrSpecificBox.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/sampleentry/AmrSpecificBox.java deleted file mode 100644 index f69de7baf..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/sampleentry/AmrSpecificBox.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Copyright 2008 CoreMedia AG, Hamburg - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coremedia.iso.boxes.sampleentry; - - -import com.coremedia.iso.IsoFile; -import com.coremedia.iso.IsoTypeReader; -import com.coremedia.iso.IsoTypeWriter; -import com.googlecode.mp4parser.AbstractBox; - -import java.nio.ByteBuffer; - -/** - * AMR audio format specific subbox of an audio sample entry. - * - * @see com.coremedia.iso.boxes.sampleentry.AudioSampleEntry - */ -public class AmrSpecificBox extends AbstractBox { - public static final String TYPE = "damr"; - - private String vendor; - private int decoderVersion; - private int modeSet; - private int modeChangePeriod; - private int framesPerSample; - - public AmrSpecificBox() { - super(TYPE); - } - - public String getVendor() { - return vendor; - } - - public int getDecoderVersion() { - return decoderVersion; - } - - public int getModeSet() { - return modeSet; - } - - public int getModeChangePeriod() { - return modeChangePeriod; - } - - public int getFramesPerSample() { - return framesPerSample; - } - - protected long getContentSize() { - return 9; - } - - @Override - public void _parseDetails(ByteBuffer content) { - byte[] v = new byte[4]; - content.get(v); - vendor = IsoFile.bytesToFourCC(v); - - decoderVersion = IsoTypeReader.readUInt8(content); - modeSet = IsoTypeReader.readUInt16(content); - modeChangePeriod = IsoTypeReader.readUInt8(content); - framesPerSample = IsoTypeReader.readUInt8(content); - - } - - - public void getContent(ByteBuffer byteBuffer) { - byteBuffer.put(IsoFile.fourCCtoBytes(vendor)); - IsoTypeWriter.writeUInt8(byteBuffer, decoderVersion); - IsoTypeWriter.writeUInt16(byteBuffer, modeSet); - IsoTypeWriter.writeUInt8(byteBuffer, modeChangePeriod); - IsoTypeWriter.writeUInt8(byteBuffer, framesPerSample); - } - - public String toString() { - StringBuilder buffer = new StringBuilder(); - buffer.append("AmrSpecificBox[vendor=").append(getVendor()); - buffer.append(";decoderVersion=").append(getDecoderVersion()); - buffer.append(";modeSet=").append(getModeSet()); - buffer.append(";modeChangePeriod=").append(getModeChangePeriod()); - buffer.append(";framesPerSample=").append(getFramesPerSample()); - buffer.append("]"); - return buffer.toString(); - } -} diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/sampleentry/AudioSampleEntry.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/sampleentry/AudioSampleEntry.java deleted file mode 100644 index 23c1ba727..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/sampleentry/AudioSampleEntry.java +++ /dev/null @@ -1,251 +0,0 @@ -/* - * Copyright 2008 CoreMedia AG, Hamburg - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coremedia.iso.boxes.sampleentry; - -import com.coremedia.iso.BoxParser; -import com.coremedia.iso.IsoTypeReader; -import com.coremedia.iso.IsoTypeWriter; -import com.coremedia.iso.boxes.Box; -import com.coremedia.iso.boxes.ContainerBox; - -import java.nio.ByteBuffer; - -/** - * Contains basic information about the audio samples in this track. Format-specific information - * is appened as boxes after the data described in ISO/IEC 14496-12 chapter 8.16.2. - */ -public class AudioSampleEntry extends SampleEntry implements ContainerBox { - - public static final String TYPE1 = "samr"; - public static final String TYPE2 = "sawb"; - public static final String TYPE3 = "mp4a"; - public static final String TYPE4 = "drms"; - public static final String TYPE5 = "alac"; - public static final String TYPE7 = "owma"; - public static final String TYPE8 = "ac-3"; /* ETSI TS 102 366 1.2.1 Annex F */ - public static final String TYPE9 = "ec-3"; /* ETSI TS 102 366 1.2.1 Annex F */ - public static final String TYPE10 = "mlpa"; - - /** - * Identifier for an encrypted audio track. - * - * @see com.coremedia.iso.boxes.ProtectionSchemeInformationBox - */ - public static final String TYPE_ENCRYPTED = "enca"; - - private int channelCount; - private int sampleSize; - private long sampleRate; - private int soundVersion; - private int compressionId; - private int packetSize; - private long samplesPerPacket; - private long bytesPerPacket; - private long bytesPerFrame; - private long bytesPerSample; - - private int reserved1; - private long reserved2; - private byte[] soundVersion2Data; - private BoxParser boxParser; - - public AudioSampleEntry(String type) { - super(type); - } - - public int getChannelCount() { - return channelCount; - } - - public int getSampleSize() { - return sampleSize; - } - - public long getSampleRate() { - return sampleRate; - } - - public int getSoundVersion() { - return soundVersion; - } - - public int getCompressionId() { - return compressionId; - } - - public int getPacketSize() { - return packetSize; - } - - public long getSamplesPerPacket() { - return samplesPerPacket; - } - - public long getBytesPerPacket() { - return bytesPerPacket; - } - - public long getBytesPerFrame() { - return bytesPerFrame; - } - - public long getBytesPerSample() { - return bytesPerSample; - } - - public void setChannelCount(int channelCount) { - this.channelCount = channelCount; - } - - public void setSampleSize(int sampleSize) { - this.sampleSize = sampleSize; - } - - public void setSampleRate(long sampleRate) { - this.sampleRate = sampleRate; - } - - public void setSoundVersion(int soundVersion) { - this.soundVersion = soundVersion; - } - - public void setCompressionId(int compressionId) { - this.compressionId = compressionId; - } - - public void setPacketSize(int packetSize) { - this.packetSize = packetSize; - } - - public void setSamplesPerPacket(long samplesPerPacket) { - this.samplesPerPacket = samplesPerPacket; - } - - public void setBytesPerPacket(long bytesPerPacket) { - this.bytesPerPacket = bytesPerPacket; - } - - public void setBytesPerFrame(long bytesPerFrame) { - this.bytesPerFrame = bytesPerFrame; - } - - public void setBytesPerSample(long bytesPerSample) { - this.bytesPerSample = bytesPerSample; - } - - public void setReserved1(int reserved1) { - this.reserved1 = reserved1; - } - - public void setReserved2(long reserved2) { - this.reserved2 = reserved2; - } - - public void setSoundVersion2Data(byte[] soundVersion2Data) { - this.soundVersion2Data = soundVersion2Data; - } - - public void setBoxParser(BoxParser boxParser) { - this.boxParser = boxParser; - } - - @Override - public void _parseDetails(ByteBuffer content) { - _parseReservedAndDataReferenceIndex(content); //parses the six reserved bytes and dataReferenceIndex - // 8 bytes already parsed - //reserved bits - used by qt - soundVersion = IsoTypeReader.readUInt16(content); - - //reserved - reserved1 = IsoTypeReader.readUInt16(content); - reserved2 = IsoTypeReader.readUInt32(content); - - channelCount = IsoTypeReader.readUInt16(content); - sampleSize = IsoTypeReader.readUInt16(content); - //reserved bits - used by qt - compressionId = IsoTypeReader.readUInt16(content); - //reserved bits - used by qt - packetSize = IsoTypeReader.readUInt16(content); - //sampleRate = in.readFixedPoint1616(); - sampleRate = IsoTypeReader.readUInt32(content); - if (!type.equals("mlpa")) { - sampleRate = sampleRate >>> 16; - } - - //more qt stuff - see http://mp4v2.googlecode.com/svn-history/r388/trunk/src/atom_sound.cpp - if (soundVersion > 0) { - samplesPerPacket = IsoTypeReader.readUInt32(content); - bytesPerPacket = IsoTypeReader.readUInt32(content); - bytesPerFrame = IsoTypeReader.readUInt32(content); - bytesPerSample = IsoTypeReader.readUInt32(content); - } - if (soundVersion == 2) { - - soundVersion2Data = new byte[20]; - content.get(20); - } - _parseChildBoxes(content); - - } - - - @Override - protected long getContentSize() { - long contentSize = 28; - contentSize += soundVersion > 0 ? 16 : 0; - contentSize += soundVersion == 2 ? 20 : 0; - for (Box boxe : boxes) { - contentSize += boxe.getSize(); - } - return contentSize; - } - - - public String toString() { - return "AudioSampleEntry"; - } - - @Override - protected void getContent(ByteBuffer byteBuffer) { - _writeReservedAndDataReferenceIndex(byteBuffer); - IsoTypeWriter.writeUInt16(byteBuffer, soundVersion); - IsoTypeWriter.writeUInt16(byteBuffer, reserved1); - IsoTypeWriter.writeUInt32(byteBuffer, reserved2); - IsoTypeWriter.writeUInt16(byteBuffer, channelCount); - IsoTypeWriter.writeUInt16(byteBuffer, sampleSize); - IsoTypeWriter.writeUInt16(byteBuffer, compressionId); - IsoTypeWriter.writeUInt16(byteBuffer, packetSize); - //isos.writeFixedPont1616(getSampleRate()); - if (type.equals("mlpa")) { - IsoTypeWriter.writeUInt32(byteBuffer, getSampleRate()); - } else { - IsoTypeWriter.writeUInt32(byteBuffer, getSampleRate() << 16); - } - - if (soundVersion > 0) { - IsoTypeWriter.writeUInt32(byteBuffer, samplesPerPacket); - IsoTypeWriter.writeUInt32(byteBuffer, bytesPerPacket); - IsoTypeWriter.writeUInt32(byteBuffer, bytesPerFrame); - IsoTypeWriter.writeUInt32(byteBuffer, bytesPerSample); - } - - if (soundVersion == 2) { - byteBuffer.put(soundVersion2Data); - } - _writeChildBoxes(byteBuffer); - } -} diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/sampleentry/MpegSampleEntry.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/sampleentry/MpegSampleEntry.java deleted file mode 100644 index 53a4e541e..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/sampleentry/MpegSampleEntry.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.coremedia.iso.boxes.sampleentry; - -import com.coremedia.iso.BoxParser; -import com.coremedia.iso.boxes.Box; -import com.coremedia.iso.boxes.ContainerBox; - -import java.nio.ByteBuffer; -import java.util.Arrays; - -public class MpegSampleEntry extends SampleEntry implements ContainerBox { - - private BoxParser boxParser; - - public MpegSampleEntry(String type) { - super(type); - } - - @Override - public void _parseDetails(ByteBuffer content) { - _parseReservedAndDataReferenceIndex(content); - _parseChildBoxes(content); - - } - - @Override - protected long getContentSize() { - long contentSize = 8; - for (Box boxe : boxes) { - contentSize += boxe.getSize(); - } - return contentSize; - } - - public String toString() { - return "MpegSampleEntry" + Arrays.asList(getBoxes()); - } - - @Override - protected void getContent(ByteBuffer byteBuffer) { - _writeReservedAndDataReferenceIndex(byteBuffer); - _writeChildBoxes(byteBuffer); - } -} diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/sampleentry/Ovc1VisualSampleEntryImpl.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/sampleentry/Ovc1VisualSampleEntryImpl.java deleted file mode 100644 index 56b8adb45..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/sampleentry/Ovc1VisualSampleEntryImpl.java +++ /dev/null @@ -1,45 +0,0 @@ -package com.coremedia.iso.boxes.sampleentry; - -import com.coremedia.iso.IsoTypeWriter; -import com.coremedia.iso.boxes.Box; - -import java.nio.ByteBuffer; - - -public class Ovc1VisualSampleEntryImpl extends SampleEntry { - private byte[] vc1Content; - public static final String TYPE = "ovc1"; - - - @Override - protected long getContentSize() { - long size = 8; - - for (Box box : boxes) { - size += box.getSize(); - } - size += vc1Content.length; - return size; - } - - @Override - public void _parseDetails(ByteBuffer content) { - _parseReservedAndDataReferenceIndex(content); - vc1Content = new byte[content.remaining()]; - content.get(vc1Content); - - } - - @Override - protected void getContent(ByteBuffer byteBuffer) { - byteBuffer.put(new byte[6]); - IsoTypeWriter.writeUInt16(byteBuffer, getDataReferenceIndex()); - byteBuffer.put(vc1Content); - } - - - protected Ovc1VisualSampleEntryImpl() { - super(TYPE); - } - -} diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/sampleentry/SampleEntry.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/sampleentry/SampleEntry.java deleted file mode 100644 index 9b0ac1a73..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/sampleentry/SampleEntry.java +++ /dev/null @@ -1,157 +0,0 @@ -/* - * Copyright 2008 CoreMedia AG, Hamburg - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coremedia.iso.boxes.sampleentry; - -import com.coremedia.iso.BoxParser; -import com.coremedia.iso.IsoTypeReader; -import com.coremedia.iso.IsoTypeWriter; -import com.googlecode.mp4parser.AbstractBox; -import com.coremedia.iso.boxes.Box; -import com.coremedia.iso.boxes.ContainerBox; -import com.googlecode.mp4parser.util.ByteBufferByteChannel; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.nio.ByteBuffer; -import java.nio.channels.Channels; -import java.nio.channels.ReadableByteChannel; -import java.nio.channels.WritableByteChannel; -import java.util.ArrayList; -import java.util.LinkedList; -import java.util.List; - -/** - * Abstract base class for all sample entries. - * - * @see com.coremedia.iso.boxes.sampleentry.AudioSampleEntry - * @see com.coremedia.iso.boxes.sampleentry.VisualSampleEntry - * @see com.coremedia.iso.boxes.sampleentry.TextSampleEntry - */ -public abstract class SampleEntry extends AbstractBox implements ContainerBox { - - - private int dataReferenceIndex; - protected List boxes = new LinkedList(); - private BoxParser boxParser; - - - protected SampleEntry(String type) { - super(type); - } - - public void setType(String type) { - this.type = type; - } - - public int getDataReferenceIndex() { - return dataReferenceIndex; - } - - public void setDataReferenceIndex(int dataReferenceIndex) { - this.dataReferenceIndex = dataReferenceIndex; - } - - public void setBoxes(List boxes) { - this.boxes = new LinkedList(boxes); - } - - public void addBox(AbstractBox b) { - boxes.add(b); - } - - public boolean removeBox(Box b) { - return boxes.remove(b); - } - - public List getBoxes() { - return boxes; - } - - @SuppressWarnings("unchecked") - public List getBoxes(Class clazz, boolean recursive) { - List boxesToBeReturned = new ArrayList(2); - for (Box boxe : boxes) { //clazz.isInstance(boxe) / clazz == boxe.getClass()? - if (clazz == boxe.getClass()) { - boxesToBeReturned.add((T) boxe); - } - - if (recursive && boxe instanceof ContainerBox) { - boxesToBeReturned.addAll(((ContainerBox) boxe).getBoxes(clazz, recursive)); - } - } - // Optimize here! Spare object creation work on arrays directly! System.arrayCopy - return boxesToBeReturned; - //return (T[]) boxesToBeReturned.toArray(); - } - - @SuppressWarnings("unchecked") - public List getBoxes(Class clazz) { - return getBoxes(clazz, false); - } - - @Override - public void parse(ReadableByteChannel readableByteChannel, ByteBuffer header, long contentSize, BoxParser boxParser) throws IOException { - super.parse(readableByteChannel, header, contentSize, boxParser); - this.boxParser = boxParser; - } - - - public void _parseReservedAndDataReferenceIndex(ByteBuffer content) { - content.get(new byte[6]); // ignore 6 reserved bytes; - dataReferenceIndex = IsoTypeReader.readUInt16(content); - } - - public void _parseChildBoxes(ByteBuffer content) { - while (content.remaining() > 8) { - try { - boxes.add(boxParser.parseBox(new ByteBufferByteChannel(content), this)); - } catch (IOException e) { - throw new RuntimeException(e); - } - - } - setDeadBytes(content.slice()); - } - - public void _writeReservedAndDataReferenceIndex(ByteBuffer bb) { - bb.put(new byte[6]); - IsoTypeWriter.writeUInt16(bb, dataReferenceIndex); - } - - public void _writeChildBoxes(ByteBuffer bb) { - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - WritableByteChannel wbc = Channels.newChannel(baos); - try { - for (Box box : boxes) { - box.getBox(wbc); - } - wbc.close(); - } catch (IOException e) { - throw new RuntimeException("Cannot happen. Everything should be in memory and therefore no exceptions."); - } - bb.put(baos.toByteArray()); - } - - public long getNumOfBytesToFirstChild() { - long sizeOfChildren = 0; - for (Box box : boxes) { - sizeOfChildren += box.getSize(); - } - return getSize() - sizeOfChildren; - } - -} diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/sampleentry/SubtitleSampleEntry.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/sampleentry/SubtitleSampleEntry.java deleted file mode 100644 index 21d0cc41a..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/sampleentry/SubtitleSampleEntry.java +++ /dev/null @@ -1,76 +0,0 @@ -package com.coremedia.iso.boxes.sampleentry; - -import com.coremedia.iso.IsoTypeReader; -import com.coremedia.iso.IsoTypeWriter; - -import java.nio.ByteBuffer; - -/** - * Created by IntelliJ IDEA. - * User: magnus - * Date: 2012-03-08 - * Time: 11:36 - * To change this template use File | Settings | File Templates. - */ -public class SubtitleSampleEntry extends SampleEntry { - - public static final String TYPE1 = "stpp"; - - public static final String TYPE_ENCRYPTED = ""; // This is not known! - - private String namespace; - private String schemaLocation; - private String imageMimeType; - - public SubtitleSampleEntry(String type) { - super(type); - } - - @Override - protected long getContentSize() { - long contentSize = 8 + namespace.length() + schemaLocation.length() + imageMimeType.length() + 3; - return contentSize; - } - - @Override - public void _parseDetails(ByteBuffer content) { - _parseReservedAndDataReferenceIndex(content); - namespace = IsoTypeReader.readString(content); - schemaLocation = IsoTypeReader.readString(content); - imageMimeType = IsoTypeReader.readString(content); - _parseChildBoxes(content); - } - - @Override - protected void getContent(ByteBuffer byteBuffer) { - _writeReservedAndDataReferenceIndex(byteBuffer); - IsoTypeWriter.writeUtf8String(byteBuffer, namespace); - IsoTypeWriter.writeUtf8String(byteBuffer, schemaLocation); - IsoTypeWriter.writeUtf8String(byteBuffer, imageMimeType); - } - - public String getNamespace() { - return namespace; - } - - public void setNamespace(String namespace) { - this.namespace = namespace; - } - - public String getSchemaLocation() { - return schemaLocation; - } - - public void setSchemaLocation(String schemaLocation) { - this.schemaLocation = schemaLocation; - } - - public String getImageMimeType() { - return imageMimeType; - } - - public void setImageMimeType(String imageMimeType) { - this.imageMimeType = imageMimeType; - } -} - diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/sampleentry/TextSampleEntry.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/sampleentry/TextSampleEntry.java deleted file mode 100644 index 3a0b83a13..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/sampleentry/TextSampleEntry.java +++ /dev/null @@ -1,305 +0,0 @@ -/* - * Copyright 2008 CoreMedia AG, Hamburg - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coremedia.iso.boxes.sampleentry; - -import com.coremedia.iso.IsoTypeReader; -import com.coremedia.iso.IsoTypeWriter; -import com.coremedia.iso.boxes.Box; - -import java.io.IOException; -import java.nio.ByteBuffer; - -/** - * Entry type for timed text samples defined in the timed text specification (ISO/IEC 14496-17). - */ -public class TextSampleEntry extends SampleEntry { - - public static final String TYPE1 = "tx3g"; - - public static final String TYPE_ENCRYPTED = "enct"; - -/* class TextSampleEntry() extends SampleEntry ('tx3g') { - unsigned int(32) displayFlags; - signed int(8) horizontal-justification; - signed int(8) vertical-justification; - unsigned int(8) background-color-rgba[4]; - BoxRecord default-text-box; - StyleRecord default-style; - FontTableBox font-table; - } - */ - - private long displayFlags; // 32 bits - private int horizontalJustification; // 8 bit - private int verticalJustification; // 8 bit - private int[] backgroundColorRgba = new int[4]; // 4 bytes - private BoxRecord boxRecord = new BoxRecord(); - private StyleRecord styleRecord = new StyleRecord(); - - public TextSampleEntry(String type) { - super(type); - } - - @Override - public void _parseDetails(ByteBuffer content) { - _parseReservedAndDataReferenceIndex(content); - displayFlags = IsoTypeReader.readUInt32(content); - horizontalJustification = IsoTypeReader.readUInt8(content); - verticalJustification = IsoTypeReader.readUInt8(content); - backgroundColorRgba = new int[4]; - backgroundColorRgba[0] = IsoTypeReader.readUInt8(content); - backgroundColorRgba[1] = IsoTypeReader.readUInt8(content); - backgroundColorRgba[2] = IsoTypeReader.readUInt8(content); - backgroundColorRgba[3] = IsoTypeReader.readUInt8(content); - boxRecord = new BoxRecord(); - boxRecord.parse(content); - - styleRecord = new StyleRecord(); - styleRecord.parse(content); - _parseChildBoxes(content); - } - - - protected long getContentSize() { - long contentSize = 18; - contentSize += boxRecord.getSize(); - contentSize += styleRecord.getSize(); - for (Box boxe : boxes) { - contentSize += boxe.getSize(); - } - return contentSize; - } - - public String toString() { - return "TextSampleEntry"; - } - - @Override - protected void getContent(ByteBuffer byteBuffer) { - _writeReservedAndDataReferenceIndex(byteBuffer); - IsoTypeWriter.writeUInt32(byteBuffer, displayFlags); - IsoTypeWriter.writeUInt8(byteBuffer, horizontalJustification); - IsoTypeWriter.writeUInt8(byteBuffer, verticalJustification); - IsoTypeWriter.writeUInt8(byteBuffer, backgroundColorRgba[0]); - IsoTypeWriter.writeUInt8(byteBuffer, backgroundColorRgba[1]); - IsoTypeWriter.writeUInt8(byteBuffer, backgroundColorRgba[2]); - IsoTypeWriter.writeUInt8(byteBuffer, backgroundColorRgba[3]); - boxRecord.getContent(byteBuffer); - styleRecord.getContent(byteBuffer); - - _writeChildBoxes(byteBuffer); - } - - public BoxRecord getBoxRecord() { - return boxRecord; - } - - public void setBoxRecord(BoxRecord boxRecord) { - this.boxRecord = boxRecord; - } - - public StyleRecord getStyleRecord() { - return styleRecord; - } - - public void setStyleRecord(StyleRecord styleRecord) { - this.styleRecord = styleRecord; - } - - public boolean isScrollIn() { - return (displayFlags & 0x00000020) == 0x00000020; - } - - public void setScrollIn(boolean scrollIn) { - if (scrollIn) { - displayFlags |= 0x00000020; - } else { - displayFlags &= ~0x00000020; - } - } - - public boolean isScrollOut() { - return (displayFlags & 0x00000040) == 0x00000040; - } - - public void setScrollOut(boolean scrollOutIn) { - if (scrollOutIn) { - displayFlags |= 0x00000040; - } else { - displayFlags &= ~0x00000040; - } - } - - public boolean isScrollDirection() { - return (displayFlags & 0x00000180) == 0x00000180; - } - - public void setScrollDirection(boolean scrollOutIn) { - if (scrollOutIn) { - displayFlags |= 0x00000180; - } else { - displayFlags &= ~0x00000180; - } - } - - public boolean isContinuousKaraoke() { - return (displayFlags & 0x00000800) == 0x00000800; - } - - public void setContinuousKaraoke(boolean continuousKaraoke) { - if (continuousKaraoke) { - displayFlags |= 0x00000800; - } else { - displayFlags &= ~0x00000800; - } - } - - public boolean isWriteTextVertically() { - return (displayFlags & 0x00020000) == 0x00020000; - } - - public void setWriteTextVertically(boolean writeTextVertically) { - if (writeTextVertically) { - displayFlags |= 0x00020000; - } else { - displayFlags &= ~0x00020000; - } - } - - - public boolean isFillTextRegion() { - return (displayFlags & 0x00040000) == 0x00040000; - } - - public void setFillTextRegion(boolean fillTextRegion) { - if (fillTextRegion) { - displayFlags |= 0x00040000; - } else { - displayFlags &= ~0x00040000; - } - } - - - public int getHorizontalJustification() { - return horizontalJustification; - } - - public void setHorizontalJustification(int horizontalJustification) { - this.horizontalJustification = horizontalJustification; - } - - public int getVerticalJustification() { - return verticalJustification; - } - - public void setVerticalJustification(int verticalJustification) { - this.verticalJustification = verticalJustification; - } - - public int[] getBackgroundColorRgba() { - return backgroundColorRgba; - } - - public void setBackgroundColorRgba(int[] backgroundColorRgba) { - this.backgroundColorRgba = backgroundColorRgba; - } - - public static class BoxRecord { - int top; - int left; - int bottom; - int right; - - public void parse(ByteBuffer in) { - top = IsoTypeReader.readUInt16(in); - left = IsoTypeReader.readUInt16(in); - bottom = IsoTypeReader.readUInt16(in); - right = IsoTypeReader.readUInt16(in); - } - - public void getContent(ByteBuffer bb) { - IsoTypeWriter.writeUInt16(bb, top); - IsoTypeWriter.writeUInt16(bb, left); - IsoTypeWriter.writeUInt16(bb, bottom); - IsoTypeWriter.writeUInt16(bb, right); - } - - public int getSize() { - return 8; - } - } - - /* - class FontRecord { - unsigned int(16) font-ID; - unsigned int(8) font-name-length; - unsigned int(8) font[font-name-length]; -} - */ - - - /* - aligned(8) class StyleRecord { - unsigned int(16) startChar; - unsigned int(16) endChar; - unsigned int(16) font-ID; - unsigned int(8) face-style-flags; - unsigned int(8) font-size; - unsigned int(8) text-color-rgba[4]; -} - */ - public static class StyleRecord { - int startChar; - int endChar; - int fontId; - int faceStyleFlags; - int fontSize; - int[] textColor = new int[]{0xff, 0xff, 0xff, 0xff}; - - public void parse(ByteBuffer in) { - startChar = IsoTypeReader.readUInt16(in); - endChar = IsoTypeReader.readUInt16(in); - fontId = IsoTypeReader.readUInt16(in); - faceStyleFlags = IsoTypeReader.readUInt8(in); - fontSize = IsoTypeReader.readUInt8(in); - textColor = new int[4]; - textColor[0] = IsoTypeReader.readUInt8(in); - textColor[1] = IsoTypeReader.readUInt8(in); - textColor[2] = IsoTypeReader.readUInt8(in); - textColor[3] = IsoTypeReader.readUInt8(in); - } - - - public void getContent(ByteBuffer bb) { - IsoTypeWriter.writeUInt16(bb, startChar); - IsoTypeWriter.writeUInt16(bb, endChar); - IsoTypeWriter.writeUInt16(bb, fontId); - IsoTypeWriter.writeUInt8(bb, faceStyleFlags); - IsoTypeWriter.writeUInt8(bb, fontSize); - IsoTypeWriter.writeUInt8(bb, textColor[0]); - IsoTypeWriter.writeUInt8(bb, textColor[1]); - IsoTypeWriter.writeUInt8(bb, textColor[2]); - IsoTypeWriter.writeUInt8(bb, textColor[3]); - } - - public int getSize() { - return 12; - } - } - - -} diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/sampleentry/VisualSampleEntry.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/sampleentry/VisualSampleEntry.java deleted file mode 100644 index 2d4b49631..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/sampleentry/VisualSampleEntry.java +++ /dev/null @@ -1,213 +0,0 @@ -/* - * Copyright 2008 CoreMedia AG, Hamburg - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coremedia.iso.boxes.sampleentry; - -import com.coremedia.iso.IsoTypeReader; -import com.coremedia.iso.IsoTypeWriter; -import com.coremedia.iso.Utf8; -import com.coremedia.iso.boxes.Box; -import com.coremedia.iso.boxes.ContainerBox; - -import java.nio.ByteBuffer; - -/** - * Contains information common to all visual tracks. - * - *
    - * class VisualSampleEntry(codingname) extends SampleEntry (codingname){
    - * unsigned int(16) pre_defined = 0;
    - * const unsigned int(16) reserved = 0;
    - * unsigned int(32)[3] pre_defined = 0;
    - * unsigned int(16) width;
    - * unsigned int(16) height;
    - * template unsigned int(32) horizresolution = 0x00480000; // 72 dpi
    - * template unsigned int(32) vertresolution = 0x00480000; // 72 dpi
    - * const unsigned int(32) reserved = 0;
    - * template unsigned int(16) frame_count = 1;
    - * string[32] compressorname;
    - * template unsigned int(16) depth = 0x0018;
    - * int(16) pre_defined = -1;
    - * }
    - *
    - *
    - *

    - * Format-specific informationis appened as boxes after the data described in ISO/IEC 14496-12 chapter 8.16.2. - */ -public class VisualSampleEntry extends SampleEntry implements ContainerBox { - public static final String TYPE1 = "mp4v"; - public static final String TYPE2 = "s263"; - public static final String TYPE3 = "avc1"; - - - /** - * Identifier for an encrypted video track. - * - * @see com.coremedia.iso.boxes.ProtectionSchemeInformationBox - */ - public static final String TYPE_ENCRYPTED = "encv"; - - - private int width; - private int height; - private double horizresolution; - private double vertresolution; - private int frameCount; - private String compressorname; - private int depth; - - private long[] predefined = new long[3]; - - public VisualSampleEntry(String type) { - super(type); - } - - public int getWidth() { - return width; - } - - public int getHeight() { - return height; - } - - public double getHorizresolution() { - return horizresolution; - } - - public double getVertresolution() { - return vertresolution; - } - - public int getFrameCount() { - return frameCount; - } - - public String getCompressorname() { - return compressorname; - } - - public int getDepth() { - return depth; - } - - public void setCompressorname(String compressorname) { - this.compressorname = compressorname; - } - - public void setWidth(int width) { - this.width = width; - } - - public void setHeight(int height) { - this.height = height; - } - - public void setHorizresolution(double horizresolution) { - this.horizresolution = horizresolution; - } - - public void setVertresolution(double vertresolution) { - this.vertresolution = vertresolution; - } - - public void setFrameCount(int frameCount) { - this.frameCount = frameCount; - } - - public void setDepth(int depth) { - this.depth = depth; - } - - @Override - public void _parseDetails(ByteBuffer content) { - _parseReservedAndDataReferenceIndex(content); - long tmp = IsoTypeReader.readUInt16(content); - assert 0 == tmp : "reserved byte not 0"; - tmp = IsoTypeReader.readUInt16(content); - assert 0 == tmp : "reserved byte not 0"; - predefined[0] = IsoTypeReader.readUInt32(content); // should be zero - predefined[1] = IsoTypeReader.readUInt32(content); // should be zero - predefined[2] = IsoTypeReader.readUInt32(content); // should be zero - width = IsoTypeReader.readUInt16(content); - height = IsoTypeReader.readUInt16(content); - horizresolution = IsoTypeReader.readFixedPoint1616(content); - vertresolution = IsoTypeReader.readFixedPoint1616(content); - tmp = IsoTypeReader.readUInt32(content); - assert 0 == tmp : "reserved byte not 0"; - frameCount = IsoTypeReader.readUInt16(content); - int compressornameDisplayAbleData = IsoTypeReader.readUInt8(content); - if (compressornameDisplayAbleData > 31) { - System.out.println("invalid compressor name displayable data: " + compressornameDisplayAbleData); - compressornameDisplayAbleData = 31; - } - byte[] bytes = new byte[compressornameDisplayAbleData]; - content.get(bytes); - compressorname = Utf8.convert(bytes); - if (compressornameDisplayAbleData < 31) { - byte[] zeros = new byte[31 - compressornameDisplayAbleData]; - content.get(zeros); - //assert Arrays.equals(zeros, new byte[zeros.length]) : "The compressor name length was not filled up with zeros"; - } - depth = IsoTypeReader.readUInt16(content); - tmp = IsoTypeReader.readUInt16(content); - assert 0xFFFF == tmp; - - _parseChildBoxes(content); - - } - - - protected long getContentSize() { - long contentSize = 78; - for (Box boxe : boxes) { - contentSize += boxe.getSize(); - } - return contentSize; - } - - @Override - protected void getContent(ByteBuffer byteBuffer) { - _writeReservedAndDataReferenceIndex(byteBuffer); - IsoTypeWriter.writeUInt16(byteBuffer, 0); - IsoTypeWriter.writeUInt16(byteBuffer, 0); - IsoTypeWriter.writeUInt32(byteBuffer, predefined[0]); - IsoTypeWriter.writeUInt32(byteBuffer, predefined[1]); - IsoTypeWriter.writeUInt32(byteBuffer, predefined[2]); - - IsoTypeWriter.writeUInt16(byteBuffer, getWidth()); - IsoTypeWriter.writeUInt16(byteBuffer, getHeight()); - - IsoTypeWriter.writeFixedPont1616(byteBuffer, getHorizresolution()); - IsoTypeWriter.writeFixedPont1616(byteBuffer, getVertresolution()); - - - IsoTypeWriter.writeUInt32(byteBuffer, 0); - IsoTypeWriter.writeUInt16(byteBuffer, getFrameCount()); - IsoTypeWriter.writeUInt8(byteBuffer, Utf8.utf8StringLengthInBytes(getCompressorname())); - byteBuffer.put(Utf8.convert(getCompressorname())); - int a = Utf8.utf8StringLengthInBytes(getCompressorname()); - while (a < 31) { - a++; - byteBuffer.put((byte) 0); - } - IsoTypeWriter.writeUInt16(byteBuffer, getDepth()); - IsoTypeWriter.writeUInt16(byteBuffer, 0xFFFF); - - _writeChildBoxes(byteBuffer); - - } - -} diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/threegpp26244/LocationInformationBox.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/threegpp26244/LocationInformationBox.java deleted file mode 100644 index 089d97b81..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/threegpp26244/LocationInformationBox.java +++ /dev/null @@ -1,126 +0,0 @@ -package com.coremedia.iso.boxes.threegpp26244; - -import com.coremedia.iso.IsoTypeReader; -import com.coremedia.iso.IsoTypeWriter; -import com.coremedia.iso.Utf8; -import com.googlecode.mp4parser.AbstractFullBox; - -import java.nio.ByteBuffer; - -/** - * Location Information Box as specified in TS 26.244. - */ -public class LocationInformationBox extends AbstractFullBox { - public static final String TYPE = "loci"; - - private String language; - private String name = ""; - private int role; - private double longitude; - private double latitude; - private double altitude; - private String astronomicalBody = ""; - private String additionalNotes = ""; - - public LocationInformationBox() { - super(TYPE); - } - - public String getLanguage() { - return language; - } - - public void setLanguage(String language) { - this.language = language; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public int getRole() { - return role; - } - - public void setRole(int role) { - this.role = role; - } - - public double getLongitude() { - return longitude; - } - - public void setLongitude(double longitude) { - this.longitude = longitude; - } - - public double getLatitude() { - return latitude; - } - - public void setLatitude(double latitude) { - this.latitude = latitude; - } - - public double getAltitude() { - return altitude; - } - - public void setAltitude(double altitude) { - this.altitude = altitude; - } - - public String getAstronomicalBody() { - return astronomicalBody; - } - - public void setAstronomicalBody(String astronomicalBody) { - this.astronomicalBody = astronomicalBody; - } - - public String getAdditionalNotes() { - return additionalNotes; - } - - public void setAdditionalNotes(String additionalNotes) { - this.additionalNotes = additionalNotes; - } - - protected long getContentSize() { - return 22 + Utf8.convert(name).length + Utf8.convert(astronomicalBody).length + Utf8.convert(additionalNotes).length; - } - - @Override - public void _parseDetails(ByteBuffer content) { - parseVersionAndFlags(content); - language = IsoTypeReader.readIso639(content); - name = IsoTypeReader.readString(content); - role = IsoTypeReader.readUInt8(content); - longitude = IsoTypeReader.readFixedPoint1616(content); - latitude = IsoTypeReader.readFixedPoint1616(content); - altitude = IsoTypeReader.readFixedPoint1616(content); - astronomicalBody = IsoTypeReader.readString(content); - additionalNotes = IsoTypeReader.readString(content); - } - - - @Override - protected void getContent(ByteBuffer byteBuffer) { - writeVersionAndFlags(byteBuffer); - IsoTypeWriter.writeIso639(byteBuffer, language); - byteBuffer.put(Utf8.convert(name)); - byteBuffer.put((byte) 0); - IsoTypeWriter.writeUInt8(byteBuffer, role); - IsoTypeWriter.writeFixedPont1616(byteBuffer, longitude); - IsoTypeWriter.writeFixedPont1616(byteBuffer, latitude); - IsoTypeWriter.writeFixedPont1616(byteBuffer, altitude); - byteBuffer.put(Utf8.convert(astronomicalBody)); - byteBuffer.put((byte) 0); - byteBuffer.put(Utf8.convert(additionalNotes)); - byteBuffer.put((byte) 0); - } -} diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/vodafone/AlbumArtistBox.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/vodafone/AlbumArtistBox.java deleted file mode 100644 index aba12a419..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/vodafone/AlbumArtistBox.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright 2008 CoreMedia AG, Hamburg - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coremedia.iso.boxes.vodafone; - - -import com.coremedia.iso.IsoTypeReader; -import com.coremedia.iso.IsoTypeWriter; -import com.coremedia.iso.Utf8; -import com.googlecode.mp4parser.AbstractFullBox; - -import java.nio.ByteBuffer; - -/** - * Special box used by Vodafone in their DCF containing information about the artist. Mainly used for OMA DCF files - * containing music. Resides in the {@link com.coremedia.iso.boxes.UserDataBox}. - */ -public class AlbumArtistBox extends AbstractFullBox { - public static final String TYPE = "albr"; - - private String language; - private String albumArtist; - - public AlbumArtistBox() { - super(TYPE); - } - - public String getLanguage() { - return language; - } - - public String getAlbumArtist() { - return albumArtist; - } - - public void setLanguage(String language) { - this.language = language; - } - - public void setAlbumArtist(String albumArtist) { - this.albumArtist = albumArtist; - } - - protected long getContentSize() { - return 6 + Utf8.utf8StringLengthInBytes(albumArtist) + 1; - } - - @Override - public void _parseDetails(ByteBuffer content) { - parseVersionAndFlags(content); - language = IsoTypeReader.readIso639(content); - albumArtist = IsoTypeReader.readString(content); - } - - protected void getContent(ByteBuffer byteBuffer) { - writeVersionAndFlags(byteBuffer); - IsoTypeWriter.writeIso639(byteBuffer, language); - byteBuffer.put(Utf8.convert(albumArtist)); - byteBuffer.put((byte) 0); - } - - public String toString() { - return "AlbumArtistBox[language=" + getLanguage() + ";albumArtist=" + getAlbumArtist() + "]"; - } -} diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/vodafone/ContentDistributorIdBox.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/vodafone/ContentDistributorIdBox.java deleted file mode 100644 index dc36f452c..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/vodafone/ContentDistributorIdBox.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright 2008 CoreMedia AG, Hamburg - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coremedia.iso.boxes.vodafone; - -import com.coremedia.iso.IsoTypeReader; -import com.coremedia.iso.IsoTypeWriter; -import com.coremedia.iso.Utf8; -import com.googlecode.mp4parser.AbstractFullBox; - -import java.nio.ByteBuffer; - -/** - * Vodafone specific box. Usage unclear. - */ -public class ContentDistributorIdBox extends AbstractFullBox { - public static final String TYPE = "cdis"; - - private String language; - private String contentDistributorId; - - public ContentDistributorIdBox() { - super(TYPE); - } - - public String getLanguage() { - return language; - } - - public String getContentDistributorId() { - return contentDistributorId; - } - - protected long getContentSize() { - return 2 + Utf8.utf8StringLengthInBytes(contentDistributorId) + 5; - } - - @Override - public void _parseDetails(ByteBuffer content) { - parseVersionAndFlags(content); - language = IsoTypeReader.readIso639(content); - contentDistributorId = IsoTypeReader.readString(content); - } - - @Override - protected void getContent(ByteBuffer byteBuffer) { - writeVersionAndFlags(byteBuffer); - IsoTypeWriter.writeIso639(byteBuffer, language); - byteBuffer.put(Utf8.convert(contentDistributorId)); - byteBuffer.put((byte) 0); - - } - - public String toString() { - return "ContentDistributorIdBox[language=" + getLanguage() + ";contentDistributorId=" + getContentDistributorId() + "]"; - } -} diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/vodafone/CoverUriBox.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/vodafone/CoverUriBox.java deleted file mode 100644 index 0e78b25cb..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/vodafone/CoverUriBox.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright 2008 CoreMedia AG, Hamburg - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coremedia.iso.boxes.vodafone; - -import com.coremedia.iso.IsoTypeReader; -import com.coremedia.iso.Utf8; -import com.googlecode.mp4parser.AbstractFullBox; - -import java.nio.ByteBuffer; - -/** - * A vodafone specific box. - */ -public class CoverUriBox extends AbstractFullBox { - public static final String TYPE = "cvru"; - - private String coverUri; - - public CoverUriBox() { - super(TYPE); - } - - public String getCoverUri() { - return coverUri; - } - - public void setCoverUri(String coverUri) { - this.coverUri = coverUri; - } - - protected long getContentSize() { - return Utf8.utf8StringLengthInBytes(coverUri) + 5; - } - - @Override - public void _parseDetails(ByteBuffer content) { - parseVersionAndFlags(content); - coverUri = IsoTypeReader.readString(content); - } - - @Override - protected void getContent(ByteBuffer byteBuffer) { - writeVersionAndFlags(byteBuffer); - byteBuffer.put(Utf8.convert(coverUri)); - byteBuffer.put((byte) 0); - } - - - public String toString() { - return "CoverUriBox[coverUri=" + getCoverUri() + "]"; - } -} diff --git a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/vodafone/LyricsUriBox.java b/android-aac-enc/src/main/java/com/coremedia/iso/boxes/vodafone/LyricsUriBox.java deleted file mode 100644 index fbfc243ae..000000000 --- a/android-aac-enc/src/main/java/com/coremedia/iso/boxes/vodafone/LyricsUriBox.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright 2008 CoreMedia AG, Hamburg - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coremedia.iso.boxes.vodafone; - -import com.coremedia.iso.IsoTypeReader; -import com.coremedia.iso.Utf8; -import com.googlecode.mp4parser.AbstractFullBox; - -import java.nio.ByteBuffer; - -/** - * A box in the {@link com.coremedia.iso.boxes.UserDataBox} containing information about the lyric location. - * Invented by Vodafone. - */ -public class LyricsUriBox extends AbstractFullBox { - public static final String TYPE = "lrcu"; - - private String lyricsUri; - - public LyricsUriBox() { - super(TYPE); - } - - public String getLyricsUri() { - return lyricsUri; - } - - public void setLyricsUri(String lyricsUri) { - this.lyricsUri = lyricsUri; - } - - protected long getContentSize() { - return Utf8.utf8StringLengthInBytes(lyricsUri) + 5; - } - - @Override - public void _parseDetails(ByteBuffer content) { - parseVersionAndFlags(content); - lyricsUri = IsoTypeReader.readString(content); - } - - @Override - protected void getContent(ByteBuffer byteBuffer) { - writeVersionAndFlags(byteBuffer); - byteBuffer.put(Utf8.convert(lyricsUri)); - byteBuffer.put((byte) 0); - } - - public String toString() { - return "LyricsUriBox[lyricsUri=" + getLyricsUri() + "]"; - } -} diff --git a/android-aac-enc/src/main/java/com/googlecode/mp4parser/AbstractBox.java b/android-aac-enc/src/main/java/com/googlecode/mp4parser/AbstractBox.java deleted file mode 100644 index 21ab03e3c..000000000 --- a/android-aac-enc/src/main/java/com/googlecode/mp4parser/AbstractBox.java +++ /dev/null @@ -1,271 +0,0 @@ -/* - * Copyright 2012 Sebastian Annies, Hamburg - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.googlecode.mp4parser; - -import com.coremedia.iso.BoxParser; -import com.coremedia.iso.ChannelHelper; -import com.coremedia.iso.Hex; -import com.coremedia.iso.IsoFile; -import com.coremedia.iso.IsoTypeWriter; -import com.coremedia.iso.boxes.Box; -import com.coremedia.iso.boxes.ContainerBox; -import com.coremedia.iso.boxes.UserBox; -import com.googlecode.mp4parser.annotations.DoNotParseDetail; - -import java.io.IOException; -import java.nio.ByteBuffer; -import java.nio.channels.FileChannel; -import java.nio.channels.ReadableByteChannel; -import java.nio.channels.WritableByteChannel; -import java.util.logging.Logger; - -import static com.googlecode.mp4parser.util.CastUtils.l2i; - -/** - * A basic on-demand parsing box. Requires the implementation of three methods to become a fully working box: - *

      - *
    1. {@link #_parseDetails(java.nio.ByteBuffer)}
    2. - *
    3. {@link #getContent(java.nio.ByteBuffer)}
    4. - *
    5. {@link #getContentSize()}
    6. - *
    - * additionally this new box has to be put into the isoparser-default.properties file so that - * it is accessible by the PropertyBoxParserImpl - */ -public abstract class AbstractBox implements Box { - private static Logger LOG = Logger.getLogger(AbstractBox.class.getName()); - - protected String type; - private byte[] userType; - private ContainerBox parent; - - private ByteBuffer content; - private ByteBuffer deadBytes = null; - - - protected AbstractBox(String type) { - this.type = type; - } - - protected AbstractBox(String type, byte[] userType) { - this.type = type; - this.userType = userType; - } - - /** - * Get the box's content size without its header. This must be the exact number of bytes - * that getContent(ByteBuffer) writes. - * - * @return Gets the box's content size in bytes - * @see #getContent(java.nio.ByteBuffer) - */ - protected abstract long getContentSize(); - - /** - * Write the box's content into the given ByteBuffer. This must include flags - * and version in case of a full box. byteBuffer has been initialized with - * getSize() bytes. - * - * @param byteBuffer the sink for the box's content - */ - protected abstract void getContent(ByteBuffer byteBuffer); - - /** - * Parse the box's fields and child boxes if any. - * - * @param content the box's raw content beginning after the 4-cc field. - */ - protected abstract void _parseDetails(ByteBuffer content); - - /** - * Read the box's content from a byte channel without parsing it. Parsing is done on-demand. - * - * @param readableByteChannel the (part of the) iso file to parse - * @param contentSize expected contentSize of the box - * @param boxParser creates inner boxes - * @throws IOException in case of an I/O error. - */ - @DoNotParseDetail - public void parse(ReadableByteChannel readableByteChannel, ByteBuffer header, long contentSize, BoxParser boxParser) throws IOException { - if (readableByteChannel instanceof FileChannel && contentSize > 1024 * 1024) { - // It's quite expensive to map a file into the memory. Just do it when the box is larger than a MB. - content = ((FileChannel) readableByteChannel).map(FileChannel.MapMode.READ_ONLY, ((FileChannel) readableByteChannel).position(), contentSize); - ((FileChannel) readableByteChannel).position(((FileChannel) readableByteChannel).position() + contentSize); - } else { - assert contentSize < Integer.MAX_VALUE; - content = ChannelHelper.readFully(readableByteChannel, contentSize); - } - } - - public void getBox(WritableByteChannel os) throws IOException { - ByteBuffer bb = ByteBuffer.allocate(l2i(getSize())); - getHeader(bb); - if (content == null) { - getContent(bb); - if (deadBytes != null) { - deadBytes.rewind(); - while (deadBytes.remaining() > 0) { - bb.put(deadBytes); - } - } - } else { - content.rewind(); - bb.put(content); - } - bb.rewind(); - os.write(bb); - } - - - /** - * Parses the raw content of the box. It surrounds the actual parsing - * which is done - */ - synchronized final void parseDetails() { - if (content != null) { - ByteBuffer content = this.content; - this.content = null; - content.rewind(); - _parseDetails(content); - if (content.remaining() > 0) { - deadBytes = content.slice(); - } - assert verify(content); - } - } - - /** - * Sets the 'dead' bytes. These bytes are left if the content of the box - * has been parsed but not all bytes have been used up. - * - * @param newDeadBytes the unused bytes with no meaning but required for bytewise reconstruction - */ - protected void setDeadBytes(ByteBuffer newDeadBytes) { - deadBytes = newDeadBytes; - } - - - /** - * Gets the full size of the box including header and content. - * - * @return the box's size - */ - public long getSize() { - long size = (content == null ? getContentSize() : content.limit()); - size += (8 + // size|type - (size >= ((1L << 32) - 8) ? 8 : 0) + // 32bit - 8 byte size and type - (UserBox.TYPE.equals(getType()) ? 16 : 0)); - size += (deadBytes == null ? 0 : deadBytes.limit()); - return size; - } - - @DoNotParseDetail - public String getType() { - return type; - } - - @DoNotParseDetail - public byte[] getUserType() { - return userType; - } - - @DoNotParseDetail - public ContainerBox getParent() { - return parent; - } - - @DoNotParseDetail - public void setParent(ContainerBox parent) { - this.parent = parent; - } - - @DoNotParseDetail - public IsoFile getIsoFile() { - return parent.getIsoFile(); - } - - /** - * Check if details are parsed. - * - * @return true whenever the content ByteBuffer is not null - */ - public boolean isParsed() { - return content == null; - } - - - /** - * Verifies that a box can be reconstructed byte-exact after parsing. - * - * @param content the raw content of the box - * @return true if raw content exactly matches the reconstructed content - */ - private boolean verify(ByteBuffer content) { - ByteBuffer bb = ByteBuffer.allocate(l2i(getContentSize() + (deadBytes != null ? deadBytes.limit() : 0))); - getContent(bb); - if (deadBytes != null) { - deadBytes.rewind(); - while (deadBytes.remaining() > 0) { - bb.put(deadBytes); - } - } - content.rewind(); - bb.rewind(); - - - if (content.remaining() != bb.remaining()) { - LOG.severe("remaining differs " + content.remaining() + " vs. " + bb.remaining()); - return false; - } - int p = content.position(); - for (int i = content.limit() - 1, j = bb.limit() - 1; i >= p; i--, j--) { - byte v1 = content.get(i); - byte v2 = bb.get(j); - if (v1 != v2) { - LOG.severe("buffers differ at " + i + ": " + v1 + "/" + v2); - byte[] b1 = new byte[content.remaining()]; - byte[] b2 = new byte[bb.remaining()]; - content.get(b1); - bb.get(b2); - System.err.println(Hex.encodeHex(b1)); - System.err.println(Hex.encodeHex(b2)); - return false; - } - } - return true; - - } - - private boolean isSmallBox() { - return (content == null ? (getContentSize() + (deadBytes != null ? deadBytes.limit() : 0) + 8) : content.limit()) < 1L << 32; - } - - private void getHeader(ByteBuffer byteBuffer) { - if (isSmallBox()) { - IsoTypeWriter.writeUInt32(byteBuffer, this.getSize()); - byteBuffer.put(IsoFile.fourCCtoBytes(getType())); - } else { - IsoTypeWriter.writeUInt32(byteBuffer, 1); - byteBuffer.put(IsoFile.fourCCtoBytes(getType())); - IsoTypeWriter.writeUInt64(byteBuffer, getSize()); - } - if (UserBox.TYPE.equals(getType())) { - byteBuffer.put(getUserType()); - } - - - } -} diff --git a/android-aac-enc/src/main/java/com/googlecode/mp4parser/AbstractContainerBox.java b/android-aac-enc/src/main/java/com/googlecode/mp4parser/AbstractContainerBox.java deleted file mode 100644 index 01b099654..000000000 --- a/android-aac-enc/src/main/java/com/googlecode/mp4parser/AbstractContainerBox.java +++ /dev/null @@ -1,170 +0,0 @@ -/* - * Copyright 2008 CoreMedia AG, Hamburg - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.googlecode.mp4parser; - -import com.coremedia.iso.BoxParser; -import com.coremedia.iso.boxes.Box; -import com.coremedia.iso.boxes.ContainerBox; -import com.googlecode.mp4parser.util.ByteBufferByteChannel; - -import java.io.IOException; -import java.nio.ByteBuffer; -import java.nio.channels.ReadableByteChannel; -import java.nio.channels.WritableByteChannel; -import java.util.ArrayList; -import java.util.Collections; -import java.util.LinkedList; -import java.util.List; -import java.util.logging.Logger; - - -/** - * Abstract base class suitable for most boxes acting purely as container for other boxes. - */ -public abstract class AbstractContainerBox extends AbstractBox implements ContainerBox { - private static Logger LOG = Logger.getLogger(AbstractContainerBox.class.getName()); - - protected List boxes = new LinkedList(); - protected BoxParser boxParser; - - @Override - protected long getContentSize() { - long contentSize = 0; - for (Box boxe : boxes) { - contentSize += boxe.getSize(); - } - return contentSize; - } - - public AbstractContainerBox(String type) { - super(type); - } - - public List getBoxes() { - return Collections.unmodifiableList(boxes); - } - - public void setBoxes(List boxes) { - this.boxes = new LinkedList(boxes); - } - - @SuppressWarnings("unchecked") - public List getBoxes(Class clazz) { - return getBoxes(clazz, false); - } - - @SuppressWarnings("unchecked") - public List getBoxes(Class clazz, boolean recursive) { - List boxesToBeReturned = new ArrayList(2); - for (Box boxe : boxes) { - //clazz.isInstance(boxe) / clazz == boxe.getClass()? - // I hereby finally decide to use isInstance - - if (clazz.isInstance(boxe)) { - boxesToBeReturned.add((T) boxe); - } - - if (recursive && boxe instanceof ContainerBox) { - boxesToBeReturned.addAll(((ContainerBox) boxe).getBoxes(clazz, recursive)); - } - } - return boxesToBeReturned; - } - - /** - * Add b to the container and sets the parent correctly. - * - * @param b will be added to the container - */ - public void addBox(Box b) { - b.setParent(this); - boxes.add(b); - } - - public void removeBox(Box b) { - boxes.remove(b); - } - - @Override - public void parse(ReadableByteChannel readableByteChannel, ByteBuffer header, long contentSize, BoxParser boxParser) throws IOException { - super.parse(readableByteChannel, header, contentSize, boxParser); - this.boxParser = boxParser; - } - - @Override - public void _parseDetails(ByteBuffer content) { - parseChildBoxes(content); - } - - - public String toString() { - StringBuilder buffer = new StringBuilder(); - - buffer.append(this.getClass().getSimpleName()).append("["); - for (int i = 0; i < boxes.size(); i++) { - if (i > 0) { - buffer.append(";"); - } - buffer.append(boxes.get(i).toString()); - } - buffer.append("]"); - return buffer.toString(); - } - - /** - * The number of bytes from box start (first length byte) to the - * first length byte of the first child box - * - * @return offset to first child box - */ - public long getNumOfBytesToFirstChild() { - return 8; - } - - @Override - protected void getContent(ByteBuffer byteBuffer) { - writeChildBoxes(byteBuffer); - } - - protected final void parseChildBoxes(ByteBuffer content) { - try { - while (content.remaining() >= 8) { // 8 is the minimal size for a sane box - boxes.add(boxParser.parseBox(new ByteBufferByteChannel(content), this)); - } - - if (content.remaining() != 0) { - setDeadBytes(content.slice()); - LOG.warning("Something's wrong with the sizes. There are dead bytes in a container box."); - } - } catch (IOException e) { - throw new RuntimeException(e); - } - } - - protected final void writeChildBoxes(ByteBuffer bb) { - WritableByteChannel wbc = new ByteBufferByteChannel(bb); - for (Box box : boxes) { - try { - box.getBox(wbc); - } catch (IOException e) { - // My WritableByteChannel won't throw any excpetion - throw new RuntimeException("Cannot happen to me", e); - } - } - } - -} diff --git a/android-aac-enc/src/main/java/com/googlecode/mp4parser/AbstractFullBox.java b/android-aac-enc/src/main/java/com/googlecode/mp4parser/AbstractFullBox.java deleted file mode 100644 index bec8975b7..000000000 --- a/android-aac-enc/src/main/java/com/googlecode/mp4parser/AbstractFullBox.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright 2008 CoreMedia AG, Hamburg - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.googlecode.mp4parser; - - -import com.coremedia.iso.IsoTypeReader; -import com.coremedia.iso.IsoTypeWriter; -import com.coremedia.iso.boxes.FullBox; - -import java.nio.ByteBuffer; - -/** - * Base class for all ISO Full boxes. - */ -public abstract class AbstractFullBox extends AbstractBox implements FullBox { - private int version; - private int flags; - - protected AbstractFullBox(String type) { - super(type); - } - - protected AbstractFullBox(String type, byte[] userType) { - super(type, userType); - } - - public int getVersion() { - return version; - } - - public void setVersion(int version) { - this.version = version; - } - - public int getFlags() { - return flags; - } - - public void setFlags(int flags) { - this.flags = flags; - } - - - /** - * Parses the version/flags header and returns the remaining box size. - * - * @param content - * @return number of bytes read - */ - protected final long parseVersionAndFlags(ByteBuffer content) { - version = IsoTypeReader.readUInt8(content); - flags = IsoTypeReader.readUInt24(content); - return 4; - } - - protected final void writeVersionAndFlags(ByteBuffer bb) { - IsoTypeWriter.writeUInt8(bb, version); - IsoTypeWriter.writeUInt24(bb, flags); - } -} diff --git a/android-aac-enc/src/main/java/com/googlecode/mp4parser/FullContainerBox.java b/android-aac-enc/src/main/java/com/googlecode/mp4parser/FullContainerBox.java deleted file mode 100644 index 8de9a1350..000000000 --- a/android-aac-enc/src/main/java/com/googlecode/mp4parser/FullContainerBox.java +++ /dev/null @@ -1,157 +0,0 @@ -/* - * Copyright 2008 CoreMedia AG, Hamburg - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.googlecode.mp4parser; - -import com.coremedia.iso.BoxParser; -import com.coremedia.iso.boxes.Box; -import com.coremedia.iso.boxes.ContainerBox; -import com.googlecode.mp4parser.util.ByteBufferByteChannel; - -import java.io.IOException; -import java.nio.ByteBuffer; -import java.nio.channels.ReadableByteChannel; -import java.nio.channels.WritableByteChannel; -import java.util.ArrayList; -import java.util.LinkedList; -import java.util.List; -import java.util.logging.Logger; - -/** - * Abstract base class for a full iso box only containing ither boxes. - */ -public abstract class FullContainerBox extends AbstractFullBox implements ContainerBox { - protected List boxes = new LinkedList(); - private static Logger LOG = Logger.getLogger(FullContainerBox.class.getName()); - BoxParser boxParser; - - public void setBoxes(List boxes) { - this.boxes = new LinkedList(boxes); - } - - @SuppressWarnings("unchecked") - public List getBoxes(Class clazz) { - return getBoxes(clazz, false); - } - - @SuppressWarnings("unchecked") - public List getBoxes(Class clazz, boolean recursive) { - List boxesToBeReturned = new ArrayList(2); - for (Box boxe : boxes) { //clazz.isInstance(boxe) / clazz == boxe.getClass()? - if (clazz == boxe.getClass()) { - boxesToBeReturned.add((T) boxe); - } - - if (recursive && boxe instanceof ContainerBox) { - boxesToBeReturned.addAll((((ContainerBox) boxe).getBoxes(clazz, recursive))); - } - } - // Optimize here! Spare object creation work on arrays directly! System.arrayCopy - return boxesToBeReturned; - //return (T[]) boxesToBeReturned.toArray(); - } - - protected long getContentSize() { - long contentSize = 4; // flags and version - for (Box boxe : boxes) { - contentSize += boxe.getSize(); - } - return contentSize; - } - - public void addBox(Box b) { - boxes.add(b); - } - - public void removeBox(Box b) { - boxes.remove(b); - } - - public FullContainerBox(String type) { - super(type); - } - - public List getBoxes() { - return boxes; - } - - @Override - public void parse(ReadableByteChannel readableByteChannel, ByteBuffer header, long contentSize, BoxParser boxParser) throws IOException { - super.parse(readableByteChannel, header, contentSize, boxParser); - this.boxParser = boxParser; - } - - @Override - public void _parseDetails(ByteBuffer content) { - parseVersionAndFlags(content); - parseChildBoxes(content); - } - - protected final void parseChildBoxes(ByteBuffer content) { - try { - while (content.remaining() >= 8) { // 8 is the minimal size for a sane box - boxes.add(boxParser.parseBox(new ByteBufferByteChannel(content), this)); - } - - if (content.remaining() != 0) { - setDeadBytes(content.slice()); - LOG.severe("Some sizes are wrong"); - } - } catch (IOException e) { - throw new RuntimeException(e); - } - } - - public String toString() { - StringBuilder buffer = new StringBuilder(); - buffer.append(this.getClass().getSimpleName()).append("["); - for (int i = 0; i < boxes.size(); i++) { - if (i > 0) { - buffer.append(";"); - } - buffer.append(boxes.get(i).toString()); - } - buffer.append("]"); - return buffer.toString(); - } - - - protected void getContent(ByteBuffer byteBuffer) { - writeVersionAndFlags(byteBuffer); - writeChildBoxes(byteBuffer); - } - - protected final void writeChildBoxes(ByteBuffer bb) { - WritableByteChannel wbc = new ByteBufferByteChannel(bb); - for (Box box : boxes) { - try { - box.getBox(wbc); - } catch (IOException e) { - // cannot happen since my WritableByteChannel won't throw any excpetion - throw new RuntimeException("Cannot happen.", e); - } - - } - } - - public long getNumOfBytesToFirstChild() { - long sizeOfChildren = 0; - for (Box box : boxes) { - sizeOfChildren += box.getSize(); - } - return getSize() - sizeOfChildren; - } -} diff --git a/android-aac-enc/src/main/java/com/googlecode/mp4parser/annotations/DoNotParseDetail.java b/android-aac-enc/src/main/java/com/googlecode/mp4parser/annotations/DoNotParseDetail.java deleted file mode 100644 index c08460f3a..000000000 --- a/android-aac-enc/src/main/java/com/googlecode/mp4parser/annotations/DoNotParseDetail.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright 2012 Sebastian Annies, Hamburg - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.googlecode.mp4parser.annotations; - -import java.lang.annotation.Documented; -import java.lang.annotation.ElementType; -import java.lang.annotation.Inherited; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * - */ - -@Target({ElementType.METHOD, ElementType.TYPE}) -@Retention(RetentionPolicy.RUNTIME) -@Inherited -@Documented -/** - * Mark a method with this annotation to prevent triggering the call of - * AbstractBox#parseDetails() before actually executing the - * method. - * @see com.googlecode.mp4parser.RequiresParseDetailAspect - */ -public @interface DoNotParseDetail { -} - - diff --git a/android-aac-enc/src/main/java/com/googlecode/mp4parser/annotations/ParseDetail.java b/android-aac-enc/src/main/java/com/googlecode/mp4parser/annotations/ParseDetail.java deleted file mode 100644 index 7b66d5337..000000000 --- a/android-aac-enc/src/main/java/com/googlecode/mp4parser/annotations/ParseDetail.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright 2012 Sebastian Annies, Hamburg - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.googlecode.mp4parser.annotations; - -import java.lang.annotation.Documented; -import java.lang.annotation.ElementType; -import java.lang.annotation.Inherited; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - - -@Target({ElementType.METHOD, ElementType.TYPE}) -@Retention(RetentionPolicy.RUNTIME) -@Inherited -@Documented -public @interface ParseDetail { -} - - diff --git a/android-aac-enc/src/main/java/com/googlecode/mp4parser/authoring/AbstractTrack.java b/android-aac-enc/src/main/java/com/googlecode/mp4parser/authoring/AbstractTrack.java deleted file mode 100644 index fb0e2242b..000000000 --- a/android-aac-enc/src/main/java/com/googlecode/mp4parser/authoring/AbstractTrack.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright 2012 Sebastian Annies, Hamburg - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.googlecode.mp4parser.authoring; - -/** - * - */ -public abstract class AbstractTrack implements Track { - private boolean enabled = true; - private boolean inMovie = true; - private boolean inPreview = true; - private boolean inPoster = true; - - public boolean isEnabled() { - return enabled; - } - - public boolean isInMovie() { - return inMovie; - } - - public boolean isInPreview() { - return inPreview; - } - - public boolean isInPoster() { - return inPoster; - } - - public void setEnabled(boolean enabled) { - this.enabled = enabled; - } - - public void setInMovie(boolean inMovie) { - this.inMovie = inMovie; - } - - public void setInPreview(boolean inPreview) { - this.inPreview = inPreview; - } - - public void setInPoster(boolean inPoster) { - this.inPoster = inPoster; - } - -} diff --git a/android-aac-enc/src/main/java/com/googlecode/mp4parser/authoring/DateHelper.java b/android-aac-enc/src/main/java/com/googlecode/mp4parser/authoring/DateHelper.java deleted file mode 100644 index 02528590c..000000000 --- a/android-aac-enc/src/main/java/com/googlecode/mp4parser/authoring/DateHelper.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright 2012 Sebastian Annies, Hamburg - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.googlecode.mp4parser.authoring; - -import java.util.Date; - -/** - * Converts ISO Dates (seconds since 1/1/1904) to Date and vice versa. - */ -public class DateHelper { - /** - * Converts a long value with seconds since 1/1/1904 to Date. - * - * @param secondsSince seconds since 1/1/1904 - * @return date the corresponding Date - */ - static public Date convert(long secondsSince) { - return new Date((secondsSince - 2082844800L) * 1000L); - } - - - /** - * Converts a date as long to a mac date as long - * - * @param date date to convert - * @return date in mac format - */ - static public long convert(Date date) { - return (date.getTime() / 1000L) + 2082844800L; - } -} diff --git a/android-aac-enc/src/main/java/com/googlecode/mp4parser/authoring/Movie.java b/android-aac-enc/src/main/java/com/googlecode/mp4parser/authoring/Movie.java deleted file mode 100644 index 0658682ae..000000000 --- a/android-aac-enc/src/main/java/com/googlecode/mp4parser/authoring/Movie.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright 2012 Sebastian Annies, Hamburg - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.googlecode.mp4parser.authoring; - -import java.util.LinkedList; -import java.util.List; - -/** - * - */ -public class Movie { - List tracks = new LinkedList(); - - public List getTracks() { - return tracks; - } - - public void setTracks(List tracks) { - this.tracks = tracks; - } - - public void addTrack(Track nuTrack) { - // do some checking - // perhaps the movie needs to get longer! - if (getTrackByTrackId(nuTrack.getTrackMetaData().getTrackId()) != null) { - // We already have a track with that trackId. Create a new one - nuTrack.getTrackMetaData().setTrackId(getNextTrackId()); - } - tracks.add(nuTrack); - } - - - @Override - public String toString() { - String s = "Movie{ "; - for (Track track : tracks) { - s += "track_" + track.getTrackMetaData().getTrackId() + " (" + track.getHandler() + ") "; - } - - s += '}'; - return s; - } - - public long getNextTrackId() { - long nextTrackId = 0; - for (Track track : tracks) { - nextTrackId = nextTrackId < track.getTrackMetaData().getTrackId() ? track.getTrackMetaData().getTrackId() : nextTrackId; - } - return ++nextTrackId; - } - - - public Track getTrackByTrackId(long trackId) { - for (Track track : tracks) { - if (track.getTrackMetaData().getTrackId() == trackId) { - return track; - } - } - return null; - } - - - public long getTimescale() { - long timescale = this.getTracks().iterator().next().getTrackMetaData().getTimescale(); - for (Track track : this.getTracks()) { - timescale = gcd(track.getTrackMetaData().getTimescale(), timescale); - } - return timescale; - } - - public static long gcd(long a, long b) { - if (b == 0) { - return a; - } - return gcd(b, a % b); - } - -} diff --git a/android-aac-enc/src/main/java/com/googlecode/mp4parser/authoring/Mp4TrackImpl.java b/android-aac-enc/src/main/java/com/googlecode/mp4parser/authoring/Mp4TrackImpl.java deleted file mode 100644 index f6bafd1b9..000000000 --- a/android-aac-enc/src/main/java/com/googlecode/mp4parser/authoring/Mp4TrackImpl.java +++ /dev/null @@ -1,178 +0,0 @@ -/* - * Copyright 2012 Sebastian Annies, Hamburg - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.googlecode.mp4parser.authoring; - -import com.coremedia.iso.boxes.*; -import com.coremedia.iso.boxes.fragment.MovieExtendsBox; -import com.coremedia.iso.boxes.fragment.MovieFragmentBox; -import com.coremedia.iso.boxes.fragment.TrackFragmentBox; -import com.coremedia.iso.boxes.fragment.TrackRunBox; -import com.coremedia.iso.boxes.mdat.SampleList; - -import java.nio.ByteBuffer; -import java.util.LinkedList; -import java.util.List; - -import static com.googlecode.mp4parser.util.CastUtils.l2i; - -/** - * Represents a single track of an MP4 file. - */ -public class Mp4TrackImpl extends AbstractTrack { - private List samples; - private SampleDescriptionBox sampleDescriptionBox; - private List decodingTimeEntries; - private List compositionTimeEntries; - private long[] syncSamples; - private List sampleDependencies; - private TrackMetaData trackMetaData = new TrackMetaData(); - private String handler; - private AbstractMediaHeaderBox mihd; - - public Mp4TrackImpl(TrackBox trackBox) { - samples = new SampleList(trackBox); - SampleTableBox stbl = trackBox.getMediaBox().getMediaInformationBox().getSampleTableBox(); - handler = trackBox.getMediaBox().getHandlerBox().getHandlerType(); - - - mihd = trackBox.getMediaBox().getMediaInformationBox().getMediaHeaderBox(); - - - sampleDescriptionBox = stbl.getSampleDescriptionBox(); - if (trackBox.getParent().getBoxes(MovieExtendsBox.class).size() > 0) { - - decodingTimeEntries = new LinkedList(); - compositionTimeEntries = new LinkedList(); - sampleDependencies = new LinkedList(); - - for (MovieFragmentBox movieFragmentBox : trackBox.getIsoFile().getBoxes(MovieFragmentBox.class)) { - List trafs = movieFragmentBox.getBoxes(TrackFragmentBox.class); - for (TrackFragmentBox traf : trafs) { - if (traf.getTrackFragmentHeaderBox().getTrackId() == trackBox.getTrackHeaderBox().getTrackId()) { - List truns = traf.getBoxes(TrackRunBox.class); - for (TrackRunBox trun : truns) { - for (TrackRunBox.Entry entry : trun.getEntries()) { - if (trun.isSampleDurationPresent()) { - if (decodingTimeEntries.size() == 0 || - decodingTimeEntries.get(decodingTimeEntries.size() - 1).getDelta() != entry.getSampleDuration()) { - decodingTimeEntries.add(new TimeToSampleBox.Entry(1, entry.getSampleDuration())); - } else { - TimeToSampleBox.Entry e = decodingTimeEntries.get(decodingTimeEntries.size() - 1); - e.setCount(e.getCount() + 1); - } - } - if (trun.isSampleCompositionTimeOffsetPresent()) { - if (compositionTimeEntries.size() == 0 || - compositionTimeEntries.get(compositionTimeEntries.size() - 1).getOffset() != entry.getSampleCompositionTimeOffset()) { - compositionTimeEntries.add(new CompositionTimeToSample.Entry(1, l2i(entry.getSampleCompositionTimeOffset()))); - } else { - CompositionTimeToSample.Entry e = compositionTimeEntries.get(compositionTimeEntries.size() - 1); - e.setCount(e.getCount() + 1); - } - } - - } - - - } - - - } - } - } - } else { - decodingTimeEntries = stbl.getTimeToSampleBox().getEntries(); - if (stbl.getCompositionTimeToSample() != null) { - compositionTimeEntries = stbl.getCompositionTimeToSample().getEntries(); - } - if (stbl.getSyncSampleBox() != null) { - syncSamples = stbl.getSyncSampleBox().getSampleNumber(); - } - if (stbl.getSampleDependencyTypeBox() != null) { - sampleDependencies = stbl.getSampleDependencyTypeBox().getEntries(); - } - } - MediaHeaderBox mdhd = trackBox.getMediaBox().getMediaHeaderBox(); - TrackHeaderBox tkhd = trackBox.getTrackHeaderBox(); - - setEnabled(tkhd.isEnabled()); - setInMovie(tkhd.isInMovie()); - setInPoster(tkhd.isInPoster()); - setInPreview(tkhd.isInPreview()); - - trackMetaData.setTrackId(tkhd.getTrackId()); - trackMetaData.setCreationTime(DateHelper.convert(mdhd.getCreationTime())); - trackMetaData.setLanguage(mdhd.getLanguage()); -/* System.err.println(mdhd.getModificationTime()); - System.err.println(DateHelper.convert(mdhd.getModificationTime())); - System.err.println(DateHelper.convert(DateHelper.convert(mdhd.getModificationTime()))); - System.err.println(DateHelper.convert(DateHelper.convert(DateHelper.convert(mdhd.getModificationTime()))));*/ - - trackMetaData.setModificationTime(DateHelper.convert(mdhd.getModificationTime())); - trackMetaData.setTimescale(mdhd.getTimescale()); - trackMetaData.setHeight(tkhd.getHeight()); - trackMetaData.setWidth(tkhd.getWidth()); - trackMetaData.setLayer(tkhd.getLayer()); - } - - public List getSamples() { - return samples; - } - - - public SampleDescriptionBox getSampleDescriptionBox() { - return sampleDescriptionBox; - } - - public List getDecodingTimeEntries() { - return decodingTimeEntries; - } - - public List getCompositionTimeEntries() { - return compositionTimeEntries; - } - - public long[] getSyncSamples() { - return syncSamples; - } - - public List getSampleDependencies() { - return sampleDependencies; - } - - public TrackMetaData getTrackMetaData() { - return trackMetaData; - } - - public String getHandler() { - return handler; - } - - public AbstractMediaHeaderBox getMediaHeaderBox() { - return mihd; - } - - public SubSampleInformationBox getSubsampleInformationBox() { - return null; - } - - @Override - public String toString() { - return "Mp4TrackImpl{" + - "handler='" + handler + '\'' + - '}'; - } -} diff --git a/android-aac-enc/src/main/java/com/googlecode/mp4parser/authoring/Track.java b/android-aac-enc/src/main/java/com/googlecode/mp4parser/authoring/Track.java deleted file mode 100644 index 8c587f17a..000000000 --- a/android-aac-enc/src/main/java/com/googlecode/mp4parser/authoring/Track.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright 2012 Sebastian Annies, Hamburg - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.googlecode.mp4parser.authoring; - -import com.coremedia.iso.boxes.*; - -import java.nio.ByteBuffer; -import java.util.List; - -/** - * Represents a Track. A track is a timed sequence of related samples. - *

    - * NOTE:
    getDecodingTimeEntries(); - - List getCompositionTimeEntries(); - - long[] getSyncSamples(); - - List getSampleDependencies(); - - TrackMetaData getTrackMetaData(); - - String getHandler(); - - boolean isEnabled(); - - boolean isInMovie(); - - boolean isInPreview(); - - boolean isInPoster(); - - List getSamples(); - - public AbstractMediaHeaderBox getMediaHeaderBox(); - - public SubSampleInformationBox getSubsampleInformationBox(); - -} diff --git a/android-aac-enc/src/main/java/com/googlecode/mp4parser/authoring/TrackMetaData.java b/android-aac-enc/src/main/java/com/googlecode/mp4parser/authoring/TrackMetaData.java deleted file mode 100644 index d4ddbdddc..000000000 --- a/android-aac-enc/src/main/java/com/googlecode/mp4parser/authoring/TrackMetaData.java +++ /dev/null @@ -1,139 +0,0 @@ -/* - * Copyright 2012 Sebastian Annies, Hamburg - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.googlecode.mp4parser.authoring; - -import java.util.Date; - -/** - * - */ -public class TrackMetaData implements Cloneable { - private String language; - private long timescale; - private Date modificationTime; - private Date creationTime; - private double width; - private double height; - private float volume; - private long trackId = 1; // zero is not allowed - private int group = 0; - private double startTime = 0; - - - /** - * specifies the front-to-back ordering of video tracks; tracks with lower - * numbers are closer to the viewer. 0 is the normal value, and -1 would be - * in front of track 0, and so on. - */ - int layer; - - public String getLanguage() { - return language; - } - - public void setLanguage(String language) { - this.language = language; - } - - public long getTimescale() { - return timescale; - } - - public void setTimescale(long timescale) { - this.timescale = timescale; - } - - public Date getModificationTime() { - return modificationTime; - } - - public void setModificationTime(Date modificationTime) { - this.modificationTime = modificationTime; - } - - public Date getCreationTime() { - return creationTime; - } - - public void setCreationTime(Date creationTime) { - this.creationTime = creationTime; - } - - public double getWidth() { - return width; - } - - public void setWidth(double width) { - this.width = width; - } - - public double getHeight() { - return height; - } - - public void setHeight(double height) { - this.height = height; - } - - public long getTrackId() { - return trackId; - } - - public void setTrackId(long trackId) { - this.trackId = trackId; - } - - public int getLayer() { - return layer; - } - - public void setLayer(int layer) { - this.layer = layer; - } - - public float getVolume() { - return volume; - } - - public void setVolume(float volume) { - this.volume = volume; - } - - public int getGroup() { - return group; - } - - public void setGroup(int group) { - this.group = group; - } - - public double getStartTime() { - return startTime; - } - - public void setStartTime(double startTime) { - this.startTime = startTime; - } - - public Object clone() { - try { - return super.clone(); - } catch (CloneNotSupportedException e) { - return null; - } - } - -} diff --git a/android-aac-enc/src/main/java/com/googlecode/mp4parser/authoring/builder/ByteBufferHelper.java b/android-aac-enc/src/main/java/com/googlecode/mp4parser/authoring/builder/ByteBufferHelper.java deleted file mode 100644 index ad21b1168..000000000 --- a/android-aac-enc/src/main/java/com/googlecode/mp4parser/authoring/builder/ByteBufferHelper.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright 2012 Sebastian Annies, Hamburg - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.googlecode.mp4parser.authoring.builder; - -import java.nio.ByteBuffer; -import java.nio.MappedByteBuffer; -import java.util.ArrayList; -import java.util.List; - -/** - * Used to merge adjacent byte buffers. - */ -public class ByteBufferHelper { - public static List mergeAdjacentBuffers(List samples) { - ArrayList nuSamples = new ArrayList(samples.size()); - for (ByteBuffer buffer : samples) { - int lastIndex = nuSamples.size() - 1; - if (lastIndex >= 0 && buffer.hasArray() && nuSamples.get(lastIndex).hasArray() && buffer.array() == nuSamples.get(lastIndex).array() && - nuSamples.get(lastIndex).arrayOffset() + nuSamples.get(lastIndex).limit() == buffer.arrayOffset()) { - ByteBuffer oldBuffer = nuSamples.remove(lastIndex); - ByteBuffer nu = ByteBuffer.wrap(buffer.array(), oldBuffer.arrayOffset(), oldBuffer.limit() + buffer.limit()).slice(); - // We need to slice here since wrap([], offset, length) just sets position and not the arrayOffset. - nuSamples.add(nu); - } else if (lastIndex >= 0 && - buffer instanceof MappedByteBuffer && nuSamples.get(lastIndex) instanceof MappedByteBuffer && - nuSamples.get(lastIndex).limit() == nuSamples.get(lastIndex).capacity() - buffer.capacity()) { - // This can go wrong - but will it? - ByteBuffer oldBuffer = nuSamples.get(lastIndex); - oldBuffer.limit(buffer.limit() + oldBuffer.limit()); - } else { - buffer.rewind(); - nuSamples.add(buffer); - } - } - return nuSamples; - } -} diff --git a/android-aac-enc/src/main/java/com/googlecode/mp4parser/authoring/builder/DefaultMp4Builder.java b/android-aac-enc/src/main/java/com/googlecode/mp4parser/authoring/builder/DefaultMp4Builder.java deleted file mode 100644 index a8e5d224b..000000000 --- a/android-aac-enc/src/main/java/com/googlecode/mp4parser/authoring/builder/DefaultMp4Builder.java +++ /dev/null @@ -1,547 +0,0 @@ -/* - * Copyright 2012 Sebastian Annies, Hamburg - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.googlecode.mp4parser.authoring.builder; - -import com.coremedia.iso.BoxParser; -import com.coremedia.iso.IsoFile; -import com.coremedia.iso.IsoTypeWriter; -import com.coremedia.iso.boxes.Box; -import com.coremedia.iso.boxes.CompositionTimeToSample; -import com.coremedia.iso.boxes.ContainerBox; -import com.coremedia.iso.boxes.DataEntryUrlBox; -import com.coremedia.iso.boxes.DataInformationBox; -import com.coremedia.iso.boxes.DataReferenceBox; -import com.coremedia.iso.boxes.EditBox; -import com.coremedia.iso.boxes.EditListBox; -import com.coremedia.iso.boxes.FileTypeBox; -import com.coremedia.iso.boxes.HandlerBox; -import com.coremedia.iso.boxes.MediaBox; -import com.coremedia.iso.boxes.MediaHeaderBox; -import com.coremedia.iso.boxes.MediaInformationBox; -import com.coremedia.iso.boxes.MovieBox; -import com.coremedia.iso.boxes.MovieHeaderBox; -import com.coremedia.iso.boxes.SampleDependencyTypeBox; -import com.coremedia.iso.boxes.SampleSizeBox; -import com.coremedia.iso.boxes.SampleTableBox; -import com.coremedia.iso.boxes.SampleToChunkBox; -import com.coremedia.iso.boxes.StaticChunkOffsetBox; -import com.coremedia.iso.boxes.SyncSampleBox; -import com.coremedia.iso.boxes.TimeToSampleBox; -import com.coremedia.iso.boxes.TrackBox; -import com.coremedia.iso.boxes.TrackHeaderBox; -import com.googlecode.mp4parser.authoring.DateHelper; -import com.googlecode.mp4parser.authoring.Movie; -import com.googlecode.mp4parser.authoring.Track; - -import java.io.IOException; -import java.nio.ByteBuffer; -import java.nio.MappedByteBuffer; -import java.nio.channels.GatheringByteChannel; -import java.nio.channels.ReadableByteChannel; -import java.nio.channels.WritableByteChannel; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Date; -import java.util.HashMap; -import java.util.HashSet; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.logging.Logger; - -import static com.googlecode.mp4parser.util.CastUtils.l2i; - -/** - * Creates a plain MP4 file from a video. Plain as plain can be. - */ -public class DefaultMp4Builder implements Mp4Builder { - Set chunkOffsetBoxes = new HashSet(); - private static Logger LOG = Logger.getLogger(DefaultMp4Builder.class.getName()); - - HashMap> track2Sample = new HashMap>(); - HashMap track2SampleSizes = new HashMap(); - private FragmentIntersectionFinder intersectionFinder = new TwoSecondIntersectionFinder(); - - List hdlrs = new LinkedList(); - - public void setAllowedHandlers(List hdlrs) { - this.hdlrs = hdlrs; - } - - public void setIntersectionFinder(FragmentIntersectionFinder intersectionFinder) { - this.intersectionFinder = intersectionFinder; - } - - /** - * {@inheritDoc} - */ - public IsoFile build(Movie movie) { - LOG.fine("Creating movie " + movie); - for (Track track : movie.getTracks()) { - // getting the samples may be a time consuming activity - List samples = track.getSamples(); - track2Sample.put(track, samples); - long[] sizes = new long[samples.size()]; - for (int i = 0; i < sizes.length; i++) { - sizes[i] = samples.get(i).limit(); - } - track2SampleSizes.put(track, sizes); - } - - IsoFile isoFile = new IsoFile(); - // ouch that is ugly but I don't know how to do it else - List minorBrands = new LinkedList(); - minorBrands.add("isom"); - minorBrands.add("iso2"); - minorBrands.add("avc1"); - - isoFile.addBox(new FileTypeBox("isom", 0, minorBrands)); - isoFile.addBox(createMovieBox(movie)); - InterleaveChunkMdat mdat = new InterleaveChunkMdat(movie); - isoFile.addBox(mdat); - - /* - dataOffset is where the first sample starts. In this special mdat the samples always start - at offset 16 so that we can use the same offset for large boxes and small boxes - */ - long dataOffset = mdat.getDataOffset(); - for (StaticChunkOffsetBox chunkOffsetBox : chunkOffsetBoxes) { - long[] offsets = chunkOffsetBox.getChunkOffsets(); - for (int i = 0; i < offsets.length; i++) { - offsets[i] += dataOffset; - } - } - - - return isoFile; - } - - private MovieBox createMovieBox(Movie movie) { - MovieBox movieBox = new MovieBox(); - List movieBoxChildren = new LinkedList(); - MovieHeaderBox mvhd = new MovieHeaderBox(); - mvhd.setVersion(1); - mvhd.setCreationTime(DateHelper.convert(new Date())); - mvhd.setModificationTime(DateHelper.convert(new Date())); - - long movieTimeScale = getTimescale(movie); - long duration = 0; - - for (Track track : movie.getTracks()) { - long tracksDuration = getDuration(track) * movieTimeScale / track.getTrackMetaData().getTimescale(); - if (tracksDuration > duration) { - duration = tracksDuration; - } - - - } - - mvhd.setDuration(duration); - mvhd.setTimescale(movieTimeScale); - // find the next available trackId - long nextTrackId = 0; - for (Track track : movie.getTracks()) { - nextTrackId = nextTrackId < track.getTrackMetaData().getTrackId() ? track.getTrackMetaData().getTrackId() : nextTrackId; - } - mvhd.setNextTrackId(++nextTrackId); - movieBoxChildren.add(mvhd); - for (Track track : movie.getTracks()) { - movieBoxChildren.add(createTrackBox(track, movie)); - } - // metadata here - movieBox.setBoxes(movieBoxChildren); - Box udta = createUdta(movie); - if (udta != null) { - movieBox.addBox(udta); - } - return movieBox; - - } - - /** - * Override to create a user data box that may contain metadata. - * @return a 'udta' box or null if none provided - */ - protected Box createUdta(Movie movie) { - return null; - } - - private TrackBox createTrackBox(Track track, Movie movie) { - - LOG.info("Creating Mp4TrackImpl " + track); - TrackBox trackBox = new TrackBox(); - TrackHeaderBox tkhd = new TrackHeaderBox(); - tkhd.setVersion(1); - int flags = 0; - if (track.isEnabled()) { - flags += 1; - } - - if (track.isInMovie()) { - flags += 2; - } - - if (track.isInPreview()) { - flags += 4; - } - - if (track.isInPoster()) { - flags += 8; - } - tkhd.setFlags(flags); - - tkhd.setAlternateGroup(track.getTrackMetaData().getGroup()); - tkhd.setCreationTime(DateHelper.convert(track.getTrackMetaData().getCreationTime())); - // We need to take edit list box into account in trackheader duration - // but as long as I don't support edit list boxes it is sufficient to - // just translate media duration to movie timescale - tkhd.setDuration(getDuration(track) * getTimescale(movie) / track.getTrackMetaData().getTimescale()); - tkhd.setHeight(track.getTrackMetaData().getHeight()); - tkhd.setWidth(track.getTrackMetaData().getWidth()); - tkhd.setLayer(track.getTrackMetaData().getLayer()); - tkhd.setModificationTime(DateHelper.convert(new Date())); - tkhd.setTrackId(track.getTrackMetaData().getTrackId()); - tkhd.setVolume(track.getTrackMetaData().getVolume()); - trackBox.addBox(tkhd); - -/* - EditBox edit = new EditBox(); - EditListBox editListBox = new EditListBox(); - editListBox.setEntries(Collections.singletonList( - new EditListBox.Entry(editListBox, (long) (track.getTrackMetaData().getStartTime() * getTimescale(movie)), -1, 1))); - edit.addBox(editListBox); - trackBox.addBox(edit); -*/ - - MediaBox mdia = new MediaBox(); - trackBox.addBox(mdia); - MediaHeaderBox mdhd = new MediaHeaderBox(); - mdhd.setCreationTime(DateHelper.convert(track.getTrackMetaData().getCreationTime())); - mdhd.setDuration(getDuration(track)); - mdhd.setTimescale(track.getTrackMetaData().getTimescale()); - mdhd.setLanguage(track.getTrackMetaData().getLanguage()); - mdia.addBox(mdhd); - HandlerBox hdlr = new HandlerBox(); - mdia.addBox(hdlr); - - hdlr.setHandlerType(track.getHandler()); - - MediaInformationBox minf = new MediaInformationBox(); - minf.addBox(track.getMediaHeaderBox()); - - // dinf: all these three boxes tell us is that the actual - // data is in the current file and not somewhere external - DataInformationBox dinf = new DataInformationBox(); - DataReferenceBox dref = new DataReferenceBox(); - dinf.addBox(dref); - DataEntryUrlBox url = new DataEntryUrlBox(); - url.setFlags(1); - dref.addBox(url); - minf.addBox(dinf); - // - - SampleTableBox stbl = new SampleTableBox(); - - stbl.addBox(track.getSampleDescriptionBox()); - - List decodingTimeToSampleEntries = track.getDecodingTimeEntries(); - if (decodingTimeToSampleEntries != null && !track.getDecodingTimeEntries().isEmpty()) { - TimeToSampleBox stts = new TimeToSampleBox(); - stts.setEntries(track.getDecodingTimeEntries()); - stbl.addBox(stts); - } - - List compositionTimeToSampleEntries = track.getCompositionTimeEntries(); - if (compositionTimeToSampleEntries != null && !compositionTimeToSampleEntries.isEmpty()) { - CompositionTimeToSample ctts = new CompositionTimeToSample(); - ctts.setEntries(compositionTimeToSampleEntries); - stbl.addBox(ctts); - } - - long[] syncSamples = track.getSyncSamples(); - if (syncSamples != null && syncSamples.length > 0) { - SyncSampleBox stss = new SyncSampleBox(); - stss.setSampleNumber(syncSamples); - stbl.addBox(stss); - } - - if (track.getSampleDependencies() != null && !track.getSampleDependencies().isEmpty()) { - SampleDependencyTypeBox sdtp = new SampleDependencyTypeBox(); - sdtp.setEntries(track.getSampleDependencies()); - stbl.addBox(sdtp); - } - int chunkSize[] = getChunkSizes(track, movie); - SampleToChunkBox stsc = new SampleToChunkBox(); - stsc.setEntries(new LinkedList()); - long lastChunkSize = Integer.MIN_VALUE; // to be sure the first chunks hasn't got the same size - for (int i = 0; i < chunkSize.length; i++) { - // The sample description index references the sample description box - // that describes the samples of this chunk. My Tracks cannot have more - // than one sample description box. Therefore 1 is always right - // the first chunk has the number '1' - if (lastChunkSize != chunkSize[i]) { - stsc.getEntries().add(new SampleToChunkBox.Entry(i + 1, chunkSize[i], 1)); - lastChunkSize = chunkSize[i]; - } - } - stbl.addBox(stsc); - - SampleSizeBox stsz = new SampleSizeBox(); - stsz.setSampleSizes(track2SampleSizes.get(track)); - - stbl.addBox(stsz); - // The ChunkOffsetBox we create here is just a stub - // since we haven't created the whole structure we can't tell where the - // first chunk starts (mdat box). So I just let the chunk offset - // start at zero and I will add the mdat offset later. - StaticChunkOffsetBox stco = new StaticChunkOffsetBox(); - this.chunkOffsetBoxes.add(stco); - long offset = 0; - long[] chunkOffset = new long[chunkSize.length]; - // all tracks have the same number of chunks - LOG.fine("Calculating chunk offsets for track_" + track.getTrackMetaData().getTrackId()); - for (int i = 0; i < chunkSize.length; i++) { - // The filelayout will be: - // chunk_1_track_1,... ,chunk_1_track_n, chunk_2_track_1,... ,chunk_2_track_n, ... , chunk_m_track_1,... ,chunk_m_track_n - // calculating the offsets - LOG.finer("Calculating chunk offsets for track_" + track.getTrackMetaData().getTrackId() + " chunk " + i); - for (Track current : movie.getTracks()) { - LOG.finest("Adding offsets of track_" + current.getTrackMetaData().getTrackId()); - int[] chunkSizes = getChunkSizes(current, movie); - long firstSampleOfChunk = 0; - for (int j = 0; j < i; j++) { - firstSampleOfChunk += chunkSizes[j]; - } - if (current == track) { - chunkOffset[i] = offset; - } - for (int j = l2i(firstSampleOfChunk); j < firstSampleOfChunk + chunkSizes[i]; j++) { - offset += track2SampleSizes.get(current)[j]; - } - } - } - stco.setChunkOffsets(chunkOffset); - stbl.addBox(stco); - minf.addBox(stbl); - mdia.addBox(minf); - - return trackBox; - } - - private class InterleaveChunkMdat implements Box { - List tracks; - List samples = new LinkedList(); - ContainerBox parent; - - long contentSize = 0; - - public ContainerBox getParent() { - return parent; - } - - public void setParent(ContainerBox parent) { - this.parent = parent; - } - - public void parse(ReadableByteChannel readableByteChannel, ByteBuffer header, long contentSize, BoxParser boxParser) throws IOException { - } - - private InterleaveChunkMdat(Movie movie) { - - tracks = movie.getTracks(); - Map chunks = new HashMap(); - for (Track track : movie.getTracks()) { - chunks.put(track, getChunkSizes(track, movie)); - } - - for (int i = 0; i < chunks.values().iterator().next().length; i++) { - for (Track track : tracks) { - - int[] chunkSizes = chunks.get(track); - long firstSampleOfChunk = 0; - for (int j = 0; j < i; j++) { - firstSampleOfChunk += chunkSizes[j]; - } - - for (int j = l2i(firstSampleOfChunk); j < firstSampleOfChunk + chunkSizes[i]; j++) { - - ByteBuffer s = DefaultMp4Builder.this.track2Sample.get(track).get(j); - contentSize += s.limit(); - samples.add((ByteBuffer) s.rewind()); - } - - } - - } - - } - - public long getDataOffset() { - Box b = this; - long offset = 16; - while (b.getParent() != null) { - for (Box box : b.getParent().getBoxes()) { - if (b == box) { - break; - } - offset += box.getSize(); - } - b = b.getParent(); - } - return offset; - } - - - public String getType() { - return "mdat"; - } - - public long getSize() { - return 16 + contentSize; - } - - private boolean isSmallBox(long contentSize) { - return (contentSize + 8) < 4294967296L; - } - - - public void getBox(WritableByteChannel writableByteChannel) throws IOException { - ByteBuffer bb = ByteBuffer.allocate(16); - long size = getSize(); - if (isSmallBox(size)) { - IsoTypeWriter.writeUInt32(bb, size); - } else { - IsoTypeWriter.writeUInt32(bb, 1); - } - bb.put(IsoFile.fourCCtoBytes("mdat")); - if (isSmallBox(size)) { - bb.put(new byte[8]); - } else { - IsoTypeWriter.writeUInt64(bb, size); - } - bb.rewind(); - writableByteChannel.write(bb); - if (writableByteChannel instanceof GatheringByteChannel) { - List nuSamples = unifyAdjacentBuffers(samples); - - int STEPSIZE = 1024; - for (int i = 0; i < Math.ceil((double) nuSamples.size() / STEPSIZE); i++) { - List sublist = nuSamples.subList( - i * STEPSIZE, // start - (i + 1) * STEPSIZE < nuSamples.size() ? (i + 1) * STEPSIZE : nuSamples.size()); // end - ByteBuffer sampleArray[] = sublist.toArray(new ByteBuffer[sublist.size()]); - do { - ((GatheringByteChannel) writableByteChannel).write(sampleArray); - } while (sampleArray[sampleArray.length - 1].remaining() > 0); - } - //System.err.println(bytesWritten); - } else { - for (ByteBuffer sample : samples) { - sample.rewind(); - writableByteChannel.write(sample); - } - } - } - - } - - /** - * Gets the chunk sizes for the given track. - * - * @param track - * @param movie - * @return - */ - int[] getChunkSizes(Track track, Movie movie) { - - long[] referenceChunkStarts = intersectionFinder.sampleNumbers(track, movie); - int[] chunkSizes = new int[referenceChunkStarts.length]; - - - for (int i = 0; i < referenceChunkStarts.length; i++) { - long start = referenceChunkStarts[i] - 1; - long end; - if (referenceChunkStarts.length == i + 1) { - end = track.getSamples().size() - 1; - } else { - end = referenceChunkStarts[i + 1] - 1; - } - - chunkSizes[i] = l2i(end - start); - // The Stretch makes sure that there are as much audio and video chunks! - } - assert DefaultMp4Builder.this.track2Sample.get(track).size() == sum(chunkSizes) : "The number of samples and the sum of all chunk lengths must be equal"; - return chunkSizes; - - - } - - - private static long sum(int[] ls) { - long rc = 0; - for (long l : ls) { - rc += l; - } - return rc; - } - - protected static long getDuration(Track track) { - long duration = 0; - for (TimeToSampleBox.Entry entry : track.getDecodingTimeEntries()) { - duration += entry.getCount() * entry.getDelta(); - } - return duration; - } - - public long getTimescale(Movie movie) { - long timescale = movie.getTracks().iterator().next().getTrackMetaData().getTimescale(); - for (Track track : movie.getTracks()) { - timescale = gcd(track.getTrackMetaData().getTimescale(), timescale); - } - return timescale; - } - - public static long gcd(long a, long b) { - if (b == 0) { - return a; - } - return gcd(b, a % b); - } - - public List unifyAdjacentBuffers(List samples) { - ArrayList nuSamples = new ArrayList(samples.size()); - for (ByteBuffer buffer : samples) { - int lastIndex = nuSamples.size() - 1; - if (lastIndex >= 0 && buffer.hasArray() && nuSamples.get(lastIndex).hasArray() && buffer.array() == nuSamples.get(lastIndex).array() && - nuSamples.get(lastIndex).arrayOffset() + nuSamples.get(lastIndex).limit() == buffer.arrayOffset()) { - ByteBuffer oldBuffer = nuSamples.remove(lastIndex); - ByteBuffer nu = ByteBuffer.wrap(buffer.array(), oldBuffer.arrayOffset(), oldBuffer.limit() + buffer.limit()).slice(); - // We need to slice here since wrap([], offset, length) just sets position and not the arrayOffset. - nuSamples.add(nu); - } else if (lastIndex >= 0 && - buffer instanceof MappedByteBuffer && nuSamples.get(lastIndex) instanceof MappedByteBuffer && - nuSamples.get(lastIndex).limit() == nuSamples.get(lastIndex).capacity() - buffer.capacity()) { - // This can go wrong - but will it? - ByteBuffer oldBuffer = nuSamples.get(lastIndex); - oldBuffer.limit(buffer.limit() + oldBuffer.limit()); - } else { - nuSamples.add(buffer); - } - } - return nuSamples; - } -} diff --git a/android-aac-enc/src/main/java/com/googlecode/mp4parser/authoring/builder/FragmentIntersectionFinder.java b/android-aac-enc/src/main/java/com/googlecode/mp4parser/authoring/builder/FragmentIntersectionFinder.java deleted file mode 100644 index 1224bbfb1..000000000 --- a/android-aac-enc/src/main/java/com/googlecode/mp4parser/authoring/builder/FragmentIntersectionFinder.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright 2012 Sebastian Annies, Hamburg - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.googlecode.mp4parser.authoring.builder; - -import com.googlecode.mp4parser.authoring.Movie; -import com.googlecode.mp4parser.authoring.Track; - -/** - * - */ -public interface FragmentIntersectionFinder { - /** - * Gets the ordinal number of the samples which will be the first sample - * in each fragment. - * - * @param track concerned track - * @param movie the context of the track - * @return an array containing the ordinal of each fragment's first sample - */ - public long[] sampleNumbers(Track track, Movie movie); -} diff --git a/android-aac-enc/src/main/java/com/googlecode/mp4parser/authoring/builder/FragmentedMp4Builder.java b/android-aac-enc/src/main/java/com/googlecode/mp4parser/authoring/builder/FragmentedMp4Builder.java deleted file mode 100644 index 801af0d94..000000000 --- a/android-aac-enc/src/main/java/com/googlecode/mp4parser/authoring/builder/FragmentedMp4Builder.java +++ /dev/null @@ -1,654 +0,0 @@ -/* - * Copyright 2012 Sebastian Annies, Hamburg - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.googlecode.mp4parser.authoring.builder; - -import com.coremedia.iso.BoxParser; -import com.coremedia.iso.IsoFile; -import com.coremedia.iso.IsoTypeWriter; -import com.coremedia.iso.boxes.Box; -import com.coremedia.iso.boxes.CompositionTimeToSample; -import com.coremedia.iso.boxes.ContainerBox; -import com.coremedia.iso.boxes.DataEntryUrlBox; -import com.coremedia.iso.boxes.DataInformationBox; -import com.coremedia.iso.boxes.DataReferenceBox; -import com.coremedia.iso.boxes.FileTypeBox; -import com.coremedia.iso.boxes.HandlerBox; -import com.coremedia.iso.boxes.MediaBox; -import com.coremedia.iso.boxes.MediaHeaderBox; -import com.coremedia.iso.boxes.MediaInformationBox; -import com.coremedia.iso.boxes.MovieBox; -import com.coremedia.iso.boxes.MovieHeaderBox; -import com.coremedia.iso.boxes.SampleDependencyTypeBox; -import com.coremedia.iso.boxes.SampleTableBox; -import com.coremedia.iso.boxes.StaticChunkOffsetBox; -import com.coremedia.iso.boxes.TimeToSampleBox; -import com.coremedia.iso.boxes.TrackBox; -import com.coremedia.iso.boxes.TrackHeaderBox; -import com.coremedia.iso.boxes.fragment.MovieExtendsBox; -import com.coremedia.iso.boxes.fragment.MovieFragmentBox; -import com.coremedia.iso.boxes.fragment.MovieFragmentHeaderBox; -import com.coremedia.iso.boxes.fragment.MovieFragmentRandomAccessBox; -import com.coremedia.iso.boxes.fragment.MovieFragmentRandomAccessOffsetBox; -import com.coremedia.iso.boxes.fragment.SampleFlags; -import com.coremedia.iso.boxes.fragment.TrackExtendsBox; -import com.coremedia.iso.boxes.fragment.TrackFragmentBox; -import com.coremedia.iso.boxes.fragment.TrackFragmentHeaderBox; -import com.coremedia.iso.boxes.fragment.TrackFragmentRandomAccessBox; -import com.coremedia.iso.boxes.fragment.TrackRunBox; -import com.googlecode.mp4parser.authoring.DateHelper; -import com.googlecode.mp4parser.authoring.Movie; -import com.googlecode.mp4parser.authoring.Track; - -import java.io.IOException; -import java.nio.ByteBuffer; -import java.nio.channels.GatheringByteChannel; -import java.nio.channels.ReadableByteChannel; -import java.nio.channels.WritableByteChannel; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.Comparator; -import java.util.Date; -import java.util.LinkedList; -import java.util.List; -import java.util.Queue; -import java.util.logging.Logger; - -import static com.googlecode.mp4parser.util.CastUtils.l2i; - -/** - * Creates a fragmented MP4 file. - */ -public class FragmentedMp4Builder implements Mp4Builder { - FragmentIntersectionFinder intersectionFinder = new SyncSampleIntersectFinderImpl(); - - private static final Logger LOG = Logger.getLogger(FragmentedMp4Builder.class.getName()); - - public List getAllowedHandlers() { - return Arrays.asList("soun", "vide"); - } - - public Box createFtyp(Movie movie) { - List minorBrands = new LinkedList(); - minorBrands.add("isom"); - minorBrands.add("iso2"); - minorBrands.add("avc1"); - return new FileTypeBox("isom", 0, minorBrands); - } - - protected List createMoofMdat(final Movie movie) { - List boxes = new LinkedList(); - int maxNumberOfFragments = 0; - for (Track track : movie.getTracks()) { - int currentLength = intersectionFinder.sampleNumbers(track, movie).length; - maxNumberOfFragments = currentLength > maxNumberOfFragments ? currentLength : maxNumberOfFragments; - } - int sequence = 1; - for (int i = 0; i < maxNumberOfFragments; i++) { - - final List sizeSortedTracks = new LinkedList(movie.getTracks()); - final int j = i; - Collections.sort(sizeSortedTracks, new Comparator() { - public int compare(Track o1, Track o2) { - long[] startSamples1 = intersectionFinder.sampleNumbers(o1, movie); - long startSample1 = startSamples1[j]; - // one based sample numbers - the first sample is 1 - long endSample1 = j + 1 < startSamples1.length ? startSamples1[j + 1] : o1.getSamples().size() + 1; - long[] startSamples2 = intersectionFinder.sampleNumbers(o2, movie); - long startSample2 = startSamples2[j]; - // one based sample numbers - the first sample is 1 - long endSample2 = j + 1 < startSamples2.length ? startSamples2[j + 1] : o2.getSamples().size() + 1; - List samples1 = o1.getSamples().subList(l2i(startSample1) - 1, l2i(endSample1) - 1); - List samples2 = o2.getSamples().subList(l2i(startSample2) - 1, l2i(endSample2) - 1); - int size1 = 0; - for (ByteBuffer byteBuffer : samples1) { - size1 += byteBuffer.limit(); - } - int size2 = 0; - for (ByteBuffer byteBuffer : samples2) { - size2 += byteBuffer.limit(); - } - return size1 - size2; - } - }); - - for (Track track : sizeSortedTracks) { - if (getAllowedHandlers().isEmpty() || getAllowedHandlers().contains(track.getHandler())) { - long[] startSamples = intersectionFinder.sampleNumbers(track, movie); - - if (i < startSamples.length) { - long startSample = startSamples[i]; - // one based sample numbers - the first sample is 1 - long endSample = i + 1 < startSamples.length ? startSamples[i + 1] : track.getSamples().size() + 1; - - if (startSample == endSample) { - // empty fragment - // just don't add any boxes. - } else { - boxes.add(createMoof(startSample, endSample, track, sequence)); - boxes.add(createMdat(startSample, endSample, track, sequence++)); - } - - } else { - //obvious this track has not that many fragments - } - } - } - - - } - return boxes; - } - - /** - * {@inheritDoc} - */ - public IsoFile build(Movie movie) { - LOG.fine("Creating movie " + movie); - IsoFile isoFile = new IsoFile(); - - - isoFile.addBox(createFtyp(movie)); - isoFile.addBox(createMoov(movie)); - - for (Box box : createMoofMdat(movie)) { - isoFile.addBox(box); - } - isoFile.addBox(createMfra(movie, isoFile)); - - return isoFile; - } - - protected Box createMdat(final long startSample, final long endSample, final Track track, final int i) { - - class Mdat implements Box { - ContainerBox parent; - - public ContainerBox getParent() { - return parent; - } - - public void setParent(ContainerBox parent) { - this.parent = parent; - } - - public long getSize() { - long size = 8; // I don't expect 2gig fragments - for (ByteBuffer sample : getSamples(startSample, endSample, track, i)) { - size += sample.limit(); - } - return size; - } - - public String getType() { - return "mdat"; - } - - public void getBox(WritableByteChannel writableByteChannel) throws IOException { - List bbs = getSamples(startSample, endSample, track, i); - final List samples = ByteBufferHelper.mergeAdjacentBuffers(bbs); - ByteBuffer header = ByteBuffer.allocate(8); - IsoTypeWriter.writeUInt32(header, l2i(getSize())); - header.put(IsoFile.fourCCtoBytes(getType())); - header.rewind(); - writableByteChannel.write(header); - if (writableByteChannel instanceof GatheringByteChannel) { - - int STEPSIZE = 1024; - for (int i = 0; i < Math.ceil((double) samples.size() / STEPSIZE); i++) { - List sublist = samples.subList( - i * STEPSIZE, // start - (i + 1) * STEPSIZE < samples.size() ? (i + 1) * STEPSIZE : samples.size()); // end - ByteBuffer sampleArray[] = sublist.toArray(new ByteBuffer[sublist.size()]); - do { - ((GatheringByteChannel) writableByteChannel).write(sampleArray); - } while (sampleArray[sampleArray.length - 1].remaining() > 0); - } - //System.err.println(bytesWritten); - } else { - for (ByteBuffer sample : samples) { - sample.rewind(); - writableByteChannel.write(sample); - } - } - - } - - public void parse(ReadableByteChannel readableByteChannel, ByteBuffer header, long contentSize, BoxParser boxParser) throws IOException { - - } - } - - return new Mdat(); - } - - protected Box createTfhd(long startSample, long endSample, Track track, int sequenceNumber) { - TrackFragmentHeaderBox tfhd = new TrackFragmentHeaderBox(); - SampleFlags sf = new SampleFlags(); - - tfhd.setDefaultSampleFlags(sf); - tfhd.setBaseDataOffset(-1); - tfhd.setTrackId(track.getTrackMetaData().getTrackId()); - return tfhd; - } - - protected Box createMfhd(long startSample, long endSample, Track track, int sequenceNumber) { - MovieFragmentHeaderBox mfhd = new MovieFragmentHeaderBox(); - mfhd.setSequenceNumber(sequenceNumber); - return mfhd; - } - - protected Box createTraf(long startSample, long endSample, Track track, int sequenceNumber) { - TrackFragmentBox traf = new TrackFragmentBox(); - traf.addBox(createTfhd(startSample, endSample, track, sequenceNumber)); - for (Box trun : createTruns(startSample, endSample, track, sequenceNumber)) { - traf.addBox(trun); - } - - return traf; - } - - - /** - * @param startSample first sample in list starting with 1. 1 is the first sample. - * @param endSample - * @param track - * @param sequenceNumber - * @return - */ - protected List getSamples(long startSample, long endSample, Track track, int sequenceNumber) { - // since startSample and endSample are one-based substract 1 before addressing list elements - return track.getSamples().subList(l2i(startSample) - 1, l2i(endSample) - 1); - } - - - protected List createTruns(long startSample, long endSample, Track track, int sequenceNumber) { - List samples = getSamples(startSample, endSample, track, sequenceNumber); - - long[] sampleSizes = new long[samples.size()]; - for (int i = 0; i < sampleSizes.length; i++) { - sampleSizes[i] = samples.get(i).limit(); - } - TrackRunBox trun = new TrackRunBox(); - - - trun.setSampleDurationPresent(true); - trun.setSampleSizePresent(true); - List entries = new ArrayList(l2i(endSample - startSample)); - - - Queue timeQueue = new LinkedList(track.getDecodingTimeEntries()); - long left = startSample; - long curEntryLeft = timeQueue.peek().getCount(); - while (left >= curEntryLeft) { - left -= curEntryLeft; - timeQueue.remove(); - curEntryLeft = timeQueue.peek().getCount(); - } - curEntryLeft -= left; - - - Queue compositionTimeQueue = - track.getCompositionTimeEntries() != null && track.getCompositionTimeEntries().size() > 0 ? - new LinkedList(track.getCompositionTimeEntries()) : null; - long compositionTimeEntriesLeft = compositionTimeQueue != null ? compositionTimeQueue.peek().getCount() : -1; - - - trun.setSampleCompositionTimeOffsetPresent(compositionTimeEntriesLeft > 0); - - // fast forward composition stuff - for (long i = 1; i < startSample; i++) { - if (compositionTimeQueue != null) { - trun.setSampleCompositionTimeOffsetPresent(true); - if (--compositionTimeEntriesLeft == 0 && compositionTimeQueue.size() > 1) { - compositionTimeQueue.remove(); - compositionTimeEntriesLeft = compositionTimeQueue.element().getCount(); - } - } - } - - boolean sampleFlagsRequired = (track.getSampleDependencies() != null && !track.getSampleDependencies().isEmpty() || - track.getSyncSamples() != null && track.getSyncSamples().length != 0); - - trun.setSampleFlagsPresent(sampleFlagsRequired); - - for (int i = 0; i < sampleSizes.length; i++) { - TrackRunBox.Entry entry = new TrackRunBox.Entry(); - entry.setSampleSize(sampleSizes[i]); - if (sampleFlagsRequired) { - //if (false) { - SampleFlags sflags = new SampleFlags(); - - if (track.getSampleDependencies() != null && !track.getSampleDependencies().isEmpty()) { - SampleDependencyTypeBox.Entry e = track.getSampleDependencies().get(i); - sflags.setSampleDependsOn(e.getSampleDependsOn()); - sflags.setSampleIsDependedOn(e.getSampleIsDependentOn()); - sflags.setSampleHasRedundancy(e.getSampleHasRedundancy()); - } - if (track.getSyncSamples() != null && track.getSyncSamples().length > 0) { - // we have to mark non-sync samples! - if (Arrays.binarySearch(track.getSyncSamples(), startSample + i) >= 0) { - sflags.setSampleIsDifferenceSample(false); - sflags.setSampleDependsOn(2); - } else { - sflags.setSampleIsDifferenceSample(true); - sflags.setSampleDependsOn(1); - } - } - // i don't have sample degradation - entry.setSampleFlags(sflags); - - } - - entry.setSampleDuration(timeQueue.peek().getDelta()); - if (--curEntryLeft == 0 && timeQueue.size() > 1) { - timeQueue.remove(); - curEntryLeft = timeQueue.peek().getCount(); - } - - if (compositionTimeQueue != null) { - trun.setSampleCompositionTimeOffsetPresent(true); - entry.setSampleCompositionTimeOffset(compositionTimeQueue.peek().getOffset()); - if (--compositionTimeEntriesLeft == 0 && compositionTimeQueue.size() > 1) { - compositionTimeQueue.remove(); - compositionTimeEntriesLeft = compositionTimeQueue.element().getCount(); - } - } - entries.add(entry); - } - - trun.setEntries(entries); - - return Collections.singletonList(trun); - } - - protected Box createMoof(long startSample, long endSample, Track track, int sequenceNumber) { - - - MovieFragmentBox moof = new MovieFragmentBox(); - moof.addBox(createMfhd(startSample, endSample, track, sequenceNumber)); - moof.addBox(createTraf(startSample, endSample, track, sequenceNumber)); - - TrackRunBox firstTrun = moof.getTrackRunBoxes().get(0); - firstTrun.setDataOffset(1); // dummy to make size correct - firstTrun.setDataOffset((int) (8 + moof.getSize())); // mdat header + moof size - - return moof; - } - - protected Box createMvhd(Movie movie) { - MovieHeaderBox mvhd = new MovieHeaderBox(); - mvhd.setVersion(1); - mvhd.setCreationTime(DateHelper.convert(new Date())); - mvhd.setModificationTime(DateHelper.convert(new Date())); - long movieTimeScale = movie.getTimescale(); - long duration = 0; - - for (Track track : movie.getTracks()) { - long tracksDuration = getDuration(track) * movieTimeScale / track.getTrackMetaData().getTimescale(); - if (tracksDuration > duration) { - duration = tracksDuration; - } - - - } - - mvhd.setDuration(duration); - mvhd.setTimescale(movieTimeScale); - // find the next available trackId - long nextTrackId = 0; - for (Track track : movie.getTracks()) { - nextTrackId = nextTrackId < track.getTrackMetaData().getTrackId() ? track.getTrackMetaData().getTrackId() : nextTrackId; - } - mvhd.setNextTrackId(++nextTrackId); - return mvhd; - } - - protected Box createMoov(Movie movie) { - MovieBox movieBox = new MovieBox(); - - movieBox.addBox(createMvhd(movie)); - movieBox.addBox(createMvex(movie)); - - for (Track track : movie.getTracks()) { - movieBox.addBox(createTrak(track, movie)); - } - // metadata here - return movieBox; - - } - - protected Box createTfra(Track track, IsoFile isoFile) { - TrackFragmentRandomAccessBox tfra = new TrackFragmentRandomAccessBox(); - tfra.setVersion(1); // use long offsets and times - List offset2timeEntries = new LinkedList(); - List boxes = isoFile.getBoxes(); - long offset = 0; - long duration = 0; - for (Box box : boxes) { - if (box instanceof MovieFragmentBox) { - List trafs = ((MovieFragmentBox) box).getBoxes(TrackFragmentBox.class); - for (int i = 0; i < trafs.size(); i++) { - TrackFragmentBox traf = trafs.get(i); - if (traf.getTrackFragmentHeaderBox().getTrackId() == track.getTrackMetaData().getTrackId()) { - // here we are at the offset required for the current entry. - List truns = traf.getBoxes(TrackRunBox.class); - for (int j = 0; j < truns.size(); j++) { - List offset2timeEntriesThisTrun = new LinkedList(); - TrackRunBox trun = truns.get(j); - for (int k = 0; k < trun.getEntries().size(); k++) { - TrackRunBox.Entry trunEntry = trun.getEntries().get(k); - SampleFlags sf = null; - if (k == 0 && trun.isFirstSampleFlagsPresent()) { - sf = trun.getFirstSampleFlags(); - } else if (trun.isSampleFlagsPresent()) { - sf = trunEntry.getSampleFlags(); - } else { - List mvexs = isoFile.getMovieBox().getBoxes(MovieExtendsBox.class); - for (MovieExtendsBox mvex : mvexs) { - List trexs = mvex.getBoxes(TrackExtendsBox.class); - for (TrackExtendsBox trex : trexs) { - if (trex.getTrackId() == track.getTrackMetaData().getTrackId()) { - sf = trex.getDefaultSampleFlags(); - } - } - } - - } - if (sf == null) { - throw new RuntimeException("Could not find any SampleFlags to indicate random access or not"); - } - if (sf.getSampleDependsOn() == 2) { - offset2timeEntriesThisTrun.add(new TrackFragmentRandomAccessBox.Entry( - duration, - offset, - i + 1, j + 1, k + 1)); - } - duration += trunEntry.getSampleDuration(); - } - if (offset2timeEntriesThisTrun.size() == trun.getEntries().size() && trun.getEntries().size() > 0) { - // Oooops every sample seems to be random access sample - // is this an audio track? I don't care. - // I just use the first for trun sample for tfra random access - offset2timeEntries.add(offset2timeEntriesThisTrun.get(0)); - } else { - offset2timeEntries.addAll(offset2timeEntriesThisTrun); - } - } - } - } - } - - - offset += box.getSize(); - } - tfra.setEntries(offset2timeEntries); - tfra.setTrackId(track.getTrackMetaData().getTrackId()); - return tfra; - } - - protected Box createMfra(Movie movie, IsoFile isoFile) { - MovieFragmentRandomAccessBox mfra = new MovieFragmentRandomAccessBox(); - for (Track track : movie.getTracks()) { - mfra.addBox(createTfra(track, isoFile)); - } - - MovieFragmentRandomAccessOffsetBox mfro = new MovieFragmentRandomAccessOffsetBox(); - mfra.addBox(mfro); - mfro.setMfraSize(mfra.getSize()); - return mfra; - } - - protected Box createTrex(Movie movie, Track track) { - TrackExtendsBox trex = new TrackExtendsBox(); - trex.setTrackId(track.getTrackMetaData().getTrackId()); - trex.setDefaultSampleDescriptionIndex(1); - trex.setDefaultSampleDuration(0); - trex.setDefaultSampleSize(0); - SampleFlags sf = new SampleFlags(); - if ("soun".equals(track.getHandler())) { - // as far as I know there is no audio encoding - // where the sample are not self contained. - sf.setSampleDependsOn(2); - sf.setSampleIsDependedOn(2); - } - trex.setDefaultSampleFlags(sf); - return trex; - } - - - protected Box createMvex(Movie movie) { - MovieExtendsBox mvex = new MovieExtendsBox(); - - for (Track track : movie.getTracks()) { - mvex.addBox(createTrex(movie, track)); - } - return mvex; - } - - protected Box createTkhd(Movie movie, Track track) { - TrackHeaderBox tkhd = new TrackHeaderBox(); - tkhd.setVersion(1); - int flags = 0; - if (track.isEnabled()) { - flags += 1; - } - - if (track.isInMovie()) { - flags += 2; - } - - if (track.isInPreview()) { - flags += 4; - } - - if (track.isInPoster()) { - flags += 8; - } - tkhd.setFlags(flags); - - tkhd.setAlternateGroup(track.getTrackMetaData().getGroup()); - tkhd.setCreationTime(DateHelper.convert(track.getTrackMetaData().getCreationTime())); - // We need to take edit list box into account in trackheader duration - // but as long as I don't support edit list boxes it is sufficient to - // just translate media duration to movie timescale - tkhd.setDuration(getDuration(track) * movie.getTimescale() / track.getTrackMetaData().getTimescale()); - tkhd.setHeight(track.getTrackMetaData().getHeight()); - tkhd.setWidth(track.getTrackMetaData().getWidth()); - tkhd.setLayer(track.getTrackMetaData().getLayer()); - tkhd.setModificationTime(DateHelper.convert(new Date())); - tkhd.setTrackId(track.getTrackMetaData().getTrackId()); - tkhd.setVolume(track.getTrackMetaData().getVolume()); - return tkhd; - } - - protected Box createMdhd(Movie movie, Track track) { - MediaHeaderBox mdhd = new MediaHeaderBox(); - mdhd.setCreationTime(DateHelper.convert(track.getTrackMetaData().getCreationTime())); - mdhd.setDuration(getDuration(track)); - mdhd.setTimescale(track.getTrackMetaData().getTimescale()); - mdhd.setLanguage(track.getTrackMetaData().getLanguage()); - return mdhd; - } - - protected Box createStbl(Movie movie, Track track) { - SampleTableBox stbl = new SampleTableBox(); - - stbl.addBox(track.getSampleDescriptionBox()); - stbl.addBox(new TimeToSampleBox()); - //stbl.addBox(new SampleToChunkBox()); - stbl.addBox(new StaticChunkOffsetBox()); - return stbl; - } - - protected Box createMinf(Track track, Movie movie) { - MediaInformationBox minf = new MediaInformationBox(); - minf.addBox(track.getMediaHeaderBox()); - minf.addBox(createDinf(movie, track)); - minf.addBox(createStbl(movie, track)); - return minf; - } - - protected Box createMdiaHdlr(Track track, Movie movie) { - HandlerBox hdlr = new HandlerBox(); - hdlr.setHandlerType(track.getHandler()); - return hdlr; - } - - protected Box createMdia(Track track, Movie movie) { - MediaBox mdia = new MediaBox(); - mdia.addBox(createMdhd(movie, track)); - - - mdia.addBox(createMdiaHdlr(track, movie)); - - - mdia.addBox(createMinf(track, movie)); - return mdia; - } - - protected Box createTrak(Track track, Movie movie) { - LOG.fine("Creating Track " + track); - TrackBox trackBox = new TrackBox(); - trackBox.addBox(createTkhd(movie, track)); - trackBox.addBox(createMdia(track, movie)); - return trackBox; - } - - protected DataInformationBox createDinf(Movie movie, Track track) { - DataInformationBox dinf = new DataInformationBox(); - DataReferenceBox dref = new DataReferenceBox(); - dinf.addBox(dref); - DataEntryUrlBox url = new DataEntryUrlBox(); - url.setFlags(1); - dref.addBox(url); - return dinf; - } - - public void setIntersectionFinder(FragmentIntersectionFinder intersectionFinder) { - this.intersectionFinder = intersectionFinder; - } - - protected long getDuration(Track track) { - long duration = 0; - for (TimeToSampleBox.Entry entry : track.getDecodingTimeEntries()) { - duration += entry.getCount() * entry.getDelta(); - } - return duration; - } - - -} diff --git a/android-aac-enc/src/main/java/com/googlecode/mp4parser/authoring/builder/Mp4Builder.java b/android-aac-enc/src/main/java/com/googlecode/mp4parser/authoring/builder/Mp4Builder.java deleted file mode 100644 index b44f70a95..000000000 --- a/android-aac-enc/src/main/java/com/googlecode/mp4parser/authoring/builder/Mp4Builder.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright 2012 Sebastian Annies, Hamburg - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.googlecode.mp4parser.authoring.builder; - -import com.coremedia.iso.IsoFile; -import com.googlecode.mp4parser.authoring.Movie; - -import java.io.IOException; - -/** - * Transforms a Movie object to an IsoFile. Implementations can - * determine the specific format: Fragmented MP4, MP4, MP4 with Apple Metadata, - * MP4 with 3GPP Metadata, MOV. - */ -public interface Mp4Builder { - /** - * Builds the actual IsoFile from the Movie. - * - * @param movie data source - * @return the freshly built IsoFile - */ - public IsoFile build(Movie movie); - -} diff --git a/android-aac-enc/src/main/java/com/googlecode/mp4parser/authoring/builder/SyncSampleIntersectFinderImpl.java b/android-aac-enc/src/main/java/com/googlecode/mp4parser/authoring/builder/SyncSampleIntersectFinderImpl.java deleted file mode 100644 index d74052268..000000000 --- a/android-aac-enc/src/main/java/com/googlecode/mp4parser/authoring/builder/SyncSampleIntersectFinderImpl.java +++ /dev/null @@ -1,205 +0,0 @@ -/* - * Copyright 2012 Sebastian Annies, Hamburg - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.googlecode.mp4parser.authoring.builder; - -import com.coremedia.iso.boxes.TimeToSampleBox; -import com.coremedia.iso.boxes.sampleentry.AudioSampleEntry; -import com.googlecode.mp4parser.authoring.Movie; -import com.googlecode.mp4parser.authoring.Track; - -import java.util.Arrays; -import java.util.LinkedList; -import java.util.List; -import java.util.Queue; -import java.util.logging.Logger; - -import static com.googlecode.mp4parser.util.Math.lcm; - -/** - * This FragmentIntersectionFinder cuts the input movie video tracks in - * fragments of the same length exactly before the sync samples. Audio tracks are cut - * into pieces of similar length. - */ -public class SyncSampleIntersectFinderImpl implements FragmentIntersectionFinder { - - private static Logger LOG = Logger.getLogger(SyncSampleIntersectFinderImpl.class.getName()); - - /** - * Gets an array of sample numbers that are meant to be the first sample of each - * chunk or fragment. - * - * @param track concerned track - * @param movie the context of the track - * @return an array containing the ordinal of each fragment's first sample - */ - public long[] sampleNumbers(Track track, Movie movie) { - if ("vide".equals(track.getHandler())) { - if (track.getSyncSamples() != null && track.getSyncSamples().length > 0) { - List times = getSyncSamplesTimestamps(movie, track); - return getCommonIndices(track.getSyncSamples(), getTimes(movie, track), times.toArray(new long[times.size()][])); - } else { - throw new RuntimeException("Video Tracks need sync samples. Only tracks other than video may have no sync samples."); - } - } else if ("soun".equals(track.getHandler())) { - Track referenceTrack = null; - for (Track candidate : movie.getTracks()) { - if (candidate.getSyncSamples() != null && candidate.getSyncSamples().length > 0) { - referenceTrack = candidate; - } - } - if (referenceTrack != null) { - - // Gets the reference track's fra - long[] refSyncSamples = sampleNumbers(referenceTrack, movie); - - int refSampleCount = referenceTrack.getSamples().size(); - - long[] syncSamples = new long[refSyncSamples.length]; - long minSampleRate = 192000; - for (Track testTrack : movie.getTracks()) { - if ("soun".equals(testTrack.getHandler())) { - AudioSampleEntry ase = (AudioSampleEntry) testTrack.getSampleDescriptionBox().getSampleEntry(); - if (ase.getSampleRate() < minSampleRate) { - minSampleRate = ase.getSampleRate(); - long sc = testTrack.getSamples().size(); - double stretch = (double) sc / refSampleCount; - - for (int i = 0; i < syncSamples.length; i++) { - int start = (int) Math.ceil(stretch * (refSyncSamples[i] - 1)) + 1; - syncSamples[i] = start; - // The Stretch makes sure that there are as much audio and video chunks! - } - } - } - } - AudioSampleEntry ase = (AudioSampleEntry) track.getSampleDescriptionBox().getSampleEntry(); - double factor = (double) ase.getSampleRate() / (double) minSampleRate; - if (factor != Math.rint(factor)) { // Not an integer - throw new RuntimeException("Sample rates must be a multiple of the lowest sample rate to create a correct file!"); - } - for (int i = 1; i < syncSamples.length; i++) { - syncSamples[i] = (int) (1 + (syncSamples[i] - 1) * factor); - } - return syncSamples; - } - throw new RuntimeException("There was absolutely no Track with sync samples. I can't work with that!"); - } else { - // Ok, my track has no sync samples - let's find one with sync samples. - for (Track candidate : movie.getTracks()) { - if (candidate.getSyncSamples() != null && candidate.getSyncSamples().length > 0) { - long[] refSyncSamples = sampleNumbers(candidate, movie); - int refSampleCount = candidate.getSamples().size(); - - long[] syncSamples = new long[refSyncSamples.length]; - long sc = track.getSamples().size(); - double stretch = (double) sc / refSampleCount; - - for (int i = 0; i < syncSamples.length; i++) { - int start = (int) Math.ceil(stretch * (refSyncSamples[i] - 1)) + 1; - syncSamples[i] = start; - // The Stretch makes sure that there are as much audio and video chunks! - } - return syncSamples; - } - } - throw new RuntimeException("There was absolutely no Track with sync samples. I can't work with that!"); - } - - - } - - /** - * Calculates the timestamp of all tracks' sync samples. - * - * @param movie - * @param track - * @return - */ - public static List getSyncSamplesTimestamps(Movie movie, Track track) { - List times = new LinkedList(); - for (Track currentTrack : movie.getTracks()) { - if (currentTrack.getHandler().equals(track.getHandler())) { - long[] currentTrackSyncSamples = currentTrack.getSyncSamples(); - if (currentTrackSyncSamples != null && currentTrackSyncSamples.length > 0) { - final long[] currentTrackTimes = getTimes(movie, currentTrack); - times.add(currentTrackTimes); - } - } - } - return times; - } - - public static long[] getCommonIndices(long[] syncSamples, long[] syncSampleTimes, long[]... otherTracksTimes) { - List nuSyncSamples = new LinkedList(); - for (int i = 0; i < syncSampleTimes.length; i++) { - boolean foundInEveryRef = true; - for (long[] times : otherTracksTimes) { - foundInEveryRef &= (Arrays.binarySearch(times, syncSampleTimes[i]) >= 0); - } - if (foundInEveryRef) { - nuSyncSamples.add(syncSamples[i]); - } - } - long[] nuSyncSampleArray = new long[nuSyncSamples.size()]; - for (int i = 0; i < nuSyncSampleArray.length; i++) { - nuSyncSampleArray[i] = nuSyncSamples.get(i); - } - if (nuSyncSampleArray.length < (syncSamples.length * 0.3)) { - LOG.warning("There are less than 25% of common sync samples in the given track."); - throw new RuntimeException("There are less than 25% of common sync samples in the given track."); - } else if (nuSyncSampleArray.length < (syncSamples.length * 0.5)) { - LOG.fine("There are less than 50% of common sync samples in the given track. This is implausible but I'm ok to continue."); - } else if (nuSyncSampleArray.length < syncSamples.length) { - LOG.finest("Common SyncSample positions vs. this tracks SyncSample positions: " + nuSyncSampleArray.length + " vs. " + syncSamples.length); - } - return nuSyncSampleArray; - } - - - private static long[] getTimes(Movie m, Track track) { - long[] syncSamples = track.getSyncSamples(); - long[] syncSampleTimes = new long[syncSamples.length]; - Queue timeQueue = new LinkedList(track.getDecodingTimeEntries()); - - int currentSample = 1; // first syncsample is 1 - long currentDuration = 0; - long currentDelta = 0; - int currentSyncSampleIndex = 0; - long left = 0; - - long timeScale = 1; - for (Track track1 : m.getTracks()) { - if (track1.getTrackMetaData().getTimescale() != track.getTrackMetaData().getTimescale()) { - timeScale = lcm(timeScale, track1.getTrackMetaData().getTimescale()); - } - } - - - while (currentSample <= syncSamples[syncSamples.length - 1]) { - if (currentSample++ == syncSamples[currentSyncSampleIndex]) { - syncSampleTimes[currentSyncSampleIndex++] = currentDuration * timeScale; - } - if (left-- == 0) { - TimeToSampleBox.Entry entry = timeQueue.poll(); - left = entry.getCount(); - currentDelta = entry.getDelta(); - } - currentDuration += currentDelta; - } - return syncSampleTimes; - - } -} diff --git a/android-aac-enc/src/main/java/com/googlecode/mp4parser/authoring/builder/TwoSecondIntersectionFinder.java b/android-aac-enc/src/main/java/com/googlecode/mp4parser/authoring/builder/TwoSecondIntersectionFinder.java deleted file mode 100644 index 89960723a..000000000 --- a/android-aac-enc/src/main/java/com/googlecode/mp4parser/authoring/builder/TwoSecondIntersectionFinder.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright 2012 Sebastian Annies, Hamburg - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.googlecode.mp4parser.authoring.builder; - -import java.util.Arrays; -import java.util.List; - -import com.coremedia.iso.boxes.TimeToSampleBox; -import com.googlecode.mp4parser.authoring.Movie; -import com.googlecode.mp4parser.authoring.Track; - -/** - * This FragmentIntersectionFinder cuts the input movie in 2 second - * snippets. - */ -public class TwoSecondIntersectionFinder implements FragmentIntersectionFinder { - - protected long getDuration(Track track) { - long duration = 0; - for (TimeToSampleBox.Entry entry : track.getDecodingTimeEntries()) { - duration += entry.getCount() * entry.getDelta(); - } - return duration; - } - - /** - * {@inheritDoc} - */ - public long[] sampleNumbers(Track track, Movie movie) { - List entries = track.getDecodingTimeEntries(); - - double trackLength = 0; - for (Track thisTrack : movie.getTracks()) { - double thisTracksLength = getDuration(thisTrack) / thisTrack.getTrackMetaData().getTimescale(); - if (trackLength < thisTracksLength) { - trackLength = thisTracksLength; - } - } - - long fragments[] = new long[(int) Math.max(2, Math.ceil(trackLength / 2)) - 1]; - Arrays.fill(fragments, -1); - fragments[0] = 0; - - long time = 0; - int samples = 0; - for (TimeToSampleBox.Entry entry : entries) { - for (int i = 0; i < entry.getCount(); i++) { - int currentFragment = (int) (time / track.getTrackMetaData().getTimescale() / 2) + 1; - if (currentFragment >= fragments.length) { - break; - } - fragments[currentFragment] = samples++; - time += entry.getDelta(); - } - } - long last = samples; - // fill all -1 ones. - for (int i = fragments.length - 1; i >= 0; i--) { - if (fragments[i] == -1) { - fragments[i] = last; - } - last = fragments[i]; - } - return fragments; - - } - -} diff --git a/android-aac-enc/src/main/java/com/googlecode/mp4parser/authoring/builder/smoothstreaming/AudioQuality.java b/android-aac-enc/src/main/java/com/googlecode/mp4parser/authoring/builder/smoothstreaming/AudioQuality.java deleted file mode 100644 index d05c9db0e..000000000 --- a/android-aac-enc/src/main/java/com/googlecode/mp4parser/authoring/builder/smoothstreaming/AudioQuality.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright 2012 Sebastian Annies, Hamburg - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.googlecode.mp4parser.authoring.builder.smoothstreaming; - - -public class AudioQuality { - long bitrate; - int audioTag; - long samplingRate; - int channels; - int bitPerSample; - int packetSize; - String language; - String codecPrivateData; -} diff --git a/android-aac-enc/src/main/java/com/googlecode/mp4parser/authoring/builder/smoothstreaming/ManifestWriter.java b/android-aac-enc/src/main/java/com/googlecode/mp4parser/authoring/builder/smoothstreaming/ManifestWriter.java deleted file mode 100644 index 27e0bbf76..000000000 --- a/android-aac-enc/src/main/java/com/googlecode/mp4parser/authoring/builder/smoothstreaming/ManifestWriter.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright 2012 Sebastian Annies, Hamburg - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.googlecode.mp4parser.authoring.builder.smoothstreaming; - - -import com.googlecode.mp4parser.authoring.Movie; -import com.googlecode.mp4parser.authoring.Track; - -import java.io.IOException; - -public interface ManifestWriter { - String getManifest(Movie inputs) throws IOException; - - long getBitrate(Track track); - - long[] calculateFragmentDurations(Track track, Movie movie); - -} diff --git a/android-aac-enc/src/main/java/com/googlecode/mp4parser/authoring/builder/smoothstreaming/PackageWriter.java b/android-aac-enc/src/main/java/com/googlecode/mp4parser/authoring/builder/smoothstreaming/PackageWriter.java deleted file mode 100644 index 0d77d184d..000000000 --- a/android-aac-enc/src/main/java/com/googlecode/mp4parser/authoring/builder/smoothstreaming/PackageWriter.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2012 Sebastian Annies, Hamburg - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.googlecode.mp4parser.authoring.builder.smoothstreaming; - -import com.googlecode.mp4parser.authoring.Movie; - -import java.io.IOException; - -/** - * Writes the whole package. - */ -public interface PackageWriter { - public void write(Movie qualities) throws IOException; -} diff --git a/android-aac-enc/src/main/java/com/googlecode/mp4parser/authoring/builder/smoothstreaming/VideoQuality.java b/android-aac-enc/src/main/java/com/googlecode/mp4parser/authoring/builder/smoothstreaming/VideoQuality.java deleted file mode 100644 index bd9282af9..000000000 --- a/android-aac-enc/src/main/java/com/googlecode/mp4parser/authoring/builder/smoothstreaming/VideoQuality.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright 2012 Sebastian Annies, Hamburg - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.googlecode.mp4parser.authoring.builder.smoothstreaming; - -class VideoQuality { - long bitrate; - String fourCC; - int width; - int height; - String codecPrivateData; - int nalLength; -} diff --git a/android-aac-enc/src/main/java/com/googlecode/mp4parser/authoring/container/mp4/MovieCreator.java b/android-aac-enc/src/main/java/com/googlecode/mp4parser/authoring/container/mp4/MovieCreator.java deleted file mode 100644 index ed9d15f89..000000000 --- a/android-aac-enc/src/main/java/com/googlecode/mp4parser/authoring/container/mp4/MovieCreator.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright 2012 Sebastian Annies, Hamburg - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.googlecode.mp4parser.authoring.container.mp4; - -import com.coremedia.iso.IsoFile; -import com.coremedia.iso.boxes.TrackBox; -import com.googlecode.mp4parser.authoring.Movie; -import com.googlecode.mp4parser.authoring.Mp4TrackImpl; - -import java.io.IOException; -import java.nio.channels.ReadableByteChannel; -import java.util.List; - -/** - * Shortcut to build a movie from an MP4 file. - */ -public class MovieCreator { - public static Movie build(ReadableByteChannel channel) throws IOException { - IsoFile isoFile = new IsoFile(channel); - Movie m = new Movie(); - List trackBoxes = isoFile.getMovieBox().getBoxes(TrackBox.class); - for (TrackBox trackBox : trackBoxes) { - m.addTrack(new Mp4TrackImpl(trackBox)); - } - return m; - } -} diff --git a/android-aac-enc/src/main/java/com/googlecode/mp4parser/authoring/tracks/AACTrackImpl.java b/android-aac-enc/src/main/java/com/googlecode/mp4parser/authoring/tracks/AACTrackImpl.java deleted file mode 100644 index ee255c50e..000000000 --- a/android-aac-enc/src/main/java/com/googlecode/mp4parser/authoring/tracks/AACTrackImpl.java +++ /dev/null @@ -1,273 +0,0 @@ -package com.googlecode.mp4parser.authoring.tracks; - -import java.io.IOException; -import java.io.PushbackInputStream; -import java.nio.ByteBuffer; -import java.util.Date; -import java.util.HashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; - -import com.coremedia.iso.boxes.AbstractMediaHeaderBox; -import com.coremedia.iso.boxes.CompositionTimeToSample; -import com.coremedia.iso.boxes.SampleDependencyTypeBox; -import com.coremedia.iso.boxes.SampleDescriptionBox; -import com.coremedia.iso.boxes.SoundMediaHeaderBox; -import com.coremedia.iso.boxes.SubSampleInformationBox; -import com.coremedia.iso.boxes.TimeToSampleBox; -import com.coremedia.iso.boxes.sampleentry.AudioSampleEntry; -import com.googlecode.mp4parser.authoring.AbstractTrack; -import com.googlecode.mp4parser.authoring.TrackMetaData; -import com.googlecode.mp4parser.boxes.mp4.ESDescriptorBox; -import com.googlecode.mp4parser.boxes.mp4.objectdescriptors.AudioSpecificConfig; -import com.googlecode.mp4parser.boxes.mp4.objectdescriptors.BitReaderBuffer; -import com.googlecode.mp4parser.boxes.mp4.objectdescriptors.DecoderConfigDescriptor; -import com.googlecode.mp4parser.boxes.mp4.objectdescriptors.ESDescriptor; -import com.googlecode.mp4parser.boxes.mp4.objectdescriptors.SLConfigDescriptor; - -/** - * Created with IntelliJ IDEA. - * User: magnus - * Date: 2012-04-20 - * Time: 11:14 - * To change this template use File | Settings | File Templates. - */ -public class AACTrackImpl extends AbstractTrack { - TrackMetaData trackMetaData = new TrackMetaData(); - SampleDescriptionBox sampleDescriptionBox; - - int samplerate; - int bitrate; - int channelCount; - int channelconfig; - - int bufferSizeDB; - long maxBitRate; - long avgBitRate; - - private PushbackInputStream inputStream; - private List samples; - boolean readSamples = false; - List stts; - public static Map samplingFrequencyIndexMap = new HashMap(); - - public AACTrackImpl(PushbackInputStream inputStream) throws IOException { - this.inputStream = inputStream; - stts = new LinkedList(); - - samplingFrequencyIndexMap.put(96000, 0); - samplingFrequencyIndexMap.put(88200, 1); - samplingFrequencyIndexMap.put(64000, 2); - samplingFrequencyIndexMap.put(48000, 3); - samplingFrequencyIndexMap.put(44100, 4); - samplingFrequencyIndexMap.put(32000, 5); - samplingFrequencyIndexMap.put(24000, 6); - samplingFrequencyIndexMap.put(22050, 7); - samplingFrequencyIndexMap.put(16000, 8); - samplingFrequencyIndexMap.put(12000, 9); - samplingFrequencyIndexMap.put(11025, 10); - samplingFrequencyIndexMap.put(8000, 11); - samplingFrequencyIndexMap.put(0x0, 96000); - samplingFrequencyIndexMap.put(0x1, 88200); - samplingFrequencyIndexMap.put(0x2, 64000); - samplingFrequencyIndexMap.put(0x3, 48000); - samplingFrequencyIndexMap.put(0x4, 44100); - samplingFrequencyIndexMap.put(0x5, 32000); - samplingFrequencyIndexMap.put(0x6, 24000); - samplingFrequencyIndexMap.put(0x7, 22050); - samplingFrequencyIndexMap.put(0x8, 16000); - samplingFrequencyIndexMap.put(0x9, 12000); - samplingFrequencyIndexMap.put(0xa, 11025); - samplingFrequencyIndexMap.put(0xb, 8000); - - if (!readVariables()) { - throw new IOException(); - } - - samples = new LinkedList(); - if (!readSamples()) { - throw new IOException(); - } - - double packetsPerSecond = (double)samplerate / 1024.0; - double duration = samples.size() / packetsPerSecond; - - long dataSize = 0; - LinkedList queue = new LinkedList(); - for (int i = 0; i < samples.size(); i++) { - int size = samples.get(i).capacity(); - dataSize += size; - queue.add(size); - while (queue.size() > packetsPerSecond) { - queue.removeFirst(); - } - if (queue.size() == (int) packetsPerSecond) { - int currSize = 0; - for (int j = 0 ; j < queue.size(); j++) { - currSize += queue.get(j); - } - double currBitrate = 8.0 * currSize / queue.size() * packetsPerSecond; - if (currBitrate > maxBitRate) { - maxBitRate = (int)currBitrate; - } - } - } - - avgBitRate = (int) (8 * dataSize / duration); - - bufferSizeDB = 1536; /* TODO: Calcultate this somehow! */ - - sampleDescriptionBox = new SampleDescriptionBox(); - AudioSampleEntry audioSampleEntry = new AudioSampleEntry("mp4a"); - audioSampleEntry.setChannelCount(2); - audioSampleEntry.setSampleRate(samplerate); - audioSampleEntry.setDataReferenceIndex(1); - audioSampleEntry.setSampleSize(16); - - - ESDescriptorBox esds = new ESDescriptorBox(); - ESDescriptor descriptor = new ESDescriptor(); - descriptor.setEsId(0); - - SLConfigDescriptor slConfigDescriptor = new SLConfigDescriptor(); - slConfigDescriptor.setPredefined(2); - descriptor.setSlConfigDescriptor(slConfigDescriptor); - - DecoderConfigDescriptor decoderConfigDescriptor = new DecoderConfigDescriptor(); - decoderConfigDescriptor.setObjectTypeIndication(0x40); - decoderConfigDescriptor.setStreamType(5); - decoderConfigDescriptor.setBufferSizeDB(bufferSizeDB); - decoderConfigDescriptor.setMaxBitRate(maxBitRate); - decoderConfigDescriptor.setAvgBitRate(avgBitRate); - - AudioSpecificConfig audioSpecificConfig = new AudioSpecificConfig(); - audioSpecificConfig.setAudioObjectType(2); // AAC LC - audioSpecificConfig.setSamplingFrequencyIndex(samplingFrequencyIndexMap.get(samplerate)); - audioSpecificConfig.setChannelConfiguration(channelconfig); - decoderConfigDescriptor.setAudioSpecificInfo(audioSpecificConfig); - - descriptor.setDecoderConfigDescriptor(decoderConfigDescriptor); - - ByteBuffer data = descriptor.serialize(); - esds.setData(data); - audioSampleEntry.addBox(esds); - sampleDescriptionBox.addBox(audioSampleEntry); - - trackMetaData.setCreationTime(new Date()); - trackMetaData.setModificationTime(new Date()); - trackMetaData.setLanguage("eng"); - trackMetaData.setTimescale(samplerate); // Audio tracks always use samplerate as timescale - - } - - public SampleDescriptionBox getSampleDescriptionBox() { - return sampleDescriptionBox; //To change body of implemented methods use File | Settings | File Templates. - } - - public List getDecodingTimeEntries() { - return stts; //To change body of implemented methods use File | Settings | File Templates. - } - - public List getCompositionTimeEntries() { - return null; //To change body of implemented methods use File | Settings | File Templates. - } - - public long[] getSyncSamples() { - return null; //To change body of implemented methods use File | Settings | File Templates. - } - - public List getSampleDependencies() { - return null; //To change body of implemented methods use File | Settings | File Templates. - } - - public TrackMetaData getTrackMetaData() { - return trackMetaData; //To change body of implemented methods use File | Settings | File Templates. - } - - public String getHandler() { - return "soun"; //To change body of implemented methods use File | Settings | File Templates. - } - - public List getSamples() { - return samples; //To change body of implemented methods use File | Settings | File Templates. - } - - public AbstractMediaHeaderBox getMediaHeaderBox() { - return new SoundMediaHeaderBox(); - } - - public SubSampleInformationBox getSubsampleInformationBox() { - return null; //To change body of implemented methods use File | Settings | File Templates. - } - - private boolean readVariables() throws IOException { - byte[] data = new byte[100]; - if (100 != inputStream.read(data, 0, 100)) { - return false; - } - inputStream.unread(data); - - ByteBuffer bb = ByteBuffer.wrap(data); - BitReaderBuffer brb = new BitReaderBuffer(bb); - int syncword = brb.readBits(12); - - if (syncword != 0xfff) { - return false; - } - int id = brb.readBits(1); - int layer = brb.readBits(2); - int protectionAbsent = brb.readBits(1); - int profile = brb.readBits(2); - samplerate = samplingFrequencyIndexMap.get(brb.readBits(4)); - brb.readBits(1); - channelconfig = brb.readBits(3); - int original = brb.readBits(1); - int home = brb.readBits(1); - int emphasis = brb.readBits(2); - - return true; - } - - private boolean readSamples() throws IOException { - if (readSamples) { - return true; - } - - readSamples = true; - byte[] header = new byte[15]; - boolean ret = false; - while (-1 != inputStream.read(header)) { - ret = true; - ByteBuffer bb = ByteBuffer.wrap(header); - - inputStream.unread(header); - BitReaderBuffer brb = new BitReaderBuffer(bb); - int syncword = brb.readBits(12); - - if (syncword != 0xfff) { - return false; - } - brb.readBits(3); - int protectionAbsent = brb.readBits(1); - brb.readBits(14); - int frameSize = brb.readBits(13); - int bufferFullness = brb.readBits(11); - int noBlocks = brb.readBits(2); - int used = (int) Math.ceil(brb.getPosition() / 8.0); - if (protectionAbsent == 0) { - used += 2; - } - inputStream.skip(used); - frameSize -= used; -// System.out.println("Size: " + frameSize + " fullness: " + bufferFullness + " no blocks: " + noBlocks); - byte[] data = new byte[frameSize]; - inputStream.read(data); - samples.add(ByteBuffer.wrap(data)); - stts.add(new TimeToSampleBox.Entry(1, 1024)); - - } - return ret; - } -} - diff --git a/android-aac-enc/src/main/java/com/googlecode/mp4parser/authoring/tracks/AC3TrackImpl.java b/android-aac-enc/src/main/java/com/googlecode/mp4parser/authoring/tracks/AC3TrackImpl.java deleted file mode 100644 index a095b1bb6..000000000 --- a/android-aac-enc/src/main/java/com/googlecode/mp4parser/authoring/tracks/AC3TrackImpl.java +++ /dev/null @@ -1,501 +0,0 @@ -package com.googlecode.mp4parser.authoring.tracks; - -import com.coremedia.iso.boxes.*; -import com.coremedia.iso.boxes.sampleentry.AudioSampleEntry; -import com.googlecode.mp4parser.authoring.AbstractTrack; -import com.googlecode.mp4parser.authoring.TrackMetaData; -import com.googlecode.mp4parser.boxes.AC3SpecificBox; -import com.googlecode.mp4parser.boxes.mp4.objectdescriptors.BitReaderBuffer; - -import java.io.InputStream; -import java.io.IOException; -import java.nio.ByteBuffer; -import java.util.Date; -import java.util.LinkedList; -import java.util.List; - -public class AC3TrackImpl extends AbstractTrack { - TrackMetaData trackMetaData = new TrackMetaData(); - SampleDescriptionBox sampleDescriptionBox; - - int samplerate; - int bitrate; - int channelCount; - - int fscod; - int bsid; - int bsmod; - int acmod; - int lfeon; - int frmsizecod; - - int frameSize; - int[][][][] bitRateAndFrameSizeTable; - - private InputStream inputStream; - private List samples; - boolean readSamples = false; - List stts; - - public AC3TrackImpl(InputStream fin) throws IOException { - inputStream = fin; - bitRateAndFrameSizeTable = new int[19][2][3][2]; - stts = new LinkedList(); - initBitRateAndFrameSizeTable(); - if (!readVariables()) { - throw new IOException(); - } - - sampleDescriptionBox = new SampleDescriptionBox(); - AudioSampleEntry audioSampleEntry = new AudioSampleEntry("ac-3"); - audioSampleEntry.setChannelCount(2); - audioSampleEntry.setSampleRate(samplerate); - audioSampleEntry.setDataReferenceIndex(1); - audioSampleEntry.setSampleSize(16); - - AC3SpecificBox ac3 = new AC3SpecificBox(); - ac3.setAcmod(acmod); - ac3.setBitRateCode(frmsizecod >> 1); - ac3.setBsid(bsid); - ac3.setBsmod(bsmod); - ac3.setFscod(fscod); - ac3.setLfeon(lfeon); - ac3.setReserved(0); - - audioSampleEntry.addBox(ac3); - sampleDescriptionBox.addBox(audioSampleEntry); - - trackMetaData.setCreationTime(new Date()); - trackMetaData.setModificationTime(new Date()); - trackMetaData.setLanguage("eng"); - trackMetaData.setTimescale(samplerate); // Audio tracks always use samplerate as timescale - - samples = new LinkedList(); - if (!readSamples()) { - throw new IOException(); - } - } - - - public List getSamples() { - - return samples; - } - - public SampleDescriptionBox getSampleDescriptionBox() { - return sampleDescriptionBox; - } - - public List getDecodingTimeEntries() { - return stts; - } - - public List getCompositionTimeEntries() { - return null; - } - - public long[] getSyncSamples() { - return null; - } - - public List getSampleDependencies() { - return null; - } - - public TrackMetaData getTrackMetaData() { - return trackMetaData; - } - - public String getHandler() { - return "soun"; - } - - public AbstractMediaHeaderBox getMediaHeaderBox() { - return new SoundMediaHeaderBox(); - } - - public SubSampleInformationBox getSubsampleInformationBox() { - return null; - } - - private boolean readVariables() throws IOException { - byte[] data = new byte[100]; - if (100 != inputStream.read(data, 0, 100)) { - return false; - } - inputStream.skip(-100); // Rewind - ByteBuffer bb = ByteBuffer.wrap(data); - BitReaderBuffer brb = new BitReaderBuffer(bb); - int syncword = brb.readBits(16); - if (syncword != 0xb77) { - return false; - } - brb.readBits(16); // CRC-1 - fscod = brb.readBits(2); - - switch (fscod) { - case 0: - samplerate = 48000; - break; - - case 1: - samplerate = 44100; - break; - - case 2: - samplerate = 32000; - break; - - case 3: - samplerate = 0; - break; - - } - if (samplerate == 0) { - return false; - } - - frmsizecod = brb.readBits(6); - - if (!calcBitrateAndFrameSize(frmsizecod)) { - return false; - } - - if (frameSize == 0) { - return false; - } - bsid = brb.readBits(5); - bsmod = brb.readBits(3); - acmod = brb.readBits(3); - - if (bsid == 9) { - samplerate /= 2; - } else if (bsid != 8 && bsid != 6) { - return false; - } - - if ((acmod != 1) && ((acmod & 1) == 1)) { - brb.readBits(2); - } - - if (0 != (acmod & 4)) { - brb.readBits(2); - } - - if (acmod == 2) { - brb.readBits(2); - } - - switch (acmod) { - case 0: - channelCount = 2; - break; - - case 1: - channelCount = 1; - break; - - case 2: - channelCount = 2; - break; - - case 3: - channelCount = 3; - break; - - case 4: - channelCount = 3; - break; - - case 5: - channelCount = 4; - break; - - case 6: - channelCount = 4; - break; - - case 7: - channelCount = 5; - break; - - } - - lfeon = brb.readBits(1); - - if (lfeon == 1) { - channelCount++; - } - return true; - } - - private boolean calcBitrateAndFrameSize(int code) { - int frmsizecode = code >>> 1; - int flag = code & 1; - if (frmsizecode > 18 || flag > 1 || fscod > 2) { - return false; - } - bitrate = bitRateAndFrameSizeTable[frmsizecode][flag][fscod][0]; - frameSize = 2 * bitRateAndFrameSizeTable[frmsizecode][flag][fscod][1]; - return true; - } - - private boolean readSamples() throws IOException { - if (readSamples) { - return true; - } - readSamples = true; - byte[] header = new byte[5]; - boolean ret = false; - while (-1 != inputStream.read(header)) { - ret = true; - int frmsizecode = header[4] & 63; - calcBitrateAndFrameSize(frmsizecode); - inputStream.skip(-5); - byte[] data = new byte[frameSize]; - inputStream.read(data); - samples.add(ByteBuffer.wrap(data)); - stts.add(new TimeToSampleBox.Entry(1, 1536)); - - } - return ret; - } - - private void initBitRateAndFrameSizeTable() { - // ETSI 102 366 Table 4.13, in frmsizecod, flag, fscod, bitrate/size order. Note that all sizes are in words, and all bitrates in kbps - - // 48kHz - bitRateAndFrameSizeTable[0][0][0][0] = 32; - bitRateAndFrameSizeTable[0][1][0][0] = 32; - bitRateAndFrameSizeTable[0][0][0][1] = 64; - bitRateAndFrameSizeTable[0][1][0][1] = 64; - bitRateAndFrameSizeTable[1][0][0][0] = 40; - bitRateAndFrameSizeTable[1][1][0][0] = 40; - bitRateAndFrameSizeTable[1][0][0][1] = 80; - bitRateAndFrameSizeTable[1][1][0][1] = 80; - bitRateAndFrameSizeTable[2][0][0][0] = 48; - bitRateAndFrameSizeTable[2][1][0][0] = 48; - bitRateAndFrameSizeTable[2][0][0][1] = 96; - bitRateAndFrameSizeTable[2][1][0][1] = 96; - bitRateAndFrameSizeTable[3][0][0][0] = 56; - bitRateAndFrameSizeTable[3][1][0][0] = 56; - bitRateAndFrameSizeTable[3][0][0][1] = 112; - bitRateAndFrameSizeTable[3][1][0][1] = 112; - bitRateAndFrameSizeTable[4][0][0][0] = 64; - bitRateAndFrameSizeTable[4][1][0][0] = 64; - bitRateAndFrameSizeTable[4][0][0][1] = 128; - bitRateAndFrameSizeTable[4][1][0][1] = 128; - bitRateAndFrameSizeTable[5][0][0][0] = 80; - bitRateAndFrameSizeTable[5][1][0][0] = 80; - bitRateAndFrameSizeTable[5][0][0][1] = 160; - bitRateAndFrameSizeTable[5][1][0][1] = 160; - bitRateAndFrameSizeTable[6][0][0][0] = 96; - bitRateAndFrameSizeTable[6][1][0][0] = 96; - bitRateAndFrameSizeTable[6][0][0][1] = 192; - bitRateAndFrameSizeTable[6][1][0][1] = 192; - bitRateAndFrameSizeTable[7][0][0][0] = 112; - bitRateAndFrameSizeTable[7][1][0][0] = 112; - bitRateAndFrameSizeTable[7][0][0][1] = 224; - bitRateAndFrameSizeTable[7][1][0][1] = 224; - bitRateAndFrameSizeTable[8][0][0][0] = 128; - bitRateAndFrameSizeTable[8][1][0][0] = 128; - bitRateAndFrameSizeTable[8][0][0][1] = 256; - bitRateAndFrameSizeTable[8][1][0][1] = 256; - bitRateAndFrameSizeTable[9][0][0][0] = 160; - bitRateAndFrameSizeTable[9][1][0][0] = 160; - bitRateAndFrameSizeTable[9][0][0][1] = 320; - bitRateAndFrameSizeTable[9][1][0][1] = 320; - bitRateAndFrameSizeTable[10][0][0][0] = 192; - bitRateAndFrameSizeTable[10][1][0][0] = 192; - bitRateAndFrameSizeTable[10][0][0][1] = 384; - bitRateAndFrameSizeTable[10][1][0][1] = 384; - bitRateAndFrameSizeTable[11][0][0][0] = 224; - bitRateAndFrameSizeTable[11][1][0][0] = 224; - bitRateAndFrameSizeTable[11][0][0][1] = 448; - bitRateAndFrameSizeTable[11][1][0][1] = 448; - bitRateAndFrameSizeTable[12][0][0][0] = 256; - bitRateAndFrameSizeTable[12][1][0][0] = 256; - bitRateAndFrameSizeTable[12][0][0][1] = 512; - bitRateAndFrameSizeTable[12][1][0][1] = 512; - bitRateAndFrameSizeTable[13][0][0][0] = 320; - bitRateAndFrameSizeTable[13][1][0][0] = 320; - bitRateAndFrameSizeTable[13][0][0][1] = 640; - bitRateAndFrameSizeTable[13][1][0][1] = 640; - bitRateAndFrameSizeTable[14][0][0][0] = 384; - bitRateAndFrameSizeTable[14][1][0][0] = 384; - bitRateAndFrameSizeTable[14][0][0][1] = 768; - bitRateAndFrameSizeTable[14][1][0][1] = 768; - bitRateAndFrameSizeTable[15][0][0][0] = 448; - bitRateAndFrameSizeTable[15][1][0][0] = 448; - bitRateAndFrameSizeTable[15][0][0][1] = 896; - bitRateAndFrameSizeTable[15][1][0][1] = 896; - bitRateAndFrameSizeTable[16][0][0][0] = 512; - bitRateAndFrameSizeTable[16][1][0][0] = 512; - bitRateAndFrameSizeTable[16][0][0][1] = 1024; - bitRateAndFrameSizeTable[16][1][0][1] = 1024; - bitRateAndFrameSizeTable[17][0][0][0] = 576; - bitRateAndFrameSizeTable[17][1][0][0] = 576; - bitRateAndFrameSizeTable[17][0][0][1] = 1152; - bitRateAndFrameSizeTable[17][1][0][1] = 1152; - bitRateAndFrameSizeTable[18][0][0][0] = 640; - bitRateAndFrameSizeTable[18][1][0][0] = 640; - bitRateAndFrameSizeTable[18][0][0][1] = 1280; - bitRateAndFrameSizeTable[18][1][0][1] = 1280; - - // 44.1 kHz - bitRateAndFrameSizeTable[0][0][1][0] = 32; - bitRateAndFrameSizeTable[0][1][1][0] = 32; - bitRateAndFrameSizeTable[0][0][1][1] = 69; - bitRateAndFrameSizeTable[0][1][1][1] = 70; - bitRateAndFrameSizeTable[1][0][1][0] = 40; - bitRateAndFrameSizeTable[1][1][1][0] = 40; - bitRateAndFrameSizeTable[1][0][1][1] = 87; - bitRateAndFrameSizeTable[1][1][1][1] = 88; - bitRateAndFrameSizeTable[2][0][1][0] = 48; - bitRateAndFrameSizeTable[2][1][1][0] = 48; - bitRateAndFrameSizeTable[2][0][1][1] = 104; - bitRateAndFrameSizeTable[2][1][1][1] = 105; - bitRateAndFrameSizeTable[3][0][1][0] = 56; - bitRateAndFrameSizeTable[3][1][1][0] = 56; - bitRateAndFrameSizeTable[3][0][1][1] = 121; - bitRateAndFrameSizeTable[3][1][1][1] = 122; - bitRateAndFrameSizeTable[4][0][1][0] = 64; - bitRateAndFrameSizeTable[4][1][1][0] = 64; - bitRateAndFrameSizeTable[4][0][1][1] = 139; - bitRateAndFrameSizeTable[4][1][1][1] = 140; - bitRateAndFrameSizeTable[5][0][1][0] = 80; - bitRateAndFrameSizeTable[5][1][1][0] = 80; - bitRateAndFrameSizeTable[5][0][1][1] = 174; - bitRateAndFrameSizeTable[5][1][1][1] = 175; - bitRateAndFrameSizeTable[6][0][1][0] = 96; - bitRateAndFrameSizeTable[6][1][1][0] = 96; - bitRateAndFrameSizeTable[6][0][1][1] = 208; - bitRateAndFrameSizeTable[6][1][1][1] = 209; - bitRateAndFrameSizeTable[7][0][1][0] = 112; - bitRateAndFrameSizeTable[7][1][1][0] = 112; - bitRateAndFrameSizeTable[7][0][1][1] = 243; - bitRateAndFrameSizeTable[7][1][1][1] = 244; - bitRateAndFrameSizeTable[8][0][1][0] = 128; - bitRateAndFrameSizeTable[8][1][1][0] = 128; - bitRateAndFrameSizeTable[8][0][1][1] = 278; - bitRateAndFrameSizeTable[8][1][1][1] = 279; - bitRateAndFrameSizeTable[9][0][1][0] = 160; - bitRateAndFrameSizeTable[9][1][1][0] = 160; - bitRateAndFrameSizeTable[9][0][1][1] = 348; - bitRateAndFrameSizeTable[9][1][1][1] = 349; - bitRateAndFrameSizeTable[10][0][1][0] = 192; - bitRateAndFrameSizeTable[10][1][1][0] = 192; - bitRateAndFrameSizeTable[10][0][1][1] = 417; - bitRateAndFrameSizeTable[10][1][1][1] = 418; - bitRateAndFrameSizeTable[11][0][1][0] = 224; - bitRateAndFrameSizeTable[11][1][1][0] = 224; - bitRateAndFrameSizeTable[11][0][1][1] = 487; - bitRateAndFrameSizeTable[11][1][1][1] = 488; - bitRateAndFrameSizeTable[12][0][1][0] = 256; - bitRateAndFrameSizeTable[12][1][1][0] = 256; - bitRateAndFrameSizeTable[12][0][1][1] = 557; - bitRateAndFrameSizeTable[12][1][1][1] = 558; - bitRateAndFrameSizeTable[13][0][1][0] = 320; - bitRateAndFrameSizeTable[13][1][1][0] = 320; - bitRateAndFrameSizeTable[13][0][1][1] = 696; - bitRateAndFrameSizeTable[13][1][1][1] = 697; - bitRateAndFrameSizeTable[14][0][1][0] = 384; - bitRateAndFrameSizeTable[14][1][1][0] = 384; - bitRateAndFrameSizeTable[14][0][1][1] = 835; - bitRateAndFrameSizeTable[14][1][1][1] = 836; - bitRateAndFrameSizeTable[15][0][1][0] = 448; - bitRateAndFrameSizeTable[15][1][1][0] = 448; - bitRateAndFrameSizeTable[15][0][1][1] = 975; - bitRateAndFrameSizeTable[15][1][1][1] = 975; - bitRateAndFrameSizeTable[16][0][1][0] = 512; - bitRateAndFrameSizeTable[16][1][1][0] = 512; - bitRateAndFrameSizeTable[16][0][1][1] = 1114; - bitRateAndFrameSizeTable[16][1][1][1] = 1115; - bitRateAndFrameSizeTable[17][0][1][0] = 576; - bitRateAndFrameSizeTable[17][1][1][0] = 576; - bitRateAndFrameSizeTable[17][0][1][1] = 1253; - bitRateAndFrameSizeTable[17][1][1][1] = 1254; - bitRateAndFrameSizeTable[18][0][1][0] = 640; - bitRateAndFrameSizeTable[18][1][1][0] = 640; - bitRateAndFrameSizeTable[18][0][1][1] = 1393; - bitRateAndFrameSizeTable[18][1][1][1] = 1394; - - // 32kHz - bitRateAndFrameSizeTable[0][0][2][0] = 32; - bitRateAndFrameSizeTable[0][1][2][0] = 32; - bitRateAndFrameSizeTable[0][0][2][1] = 96; - bitRateAndFrameSizeTable[0][1][2][1] = 96; - bitRateAndFrameSizeTable[1][0][2][0] = 40; - bitRateAndFrameSizeTable[1][1][2][0] = 40; - bitRateAndFrameSizeTable[1][0][2][1] = 120; - bitRateAndFrameSizeTable[1][1][2][1] = 120; - bitRateAndFrameSizeTable[2][0][2][0] = 48; - bitRateAndFrameSizeTable[2][1][2][0] = 48; - bitRateAndFrameSizeTable[2][0][2][1] = 144; - bitRateAndFrameSizeTable[2][1][2][1] = 144; - bitRateAndFrameSizeTable[3][0][2][0] = 56; - bitRateAndFrameSizeTable[3][1][2][0] = 56; - bitRateAndFrameSizeTable[3][0][2][1] = 168; - bitRateAndFrameSizeTable[3][1][2][1] = 168; - bitRateAndFrameSizeTable[4][0][2][0] = 64; - bitRateAndFrameSizeTable[4][1][2][0] = 64; - bitRateAndFrameSizeTable[4][0][2][1] = 192; - bitRateAndFrameSizeTable[4][1][2][1] = 192; - bitRateAndFrameSizeTable[5][0][2][0] = 80; - bitRateAndFrameSizeTable[5][1][2][0] = 80; - bitRateAndFrameSizeTable[5][0][2][1] = 240; - bitRateAndFrameSizeTable[5][1][2][1] = 240; - bitRateAndFrameSizeTable[6][0][2][0] = 96; - bitRateAndFrameSizeTable[6][1][2][0] = 96; - bitRateAndFrameSizeTable[6][0][2][1] = 288; - bitRateAndFrameSizeTable[6][1][2][1] = 288; - bitRateAndFrameSizeTable[7][0][2][0] = 112; - bitRateAndFrameSizeTable[7][1][2][0] = 112; - bitRateAndFrameSizeTable[7][0][2][1] = 336; - bitRateAndFrameSizeTable[7][1][2][1] = 336; - bitRateAndFrameSizeTable[8][0][2][0] = 128; - bitRateAndFrameSizeTable[8][1][2][0] = 128; - bitRateAndFrameSizeTable[8][0][2][1] = 384; - bitRateAndFrameSizeTable[8][1][2][1] = 384; - bitRateAndFrameSizeTable[9][0][2][0] = 160; - bitRateAndFrameSizeTable[9][1][2][0] = 160; - bitRateAndFrameSizeTable[9][0][2][1] = 480; - bitRateAndFrameSizeTable[9][1][2][1] = 480; - bitRateAndFrameSizeTable[10][0][2][0] = 192; - bitRateAndFrameSizeTable[10][1][2][0] = 192; - bitRateAndFrameSizeTable[10][0][2][1] = 576; - bitRateAndFrameSizeTable[10][1][2][1] = 576; - bitRateAndFrameSizeTable[11][0][2][0] = 224; - bitRateAndFrameSizeTable[11][1][2][0] = 224; - bitRateAndFrameSizeTable[11][0][2][1] = 672; - bitRateAndFrameSizeTable[11][1][2][1] = 672; - bitRateAndFrameSizeTable[12][0][2][0] = 256; - bitRateAndFrameSizeTable[12][1][2][0] = 256; - bitRateAndFrameSizeTable[12][0][2][1] = 768; - bitRateAndFrameSizeTable[12][1][2][1] = 768; - bitRateAndFrameSizeTable[13][0][2][0] = 320; - bitRateAndFrameSizeTable[13][1][2][0] = 320; - bitRateAndFrameSizeTable[13][0][2][1] = 960; - bitRateAndFrameSizeTable[13][1][2][1] = 960; - bitRateAndFrameSizeTable[14][0][2][0] = 384; - bitRateAndFrameSizeTable[14][1][2][0] = 384; - bitRateAndFrameSizeTable[14][0][2][1] = 1152; - bitRateAndFrameSizeTable[14][1][2][1] = 1152; - bitRateAndFrameSizeTable[15][0][2][0] = 448; - bitRateAndFrameSizeTable[15][1][2][0] = 448; - bitRateAndFrameSizeTable[15][0][2][1] = 1344; - bitRateAndFrameSizeTable[15][1][2][1] = 1344; - bitRateAndFrameSizeTable[16][0][2][0] = 512; - bitRateAndFrameSizeTable[16][1][2][0] = 512; - bitRateAndFrameSizeTable[16][0][2][1] = 1536; - bitRateAndFrameSizeTable[16][1][2][1] = 1536; - bitRateAndFrameSizeTable[17][0][2][0] = 576; - bitRateAndFrameSizeTable[17][1][2][0] = 576; - bitRateAndFrameSizeTable[17][0][2][1] = 1728; - bitRateAndFrameSizeTable[17][1][2][1] = 1728; - bitRateAndFrameSizeTable[18][0][2][0] = 640; - bitRateAndFrameSizeTable[18][1][2][0] = 640; - bitRateAndFrameSizeTable[18][0][2][1] = 1920; - bitRateAndFrameSizeTable[18][1][2][1] = 1920; - } -} \ No newline at end of file diff --git a/android-aac-enc/src/main/java/com/googlecode/mp4parser/authoring/tracks/Amf0Track.java b/android-aac-enc/src/main/java/com/googlecode/mp4parser/authoring/tracks/Amf0Track.java deleted file mode 100644 index 97fd74ba0..000000000 --- a/android-aac-enc/src/main/java/com/googlecode/mp4parser/authoring/tracks/Amf0Track.java +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Copyright 2012 Sebastian Annies, Hamburg - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.googlecode.mp4parser.authoring.tracks; - -import com.coremedia.iso.boxes.*; -import com.googlecode.mp4parser.authoring.AbstractTrack; -import com.googlecode.mp4parser.authoring.TrackMetaData; -import com.googlecode.mp4parser.boxes.adobe.ActionMessageFormat0SampleEntryBox; - -import java.nio.ByteBuffer; -import java.util.Collections; -import java.util.Date; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.SortedMap; -import java.util.TreeMap; - -public class Amf0Track extends AbstractTrack { - SortedMap rawSamples = new TreeMap() { - }; - private TrackMetaData trackMetaData = new TrackMetaData(); - - - /** - * Creates a new AMF0 track from - * - * @param rawSamples - */ - public Amf0Track(Map rawSamples) { - this.rawSamples = new TreeMap(rawSamples); - trackMetaData.setCreationTime(new Date()); - trackMetaData.setModificationTime(new Date()); - trackMetaData.setTimescale(1000); // Text tracks use millieseconds - trackMetaData.setLanguage("eng"); - } - - public List getSamples() { - LinkedList samples = new LinkedList(); - for (byte[] bytes : rawSamples.values()) { - samples.add(ByteBuffer.wrap(bytes)); - } - return samples; - } - - public SampleDescriptionBox getSampleDescriptionBox() { - SampleDescriptionBox stsd = new SampleDescriptionBox(); - ActionMessageFormat0SampleEntryBox amf0 = new ActionMessageFormat0SampleEntryBox(); - amf0.setDataReferenceIndex(1); - stsd.addBox(amf0); - return stsd; - } - - public List getDecodingTimeEntries() { - LinkedList timesToSample = new LinkedList(); - LinkedList keys = new LinkedList(rawSamples.keySet()); - Collections.sort(keys); - long lastTimeStamp = 0; - for (Long key : keys) { - long delta = key - lastTimeStamp; - if (timesToSample.size() > 0 && timesToSample.peek().getDelta() == delta) { - timesToSample.peek().setCount(timesToSample.peek().getCount() + 1); - } else { - timesToSample.add(new TimeToSampleBox.Entry(1, delta)); - } - lastTimeStamp = key; - } - return timesToSample; - } - - public List getCompositionTimeEntries() { - // AMF0 tracks do not have Composition Time - return null; - } - - public long[] getSyncSamples() { - // AMF0 tracks do not have Sync Samples - return null; - } - - public List getSampleDependencies() { - // AMF0 tracks do not have Sample Dependencies - return null; - } - - public TrackMetaData getTrackMetaData() { - return trackMetaData; //To change body of implemented methods use File | Settings | File Templates. - } - - public String getHandler() { - return "data"; - } - - public AbstractMediaHeaderBox getMediaHeaderBox() { - return new NullMediaHeaderBox(); - } - - public SubSampleInformationBox getSubsampleInformationBox() { - return null; - } - -} diff --git a/android-aac-enc/src/main/java/com/googlecode/mp4parser/authoring/tracks/AppendTrack.java b/android-aac-enc/src/main/java/com/googlecode/mp4parser/authoring/tracks/AppendTrack.java deleted file mode 100644 index 6fee40203..000000000 --- a/android-aac-enc/src/main/java/com/googlecode/mp4parser/authoring/tracks/AppendTrack.java +++ /dev/null @@ -1,166 +0,0 @@ -/* - * Copyright 2012 Sebastian Annies, Hamburg - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.googlecode.mp4parser.authoring.tracks; - -import com.coremedia.iso.boxes.*; -import com.googlecode.mp4parser.authoring.AbstractTrack; -import com.googlecode.mp4parser.authoring.Track; -import com.googlecode.mp4parser.authoring.TrackMetaData; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.nio.ByteBuffer; -import java.nio.channels.Channels; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.LinkedList; -import java.util.List; - -/** - * Appends two or more Tracks of the same type. No only that the type must be equal - * also the decoder settings must be the same. - */ -public class AppendTrack extends AbstractTrack { - Track[] tracks; - - public AppendTrack(Track... tracks) throws IOException { - this.tracks = tracks; - byte[] referenceSampleDescriptionBox = null; - for (Track track : tracks) { - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - track.getSampleDescriptionBox().getBox(Channels.newChannel(baos)); - if (referenceSampleDescriptionBox == null) { - referenceSampleDescriptionBox = baos.toByteArray(); - } else if (!Arrays.equals(referenceSampleDescriptionBox, baos.toByteArray())) { - throw new IOException("Cannot append " + track + " to " + tracks[0] + " since their Sample Description Boxes differ"); - } - } - } - - public List getSamples() { - ArrayList lists = new ArrayList(); - - for (Track track : tracks) { - lists.addAll(track.getSamples()); - } - - return lists; - } - - public SampleDescriptionBox getSampleDescriptionBox() { - return tracks[0].getSampleDescriptionBox(); - } - - public List getDecodingTimeEntries() { - if (tracks[0].getDecodingTimeEntries() != null && !tracks[0].getDecodingTimeEntries().isEmpty()) { - List lists = new LinkedList(); - for (Track track : tracks) { - lists.add(TimeToSampleBox.blowupTimeToSamples(track.getDecodingTimeEntries())); - } - - LinkedList returnDecodingEntries = new LinkedList(); - for (long[] list : lists) { - for (long nuDecodingTime : list) { - if (returnDecodingEntries.isEmpty() || returnDecodingEntries.getLast().getDelta() != nuDecodingTime) { - TimeToSampleBox.Entry e = new TimeToSampleBox.Entry(1, nuDecodingTime); - returnDecodingEntries.add(e); - } else { - TimeToSampleBox.Entry e = returnDecodingEntries.getLast(); - e.setCount(e.getCount() + 1); - } - } - } - return returnDecodingEntries; - } else { - return null; - } - } - - public List getCompositionTimeEntries() { - if (tracks[0].getCompositionTimeEntries() != null && !tracks[0].getCompositionTimeEntries().isEmpty()) { - List lists = new LinkedList(); - for (Track track : tracks) { - lists.add(CompositionTimeToSample.blowupCompositionTimes(track.getCompositionTimeEntries())); - } - LinkedList compositionTimeEntries = new LinkedList(); - for (int[] list : lists) { - for (int compositionTime : list) { - if (compositionTimeEntries.isEmpty() || compositionTimeEntries.getLast().getOffset() != compositionTime) { - CompositionTimeToSample.Entry e = new CompositionTimeToSample.Entry(1, compositionTime); - compositionTimeEntries.add(e); - } else { - CompositionTimeToSample.Entry e = compositionTimeEntries.getLast(); - e.setCount(e.getCount() + 1); - } - } - } - return compositionTimeEntries; - } else { - return null; - } - } - - public long[] getSyncSamples() { - if (tracks[0].getSyncSamples() != null && tracks[0].getSyncSamples().length > 0) { - int numSyncSamples = 0; - for (Track track : tracks) { - numSyncSamples += track.getSyncSamples().length; - } - long[] returnSyncSamples = new long[numSyncSamples]; - - int pos = 0; - long samplesBefore = 0; - for (Track track : tracks) { - for (long l : track.getSyncSamples()) { - returnSyncSamples[pos++] = samplesBefore + l; - } - samplesBefore += track.getSamples().size(); - } - return returnSyncSamples; - } else { - return null; - } - } - - public List getSampleDependencies() { - if (tracks[0].getSampleDependencies() != null && !tracks[0].getSampleDependencies().isEmpty()) { - List list = new LinkedList(); - for (Track track : tracks) { - list.addAll(track.getSampleDependencies()); - } - return list; - } else { - return null; - } - } - - public TrackMetaData getTrackMetaData() { - return tracks[0].getTrackMetaData(); - } - - public String getHandler() { - return tracks[0].getHandler(); - } - - public AbstractMediaHeaderBox getMediaHeaderBox() { - return tracks[0].getMediaHeaderBox(); - } - - public SubSampleInformationBox getSubsampleInformationBox() { - return tracks[0].getSubsampleInformationBox(); - } - -} diff --git a/android-aac-enc/src/main/java/com/googlecode/mp4parser/authoring/tracks/ChangeTimeScaleTrack.java b/android-aac-enc/src/main/java/com/googlecode/mp4parser/authoring/tracks/ChangeTimeScaleTrack.java deleted file mode 100644 index 3390c4dcc..000000000 --- a/android-aac-enc/src/main/java/com/googlecode/mp4parser/authoring/tracks/ChangeTimeScaleTrack.java +++ /dev/null @@ -1,176 +0,0 @@ -/* - * Copyright 2012 Sebastian Annies, Hamburg - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.googlecode.mp4parser.authoring.tracks; - -import static java.lang.Math.round; - -import java.nio.ByteBuffer; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.LinkedList; -import java.util.List; - -import com.coremedia.iso.boxes.AbstractMediaHeaderBox; -import com.coremedia.iso.boxes.CompositionTimeToSample; -import com.coremedia.iso.boxes.SampleDependencyTypeBox; -import com.coremedia.iso.boxes.SampleDescriptionBox; -import com.coremedia.iso.boxes.SubSampleInformationBox; -import com.coremedia.iso.boxes.TimeToSampleBox; -import com.googlecode.mp4parser.authoring.Track; -import com.googlecode.mp4parser.authoring.TrackMetaData; - -/** - * Changes the timescale of a track by wrapping the track. - */ -public class ChangeTimeScaleTrack implements Track { - Track source; - List ctts; - List tts; - long timeScale; - - /** - * Changes the time scale of the source track to the target time scale and makes sure - * that any rounding errors that may have summed are corrected exactly before the syncSamples. - * - * @param source the source track - * @param targetTimeScale the resulting time scale of this track. - * @param syncSamples at these sync points where rounding error are corrected. - */ - public ChangeTimeScaleTrack(Track source, long targetTimeScale, long[] syncSamples) { - this.source = source; - this.timeScale = targetTimeScale; - double timeScaleFactor = (double) targetTimeScale / source.getTrackMetaData().getTimescale(); - ctts = adjustCtts(source.getCompositionTimeEntries(), timeScaleFactor); - tts = adjustTts(source.getDecodingTimeEntries(), timeScaleFactor, syncSamples); - } - - public SampleDescriptionBox getSampleDescriptionBox() { - return source.getSampleDescriptionBox(); - } - - public List getDecodingTimeEntries() { - return tts; - } - - public List getCompositionTimeEntries() { - return ctts; - } - - public long[] getSyncSamples() { - return source.getSyncSamples(); - } - - public List getSampleDependencies() { - return source.getSampleDependencies(); - } - - public TrackMetaData getTrackMetaData() { - TrackMetaData trackMetaData = (TrackMetaData) source.getTrackMetaData().clone(); - trackMetaData.setTimescale(timeScale); - return trackMetaData; - } - - public String getHandler() { - return source.getHandler(); - } - - public boolean isEnabled() { - return source.isEnabled(); - } - - public boolean isInMovie() { - return source.isInMovie(); - } - - public boolean isInPreview() { - return source.isInPreview(); - } - - public boolean isInPoster() { - return source.isInPoster(); - } - - public List getSamples() { - return source.getSamples(); - } - - - /** - * Adjusting the composition times is easy. Just scale it by the factor - that's it. There is no rounding - * error summing up. - * - * @param source - * @param timeScaleFactor - * @return - */ - static List adjustCtts(List source, double timeScaleFactor) { - if (source != null) { - List entries2 = new ArrayList(source.size()); - for (CompositionTimeToSample.Entry entry : source) { - entries2.add(new CompositionTimeToSample.Entry(entry.getCount(), (int) Math.round(timeScaleFactor * entry.getOffset()))); - } - return entries2; - } else { - return null; - } - } - - static List adjustTts(List source, double timeScaleFactor, long[] syncSample) { - double deviation = 0; - long[] sourceArray = TimeToSampleBox.blowupTimeToSamples(source); - LinkedList entries2 = new LinkedList(); - for (int i = 0; i < sourceArray.length; i++) { - long duration = sourceArray[i]; - double d = timeScaleFactor * duration; - long x = round(d); - deviation += d - x; - TimeToSampleBox.Entry last = entries2.getLast(); - if (Arrays.binarySearch(syncSample, i + 1) >= 0) { - // apply correction here! - if (Math.abs(deviation) >= 1) { - //System.err.println("Sample " + i + " corrected by adding + " + Math.round(deviation) ); - x += Math.round(deviation); - deviation = deviation - Math.round(deviation); // there is a rest! - - } - } - if (last == null) { - entries2.add(new TimeToSampleBox.Entry(1, x)); - } else if (last.getDelta() != x) { - entries2.add(new TimeToSampleBox.Entry(1, x)); - } else { - last.setCount(last.getCount() + 1); - } - - } - return entries2; - } - - public AbstractMediaHeaderBox getMediaHeaderBox() { - return source.getMediaHeaderBox(); - } - - public SubSampleInformationBox getSubsampleInformationBox() { - return source.getSubsampleInformationBox(); - } - - @Override - public String toString() { - return "ChangeTimeScaleTrack{" + - "source=" + source + - '}'; - } -} \ No newline at end of file diff --git a/android-aac-enc/src/main/java/com/googlecode/mp4parser/authoring/tracks/CroppedTrack.java b/android-aac-enc/src/main/java/com/googlecode/mp4parser/authoring/tracks/CroppedTrack.java deleted file mode 100644 index 518e7e62e..000000000 --- a/android-aac-enc/src/main/java/com/googlecode/mp4parser/authoring/tracks/CroppedTrack.java +++ /dev/null @@ -1,150 +0,0 @@ -/* - * Copyright 2012 Sebastian Annies, Hamburg - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.googlecode.mp4parser.authoring.tracks; - -import com.coremedia.iso.boxes.*; -import com.googlecode.mp4parser.authoring.AbstractTrack; -import com.googlecode.mp4parser.authoring.Track; -import com.googlecode.mp4parser.authoring.TrackMetaData; - -import java.nio.ByteBuffer; -import java.util.LinkedList; -import java.util.List; - -/** - * Generates a Track that starts at fromSample and ends at toSample (exclusive). The user of this class - * has to make sure that the fromSample is a random access sample. - *

      - *
    • In AAC this is every single sample
    • - *
    • In H264 this is every sample that is marked in the SyncSampleBox
    • - *
    - */ -public class CroppedTrack extends AbstractTrack { - Track origTrack; - private int fromSample; - private int toSample; - private long[] syncSampleArray; - - public CroppedTrack(Track origTrack, long fromSample, long toSample) { - this.origTrack = origTrack; - assert fromSample <= Integer.MAX_VALUE; - assert toSample <= Integer.MAX_VALUE; - this.fromSample = (int) fromSample; - this.toSample = (int) toSample; - } - - public List getSamples() { - return origTrack.getSamples().subList(fromSample, toSample); - } - - public SampleDescriptionBox getSampleDescriptionBox() { - return origTrack.getSampleDescriptionBox(); - } - - public List getDecodingTimeEntries() { - if (origTrack.getDecodingTimeEntries() != null && !origTrack.getDecodingTimeEntries().isEmpty()) { - long[] decodingTimes = TimeToSampleBox.blowupTimeToSamples(origTrack.getDecodingTimeEntries()); - long[] nuDecodingTimes = new long[toSample - fromSample]; - System.arraycopy(decodingTimes, fromSample, nuDecodingTimes, 0, toSample - fromSample); - - LinkedList returnDecodingEntries = new LinkedList(); - - for (long nuDecodingTime : nuDecodingTimes) { - if (returnDecodingEntries.isEmpty() || returnDecodingEntries.getLast().getDelta() != nuDecodingTime) { - TimeToSampleBox.Entry e = new TimeToSampleBox.Entry(1, nuDecodingTime); - returnDecodingEntries.add(e); - } else { - TimeToSampleBox.Entry e = returnDecodingEntries.getLast(); - e.setCount(e.getCount() + 1); - } - } - return returnDecodingEntries; - } else { - return null; - } - } - - public List getCompositionTimeEntries() { - if (origTrack.getCompositionTimeEntries() != null && !origTrack.getCompositionTimeEntries().isEmpty()) { - int[] compositionTime = CompositionTimeToSample.blowupCompositionTimes(origTrack.getCompositionTimeEntries()); - int[] nuCompositionTimes = new int[toSample - fromSample]; - System.arraycopy(compositionTime, fromSample, nuCompositionTimes, 0, toSample - fromSample); - - LinkedList returnDecodingEntries = new LinkedList(); - - for (int nuDecodingTime : nuCompositionTimes) { - if (returnDecodingEntries.isEmpty() || returnDecodingEntries.getLast().getOffset() != nuDecodingTime) { - CompositionTimeToSample.Entry e = new CompositionTimeToSample.Entry(1, nuDecodingTime); - returnDecodingEntries.add(e); - } else { - CompositionTimeToSample.Entry e = returnDecodingEntries.getLast(); - e.setCount(e.getCount() + 1); - } - } - return returnDecodingEntries; - } else { - return null; - } - } - - synchronized public long[] getSyncSamples() { - if (this.syncSampleArray == null) { - if (origTrack.getSyncSamples() != null && origTrack.getSyncSamples().length > 0) { - List syncSamples = new LinkedList(); - for (long l : origTrack.getSyncSamples()) { - if (l >= fromSample && l < toSample) { - syncSamples.add(l - fromSample); - } - } - syncSampleArray = new long[syncSamples.size()]; - for (int i = 0; i < syncSampleArray.length; i++) { - syncSampleArray[i] = syncSamples.get(i); - - } - return syncSampleArray; - } else { - return null; - } - } else { - return this.syncSampleArray; - } - } - - public List getSampleDependencies() { - if (origTrack.getSampleDependencies() != null && !origTrack.getSampleDependencies().isEmpty()) { - return origTrack.getSampleDependencies().subList(fromSample, toSample); - } else { - return null; - } - } - - public TrackMetaData getTrackMetaData() { - return origTrack.getTrackMetaData(); - } - - public String getHandler() { - return origTrack.getHandler(); - } - - public AbstractMediaHeaderBox getMediaHeaderBox() { - return origTrack.getMediaHeaderBox(); - } - - public SubSampleInformationBox getSubsampleInformationBox() { - return origTrack.getSubsampleInformationBox(); - } - -} \ No newline at end of file diff --git a/android-aac-enc/src/main/java/com/googlecode/mp4parser/authoring/tracks/DivideTimeScaleTrack.java b/android-aac-enc/src/main/java/com/googlecode/mp4parser/authoring/tracks/DivideTimeScaleTrack.java deleted file mode 100644 index a6412478e..000000000 --- a/android-aac-enc/src/main/java/com/googlecode/mp4parser/authoring/tracks/DivideTimeScaleTrack.java +++ /dev/null @@ -1,131 +0,0 @@ -/* - * Copyright 2012 Sebastian Annies, Hamburg - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.googlecode.mp4parser.authoring.tracks; - -import com.coremedia.iso.boxes.AbstractMediaHeaderBox; -import com.coremedia.iso.boxes.CompositionTimeToSample; -import com.coremedia.iso.boxes.SampleDependencyTypeBox; -import com.coremedia.iso.boxes.SampleDescriptionBox; -import com.coremedia.iso.boxes.SubSampleInformationBox; -import com.coremedia.iso.boxes.TimeToSampleBox; -import com.googlecode.mp4parser.authoring.Track; -import com.googlecode.mp4parser.authoring.TrackMetaData; - -import java.nio.ByteBuffer; -import java.util.ArrayList; -import java.util.LinkedList; -import java.util.List; - -/** - * Changes the timescale of a track by wrapping the track. - */ -public class DivideTimeScaleTrack implements Track { - Track source; - private int timeScaleDivisor; - - public DivideTimeScaleTrack(Track source, int timeScaleDivisor) { - this.source = source; - this.timeScaleDivisor = timeScaleDivisor; - } - - public SampleDescriptionBox getSampleDescriptionBox() { - return source.getSampleDescriptionBox(); - } - - public List getDecodingTimeEntries() { - return adjustTts(); - } - - public List getCompositionTimeEntries() { - return adjustCtts(); - } - - public long[] getSyncSamples() { - return source.getSyncSamples(); - } - - public List getSampleDependencies() { - return source.getSampleDependencies(); - } - - public TrackMetaData getTrackMetaData() { - TrackMetaData trackMetaData = (TrackMetaData) source.getTrackMetaData().clone(); - trackMetaData.setTimescale(source.getTrackMetaData().getTimescale() / this.timeScaleDivisor); - return trackMetaData; - } - - public String getHandler() { - return source.getHandler(); - } - - public boolean isEnabled() { - return source.isEnabled(); - } - - public boolean isInMovie() { - return source.isInMovie(); - } - - public boolean isInPreview() { - return source.isInPreview(); - } - - public boolean isInPoster() { - return source.isInPoster(); - } - - public List getSamples() { - return source.getSamples(); - } - - - List adjustCtts() { - List origCtts = this.source.getCompositionTimeEntries(); - if (origCtts != null) { - List entries2 = new ArrayList(origCtts.size()); - for (CompositionTimeToSample.Entry entry : origCtts) { - entries2.add(new CompositionTimeToSample.Entry(entry.getCount(), entry.getOffset() / timeScaleDivisor)); - } - return entries2; - } else { - return null; - } - } - - List adjustTts() { - List origTts = source.getDecodingTimeEntries(); - LinkedList entries2 = new LinkedList(); - for (TimeToSampleBox.Entry e : origTts) { - entries2.add(new TimeToSampleBox.Entry(e.getCount(), e.getDelta() / timeScaleDivisor)); - } - return entries2; - } - - public AbstractMediaHeaderBox getMediaHeaderBox() { - return source.getMediaHeaderBox(); - } - - public SubSampleInformationBox getSubsampleInformationBox() { - return source.getSubsampleInformationBox(); - } - - @Override - public String toString() { - return "MultiplyTimeScaleTrack{" + - "source=" + source + - '}'; - } -} diff --git a/android-aac-enc/src/main/java/com/googlecode/mp4parser/authoring/tracks/EC3TrackImpl.java b/android-aac-enc/src/main/java/com/googlecode/mp4parser/authoring/tracks/EC3TrackImpl.java deleted file mode 100644 index 01b788f3a..000000000 --- a/android-aac-enc/src/main/java/com/googlecode/mp4parser/authoring/tracks/EC3TrackImpl.java +++ /dev/null @@ -1,403 +0,0 @@ -package com.googlecode.mp4parser.authoring.tracks; - -import com.coremedia.iso.boxes.*; -import com.coremedia.iso.boxes.sampleentry.AudioSampleEntry; -import com.googlecode.mp4parser.authoring.AbstractTrack; -import com.googlecode.mp4parser.authoring.TrackMetaData; -import com.googlecode.mp4parser.boxes.AC3SpecificBox; -import com.googlecode.mp4parser.boxes.EC3SpecificBox; -import com.googlecode.mp4parser.boxes.mp4.objectdescriptors.BitReaderBuffer; - -import java.io.IOException; -import java.io.InputStream; -import java.nio.ByteBuffer; -import java.util.Date; -import java.util.LinkedList; -import java.util.List; - -/** - * Created by IntelliJ IDEA. - * User: magnus - * Date: 2012-03-14 - * Time: 10:39 - * To change this template use File | Settings | File Templates. - */ -public class EC3TrackImpl extends AbstractTrack { - TrackMetaData trackMetaData = new TrackMetaData(); - SampleDescriptionBox sampleDescriptionBox; - - int samplerate; - int bitrate; - int frameSize; - - List entries = new LinkedList(); - - private InputStream inputStream; - private List samples; - List stts = new LinkedList(); - - public EC3TrackImpl(InputStream fin) throws IOException { - inputStream = fin; - - boolean done = false; - while (!done) { - BitStreamInfo bsi = readVariables(); - if (bsi == null) { - throw new IOException(); - } - for (int i = 0; i < entries.size(); i++) { - if (bsi.strmtyp != 1 && entries.get(i).substreamid == bsi.substreamid) { - done = true; - } - } - if (!done) { - entries.add(bsi); - inputStream.skip(bsi.frameSize); - } - } - for (BitStreamInfo bsi : entries) { - inputStream.skip(-1 * bsi.frameSize); - } - - if (entries.size() == 0) { - throw new IOException(); - } - samplerate = entries.get(0).samplerate; - - sampleDescriptionBox = new SampleDescriptionBox(); - AudioSampleEntry audioSampleEntry = new AudioSampleEntry("ec-3"); - audioSampleEntry.setChannelCount(2); - audioSampleEntry.setSampleRate(samplerate); - audioSampleEntry.setDataReferenceIndex(1); - audioSampleEntry.setSampleSize(16); - - EC3SpecificBox ec3 = new EC3SpecificBox(); - int[] deps = new int[entries.size()]; - int[] chan_locs = new int[entries.size()]; - for (BitStreamInfo bsi : entries) { - if (bsi.strmtyp == 1) { - deps[bsi.substreamid]++; - chan_locs[bsi.substreamid] = ((bsi.chanmap >> 6) & 0x100) | ((bsi.chanmap >> 5) & 0xff); - } - } - for (BitStreamInfo bsi : entries) { - if (bsi.strmtyp != 1) { - EC3SpecificBox.Entry e = new EC3SpecificBox.Entry(); - e.fscod = bsi.fscod; - e.bsid = bsi.bsid; - e.bsmod = bsi.bsmod; - e.acmod = bsi.acmod; - e.lfeon = bsi.lfeon; - e.reserved = 0; - e.num_dep_sub = deps[bsi.substreamid]; - e.chan_loc = chan_locs[bsi.substreamid]; - e.reserved2 = 0; - ec3.addEntry(e); - } - bitrate += bsi.bitrate; - frameSize += bsi.frameSize; - } - - ec3.setDataRate(bitrate / 1000); - audioSampleEntry.addBox(ec3); - sampleDescriptionBox.addBox(audioSampleEntry); - - trackMetaData.setCreationTime(new Date()); - trackMetaData.setModificationTime(new Date()); - trackMetaData.setLanguage("eng"); - trackMetaData.setTimescale(samplerate); // Audio tracks always use samplerate as timescale - - samples = new LinkedList(); - if (!readSamples()) { - throw new IOException(); - } - } - - - public List getSamples() { - - return samples; - } - - public SampleDescriptionBox getSampleDescriptionBox() { - return sampleDescriptionBox; - } - - public List getDecodingTimeEntries() { - return stts; - } - - public List getCompositionTimeEntries() { - return null; - } - - public long[] getSyncSamples() { - return null; - } - - public List getSampleDependencies() { - return null; - } - - public TrackMetaData getTrackMetaData() { - return trackMetaData; - } - - public String getHandler() { - return "soun"; - } - - public AbstractMediaHeaderBox getMediaHeaderBox() { - return new SoundMediaHeaderBox(); - } - - public SubSampleInformationBox getSubsampleInformationBox() { - return null; - } - - private BitStreamInfo readVariables() throws IOException { - byte[] data = new byte[200]; - if (200 != inputStream.read(data, 0, 200)) { - return null; - } - inputStream.skip(-200); // Rewind - ByteBuffer bb = ByteBuffer.wrap(data); - BitReaderBuffer brb = new BitReaderBuffer(bb); - int syncword = brb.readBits(16); - if (syncword != 0xb77) { - return null; - } - - BitStreamInfo entry = new BitStreamInfo(); - - entry.strmtyp = brb.readBits(2); - entry.substreamid = brb.readBits(3); - int frmsiz = brb.readBits(11); - entry.frameSize = 2 * (frmsiz + 1); - - entry.fscod = brb.readBits(2); - int fscod2 = -1; - int numblkscod; - if (entry.fscod == 3) { - fscod2 = brb.readBits(2); - numblkscod = 3; - } else { - numblkscod = brb.readBits(2); - } - int numberOfBlocksPerSyncFrame = 0; - switch (numblkscod) { - case 0: - numberOfBlocksPerSyncFrame = 1; - break; - - case 1: - numberOfBlocksPerSyncFrame = 2; - break; - - case 2: - numberOfBlocksPerSyncFrame = 3; - break; - - case 3: - numberOfBlocksPerSyncFrame = 6; - break; - - } - entry.frameSize *= (6 / numberOfBlocksPerSyncFrame); // Not sure if this is the correct algorithm? - - entry.acmod = brb.readBits(3); - entry.lfeon = brb.readBits(1); - entry.bsid = brb.readBits(5); - brb.readBits(5); - if (1 == brb.readBits(1)) { - brb.readBits(8); // compr - } - if (0 == entry.acmod) { - brb.readBits(5); - if (1 == brb.readBits(1)) { - brb.readBits(8); - } - } - if (1 == entry.strmtyp) { - if (1 == brb.readBits(1)) { - entry.chanmap = brb.readBits(16); - } - } - if (1 == brb.readBits(1)) { // mixing metadata - if (entry.acmod > 2) { - brb.readBits(2); - } - if (1 == (entry.acmod & 1) && entry.acmod > 2) { - brb.readBits(3); - brb.readBits(3); - } - if (0 < (entry.acmod & 4)) { - brb.readBits(3); - brb.readBits(3); - } - if (1 == entry.lfeon) { - if (1 == brb.readBits(1)) { - brb.readBits(5); - } - } - if (0 == entry.strmtyp) { - if (1 == brb.readBits(1)) { - brb.readBits(6); - } - if (0 == entry.acmod) { - if (1 == brb.readBits(1)) { - brb.readBits(6); - } - } - if (1 == brb.readBits(1)) { - brb.readBits(6); - } - int mixdef = brb.readBits(2); - if (1 == mixdef) { - brb.readBits(5); - } else if (2 == mixdef) { - brb.readBits(12); - } else if (3 == mixdef) { - int mixdeflen = brb.readBits(5); - if (1 == brb.readBits(1)) { - brb.readBits(5); - if (1 == brb.readBits(1)) { - brb.readBits(4); - } - if (1 == brb.readBits(1)) { - brb.readBits(4); - } - if (1 == brb.readBits(1)) { - brb.readBits(4); - } - if (1 == brb.readBits(1)) { - brb.readBits(4); - } - if (1 == brb.readBits(1)) { - brb.readBits(4); - } - if (1 == brb.readBits(1)) { - brb.readBits(4); - } - if (1 == brb.readBits(1)) { - brb.readBits(4); - } - if (1 == brb.readBits(1)) { - if (1 == brb.readBits(1)) { - brb.readBits(4); - } - if (1 == brb.readBits(1)) { - brb.readBits(4); - } - } - } - if (1 == brb.readBits(1)) { - brb.readBits(5); - if (1 == brb.readBits(1)) { - brb.readBits(7); - if (1 == brb.readBits(1)) { - brb.readBits(8); - } - } - } - for (int i = 0; i < (mixdeflen + 2); i++) { - brb.readBits(8); - } - brb.byteSync(); - } - if (entry.acmod < 2) { - if (1 == brb.readBits(1)) { - brb.readBits(14); - } - if (0 == entry.acmod) { - if (1 == brb.readBits(1)) { - brb.readBits(14); - } - } - if (1 == brb.readBits(1)) { - if (numblkscod == 0) { - brb.readBits(5); - } else { - for (int i = 0; i < numberOfBlocksPerSyncFrame; i++) { - if (1 == brb.readBits(1)) { - brb.readBits(5); - } - } - } - - } - } - } - } - if (1 == brb.readBits(1)) { // infomdate - entry.bsmod = brb.readBits(3); - } - - switch (entry.fscod) { - case 0: - entry.samplerate = 48000; - break; - - case 1: - entry.samplerate = 44100; - break; - - case 2: - entry.samplerate = 32000; - break; - - case 3: { - switch (fscod2) { - case 0: - entry.samplerate = 24000; - break; - - case 1: - entry.samplerate = 22050; - break; - - case 2: - entry.samplerate = 16000; - break; - - case 3: - entry.samplerate = 0; - break; - } - break; - } - - } - if (entry.samplerate == 0) { - return null; - } - - entry.bitrate = (int) (((double) entry.samplerate) / 1536.0 * entry.frameSize * 8); - - return entry; - } - - private boolean readSamples() throws IOException { - int read = frameSize; - boolean ret = false; - while (frameSize == read) { - ret = true; - byte[] data = new byte[frameSize]; - read = inputStream.read(data); - if (read == frameSize) { - samples.add(ByteBuffer.wrap(data)); - stts.add(new TimeToSampleBox.Entry(1, 1536)); - } - } - return ret; - } - - public static class BitStreamInfo extends EC3SpecificBox.Entry { - public int frameSize; - public int substreamid; - public int bitrate; - public int samplerate; - public int strmtyp; - public int chanmap; - } -} diff --git a/android-aac-enc/src/main/java/com/googlecode/mp4parser/authoring/tracks/H264TrackImpl.java b/android-aac-enc/src/main/java/com/googlecode/mp4parser/authoring/tracks/H264TrackImpl.java deleted file mode 100644 index 8358046fa..000000000 --- a/android-aac-enc/src/main/java/com/googlecode/mp4parser/authoring/tracks/H264TrackImpl.java +++ /dev/null @@ -1,678 +0,0 @@ -package com.googlecode.mp4parser.authoring.tracks; - -import com.coremedia.iso.boxes.AbstractMediaHeaderBox; -import com.coremedia.iso.boxes.CompositionTimeToSample; -import com.coremedia.iso.boxes.SampleDependencyTypeBox; -import com.coremedia.iso.boxes.SampleDescriptionBox; -import com.coremedia.iso.boxes.SubSampleInformationBox; -import com.coremedia.iso.boxes.TimeToSampleBox; -import com.coremedia.iso.boxes.VideoMediaHeaderBox; -import com.coremedia.iso.boxes.h264.AvcConfigurationBox; -import com.coremedia.iso.boxes.sampleentry.VisualSampleEntry; -import com.googlecode.mp4parser.authoring.AbstractTrack; -import com.googlecode.mp4parser.authoring.TrackMetaData; -import com.googlecode.mp4parser.h264.model.PictureParameterSet; -import com.googlecode.mp4parser.h264.model.SeqParameterSet; -import com.googlecode.mp4parser.h264.read.CAVLCReader; - -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.nio.ByteBuffer; -import java.util.ArrayList; -import java.util.Date; -import java.util.LinkedList; -import java.util.List; - -/** - * The H264TrackImpl creates a Track from an H.264 - * Annex B file. - */ -public class H264TrackImpl extends AbstractTrack { - TrackMetaData trackMetaData = new TrackMetaData(); - SampleDescriptionBox sampleDescriptionBox; - - private ReaderWrapper reader; - private List samples; - boolean readSamples = false; - - List stts; - List ctts; - List sdtp; - List stss; - - SeqParameterSet seqParameterSet = null; - PictureParameterSet pictureParameterSet = null; - LinkedList seqParameterSetList = new LinkedList(); - LinkedList pictureParameterSetList = new LinkedList(); - - private int width; - private int height; - private int timescale; - private int frametick; - - private SEIMessage seiMessage; - int frameNrInGop = 0; - - public H264TrackImpl(InputStream inputStream) throws IOException { - this.reader = new ReaderWrapper(inputStream); - stts = new LinkedList(); - ctts = new LinkedList(); - sdtp = new LinkedList(); - stss = new LinkedList(); - - samples = new LinkedList(); - if (!readSamples()) { - throw new IOException(); - } - - if (!readVariables()) { - throw new IOException(); - } - - sampleDescriptionBox = new SampleDescriptionBox(); - VisualSampleEntry visualSampleEntry = new VisualSampleEntry("avc1"); - visualSampleEntry.setDataReferenceIndex(1); - visualSampleEntry.setDepth(24); - visualSampleEntry.setFrameCount(1); - visualSampleEntry.setHorizresolution(72); - visualSampleEntry.setVertresolution(72); - visualSampleEntry.setWidth(width); - visualSampleEntry.setHeight(height); - visualSampleEntry.setCompressorname("AVC Coding"); - - AvcConfigurationBox avcConfigurationBox = new AvcConfigurationBox(); - - avcConfigurationBox.setSequenceParameterSets(seqParameterSetList); - avcConfigurationBox.setPictureParameterSets(pictureParameterSetList); - avcConfigurationBox.setAvcLevelIndication(seqParameterSet.level_idc); - avcConfigurationBox.setAvcProfileIndicaation(seqParameterSet.profile_idc); - avcConfigurationBox.setBitDepthLumaMinus8(seqParameterSet.bit_depth_luma_minus8); - avcConfigurationBox.setBitDepthChromaMinus8(seqParameterSet.bit_depth_chroma_minus8); - avcConfigurationBox.setChromaFormat(seqParameterSet.chroma_format_idc.getId()); - avcConfigurationBox.setConfigurationVersion(1); - avcConfigurationBox.setLengthSizeMinusOne(3); - avcConfigurationBox.setProfileCompatibility(seqParameterSetList.get(0)[1]); - - visualSampleEntry.addBox(avcConfigurationBox); - sampleDescriptionBox.addBox(visualSampleEntry); - - trackMetaData.setCreationTime(new Date()); - trackMetaData.setModificationTime(new Date()); - trackMetaData.setLanguage("eng"); - trackMetaData.setTimescale(timescale); // Audio tracks always use samplerate as timescale - trackMetaData.setWidth(width); - trackMetaData.setHeight(height); - } - - public SampleDescriptionBox getSampleDescriptionBox() { - return sampleDescriptionBox; - } - - public List getDecodingTimeEntries() { - return stts; //To change body of implemented methods use File | Settings | File Templates. - } - - public List getCompositionTimeEntries() { - return ctts; - } - - public long[] getSyncSamples() { - long[] returns = new long[stss.size()]; - for (int i = 0; i < stss.size(); i++) { - returns[i] = stss.get(i); - } - return returns; - } - - public List getSampleDependencies() { - return sdtp; - } - - public TrackMetaData getTrackMetaData() { - return trackMetaData; - } - - public String getHandler() { - return "vide"; - } - - public List getSamples() { - return samples; - } - - public AbstractMediaHeaderBox getMediaHeaderBox() { - return new VideoMediaHeaderBox(); - } - - public SubSampleInformationBox getSubsampleInformationBox() { - return null; - } - - private boolean readVariables() { - width = (seqParameterSet.pic_width_in_mbs_minus1 + 1) * 16; - int mult = 2; - if (seqParameterSet.frame_mbs_only_flag) { - mult = 1; - } - height = 16 * (seqParameterSet.pic_height_in_map_units_minus1 + 1) * mult; - if (seqParameterSet.frame_cropping_flag) { - int chromaArrayType = 0; - if (seqParameterSet.residual_color_transform_flag == false) { - chromaArrayType = seqParameterSet.chroma_format_idc.getId(); - } - int cropUnitX = 1; - int cropUnitY = mult; - if (chromaArrayType != 0) { - cropUnitX = seqParameterSet.chroma_format_idc.getSubWidth(); - cropUnitY = seqParameterSet.chroma_format_idc.getSubHeight() * mult; - } - - width -= cropUnitX * (seqParameterSet.frame_crop_left_offset + seqParameterSet.frame_crop_right_offset); - height -= cropUnitY * (seqParameterSet.frame_crop_top_offset + seqParameterSet.frame_crop_bottom_offset); - } - return true; - } - - private boolean findNextStartcode() throws IOException { - byte[] test = new byte[4]; - while (4 == reader.read(test)) { - if (test[0] == 0 && test[1] == 0 && test[2] == 0 && test[3] == 1) { - return true; - } - reader.rewind(3); - } - return false; - } - - private enum NALActions { - IGNORE, BUFFER, STORE, END - } - - private boolean readSamples() throws IOException { - if (readSamples) { - return true; - } - - readSamples = true; - - long pos = reader.getPos(); - findNextStartcode(); - - ArrayList buffered = new ArrayList(); - - int frameNr = 0; - - while (findNextStartcode()) { - long newpos = reader.getPos() - 4; - int size = (int) (newpos - pos); - reader.rewind(size); - byte[] data = new byte[size - 4]; - reader.read(data); - int type = data[0]; - int nal_ref_idc = (type >> 5) & 3; - int nal_unit_type = type & 0x1f; - System.out.println("Found startcode at " + pos + " Type: " + nal_unit_type + " ref idc: " + nal_ref_idc + " (size " + size + ")"); - NALActions action = handleNALUnit(nal_ref_idc, nal_unit_type, data); - switch (action) { - case IGNORE: - break; - - case BUFFER: - buffered.add(data); - break; - - case STORE: - int stdpValue = 22; - frameNr++; - buffered.add(data); - ByteBuffer bb = createSample(buffered); - boolean IdrPicFlag = false; - if (nal_unit_type == 5) { - stdpValue += 16; - IdrPicFlag = true; - } - ByteArrayInputStream bs = cleanBuffer(buffered.get(buffered.size() - 1)); - SliceHeader sh = new SliceHeader(bs, seqParameterSet, pictureParameterSet, IdrPicFlag); - if (sh.slice_type == SliceHeader.SliceType.B) { - stdpValue += 4; - } - System.out.println("Adding sample with size " + bb.capacity() + " and header " + sh); - buffered.clear(); - samples.add(bb); - stts.add(new TimeToSampleBox.Entry(1, frametick)); - if (nal_unit_type == 5) { // IDR Picture - stss.add(frameNr); - } - if (seiMessage.n_frames == 0) { - frameNrInGop = 0; - } - int offset = 0; - if (seiMessage.clock_timestamp_flag) { - offset = seiMessage.n_frames - frameNrInGop; - } else if (seiMessage.removal_delay_flag) { - offset = seiMessage.dpb_removal_delay / 2; - } - ctts.add(new CompositionTimeToSample.Entry(1, offset * frametick)); - sdtp.add(new SampleDependencyTypeBox.Entry(stdpValue)); - frameNrInGop++; - break; - - case END: - return true; - - - } - pos = newpos; - reader.seek(4); - } - return true; - } - - private ByteBuffer createSample(List buffers) { - int outsize = 0; - for (int i = 0; i < buffers.size(); i++) { - outsize += buffers.get(i).length + 4; - } - byte[] output = new byte[outsize]; - - ByteBuffer bb = ByteBuffer.wrap(output); - for (int i = 0; i < buffers.size(); i++) { - bb.putInt(buffers.get(i).length); - bb.put(buffers.get(i)); - } - bb.rewind(); - return bb; - } - - private ByteArrayInputStream cleanBuffer(byte[] data) { - byte[] output = new byte[data.length]; - int inPos = 0; - int outPos = 0; - while (inPos < data.length) { - if (data[inPos] == 0 && data[inPos + 1] == 0 && data[inPos + 2] == 3) { - output[outPos] = 0; - output[outPos + 1] = 0; - inPos += 3; - outPos += 2; - } else { - output[outPos] = data[inPos]; - inPos++; - outPos++; - } - } - return new ByteArrayInputStream(output, 0, outPos); - } - - private NALActions handleNALUnit(int nal_ref_idc, int nal_unit_type, byte[] data) throws IOException { - NALActions action; - switch (nal_unit_type) { - case 1: - case 2: - case 3: - case 4: - case 5: - action = NALActions.STORE; // Will only work in single slice per frame mode! - break; - - case 6: - seiMessage = new SEIMessage(cleanBuffer(data), seqParameterSet); - action = NALActions.BUFFER; - break; - - case 9: -// printAccessUnitDelimiter(data); - action = NALActions.BUFFER; - break; - - - case 7: - if (seqParameterSet == null) { - ByteArrayInputStream is = new ByteArrayInputStream(data); - is.read(); - seqParameterSet = SeqParameterSet.read(is); - seqParameterSetList.add(data); - if (seqParameterSet.vuiParams != null) { - timescale = seqParameterSet.vuiParams.time_scale >> 1; // Not sure why, but I found this in several places, and it works... - frametick = seqParameterSet.vuiParams.num_units_in_tick; - } else { - System.err.println("Warning: Can't determine frame rate. Guessing 25 fps"); - timescale = 90000; - frametick = 3600; - } - } - action = NALActions.IGNORE; - break; - - case 8: - if (pictureParameterSet == null) { - ByteArrayInputStream is = new ByteArrayInputStream(data); - is.read(); - pictureParameterSet = PictureParameterSet.read(is); - pictureParameterSetList.add(data); - } - action = NALActions.IGNORE; - break; - - case 10: - case 11: - action = NALActions.END; - break; - - default: - System.err.println("Unknown NAL unit type: " + nal_unit_type); - action = NALActions.IGNORE; - - } - - return action; - } - - public void printAccessUnitDelimiter(byte[] data) { - System.out.println("Access unit delimiter: " + (data[0] >> 5)); - } - - public static class SliceHeader { - - public enum SliceType { - P, B, I, SP, SI - } - - public int first_mb_in_slice; - public SliceType slice_type; - public int pic_parameter_set_id; - public int colour_plane_id; - public int frame_num; - public boolean field_pic_flag = false; - public boolean bottom_field_flag = false; - public int idr_pic_id; - public int pic_order_cnt_lsb; - public int delta_pic_order_cnt_bottom; - - public SliceHeader(InputStream is, SeqParameterSet sps, PictureParameterSet pps, boolean IdrPicFlag) throws IOException { - is.read(); - CAVLCReader reader = new CAVLCReader(is); - first_mb_in_slice = reader.readUE("SliceHeader: first_mb_in_slice"); - switch (reader.readUE("SliceHeader: slice_type")) { - case 0: - case 5: - slice_type = SliceType.P; - break; - - case 1: - case 6: - slice_type = SliceType.B; - break; - - case 2: - case 7: - slice_type = SliceType.I; - break; - - case 3: - case 8: - slice_type = SliceType.SP; - break; - - case 4: - case 9: - slice_type = SliceType.SI; - break; - - } - pic_parameter_set_id = reader.readUE("SliceHeader: pic_parameter_set_id"); - if (sps.residual_color_transform_flag) { - colour_plane_id = reader.readU(2, "SliceHeader: colour_plane_id"); - } - frame_num = reader.readU(sps.log2_max_frame_num_minus4 + 4, "SliceHeader: frame_num"); - - if (!sps.frame_mbs_only_flag) { - field_pic_flag = reader.readBool("SliceHeader: field_pic_flag"); - if (field_pic_flag) { - bottom_field_flag = reader.readBool("SliceHeader: bottom_field_flag"); - } - } - if (IdrPicFlag) { - idr_pic_id = reader.readUE("SliceHeader: idr_pic_id"); - if (sps.pic_order_cnt_type == 0) { - pic_order_cnt_lsb = reader.readU(sps.log2_max_pic_order_cnt_lsb_minus4 + 4, "SliceHeader: pic_order_cnt_lsb"); - if (pps.pic_order_present_flag && !field_pic_flag) { - delta_pic_order_cnt_bottom = reader.readSE("SliceHeader: delta_pic_order_cnt_bottom"); - } - } - } - } - - @Override - public String toString() { - return "SliceHeader{" + - "first_mb_in_slice=" + first_mb_in_slice + - ", slice_type=" + slice_type + - ", pic_parameter_set_id=" + pic_parameter_set_id + - ", colour_plane_id=" + colour_plane_id + - ", frame_num=" + frame_num + - ", field_pic_flag=" + field_pic_flag + - ", bottom_field_flag=" + bottom_field_flag + - ", idr_pic_id=" + idr_pic_id + - ", pic_order_cnt_lsb=" + pic_order_cnt_lsb + - ", delta_pic_order_cnt_bottom=" + delta_pic_order_cnt_bottom + - '}'; - } - } - - private class ReaderWrapper { - private InputStream inputStream; - private long pos = 0; - - private ReaderWrapper(InputStream inputStream) { - this.inputStream = inputStream; - } - - int read() throws IOException { - pos++; - return inputStream.read(); - } - - long read(byte[] data) throws IOException { - long read = inputStream.read(data); - pos += read; - return read; - } - - long rewind(int dist) throws IOException { - long skipped = inputStream.skip(-dist); - pos += skipped; - return -skipped; - } - - long seek(int dist) throws IOException { - long seeked = inputStream.skip(dist); - pos += seeked; - return seeked; - } - - public long getPos() { - return pos; - } - } - - public class SEIMessage { - - int payloadType = 0; - int payloadSize = 0; - - boolean removal_delay_flag; - int cpb_removal_delay; - int dpb_removal_delay; - - boolean clock_timestamp_flag; - int pic_struct; - int ct_type; - int nuit_field_based_flag; - int counting_type; - int full_timestamp_flag; - int discontinuity_flag; - int cnt_dropped_flag; - int n_frames; - int seconds_value; - int minutes_value; - int hours_value; - int time_offset_length; - int time_offset; - - SeqParameterSet sps; - - public SEIMessage(InputStream is, SeqParameterSet sps) throws IOException { - this.sps = sps; - is.read(); - int datasize = is.available(); - int read = 0; - while (read < datasize) { - payloadType = 0; - payloadSize = 0; - int last_payload_type_bytes = is.read(); - read++; - while (last_payload_type_bytes == 0xff) { - payloadType += last_payload_type_bytes; - last_payload_type_bytes = is.read(); - read++; - } - payloadType += last_payload_type_bytes; - int last_payload_size_bytes = is.read(); - read++; - - while (last_payload_size_bytes == 0xff) { - payloadSize += last_payload_size_bytes; - last_payload_size_bytes = is.read(); - read++; - } - payloadSize += last_payload_size_bytes; - if (datasize - read >= payloadSize) { - if (payloadType == 1) { // pic_timing is what we are interested in! - if (sps.vuiParams != null && (sps.vuiParams.nalHRDParams != null || sps.vuiParams.vclHRDParams != null || sps.vuiParams.pic_struct_present_flag)) { - byte[] data = new byte[payloadSize]; - is.read(data); - read += payloadSize; - CAVLCReader reader = new CAVLCReader(new ByteArrayInputStream(data)); - if (sps.vuiParams.nalHRDParams != null || sps.vuiParams.vclHRDParams != null) { - removal_delay_flag = true; - cpb_removal_delay = reader.readU(sps.vuiParams.nalHRDParams.cpb_removal_delay_length_minus1 + 1, "SEI: cpb_removal_delay"); - dpb_removal_delay = reader.readU(sps.vuiParams.nalHRDParams.dpb_output_delay_length_minus1 + 1, "SEI: dpb_removal_delay"); - } else { - removal_delay_flag = false; - } - if (sps.vuiParams.pic_struct_present_flag) { - pic_struct = reader.readU(4, "SEI: pic_struct"); - int numClockTS; - switch (pic_struct) { - case 0: - case 1: - case 2: - default: - numClockTS = 1; - break; - - case 3: - case 4: - case 7: - numClockTS = 2; - break; - - case 5: - case 6: - case 8: - numClockTS = 3; - break; - } - for (int i = 0; i < numClockTS; i++) { - clock_timestamp_flag = reader.readBool("pic_timing SEI: clock_timestamp_flag[" + i + "]"); - if (clock_timestamp_flag) { - ct_type = reader.readU(2, "pic_timing SEI: ct_type"); - nuit_field_based_flag = reader.readU(1, "pic_timing SEI: nuit_field_based_flag"); - counting_type = reader.readU(5, "pic_timing SEI: counting_type"); - full_timestamp_flag = reader.readU(1, "pic_timing SEI: full_timestamp_flag"); - discontinuity_flag = reader.readU(1, "pic_timing SEI: discontinuity_flag"); - cnt_dropped_flag = reader.readU(1, "pic_timing SEI: cnt_dropped_flag"); - n_frames = reader.readU(8, "pic_timing SEI: n_frames"); - if (full_timestamp_flag == 1) { - seconds_value = reader.readU(6, "pic_timing SEI: seconds_value"); - minutes_value = reader.readU(6, "pic_timing SEI: minutes_value"); - hours_value = reader.readU(5, "pic_timing SEI: hours_value"); - } else { - if (reader.readBool("pic_timing SEI: seconds_flag")) { - seconds_value = reader.readU(6, "pic_timing SEI: seconds_value"); - if (reader.readBool("pic_timing SEI: minutes_flag")) { - minutes_value = reader.readU(6, "pic_timing SEI: minutes_value"); - if (reader.readBool("pic_timing SEI: hours_flag")) { - hours_value = reader.readU(5, "pic_timing SEI: hours_value"); - } - } - } - } - if (true) { - if (sps.vuiParams.nalHRDParams != null) { - time_offset_length = sps.vuiParams.nalHRDParams.time_offset_length; - } else if (sps.vuiParams.vclHRDParams != null) { - time_offset_length = sps.vuiParams.vclHRDParams.time_offset_length; - } else { - time_offset_length = 24; - } - time_offset = reader.readU(24, "pic_timing SEI: time_offset"); - } - } - } - } - - } else { - for (int i = 0; i < payloadSize; i++) { - is.read(); - read++; - } - } - } else { - for (int i = 0; i < payloadSize; i++) { - is.read(); - read++; - } - } - } else { - read = datasize; - } - System.out.println(this); - } - } - - @Override - public String toString() { - String out = "SEIMessage{" + - "payloadType=" + payloadType + - ", payloadSize=" + payloadSize; - if (payloadType == 1) { - if (sps.vuiParams.nalHRDParams != null || sps.vuiParams.vclHRDParams != null) { - - out += ", cpb_removal_delay=" + cpb_removal_delay + - ", dpb_removal_delay=" + dpb_removal_delay; - } - if (sps.vuiParams.pic_struct_present_flag) { - out += ", pic_struct=" + pic_struct; - if (clock_timestamp_flag) { - out += ", ct_type=" + ct_type + - ", nuit_field_based_flag=" + nuit_field_based_flag + - ", counting_type=" + counting_type + - ", full_timestamp_flag=" + full_timestamp_flag + - ", discontinuity_flag=" + discontinuity_flag + - ", cnt_dropped_flag=" + cnt_dropped_flag + - ", n_frames=" + n_frames + - ", seconds_value=" + seconds_value + - ", minutes_value=" + minutes_value + - ", hours_value=" + hours_value + - ", time_offset_length=" + time_offset_length + - ", time_offset=" + time_offset; - } - } - } - out += '}'; - return out; - } - } -} diff --git a/android-aac-enc/src/main/java/com/googlecode/mp4parser/authoring/tracks/MultiplyTimeScaleTrack.java b/android-aac-enc/src/main/java/com/googlecode/mp4parser/authoring/tracks/MultiplyTimeScaleTrack.java deleted file mode 100644 index 2e54e64ba..000000000 --- a/android-aac-enc/src/main/java/com/googlecode/mp4parser/authoring/tracks/MultiplyTimeScaleTrack.java +++ /dev/null @@ -1,135 +0,0 @@ -/* - * Copyright 2012 Sebastian Annies, Hamburg - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.googlecode.mp4parser.authoring.tracks; - -import com.coremedia.iso.boxes.AbstractMediaHeaderBox; -import com.coremedia.iso.boxes.CompositionTimeToSample; -import com.coremedia.iso.boxes.SampleDependencyTypeBox; -import com.coremedia.iso.boxes.SampleDescriptionBox; -import com.coremedia.iso.boxes.SubSampleInformationBox; -import com.coremedia.iso.boxes.TimeToSampleBox; -import com.googlecode.mp4parser.authoring.Movie; -import com.googlecode.mp4parser.authoring.Track; -import com.googlecode.mp4parser.authoring.TrackMetaData; - -import java.nio.ByteBuffer; -import java.util.ArrayList; -import java.util.LinkedList; -import java.util.List; - -import static com.googlecode.mp4parser.util.CastUtils.l2i; -import static com.googlecode.mp4parser.util.Math.gcd; -import static com.googlecode.mp4parser.util.Math.lcm; -import static java.lang.Math.round; - -/** - * Changes the timescale of a track by wrapping the track. - */ -public class MultiplyTimeScaleTrack implements Track { - Track source; - private int timeScaleFactor; - - public MultiplyTimeScaleTrack(Track source, int timeScaleFactor) { - this.source = source; - this.timeScaleFactor = timeScaleFactor; - } - - public SampleDescriptionBox getSampleDescriptionBox() { - return source.getSampleDescriptionBox(); - } - - public List getDecodingTimeEntries() { - return adjustTts(source.getDecodingTimeEntries(), timeScaleFactor); - } - - public List getCompositionTimeEntries() { - return adjustCtts(source.getCompositionTimeEntries(), timeScaleFactor); - } - - public long[] getSyncSamples() { - return source.getSyncSamples(); - } - - public List getSampleDependencies() { - return source.getSampleDependencies(); - } - - public TrackMetaData getTrackMetaData() { - TrackMetaData trackMetaData = (TrackMetaData) source.getTrackMetaData().clone(); - trackMetaData.setTimescale(source.getTrackMetaData().getTimescale() * this.timeScaleFactor); - return trackMetaData; - } - - public String getHandler() { - return source.getHandler(); - } - - public boolean isEnabled() { - return source.isEnabled(); - } - - public boolean isInMovie() { - return source.isInMovie(); - } - - public boolean isInPreview() { - return source.isInPreview(); - } - - public boolean isInPoster() { - return source.isInPoster(); - } - - public List getSamples() { - return source.getSamples(); - } - - - static List adjustCtts(List source, int timeScaleFactor) { - if (source != null) { - List entries2 = new ArrayList(source.size()); - for (CompositionTimeToSample.Entry entry : source) { - entries2.add(new CompositionTimeToSample.Entry(entry.getCount(), timeScaleFactor * entry.getOffset())); - } - return entries2; - } else { - return null; - } - } - - static List adjustTts(List source, int timeScaleFactor) { - LinkedList entries2 = new LinkedList(); - for (TimeToSampleBox.Entry e : source) { - entries2.add(new TimeToSampleBox.Entry(e.getCount(), timeScaleFactor * e.getDelta())); - } - return entries2; - } - - public AbstractMediaHeaderBox getMediaHeaderBox() { - return source.getMediaHeaderBox(); - } - - public SubSampleInformationBox getSubsampleInformationBox() { - return source.getSubsampleInformationBox(); - } - - @Override - public String toString() { - return "MultiplyTimeScaleTrack{" + - "source=" + source + - '}'; - } -} diff --git a/android-aac-enc/src/main/java/com/googlecode/mp4parser/authoring/tracks/TextTrackImpl.java b/android-aac-enc/src/main/java/com/googlecode/mp4parser/authoring/tracks/TextTrackImpl.java deleted file mode 100644 index eddf54fff..000000000 --- a/android-aac-enc/src/main/java/com/googlecode/mp4parser/authoring/tracks/TextTrackImpl.java +++ /dev/null @@ -1,164 +0,0 @@ -/* - * Copyright 2012 Sebastian Annies, Hamburg - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.googlecode.mp4parser.authoring.tracks; - -import com.coremedia.iso.boxes.*; -import com.coremedia.iso.boxes.sampleentry.TextSampleEntry; -import com.googlecode.mp4parser.authoring.AbstractTrack; -import com.googlecode.mp4parser.authoring.TrackMetaData; -import com.googlecode.mp4parser.boxes.threegpp26245.FontTableBox; - -import java.io.ByteArrayOutputStream; -import java.io.DataOutputStream; -import java.io.IOException; -import java.nio.ByteBuffer; -import java.util.Collections; -import java.util.Date; -import java.util.LinkedList; -import java.util.List; - -/** - * - */ -public class TextTrackImpl extends AbstractTrack { - TrackMetaData trackMetaData = new TrackMetaData(); - SampleDescriptionBox sampleDescriptionBox; - List subs = new LinkedList(); - - public List getSubs() { - return subs; - } - - public TextTrackImpl() { - sampleDescriptionBox = new SampleDescriptionBox(); - TextSampleEntry tx3g = new TextSampleEntry("tx3g"); - tx3g.setStyleRecord(new TextSampleEntry.StyleRecord()); - tx3g.setBoxRecord(new TextSampleEntry.BoxRecord()); - sampleDescriptionBox.addBox(tx3g); - - FontTableBox ftab = new FontTableBox(); - ftab.setEntries(Collections.singletonList(new FontTableBox.FontRecord(1, "Serif"))); - - tx3g.addBox(ftab); - - - trackMetaData.setCreationTime(new Date()); - trackMetaData.setModificationTime(new Date()); - trackMetaData.setTimescale(1000); // Text tracks use millieseconds - - - } - - - public List getSamples() { - List samples = new LinkedList(); - long lastEnd = 0; - for (Line sub : subs) { - long silentTime = sub.from - lastEnd; - if (silentTime > 0) { - samples.add(ByteBuffer.wrap(new byte[]{0, 0})); - } else if (silentTime < 0) { - throw new Error("Subtitle display times may not intersect"); - } - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - DataOutputStream dos = new DataOutputStream(baos); - try { - dos.writeShort(sub.text.getBytes("UTF-8").length); - dos.write(sub.text.getBytes("UTF-8")); - dos.close(); - } catch (IOException e) { - throw new Error("VM is broken. Does not support UTF-8"); - } - samples.add(ByteBuffer.wrap(baos.toByteArray())); - lastEnd = sub.to; - } - return samples; - } - - public SampleDescriptionBox getSampleDescriptionBox() { - return sampleDescriptionBox; - } - - public List getDecodingTimeEntries() { - List stts = new LinkedList(); - long lastEnd = 0; - for (Line sub : subs) { - long silentTime = sub.from - lastEnd; - if (silentTime > 0) { - stts.add(new TimeToSampleBox.Entry(1, silentTime)); - } else if (silentTime < 0) { - throw new Error("Subtitle display times may not intersect"); - } - stts.add(new TimeToSampleBox.Entry(1, sub.to - sub.from)); - lastEnd = sub.to; - } - return stts; - } - - public List getCompositionTimeEntries() { - return null; - } - - public long[] getSyncSamples() { - return null; - } - - public List getSampleDependencies() { - return null; - } - - public TrackMetaData getTrackMetaData() { - return trackMetaData; - } - - public String getHandler() { - return "text"; - } - - - public static class Line { - long from; - long to; - String text; - - - public Line(long from, long to, String text) { - this.from = from; - this.to = to; - this.text = text; - } - - public long getFrom() { - return from; - } - - public String getText() { - return text; - } - - public long getTo() { - return to; - } - } - - public AbstractMediaHeaderBox getMediaHeaderBox() { - return new NullMediaHeaderBox(); - } - - public SubSampleInformationBox getSubsampleInformationBox() { - return null; - } -} diff --git a/android-aac-enc/src/main/java/com/googlecode/mp4parser/boxes/AC3SpecificBox.java b/android-aac-enc/src/main/java/com/googlecode/mp4parser/boxes/AC3SpecificBox.java deleted file mode 100644 index a3006cdfb..000000000 --- a/android-aac-enc/src/main/java/com/googlecode/mp4parser/boxes/AC3SpecificBox.java +++ /dev/null @@ -1,119 +0,0 @@ -package com.googlecode.mp4parser.boxes; - -import com.googlecode.mp4parser.AbstractBox; -import com.googlecode.mp4parser.boxes.mp4.objectdescriptors.BitReaderBuffer; -import com.googlecode.mp4parser.boxes.mp4.objectdescriptors.BitWriterBuffer; - -import java.nio.ByteBuffer; - -public class AC3SpecificBox extends AbstractBox { - int fscod; - int bsid; - int bsmod; - int acmod; - int lfeon; - int bitRateCode; - int reserved; - - public AC3SpecificBox() { - super("dac3"); - } - - @Override - protected long getContentSize() { - return 3; - } - - @Override - public void _parseDetails(ByteBuffer content) { - BitReaderBuffer brb = new BitReaderBuffer(content); - fscod = brb.readBits(2); - bsid = brb.readBits(5); - bsmod = brb.readBits(3); - acmod = brb.readBits(3); - lfeon = brb.readBits(1); - bitRateCode = brb.readBits(5); - reserved = brb.readBits(5); - } - - @Override - protected void getContent(ByteBuffer byteBuffer) { - BitWriterBuffer bwb = new BitWriterBuffer(byteBuffer); - bwb.writeBits(fscod, 2); - bwb.writeBits(bsid, 5); - bwb.writeBits(bsmod, 3); - bwb.writeBits(acmod, 3); - bwb.writeBits(lfeon, 1); - bwb.writeBits(bitRateCode, 5); - bwb.writeBits(reserved, 5); - } - - public int getFscod() { - return fscod; - } - - public void setFscod(int fscod) { - this.fscod = fscod; - } - - public int getBsid() { - return bsid; - } - - public void setBsid(int bsid) { - this.bsid = bsid; - } - - public int getBsmod() { - return bsmod; - } - - public void setBsmod(int bsmod) { - this.bsmod = bsmod; - } - - public int getAcmod() { - return acmod; - } - - public void setAcmod(int acmod) { - this.acmod = acmod; - } - - public int getLfeon() { - return lfeon; - } - - public void setLfeon(int lfeon) { - this.lfeon = lfeon; - } - - public int getBitRateCode() { - return bitRateCode; - } - - public void setBitRateCode(int bitRateCode) { - this.bitRateCode = bitRateCode; - } - - public int getReserved() { - return reserved; - } - - public void setReserved(int reserved) { - this.reserved = reserved; - } - - @Override - public String toString() { - return "AC3SpecificBox{" + - "fscod=" + fscod + - ", bsid=" + bsid + - ", bsmod=" + bsmod + - ", acmod=" + acmod + - ", lfeon=" + lfeon + - ", bitRateCode=" + bitRateCode + - ", reserved=" + reserved + - '}'; - } -} diff --git a/android-aac-enc/src/main/java/com/googlecode/mp4parser/boxes/AbstractSampleEncryptionBox.java b/android-aac-enc/src/main/java/com/googlecode/mp4parser/boxes/AbstractSampleEncryptionBox.java deleted file mode 100644 index e4f9442fa..000000000 --- a/android-aac-enc/src/main/java/com/googlecode/mp4parser/boxes/AbstractSampleEncryptionBox.java +++ /dev/null @@ -1,303 +0,0 @@ -package com.googlecode.mp4parser.boxes; - -import com.coremedia.iso.Hex; -import com.coremedia.iso.IsoTypeReader; -import com.coremedia.iso.IsoTypeWriter; -import com.googlecode.mp4parser.AbstractFullBox; - -import java.io.IOException; -import java.math.BigInteger; -import java.nio.ByteBuffer; -import java.nio.channels.WritableByteChannel; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.LinkedList; -import java.util.List; - - -public abstract class AbstractSampleEncryptionBox extends AbstractFullBox { - int algorithmId = -1; - int ivSize = -1; - byte[] kid = new byte[16]; - List entries = new LinkedList(); - - protected AbstractSampleEncryptionBox(String type) { - super(type); - } - - public int getOffsetToFirstIV() { - int offset = (getSize() > (1l << 32) ? 16 : 8); - offset += isOverrideTrackEncryptionBoxParameters() ? 20 : 0; - offset += 4; //num entries - return offset; - } - - @Override - public void _parseDetails(ByteBuffer content) { - parseVersionAndFlags(content); - if ((getFlags() & 0x1) > 0) { - algorithmId = IsoTypeReader.readUInt24(content); - ivSize = IsoTypeReader.readUInt8(content); - kid = new byte[16]; - content.get(kid); - } - long numOfEntries = IsoTypeReader.readUInt32(content); - while (numOfEntries-- > 0) { - Entry e = new Entry(); - e.iv = new byte[((getFlags() & 0x1) > 0) ? ivSize : 8]; - content.get(e.iv); - if ((getFlags() & 0x2) > 0) { - int numOfPairs = IsoTypeReader.readUInt16(content); - e.pairs = new LinkedList(); - while (numOfPairs-- > 0) { - e.pairs.add(e.createPair(IsoTypeReader.readUInt16(content), IsoTypeReader.readUInt32(content))); - } - } - entries.add(e); - - } - } - - - public int getSampleCount() { - return entries.size(); - } - - public List getEntries() { - return entries; - } - - public void setEntries(List entries) { - this.entries = entries; - } - - public int getAlgorithmId() { - return algorithmId; - } - - public void setAlgorithmId(int algorithmId) { - this.algorithmId = algorithmId; - } - - public int getIvSize() { - return ivSize; - } - - public void setIvSize(int ivSize) { - this.ivSize = ivSize; - } - - public byte[] getKid() { - return kid; - } - - public void setKid(byte[] kid) { - this.kid = kid; - } - - - public boolean isSubSampleEncryption() { - return (getFlags() & 0x2) > 0; - } - - public boolean isOverrideTrackEncryptionBoxParameters() { - return (getFlags() & 0x1) > 0; - } - - public void setSubSampleEncryption(boolean b) { - if (b) { - setFlags(getFlags() | 0x2); - } else { - setFlags(getFlags() & (0xffffff ^ 0x2)); - } - } - - public void setOverrideTrackEncryptionBoxParameters(boolean b) { - if (b) { - setFlags(getFlags() | 0x1); - } else { - setFlags(getFlags() & (0xffffff ^ 0x1)); - } - } - - - @Override - protected void getContent(ByteBuffer byteBuffer) { - writeVersionAndFlags(byteBuffer); - if (isOverrideTrackEncryptionBoxParameters()) { - IsoTypeWriter.writeUInt24(byteBuffer, algorithmId); - IsoTypeWriter.writeUInt8(byteBuffer, ivSize); - byteBuffer.put(kid); - } - IsoTypeWriter.writeUInt32(byteBuffer, entries.size()); - for (Entry entry : entries) { - if (isOverrideTrackEncryptionBoxParameters()) { - byte[] ivFull = new byte[ivSize]; - System.arraycopy(entry.iv, 0, ivFull, ivSize - entry.iv.length, entry.iv.length); - byteBuffer.put(ivFull); - } else { - // just put the iv - i don't know any better - byteBuffer.put(entry.iv); - } - if (isSubSampleEncryption()) { - IsoTypeWriter.writeUInt16(byteBuffer, entry.pairs.size()); - for (Entry.Pair pair : entry.pairs) { - IsoTypeWriter.writeUInt16(byteBuffer, pair.clear); - IsoTypeWriter.writeUInt32(byteBuffer, pair.encrypted); - } - } - } - } - - @Override - protected long getContentSize() { - long contentSize = 4; - if (isOverrideTrackEncryptionBoxParameters()) { - contentSize += 4; - contentSize += kid.length; - } - contentSize += 4; - for (Entry entry : entries) { - contentSize += entry.getSize(); - } - return contentSize; - } - - @Override - public void getBox(WritableByteChannel os) throws IOException { - super.getBox(os); - } - - public Entry createEntry() { - return new Entry(); - } - - public class Entry { - public byte[] iv; - public List pairs = new LinkedList(); - - public int getSize() { - int size = 0; - if (isOverrideTrackEncryptionBoxParameters()) { - size = ivSize; - } else { - size = iv.length; - } - - - if (isSubSampleEncryption()) { - size += 2; - for (Entry.Pair pair : pairs) { - size += 6; - } - } - return size; - } - - public Pair createPair(int clear, long encrypted) { - return new Pair(clear, encrypted); - } - - - public class Pair { - public int clear; - public long encrypted; - - public Pair(int clear, long encrypted) { - this.clear = clear; - this.encrypted = encrypted; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - Pair pair = (Pair) o; - - if (clear != pair.clear) return false; - if (encrypted != pair.encrypted) return false; - - return true; - } - - @Override - public int hashCode() { - int result = clear; - result = 31 * result + (int) (encrypted ^ (encrypted >>> 32)); - return result; - } - - @Override - public String toString() { - return "clr:" + clear + " enc:" + encrypted; - } - } - - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - Entry entry = (Entry) o; - - if (!new BigInteger(iv).equals(new BigInteger(entry.iv))) return false; - if (pairs != null ? !pairs.equals(entry.pairs) : entry.pairs != null) return false; - - return true; - } - - @Override - public int hashCode() { - int result = iv != null ? Arrays.hashCode(iv) : 0; - result = 31 * result + (pairs != null ? pairs.hashCode() : 0); - return result; - } - - @Override - public String toString() { - return "Entry{" + - "iv=" + Hex.encodeHex(iv) + - ", pairs=" + pairs + - '}'; - } - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - AbstractSampleEncryptionBox that = (AbstractSampleEncryptionBox) o; - - if (algorithmId != that.algorithmId) return false; - if (ivSize != that.ivSize) return false; - if (entries != null ? !entries.equals(that.entries) : that.entries != null) return false; - if (!Arrays.equals(kid, that.kid)) return false; - - return true; - } - - @Override - public int hashCode() { - int result = algorithmId; - result = 31 * result + ivSize; - result = 31 * result + (kid != null ? Arrays.hashCode(kid) : 0); - result = 31 * result + (entries != null ? entries.hashCode() : 0); - return result; - } - - public List getEntrySizes() { - List entrySizes = new ArrayList(entries.size()); - for (Entry entry : entries) { - short size = (short) entry.iv.length; - if (isSubSampleEncryption()) { - size += 2; //numPairs - size += entry.pairs.size() * 6; - } - entrySizes.add(size); - } - return entrySizes; - } -} diff --git a/android-aac-enc/src/main/java/com/googlecode/mp4parser/boxes/AbstractTrackEncryptionBox.java b/android-aac-enc/src/main/java/com/googlecode/mp4parser/boxes/AbstractTrackEncryptionBox.java deleted file mode 100644 index fe35fdee9..000000000 --- a/android-aac-enc/src/main/java/com/googlecode/mp4parser/boxes/AbstractTrackEncryptionBox.java +++ /dev/null @@ -1,93 +0,0 @@ -package com.googlecode.mp4parser.boxes; - -import com.coremedia.iso.IsoTypeReader; -import com.coremedia.iso.IsoTypeWriter; -import com.googlecode.mp4parser.AbstractFullBox; - -import java.nio.ByteBuffer; -import java.nio.ByteOrder; -import java.util.Arrays; -import java.util.UUID; - -/** - * - */ -public abstract class AbstractTrackEncryptionBox extends AbstractFullBox { - int defaultAlgorithmId; - int defaultIvSize; - byte[] default_KID; - - protected AbstractTrackEncryptionBox(String type) { - super(type); - } - - public int getDefaultAlgorithmId() { - return defaultAlgorithmId; - } - - public void setDefaultAlgorithmId(int defaultAlgorithmId) { - this.defaultAlgorithmId = defaultAlgorithmId; - } - - public int getDefaultIvSize() { - return defaultIvSize; - } - - public void setDefaultIvSize(int defaultIvSize) { - this.defaultIvSize = defaultIvSize; - } - - public String getDefault_KID() { - ByteBuffer b = ByteBuffer.wrap(default_KID); - b.order(ByteOrder.BIG_ENDIAN); - return new UUID(b.getLong(), b.getLong()).toString(); - } - - public void setDefault_KID(byte[] default_KID) { - this.default_KID = default_KID; - } - - @Override - public void _parseDetails(ByteBuffer content) { - parseVersionAndFlags(content); - defaultAlgorithmId = IsoTypeReader.readUInt24(content); - defaultIvSize = IsoTypeReader.readUInt8(content); - default_KID = new byte[16]; - content.get(default_KID); - } - - @Override - protected void getContent(ByteBuffer byteBuffer) { - writeVersionAndFlags(byteBuffer); - IsoTypeWriter.writeUInt24(byteBuffer, defaultAlgorithmId); - IsoTypeWriter.writeUInt8(byteBuffer, defaultIvSize); - byteBuffer.put(default_KID); - } - - @Override - protected long getContentSize() { - return 24; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - AbstractTrackEncryptionBox that = (AbstractTrackEncryptionBox) o; - - if (defaultAlgorithmId != that.defaultAlgorithmId) return false; - if (defaultIvSize != that.defaultIvSize) return false; - if (!Arrays.equals(default_KID, that.default_KID)) return false; - - return true; - } - - @Override - public int hashCode() { - int result = defaultAlgorithmId; - result = 31 * result + defaultIvSize; - result = 31 * result + (default_KID != null ? Arrays.hashCode(default_KID) : 0); - return result; - } -} diff --git a/android-aac-enc/src/main/java/com/googlecode/mp4parser/boxes/DTSSpecificBox.java b/android-aac-enc/src/main/java/com/googlecode/mp4parser/boxes/DTSSpecificBox.java deleted file mode 100644 index a4cb34636..000000000 --- a/android-aac-enc/src/main/java/com/googlecode/mp4parser/boxes/DTSSpecificBox.java +++ /dev/null @@ -1,217 +0,0 @@ -package com.googlecode.mp4parser.boxes; - -import com.coremedia.iso.IsoTypeReader; -import com.coremedia.iso.IsoTypeWriter; -import com.googlecode.mp4parser.AbstractBox; -import com.googlecode.mp4parser.boxes.mp4.objectdescriptors.BitReaderBuffer; -import com.googlecode.mp4parser.boxes.mp4.objectdescriptors.BitWriterBuffer; - -import java.nio.ByteBuffer; - -/** - * Created by IntelliJ IDEA. - * User: magnus - * Date: 2012-03-09 - * Time: 16:11 - * To change this template use File | Settings | File Templates. - */ -public class DTSSpecificBox extends AbstractBox { - - long DTSSamplingFrequency; - long maxBitRate; - long avgBitRate; - int pcmSampleDepth; - int frameDuration; - int streamConstruction; - int coreLFEPresent; - int coreLayout; - int coreSize; - int stereoDownmix; - int representationType; - int channelLayout; - int multiAssetFlag; - int LBRDurationMod; - int reservedBoxPresent; - int reserved; - - public DTSSpecificBox() { - super("ddts"); - } - - @Override - protected long getContentSize() { - return 20; - } - - @Override - public void _parseDetails(ByteBuffer content) { - DTSSamplingFrequency = IsoTypeReader.readUInt32(content); - maxBitRate = IsoTypeReader.readUInt32(content); - avgBitRate = IsoTypeReader.readUInt32(content); - pcmSampleDepth = IsoTypeReader.readUInt8(content); - BitReaderBuffer brb = new BitReaderBuffer(content); - frameDuration = brb.readBits(2); - streamConstruction = brb.readBits(5); - coreLFEPresent = brb.readBits(1); - coreLayout = brb.readBits(6); - coreSize = brb.readBits(14); - stereoDownmix = brb.readBits(1); - representationType = brb.readBits(3); - channelLayout = brb.readBits(16); - multiAssetFlag = brb.readBits(1); - LBRDurationMod = brb.readBits(1); - reservedBoxPresent = brb.readBits(1); - reserved = brb.readBits(5); - - } - - @Override - protected void getContent(ByteBuffer byteBuffer) { - IsoTypeWriter.writeUInt32(byteBuffer, DTSSamplingFrequency); - IsoTypeWriter.writeUInt32(byteBuffer, maxBitRate); - IsoTypeWriter.writeUInt32(byteBuffer, avgBitRate); - IsoTypeWriter.writeUInt8(byteBuffer, pcmSampleDepth); - BitWriterBuffer bwb = new BitWriterBuffer(byteBuffer); - bwb.writeBits(frameDuration, 2); - bwb.writeBits(streamConstruction, 5); - bwb.writeBits(coreLFEPresent, 1); - bwb.writeBits(coreLayout, 6); - bwb.writeBits(coreSize, 14); - bwb.writeBits(stereoDownmix, 1); - bwb.writeBits(representationType, 3); - bwb.writeBits(channelLayout, 16); - bwb.writeBits(multiAssetFlag, 1); - bwb.writeBits(LBRDurationMod, 1); - bwb.writeBits(reservedBoxPresent, 1); - bwb.writeBits(reserved, 5); - - } - - public long getAvgBitRate() { - return avgBitRate; - } - - public void setAvgBitRate(long avgBitRate) { - this.avgBitRate = avgBitRate; - } - - public long getDTSSamplingFrequency() { - return DTSSamplingFrequency; - } - - public void setDTSSamplingFrequency(long DTSSamplingFrequency) { - this.DTSSamplingFrequency = DTSSamplingFrequency; - } - - public long getMaxBitRate() { - return maxBitRate; - } - - public void setMaxBitRate(long maxBitRate) { - this.maxBitRate = maxBitRate; - } - - public int getPcmSampleDepth() { - return pcmSampleDepth; - } - - public void setPcmSampleDepth(int pcmSampleDepth) { - this.pcmSampleDepth = pcmSampleDepth; - } - - public int getFrameDuration() { - return frameDuration; - } - - public void setFrameDuration(int frameDuration) { - this.frameDuration = frameDuration; - } - - public int getStreamConstruction() { - return streamConstruction; - } - - public void setStreamConstruction(int streamConstruction) { - this.streamConstruction = streamConstruction; - } - - public int getCoreLFEPresent() { - return coreLFEPresent; - } - - public void setCoreLFEPresent(int coreLFEPresent) { - this.coreLFEPresent = coreLFEPresent; - } - - public int getCoreLayout() { - return coreLayout; - } - - public void setCoreLayout(int coreLayout) { - this.coreLayout = coreLayout; - } - - public int getCoreSize() { - return coreSize; - } - - public void setCoreSize(int coreSize) { - this.coreSize = coreSize; - } - - public int getStereoDownmix() { - return stereoDownmix; - } - - public void setStereoDownmix(int stereoDownmix) { - this.stereoDownmix = stereoDownmix; - } - - public int getRepresentationType() { - return representationType; - } - - public void setRepresentationType(int representationType) { - this.representationType = representationType; - } - - public int getChannelLayout() { - return channelLayout; - } - - public void setChannelLayout(int channelLayout) { - this.channelLayout = channelLayout; - } - - public int getMultiAssetFlag() { - return multiAssetFlag; - } - - public void setMultiAssetFlag(int multiAssetFlag) { - this.multiAssetFlag = multiAssetFlag; - } - - public int getLBRDurationMod() { - return LBRDurationMod; - } - - public void setLBRDurationMod(int LBRDurationMod) { - this.LBRDurationMod = LBRDurationMod; - } - - public int getReserved() { - return reserved; - } - - public void setReserved(int reserved) { - this.reserved = reserved; - } - - public int getReservedBoxPresent() { - return reservedBoxPresent; - } - - public void setReservedBoxPresent(int reservedBoxPresent) { - this.reservedBoxPresent = reservedBoxPresent; - } -} diff --git a/android-aac-enc/src/main/java/com/googlecode/mp4parser/boxes/EC3SpecificBox.java b/android-aac-enc/src/main/java/com/googlecode/mp4parser/boxes/EC3SpecificBox.java deleted file mode 100644 index 9fd5e28d0..000000000 --- a/android-aac-enc/src/main/java/com/googlecode/mp4parser/boxes/EC3SpecificBox.java +++ /dev/null @@ -1,139 +0,0 @@ -package com.googlecode.mp4parser.boxes; - -import com.googlecode.mp4parser.AbstractBox; -import com.googlecode.mp4parser.boxes.mp4.objectdescriptors.BitReaderBuffer; -import com.googlecode.mp4parser.boxes.mp4.objectdescriptors.BitWriterBuffer; - -import java.nio.ByteBuffer; -import java.util.LinkedList; -import java.util.List; - -/** - * - */ -public class EC3SpecificBox extends AbstractBox { - List entries = new LinkedList(); - int dataRate; - int numIndSub; - public EC3SpecificBox() { - super("dec3"); - } - - @Override - protected long getContentSize() { - long size = 2; - for (Entry entry : entries) { - if (entry.num_dep_sub > 0) { - size += 4; - } else { - size += 3; - } - } - return size; - } - - @Override - public void _parseDetails(ByteBuffer content) { - BitReaderBuffer brb = new BitReaderBuffer(content); - dataRate = brb.readBits(13); - numIndSub = brb.readBits(3) + 1; - // This field indicates the number of independent substreams that are present in the Enhanced AC-3 bitstream. The value - // of this field is one less than the number of independent substreams present. - - - for (int i = 0; i < numIndSub; i++) { - Entry e = new Entry(); - e.fscod = brb.readBits(2); - e.bsid = brb.readBits(5); - e.bsmod = brb.readBits(5); - e.acmod = brb.readBits(3); - e.lfeon = brb.readBits(1); - e.reserved = brb.readBits(3); - e.num_dep_sub = brb.readBits(4); - if (e.num_dep_sub > 0) { - e.chan_loc = brb.readBits(9); - } else { - e.reserved2 = brb.readBits(1); - } - entries.add(e); - } - } - - @Override - protected void getContent(ByteBuffer byteBuffer) { - BitWriterBuffer bwb = new BitWriterBuffer(byteBuffer); - bwb.writeBits(dataRate, 13); - bwb.writeBits(entries.size() - 1, 3); - for (Entry e : entries) { - bwb.writeBits(e.fscod, 2); - bwb.writeBits(e.bsid, 5); - bwb.writeBits(e.bsmod, 5); - bwb.writeBits(e.acmod, 3); - bwb.writeBits(e.lfeon, 1); - bwb.writeBits(e.reserved, 3); - bwb.writeBits(e.num_dep_sub, 4); - if (e.num_dep_sub > 0) { - bwb.writeBits(e.chan_loc, 9); - } else { - bwb.writeBits(e.reserved2, 1); - } - } - } - - - public List getEntries() { - return entries; - } - - public void setEntries(List entries) { - this.entries = entries; - } - - public void addEntry(Entry entry) { - this.entries.add(entry); - } - - public int getDataRate() { - return dataRate; - } - - public void setDataRate(int dataRate) { - this.dataRate = dataRate; - } - - public int getNumIndSub() { - return numIndSub; - } - - public void setNumIndSub(int numIndSub) { - this.numIndSub = numIndSub; - } - - public static class Entry { - public int fscod; - public int bsid; - public int bsmod; - public int acmod; - public int lfeon; - public int reserved; - public int num_dep_sub; - public int chan_loc; - public int reserved2; - - - @Override - public String toString() { - return "Entry{" + - "fscod=" + fscod + - ", bsid=" + bsid + - ", bsmod=" + bsmod + - ", acmod=" + acmod + - ", lfeon=" + lfeon + - ", reserved=" + reserved + - ", num_dep_sub=" + num_dep_sub + - ", chan_loc=" + chan_loc + - ", reserved2=" + reserved2 + - '}'; - } - } -} diff --git a/android-aac-enc/src/main/java/com/googlecode/mp4parser/boxes/MLPSpecificBox.java b/android-aac-enc/src/main/java/com/googlecode/mp4parser/boxes/MLPSpecificBox.java deleted file mode 100644 index fe6f0d885..000000000 --- a/android-aac-enc/src/main/java/com/googlecode/mp4parser/boxes/MLPSpecificBox.java +++ /dev/null @@ -1,76 +0,0 @@ -package com.googlecode.mp4parser.boxes; - -import com.googlecode.mp4parser.AbstractBox; -import com.googlecode.mp4parser.boxes.mp4.objectdescriptors.BitReaderBuffer; -import com.googlecode.mp4parser.boxes.mp4.objectdescriptors.BitWriterBuffer; - -import java.nio.ByteBuffer; - - -public class MLPSpecificBox extends AbstractBox { - - int format_info; - int peak_data_rate; - int reserved; - int reserved2; - - public MLPSpecificBox() { - super("dmlp"); - } - - @Override - protected long getContentSize() { - return 10; - } - - @Override - public void _parseDetails(ByteBuffer content) { - BitReaderBuffer brb = new BitReaderBuffer(content); - format_info = brb.readBits(32); - peak_data_rate = brb.readBits(15); - reserved = brb.readBits(1); - reserved2 = brb.readBits(32); - } - - @Override - protected void getContent(ByteBuffer byteBuffer) { - BitWriterBuffer bwb = new BitWriterBuffer(byteBuffer); - bwb.writeBits(format_info, 32); - bwb.writeBits(peak_data_rate, 15); - bwb.writeBits(reserved, 1); - bwb.writeBits(reserved2, 32); - //To change body of implemented methods use File | Settings | File Templates. - } - - public int getFormat_info() { - return format_info; - } - - public void setFormat_info(int format_info) { - this.format_info = format_info; - } - - public int getPeak_data_rate() { - return peak_data_rate; - } - - public void setPeak_data_rate(int peak_data_rate) { - this.peak_data_rate = peak_data_rate; - } - - public int getReserved() { - return reserved; - } - - public void setReserved(int reserved) { - this.reserved = reserved; - } - - public int getReserved2() { - return reserved2; - } - - public void setReserved2(int reserved2) { - this.reserved2 = reserved2; - } -} diff --git a/android-aac-enc/src/main/java/com/googlecode/mp4parser/boxes/adobe/ActionMessageFormat0SampleEntryBox.java b/android-aac-enc/src/main/java/com/googlecode/mp4parser/boxes/adobe/ActionMessageFormat0SampleEntryBox.java deleted file mode 100644 index 483dd8fd0..000000000 --- a/android-aac-enc/src/main/java/com/googlecode/mp4parser/boxes/adobe/ActionMessageFormat0SampleEntryBox.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.googlecode.mp4parser.boxes.adobe; - -import com.coremedia.iso.boxes.Box; -import com.coremedia.iso.boxes.sampleentry.SampleEntry; - -import java.nio.ByteBuffer; - -/** - * Sample Entry as used for Action Message Format tracks. - */ -public class ActionMessageFormat0SampleEntryBox extends SampleEntry { - public ActionMessageFormat0SampleEntryBox() { - super("amf0"); - } - - @Override - protected long getContentSize() { - long size = 8; - for (Box box : boxes) { - size += box.getSize(); - } - - return size; - } - - - @Override - public void _parseDetails(ByteBuffer content) { - _parseReservedAndDataReferenceIndex(content); - _parseChildBoxes(content); - } - - @Override - protected void getContent(ByteBuffer byteBuffer) { - _writeReservedAndDataReferenceIndex(byteBuffer); - _writeChildBoxes(byteBuffer); - } -} diff --git a/android-aac-enc/src/main/java/com/googlecode/mp4parser/boxes/apple/TimeCodeBox.java b/android-aac-enc/src/main/java/com/googlecode/mp4parser/boxes/apple/TimeCodeBox.java deleted file mode 100644 index b55c92747..000000000 --- a/android-aac-enc/src/main/java/com/googlecode/mp4parser/boxes/apple/TimeCodeBox.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.googlecode.mp4parser.boxes.apple; - -import com.coremedia.iso.boxes.Box; -import com.coremedia.iso.boxes.sampleentry.SampleEntry; - -import java.nio.ByteBuffer; - -public class TimeCodeBox extends SampleEntry { - byte[] data; - - - public TimeCodeBox() { - super("tmcd"); - } - - @Override - protected long getContentSize() { - long size = 26; - for (Box box : boxes) { - size += box.getSize(); - } - return size; - } - - @Override - public void _parseDetails(ByteBuffer content) { - _parseReservedAndDataReferenceIndex(content); - data = new byte[18]; - content.get(data); - _parseChildBoxes(content); - } - - @Override - protected void getContent(ByteBuffer byteBuffer) { - _writeReservedAndDataReferenceIndex(byteBuffer); - byteBuffer.put(data); - _writeChildBoxes(byteBuffer); - } -} diff --git a/android-aac-enc/src/main/java/com/googlecode/mp4parser/boxes/basemediaformat/AvcNalUnitStorageBox.java b/android-aac-enc/src/main/java/com/googlecode/mp4parser/boxes/basemediaformat/AvcNalUnitStorageBox.java deleted file mode 100644 index 45a54958a..000000000 --- a/android-aac-enc/src/main/java/com/googlecode/mp4parser/boxes/basemediaformat/AvcNalUnitStorageBox.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright 2011 castLabs, Berlin - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.googlecode.mp4parser.boxes.basemediaformat; - -import com.googlecode.mp4parser.AbstractBox; -import com.coremedia.iso.boxes.h264.AvcConfigurationBox; - -import java.io.ByteArrayOutputStream; -import java.nio.ByteBuffer; -import java.util.Arrays; - -import static com.googlecode.mp4parser.util.CastUtils.l2i; - -/** - * The AVC NAL Unit Storage Box SHALL contain an AVCDecoderConfigurationRecord, - * as defined in section 5.2.4.1 of the ISO 14496-12. - */ -public class AvcNalUnitStorageBox extends AbstractBox { - byte[] data; - - public AvcNalUnitStorageBox() { - super("avcn"); - } - - - public AvcNalUnitStorageBox(AvcConfigurationBox avcConfigurationBox) { - super("avcn"); - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - - ByteBuffer content = ByteBuffer.allocate(l2i(avcConfigurationBox.getContentSize())); - avcConfigurationBox.getContent(content); - data = content.array(); - } - - @Override - protected long getContentSize() { - return data.length; - } - - - public void setData(byte[] data) { - this.data = data; - } - - @Override - public void _parseDetails(ByteBuffer content) { - data = new byte[content.remaining()]; - } - - @Override - protected void getContent(ByteBuffer byteBuffer) { - byteBuffer.put(data); - } - - @Override - public String toString() { - return "AvcNalUnitStorageBox{" + - "data=" + Arrays.toString(data) + - '}'; - } -} diff --git a/android-aac-enc/src/main/java/com/googlecode/mp4parser/boxes/basemediaformat/SampleEncryptionBox.java b/android-aac-enc/src/main/java/com/googlecode/mp4parser/boxes/basemediaformat/SampleEncryptionBox.java deleted file mode 100644 index 3430818b4..000000000 --- a/android-aac-enc/src/main/java/com/googlecode/mp4parser/boxes/basemediaformat/SampleEncryptionBox.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.googlecode.mp4parser.boxes.basemediaformat; - -import com.googlecode.mp4parser.boxes.AbstractSampleEncryptionBox; - -/** - * aligned(8) class AbstractSampleEncryptionBox extends FullBox(‘uuid’, extended_type= 0xA2394F52-5A9B-4f14-A244-6C427C648DF4, version=0, flags=0) - * { - *

    - * unsigned int (32) sample_count; - * { - * unsigned int(16) InitializationVector; - * }[ sample_count ] - * } - */ -public class SampleEncryptionBox extends AbstractSampleEncryptionBox { - - /** - * Creates a SampleEncryptionBox for non-h264 tracks. - */ - public SampleEncryptionBox() { - super("senc"); - - } -} diff --git a/android-aac-enc/src/main/java/com/googlecode/mp4parser/boxes/basemediaformat/TrackEncryptionBox.java b/android-aac-enc/src/main/java/com/googlecode/mp4parser/boxes/basemediaformat/TrackEncryptionBox.java deleted file mode 100644 index dd93a12df..000000000 --- a/android-aac-enc/src/main/java/com/googlecode/mp4parser/boxes/basemediaformat/TrackEncryptionBox.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.googlecode.mp4parser.boxes.basemediaformat; - -import com.googlecode.mp4parser.boxes.AbstractTrackEncryptionBox; - -/** - * - */ -public class TrackEncryptionBox extends AbstractTrackEncryptionBox { - public TrackEncryptionBox() { - super("tenc"); - } -} diff --git a/android-aac-enc/src/main/java/com/googlecode/mp4parser/boxes/mp4-boxes.zip b/android-aac-enc/src/main/java/com/googlecode/mp4parser/boxes/mp4-boxes.zip deleted file mode 100644 index c9bcf8b94..000000000 Binary files a/android-aac-enc/src/main/java/com/googlecode/mp4parser/boxes/mp4-boxes.zip and /dev/null differ diff --git a/android-aac-enc/src/main/java/com/googlecode/mp4parser/boxes/mp4/AbstractDescriptorBox.java b/android-aac-enc/src/main/java/com/googlecode/mp4parser/boxes/mp4/AbstractDescriptorBox.java deleted file mode 100644 index 7d614e263..000000000 --- a/android-aac-enc/src/main/java/com/googlecode/mp4parser/boxes/mp4/AbstractDescriptorBox.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright 2011 castLabs, Berlin - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.googlecode.mp4parser.boxes.mp4; - -import com.googlecode.mp4parser.AbstractFullBox; -import com.googlecode.mp4parser.boxes.mp4.objectdescriptors.BaseDescriptor; -import com.googlecode.mp4parser.boxes.mp4.objectdescriptors.ObjectDescriptorFactory; - -import java.io.IOException; -import java.nio.ByteBuffer; -import java.util.logging.Level; -import java.util.logging.Logger; - -/** - * ES Descriptor Box. - */ -public class AbstractDescriptorBox extends AbstractFullBox { - private static Logger log = Logger.getLogger(AbstractDescriptorBox.class.getName()); - - - public BaseDescriptor descriptor; - public ByteBuffer data; - - public AbstractDescriptorBox(String type) { - super(type); - } - - @Override - protected void getContent(ByteBuffer byteBuffer) { - writeVersionAndFlags(byteBuffer); - data.rewind(); // has been fforwarded by parsing - byteBuffer.put(data); - } - - @Override - protected long getContentSize() { - return 4 + data.limit(); - } - - public BaseDescriptor getDescriptor() { - return descriptor; - } - - public String getDescriptorAsString() { - return descriptor.toString(); - } - - public void setData(ByteBuffer data) { - this.data = data; - } - - @Override - public void _parseDetails(ByteBuffer content) { - parseVersionAndFlags(content); - data = content.slice(); - content.position(content.position() + content.remaining()); - try { - data.rewind(); - descriptor = ObjectDescriptorFactory.createFrom(-1, data); - } catch (IOException e) { - log.log(Level.WARNING, "Error parsing ObjectDescriptor", e); - //that's why we copied it ;) - } catch (IndexOutOfBoundsException e) { - log.log(Level.WARNING, "Error parsing ObjectDescriptor", e); - //that's why we copied it ;) - } - - } - -} diff --git a/android-aac-enc/src/main/java/com/googlecode/mp4parser/boxes/mp4/ESDescriptorBox.java b/android-aac-enc/src/main/java/com/googlecode/mp4parser/boxes/mp4/ESDescriptorBox.java deleted file mode 100644 index 5d9d59175..000000000 --- a/android-aac-enc/src/main/java/com/googlecode/mp4parser/boxes/mp4/ESDescriptorBox.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2011 castLabs, Berlin - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.googlecode.mp4parser.boxes.mp4; - -import com.googlecode.mp4parser.boxes.mp4.objectdescriptors.ESDescriptor; - -/** - * ES Descriptor Box. - */ -public class ESDescriptorBox extends AbstractDescriptorBox { - public static final String TYPE = "esds"; - - public ESDescriptorBox() { - super(TYPE); - } - - public ESDescriptor getEsDescriptor() { - return (ESDescriptor) super.getDescriptor(); - } - - -} diff --git a/android-aac-enc/src/main/java/com/googlecode/mp4parser/boxes/mp4/ObjectDescriptorBox.java b/android-aac-enc/src/main/java/com/googlecode/mp4parser/boxes/mp4/ObjectDescriptorBox.java deleted file mode 100644 index c9e7493fe..000000000 --- a/android-aac-enc/src/main/java/com/googlecode/mp4parser/boxes/mp4/ObjectDescriptorBox.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright 2011 Sebastian Annies, Hamburg - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.googlecode.mp4parser.boxes.mp4; - -/** - * This object contains an Object Descriptor or an Initial Object Descriptor. - * There are a number of possible file types based on usage, depending on the descriptor: - *

      - *
    • Presentation, contains IOD which contains a BIFS stream (MP4 file); - *
    • Sub-part of a presentation, contains an IOD without a BIFS stream (MP4 file);
    • - *
    • Sub-part of a presentation, contains an OD (MP4 file);
    • - *
    • Free-form file, referenced by MP4 data references (free-format);
    • - *
    • Sub-part of a presentation, referenced by an ES URL.
    • - *
    - * NOTE:
    - * The first three are MP4 files, a file referenced by a data reference is not necessarily an MP4 file, as it is - * free-format. Files referenced by ES URLs, by data references, or intended as input to an editing process, need not have - * an Object Descriptor Box.
    - * An OD URL may point to an MP4 file. Implicitly, the target of such a URL is the OD/IOD located in the 'iods' - * atom in that file.
    - * If an MP4 file contains several object descriptors, only the OD/IOD in the 'iods' atom can be addressed using - * an OD URL from a remote MPEG-4 presentation. - */ -public class ObjectDescriptorBox extends AbstractDescriptorBox { - public static final String TYPE = "iods"; - - public ObjectDescriptorBox() { - super(TYPE); - } - - -} diff --git a/android-aac-enc/src/main/java/com/googlecode/mp4parser/boxes/mp4/objectdescriptors/AudioSpecificConfig.java b/android-aac-enc/src/main/java/com/googlecode/mp4parser/boxes/mp4/objectdescriptors/AudioSpecificConfig.java deleted file mode 100644 index 08f0817f8..000000000 --- a/android-aac-enc/src/main/java/com/googlecode/mp4parser/boxes/mp4/objectdescriptors/AudioSpecificConfig.java +++ /dev/null @@ -1,979 +0,0 @@ -/* - * Copyright 2011 castLabs, Berlin - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.googlecode.mp4parser.boxes.mp4.objectdescriptors; - -import com.coremedia.iso.IsoTypeWriter; - -import java.io.IOException; -import java.nio.ByteBuffer; -import java.util.HashMap; -import java.util.Map; - - -// -//GetAudioObjectType() -//{ -//audioObjectType; 5 uimsbf -//if (audioObjectType == 31) { -//audioObjectType = 32 + audioObjectTypeExt; 6 uimsbf -//} -//return audioObjectType; -//} -//AudioSpecificConfig () -//{ -//audioObjectType = GetAudioObjectType(); -//samplingFrequencyIndex; 4 bslbf -//if ( samplingFrequencyIndex == 0xf ) { -//samplingFrequency; 24 uimsbf -//} -//channelConfiguration; 4 bslbf -//sbrPresentFlag = -1; -//psPresentFlag = -1; -//if ( audioObjectType == 5 || -//audioObjectType == 29 ) { -//extensionAudioObjectType = 5; -//sbrPresentFlag = 1; -//if ( audioObjectType == 29 ) { -//psPresentFlag = 1; -//} -//extensionSamplingFrequencyIndex; 4 uimsbf -//if ( extensionSamplingFrequencyIndex == 0xf ) -//extensionSamplingFrequency; 24 uimsbf -//audioObjectType = GetAudioObjectType(); -//if ( audioObjectType == 22 ) -//extensionChannelConfiguration; 4 uimsbf -//} -//else { -//extensionAudioObjectType = 0; -//} -//switch (audioObjectType) { -//case 1: -//case 2: -//case 3: -//case 4: -//case 6: -//case 7: -//case 17: -//case 19: -//case 20: -//case 21: -//case 22: -//case 23: -//GASpecificConfig(); -//break: -//case 8: -//CelpSpecificConfig(); -//break; -//case 9: -//HvxcSpecificConfig(); -//break: -//case 12: -//TTSSpecificConfig(); -//break; -//case 13: -//case 14: -//case 15: -//case 16: -//StructuredAudioSpecificConfig(); -//break; -//case 24: -//ErrorResilientCelpSpecificConfig(); -//break; -//case 25: -//ErrorResilientHvxcSpecificConfig(); -//break; -//case 26: -//case 27: -//ParametricSpecificConfig(); -//break; -// case 28: -//SSCSpecificConfig(); -//break; -//case 30: -//sacPayloadEmbedding; 1 uimsbf -//SpatialSpecificConfig(); -//break; -//case 32: -//case 33: -//case 34: -//MPEG_1_2_SpecificConfig(); -//break; -//case 35: -//DSTSpecificConfig(); -//break; -//case 36: -//fillBits; 5 bslbf -//ALSSpecificConfig(); -//break; -//case 37: -//case 38: -//SLSSpecificConfig(); -//break; -//case 39: -//ELDSpecificConfig(channelConfiguration); -//break: -//case 40: -//case 41: -//SymbolicMusicSpecificConfig(); -//break; -//default: -///* reserved */ -//} -//switch (audioObjectType) { -//case 17: -//case 19: -//case 20: -//case 21: -//case 22: -//case 23: -//case 24: -//case 25: -//case 26: -//case 27: -//case 39: -//epConfig; 2 bslbf -//if ( epConfig == 2 || epConfig == 3 ) { -//ErrorProtectionSpecificConfig(); -//} -//if ( epConfig == 3 ) { -//directMapping; 1 bslbf -//if ( ! directMapping ) { -///* tbd */ -//} -//} -//} -//if ( extensionAudioObjectType != 5 && bits_to_decode() >= 16 ) { -//syncExtensionType; 11 bslbf -//if (syncExtensionType == 0x2b7) { -// extensionAudioObjectType = GetAudioObjectType(); -//if ( extensionAudioObjectType == 5 ) { -//sbrPresentFlag; 1 uimsbf -//if (sbrPresentFlag == 1) { -//extensionSamplingFrequencyIndex; 4 uimsbf -//if ( extensionSamplingFrequencyIndex == 0xf ) { -//extensionSamplingFrequency; 24 uimsbf -//} -//if ( bits_to_decode() >= 12 ) { -//syncExtensionType; 11 bslbf -//if (syncExtesionType == 0x548) { -//psPresentFlag; 1 uimsbf -//} -//} -//} -//} -//if ( extensionAudioObjectType == 22 ) { -//sbrPresentFlag; 1 uimsbf -//if (sbrPresentFlag == 1) { -//extensionSamplingFrequencyIndex; 4 uimsbf -//if ( extensionSamplingFrequencyIndex == 0xf ) { -//extensionSamplingFrequency; 24 uimsbf -//} -//} -//extensionChannelConfiguration; 4 uimsbf -//} -//} -//} -//} -// } -// -// TFCodingType -//0x0 AAC scaleable -//0x1 BSAC -//0x2 TwinVQ -//0x3 AAC non scaleable (i.e. multichannel) -// -// class TFSpecificConfig( uint(4) samplingFrequencyIndex, uint(4) channelConfiguration ) { -//uint(2) TFCodingType; -//uint(1) frameLength; -//uint(1) dependsOnCoreCoder; -//if (dependsOnCoreCoder == 1){ -//uint(14)coreCoderDelay -//} -//if (TFCodingType==BSAC) { -//uint(11) lslayer_length -//} -//uint (1) extensionFlag; -//if (channelConfiguration == 0 ){ -//program_config_element(); -//} -//if (extensionFlag==1){ -// -//} -//} -// -//program_config_element() -//{ -//element_instance_tag 4 uimsbf -//profile 2 uimsbf -//sampling_frequency_index 4 uimsbf -//num_front_channel_elements 4 uimsbf -//num_side_channel_elements 4 uimsbf -//num_back_channel_elements 4 uimsbf -// num_lfe_channel_elements 2 uimsbf -//num_assoc_data_elements 3 uimsbf -//num_valid_cc_elements 4 uimsbf -//mono_mixdown_present 1 uimsbf -//if ( mono_mixdown_present == 1 ) -//mono_mixdown_element_number 4 uimsbf -//stereo_mixdown_present 1 uimsbf -//if ( stereo_mixdown_present == 1 ) -//stereo_mixdown_element_number 4 uimsbf -//matrix_mixdown_idx_present 1 uimsbf -//if ( matrix_mixdown_idx_present == 1 ) { -//matrix_mixdown_idx 2 uimsbf -//pseudo_surround_enable 1 uimsbf -//} -//for ( i = 0; i < num_front_channel_elements; i++) { -//front_element_is_cpe[i]; 1 bslbf -//front_element_tag_select[i]; 4 uimsbf -//} -//for ( i = 0; i < num_side_channel_elements; i++) { -//side_element_is_cpe[i]; 1 bslbf -//side_element_tag_select[i]; 4 uimsbf -//} -//for ( i = 0; i < num_back_channel_elements; i++) { -//back_element_is_cpe[i]; 1 bslbf -//back_element_tag_select[i]; 4 uimsbf -//} -//for ( i = 0; i < num_lfe_channel_elements; i++) -//lfe_element_tag_select[i]; 4 uimsbf -//for ( i = 0; i < num_assoc_data_elements; i++) -//assoc_data_element_tag_select[i]; 4 uimsbf -//for ( i = 0; i < num_valid_cc_elements; i++) { -//cc_element_is_ind_sw[i]; 1 uimsbf -//valid_cc_element_tag_select[i]; 4 uimsbf -//} -//byte_alignment() -//comment_field_bytes 8 uimsbf -//for ( i = 0; i < comment_field_bytes; i++) -//comment_field_data[i]; 8 uimsbf -//} - -@Descriptor(tags = 0x5, objectTypeIndication = 0x40) -public class AudioSpecificConfig extends BaseDescriptor { - ByteBuffer configBytes; - long endPos; - - public static Map samplingFrequencyIndexMap = new HashMap(); - public static Map audioObjectTypeMap = new HashMap(); - int audioObjectType; - int samplingFrequencyIndex; - int samplingFrequency; - int channelConfiguration; - int extensionAudioObjectType; - int sbrPresentFlag; - int psPresentFlag; - int extensionSamplingFrequencyIndex; - int extensionSamplingFrequency; - int extensionChannelConfiguration; - int sacPayloadEmbedding; - int fillBits; - int epConfig; - int directMapping; - int syncExtensionType; - - //GASpecificConfig - int frameLengthFlag; - int dependsOnCoreCoder; - int coreCoderDelay; - int extensionFlag; - int layerNr; - int numOfSubFrame; - int layer_length; - int aacSectionDataResilienceFlag; - int aacScalefactorDataResilienceFlag; - int aacSpectralDataResilienceFlag; - int extensionFlag3; - boolean gaSpecificConfig; - - //ParametricSpecificConfig - int isBaseLayer; - int paraMode; - int paraExtensionFlag; - int hvxcVarMode; - int hvxcRateMode; - int erHvxcExtensionFlag; - int var_ScalableFlag; - int hilnQuantMode; - int hilnMaxNumLine; - int hilnSampleRateCode; - int hilnFrameLength; - int hilnContMode; - int hilnEnhaLayer; - int hilnEnhaQuantMode; - boolean parametricSpecificConfig; - - @Override - public void parseDetail(ByteBuffer bb) throws IOException { - configBytes = bb.slice(); - configBytes.limit(sizeOfInstance); - bb.position(bb.position() + sizeOfInstance); - - - BitReaderBuffer bitReaderBuffer = new BitReaderBuffer(configBytes); - audioObjectType = getAudioObjectType(bitReaderBuffer); - samplingFrequencyIndex = bitReaderBuffer.readBits(4); - - if (samplingFrequencyIndex == 0xf) { - samplingFrequency = bitReaderBuffer.readBits(24); - } - - channelConfiguration = bitReaderBuffer.readBits(4); - - if (audioObjectType == 5 || - audioObjectType == 29) { - extensionAudioObjectType = 5; - sbrPresentFlag = 1; - if (audioObjectType == 29) { - psPresentFlag = 1; - } - extensionSamplingFrequencyIndex = bitReaderBuffer.readBits(4); - if (extensionSamplingFrequencyIndex == 0xf) - extensionSamplingFrequency = bitReaderBuffer.readBits(24); - audioObjectType = getAudioObjectType(bitReaderBuffer); - if (audioObjectType == 22) - extensionChannelConfiguration = bitReaderBuffer.readBits(4); - } else { - extensionAudioObjectType = 0; - } - - switch (audioObjectType) { - case 1: - case 2: - case 3: - case 4: - case 6: - case 7: - case 17: - case 19: - case 20: - case 21: - case 22: - case 23: - parseGaSpecificConfig(samplingFrequencyIndex, channelConfiguration, audioObjectType, bitReaderBuffer); - //GASpecificConfig(); - break; - case 8: - throw new UnsupportedOperationException("can't parse CelpSpecificConfig yet"); - //CelpSpecificConfig(); - //break; - case 9: - throw new UnsupportedOperationException("can't parse HvxcSpecificConfig yet"); - //HvxcSpecificConfig(); - //break; - case 12: - throw new UnsupportedOperationException("can't parse TTSSpecificConfig yet"); - //TTSSpecificConfig(); - //break; - case 13: - case 14: - case 15: - case 16: - throw new UnsupportedOperationException("can't parse StructuredAudioSpecificConfig yet"); - //StructuredAudioSpecificConfig(); - //break; - case 24: - throw new UnsupportedOperationException("can't parse ErrorResilientCelpSpecificConfig yet"); - //ErrorResilientCelpSpecificConfig(); - //break; - case 25: - throw new UnsupportedOperationException("can't parse ErrorResilientHvxcSpecificConfig yet"); - //ErrorResilientHvxcSpecificConfig(); - //break; - case 26: - case 27: - parseParametricSpecificConfig(samplingFrequencyIndex, channelConfiguration, audioObjectType, bitReaderBuffer); - //ParametricSpecificConfig(); - break; - case 28: - throw new UnsupportedOperationException("can't parse SSCSpecificConfig yet"); - //SSCSpecificConfig(); - //break; - case 30: - sacPayloadEmbedding = bitReaderBuffer.readBits(1); - throw new UnsupportedOperationException("can't parse SpatialSpecificConfig yet"); - //SpatialSpecificConfig(); - //break; - case 32: - case 33: - case 34: - throw new UnsupportedOperationException("can't parse MPEG_1_2_SpecificConfig yet"); - //MPEG_1_2_SpecificConfig(); - //break; - case 35: - throw new UnsupportedOperationException("can't parse DSTSpecificConfig yet"); - //DSTSpecificConfig(); - //break; - case 36: - fillBits = bitReaderBuffer.readBits(5); - throw new UnsupportedOperationException("can't parse ALSSpecificConfig yet"); - //ALSSpecificConfig(); - //break; - case 37: - case 38: - throw new UnsupportedOperationException("can't parse SLSSpecificConfig yet"); - //SLSSpecificConfig(); - //break; - case 39: - throw new UnsupportedOperationException("can't parse ELDSpecificConfig yet"); - //ELDSpecificConfig(channelConfiguration); - //break; - case 40: - case 41: - throw new UnsupportedOperationException("can't parse SymbolicMusicSpecificConfig yet"); - //SymbolicMusicSpecificConfig(); - //break; - default: - /* reserved */ - } - - switch (audioObjectType) { - case 17: - case 19: - case 20: - case 21: - case 22: - case 23: - case 24: - case 25: - case 26: - case 27: - case 39: - epConfig = bitReaderBuffer.readBits(2); - if (epConfig == 2 || epConfig == 3) { - throw new UnsupportedOperationException("can't parse ErrorProtectionSpecificConfig yet"); - //ErrorProtectionSpecificConfig(); - } - if (epConfig == 3) { - directMapping = bitReaderBuffer.readBits(1); - if (directMapping == 0) { - /* tbd */ - throw new RuntimeException("not implemented"); - } - } - } - - if (extensionAudioObjectType != 5 && bitReaderBuffer.remainingBits() >= 16) { - syncExtensionType = bitReaderBuffer.readBits(11); - if (syncExtensionType == 0x2b7) { - extensionAudioObjectType = getAudioObjectType(bitReaderBuffer); - if (extensionAudioObjectType == 5) { - sbrPresentFlag = bitReaderBuffer.readBits(1); - if (sbrPresentFlag == 1) { - extensionSamplingFrequencyIndex = bitReaderBuffer.readBits(4); - if (extensionSamplingFrequencyIndex == 0xf) { - extensionSamplingFrequency = bitReaderBuffer.readBits(24); - } - if (bitReaderBuffer.remainingBits() >= 12) { - syncExtensionType = bitReaderBuffer.readBits(11); //10101001000 - if (syncExtensionType == 0x548) { - psPresentFlag = bitReaderBuffer.readBits(1); - } - } - } - } - if (extensionAudioObjectType == 22) { - sbrPresentFlag = bitReaderBuffer.readBits(1); - if (sbrPresentFlag == 1) { - extensionSamplingFrequencyIndex = bitReaderBuffer.readBits(4); - if (extensionSamplingFrequencyIndex == 0xf) { - extensionSamplingFrequency = bitReaderBuffer.readBits(24); - } - } - extensionChannelConfiguration = bitReaderBuffer.readBits(4); - } - } - } - } - - private int gaSpecificConfigSize() { - return 0; - } - - public int serializedSize() { - int out = 4; - if (audioObjectType == 2) { - out += gaSpecificConfigSize(); - } else { - throw new UnsupportedOperationException("can't serialize that yet"); - } - return out; - } - - public ByteBuffer serialize() { - ByteBuffer out = ByteBuffer.allocate(serializedSize()); - IsoTypeWriter.writeUInt8(out, 5); - IsoTypeWriter.writeUInt8(out, serializedSize() - 2); - BitWriterBuffer bwb = new BitWriterBuffer(out); - bwb.writeBits(audioObjectType, 5); - bwb.writeBits(samplingFrequencyIndex, 4); - if (samplingFrequencyIndex == 0xf) { - throw new UnsupportedOperationException("can't serialize that yet"); - } - bwb.writeBits(channelConfiguration, 4); - - // Don't support any extensions, unusual GASpecificConfig other than the default or anything... - - return out; - } - - private int getAudioObjectType(BitReaderBuffer in) throws IOException { - int audioObjectType = in.readBits(5); - if (audioObjectType == 31) { - audioObjectType = 32 + in.readBits(6); - } - return audioObjectType; - } - - private void parseGaSpecificConfig(int samplingFrequencyIndex, int channelConfiguration, int audioObjectType, BitReaderBuffer in) throws IOException { -// GASpecificConfig (samplingFrequencyIndex, -// channelConfiguration, -// audioObjectType) -// { - frameLengthFlag = in.readBits(1); - dependsOnCoreCoder = in.readBits(1); - if (dependsOnCoreCoder == 1) { - coreCoderDelay = in.readBits(14); - } - extensionFlag = in.readBits(1); - if (channelConfiguration == 0) { - throw new UnsupportedOperationException("can't parse program_config_element yet"); - //program_config_element (); - } - if ((audioObjectType == 6) || (audioObjectType == 20)) { - layerNr = in.readBits(3); - } - if (extensionFlag == 1) { - if (audioObjectType == 22) { - numOfSubFrame = in.readBits(5); - layer_length = in.readBits(11); - } - if (audioObjectType == 17 || audioObjectType == 19 || - audioObjectType == 20 || audioObjectType == 23) { - aacSectionDataResilienceFlag = in.readBits(1); - aacScalefactorDataResilienceFlag = in.readBits(1); - aacSpectralDataResilienceFlag = in.readBits(1); - } - extensionFlag3 = in.readBits(1); - if (extensionFlag3 == 1) { - /* tbd in version 3 */ - } - } -// } - gaSpecificConfig = true; - } - - private void parseParametricSpecificConfig(int samplingFrequencyIndex, int channelConfiguration, int audioObjectType, BitReaderBuffer in) throws IOException { - /* - ParametricSpecificConfig() { - isBaseLayer; 1 uimsbf - if (isBaseLayer) { - PARAconfig(); - } else { - HILNenexConfig(); - } - } - */ - isBaseLayer = in.readBits(1); - if (isBaseLayer == 1) { - parseParaConfig(samplingFrequencyIndex, channelConfiguration, audioObjectType, in); - } else { - parseHilnEnexConfig(samplingFrequencyIndex, channelConfiguration, audioObjectType, in); - } - } - - private void parseParaConfig(int samplingFrequencyIndex, int channelConfiguration, int audioObjectType, BitReaderBuffer in) throws IOException { - /* - PARAconfig() - { - PARAmode; 2 uimsbf - if (PARAmode != 1) { - ErHVXCconfig(); - } - if (PARAmode != 0) { - HILNconfig(); - } - PARAextensionFlag; 1 uimsbf - if (PARAextensionFlag) { - // to be defined in MPEG-4 Phase 3 - } - } - */ - paraMode = in.readBits(2); - - if (paraMode != 1) { - parseErHvxcConfig(samplingFrequencyIndex, channelConfiguration, audioObjectType, in); - } - if (paraMode != 0) { - parseHilnConfig(samplingFrequencyIndex, channelConfiguration, audioObjectType, in); - } - - paraExtensionFlag = in.readBits(1); - parametricSpecificConfig = true; - } - - private void parseErHvxcConfig(int samplingFrequencyIndex, int channelConfiguration, int audioObjectType, BitReaderBuffer in) throws IOException { - /* - ErHVXCconfig() - { - HVXCvarMode; 1 uimsbf - HVXCrateMode; 2 uimsbf - extensionFlag; 1 uimsbf - if (extensionFlag) { - var_ScalableFlag; 1 uimsbf - } - } - */ - hvxcVarMode = in.readBits(1); - hvxcRateMode = in.readBits(2); - erHvxcExtensionFlag = in.readBits(1); - - if (erHvxcExtensionFlag == 1) { - var_ScalableFlag = in.readBits(1); - } - } - - private void parseHilnConfig(int samplingFrequencyIndex, int channelConfiguration, int audioObjectType, BitReaderBuffer in) throws IOException { - /* - HILNconfig() - { - HILNquantMode; 1 uimsbf - HILNmaxNumLine; 8 uimsbf - HILNsampleRateCode; 4 uimsbf - HILNframeLength; 12 uimsbf - HILNcontMode; 2 uimsbf - } - */ - hilnQuantMode = in.readBits(1); - hilnMaxNumLine = in.readBits(8); - hilnSampleRateCode = in.readBits(4); - hilnFrameLength = in.readBits(12); - hilnContMode = in.readBits(2); - } - - private void parseHilnEnexConfig(int samplingFrequencyIndex, int channelConfiguration, int audioObjectType, BitReaderBuffer in) throws IOException { - /* - HILNenexConfig() - { - HILNenhaLayer; 1 uimsbf - if (HILNenhaLayer) { - HILNenhaQuantMode; 2 uimsbf - } - } - */ - hilnEnhaLayer = in.readBits(1); - if (hilnEnhaLayer == 1) { - hilnEnhaQuantMode = in.readBits(2); - } - } - - public ByteBuffer getConfigBytes() { - return configBytes; - } - - public int getAudioObjectType() { - return audioObjectType; - } - - public int getExtensionAudioObjectType() { - return extensionAudioObjectType; - } - - public int getSbrPresentFlag() { - return sbrPresentFlag; - } - - public int getPsPresentFlag() { - return psPresentFlag; - } - - public void setAudioObjectType(int audioObjectType) { - this.audioObjectType = audioObjectType; - } - - public void setSamplingFrequencyIndex(int samplingFrequencyIndex) { - this.samplingFrequencyIndex = samplingFrequencyIndex; - } - - public void setSamplingFrequency(int samplingFrequency) { - this.samplingFrequency = samplingFrequency; - } - - public void setChannelConfiguration(int channelConfiguration) { - this.channelConfiguration = channelConfiguration; - } - - @Override - public String toString() { - final StringBuilder sb = new StringBuilder(); - sb.append("AudioSpecificConfig"); - sb.append("{configBytes=").append(configBytes); - sb.append(", audioObjectType=").append(audioObjectType).append(" (").append(audioObjectTypeMap.get(audioObjectType)).append(")"); - sb.append(", samplingFrequencyIndex=").append(samplingFrequencyIndex).append(" (").append(samplingFrequencyIndexMap.get(samplingFrequencyIndex)).append(")"); - sb.append(", samplingFrequency=").append(samplingFrequency); - sb.append(", channelConfiguration=").append(channelConfiguration); - if (extensionAudioObjectType > 0) { - sb.append(", extensionAudioObjectType=").append(extensionAudioObjectType).append(" (").append(audioObjectTypeMap.get(extensionAudioObjectType)).append(")"); - sb.append(", sbrPresentFlag=").append(sbrPresentFlag); - sb.append(", psPresentFlag=").append(psPresentFlag); - sb.append(", extensionSamplingFrequencyIndex=").append(extensionSamplingFrequencyIndex).append(" (").append(samplingFrequencyIndexMap.get(extensionSamplingFrequencyIndex)).append(")"); - sb.append(", extensionSamplingFrequency=").append(extensionSamplingFrequency); - sb.append(", extensionChannelConfiguration=").append(extensionChannelConfiguration); - } -// sb.append(", sacPayloadEmbedding=").append(sacPayloadEmbedding); -// sb.append(", fillBits=").append(fillBits); -// sb.append(", epConfig=").append(epConfig); -// sb.append(", directMapping=").append(directMapping); - sb.append(", syncExtensionType=").append(syncExtensionType); - if (gaSpecificConfig) { - sb.append(", frameLengthFlag=").append(frameLengthFlag); - sb.append(", dependsOnCoreCoder=").append(dependsOnCoreCoder); - sb.append(", coreCoderDelay=").append(coreCoderDelay); - sb.append(", extensionFlag=").append(extensionFlag); - sb.append(", layerNr=").append(layerNr); - sb.append(", numOfSubFrame=").append(numOfSubFrame); - sb.append(", layer_length=").append(layer_length); - sb.append(", aacSectionDataResilienceFlag=").append(aacSectionDataResilienceFlag); - sb.append(", aacScalefactorDataResilienceFlag=").append(aacScalefactorDataResilienceFlag); - sb.append(", aacSpectralDataResilienceFlag=").append(aacSpectralDataResilienceFlag); - sb.append(", extensionFlag3=").append(extensionFlag3); - } - if (parametricSpecificConfig) { - sb.append(", isBaseLayer=").append(isBaseLayer); - sb.append(", paraMode=").append(paraMode); - sb.append(", paraExtensionFlag=").append(paraExtensionFlag); - sb.append(", hvxcVarMode=").append(hvxcVarMode); - sb.append(", hvxcRateMode=").append(hvxcRateMode); - sb.append(", erHvxcExtensionFlag=").append(erHvxcExtensionFlag); - sb.append(", var_ScalableFlag=").append(var_ScalableFlag); - sb.append(", hilnQuantMode=").append(hilnQuantMode); - sb.append(", hilnMaxNumLine=").append(hilnMaxNumLine); - sb.append(", hilnSampleRateCode=").append(hilnSampleRateCode); - sb.append(", hilnFrameLength=").append(hilnFrameLength); - sb.append(", hilnContMode=").append(hilnContMode); - sb.append(", hilnEnhaLayer=").append(hilnEnhaLayer); - sb.append(", hilnEnhaQuantMode=").append(hilnEnhaQuantMode); - } - sb.append('}'); - return sb.toString(); - } - - static { - // sampling_frequency_index sampling frequeny -//0x0 96000 -//0x1 88200 -//0x2 64000 -//0x3 48000 -//0x4 44100 -//0x5 32000 -//0x6 24000 -//0x7 22050 -//0x8 16000 -//0x9 12000 -//0xa 11025 -//0xb 8000 -//0xc reserved -//0xd reserved -//0xe reserved -//0xf reserved - samplingFrequencyIndexMap.put(0x0, 96000); - samplingFrequencyIndexMap.put(0x1, 88200); - samplingFrequencyIndexMap.put(0x2, 64000); - samplingFrequencyIndexMap.put(0x3, 48000); - samplingFrequencyIndexMap.put(0x4, 44100); - samplingFrequencyIndexMap.put(0x5, 32000); - samplingFrequencyIndexMap.put(0x6, 24000); - samplingFrequencyIndexMap.put(0x7, 22050); - samplingFrequencyIndexMap.put(0x8, 16000); - samplingFrequencyIndexMap.put(0x9, 12000); - samplingFrequencyIndexMap.put(0xa, 11025); - samplingFrequencyIndexMap.put(0xb, 8000); - - /* audioObjectType IDs - 0 Null - 1 AAC main X X - 2 AAC LC X X X X X X X - 3 AAC SSR X X - 4 AAC LTP X X X X - 5 SBR X X - 6 AAC Scalable X X X X - 7 TwinVQ X X X - 8 CELP X X X X X X - 9 HVXC X X X X X - 10 (reserved) - 11 (reserved) - 12 TTSI X X X X X X - 13 Main synthetic X X - 14 Wavetable synthesis X* X* - 15 General MIDI X* X* - 16 Algorithmic Synthesis and Audio FX X* X* - 17 ER AAC LC X X X - 18 (reserved) - 19 ER AAC LTP X X - 20 ER AAC Scalable X X X - 21 ER TwinVQ X X - 22 ER BSAC X X - 23 ER AAC LD X X X X - 24 ER CELP X X X - 25 ER HVXC X X - 26 ER HILN X - 27 ER Parametric X - 28 SSC - 29 PS X - 30 MPEG Surround - 31 (escape) - 32 Layer-1 - 33 Layer-2 - 34 Layer-3 - 35 DST - 36 ALS - 37 SLS - 38 SLS non-core - 39 ER AAC ELD - 40 SMR Simple - 41 SMR Main - */ - audioObjectTypeMap.put(1, "AAC main"); - audioObjectTypeMap.put(2, "AAC LC"); - audioObjectTypeMap.put(3, "AAC SSR"); - audioObjectTypeMap.put(4, "AAC LTP"); - audioObjectTypeMap.put(5, "SBR"); - audioObjectTypeMap.put(6, "AAC Scalable"); - audioObjectTypeMap.put(7, "TwinVQ"); - audioObjectTypeMap.put(8, "CELP"); - audioObjectTypeMap.put(9, "HVXC"); - audioObjectTypeMap.put(10, "(reserved)"); - audioObjectTypeMap.put(11, "(reserved)"); - audioObjectTypeMap.put(12, "TTSI"); - audioObjectTypeMap.put(13, "Main synthetic"); - audioObjectTypeMap.put(14, "Wavetable synthesis"); - audioObjectTypeMap.put(15, "General MIDI"); - audioObjectTypeMap.put(16, "Algorithmic Synthesis and Audio FX"); - audioObjectTypeMap.put(17, "ER AAC LC"); - audioObjectTypeMap.put(18, "(reserved)"); - audioObjectTypeMap.put(19, "ER AAC LTP"); - audioObjectTypeMap.put(20, "ER AAC Scalable"); - audioObjectTypeMap.put(21, "ER TwinVQ"); - audioObjectTypeMap.put(22, "ER BSAC"); - audioObjectTypeMap.put(23, "ER AAC LD"); - audioObjectTypeMap.put(24, "ER CELP"); - audioObjectTypeMap.put(25, "ER HVXC"); - audioObjectTypeMap.put(26, "ER HILN"); - audioObjectTypeMap.put(27, "ER Parametric"); - audioObjectTypeMap.put(28, "SSC"); - audioObjectTypeMap.put(29, "PS"); - audioObjectTypeMap.put(30, "MPEG Surround"); - audioObjectTypeMap.put(31, "(escape)"); - audioObjectTypeMap.put(32, "Layer-1"); - audioObjectTypeMap.put(33, "Layer-2"); - audioObjectTypeMap.put(34, "Layer-3"); - audioObjectTypeMap.put(35, "DST"); - audioObjectTypeMap.put(36, "ALS"); - audioObjectTypeMap.put(37, "SLS"); - audioObjectTypeMap.put(38, "SLS non-core"); - audioObjectTypeMap.put(39, "ER AAC ELD"); - audioObjectTypeMap.put(40, "SMR Simple"); - audioObjectTypeMap.put(41, "SMR Main"); - - /* profileLevelIds - 0x00 Reserved for ISO use - - 0x01 Main Audio Profile L1 - 0x02 Main Audio Profile L2 - 0x03 Main Audio Profile L3 - 0x04 Main Audio Profile L4 - 0x05 Scalable Audio Profile L1 - 0x06 Scalable Audio Profile L2 - 0x07 Scalable Audio Profile L3 - 0x08 Scalable Audio Profile L4 - 0x09 Speech Audio Profile L1 - 0x0A Speech Audio Profile L2 - 0x0B Synthetic Audio Profile L1 - 0x0C Synthetic Audio Profile L2 - 0x0D Synthetic Audio Profile L3 - 0x0E High Quality Audio Profile L1 - 0x0F High Quality Audio Profile L2 - 0x10 High Quality Audio Profile L3 - 0x11 High Quality Audio Profile L4 - 0x12 High Quality Audio Profile L5 - 0x13 High Quality Audio Profile L6 - 0x14 High Quality Audio Profile L7 - 0x15 High Quality Audio Profile L8 - 0x16 Low Delay Audio Profile L1 - 0x17 Low Delay Audio Profile L2 - 0x18 Low Delay Audio Profile L3 - 0x19 Low Delay Audio Profile L4 - 0x1A Low Delay Audio Profile L5 - 0x1B Low Delay Audio Profile L6 - 0x1C Low Delay Audio Profile L7 - 0x1D Low Delay Audio Profile L8 - 0x1E Natural Audio Profile L1 - 0x1F Natural Audio Profile L2 - 0x20 Natural Audio Profile L3 - 0x21 Natural Audio Profile L4 - 0x22 Mobile Audio Internetworking Profile L1 - 0x23 Mobile Audio Internetworking Profile L2 - 0x24 Mobile Audio Internetworking Profile L3 - 0x25 Mobile Audio Internetworking Profile L4 - 0x26 Mobile Audio Internetworking Profile L5 - 0x27 Mobile Audio Internetworking Profile L6 - 0x28 AAC Profile L1 - 0x29 AAC Profile L2 - 0x2A AAC Profile L4 - 0x2B AAC Profile L5 - 0x2C High Efficiency AAC Profile L2 - 0x2D High Efficiency AAC Profile L3 - 0x2E High Efficiency AAC Profile L4 - 0x2F High Efficiency AAC Profile L5 - 0x30 High Efficiency AAC v2 Profile L2 - 0x31 High Efficiency AAC v2 Profile L3 - 0x32 High Efficiency AAC v2 Profile L4 - 0x33 High Efficiency AAC v2 Profile L5 - 0x34 Low Delay AAC Profile L1 - 0x35 Baseline MPEG Surround Profile (see ISO/IEC - 23003-1) - L1 - 0x36 Baseline MPEG Surround Profile (see ISO/IEC - 23003-1) - L2 - 0x37 Baseline MPEG Surround Profile (see ISO/IEC - 23003-1) - L3 - 0x38 Baseline MPEG Surround Profile (see ISO/IEC - 23003-1) - L4 - 0c39 Baseline MPEG Surround Profile (see ISO/IEC - 23003-1) - L5 - 0x3A Baseline MPEG Surround Profile (see ISO/IEC - 23003-1) - L6 - 0x3B - 0x7F reserved for ISO use - - 0x80 - 0xFD user private - - 0xFE no audio profile specified - - 0xFF no audio capability required - - - */ - } - - - public int getSamplingFrequency() { - return samplingFrequencyIndex == 0xf ? samplingFrequency : samplingFrequencyIndexMap.get(samplingFrequencyIndex); - } - - public int getChannelConfiguration() { - return channelConfiguration; - } -} diff --git a/android-aac-enc/src/main/java/com/googlecode/mp4parser/boxes/mp4/objectdescriptors/BaseDescriptor.java b/android-aac-enc/src/main/java/com/googlecode/mp4parser/boxes/mp4/objectdescriptors/BaseDescriptor.java deleted file mode 100644 index 54aac8c0e..000000000 --- a/android-aac-enc/src/main/java/com/googlecode/mp4parser/boxes/mp4/objectdescriptors/BaseDescriptor.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright 2011 castLabs, Berlin - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.googlecode.mp4parser.boxes.mp4.objectdescriptors; - -import com.coremedia.iso.IsoTypeReader; - -import java.io.IOException; -import java.nio.ByteBuffer; - -/* -abstract aligned(8) expandable(228-1) class BaseDescriptor : bit(8) tag=0 { -// empty. To be filled by classes extending this class. -} - -int sizeOfInstance = 0; -bit(1) nextByte; -bit(7) sizeOfInstance; -while(nextByte) { -bit(1) nextByte; -bit(7) sizeByte; -sizeOfInstance = sizeOfInstance<<7 | sizeByte; -} - */ -@Descriptor(tags = 0x00) -public abstract class BaseDescriptor { - int tag; - int sizeOfInstance; - int sizeBytes; - - public BaseDescriptor() { - } - - public int getTag() { - return tag; - } - - public int getSize() { - return sizeOfInstance - + 1//1 for the tag - + sizeBytes; - } - - public int getSizeOfInstance() { - return sizeOfInstance; - } - - public int getSizeBytes() { - return sizeBytes; - } - - public final void parse(int tag, ByteBuffer bb) throws IOException { - this.tag = tag; - - int i = 0; - int tmp = IsoTypeReader.readUInt8(bb); - i++; - sizeOfInstance = tmp & 0x7f; - while (tmp >>> 7 == 1) { //nextbyte indicator bit - tmp = IsoTypeReader.readUInt8(bb); - i++; - //sizeOfInstance = sizeOfInstance<<7 | sizeByte; - sizeOfInstance = sizeOfInstance << 7 | tmp & 0x7f; - } - sizeBytes = i; - ByteBuffer detailSource = bb.slice(); - detailSource.limit(sizeOfInstance); - parseDetail(detailSource); - assert detailSource.remaining() == 0: this.getClass().getSimpleName() + " has not been fully parsed"; - bb.position(bb.position() + sizeOfInstance); - } - - public abstract void parseDetail(ByteBuffer bb) throws IOException; - - - - @Override - public String toString() { - final StringBuilder sb = new StringBuilder(); - sb.append("BaseDescriptor"); - sb.append("{tag=").append(tag); - sb.append(", sizeOfInstance=").append(sizeOfInstance); - sb.append('}'); - return sb.toString(); - } -} diff --git a/android-aac-enc/src/main/java/com/googlecode/mp4parser/boxes/mp4/objectdescriptors/BitReaderBuffer.java b/android-aac-enc/src/main/java/com/googlecode/mp4parser/boxes/mp4/objectdescriptors/BitReaderBuffer.java deleted file mode 100644 index 7221503cd..000000000 --- a/android-aac-enc/src/main/java/com/googlecode/mp4parser/boxes/mp4/objectdescriptors/BitReaderBuffer.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.googlecode.mp4parser.boxes.mp4.objectdescriptors; - -import java.nio.ByteBuffer; - -public class BitReaderBuffer { - - private ByteBuffer buffer; - int initialPos; - int position; - - public BitReaderBuffer(ByteBuffer buffer) { - this.buffer = buffer; - initialPos = buffer.position(); - } - - public int readBits(int i) { - byte b = buffer.get(initialPos + position / 8); - int v = b < 0 ? b + 256 : b; - int left = 8 - position % 8; - int rc; - if (i <= left) { - rc = (v << (position % 8) & 0xFF) >> ((position % 8) + (left - i)); - position += i; - } else { - int now = left; - int then = i - left; - rc = readBits(now); - rc = rc << then; - rc += readBits(then); - } - buffer.position(initialPos + (int) Math.ceil((double) position / 8)); - return rc; - } - - public int getPosition() { - return position; - } - - public int byteSync() { - int left = 8 - position % 8; - if (left == 8) { - left = 0; - } - readBits(left); - return left; - } - - public int remainingBits() { - return buffer.limit() * 8 - position; - } -} diff --git a/android-aac-enc/src/main/java/com/googlecode/mp4parser/boxes/mp4/objectdescriptors/BitWriterBuffer.java b/android-aac-enc/src/main/java/com/googlecode/mp4parser/boxes/mp4/objectdescriptors/BitWriterBuffer.java deleted file mode 100644 index 15200d826..000000000 --- a/android-aac-enc/src/main/java/com/googlecode/mp4parser/boxes/mp4/objectdescriptors/BitWriterBuffer.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.googlecode.mp4parser.boxes.mp4.objectdescriptors; - -import java.nio.ByteBuffer; - -public class BitWriterBuffer { - - private ByteBuffer buffer; - int initialPos; - int position = 0; - - public BitWriterBuffer(ByteBuffer buffer) { - this.buffer = buffer; - this.initialPos = buffer.position(); - } - - public void writeBits(int i, int numBits) { - int left = 8 - position % 8; - if (numBits <= left) { - int current = (buffer.get(initialPos + position / 8)); - current = current < 0 ? current + 256 : current; - current += i << (left - numBits); - buffer.put(initialPos + position / 8, (byte) (current > 127 ? current - 256 : current)); - position += numBits; - } else { - int bitsSecondWrite = numBits - left; - writeBits(i >> bitsSecondWrite, left); - writeBits(i & (1 << bitsSecondWrite) - 1, bitsSecondWrite); - } - buffer.position(initialPos + position / 8 + ((position % 8 > 0) ? 1 : 0)); - } - - -} diff --git a/android-aac-enc/src/main/java/com/googlecode/mp4parser/boxes/mp4/objectdescriptors/DecoderConfigDescriptor.java b/android-aac-enc/src/main/java/com/googlecode/mp4parser/boxes/mp4/objectdescriptors/DecoderConfigDescriptor.java deleted file mode 100644 index 640d4a991..000000000 --- a/android-aac-enc/src/main/java/com/googlecode/mp4parser/boxes/mp4/objectdescriptors/DecoderConfigDescriptor.java +++ /dev/null @@ -1,262 +0,0 @@ -/* - * Copyright 2011 castLabs, Berlin - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.googlecode.mp4parser.boxes.mp4.objectdescriptors; - -import com.coremedia.iso.Hex; -import com.coremedia.iso.IsoTypeReader; -import com.coremedia.iso.IsoTypeWriter; - -import java.io.IOException; -import java.nio.ByteBuffer; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.logging.Logger; - -/** - * class DecoderConfigDescriptor extends BaseDescriptor : bit(8) - * tag=DecoderConfigDescrTag { - * bit(8) objectTypeIndication; - * bit(6) streamType; - * bit(1) upStream; - * const bit(1) reserved=1; - * bit(24) bufferSizeDB; - * bit(32) maxBitrate; - * bit(32) avgBitrate; - * DecoderSpecificInfo decSpecificInfo[0 .. 1]; - * profileLevelIndicationIndexDescriptor profileLevelIndicationIndexDescr - * [0..255]; - * } - */ -@Descriptor(tags = {0x04}) -public class DecoderConfigDescriptor extends BaseDescriptor { - private static Logger log = Logger.getLogger(DecoderConfigDescriptor.class.getName()); - - - int objectTypeIndication; - int streamType; - int upStream; - int bufferSizeDB; - long maxBitRate; - long avgBitRate; - - DecoderSpecificInfo decoderSpecificInfo; - AudioSpecificConfig audioSpecificInfo; - List profileLevelIndicationDescriptors = new ArrayList(); - byte[] configDescriptorDeadBytes; - - @Override - public void parseDetail(ByteBuffer bb) throws IOException { - objectTypeIndication = IsoTypeReader.readUInt8(bb); - - int data = IsoTypeReader.readUInt8(bb); - streamType = data >>> 2; - upStream = (data >> 1) & 0x1; - - bufferSizeDB = IsoTypeReader.readUInt24(bb); - maxBitRate = IsoTypeReader.readUInt32(bb); - avgBitRate = IsoTypeReader.readUInt32(bb); - - - - BaseDescriptor descriptor; - if (bb.remaining() > 2) { //1byte tag + at least 1byte size - final int begin = bb.position(); - descriptor = ObjectDescriptorFactory.createFrom(objectTypeIndication, bb); - final int read = bb.position() - begin; - log.finer(descriptor + " - DecoderConfigDescr1 read: " + read + ", size: " + (descriptor != null ? descriptor.getSize() : null)); - if (descriptor != null) { - final int size = descriptor.getSize(); - if (read < size) { - //skip - configDescriptorDeadBytes = new byte[size - read]; - bb.get(configDescriptorDeadBytes); - } - } - if (descriptor instanceof DecoderSpecificInfo) { - decoderSpecificInfo = (DecoderSpecificInfo) descriptor; - } - if (descriptor instanceof AudioSpecificConfig) { - audioSpecificInfo = (AudioSpecificConfig) descriptor; - } - } - - while (bb.remaining() > 2) { - final long begin = bb.position(); - descriptor = ObjectDescriptorFactory.createFrom(objectTypeIndication, bb); - final long read = bb.position() - begin; - log.finer(descriptor + " - DecoderConfigDescr2 read: " + read + ", size: " + (descriptor != null ? descriptor.getSize() : null)); - if (descriptor instanceof ProfileLevelIndicationDescriptor) { - profileLevelIndicationDescriptors.add((ProfileLevelIndicationDescriptor) descriptor); - } - } - } - public int serializedSize() { - return 15 + audioSpecificInfo.serializedSize(); - } - - public ByteBuffer serialize() { - ByteBuffer out = ByteBuffer.allocate(serializedSize()); - IsoTypeWriter.writeUInt8(out, 4); - IsoTypeWriter.writeUInt8(out, serializedSize() - 2); - IsoTypeWriter.writeUInt8(out, objectTypeIndication); - int flags = (streamType << 2) | (upStream << 1) | 1; - IsoTypeWriter.writeUInt8(out, flags); - IsoTypeWriter.writeUInt24(out, bufferSizeDB); - IsoTypeWriter.writeUInt32(out, maxBitRate); - IsoTypeWriter.writeUInt32(out, avgBitRate); - out.put(audioSpecificInfo.serialize().array()); - return out; - } - - public DecoderSpecificInfo getDecoderSpecificInfo() { - return decoderSpecificInfo; - } - - public AudioSpecificConfig getAudioSpecificInfo() { - return audioSpecificInfo; - } - - public void setAudioSpecificInfo(AudioSpecificConfig audioSpecificInfo) { - this.audioSpecificInfo = audioSpecificInfo; - } - - public List getProfileLevelIndicationDescriptors() { - return profileLevelIndicationDescriptors; - } - - public int getObjectTypeIndication() { - return objectTypeIndication; - } - - public void setObjectTypeIndication(int objectTypeIndication) { - this.objectTypeIndication = objectTypeIndication; - } - - public int getStreamType() { - return streamType; - } - - public void setStreamType(int streamType) { - this.streamType = streamType; - } - - public int getUpStream() { - return upStream; - } - - public void setUpStream(int upStream) { - this.upStream = upStream; - } - - public int getBufferSizeDB() { - return bufferSizeDB; - } - - public void setBufferSizeDB(int bufferSizeDB) { - this.bufferSizeDB = bufferSizeDB; - } - - public long getMaxBitRate() { - return maxBitRate; - } - - public void setMaxBitRate(long maxBitRate) { - this.maxBitRate = maxBitRate; - } - - public long getAvgBitRate() { - return avgBitRate; - } - - public void setAvgBitRate(long avgBitRate) { - this.avgBitRate = avgBitRate; - } - - @Override - public String toString() { - final StringBuilder sb = new StringBuilder(); - sb.append("DecoderConfigDescriptor"); - sb.append("{objectTypeIndication=").append(objectTypeIndication); - sb.append(", streamType=").append(streamType); - sb.append(", upStream=").append(upStream); - sb.append(", bufferSizeDB=").append(bufferSizeDB); - sb.append(", maxBitRate=").append(maxBitRate); - sb.append(", avgBitRate=").append(avgBitRate); - sb.append(", decoderSpecificInfo=").append(decoderSpecificInfo); - sb.append(", audioSpecificInfo=").append(audioSpecificInfo); - sb.append(", configDescriptorDeadBytes=").append(Hex.encodeHex(configDescriptorDeadBytes != null ? configDescriptorDeadBytes : new byte[]{})); - sb.append(", profileLevelIndicationDescriptors=").append(profileLevelIndicationDescriptors == null ? "null" : Arrays.asList(profileLevelIndicationDescriptors).toString()); - sb.append('}'); - return sb.toString(); - } - /*objectTypeIndication values - 0x00 Forbidden - 0x01 Systems ISO/IEC 14496-1 a - 0x02 Systems ISO/IEC 14496-1 b - 0x03 Interaction Stream - 0x04 Systems ISO/IEC 14496-1 Extended BIFS Configuration c - 0x05 Systems ISO/IEC 14496-1 AFX d - 0x06 Font Data Stream - 0x07 Synthesized Texture Stream - 0x08 Streaming Text Stream - 0x09-0x1F reserved for ISO use - 0x20 Visual ISO/IEC 14496-2 e - 0x21 Visual ITU-T Recommendation H.264 | ISO/IEC 14496-10 f - 0x22 Parameter Sets for ITU-T Recommendation H.264 | ISO/IEC 14496-10 f - 0x23-0x3F reserved for ISO use - 0x40 Audio ISO/IEC 14496-3 g - 0x41-0x5F reserved for ISO use - 0x60 Visual ISO/IEC 13818-2 Simple Profile - 0x61 Visual ISO/IEC 13818-2 Main Profile - 0x62 Visual ISO/IEC 13818-2 SNR Profile - 0x63 Visual ISO/IEC 13818-2 Spatial Profile - 0x64 Visual ISO/IEC 13818-2 High Profile - 0x65 Visual ISO/IEC 13818-2 422 Profile - 0x66 Audio ISO/IEC 13818-7 Main Profile - 0x67 Audio ISO/IEC 13818-7 LowComplexity Profile - 0x68 Audio ISO/IEC 13818-7 Scaleable Sampling Rate Profile - 0x69 Audio ISO/IEC 13818-3 - 0x6A Visual ISO/IEC 11172-2 - 0x6B Audio ISO/IEC 11172-3 - 0x6C Visual ISO/IEC 10918-1 - 0x6D reserved for registration authority i - 0x6E Visual ISO/IEC 15444-1 - 0x6F - 0x9F reserved for ISO use - 0xA0 - 0xBF reserved for registration authority i - 0xC0 - 0xE0 user private - 0xE1 reserved for registration authority i - 0xE2 - 0xFE user private - 0xFF no object type specified h - */ - /* streamType values - 0x00 Forbidden - 0x01 ObjectDescriptorStream (see 7.2.5) - 0x02 ClockReferenceStream (see 7.3.2.5) - 0x03 SceneDescriptionStream (see ISO/IEC 14496-11) - 0x04 VisualStream - 0x05 AudioStream - 0x06 MPEG7Stream - 0x07 IPMPStream (see 7.2.3.2) - 0x08 ObjectContentInfoStream (see 7.2.4.2) - 0x09 MPEGJStream - 0x0A Interaction Stream - 0x0B IPMPToolStream (see [ISO/IEC 14496-13]) - 0x0C - 0x1F reserved for ISO use - 0x20 - 0x3F user private - */ -} diff --git a/android-aac-enc/src/main/java/com/googlecode/mp4parser/boxes/mp4/objectdescriptors/DecoderSpecificInfo.java b/android-aac-enc/src/main/java/com/googlecode/mp4parser/boxes/mp4/objectdescriptors/DecoderSpecificInfo.java deleted file mode 100644 index a7b9940b1..000000000 --- a/android-aac-enc/src/main/java/com/googlecode/mp4parser/boxes/mp4/objectdescriptors/DecoderSpecificInfo.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright 2011 castLabs, Berlin - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.googlecode.mp4parser.boxes.mp4.objectdescriptors; - -import com.coremedia.iso.Hex; - -import java.io.IOException; -import java.nio.ByteBuffer; - -/** - * abstract class DecoderSpecificInfo extends BaseDescriptor : bit(8) - * tag=DecSpecificInfoTag - * { - * // empty. To be filled by classes extending this class. - * } - */ -@Descriptor(tags = 0x05) -public class DecoderSpecificInfo extends BaseDescriptor { - byte[] bytes; - - @Override - public void parseDetail(ByteBuffer bb) throws IOException { - if (sizeOfInstance > 0) { - bytes = new byte[sizeOfInstance]; - bb.get(bytes); - } - } - - public int serializedSize() { - return bytes.length; - } - - public ByteBuffer serialize() { - ByteBuffer out = ByteBuffer.wrap(bytes); - - return out; - } - - @Override - public String toString() { - final StringBuilder sb = new StringBuilder(); - sb.append("DecoderSpecificInfo"); - sb.append("{bytes=").append(bytes == null ? "null" : Hex.encodeHex(bytes)); - sb.append('}'); - return sb.toString(); - } -} diff --git a/android-aac-enc/src/main/java/com/googlecode/mp4parser/boxes/mp4/objectdescriptors/Descriptor.java b/android-aac-enc/src/main/java/com/googlecode/mp4parser/boxes/mp4/objectdescriptors/Descriptor.java deleted file mode 100644 index 819edac7c..000000000 --- a/android-aac-enc/src/main/java/com/googlecode/mp4parser/boxes/mp4/objectdescriptors/Descriptor.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright 2011 castLabs, Berlin - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.googlecode.mp4parser.boxes.mp4.objectdescriptors; - -import java.lang.annotation.Documented; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Created by IntelliJ IDEA. - * User: mstattma - * Date: 06.08.2010 - * Time: 06:54:58 - * To change this template use File | Settings | File Templates. - */ -@Documented -@Target(ElementType.TYPE) -@Retention(RetentionPolicy.RUNTIME) -public @interface Descriptor { - int[] tags(); - - int objectTypeIndication() default -1; -} diff --git a/android-aac-enc/src/main/java/com/googlecode/mp4parser/boxes/mp4/objectdescriptors/ESDescriptor.java b/android-aac-enc/src/main/java/com/googlecode/mp4parser/boxes/mp4/objectdescriptors/ESDescriptor.java deleted file mode 100644 index c24e45653..000000000 --- a/android-aac-enc/src/main/java/com/googlecode/mp4parser/boxes/mp4/objectdescriptors/ESDescriptor.java +++ /dev/null @@ -1,333 +0,0 @@ -/* - * Copyright 2011 castLabs, Berlin - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.googlecode.mp4parser.boxes.mp4.objectdescriptors; - -import com.coremedia.iso.IsoTypeReader; -import com.coremedia.iso.IsoTypeWriter; - -import java.io.IOException; -import java.nio.ByteBuffer; -import java.util.ArrayList; -import java.util.List; -import java.util.logging.Logger; - -/* -class ES_Descriptor extends BaseDescriptor : bit(8) tag=ES_DescrTag { -bit(16) ES_ID; -bit(1) streamDependenceFlag; -bit(1) URL_Flag; -bit(1) OCRstreamFlag; -bit(5) streamPriority; -if (streamDependenceFlag) -bit(16) dependsOn_ES_ID; -if (URL_Flag) { -bit(8) URLlength; -bit(8) URLstring[URLlength]; -} -if (OCRstreamFlag) -bit(16) OCR_ES_Id; -DecoderConfigDescriptor decConfigDescr; -if (ODProfileLevelIndication==0x01) //no SL extension. -{ -SLConfigDescriptor slConfigDescr; -} -else // SL extension is possible. -{ -SLConfigDescriptor slConfigDescr; -} -IPI_DescrPointer ipiPtr[0 .. 1]; -IP_IdentificationDataSet ipIDS[0 .. 255]; -IPMP_DescriptorPointer ipmpDescrPtr[0 .. 255]; -LanguageDescriptor langDescr[0 .. 255]; -QoS_Descriptor qosDescr[0 .. 1]; -RegistrationDescriptor regDescr[0 .. 1]; -ExtensionDescriptor extDescr[0 .. 255]; -} - */ -@Descriptor(tags = {0x03}) -public class ESDescriptor extends BaseDescriptor { - private static Logger log = Logger.getLogger(ESDescriptor.class.getName()); - - int esId; - int streamDependenceFlag; - int URLFlag; - int oCRstreamFlag; - int streamPriority; - - - int URLLength = 0; - String URLString; - int remoteODFlag; - - int dependsOnEsId; - int oCREsId; - - DecoderConfigDescriptor decoderConfigDescriptor; - SLConfigDescriptor slConfigDescriptor; - List otherDescriptors = new ArrayList(); - - @Override - public void parseDetail(ByteBuffer bb) throws IOException { - esId = IsoTypeReader.readUInt16(bb); - - int data = IsoTypeReader.readUInt8(bb); - streamDependenceFlag = data >>> 7; - URLFlag = (data >>> 6) & 0x1; - oCRstreamFlag = (data >>> 5) & 0x1; - streamPriority = data & 0x1f; - - if (streamDependenceFlag == 1) { - dependsOnEsId = IsoTypeReader.readUInt16(bb); - } - if (URLFlag == 1) { - URLLength = IsoTypeReader.readUInt8(bb); - URLString = IsoTypeReader.readString(bb, URLLength); - } - if (oCRstreamFlag == 1) { - oCREsId = IsoTypeReader.readUInt16(bb); - } - - int baseSize = 1 /*tag*/ + getSizeBytes() + 2 + 1 + (streamDependenceFlag == 1 ? 2 : 0) + (URLFlag == 1 ? 1 + URLLength : 0) + (oCRstreamFlag == 1 ? 2 : 0); - - int begin = bb.position(); - if (getSize() > baseSize + 2) { - BaseDescriptor descriptor = ObjectDescriptorFactory.createFrom(-1, bb); - final long read = bb.position() - begin; - log.finer(descriptor + " - ESDescriptor1 read: " + read + ", size: " + (descriptor != null ? descriptor.getSize() : null)); - if (descriptor != null) { - final int size = descriptor.getSize(); - bb.position(begin + size); - baseSize += size; - } else { - baseSize += read; - } - if (descriptor instanceof DecoderConfigDescriptor) { - decoderConfigDescriptor = (DecoderConfigDescriptor) descriptor; - } - } - - begin = bb.position(); - if (getSize() > baseSize + 2) { - BaseDescriptor descriptor = ObjectDescriptorFactory.createFrom(-1, bb); - final long read = bb.position() - begin; - log.finer(descriptor + " - ESDescriptor2 read: " + read + ", size: " + (descriptor != null ? descriptor.getSize() : null)); - if (descriptor != null) { - final int size = descriptor.getSize(); - bb.position(begin + size); - baseSize += size; - } else { - baseSize += read; - } - if (descriptor instanceof SLConfigDescriptor) { - slConfigDescriptor = (SLConfigDescriptor) descriptor; - } - } else { - log.warning("SLConfigDescriptor is missing!"); - } - - while (getSize() - baseSize > 2) { - begin = bb.position(); - BaseDescriptor descriptor = ObjectDescriptorFactory.createFrom(-1, bb); - final long read = bb.position() - begin; - log.finer(descriptor + " - ESDescriptor3 read: " + read + ", size: " + (descriptor != null ? descriptor.getSize() : null)); - if (descriptor != null) { - final int size = descriptor.getSize(); - bb.position(begin + size); - baseSize += size; - } else { - baseSize += read; - } - otherDescriptors.add(descriptor); - } - } - public int serializedSize() { - int out = 5; - if (streamDependenceFlag > 0) { - out += 2; - } - if (URLFlag > 0) { - out += 1 + URLLength; - } - if (oCRstreamFlag > 0) { - out += 2; - } - - out += decoderConfigDescriptor.serializedSize(); - out += slConfigDescriptor.serializedSize(); - - // Doesn't handle other descriptors yet - - return out; - } - - public ByteBuffer serialize() { - ByteBuffer out = ByteBuffer.allocate(serializedSize()); // Usually is around 30 bytes, so 200 should be enough... - IsoTypeWriter.writeUInt8(out, 3); - IsoTypeWriter.writeUInt8(out, serializedSize() - 2); // Not OK for longer sizes! - IsoTypeWriter.writeUInt16(out, esId); - int flags = (streamDependenceFlag << 7) | (URLFlag << 6) | (oCRstreamFlag << 5) | (streamPriority & 0x1f); - IsoTypeWriter.writeUInt8(out, flags); - if (streamDependenceFlag > 0) { - IsoTypeWriter.writeUInt16(out, dependsOnEsId); - } - if (URLFlag > 0) { - IsoTypeWriter.writeUInt8(out, URLLength); - IsoTypeWriter.writeUtf8String(out, URLString); - } - if (oCRstreamFlag > 0) { - IsoTypeWriter.writeUInt16(out, oCREsId); - } - - ByteBuffer dec = decoderConfigDescriptor.serialize(); - ByteBuffer sl = slConfigDescriptor.serialize(); - out.put(dec.array()); - out.put(sl.array()); - - // Doesn't handle other descriptors yet - - return out; - } - -// @Override -// public int getSize() { -// return 3 + (streamDependenceFlag == 1 ? 2 : 0) + -// (URLFlag == 1 ? 1 + 8 * URLLength : 0) + -// (oCRstreamFlag == 1 ? 2 : 0); -// } - - public DecoderConfigDescriptor getDecoderConfigDescriptor() { - return decoderConfigDescriptor; - } - - public SLConfigDescriptor getSlConfigDescriptor() { - return slConfigDescriptor; - } - - public void setDecoderConfigDescriptor(DecoderConfigDescriptor decoderConfigDescriptor) { - this.decoderConfigDescriptor = decoderConfigDescriptor; - } - - public void setSlConfigDescriptor(SLConfigDescriptor slConfigDescriptor) { - this.slConfigDescriptor = slConfigDescriptor; - } - - public List getOtherDescriptors() { - return otherDescriptors; - } - - public int getoCREsId() { - return oCREsId; - } - - public void setoCREsId(int oCREsId) { - this.oCREsId = oCREsId; - } - - public int getEsId() { - return esId; - } - - public void setEsId(int esId) { - this.esId = esId; - } - - public int getStreamDependenceFlag() { - return streamDependenceFlag; - } - - public void setStreamDependenceFlag(int streamDependenceFlag) { - this.streamDependenceFlag = streamDependenceFlag; - } - - public int getURLFlag() { - return URLFlag; - } - - public void setURLFlag(int URLFlag) { - this.URLFlag = URLFlag; - } - - public int getoCRstreamFlag() { - return oCRstreamFlag; - } - - public void setoCRstreamFlag(int oCRstreamFlag) { - this.oCRstreamFlag = oCRstreamFlag; - } - - public int getStreamPriority() { - return streamPriority; - } - - public void setStreamPriority(int streamPriority) { - this.streamPriority = streamPriority; - } - - public int getURLLength() { - return URLLength; - } - - public void setURLLength(int URLLength) { - this.URLLength = URLLength; - } - - public String getURLString() { - return URLString; - } - - public void setURLString(String URLString) { - this.URLString = URLString; - } - - public int getRemoteODFlag() { - return remoteODFlag; - } - - public void setRemoteODFlag(int remoteODFlag) { - this.remoteODFlag = remoteODFlag; - } - - public int getDependsOnEsId() { - return dependsOnEsId; - } - - public void setDependsOnEsId(int dependsOnEsId) { - this.dependsOnEsId = dependsOnEsId; - } - - @Override - public String toString() { - final StringBuilder sb = new StringBuilder(); - sb.append("ESDescriptor"); - sb.append("{esId=").append(esId); - sb.append(", streamDependenceFlag=").append(streamDependenceFlag); - sb.append(", URLFlag=").append(URLFlag); - sb.append(", oCRstreamFlag=").append(oCRstreamFlag); - sb.append(", streamPriority=").append(streamPriority); - sb.append(", URLLength=").append(URLLength); - sb.append(", URLString='").append(URLString).append('\''); - sb.append(", remoteODFlag=").append(remoteODFlag); - sb.append(", dependsOnEsId=").append(dependsOnEsId); - sb.append(", oCREsId=").append(oCREsId); - sb.append(", decoderConfigDescriptor=").append(decoderConfigDescriptor); - sb.append(", slConfigDescriptor=").append(slConfigDescriptor); - sb.append('}'); - return sb.toString(); - } - - -} diff --git a/android-aac-enc/src/main/java/com/googlecode/mp4parser/boxes/mp4/objectdescriptors/ExtensionDescriptor.java b/android-aac-enc/src/main/java/com/googlecode/mp4parser/boxes/mp4/objectdescriptors/ExtensionDescriptor.java deleted file mode 100644 index 97b1f7f2a..000000000 --- a/android-aac-enc/src/main/java/com/googlecode/mp4parser/boxes/mp4/objectdescriptors/ExtensionDescriptor.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright 2011 castLabs, Berlin - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.googlecode.mp4parser.boxes.mp4.objectdescriptors; - -import com.coremedia.iso.Hex; - -import java.io.IOException; -import java.nio.ByteBuffer; -import java.util.logging.Logger; - -/** - * abstract class ExtensionDescriptor extends BaseDescriptor - * : bit(8) tag = ExtensionProfileLevelDescrTag, ExtDescrTagStartRange .. - * ExtDescrTagEndRange { - * // empty. To be filled by classes extending this class. - * } - */ -@Descriptor(tags = {0x13, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253}) -public class ExtensionDescriptor extends BaseDescriptor { - private static Logger log = Logger.getLogger(ExtensionDescriptor.class.getName()); - - byte[] bytes; - - - //todo: add this better to the tags list? - //14496-1:2010 p.20: - //0x6A-0xBF Reserved for ISO use - //0xC0-0xFE User private - // - //ExtDescrTagStartRange = 0x6A - //ExtDescrTagEndRange = 0xFE - static int[] allTags() { - int[] ints = new int[0xFE - 0x6A]; - - for (int i = 0x6A; i < 0xFE; i++) { - final int pos = i - 0x6A; - log.finest("pos:" + pos); - ints[pos] = i; - } - return ints; - } - - @Override - public void parseDetail(ByteBuffer bb) throws IOException { - if (getSize() > 0) { - bytes = new byte[sizeOfInstance]; - bb.get(bytes); - } - } - - @Override - public String toString() { - final StringBuilder sb = new StringBuilder(); - sb.append("ExtensionDescriptor"); - sb.append("{bytes=").append(bytes == null ? "null" : Hex.encodeHex(bytes)); - sb.append('}'); - return sb.toString(); - } -} diff --git a/android-aac-enc/src/main/java/com/googlecode/mp4parser/boxes/mp4/objectdescriptors/ExtensionProfileLevelDescriptor.java b/android-aac-enc/src/main/java/com/googlecode/mp4parser/boxes/mp4/objectdescriptors/ExtensionProfileLevelDescriptor.java deleted file mode 100644 index d52c04479..000000000 --- a/android-aac-enc/src/main/java/com/googlecode/mp4parser/boxes/mp4/objectdescriptors/ExtensionProfileLevelDescriptor.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright 2011 castLabs, Berlin - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.googlecode.mp4parser.boxes.mp4.objectdescriptors; - -import com.coremedia.iso.Hex; - -import java.io.IOException; -import java.nio.ByteBuffer; - -/** - * abstract class ExtensionDescriptor extends BaseDescriptor - * : bit(8) tag = ExtensionProfileLevelDescrTag, ExtDescrTagStartRange .. - * ExtDescrTagEndRange { - * // empty. To be filled by classes extending this class. - * } - */ -@Descriptor(tags = {0x13}) -public class ExtensionProfileLevelDescriptor extends BaseDescriptor { - byte[] bytes; - - @Override - public void parseDetail(ByteBuffer bb) throws IOException { - if (getSize() > 0) { - bytes = new byte[getSize()]; - bb.get(bytes); - } - } - - @Override - public String toString() { - final StringBuilder sb = new StringBuilder(); - sb.append("ExtensionDescriptor"); - sb.append("{bytes=").append(bytes == null ? "null" : Hex.encodeHex(bytes)); - sb.append('}'); - return sb.toString(); - } -} diff --git a/android-aac-enc/src/main/java/com/googlecode/mp4parser/boxes/mp4/objectdescriptors/InitialObjectDescriptor.java b/android-aac-enc/src/main/java/com/googlecode/mp4parser/boxes/mp4/objectdescriptors/InitialObjectDescriptor.java deleted file mode 100644 index e9f3f6b68..000000000 --- a/android-aac-enc/src/main/java/com/googlecode/mp4parser/boxes/mp4/objectdescriptors/InitialObjectDescriptor.java +++ /dev/null @@ -1,136 +0,0 @@ -/* - * Copyright 2011 castLabs, Berlin - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.googlecode.mp4parser.boxes.mp4.objectdescriptors; - - -import com.coremedia.iso.IsoTypeReader; - -import java.io.IOException; -import java.nio.ByteBuffer; -import java.util.ArrayList; -import java.util.List; - -/* -class InitialObjectDescriptor extends ObjectDescriptorBase : bit(8) -tag=InitialObjectDescrTag { -bit(10) ObjectDescriptorID; -bit(1) URL_Flag; -bit(1) includeInlineProfileLevelFlag; -const bit(4) reserved=0b1111; -if (URL_Flag) { -bit(8) URLlength; -bit(8) URLstring[URLlength]; -} else { -bit(8) ODProfileLevelIndication; -bit(8) sceneProfileLevelIndication; -bit(8) audioProfileLevelIndication; -bit(8) visualProfileLevelIndication; -bit(8) graphicsProfileLevelIndication; -ES_Descriptor esDescr[1 .. 255]; -OCI_Descriptor ociDescr[0 .. 255]; -IPMP_DescriptorPointer ipmpDescrPtr[0 .. 255]; -IPMP_Descriptor ipmpDescr [0 .. 255]; -IPMP_ToolListDescriptor toolListDescr[0 .. 1]; -} -ExtensionDescriptor extDescr[0 .. 255]; -} -*/ -//@Descriptor(tags = {0x02, 0x10}) -public class InitialObjectDescriptor extends ObjectDescriptorBase { - private int objectDescriptorId; - int urlFlag; - int includeInlineProfileLevelFlag; - - int urlLength; - String urlString; - - int oDProfileLevelIndication; - int sceneProfileLevelIndication; - int audioProfileLevelIndication; - int visualProfileLevelIndication; - int graphicsProfileLevelIndication; - - List esDescriptors = new ArrayList(); - - List extensionDescriptors = new ArrayList(); - - List unknownDescriptors = new ArrayList(); - - @Override - public void parseDetail(ByteBuffer bb) throws IOException { - int data = IsoTypeReader.readUInt16(bb); - objectDescriptorId = (data & 0xFFC0) >> 6; - - urlFlag = (data & 0x3F) >> 5; - includeInlineProfileLevelFlag = (data & 0x1F) >> 4; - - int sizeLeft = getSize() - 2; - if (urlFlag == 1) { - urlLength = IsoTypeReader.readUInt8(bb); - urlString = IsoTypeReader.readString(bb, urlLength); - sizeLeft = sizeLeft - (1 + urlLength); - } else { - oDProfileLevelIndication = IsoTypeReader.readUInt8(bb); - sceneProfileLevelIndication = IsoTypeReader.readUInt8(bb); - audioProfileLevelIndication = IsoTypeReader.readUInt8(bb); - visualProfileLevelIndication = IsoTypeReader.readUInt8(bb); - graphicsProfileLevelIndication = IsoTypeReader.readUInt8(bb); - - sizeLeft = sizeLeft - 5; - - if (sizeLeft > 2) { - final BaseDescriptor descriptor = ObjectDescriptorFactory.createFrom(-1, bb); - sizeLeft = sizeLeft - descriptor.getSize(); - if (descriptor instanceof ESDescriptor) { - esDescriptors.add((ESDescriptor) descriptor); - } else { - unknownDescriptors.add(descriptor); - } - } - } - - if (sizeLeft > 2) { - final BaseDescriptor descriptor = ObjectDescriptorFactory.createFrom(-1, bb); - if (descriptor instanceof ExtensionDescriptor) { - extensionDescriptors.add((ExtensionDescriptor) descriptor); - } else { - unknownDescriptors.add(descriptor); - } - } - } - - @Override - public String toString() { - final StringBuilder sb = new StringBuilder(); - sb.append("InitialObjectDescriptor"); - sb.append("{objectDescriptorId=").append(objectDescriptorId); - sb.append(", urlFlag=").append(urlFlag); - sb.append(", includeInlineProfileLevelFlag=").append(includeInlineProfileLevelFlag); - sb.append(", urlLength=").append(urlLength); - sb.append(", urlString='").append(urlString).append('\''); - sb.append(", oDProfileLevelIndication=").append(oDProfileLevelIndication); - sb.append(", sceneProfileLevelIndication=").append(sceneProfileLevelIndication); - sb.append(", audioProfileLevelIndication=").append(audioProfileLevelIndication); - sb.append(", visualProfileLevelIndication=").append(visualProfileLevelIndication); - sb.append(", graphicsProfileLevelIndication=").append(graphicsProfileLevelIndication); - sb.append(", esDescriptors=").append(esDescriptors); - sb.append(", extensionDescriptors=").append(extensionDescriptors); - sb.append(", unknownDescriptors=").append(unknownDescriptors); - sb.append('}'); - return sb.toString(); - } -} diff --git a/android-aac-enc/src/main/java/com/googlecode/mp4parser/boxes/mp4/objectdescriptors/ObjectDescriptor.java_bak b/android-aac-enc/src/main/java/com/googlecode/mp4parser/boxes/mp4/objectdescriptors/ObjectDescriptor.java_bak deleted file mode 100644 index 976fa0c0c..000000000 --- a/android-aac-enc/src/main/java/com/googlecode/mp4parser/boxes/mp4/objectdescriptors/ObjectDescriptor.java_bak +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Copyright 2011 castLabs, Berlin - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.googlecode.mp4parser.boxes.mp4.objectdescriptors; - -import com.coremedia.iso.IsoTypeReader; - -import java.io.IOException; -import java.nio.ByteBuffer; -import java.util.ArrayList; -import java.util.List; - -/* -class ObjectDescriptor extends ObjectDescriptorBase : bit(8) tag=ObjectDescrTag { -bit(10) ObjectDescriptorID; -bit(1) URL_Flag; -const bit(5) reserved=0b1111.1; -if (URL_Flag) { -bit(8) URLlength; -bit(8) URLstring[URLlength]; -} else { -ES_Descriptor esDescr[1 .. 255]; -OCI_Descriptor ociDescr[0 .. 255]; -IPMP_DescriptorPointer ipmpDescrPtr[0 .. 255]; -IPMP_Descriptor ipmpDescr [0 .. 255]; -} -ExtensionDescriptor extDescr[0 .. 255]; -} -*/ -@Descriptor(tags = {0x01, 0x11}) -public class ObjectDescriptor extends ObjectDescriptorBase { - private int objectDescriptorId; - int objectDescriptorUrlFlag; - int objectDescriptorUrlLength; - String objectDescriptorUrlString; - - - private int streamCount; - private int extensionFlag; - private List esDescriptors = new ArrayList(); - - private int descriptorLength; - private List extensionDescriptors = new ArrayList(); - - public static ObjectDescriptor createFrom(ByteBuffer in) throws IOException { -/* - tmp = in.readUInt16(); - esDescriptor.objectDescriptorId = tmp & 0x3f; - esDescriptor.objectDescriptorUrlFlag = (tmp >> 5) & 0x1; - if (esDescriptor.objectDescriptorUrlFlag == 1) { - esDescriptor.objectDescriptorUrlLength = in.readUInt8(); - esDescriptor.objectDescriptorUrlString = new String(in.read(esDescriptor.objectDescriptorUrlLength)); - } - */ - - ObjectDescriptor objectDescriptor = new ObjectDescriptor(); - - int data = IsoTypeReader.readUInt16(in); - - objectDescriptor.objectDescriptorId = data & 0xFFC0; - objectDescriptor.streamCount = data & 0x3E; - objectDescriptor.extensionFlag = data & 0x1; - -// for (int i = 0; i < objectDescriptor.streamCount; i++) { -// objectDescriptor.esDescriptors.add(ESDescriptor.createFrom(in)); -// } -// -// if (objectDescriptor.extensionFlag == 1) { -// objectDescriptor.descriptorLength = in.readUInt8(); -// for (int i = 0; i < objectDescriptor.descriptorLength;) { -// ExtensionDescriptor extensionDescriptor = ExtensionDescriptor.createFrom(in); -// objectDescriptor.extensionDescriptors.add(extensionDescriptor); -// i = i + extensionDescriptor.descriptorDataLength + 1; -// } -// } - - return objectDescriptor; - } - - @Override - public String toString() { - return "ObjectDescriptor{" + - "objectDescriptorId=" + objectDescriptorId + - ", streamCount=" + streamCount + - ", extensionFlag=" + extensionFlag + - ", esDescriptors=" + esDescriptors + - ", descriptorLength=" + descriptorLength + - ", extensionDescriptors=" + extensionDescriptors + - '}'; - } -} diff --git a/android-aac-enc/src/main/java/com/googlecode/mp4parser/boxes/mp4/objectdescriptors/ObjectDescriptorBase.java b/android-aac-enc/src/main/java/com/googlecode/mp4parser/boxes/mp4/objectdescriptors/ObjectDescriptorBase.java deleted file mode 100644 index 10a30c358..000000000 --- a/android-aac-enc/src/main/java/com/googlecode/mp4parser/boxes/mp4/objectdescriptors/ObjectDescriptorBase.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2011 castLabs, Berlin - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.googlecode.mp4parser.boxes.mp4.objectdescriptors; - -/* -abstract class ObjectDescriptorBase extends BaseDescriptor : bit(8) -tag=[ObjectDescrTag..InitialObjectDescrTag] { -// empty. To be filled by classes extending this class. -} - */ -@Descriptor(tags = 0x00) -public abstract class ObjectDescriptorBase extends BaseDescriptor { -} diff --git a/android-aac-enc/src/main/java/com/googlecode/mp4parser/boxes/mp4/objectdescriptors/ObjectDescriptorFactory.java b/android-aac-enc/src/main/java/com/googlecode/mp4parser/boxes/mp4/objectdescriptors/ObjectDescriptorFactory.java deleted file mode 100644 index 386150dee..000000000 --- a/android-aac-enc/src/main/java/com/googlecode/mp4parser/boxes/mp4/objectdescriptors/ObjectDescriptorFactory.java +++ /dev/null @@ -1,189 +0,0 @@ -/* - * Copyright 2011 castLabs, Berlin - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.googlecode.mp4parser.boxes.mp4.objectdescriptors; - -import com.coremedia.iso.IsoTypeReader; - -import java.io.IOException; -import java.lang.reflect.Modifier; -import java.nio.ByteBuffer; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; -import java.util.logging.Level; -import java.util.logging.Logger; - -/* class tag values of 14496-1 -0x00 Forbidden -0x01 ObjectDescrTag -0x02 InitialObjectDescrTag -0x03 ES_DescrTag -0x04 DecoderConfigDescrTag -0x05 DecSpecificInfoTag -0x06 SLConfigDescrTag -0x07 ContentIdentDescrTag -0x08 SupplContentIdentDescrTag -0x09 IPI_DescrPointerTag -0x0A IPMP_DescrPointerTag -0x0B IPMP_DescrTag -0x0C QoS_DescrTag -0x0D RegistrationDescrTag -0x0E ES_ID_IncTag -0x0F ES_ID_RefTag -0x10 MP4_IOD_Tag -0x11 MP4_OD_Tag -0x12 IPL_DescrPointerRefTag -0x13 ExtensionProfileLevelDescrTag -0x14 profileLevelIndicationIndexDescrTag -0x15-0x3F Reserved for ISO use -0x40 ContentClassificationDescrTag -0x41 KeyWordDescrTag -0x42 RatingDescrTag -0x43 LanguageDescrTag -0x44 ShortTextualDescrTag -0x45 ExpandedTextualDescrTag -0x46 ContentCreatorNameDescrTag -0x47 ContentCreationDateDescrTag -0x48 OCICreatorNameDescrTag -0x49 OCICreationDateDescrTag -0x4A SmpteCameraPositionDescrTag -0x4B SegmentDescrTag -0x4C MediaTimeDescrTag -0x4D-0x5F Reserved for ISO use (OCI extensions) -0x60 IPMP_ToolsListDescrTag -0x61 IPMP_ToolTag -0x62 M4MuxTimingDescrTag -0x63 M4MuxCodeTableDescrTag -0x64 ExtSLConfigDescrTag -0x65 M4MuxBufferSizeDescrTag -0x66 M4MuxIdentDescrTag -0x67 DependencyPointerTag -0x68 DependencyMarkerTag -0x69 M4MuxChannelDescrTag -0x6A-0xBF Reserved for ISO use -0xC0-0xFE User private -0xFF Forbidden - */ - -/* objectTypeIndication as of 14496-1 -0x00 Forbidden -0x01 Systems ISO/IEC 14496-1 a -0x02 Systems ISO/IEC 14496-1 b -0x03 Interaction Stream -0x04 Systems ISO/IEC 14496-1 Extended BIFS Configuration c -0x05 Systems ISO/IEC 14496-1 AFX d -0x06 Font Data Stream -0x07 Synthesized Texture Stream -0x08 Streaming Text Stream -0x09-0x1F reserved for ISO use -0x20 Visual ISO/IEC 14496-2 e -0x21 Visual ITU-T Recommendation H.264 | ISO/IEC 14496-10 f -0x22 Parameter Sets for ITU-T Recommendation H.264 | ISO/IEC 14496-10 f -0x23-0x3F reserved for ISO use -0x40 Audio ISO/IEC 14496-3 g -0x41-0x5F reserved for ISO use -0x60 Visual ISO/IEC 13818-2 Simple Profile -0x61 Visual ISO/IEC 13818-2 Main Profile -0x62 Visual ISO/IEC 13818-2 SNR Profile -0x63 Visual ISO/IEC 13818-2 Spatial Profile -0x64 Visual ISO/IEC 13818-2 High Profile -0x65 Visual ISO/IEC 13818-2 422 Profile -0x66 Audio ISO/IEC 13818-7 Main Profile -0x67 Audio ISO/IEC 13818-7 LowComplexity Profile -0x68 Audio ISO/IEC 13818-7 Scaleable Sampling Rate Profile -0x69 Audio ISO/IEC 13818-3 -0x6A Visual ISO/IEC 11172-2 -0x6B Audio ISO/IEC 11172-3 -0x6C Visual ISO/IEC 10918-1 -0x6D reserved for registration authority -0x6E Visual ISO/IEC 15444-1 -0x6F - 0x9F reserved for ISO use -0xA0 - 0xBF reserved for registration authority i -0xC0 - 0xE0 user private -0xE1 reserved for registration authority i -0xE2 - 0xFE user private -0xFF no object type specified h - */ -public class ObjectDescriptorFactory { - protected static Logger log = Logger.getLogger(ObjectDescriptorFactory.class.getName()); - - protected static Map>> descriptorRegistry = new HashMap>>(); - - static { - Set> annotated = new HashSet>(); - - annotated.add(DecoderSpecificInfo.class); - annotated.add(SLConfigDescriptor.class); - annotated.add(BaseDescriptor.class); - annotated.add(ExtensionDescriptor.class); - annotated.add(ObjectDescriptorBase.class); - annotated.add(ProfileLevelIndicationDescriptor.class); - annotated.add(AudioSpecificConfig.class); - annotated.add(ExtensionProfileLevelDescriptor.class); - annotated.add(ESDescriptor.class); - annotated.add(DecoderConfigDescriptor.class); - //annotated.add(ObjectDescriptor.class); - - for (Class clazz : annotated) { - final Descriptor descriptor = clazz.getAnnotation(Descriptor.class); - final int[] tags = descriptor.tags(); - final int objectTypeInd = descriptor.objectTypeIndication(); - - Map> tagMap = descriptorRegistry.get(objectTypeInd); - if (tagMap == null) { - tagMap = new HashMap>(); - } - for (int tag : tags) { - tagMap.put(tag, clazz); - } - descriptorRegistry.put(objectTypeInd, tagMap); - } - } - - public static BaseDescriptor createFrom(int objectTypeIndication, ByteBuffer bb) throws IOException { - int tag = IsoTypeReader.readUInt8(bb); - - Map> tagMap = descriptorRegistry.get(objectTypeIndication); - if (tagMap == null) { - tagMap = descriptorRegistry.get(-1); - } - Class aClass = tagMap.get(tag); - -// if (tag == 0x00) { -// log.warning("Found illegal tag 0x00! objectTypeIndication " + Integer.toHexString(objectTypeIndication) + -// " and tag " + Integer.toHexString(tag) + " using: " + aClass); -// aClass = BaseDescriptor.class; -// } - - BaseDescriptor baseDescriptor; - if (aClass == null || aClass.isInterface() || Modifier.isAbstract(aClass.getModifiers())) { - log.warning("No ObjectDescriptor found for objectTypeIndication " + Integer.toHexString(objectTypeIndication) + - " and tag " + Integer.toHexString(tag) + " found: " + aClass); - baseDescriptor = new UnknownDescriptor(); - } else { - try { - baseDescriptor = aClass.newInstance(); - } catch (Exception e) { - log.log(Level.SEVERE, "Couldn't instantiate BaseDescriptor class " + aClass + " for objectTypeIndication " + objectTypeIndication + " and tag " + tag, e); - throw new RuntimeException(e); - } - } - baseDescriptor.parse(tag, bb); - return baseDescriptor; - } -} diff --git a/android-aac-enc/src/main/java/com/googlecode/mp4parser/boxes/mp4/objectdescriptors/ProfileLevelIndicationDescriptor.java b/android-aac-enc/src/main/java/com/googlecode/mp4parser/boxes/mp4/objectdescriptors/ProfileLevelIndicationDescriptor.java deleted file mode 100644 index 5be9e2bbb..000000000 --- a/android-aac-enc/src/main/java/com/googlecode/mp4parser/boxes/mp4/objectdescriptors/ProfileLevelIndicationDescriptor.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright 2011 castLabs, Berlin - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.googlecode.mp4parser.boxes.mp4.objectdescriptors; - -import com.coremedia.iso.IsoTypeReader; - -import java.io.IOException; -import java.nio.ByteBuffer; - -/** - * class ProfileLevelIndicationIndexDescriptor () extends BaseDescriptor - * : bit(8) ProfileLevelIndicationIndexDescrTag { - * bit(8) profileLevelIndicationIndex; - * } - */ -@Descriptor(tags = 0x14) -public class ProfileLevelIndicationDescriptor extends BaseDescriptor { - int profileLevelIndicationIndex; - - @Override - public void parseDetail( ByteBuffer bb) throws IOException { - profileLevelIndicationIndex = IsoTypeReader.readUInt8(bb); - } - - @Override - public String toString() { - final StringBuilder sb = new StringBuilder(); - sb.append("ProfileLevelIndicationDescriptor"); - sb.append("{profileLevelIndicationIndex=").append(Integer.toHexString(profileLevelIndicationIndex)); - sb.append('}'); - return sb.toString(); - } -} diff --git a/android-aac-enc/src/main/java/com/googlecode/mp4parser/boxes/mp4/objectdescriptors/SLConfigDescriptor.java b/android-aac-enc/src/main/java/com/googlecode/mp4parser/boxes/mp4/objectdescriptors/SLConfigDescriptor.java deleted file mode 100644 index a964d4dc3..000000000 --- a/android-aac-enc/src/main/java/com/googlecode/mp4parser/boxes/mp4/objectdescriptors/SLConfigDescriptor.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright 2011 castLabs, Berlin - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.googlecode.mp4parser.boxes.mp4.objectdescriptors; - -import com.coremedia.iso.IsoTypeReader; -import com.coremedia.iso.IsoTypeWriter; - -import java.io.IOException; -import java.nio.ByteBuffer; - -/** - * class SLConfigDescriptor extends BaseDescriptor : bit(8) tag=SLConfigDescrTag { - * bit(8) predefined; - * if (predefined==0) { - * bit(1) useAccessUnitStartFlag; - * bit(1) useAccessUnitEndFlag; - * bit(1) useRandomAccessPointFlag; - * bit(1) hasRandomAccessUnitsOnlyFlag; - * bit(1) usePaddingFlag; - * bit(1) useTimeStampsFlag; - * bit(1) useIdleFlag; - * bit(1) durationFlag; - * bit(32) timeStampResolution; - * bit(32) OCRResolution; - * bit(8) timeStampLength; // must be ≤ 64 - * bit(8) OCRLength; // must be ≤ 64 - * bit(8) AU_Length; // must be ≤ 32 - * bit(8) instantBitrateLength; - * bit(4) degradationPriorityLength; - * bit(5) AU_seqNumLength; // must be ≤ 16 - * bit(5) packetSeqNumLength; // must be ≤ 16 - * bit(2) reserved=0b11; - * } - * if (durationFlag) { - * bit(32) timeScale; - * bit(16) accessUnitDuration; - * bit(16) compositionUnitDuration; - * } - * if (!useTimeStampsFlag) { - * bit(timeStampLength) startDecodingTimeStamp; - * bit(timeStampLength) startCompositionTimeStamp; - * } - * } - */ -@Descriptor(tags = {0x06}) -public class SLConfigDescriptor extends BaseDescriptor { - int predefined; - - public int getPredefined() { - return predefined; - } - - public void setPredefined(int predefined) { - this.predefined = predefined; - } - - @Override - public void parseDetail(ByteBuffer bb) throws IOException { - predefined = IsoTypeReader.readUInt8(bb); - } - - public int serializedSize() { - return 3; - } - - public ByteBuffer serialize() { - ByteBuffer out = ByteBuffer.allocate(3); - IsoTypeWriter.writeUInt8(out, 6); - IsoTypeWriter.writeUInt8(out, 1); - IsoTypeWriter.writeUInt8(out, predefined); - return out; - } - - @Override - public String toString() { - final StringBuilder sb = new StringBuilder(); - sb.append("SLConfigDescriptor"); - sb.append("{predefined=").append(predefined); - sb.append('}'); - return sb.toString(); - } -} diff --git a/android-aac-enc/src/main/java/com/googlecode/mp4parser/boxes/mp4/objectdescriptors/UnknownDescriptor.java b/android-aac-enc/src/main/java/com/googlecode/mp4parser/boxes/mp4/objectdescriptors/UnknownDescriptor.java deleted file mode 100644 index e7e08cf48..000000000 --- a/android-aac-enc/src/main/java/com/googlecode/mp4parser/boxes/mp4/objectdescriptors/UnknownDescriptor.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright 2011 castLabs, Berlin - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.googlecode.mp4parser.boxes.mp4.objectdescriptors; - -import java.io.IOException; -import java.nio.ByteBuffer; -import java.util.logging.Logger; - -public class UnknownDescriptor extends BaseDescriptor { - private ByteBuffer data; - private static Logger log = Logger.getLogger(UnknownDescriptor.class.getName()); - - @Override - public void parseDetail(ByteBuffer bb) throws IOException { - data = (ByteBuffer) bb.slice().limit(this.getSizeOfInstance()); - } - - @Override - public String toString() { - final StringBuilder sb = new StringBuilder(); - sb.append("UnknownDescriptor"); - sb.append("{tag=").append(tag); - sb.append(", sizeOfInstance=").append(sizeOfInstance); - sb.append(", data=").append(data); - sb.append('}'); - return sb.toString(); - } -} diff --git a/android-aac-enc/src/main/java/com/googlecode/mp4parser/boxes/piff/PiffSampleEncryptionBox.java b/android-aac-enc/src/main/java/com/googlecode/mp4parser/boxes/piff/PiffSampleEncryptionBox.java deleted file mode 100644 index da3512d75..000000000 --- a/android-aac-enc/src/main/java/com/googlecode/mp4parser/boxes/piff/PiffSampleEncryptionBox.java +++ /dev/null @@ -1,45 +0,0 @@ -package com.googlecode.mp4parser.boxes.piff; - -import com.googlecode.mp4parser.boxes.AbstractSampleEncryptionBox; - -/** - *
    - * aligned(8) class SampleEncryptionBox extends FullBox(‘uuid’, extended_type= 0xA2394F52-5A9B-4f14-A244-6C427C648DF4, version=0, flags=0)
    - * {
    - *  if (flags & 0x000001)
    - *  {
    - *   unsigned int(24) AlgorithmID;
    - *   unsigned int(8) IV_size;
    - *   unsigned int(8)[16] KID;
    - *  }
    - *  unsigned int (32) sample_count;
    - *  {
    - *   unsigned int(IV_size) InitializationVector;
    - *   if (flags & 0x000002)
    - *   {
    - *    unsigned int(16) NumberOfEntries;
    - *    {
    - *     unsigned int(16) BytesOfClearData;
    - *     unsigned int(32) BytesOfEncryptedData;
    - *    } [ NumberOfEntries]
    - *   }
    - *  }[ sample_count ]
    - * }
    - * 
    - */ -public class PiffSampleEncryptionBox extends AbstractSampleEncryptionBox { - - /** - * Creates a AbstractSampleEncryptionBox for non-h264 tracks. - */ - public PiffSampleEncryptionBox() { - super("uuid"); - - } - - @Override - public byte[] getUserType() { - return new byte[]{(byte) 0xA2, 0x39, 0x4F, 0x52, 0x5A, (byte) 0x9B, 0x4f, 0x14, (byte) 0xA2, 0x44, 0x6C, 0x42, 0x7C, 0x64, (byte) 0x8D, (byte) 0xF4}; - } - -} diff --git a/android-aac-enc/src/main/java/com/googlecode/mp4parser/boxes/piff/PiffTrackEncryptionBox.java b/android-aac-enc/src/main/java/com/googlecode/mp4parser/boxes/piff/PiffTrackEncryptionBox.java deleted file mode 100644 index f92c0f3ec..000000000 --- a/android-aac-enc/src/main/java/com/googlecode/mp4parser/boxes/piff/PiffTrackEncryptionBox.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.googlecode.mp4parser.boxes.piff; - -import com.googlecode.mp4parser.boxes.AbstractTrackEncryptionBox; - -/** - * aligned(8) class TrackEncryptionBox extends FullBox(‘uuid’, - * extended_type=0x8974dbce-7be7-4c51-84f9-7148f9882554, version=0, - * flags=0) - * { - * unsigned int(24) default_AlgorithmID; - * unsigned int(8) default_IV_size; - * unsigned int(8)[16] default_KID; - * } - */ -public class PiffTrackEncryptionBox extends AbstractTrackEncryptionBox { - - - public PiffTrackEncryptionBox() { - super("uuid"); - } - - @Override - public byte[] getUserType() { - return new byte[]{(byte) 0x89, 0x74, (byte) 0xdb, (byte) 0xce, 0x7b, (byte) 0xe7, 0x4c, 0x51, - (byte) 0x84, (byte) 0xf9, 0x71, 0x48, (byte) 0xf9, (byte) 0x88, 0x25, 0x54}; - } - - @Override - public int getFlags() { - return 0; - } - - -} diff --git a/android-aac-enc/src/main/java/com/googlecode/mp4parser/boxes/piff/PlayReadyHeader.java b/android-aac-enc/src/main/java/com/googlecode/mp4parser/boxes/piff/PlayReadyHeader.java deleted file mode 100644 index 74246d06d..000000000 --- a/android-aac-enc/src/main/java/com/googlecode/mp4parser/boxes/piff/PlayReadyHeader.java +++ /dev/null @@ -1,253 +0,0 @@ -package com.googlecode.mp4parser.boxes.piff; - -import com.coremedia.iso.IsoFile; -import com.coremedia.iso.IsoTypeReader; -import com.coremedia.iso.IsoTypeWriter; -import com.googlecode.mp4parser.util.Path; - -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.UnsupportedEncodingException; -import java.nio.ByteBuffer; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -/** - * Specifications > Microsoft PlayReady Format Specification > 2. PlayReady Media Format > 2.7. ASF GUIDs - *

    - *

    - * ASF_Protection_System_Identifier_Object - * 9A04F079-9840-4286-AB92E65BE0885F95 - *

    - * ASF_Content_Protection_System_Microsoft_PlayReady - * F4637010-03C3-42CD-B932B48ADF3A6A54 - *

    - * ASF_StreamType_PlayReady_Encrypted_Command_Media - * 8683973A-6639-463A-ABD764F1CE3EEAE0 - *

    - *

    - * Specifications > Microsoft PlayReady Format Specification > 2. PlayReady Media Format > 2.5. Data Objects > 2.5.1. Payload Extension for AES in Counter Mode - *

    - * The sample Id is used as the IV in CTR mode. Block offset, starting at 0 and incremented by 1 after every 16 bytes, from the beginning of the sample is used as the Counter. - *

    - * The sample ID for each sample (media object) is stored as an ASF payload extension system with the ID of ASF_Payload_Extension_Encryption_SampleID = {6698B84E-0AFA-4330-AEB2-1C0A98D7A44D}. The payload extension can be stored as a fixed size extension of 8 bytes. - *

    - * The sample ID is always stored in big-endian byte order. - */ -public class PlayReadyHeader extends ProtectionSpecificHeader { - private long length; - private List records; - - public PlayReadyHeader() { - - } - - @Override - public void parse(ByteBuffer byteBuffer) { - /* - Length DWORD 32 - - PlayReady Record Count WORD 16 - - PlayReady Records See Text Varies - - */ - - length = IsoTypeReader.readUInt32BE(byteBuffer); - int recordCount = IsoTypeReader.readUInt16BE(byteBuffer); - - records = PlayReadyRecord.createFor(byteBuffer, recordCount); - } - - @Override - public ByteBuffer getData() { - - int size = 4 + 2; - for (PlayReadyRecord record : records) { - size += 2 + 2; - size += record.getValue().rewind().limit(); - } - ByteBuffer byteBuffer = ByteBuffer.allocate(size); - - IsoTypeWriter.writeUInt32BE(byteBuffer, size); - IsoTypeWriter.writeUInt16BE(byteBuffer, records.size()); - for (PlayReadyRecord record : records) { - IsoTypeWriter.writeUInt16BE(byteBuffer, record.type); - IsoTypeWriter.writeUInt16BE(byteBuffer, record.getValue().limit()); - ByteBuffer tmp4debug = record.getValue(); - byteBuffer.put(tmp4debug); - } - - return byteBuffer; - } - - public void setRecords(List records) { - this.records = records; - } - - public List getRecords() { - return Collections.unmodifiableList(records); - } - - @Override - public String toString() { - final StringBuilder sb = new StringBuilder(); - sb.append("PlayReadyHeader"); - sb.append("{length=").append(length); - sb.append(", recordCount=").append(records.size()); - sb.append(", records=").append(records); - sb.append('}'); - return sb.toString(); - } - - public static abstract class PlayReadyRecord { - int type; - - - public PlayReadyRecord(int type) { - this.type = type; - } - - public static List createFor(ByteBuffer byteBuffer, int recordCount) { - List records = new ArrayList(recordCount); - - for (int i = 0; i < recordCount; i++) { - PlayReadyRecord record; - int type = IsoTypeReader.readUInt16BE(byteBuffer); - int length = IsoTypeReader.readUInt16BE(byteBuffer); - switch (type) { - case 0x1: - record = new RMHeader(); - break; - case 0x2: - record = new DefaulPlayReadyRecord(0x02); - break; - case 0x3: - record = new EmeddedLicenseStore(); - break; - default: - record = new DefaulPlayReadyRecord(type); - } - record.parse((ByteBuffer) byteBuffer.slice().limit(length)); - byteBuffer.position(byteBuffer.position() + length); - records.add(record); - } - - return records; - } - - public abstract void parse(ByteBuffer bytes); - - @Override - public String toString() { - final StringBuilder sb = new StringBuilder(); - sb.append("PlayReadyRecord"); - sb.append("{type=").append(type); - sb.append(", length=").append(getValue().limit()); -// sb.append(", value=").append(Hex.encodeHex(getValue())).append('\''); - sb.append('}'); - return sb.toString(); - } - - public abstract ByteBuffer getValue(); - - public static class RMHeader extends PlayReadyRecord { - String header; - - public RMHeader() { - super(0x01); - } - - @Override - public void parse(ByteBuffer bytes) { - try { - byte[] str = new byte[bytes.slice().limit()]; - bytes.get(str); - header = new String(str, "UTF-16LE"); - } catch (UnsupportedEncodingException e) { - throw new RuntimeException(e); - } - } - - @Override - public ByteBuffer getValue() { - byte[] headerBytes; - try { - headerBytes = header.getBytes("UTF-16LE"); - } catch (UnsupportedEncodingException e) { - throw new RuntimeException(e); - } - return ByteBuffer.wrap(headerBytes); - } - - public void setHeader(String header) { - this.header = header; - } - - public String getHeader() { - return header; - } - - @Override - public String toString() { - final StringBuilder sb = new StringBuilder(); - sb.append("RMHeader"); - sb.append("{length=").append(getValue().limit()); - sb.append(", header='").append(header).append('\''); - sb.append('}'); - return sb.toString(); - } - } - - public static class EmeddedLicenseStore extends PlayReadyRecord { - ByteBuffer value; - - public EmeddedLicenseStore() { - super(0x03); - } - - @Override - public void parse(ByteBuffer bytes) { - this.value = bytes.duplicate(); - } - - @Override - public ByteBuffer getValue() { - return value; - } - - @Override - public String toString() { - final StringBuilder sb = new StringBuilder(); - sb.append("EmeddedLicenseStore"); - sb.append("{length=").append(getValue().limit()); - //sb.append(", value='").append(Hex.encodeHex(getValue())).append('\''); - sb.append('}'); - return sb.toString(); - } - } - - public static class DefaulPlayReadyRecord extends PlayReadyRecord { - ByteBuffer value; - - public DefaulPlayReadyRecord(int type) { - super(type); - } - - @Override - public void parse(ByteBuffer bytes) { - this.value = bytes.duplicate(); - } - - @Override - public ByteBuffer getValue() { - return value; - } - - } - - } - -} diff --git a/android-aac-enc/src/main/java/com/googlecode/mp4parser/boxes/piff/ProtectionSpecificHeader.java b/android-aac-enc/src/main/java/com/googlecode/mp4parser/boxes/piff/ProtectionSpecificHeader.java deleted file mode 100644 index 0d2f344c4..000000000 --- a/android-aac-enc/src/main/java/com/googlecode/mp4parser/boxes/piff/ProtectionSpecificHeader.java +++ /dev/null @@ -1,79 +0,0 @@ -package com.googlecode.mp4parser.boxes.piff; - - -import com.coremedia.iso.Hex; - -import java.lang.Class; -import java.lang.IllegalAccessException; -import java.lang.InstantiationException; -import java.lang.Object; -import java.lang.Override; -import java.lang.RuntimeException; -import java.lang.String; -import java.lang.StringBuilder; -import java.nio.ByteBuffer; -import java.util.HashMap; -import java.util.Map; -import java.util.UUID; - - -public class ProtectionSpecificHeader { - protected static Map> uuidRegistry = new HashMap>(); - ByteBuffer data; - - static { - uuidRegistry.put(UUID.fromString("9A04F079-9840-4286-AB92-E65BE0885F95"), PlayReadyHeader.class); - } - - @Override - public boolean equals(Object obj) { - if (obj instanceof ProtectionSpecificHeader) { - if (this.getClass().equals(obj.getClass())) { - return data.equals(((ProtectionSpecificHeader) obj).data); - } - } - return false; - } - - public static ProtectionSpecificHeader createFor(UUID systemId, ByteBuffer bufferWrapper) { - final Class aClass = uuidRegistry.get(systemId); - - ProtectionSpecificHeader protectionSpecificHeader = new ProtectionSpecificHeader(); - if (aClass != null) { - try { - protectionSpecificHeader = aClass.newInstance(); - - } catch (InstantiationException e) { - throw new RuntimeException(e); - } catch (IllegalAccessException e) { - throw new RuntimeException(e); - } - } - protectionSpecificHeader.parse(bufferWrapper); - return protectionSpecificHeader; - - } - - public void parse(ByteBuffer buffer) { - data = buffer; - - } - - public ByteBuffer getData() { - return data; - } - - @Override - public String toString() { - final StringBuilder sb = new StringBuilder(); - sb.append("ProtectionSpecificHeader"); - sb.append("{data="); - ByteBuffer data = getData().duplicate(); - data.rewind(); - byte[] bytes = new byte[data.limit()]; - data.get(bytes); - sb.append(Hex.encodeHex(bytes)); - sb.append('}'); - return sb.toString(); - } -} diff --git a/android-aac-enc/src/main/java/com/googlecode/mp4parser/boxes/piff/TfrfBox.java b/android-aac-enc/src/main/java/com/googlecode/mp4parser/boxes/piff/TfrfBox.java deleted file mode 100644 index 5dce9c4a6..000000000 --- a/android-aac-enc/src/main/java/com/googlecode/mp4parser/boxes/piff/TfrfBox.java +++ /dev/null @@ -1,129 +0,0 @@ -package com.googlecode.mp4parser.boxes.piff; - -import com.coremedia.iso.IsoTypeReader; -import com.coremedia.iso.IsoTypeWriter; -import com.googlecode.mp4parser.AbstractFullBox; - -import java.nio.ByteBuffer; -import java.util.ArrayList; -import java.util.List; - -/** - * The syntax of the fields defined in this section, specified in ABNF [RFC5234], is as follows: - * TfrfBox = TfrfBoxLength TfrfBoxType [TfrfBoxLongLength] TfrfBoxUUID TfrfBoxFields - * TfrfBoxChildren - * TfrfBoxType = "u" "u" "i" "d" - * TfrfBoxLength = BoxLength - * TfrfBoxLongLength = LongBoxLength - * TfrfBoxUUID = %xD4 %x80 %x7E %xF2 %xCA %x39 %x46 %x95 - * %x8E %x54 %x26 %xCB %x9E %x46 %xA7 %x9F - * TfrfBoxFields = TfrfBoxVersion - * TfrfBoxFlags - * FragmentCount - * (1* TfrfBoxDataFields32) / (1* TfrfBoxDataFields64) - * TfrfBoxVersion = %x00 / %x01 - * TfrfBoxFlags = 24*24 RESERVED_BIT - * FragmentCount = UINT8 - * TfrfBoxDataFields32 = FragmentAbsoluteTime32 - * FragmentDuration32 - * TfrfBoxDataFields64 = FragmentAbsoluteTime64 - * FragmentDuration64 - * FragmentAbsoluteTime64 = UNSIGNED_INT32 - * FragmentDuration64 = UNSIGNED_INT32 - * FragmentAbsoluteTime64 = UNSIGNED_INT64 - * FragmentDuration64 = UNSIGNED_INT64 - * TfrfBoxChildren = *( VendorExtensionUUIDBox ) - */ -public class TfrfBox extends AbstractFullBox { - public List entries = new ArrayList(); - - public TfrfBox() { - super("uuid"); - } - - @Override - public byte[] getUserType() { - return new byte[]{(byte) 0xd4, (byte) 0x80, (byte) 0x7e, (byte) 0xf2, (byte) 0xca, (byte) 0x39, (byte) 0x46, - (byte) 0x95, (byte) 0x8e, (byte) 0x54, 0x26, (byte) 0xcb, (byte) 0x9e, (byte) 0x46, (byte) 0xa7, (byte) 0x9f}; - } - - @Override - protected long getContentSize() { - return 5 + entries.size() * (getVersion() == 0x01 ? 16 : 8); - } - - @Override - protected void getContent(ByteBuffer byteBuffer) { - writeVersionAndFlags(byteBuffer); - IsoTypeWriter.writeUInt8(byteBuffer, entries.size()); - - for (Entry entry : entries) { - if (getVersion() == 0x01) { - IsoTypeWriter.writeUInt64(byteBuffer, entry.fragmentAbsoluteTime); - IsoTypeWriter.writeUInt64(byteBuffer, entry.fragmentAbsoluteDuration); - } else { - IsoTypeWriter.writeUInt32(byteBuffer, entry.fragmentAbsoluteTime); - IsoTypeWriter.writeUInt32(byteBuffer, entry.fragmentAbsoluteDuration); - } - } - } - - @Override - public void _parseDetails(ByteBuffer content) { - parseVersionAndFlags(content); - int fragmentCount = IsoTypeReader.readUInt8(content); - - for (int i = 0; i < fragmentCount; i++) { - Entry entry = new Entry(); - if (getVersion() == 0x01) { - entry.fragmentAbsoluteTime = IsoTypeReader.readUInt64(content); - entry.fragmentAbsoluteDuration = IsoTypeReader.readUInt64(content); - } else { - entry.fragmentAbsoluteTime = IsoTypeReader.readUInt32(content); - entry.fragmentAbsoluteDuration = IsoTypeReader.readUInt32(content); - } - entries.add(entry); - } - } - - - public long getFragmentCount() { - return entries.size(); - } - - public List getEntries() { - return entries; - } - - @Override - public String toString() { - final StringBuilder sb = new StringBuilder(); - sb.append("TfrfBox"); - sb.append("{entries=").append(entries); - sb.append('}'); - return sb.toString(); - } - - public class Entry { - long fragmentAbsoluteTime; - long fragmentAbsoluteDuration; - - public long getFragmentAbsoluteTime() { - return fragmentAbsoluteTime; - } - - public long getFragmentAbsoluteDuration() { - return fragmentAbsoluteDuration; - } - - @Override - public String toString() { - final StringBuilder sb = new StringBuilder(); - sb.append("Entry"); - sb.append("{fragmentAbsoluteTime=").append(fragmentAbsoluteTime); - sb.append(", fragmentAbsoluteDuration=").append(fragmentAbsoluteDuration); - sb.append('}'); - return sb.toString(); - } - } -} diff --git a/android-aac-enc/src/main/java/com/googlecode/mp4parser/boxes/piff/TfxdBox.java b/android-aac-enc/src/main/java/com/googlecode/mp4parser/boxes/piff/TfxdBox.java deleted file mode 100644 index 99e17463b..000000000 --- a/android-aac-enc/src/main/java/com/googlecode/mp4parser/boxes/piff/TfxdBox.java +++ /dev/null @@ -1,85 +0,0 @@ -package com.googlecode.mp4parser.boxes.piff; - -import com.coremedia.iso.IsoTypeReader; -import com.coremedia.iso.IsoTypeWriter; -import com.googlecode.mp4parser.AbstractFullBox; - -import java.nio.ByteBuffer; - -/** - * The syntax of the fields defined in this section, specified in ABNF [RFC5234], is as follows: - * TfxdBox = TfxdBoxLength TfxdBoxType [TfxdBoxLongLength] TfxdBoxUUID TfxdBoxFields - * TfxdBoxChildren - * TfxdBoxType = "u" "u" "i" "d" - * TfxdBoxLength = BoxLength - * TfxdBoxLongLength = LongBoxLength - * TfxdBoxUUID = %x6D %x1D %x9B %x05 %x42 %xD5 %x44 %xE6 - * %x80 %xE2 %x14 %x1D %xAF %xF7 %x57 %xB2 - * TfxdBoxFields = TfxdBoxVersion - * TfxdBoxFlags - * TfxdBoxDataFields32 / TfxdBoxDataFields64 - * TfxdBoxVersion = %x00 / %x01 - * TfxdBoxFlags = 24*24 RESERVED_BIT - * TfxdBoxDataFields32 = FragmentAbsoluteTime32 - * FragmentDuration32 - * TfxdBoxDataFields64 = FragmentAbsoluteTime64 - * FragmentDuration64 - * FragmentAbsoluteTime64 = UNSIGNED_INT32 - * FragmentDuration64 = UNSIGNED_INT32 - * FragmentAbsoluteTime64 = UNSIGNED_INT64 - * FragmentDuration64 = UNSIGNED_INT64 - * TfxdBoxChildren = *( VendorExtensionUUIDBox ) - */ -//@ExtendedUserType(uuid = "6d1d9b05-42d5-44e6-80e2-141daff757b2") -public class TfxdBox extends AbstractFullBox { - public long fragmentAbsoluteTime; - public long fragmentAbsoluteDuration; - - public TfxdBox() { - super("uuid"); - } - - @Override - public byte[] getUserType() { - return new byte[]{(byte) 0x6d, (byte) 0x1d, (byte) 0x9b, (byte) 0x05, (byte) 0x42, (byte) 0xd5, (byte) 0x44, - (byte) 0xe6, (byte) 0x80, (byte) 0xe2, 0x14, (byte) 0x1d, (byte) 0xaf, (byte) 0xf7, (byte) 0x57, (byte) 0xb2}; - } - - @Override - protected long getContentSize() { - return getVersion() == 0x01 ? 20 : 12; - } - - @Override - public void _parseDetails(ByteBuffer content) { - parseVersionAndFlags(content); - - if (getVersion() == 0x01) { - fragmentAbsoluteTime = IsoTypeReader.readUInt64(content); - fragmentAbsoluteDuration = IsoTypeReader.readUInt64(content); - } else { - fragmentAbsoluteTime = IsoTypeReader.readUInt32(content); - fragmentAbsoluteDuration = IsoTypeReader.readUInt32(content); - } - } - - @Override - protected void getContent(ByteBuffer byteBuffer) { - writeVersionAndFlags(byteBuffer); - if (getVersion() == 0x01) { - IsoTypeWriter.writeUInt64(byteBuffer, fragmentAbsoluteTime); - IsoTypeWriter.writeUInt64(byteBuffer, fragmentAbsoluteDuration); - } else { - IsoTypeWriter.writeUInt32(byteBuffer, fragmentAbsoluteTime); - IsoTypeWriter.writeUInt32(byteBuffer, fragmentAbsoluteDuration); - } - } - - public long getFragmentAbsoluteTime() { - return fragmentAbsoluteTime; - } - - public long getFragmentAbsoluteDuration() { - return fragmentAbsoluteDuration; - } -} diff --git a/android-aac-enc/src/main/java/com/googlecode/mp4parser/boxes/piff/UuidBasedProtectionSystemSpecificHeaderBox.java b/android-aac-enc/src/main/java/com/googlecode/mp4parser/boxes/piff/UuidBasedProtectionSystemSpecificHeaderBox.java deleted file mode 100644 index a20c92922..000000000 --- a/android-aac-enc/src/main/java/com/googlecode/mp4parser/boxes/piff/UuidBasedProtectionSystemSpecificHeaderBox.java +++ /dev/null @@ -1,112 +0,0 @@ -package com.googlecode.mp4parser.boxes.piff; - -import com.coremedia.iso.IsoFile; -import com.coremedia.iso.IsoTypeReader; -import com.coremedia.iso.IsoTypeWriter; -import com.googlecode.mp4parser.AbstractFullBox; -import com.googlecode.mp4parser.util.Path; -import com.googlecode.mp4parser.util.UUIDConverter; - -import java.io.FileInputStream; -import java.io.IOException; -import java.lang.Override;import java.lang.String;import java.lang.StringBuilder;import java.nio.ByteBuffer; -import java.util.UUID; - -import static com.googlecode.mp4parser.util.CastUtils.l2i; - -/** - * aligned(8) class UuidBasedProtectionSystemSpecificHeaderBox extends FullBox(‘uuid’, - * extended_type=0xd08a4f18-10f3-4a82-b6c8-32d8aba183d3, - * version=0, flags=0) - * { - * unsigned int(8)[16] SystemID; - * unsigned int(32) DataSize; - * unsigned int(8)[DataSize] Data; - * } - */ -public class UuidBasedProtectionSystemSpecificHeaderBox extends AbstractFullBox { - public static byte[] USER_TYPE = new byte[]{(byte) 0xd0, (byte) 0x8a, 0x4f, 0x18, 0x10, (byte) 0xf3, 0x4a, (byte) 0x82, - (byte) 0xb6, (byte) 0xc8, 0x32, (byte) 0xd8, (byte) 0xab, (byte) 0xa1, (byte) 0x83, (byte) 0xd3}; - - UUID systemId; - - ProtectionSpecificHeader protectionSpecificHeader; - - public UuidBasedProtectionSystemSpecificHeaderBox() { - super("uuid", USER_TYPE); - } - - @Override - protected long getContentSize() { - return 24 + protectionSpecificHeader.getData().limit(); - } - - @Override - public byte[] getUserType() { - return USER_TYPE; - } - - @Override - protected void getContent(ByteBuffer byteBuffer) { - writeVersionAndFlags(byteBuffer); - IsoTypeWriter.writeUInt64(byteBuffer, systemId.getMostSignificantBits()); - IsoTypeWriter.writeUInt64(byteBuffer, systemId.getLeastSignificantBits()); - ByteBuffer data = protectionSpecificHeader.getData(); - data.rewind(); - IsoTypeWriter.writeUInt32(byteBuffer, data.limit()); - byteBuffer.put(data); - } - - @Override - protected void _parseDetails(ByteBuffer content) { - parseVersionAndFlags(content); - byte[] systemIdBytes = new byte[16]; - content.get(systemIdBytes); - systemId = UUIDConverter.convert(systemIdBytes); - int dataSize = l2i(IsoTypeReader.readUInt32(content)); - protectionSpecificHeader = ProtectionSpecificHeader.createFor(systemId, content); - } - - public UUID getSystemId() { - return systemId; - } - - public void setSystemId(UUID systemId) { - this.systemId = systemId; - } - - public String getSystemIdString() { - return systemId.toString(); - } - - public ProtectionSpecificHeader getProtectionSpecificHeader() { - return protectionSpecificHeader; - } - - public String getProtectionSpecificHeaderString() { - return protectionSpecificHeader.toString(); - } - - public void setProtectionSpecificHeader(ProtectionSpecificHeader protectionSpecificHeader) { - this.protectionSpecificHeader = protectionSpecificHeader; - } - - @Override - public String toString() { - final StringBuilder sb = new StringBuilder(); - sb.append("UuidBasedProtectionSystemSpecificHeaderBox"); - sb.append("{systemId=").append(systemId.toString()); - sb.append(", dataSize=").append(protectionSpecificHeader.getData().limit()); - sb.append('}'); - return sb.toString(); - } - - - public static void main(String[] args) throws IOException { - IsoFile isoFile = new IsoFile(new FileInputStream("/home/sannies/aaa/FBW_fixedres_B_640x360_400.ismv").getChannel()); - Path p = new Path(isoFile); - UuidBasedProtectionSystemSpecificHeaderBox pssh = (UuidBasedProtectionSystemSpecificHeaderBox) p.getPath("/moov/uuid"); - pssh.getSystemIdString(); - } - -} diff --git a/android-aac-enc/src/main/java/com/googlecode/mp4parser/boxes/threegpp26245/FontTableBox.java b/android-aac-enc/src/main/java/com/googlecode/mp4parser/boxes/threegpp26245/FontTableBox.java deleted file mode 100644 index 2e3f640c1..000000000 --- a/android-aac-enc/src/main/java/com/googlecode/mp4parser/boxes/threegpp26245/FontTableBox.java +++ /dev/null @@ -1,95 +0,0 @@ -package com.googlecode.mp4parser.boxes.threegpp26245; - -import com.coremedia.iso.IsoTypeReader; -import com.coremedia.iso.IsoTypeWriter; -import com.coremedia.iso.Utf8; -import com.googlecode.mp4parser.AbstractBox; - -import java.io.IOException; -import java.nio.ByteBuffer; -import java.util.LinkedList; -import java.util.List; - -/** - * - */ -public class FontTableBox extends AbstractBox { - List entries = new LinkedList(); - - public FontTableBox() { - super("ftab"); - } - - @Override - protected long getContentSize() { - int size = 2; - for (FontRecord fontRecord : entries) { - size += fontRecord.getSize(); - } - return size; - } - - - @Override - public void _parseDetails(ByteBuffer content) { - int numberOfRecords = IsoTypeReader.readUInt16(content); - for (int i = 0; i < numberOfRecords; i++) { - FontRecord fr = new FontRecord(); - fr.parse(content); - entries.add(fr); - } - } - - @Override - protected void getContent(ByteBuffer byteBuffer) { - IsoTypeWriter.writeUInt16(byteBuffer, entries.size()); - for (FontRecord record : entries) { - record.getContent(byteBuffer); - } - } - - public List getEntries() { - return entries; - } - - public void setEntries(List entries) { - this.entries = entries; - } - - public static class FontRecord { - int fontId; - String fontname; - - public FontRecord() { - } - - public FontRecord(int fontId, String fontname) { - this.fontId = fontId; - this.fontname = fontname; - } - - public void parse(ByteBuffer bb) { - fontId = IsoTypeReader.readUInt16(bb); - int length = IsoTypeReader.readUInt8(bb); - fontname = IsoTypeReader.readString(bb, length); - } - - public void getContent(ByteBuffer bb) { - IsoTypeWriter.writeUInt16(bb, fontId); - IsoTypeWriter.writeUInt8(bb, fontname.length()); - bb.put(Utf8.convert(fontname)); - } - - public int getSize() { - return Utf8.utf8StringLengthInBytes(fontname) + 3; - } - - @Override - public String toString() { - return "FontRecord{" + - "fontId=" + fontId + - ", fontname='" + fontname + '\'' + - '}'; - } - } -} diff --git a/android-aac-enc/src/main/java/com/googlecode/mp4parser/boxes/ultraviolet/AssetInformationBox.java b/android-aac-enc/src/main/java/com/googlecode/mp4parser/boxes/ultraviolet/AssetInformationBox.java deleted file mode 100644 index a2a9e8a21..000000000 --- a/android-aac-enc/src/main/java/com/googlecode/mp4parser/boxes/ultraviolet/AssetInformationBox.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright 2011 castLabs, Berlin - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.googlecode.mp4parser.boxes.ultraviolet; - -import com.coremedia.iso.IsoTypeReader; -import com.coremedia.iso.Utf8; -import com.googlecode.mp4parser.AbstractFullBox; - -import java.nio.ByteBuffer; - -/** - * AssetInformationBox as defined Common File Format Spec. - */ -public class AssetInformationBox extends AbstractFullBox { - String apid = ""; - String profileVersion = "0000"; - - public AssetInformationBox() { - super("ainf"); - } - - @Override - protected long getContentSize() { - return Utf8.utf8StringLengthInBytes(apid) + 9; - } - - - @Override - protected void getContent(ByteBuffer byteBuffer) { - writeVersionAndFlags(byteBuffer); - byteBuffer.put(Utf8.convert(profileVersion), 0, 4); - byteBuffer.put(Utf8.convert(apid)); - byteBuffer.put((byte) 0); - } - - - @Override - public void _parseDetails(ByteBuffer content) { - parseVersionAndFlags(content); - profileVersion = IsoTypeReader.readString(content, 4); - apid = IsoTypeReader.readString(content); - content = null; - } - - public String getApid() { - return apid; - } - - public void setApid(String apid) { - this.apid = apid; - } - - public String getProfileVersion() { - return profileVersion; - } - - public void setProfileVersion(String profileVersion) { - assert profileVersion != null && profileVersion.length() == 4; - this.profileVersion = profileVersion; - } -} diff --git a/android-aac-enc/src/main/java/com/googlecode/mp4parser/boxes/ultraviolet/BaseLocationBox.java b/android-aac-enc/src/main/java/com/googlecode/mp4parser/boxes/ultraviolet/BaseLocationBox.java deleted file mode 100644 index 1c63293e0..000000000 --- a/android-aac-enc/src/main/java/com/googlecode/mp4parser/boxes/ultraviolet/BaseLocationBox.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Copyright 2011 castLabs, Berlin - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.googlecode.mp4parser.boxes.ultraviolet; - -import com.coremedia.iso.IsoTypeReader; -import com.coremedia.iso.Utf8; -import com.googlecode.mp4parser.AbstractFullBox; - -import java.nio.ByteBuffer; - -/** - * - */ -public class BaseLocationBox extends AbstractFullBox { - String baseLocation = ""; - String purchaseLocation = ""; - - public BaseLocationBox() { - super("bloc"); - } - - public BaseLocationBox(String baseLocation, String purchaseLocation) { - super("bloc"); - this.baseLocation = baseLocation; - this.purchaseLocation = purchaseLocation; - } - - public String getBaseLocation() { - return baseLocation; - } - - public void setBaseLocation(String baseLocation) { - this.baseLocation = baseLocation; - } - - public String getPurchaseLocation() { - return purchaseLocation; - } - - public void setPurchaseLocation(String purchaseLocation) { - this.purchaseLocation = purchaseLocation; - } - - @Override - protected long getContentSize() { - return 1028; - } - - @Override - public void _parseDetails(ByteBuffer content) { - parseVersionAndFlags(content); - baseLocation = IsoTypeReader.readString(content); - content.get(new byte[256 - Utf8.utf8StringLengthInBytes(baseLocation) - 1]); - purchaseLocation = IsoTypeReader.readString(content); - content.get(new byte[256 - Utf8.utf8StringLengthInBytes(purchaseLocation) - 1]); - content.get(new byte[512]); - } - - @Override - protected void getContent(ByteBuffer byteBuffer) { - writeVersionAndFlags(byteBuffer); - byteBuffer.put(Utf8.convert(baseLocation)); - byteBuffer.put(new byte[256 - Utf8.utf8StringLengthInBytes(baseLocation)]); // string plus term zero - byteBuffer.put(Utf8.convert(purchaseLocation)); - byteBuffer.put(new byte[256 - Utf8.utf8StringLengthInBytes(purchaseLocation)]); // string plus term zero - byteBuffer.put(new byte[512]); - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - BaseLocationBox that = (BaseLocationBox) o; - - if (baseLocation != null ? !baseLocation.equals(that.baseLocation) : that.baseLocation != null) return false; - if (purchaseLocation != null ? !purchaseLocation.equals(that.purchaseLocation) : that.purchaseLocation != null) - return false; - - return true; - } - - @Override - public int hashCode() { - int result = baseLocation != null ? baseLocation.hashCode() : 0; - result = 31 * result + (purchaseLocation != null ? purchaseLocation.hashCode() : 0); - return result; - } -} diff --git a/android-aac-enc/src/main/java/com/googlecode/mp4parser/h264/BTree.java b/android-aac-enc/src/main/java/com/googlecode/mp4parser/h264/BTree.java deleted file mode 100644 index 57391baf6..000000000 --- a/android-aac-enc/src/main/java/com/googlecode/mp4parser/h264/BTree.java +++ /dev/null @@ -1,69 +0,0 @@ -/* -Copyright (c) 2011 Stanislav Vitvitskiy - -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. -*/ -package com.googlecode.mp4parser.h264; - - -/** - * Simple BTree implementation needed for haffman tables - * - * @author Stanislav Vitvitskiy - */ -public class BTree { - private BTree zero; - private BTree one; - private Object value; - - /** - * Adds a leaf value to a binary path specified by path - * - * @param str - * @param value - */ - public void addString(String path, Object value) { - if (path.length() == 0) { - this.value = value; - return; - } - char charAt = path.charAt(0); - BTree branch; - if (charAt == '0') { - if (zero == null) - zero = new BTree(); - branch = zero; - } else { - if (one == null) - one = new BTree(); - branch = one; - } - branch.addString(path.substring(1), value); - } - - public BTree down(int b) { - if (b == 0) - return zero; - else - return one; - } - - public Object getValue() { - return value; - } -} \ No newline at end of file diff --git a/android-aac-enc/src/main/java/com/googlecode/mp4parser/h264/CharCache.java b/android-aac-enc/src/main/java/com/googlecode/mp4parser/h264/CharCache.java deleted file mode 100644 index 2fe8ead64..000000000 --- a/android-aac-enc/src/main/java/com/googlecode/mp4parser/h264/CharCache.java +++ /dev/null @@ -1,57 +0,0 @@ -/* -Copyright (c) 2011 Stanislav Vitvitskiy - -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. -*/ -package com.googlecode.mp4parser.h264; - -public class CharCache { - private char[] cache; - private int pos; - - public CharCache(int capacity) { - cache = new char[capacity]; - } - - public void append(String str) { - char[] chars = str.toCharArray(); - int available = cache.length - pos; - int toWrite = chars.length < available ? chars.length : available; - System.arraycopy(chars, 0, cache, pos, toWrite); - pos += toWrite; - } - - public String toString() { - return new String(cache, 0, pos); - } - - public void clear() { - pos = 0; - } - - public void append(char c) { - if (pos < cache.length - 1) { - cache[pos] = c; - pos++; - } - } - - public int length() { - return pos; - } -} diff --git a/android-aac-enc/src/main/java/com/googlecode/mp4parser/h264/Debug.java b/android-aac-enc/src/main/java/com/googlecode/mp4parser/h264/Debug.java deleted file mode 100644 index d0bea7337..000000000 --- a/android-aac-enc/src/main/java/com/googlecode/mp4parser/h264/Debug.java +++ /dev/null @@ -1,88 +0,0 @@ -/* -Copyright (c) 2011 Stanislav Vitvitskiy - -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. -*/ -package com.googlecode.mp4parser.h264; - -import java.nio.ShortBuffer; - -public class Debug { - public final static void print8x8(int[] output) { - int i = 0; - for (int x = 0; x < 8; x++) { - for (int y = 0; y < 8; y++) { - System.out.printf("%3d, ", output[i]); - i++; - } - System.out.println(); - } - } - - public final static void print8x8(short[] output) { - int i = 0; - for (int x = 0; x < 8; x++) { - for (int y = 0; y < 8; y++) { - System.out.printf("%3d, ", output[i]); - i++; - } - System.out.println(); - } - } - - public final static void print8x8(ShortBuffer output) { - for (int x = 0; x < 8; x++) { - for (int y = 0; y < 8; y++) { - System.out.printf("%3d, ", output.get()); - } - System.out.println(); - } - } - - public static void print(short[] table) { - int i = 0; - for (int x = 0; x < 8; x++) { - for (int y = 0; y < 8; y++) { - System.out.printf("%3d, ", table[i]); - i++; - } - System.out.println(); - } - } - - public static void trace(String format, Object... args) { - // System.out.printf("> " + format + "\n", args); - } - - public final static boolean debug = false; - - public static void print(int i) { - if (debug) - System.out.print(i); - } - - public static void print(String string) { - if (debug) - System.out.print(string); - } - - public static void println(String string) { - if (debug) - System.out.println(string); - } -} diff --git a/android-aac-enc/src/main/java/com/googlecode/mp4parser/h264/model/AspectRatio.java b/android-aac-enc/src/main/java/com/googlecode/mp4parser/h264/model/AspectRatio.java deleted file mode 100644 index bc66b1a04..000000000 --- a/android-aac-enc/src/main/java/com/googlecode/mp4parser/h264/model/AspectRatio.java +++ /dev/null @@ -1,50 +0,0 @@ -/* -Copyright (c) 2011 Stanislav Vitvitskiy - -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. -*/ -package com.googlecode.mp4parser.h264.model; - -/** - * Aspect ratio - *

    - * dynamic enum - * - * @author Stanislav Vitvitskiy - */ -public class AspectRatio { - - public static final AspectRatio Extended_SAR = new AspectRatio(255); - - private int value; - - private AspectRatio(int value) { - this.value = value; - } - - public static AspectRatio fromValue(int value) { - if (value == Extended_SAR.value) { - return Extended_SAR; - } - return new AspectRatio(value); - } - - public int getValue() { - return value; - } -} diff --git a/android-aac-enc/src/main/java/com/googlecode/mp4parser/h264/model/BitstreamElement.java b/android-aac-enc/src/main/java/com/googlecode/mp4parser/h264/model/BitstreamElement.java deleted file mode 100644 index f16c5e9f8..000000000 --- a/android-aac-enc/src/main/java/com/googlecode/mp4parser/h264/model/BitstreamElement.java +++ /dev/null @@ -1,29 +0,0 @@ -/* -Copyright (c) 2011 Stanislav Vitvitskiy - -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. -*/ -package com.googlecode.mp4parser.h264.model; - -import java.io.IOException; -import java.io.OutputStream; - -public abstract class BitstreamElement { - - public abstract void write(OutputStream out) throws IOException; -} diff --git a/android-aac-enc/src/main/java/com/googlecode/mp4parser/h264/model/ChromaFormat.java b/android-aac-enc/src/main/java/com/googlecode/mp4parser/h264/model/ChromaFormat.java deleted file mode 100644 index 2af2966a5..000000000 --- a/android-aac-enc/src/main/java/com/googlecode/mp4parser/h264/model/ChromaFormat.java +++ /dev/null @@ -1,77 +0,0 @@ -/* -Copyright (c) 2011 Stanislav Vitvitskiy - -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. -*/ -package com.googlecode.mp4parser.h264.model; - -/** - * Chroma format enum - * - * @author Stanislav Vitvitskiy - */ -public class ChromaFormat { - public static ChromaFormat MONOCHROME = new ChromaFormat(0, 0, 0); - public static ChromaFormat YUV_420 = new ChromaFormat(1, 2, 2); - public static ChromaFormat YUV_422 = new ChromaFormat(2, 2, 1); - public static ChromaFormat YUV_444 = new ChromaFormat(3, 1, 1); - - private int id; - private int subWidth; - private int subHeight; - - public ChromaFormat(int id, int subWidth, int subHeight) { - this.id = id; - this.subWidth = subWidth; - this.subHeight = subHeight; - } - - public static ChromaFormat fromId(int id) { - if (id == MONOCHROME.id) { - return MONOCHROME; - } else if (id == YUV_420.id) { - return YUV_420; - } else if (id == YUV_422.id) { - return YUV_422; - } else if (id == YUV_444.id) { - return YUV_444; - } - return null; - } - - public int getId() { - return id; - } - - public int getSubWidth() { - return subWidth; - } - - public int getSubHeight() { - return subHeight; - } - - @Override - public String toString() { - return "ChromaFormat{" + "\n" + - "id=" + id + ",\n" + - " subWidth=" + subWidth + ",\n" + - " subHeight=" + subHeight + - '}'; - } -} diff --git a/android-aac-enc/src/main/java/com/googlecode/mp4parser/h264/model/HRDParameters.java b/android-aac-enc/src/main/java/com/googlecode/mp4parser/h264/model/HRDParameters.java deleted file mode 100644 index f713ab240..000000000 --- a/android-aac-enc/src/main/java/com/googlecode/mp4parser/h264/model/HRDParameters.java +++ /dev/null @@ -1,53 +0,0 @@ -/* -Copyright (c) 2011 Stanislav Vitvitskiy - -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. -*/ -package com.googlecode.mp4parser.h264.model; - -import java.util.Arrays; - -public class HRDParameters { - - public int cpb_cnt_minus1; - public int bit_rate_scale; - public int cpb_size_scale; - public int[] bit_rate_value_minus1; - public int[] cpb_size_value_minus1; - public boolean[] cbr_flag; - public int initial_cpb_removal_delay_length_minus1; - public int cpb_removal_delay_length_minus1; - public int dpb_output_delay_length_minus1; - public int time_offset_length; - - @Override - public String toString() { - return "HRDParameters{" + - "cpb_cnt_minus1=" + cpb_cnt_minus1 + - ", bit_rate_scale=" + bit_rate_scale + - ", cpb_size_scale=" + cpb_size_scale + - ", bit_rate_value_minus1=" + Arrays.toString(bit_rate_value_minus1) + - ", cpb_size_value_minus1=" + Arrays.toString(cpb_size_value_minus1) + - ", cbr_flag=" + Arrays.toString(cbr_flag) + - ", initial_cpb_removal_delay_length_minus1=" + initial_cpb_removal_delay_length_minus1 + - ", cpb_removal_delay_length_minus1=" + cpb_removal_delay_length_minus1 + - ", dpb_output_delay_length_minus1=" + dpb_output_delay_length_minus1 + - ", time_offset_length=" + time_offset_length + - '}'; - } -} diff --git a/android-aac-enc/src/main/java/com/googlecode/mp4parser/h264/model/PictureParameterSet.java b/android-aac-enc/src/main/java/com/googlecode/mp4parser/h264/model/PictureParameterSet.java deleted file mode 100644 index 9154c38ee..000000000 --- a/android-aac-enc/src/main/java/com/googlecode/mp4parser/h264/model/PictureParameterSet.java +++ /dev/null @@ -1,406 +0,0 @@ -/* -Copyright (c) 2011 Stanislav Vitvitskiy - -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. -*/ -package com.googlecode.mp4parser.h264.model; - -import com.googlecode.mp4parser.h264.read.CAVLCReader; -import com.googlecode.mp4parser.h264.write.CAVLCWriter; - -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.util.Arrays; - -/** - * Picture Parameter Set entity of H264 bitstream - *

    - * capable to serialize / deserialize with CAVLC bitstream - * - * @author Stanislav Vitvitskiy - */ -public class PictureParameterSet extends BitstreamElement { - - public static class PPSExt { - public boolean transform_8x8_mode_flag; - public ScalingMatrix scalindMatrix = new ScalingMatrix(); - public int second_chroma_qp_index_offset; - public boolean[] pic_scaling_list_present_flag; - - @Override - public String toString() { - return "PPSExt{" + - "transform_8x8_mode_flag=" + transform_8x8_mode_flag + - ", scalindMatrix=" + scalindMatrix + - ", second_chroma_qp_index_offset=" + second_chroma_qp_index_offset + - ", pic_scaling_list_present_flag=" + pic_scaling_list_present_flag + - '}'; - } - } - - public boolean entropy_coding_mode_flag; - public int num_ref_idx_l0_active_minus1; - public int num_ref_idx_l1_active_minus1; - public int slice_group_change_rate_minus1; - public int pic_parameter_set_id; - public int seq_parameter_set_id; - public boolean pic_order_present_flag; - public int num_slice_groups_minus1; - public int slice_group_map_type; - public boolean weighted_pred_flag; - public int weighted_bipred_idc; - public int pic_init_qp_minus26; - public int pic_init_qs_minus26; - public int chroma_qp_index_offset; - public boolean deblocking_filter_control_present_flag; - public boolean constrained_intra_pred_flag; - public boolean redundant_pic_cnt_present_flag; - public int[] top_left; - public int[] bottom_right; - public int[] run_length_minus1; - public boolean slice_group_change_direction_flag; - public int[] slice_group_id; - public PPSExt extended; - - public static PictureParameterSet read(byte[] b) throws IOException { - return read(new ByteArrayInputStream(b)); - } - - public static PictureParameterSet read(InputStream is) throws IOException { - CAVLCReader reader = new CAVLCReader(is); - PictureParameterSet pps = new PictureParameterSet(); - - pps.pic_parameter_set_id = reader.readUE("PPS: pic_parameter_set_id"); - pps.seq_parameter_set_id = reader.readUE("PPS: seq_parameter_set_id"); - pps.entropy_coding_mode_flag = reader - .readBool("PPS: entropy_coding_mode_flag"); - pps.pic_order_present_flag = reader - .readBool("PPS: pic_order_present_flag"); - pps.num_slice_groups_minus1 = reader - .readUE("PPS: num_slice_groups_minus1"); - if (pps.num_slice_groups_minus1 > 0) { - pps.slice_group_map_type = reader - .readUE("PPS: slice_group_map_type"); - pps.top_left = new int[pps.num_slice_groups_minus1 + 1]; - pps.bottom_right = new int[pps.num_slice_groups_minus1 + 1]; - pps.run_length_minus1 = new int[pps.num_slice_groups_minus1 + 1]; - if (pps.slice_group_map_type == 0) - for (int iGroup = 0; iGroup <= pps.num_slice_groups_minus1; iGroup++) - pps.run_length_minus1[iGroup] = reader - .readUE("PPS: run_length_minus1"); - else if (pps.slice_group_map_type == 2) - for (int iGroup = 0; iGroup < pps.num_slice_groups_minus1; iGroup++) { - pps.top_left[iGroup] = reader.readUE("PPS: top_left"); - pps.bottom_right[iGroup] = reader - .readUE("PPS: bottom_right"); - } - else if (pps.slice_group_map_type == 3 - || pps.slice_group_map_type == 4 - || pps.slice_group_map_type == 5) { - pps.slice_group_change_direction_flag = reader - .readBool("PPS: slice_group_change_direction_flag"); - pps.slice_group_change_rate_minus1 = reader - .readUE("PPS: slice_group_change_rate_minus1"); - } else if (pps.slice_group_map_type == 6) { - int NumberBitsPerSliceGroupId; - if (pps.num_slice_groups_minus1 + 1 > 4) - NumberBitsPerSliceGroupId = 3; - else if (pps.num_slice_groups_minus1 + 1 > 2) - NumberBitsPerSliceGroupId = 2; - else - NumberBitsPerSliceGroupId = 1; - int pic_size_in_map_units_minus1 = reader - .readUE("PPS: pic_size_in_map_units_minus1"); - pps.slice_group_id = new int[pic_size_in_map_units_minus1 + 1]; - for (int i = 0; i <= pic_size_in_map_units_minus1; i++) { - pps.slice_group_id[i] = reader.readU( - NumberBitsPerSliceGroupId, "PPS: slice_group_id [" - + i + "]f"); - } - } - } - pps.num_ref_idx_l0_active_minus1 = reader - .readUE("PPS: num_ref_idx_l0_active_minus1"); - pps.num_ref_idx_l1_active_minus1 = reader - .readUE("PPS: num_ref_idx_l1_active_minus1"); - pps.weighted_pred_flag = reader.readBool("PPS: weighted_pred_flag"); - pps.weighted_bipred_idc = (int) reader.readNBit(2, - "PPS: weighted_bipred_idc"); - pps.pic_init_qp_minus26 = reader.readSE("PPS: pic_init_qp_minus26"); - pps.pic_init_qs_minus26 = reader.readSE("PPS: pic_init_qs_minus26"); - pps.chroma_qp_index_offset = reader - .readSE("PPS: chroma_qp_index_offset"); - pps.deblocking_filter_control_present_flag = reader - .readBool("PPS: deblocking_filter_control_present_flag"); - pps.constrained_intra_pred_flag = reader - .readBool("PPS: constrained_intra_pred_flag"); - pps.redundant_pic_cnt_present_flag = reader - .readBool("PPS: redundant_pic_cnt_present_flag"); - if (reader.moreRBSPData()) { - pps.extended = new PictureParameterSet.PPSExt(); - pps.extended.transform_8x8_mode_flag = reader - .readBool("PPS: transform_8x8_mode_flag"); - boolean pic_scaling_matrix_present_flag = reader - .readBool("PPS: pic_scaling_matrix_present_flag"); - if (pic_scaling_matrix_present_flag) { - for (int i = 0; i < 6 + 2 * (pps.extended.transform_8x8_mode_flag ? 1 - : 0); i++) { - boolean pic_scaling_list_present_flag = reader - .readBool("PPS: pic_scaling_list_present_flag"); - if (pic_scaling_list_present_flag) { - pps.extended.scalindMatrix.ScalingList4x4 = new ScalingList[8]; - pps.extended.scalindMatrix.ScalingList8x8 = new ScalingList[8]; - if (i < 6) { - pps.extended.scalindMatrix.ScalingList4x4[i] = ScalingList - .read(reader, 16); - } else { - pps.extended.scalindMatrix.ScalingList8x8[i - 6] = ScalingList - .read(reader, 64); - } - } - } - } - pps.extended.second_chroma_qp_index_offset = reader - .readSE("PPS: second_chroma_qp_index_offset"); - } - - reader.readTrailingBits(); - - return pps; - } - - public void write(OutputStream out) throws IOException { - CAVLCWriter writer = new CAVLCWriter(out); - - writer.writeUE(pic_parameter_set_id, "PPS: pic_parameter_set_id"); - writer.writeUE(seq_parameter_set_id, "PPS: seq_parameter_set_id"); - writer.writeBool(entropy_coding_mode_flag, - "PPS: entropy_coding_mode_flag"); - writer.writeBool(pic_order_present_flag, "PPS: pic_order_present_flag"); - writer.writeUE(num_slice_groups_minus1, "PPS: num_slice_groups_minus1"); - if (num_slice_groups_minus1 > 0) { - writer.writeUE(slice_group_map_type, "PPS: slice_group_map_type"); - int[] top_left = new int[1]; - int[] bottom_right = new int[1]; - int[] run_length_minus1 = new int[1]; - if (slice_group_map_type == 0) { - for (int iGroup = 0; iGroup <= num_slice_groups_minus1; iGroup++) { - writer.writeUE(run_length_minus1[iGroup], "PPS: "); - } - } else if (slice_group_map_type == 2) { - for (int iGroup = 0; iGroup < num_slice_groups_minus1; iGroup++) { - writer.writeUE(top_left[iGroup], "PPS: "); - writer.writeUE(bottom_right[iGroup], "PPS: "); - } - } else if (slice_group_map_type == 3 || slice_group_map_type == 4 - || slice_group_map_type == 5) { - writer.writeBool(slice_group_change_direction_flag, - "PPS: slice_group_change_direction_flag"); - writer.writeUE(slice_group_change_rate_minus1, - "PPS: slice_group_change_rate_minus1"); - } else if (slice_group_map_type == 6) { - int NumberBitsPerSliceGroupId; - if (num_slice_groups_minus1 + 1 > 4) - NumberBitsPerSliceGroupId = 3; - else if (num_slice_groups_minus1 + 1 > 2) - NumberBitsPerSliceGroupId = 2; - else - NumberBitsPerSliceGroupId = 1; - writer.writeUE(slice_group_id.length, "PPS: "); - for (int i = 0; i <= slice_group_id.length; i++) { - writer.writeU(slice_group_id[i], NumberBitsPerSliceGroupId); - } - } - } - writer.writeUE(num_ref_idx_l0_active_minus1, - "PPS: num_ref_idx_l0_active_minus1"); - writer.writeUE(num_ref_idx_l1_active_minus1, - "PPS: num_ref_idx_l1_active_minus1"); - writer.writeBool(weighted_pred_flag, "PPS: weighted_pred_flag"); - writer.writeNBit(weighted_bipred_idc, 2, "PPS: weighted_bipred_idc"); - writer.writeSE(pic_init_qp_minus26, "PPS: pic_init_qp_minus26"); - writer.writeSE(pic_init_qs_minus26, "PPS: pic_init_qs_minus26"); - writer.writeSE(chroma_qp_index_offset, "PPS: chroma_qp_index_offset"); - writer.writeBool(deblocking_filter_control_present_flag, - "PPS: deblocking_filter_control_present_flag"); - writer.writeBool(constrained_intra_pred_flag, - "PPS: constrained_intra_pred_flag"); - writer.writeBool(redundant_pic_cnt_present_flag, - "PPS: redundant_pic_cnt_present_flag"); - if (extended != null) { - writer.writeBool(extended.transform_8x8_mode_flag, - "PPS: transform_8x8_mode_flag"); - writer.writeBool(extended.scalindMatrix != null, - "PPS: scalindMatrix"); - if (extended.scalindMatrix != null) { - for (int i = 0; i < 6 + 2 * (extended.transform_8x8_mode_flag ? 1 - : 0); i++) { - if (i < 6) { - writer - .writeBool( - extended.scalindMatrix.ScalingList4x4[i] != null, - "PPS: "); - if (extended.scalindMatrix.ScalingList4x4[i] != null) { - extended.scalindMatrix.ScalingList4x4[i] - .write(writer); - } - - } else { - writer - .writeBool( - extended.scalindMatrix.ScalingList8x8[i - 6] != null, - "PPS: "); - if (extended.scalindMatrix.ScalingList8x8[i - 6] != null) { - extended.scalindMatrix.ScalingList8x8[i - 6] - .write(writer); - } - } - } - } - writer.writeSE(extended.second_chroma_qp_index_offset, "PPS: "); - } - - writer.writeTrailingBits(); - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + Arrays.hashCode(bottom_right); - result = prime * result + chroma_qp_index_offset; - result = prime * result + (constrained_intra_pred_flag ? 1231 : 1237); - result = prime * result - + (deblocking_filter_control_present_flag ? 1231 : 1237); - result = prime * result + (entropy_coding_mode_flag ? 1231 : 1237); - result = prime * result - + ((extended == null) ? 0 : extended.hashCode()); - result = prime * result + num_ref_idx_l0_active_minus1; - result = prime * result + num_ref_idx_l1_active_minus1; - result = prime * result + num_slice_groups_minus1; - result = prime * result + pic_init_qp_minus26; - result = prime * result + pic_init_qs_minus26; - result = prime * result + (pic_order_present_flag ? 1231 : 1237); - result = prime * result + pic_parameter_set_id; - result = prime * result - + (redundant_pic_cnt_present_flag ? 1231 : 1237); - result = prime * result + Arrays.hashCode(run_length_minus1); - result = prime * result + seq_parameter_set_id; - result = prime * result - + (slice_group_change_direction_flag ? 1231 : 1237); - result = prime * result + slice_group_change_rate_minus1; - result = prime * result + Arrays.hashCode(slice_group_id); - result = prime * result + slice_group_map_type; - result = prime * result + Arrays.hashCode(top_left); - result = prime * result + weighted_bipred_idc; - result = prime * result + (weighted_pred_flag ? 1231 : 1237); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - PictureParameterSet other = (PictureParameterSet) obj; - if (!Arrays.equals(bottom_right, other.bottom_right)) - return false; - if (chroma_qp_index_offset != other.chroma_qp_index_offset) - return false; - if (constrained_intra_pred_flag != other.constrained_intra_pred_flag) - return false; - if (deblocking_filter_control_present_flag != other.deblocking_filter_control_present_flag) - return false; - if (entropy_coding_mode_flag != other.entropy_coding_mode_flag) - return false; - if (extended == null) { - if (other.extended != null) - return false; - } else if (!extended.equals(other.extended)) - return false; - if (num_ref_idx_l0_active_minus1 != other.num_ref_idx_l0_active_minus1) - return false; - if (num_ref_idx_l1_active_minus1 != other.num_ref_idx_l1_active_minus1) - return false; - if (num_slice_groups_minus1 != other.num_slice_groups_minus1) - return false; - if (pic_init_qp_minus26 != other.pic_init_qp_minus26) - return false; - if (pic_init_qs_minus26 != other.pic_init_qs_minus26) - return false; - if (pic_order_present_flag != other.pic_order_present_flag) - return false; - if (pic_parameter_set_id != other.pic_parameter_set_id) - return false; - if (redundant_pic_cnt_present_flag != other.redundant_pic_cnt_present_flag) - return false; - if (!Arrays.equals(run_length_minus1, other.run_length_minus1)) - return false; - if (seq_parameter_set_id != other.seq_parameter_set_id) - return false; - if (slice_group_change_direction_flag != other.slice_group_change_direction_flag) - return false; - if (slice_group_change_rate_minus1 != other.slice_group_change_rate_minus1) - return false; - if (!Arrays.equals(slice_group_id, other.slice_group_id)) - return false; - if (slice_group_map_type != other.slice_group_map_type) - return false; - if (!Arrays.equals(top_left, other.top_left)) - return false; - if (weighted_bipred_idc != other.weighted_bipred_idc) - return false; - if (weighted_pred_flag != other.weighted_pred_flag) - return false; - return true; - } - - @Override - public String toString() { - return "PictureParameterSet{" + - "\n entropy_coding_mode_flag=" + entropy_coding_mode_flag + - ",\n num_ref_idx_l0_active_minus1=" + num_ref_idx_l0_active_minus1 + - ",\n num_ref_idx_l1_active_minus1=" + num_ref_idx_l1_active_minus1 + - ",\n slice_group_change_rate_minus1=" + slice_group_change_rate_minus1 + - ",\n pic_parameter_set_id=" + pic_parameter_set_id + - ",\n seq_parameter_set_id=" + seq_parameter_set_id + - ",\n pic_order_present_flag=" + pic_order_present_flag + - ",\n num_slice_groups_minus1=" + num_slice_groups_minus1 + - ",\n slice_group_map_type=" + slice_group_map_type + - ",\n weighted_pred_flag=" + weighted_pred_flag + - ",\n weighted_bipred_idc=" + weighted_bipred_idc + - ",\n pic_init_qp_minus26=" + pic_init_qp_minus26 + - ",\n pic_init_qs_minus26=" + pic_init_qs_minus26 + - ",\n chroma_qp_index_offset=" + chroma_qp_index_offset + - ",\n deblocking_filter_control_present_flag=" + deblocking_filter_control_present_flag + - ",\n constrained_intra_pred_flag=" + constrained_intra_pred_flag + - ",\n redundant_pic_cnt_present_flag=" + redundant_pic_cnt_present_flag + - ",\n top_left=" + top_left + - ",\n bottom_right=" + bottom_right + - ",\n run_length_minus1=" + run_length_minus1 + - ",\n slice_group_change_direction_flag=" + slice_group_change_direction_flag + - ",\n slice_group_id=" + slice_group_id + - ",\n extended=" + extended + - '}'; - } -} diff --git a/android-aac-enc/src/main/java/com/googlecode/mp4parser/h264/model/ScalingList.java b/android-aac-enc/src/main/java/com/googlecode/mp4parser/h264/model/ScalingList.java deleted file mode 100644 index 5d272bf00..000000000 --- a/android-aac-enc/src/main/java/com/googlecode/mp4parser/h264/model/ScalingList.java +++ /dev/null @@ -1,83 +0,0 @@ -/* -Copyright (c) 2011 Stanislav Vitvitskiy - -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. -*/ -package com.googlecode.mp4parser.h264.model; - -import com.googlecode.mp4parser.h264.read.CAVLCReader; -import com.googlecode.mp4parser.h264.write.CAVLCWriter; - -import java.io.IOException; - -/** - * Scaling list entity - *

    - * capable to serialize / deserialize with CAVLC bitstream - * - * @author Stanislav Vitvitskiy - */ -public class ScalingList { - - public int[] scalingList; - public boolean useDefaultScalingMatrixFlag; - - public void write(CAVLCWriter out) throws IOException { - if (useDefaultScalingMatrixFlag) { - out.writeSE(0, "SPS: "); - return; - } - - int lastScale = 8; - int nextScale = 8; - for (int j = 0; j < scalingList.length; j++) { - if (nextScale != 0) { - int deltaScale = scalingList[j] - lastScale - 256; - out.writeSE(deltaScale, "SPS: "); - } - lastScale = scalingList[j]; - } - } - - public static ScalingList read(CAVLCReader is, int sizeOfScalingList) - throws IOException { - - ScalingList sl = new ScalingList(); - sl.scalingList = new int[sizeOfScalingList]; - int lastScale = 8; - int nextScale = 8; - for (int j = 0; j < sizeOfScalingList; j++) { - if (nextScale != 0) { - int deltaScale = is.readSE("deltaScale"); - nextScale = (lastScale + deltaScale + 256) % 256; - sl.useDefaultScalingMatrixFlag = (j == 0 && nextScale == 0); - } - sl.scalingList[j] = nextScale == 0 ? lastScale : nextScale; - lastScale = sl.scalingList[j]; - } - return sl; - } - - @Override - public String toString() { - return "ScalingList{" + - "scalingList=" + scalingList + - ", useDefaultScalingMatrixFlag=" + useDefaultScalingMatrixFlag + - '}'; - } -} \ No newline at end of file diff --git a/android-aac-enc/src/main/java/com/googlecode/mp4parser/h264/model/ScalingMatrix.java b/android-aac-enc/src/main/java/com/googlecode/mp4parser/h264/model/ScalingMatrix.java deleted file mode 100644 index d04af8e27..000000000 --- a/android-aac-enc/src/main/java/com/googlecode/mp4parser/h264/model/ScalingMatrix.java +++ /dev/null @@ -1,37 +0,0 @@ -/* -Copyright (c) 2011 Stanislav Vitvitskiy - -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. -*/ -package com.googlecode.mp4parser.h264.model; - -import java.util.Arrays; - -public class ScalingMatrix { - - public ScalingList[] ScalingList4x4; - public ScalingList[] ScalingList8x8; - - @Override - public String toString() { - return "ScalingMatrix{" + - "ScalingList4x4=" + (ScalingList4x4 == null ? null : Arrays.asList(ScalingList4x4)) + "\n" + - ", ScalingList8x8=" + (ScalingList8x8 == null ? null : Arrays.asList(ScalingList8x8)) + "\n" + - '}'; - } -} \ No newline at end of file diff --git a/android-aac-enc/src/main/java/com/googlecode/mp4parser/h264/model/SeqParameterSet.java b/android-aac-enc/src/main/java/com/googlecode/mp4parser/h264/model/SeqParameterSet.java deleted file mode 100644 index 4894df884..000000000 --- a/android-aac-enc/src/main/java/com/googlecode/mp4parser/h264/model/SeqParameterSet.java +++ /dev/null @@ -1,556 +0,0 @@ -/* -Copyright (c) 2011 Stanislav Vitvitskiy - -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. -*/ -package com.googlecode.mp4parser.h264.model; - -import com.googlecode.mp4parser.h264.read.CAVLCReader; -import com.googlecode.mp4parser.h264.write.CAVLCWriter; - -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; - -/** - * Sequence Parameter Set structure of h264 bitstream - *

    - * capable to serialize and deserialize with CAVLC bitstream - * - * @author Stanislav Vitvitskiy - */ -public class SeqParameterSet extends BitstreamElement { - public int pic_order_cnt_type; - public boolean field_pic_flag; - public boolean delta_pic_order_always_zero_flag; - public boolean weighted_pred_flag; - public int weighted_bipred_idc; - public boolean entropy_coding_mode_flag; - public boolean mb_adaptive_frame_field_flag; - public boolean direct_8x8_inference_flag; - public ChromaFormat chroma_format_idc; - public int log2_max_frame_num_minus4; - public int log2_max_pic_order_cnt_lsb_minus4; - public int pic_height_in_map_units_minus1; - public int pic_width_in_mbs_minus1; - public int bit_depth_luma_minus8; - public int bit_depth_chroma_minus8; - public boolean qpprime_y_zero_transform_bypass_flag; - public int profile_idc; - public boolean constraint_set_0_flag; - public boolean constraint_set_1_flag; - public boolean constraint_set_2_flag; - public boolean constraint_set_3_flag; - public int level_idc; - public int seq_parameter_set_id; - public boolean residual_color_transform_flag; - public int offset_for_non_ref_pic; - public int offset_for_top_to_bottom_field; - public int num_ref_frames; - public boolean gaps_in_frame_num_value_allowed_flag; - public boolean frame_mbs_only_flag; - public boolean frame_cropping_flag; - public int frame_crop_left_offset; - public int frame_crop_right_offset; - public int frame_crop_top_offset; - public int frame_crop_bottom_offset; - public int[] offsetForRefFrame; - public VUIParameters vuiParams; - public ScalingMatrix scalingMatrix; - public int num_ref_frames_in_pic_order_cnt_cycle; - - public static SeqParameterSet read(InputStream is) throws IOException { - CAVLCReader reader = new CAVLCReader(is); - SeqParameterSet sps = new SeqParameterSet(); - - sps.profile_idc = (int) reader.readNBit(8, "SPS: profile_idc"); - sps.constraint_set_0_flag = reader - .readBool("SPS: constraint_set_0_flag"); - sps.constraint_set_1_flag = reader - .readBool("SPS: constraint_set_1_flag"); - sps.constraint_set_2_flag = reader - .readBool("SPS: constraint_set_2_flag"); - sps.constraint_set_3_flag = reader - .readBool("SPS: constraint_set_3_flag"); - reader.readNBit(4, "SPS: reserved_zero_4bits"); - sps.level_idc = (int) reader.readNBit(8, "SPS: level_idc"); - sps.seq_parameter_set_id = reader.readUE("SPS: seq_parameter_set_id"); - - if (sps.profile_idc == 100 || sps.profile_idc == 110 - || sps.profile_idc == 122 || sps.profile_idc == 144) { - sps.chroma_format_idc = ChromaFormat.fromId(reader - .readUE("SPS: chroma_format_idc")); - if (sps.chroma_format_idc == ChromaFormat.YUV_444) { - sps.residual_color_transform_flag = reader - .readBool("SPS: residual_color_transform_flag"); - } - sps.bit_depth_luma_minus8 = reader - .readUE("SPS: bit_depth_luma_minus8"); - sps.bit_depth_chroma_minus8 = reader - .readUE("SPS: bit_depth_chroma_minus8"); - sps.qpprime_y_zero_transform_bypass_flag = reader - .readBool("SPS: qpprime_y_zero_transform_bypass_flag"); - boolean seqScalingMatrixPresent = reader - .readBool("SPS: seq_scaling_matrix_present_lag"); - if (seqScalingMatrixPresent) { - readScalingListMatrix(reader, sps); - } - } else { - sps.chroma_format_idc = ChromaFormat.YUV_420; - } - sps.log2_max_frame_num_minus4 = reader - .readUE("SPS: log2_max_frame_num_minus4"); - sps.pic_order_cnt_type = reader.readUE("SPS: pic_order_cnt_type"); - if (sps.pic_order_cnt_type == 0) { - sps.log2_max_pic_order_cnt_lsb_minus4 = reader - .readUE("SPS: log2_max_pic_order_cnt_lsb_minus4"); - } else if (sps.pic_order_cnt_type == 1) { - sps.delta_pic_order_always_zero_flag = reader - .readBool("SPS: delta_pic_order_always_zero_flag"); - sps.offset_for_non_ref_pic = reader - .readSE("SPS: offset_for_non_ref_pic"); - sps.offset_for_top_to_bottom_field = reader - .readSE("SPS: offset_for_top_to_bottom_field"); - sps.num_ref_frames_in_pic_order_cnt_cycle = reader - .readUE("SPS: num_ref_frames_in_pic_order_cnt_cycle"); - sps.offsetForRefFrame = new int[sps.num_ref_frames_in_pic_order_cnt_cycle]; - for (int i = 0; i < sps.num_ref_frames_in_pic_order_cnt_cycle; i++) { - sps.offsetForRefFrame[i] = reader - .readSE("SPS: offsetForRefFrame [" + i + "]"); - } - } - sps.num_ref_frames = reader.readUE("SPS: num_ref_frames"); - sps.gaps_in_frame_num_value_allowed_flag = reader - .readBool("SPS: gaps_in_frame_num_value_allowed_flag"); - sps.pic_width_in_mbs_minus1 = reader - .readUE("SPS: pic_width_in_mbs_minus1"); - sps.pic_height_in_map_units_minus1 = reader - .readUE("SPS: pic_height_in_map_units_minus1"); - sps.frame_mbs_only_flag = reader.readBool("SPS: frame_mbs_only_flag"); - if (!sps.frame_mbs_only_flag) { - sps.mb_adaptive_frame_field_flag = reader - .readBool("SPS: mb_adaptive_frame_field_flag"); - } - sps.direct_8x8_inference_flag = reader - .readBool("SPS: direct_8x8_inference_flag"); - sps.frame_cropping_flag = reader.readBool("SPS: frame_cropping_flag"); - if (sps.frame_cropping_flag) { - sps.frame_crop_left_offset = reader - .readUE("SPS: frame_crop_left_offset"); - sps.frame_crop_right_offset = reader - .readUE("SPS: frame_crop_right_offset"); - sps.frame_crop_top_offset = reader - .readUE("SPS: frame_crop_top_offset"); - sps.frame_crop_bottom_offset = reader - .readUE("SPS: frame_crop_bottom_offset"); - } - boolean vui_parameters_present_flag = reader - .readBool("SPS: vui_parameters_present_flag"); - if (vui_parameters_present_flag) - sps.vuiParams = ReadVUIParameters(reader); - - reader.readTrailingBits(); - - return sps; - } - - private static void readScalingListMatrix(CAVLCReader reader, - SeqParameterSet sps) throws IOException { - sps.scalingMatrix = new ScalingMatrix(); - for (int i = 0; i < 8; i++) { - boolean seqScalingListPresentFlag = reader - .readBool("SPS: seqScalingListPresentFlag"); - if (seqScalingListPresentFlag) { - sps.scalingMatrix.ScalingList4x4 = new ScalingList[8]; - sps.scalingMatrix.ScalingList8x8 = new ScalingList[8]; - if (i < 6) { - sps.scalingMatrix.ScalingList4x4[i] = ScalingList.read( - reader, 16); - } else { - sps.scalingMatrix.ScalingList8x8[i - 6] = ScalingList.read( - reader, 64); - } - } - } - } - - private static VUIParameters ReadVUIParameters(CAVLCReader reader) - throws IOException { - VUIParameters vuip = new VUIParameters(); - vuip.aspect_ratio_info_present_flag = reader - .readBool("VUI: aspect_ratio_info_present_flag"); - if (vuip.aspect_ratio_info_present_flag) { - vuip.aspect_ratio = AspectRatio.fromValue((int) reader.readNBit(8, - "VUI: aspect_ratio")); - if (vuip.aspect_ratio == AspectRatio.Extended_SAR) { - vuip.sar_width = (int) reader.readNBit(16, "VUI: sar_width"); - vuip.sar_height = (int) reader.readNBit(16, "VUI: sar_height"); - } - } - vuip.overscan_info_present_flag = reader - .readBool("VUI: overscan_info_present_flag"); - if (vuip.overscan_info_present_flag) { - vuip.overscan_appropriate_flag = reader - .readBool("VUI: overscan_appropriate_flag"); - } - vuip.video_signal_type_present_flag = reader - .readBool("VUI: video_signal_type_present_flag"); - if (vuip.video_signal_type_present_flag) { - vuip.video_format = (int) reader.readNBit(3, "VUI: video_format"); - vuip.video_full_range_flag = reader - .readBool("VUI: video_full_range_flag"); - vuip.colour_description_present_flag = reader - .readBool("VUI: colour_description_present_flag"); - if (vuip.colour_description_present_flag) { - vuip.colour_primaries = (int) reader.readNBit(8, - "VUI: colour_primaries"); - vuip.transfer_characteristics = (int) reader.readNBit(8, - "VUI: transfer_characteristics"); - vuip.matrix_coefficients = (int) reader.readNBit(8, - "VUI: matrix_coefficients"); - } - } - vuip.chroma_loc_info_present_flag = reader - .readBool("VUI: chroma_loc_info_present_flag"); - if (vuip.chroma_loc_info_present_flag) { - vuip.chroma_sample_loc_type_top_field = reader - .readUE("VUI chroma_sample_loc_type_top_field"); - vuip.chroma_sample_loc_type_bottom_field = reader - .readUE("VUI chroma_sample_loc_type_bottom_field"); - } - vuip.timing_info_present_flag = reader - .readBool("VUI: timing_info_present_flag"); - if (vuip.timing_info_present_flag) { - vuip.num_units_in_tick = (int) reader.readNBit(32, - "VUI: num_units_in_tick"); - vuip.time_scale = (int) reader.readNBit(32, "VUI: time_scale"); - vuip.fixed_frame_rate_flag = reader - .readBool("VUI: fixed_frame_rate_flag"); - } - boolean nal_hrd_parameters_present_flag = reader - .readBool("VUI: nal_hrd_parameters_present_flag"); - if (nal_hrd_parameters_present_flag) - vuip.nalHRDParams = readHRDParameters(reader); - boolean vcl_hrd_parameters_present_flag = reader - .readBool("VUI: vcl_hrd_parameters_present_flag"); - if (vcl_hrd_parameters_present_flag) - vuip.vclHRDParams = readHRDParameters(reader); - if (nal_hrd_parameters_present_flag || vcl_hrd_parameters_present_flag) { - vuip.low_delay_hrd_flag = reader - .readBool("VUI: low_delay_hrd_flag"); - } - vuip.pic_struct_present_flag = reader - .readBool("VUI: pic_struct_present_flag"); - boolean bitstream_restriction_flag = reader - .readBool("VUI: bitstream_restriction_flag"); - if (bitstream_restriction_flag) { - vuip.bitstreamRestriction = new VUIParameters.BitstreamRestriction(); - vuip.bitstreamRestriction.motion_vectors_over_pic_boundaries_flag = reader - .readBool("VUI: motion_vectors_over_pic_boundaries_flag"); - vuip.bitstreamRestriction.max_bytes_per_pic_denom = reader - .readUE("VUI max_bytes_per_pic_denom"); - vuip.bitstreamRestriction.max_bits_per_mb_denom = reader - .readUE("VUI max_bits_per_mb_denom"); - vuip.bitstreamRestriction.log2_max_mv_length_horizontal = reader - .readUE("VUI log2_max_mv_length_horizontal"); - vuip.bitstreamRestriction.log2_max_mv_length_vertical = reader - .readUE("VUI log2_max_mv_length_vertical"); - vuip.bitstreamRestriction.num_reorder_frames = reader - .readUE("VUI num_reorder_frames"); - vuip.bitstreamRestriction.max_dec_frame_buffering = reader - .readUE("VUI max_dec_frame_buffering"); - } - - return vuip; - } - - private static HRDParameters readHRDParameters(CAVLCReader reader) - throws IOException { - HRDParameters hrd = new HRDParameters(); - hrd.cpb_cnt_minus1 = reader.readUE("SPS: cpb_cnt_minus1"); - hrd.bit_rate_scale = (int) reader.readNBit(4, "HRD: bit_rate_scale"); - hrd.cpb_size_scale = (int) reader.readNBit(4, "HRD: cpb_size_scale"); - hrd.bit_rate_value_minus1 = new int[hrd.cpb_cnt_minus1 + 1]; - hrd.cpb_size_value_minus1 = new int[hrd.cpb_cnt_minus1 + 1]; - hrd.cbr_flag = new boolean[hrd.cpb_cnt_minus1 + 1]; - - for (int SchedSelIdx = 0; SchedSelIdx <= hrd.cpb_cnt_minus1; SchedSelIdx++) { - hrd.bit_rate_value_minus1[SchedSelIdx] = reader - .readUE("HRD: bit_rate_value_minus1"); - hrd.cpb_size_value_minus1[SchedSelIdx] = reader - .readUE("HRD: cpb_size_value_minus1"); - hrd.cbr_flag[SchedSelIdx] = reader.readBool("HRD: cbr_flag"); - } - hrd.initial_cpb_removal_delay_length_minus1 = (int) reader.readNBit(5, - "HRD: initial_cpb_removal_delay_length_minus1"); - hrd.cpb_removal_delay_length_minus1 = (int) reader.readNBit(5, - "HRD: cpb_removal_delay_length_minus1"); - hrd.dpb_output_delay_length_minus1 = (int) reader.readNBit(5, - "HRD: dpb_output_delay_length_minus1"); - hrd.time_offset_length = (int) reader.readNBit(5, - "HRD: time_offset_length"); - return hrd; - } - - public void write(OutputStream out) throws IOException { - CAVLCWriter writer = new CAVLCWriter(out); - - writer.writeNBit(profile_idc, 8, "SPS: profile_idc"); - writer.writeBool(constraint_set_0_flag, "SPS: constraint_set_0_flag"); - writer.writeBool(constraint_set_1_flag, "SPS: constraint_set_1_flag"); - writer.writeBool(constraint_set_2_flag, "SPS: constraint_set_2_flag"); - writer.writeBool(constraint_set_3_flag, "SPS: constraint_set_3_flag"); - writer.writeNBit(0, 4, "SPS: reserved"); - writer.writeNBit(level_idc, 8, "SPS: level_idc"); - writer.writeUE(seq_parameter_set_id, "SPS: seq_parameter_set_id"); - - if (profile_idc == 100 || profile_idc == 110 || profile_idc == 122 - || profile_idc == 144) { - writer.writeUE(chroma_format_idc.getId(), "SPS: chroma_format_idc"); - if (chroma_format_idc == ChromaFormat.YUV_444) { - writer.writeBool(residual_color_transform_flag, - "SPS: residual_color_transform_flag"); - } - writer.writeUE(bit_depth_luma_minus8, "SPS: "); - writer.writeUE(bit_depth_chroma_minus8, "SPS: "); - writer.writeBool(qpprime_y_zero_transform_bypass_flag, - "SPS: qpprime_y_zero_transform_bypass_flag"); - writer.writeBool(scalingMatrix != null, "SPS: "); - if (scalingMatrix != null) { - for (int i = 0; i < 8; i++) { - if (i < 6) { - writer.writeBool( - scalingMatrix.ScalingList4x4[i] != null, - "SPS: "); - if (scalingMatrix.ScalingList4x4[i] != null) { - scalingMatrix.ScalingList4x4[i].write(writer); - } - } else { - writer.writeBool( - scalingMatrix.ScalingList8x8[i - 6] != null, - "SPS: "); - if (scalingMatrix.ScalingList8x8[i - 6] != null) { - scalingMatrix.ScalingList8x8[i - 6].write(writer); - } - } - } - } - } - writer.writeUE(log2_max_frame_num_minus4, - "SPS: log2_max_frame_num_minus4"); - writer.writeUE(pic_order_cnt_type, "SPS: pic_order_cnt_type"); - if (pic_order_cnt_type == 0) { - writer.writeUE(log2_max_pic_order_cnt_lsb_minus4, - "SPS: log2_max_pic_order_cnt_lsb_minus4"); - } else if (pic_order_cnt_type == 1) { - writer.writeBool(delta_pic_order_always_zero_flag, - "SPS: delta_pic_order_always_zero_flag"); - writer.writeSE(offset_for_non_ref_pic, - "SPS: offset_for_non_ref_pic"); - writer.writeSE(offset_for_top_to_bottom_field, - "SPS: offset_for_top_to_bottom_field"); - writer.writeUE(offsetForRefFrame.length, "SPS: "); - for (int i = 0; i < offsetForRefFrame.length; i++) - writer.writeSE(offsetForRefFrame[i], "SPS: "); - } - writer.writeUE(num_ref_frames, "SPS: num_ref_frames"); - writer.writeBool(gaps_in_frame_num_value_allowed_flag, - "SPS: gaps_in_frame_num_value_allowed_flag"); - writer.writeUE(pic_width_in_mbs_minus1, "SPS: pic_width_in_mbs_minus1"); - writer.writeUE(pic_height_in_map_units_minus1, - "SPS: pic_height_in_map_units_minus1"); - writer.writeBool(frame_mbs_only_flag, "SPS: frame_mbs_only_flag"); - if (!frame_mbs_only_flag) { - writer.writeBool(mb_adaptive_frame_field_flag, - "SPS: mb_adaptive_frame_field_flag"); - } - writer.writeBool(direct_8x8_inference_flag, - "SPS: direct_8x8_inference_flag"); - writer.writeBool(frame_cropping_flag, "SPS: frame_cropping_flag"); - if (frame_cropping_flag) { - writer.writeUE(frame_crop_left_offset, - "SPS: frame_crop_left_offset"); - writer.writeUE(frame_crop_right_offset, - "SPS: frame_crop_right_offset"); - writer.writeUE(frame_crop_top_offset, "SPS: frame_crop_top_offset"); - writer.writeUE(frame_crop_bottom_offset, - "SPS: frame_crop_bottom_offset"); - } - writer.writeBool(vuiParams != null, "SPS: "); - if (vuiParams != null) - writeVUIParameters(vuiParams, writer); - - writer.writeTrailingBits(); - } - - private void writeVUIParameters(VUIParameters vuip, CAVLCWriter writer) - throws IOException { - writer.writeBool(vuip.aspect_ratio_info_present_flag, - "VUI: aspect_ratio_info_present_flag"); - if (vuip.aspect_ratio_info_present_flag) { - writer.writeNBit(vuip.aspect_ratio.getValue(), 8, - "VUI: aspect_ratio"); - if (vuip.aspect_ratio == AspectRatio.Extended_SAR) { - writer.writeNBit(vuip.sar_width, 16, "VUI: sar_width"); - writer.writeNBit(vuip.sar_height, 16, "VUI: sar_height"); - } - } - writer.writeBool(vuip.overscan_info_present_flag, - "VUI: overscan_info_present_flag"); - if (vuip.overscan_info_present_flag) { - writer.writeBool(vuip.overscan_appropriate_flag, - "VUI: overscan_appropriate_flag"); - } - writer.writeBool(vuip.video_signal_type_present_flag, - "VUI: video_signal_type_present_flag"); - if (vuip.video_signal_type_present_flag) { - writer.writeNBit(vuip.video_format, 3, "VUI: video_format"); - writer.writeBool(vuip.video_full_range_flag, - "VUI: video_full_range_flag"); - writer.writeBool(vuip.colour_description_present_flag, - "VUI: colour_description_present_flag"); - if (vuip.colour_description_present_flag) { - writer.writeNBit(vuip.colour_primaries, 8, - "VUI: colour_primaries"); - writer.writeNBit(vuip.transfer_characteristics, 8, - "VUI: transfer_characteristics"); - writer.writeNBit(vuip.matrix_coefficients, 8, - "VUI: matrix_coefficients"); - } - } - writer.writeBool(vuip.chroma_loc_info_present_flag, - "VUI: chroma_loc_info_present_flag"); - if (vuip.chroma_loc_info_present_flag) { - writer.writeUE(vuip.chroma_sample_loc_type_top_field, - "VUI: chroma_sample_loc_type_top_field"); - writer.writeUE(vuip.chroma_sample_loc_type_bottom_field, - "VUI: chroma_sample_loc_type_bottom_field"); - } - writer.writeBool(vuip.timing_info_present_flag, - "VUI: timing_info_present_flag"); - if (vuip.timing_info_present_flag) { - writer.writeNBit(vuip.num_units_in_tick, 32, - "VUI: num_units_in_tick"); - writer.writeNBit(vuip.time_scale, 32, "VUI: time_scale"); - writer.writeBool(vuip.fixed_frame_rate_flag, - "VUI: fixed_frame_rate_flag"); - } - writer.writeBool(vuip.nalHRDParams != null, "VUI: "); - if (vuip.nalHRDParams != null) { - writeHRDParameters(vuip.nalHRDParams, writer); - } - writer.writeBool(vuip.vclHRDParams != null, "VUI: "); - if (vuip.vclHRDParams != null) { - writeHRDParameters(vuip.vclHRDParams, writer); - } - - if (vuip.nalHRDParams != null || vuip.vclHRDParams != null) { - writer - .writeBool(vuip.low_delay_hrd_flag, - "VUI: low_delay_hrd_flag"); - } - writer.writeBool(vuip.pic_struct_present_flag, - "VUI: pic_struct_present_flag"); - writer.writeBool(vuip.bitstreamRestriction != null, "VUI: "); - if (vuip.bitstreamRestriction != null) { - writer - .writeBool( - vuip.bitstreamRestriction.motion_vectors_over_pic_boundaries_flag, - "VUI: motion_vectors_over_pic_boundaries_flag"); - writer.writeUE(vuip.bitstreamRestriction.max_bytes_per_pic_denom, - "VUI: max_bytes_per_pic_denom"); - writer.writeUE(vuip.bitstreamRestriction.max_bits_per_mb_denom, - "VUI: max_bits_per_mb_denom"); - writer.writeUE( - vuip.bitstreamRestriction.log2_max_mv_length_horizontal, - "VUI: log2_max_mv_length_horizontal"); - writer.writeUE( - vuip.bitstreamRestriction.log2_max_mv_length_vertical, - "VUI: log2_max_mv_length_vertical"); - writer.writeUE(vuip.bitstreamRestriction.num_reorder_frames, - "VUI: num_reorder_frames"); - writer.writeUE(vuip.bitstreamRestriction.max_dec_frame_buffering, - "VUI: max_dec_frame_buffering"); - } - - } - - private void writeHRDParameters(HRDParameters hrd, CAVLCWriter writer) - throws IOException { - writer.writeUE(hrd.cpb_cnt_minus1, "HRD: cpb_cnt_minus1"); - writer.writeNBit(hrd.bit_rate_scale, 4, "HRD: bit_rate_scale"); - writer.writeNBit(hrd.cpb_size_scale, 4, "HRD: cpb_size_scale"); - - for (int SchedSelIdx = 0; SchedSelIdx <= hrd.cpb_cnt_minus1; SchedSelIdx++) { - writer.writeUE(hrd.bit_rate_value_minus1[SchedSelIdx], "HRD: "); - writer.writeUE(hrd.cpb_size_value_minus1[SchedSelIdx], "HRD: "); - writer.writeBool(hrd.cbr_flag[SchedSelIdx], "HRD: "); - } - writer.writeNBit(hrd.initial_cpb_removal_delay_length_minus1, 5, - "HRD: initial_cpb_removal_delay_length_minus1"); - writer.writeNBit(hrd.cpb_removal_delay_length_minus1, 5, - "HRD: cpb_removal_delay_length_minus1"); - writer.writeNBit(hrd.dpb_output_delay_length_minus1, 5, - "HRD: dpb_output_delay_length_minus1"); - writer.writeNBit(hrd.time_offset_length, 5, "HRD: time_offset_length"); - } - - @Override - public String toString() { - return "SeqParameterSet{ " + - "\n pic_order_cnt_type=" + pic_order_cnt_type + - ", \n field_pic_flag=" + field_pic_flag + - ", \n delta_pic_order_always_zero_flag=" + delta_pic_order_always_zero_flag + - ", \n weighted_pred_flag=" + weighted_pred_flag + - ", \n weighted_bipred_idc=" + weighted_bipred_idc + - ", \n entropy_coding_mode_flag=" + entropy_coding_mode_flag + - ", \n mb_adaptive_frame_field_flag=" + mb_adaptive_frame_field_flag + - ", \n direct_8x8_inference_flag=" + direct_8x8_inference_flag + - ", \n chroma_format_idc=" + chroma_format_idc + - ", \n log2_max_frame_num_minus4=" + log2_max_frame_num_minus4 + - ", \n log2_max_pic_order_cnt_lsb_minus4=" + log2_max_pic_order_cnt_lsb_minus4 + - ", \n pic_height_in_map_units_minus1=" + pic_height_in_map_units_minus1 + - ", \n pic_width_in_mbs_minus1=" + pic_width_in_mbs_minus1 + - ", \n bit_depth_luma_minus8=" + bit_depth_luma_minus8 + - ", \n bit_depth_chroma_minus8=" + bit_depth_chroma_minus8 + - ", \n qpprime_y_zero_transform_bypass_flag=" + qpprime_y_zero_transform_bypass_flag + - ", \n profile_idc=" + profile_idc + - ", \n constraint_set_0_flag=" + constraint_set_0_flag + - ", \n constraint_set_1_flag=" + constraint_set_1_flag + - ", \n constraint_set_2_flag=" + constraint_set_2_flag + - ", \n constraint_set_3_flag=" + constraint_set_3_flag + - ", \n level_idc=" + level_idc + - ", \n seq_parameter_set_id=" + seq_parameter_set_id + - ", \n residual_color_transform_flag=" + residual_color_transform_flag + - ", \n offset_for_non_ref_pic=" + offset_for_non_ref_pic + - ", \n offset_for_top_to_bottom_field=" + offset_for_top_to_bottom_field + - ", \n num_ref_frames=" + num_ref_frames + - ", \n gaps_in_frame_num_value_allowed_flag=" + gaps_in_frame_num_value_allowed_flag + - ", \n frame_mbs_only_flag=" + frame_mbs_only_flag + - ", \n frame_cropping_flag=" + frame_cropping_flag + - ", \n frame_crop_left_offset=" + frame_crop_left_offset + - ", \n frame_crop_right_offset=" + frame_crop_right_offset + - ", \n frame_crop_top_offset=" + frame_crop_top_offset + - ", \n frame_crop_bottom_offset=" + frame_crop_bottom_offset + - ", \n offsetForRefFrame=" + offsetForRefFrame + - ", \n vuiParams=" + vuiParams + - ", \n scalingMatrix=" + scalingMatrix + - ", \n num_ref_frames_in_pic_order_cnt_cycle=" + num_ref_frames_in_pic_order_cnt_cycle + - '}'; - } -} \ No newline at end of file diff --git a/android-aac-enc/src/main/java/com/googlecode/mp4parser/h264/model/VUIParameters.java b/android-aac-enc/src/main/java/com/googlecode/mp4parser/h264/model/VUIParameters.java deleted file mode 100644 index eec788003..000000000 --- a/android-aac-enc/src/main/java/com/googlecode/mp4parser/h264/model/VUIParameters.java +++ /dev/null @@ -1,94 +0,0 @@ -/* -Copyright (c) 2011 Stanislav Vitvitskiy - -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. -*/ -package com.googlecode.mp4parser.h264.model; - -public class VUIParameters { - - public static class BitstreamRestriction { - - public boolean motion_vectors_over_pic_boundaries_flag; - public int max_bytes_per_pic_denom; - public int max_bits_per_mb_denom; - public int log2_max_mv_length_horizontal; - public int log2_max_mv_length_vertical; - public int num_reorder_frames; - public int max_dec_frame_buffering; - - } - - public boolean aspect_ratio_info_present_flag; - public int sar_width; - public int sar_height; - public boolean overscan_info_present_flag; - public boolean overscan_appropriate_flag; - public boolean video_signal_type_present_flag; - public int video_format; - public boolean video_full_range_flag; - public boolean colour_description_present_flag; - public int colour_primaries; - public int transfer_characteristics; - public int matrix_coefficients; - public boolean chroma_loc_info_present_flag; - public int chroma_sample_loc_type_top_field; - public int chroma_sample_loc_type_bottom_field; - public boolean timing_info_present_flag; - public int num_units_in_tick; - public int time_scale; - public boolean fixed_frame_rate_flag; - public boolean low_delay_hrd_flag; - public boolean pic_struct_present_flag; - public HRDParameters nalHRDParams; - public HRDParameters vclHRDParams; - - public BitstreamRestriction bitstreamRestriction; - public AspectRatio aspect_ratio; - - @Override - public String toString() { - return "VUIParameters{" + "\n" + - "aspect_ratio_info_present_flag=" + aspect_ratio_info_present_flag + "\n" + - ", sar_width=" + sar_width + "\n" + - ", sar_height=" + sar_height + "\n" + - ", overscan_info_present_flag=" + overscan_info_present_flag + "\n" + - ", overscan_appropriate_flag=" + overscan_appropriate_flag + "\n" + - ", video_signal_type_present_flag=" + video_signal_type_present_flag + "\n" + - ", video_format=" + video_format + "\n" + - ", video_full_range_flag=" + video_full_range_flag + "\n" + - ", colour_description_present_flag=" + colour_description_present_flag + "\n" + - ", colour_primaries=" + colour_primaries + "\n" + - ", transfer_characteristics=" + transfer_characteristics + "\n" + - ", matrix_coefficients=" + matrix_coefficients + "\n" + - ", chroma_loc_info_present_flag=" + chroma_loc_info_present_flag + "\n" + - ", chroma_sample_loc_type_top_field=" + chroma_sample_loc_type_top_field + "\n" + - ", chroma_sample_loc_type_bottom_field=" + chroma_sample_loc_type_bottom_field + "\n" + - ", timing_info_present_flag=" + timing_info_present_flag + "\n" + - ", num_units_in_tick=" + num_units_in_tick + "\n" + - ", time_scale=" + time_scale + "\n" + - ", fixed_frame_rate_flag=" + fixed_frame_rate_flag + "\n" + - ", low_delay_hrd_flag=" + low_delay_hrd_flag + "\n" + - ", pic_struct_present_flag=" + pic_struct_present_flag + "\n" + - ", nalHRDParams=" + nalHRDParams + "\n" + - ", vclHRDParams=" + vclHRDParams + "\n" + - ", bitstreamRestriction=" + bitstreamRestriction + "\n" + - ", aspect_ratio=" + aspect_ratio + "\n" + - '}'; - } -} diff --git a/android-aac-enc/src/main/java/com/googlecode/mp4parser/h264/read/BitstreamReader.java b/android-aac-enc/src/main/java/com/googlecode/mp4parser/h264/read/BitstreamReader.java deleted file mode 100644 index 816af6a98..000000000 --- a/android-aac-enc/src/main/java/com/googlecode/mp4parser/h264/read/BitstreamReader.java +++ /dev/null @@ -1,194 +0,0 @@ -/* -Copyright (c) 2011 Stanislav Vitvitskiy - -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. -*/ -package com.googlecode.mp4parser.h264.read; - -import com.googlecode.mp4parser.h264.CharCache; - -import java.io.IOException; -import java.io.InputStream; - -/** - * A dummy implementation of H264 RBSP reading - * - * @author Stanislav Vitvitskiy - */ -public class BitstreamReader { - private InputStream is; - private int curByte; - private int nextByte; - int nBit; - protected static int bitsRead; - - protected CharCache debugBits = new CharCache(50); - - public BitstreamReader(InputStream is) throws IOException { - this.is = is; - curByte = is.read(); - nextByte = is.read(); - } - - /* - * (non-Javadoc) - * - * @see ua.org.jplayer.javcodec.h264.RBSPInputStream#read1Bit() - */ - public int read1Bit() throws IOException { - if (nBit == 8) { - advance(); - if (curByte == -1) { - return -1; - } - } - int res = (curByte >> (7 - nBit)) & 1; - nBit++; - - debugBits.append(res == 0 ? '0' : '1'); - ++bitsRead; - - return res; - } - - /* - * (non-Javadoc) - * - * @see ua.org.jplayer.javcodec.h264.RBSPInputStream#readNBit(int) - */ - public long readNBit(int n) throws IOException { - if (n > 64) - throw new IllegalArgumentException("Can not readByte more then 64 bit"); - - long val = 0; - - for (int i = 0; i < n; i++) { - val <<= 1; - val |= read1Bit(); - } - - return val; - } - - private void advance() throws IOException { - curByte = nextByte; - nextByte = is.read(); - nBit = 0; - } - - /* - * (non-Javadoc) - * - * @see ua.org.jplayer.javcodec.h264.RBSPInputStream#readByte() - */ - public int readByte() throws IOException { - if (nBit > 0) { - advance(); - } - - int res = curByte; - - advance(); - - return res; - } - - /* - * (non-Javadoc) - * - * @see ua.org.jplayer.javcodec.h264.RBSPInputStream#moreRBSPData() - */ - public boolean moreRBSPData() throws IOException { - if (nBit == 8) { - advance(); - } - int tail = 1 << (8 - nBit - 1); - int mask = ((tail << 1) - 1); - boolean hasTail = (curByte & mask) == tail; - - return !(curByte == -1 || (nextByte == -1 && hasTail)); - } - - public long getBitPosition() { - return (bitsRead * 8 + (nBit % 8)); - } - - /* - * (non-Javadoc) - * - * @see ua.org.jplayer.javcodec.h264.RBSPInputStream#readRemainingByte() - */ - public long readRemainingByte() throws IOException { - return readNBit(8 - nBit); - } - - /* - * (non-Javadoc) - * - * @see ua.org.jplayer.javcodec.h264.RBSPInputStream#next_bits(int) - */ - public int peakNextBits(int n) throws IOException { - if (n > 8) - throw new IllegalArgumentException("N should be less then 8"); - if (nBit == 8) { - advance(); - if (curByte == -1) { - return -1; - } - } - int[] bits = new int[16 - nBit]; - - int cnt = 0; - for (int i = nBit; i < 8; i++) { - bits[cnt++] = (curByte >> (7 - i)) & 0x1; - } - - for (int i = 0; i < 8; i++) { - bits[cnt++] = (nextByte >> (7 - i)) & 0x1; - } - - int result = 0; - for (int i = 0; i < n; i++) { - result <<= 1; - result |= bits[i]; - } - - return result; - } - - /* - * (non-Javadoc) - * - * @see ua.org.jplayer.javcodec.h264.RBSPInputStream#byte_aligned() - */ - public boolean isByteAligned() { - return (nBit % 8) == 0; - } - - /* - * (non-Javadoc) - * - * @see ua.org.jplayer.javcodec.h264.RBSPInputStream#close() - */ - public void close() throws IOException { - } - - public int getCurBit() { - return nBit; - } -} \ No newline at end of file diff --git a/android-aac-enc/src/main/java/com/googlecode/mp4parser/h264/read/CAVLCReader.java b/android-aac-enc/src/main/java/com/googlecode/mp4parser/h264/read/CAVLCReader.java deleted file mode 100644 index 07c7f71fb..000000000 --- a/android-aac-enc/src/main/java/com/googlecode/mp4parser/h264/read/CAVLCReader.java +++ /dev/null @@ -1,185 +0,0 @@ -/* -Copyright (c) 2011 Stanislav Vitvitskiy - -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. -*/ -package com.googlecode.mp4parser.h264.read; - - -import com.googlecode.mp4parser.h264.BTree; - -import java.io.IOException; -import java.io.InputStream; - -import static com.googlecode.mp4parser.h264.Debug.println; - - -public class CAVLCReader extends BitstreamReader { - - public CAVLCReader(InputStream is) throws IOException { - super(is); - } - - public long readNBit(int n, String message) throws IOException { - long val = readNBit(n); - - trace(message, String.valueOf(val)); - - return val; - } - - /** - * Read unsigned exp-golomb code - * - * @return - * @throws java.io.IOException - * @throws java.io.IOException - */ - private int readUE() throws IOException { - int cnt = 0; - while (read1Bit() == 0) - cnt++; - - int res = 0; - if (cnt > 0) { - long val = readNBit(cnt); - - res = (int) ((1 << cnt) - 1 + val); - } - - return res; - } - - /* - * (non-Javadoc) - * - * @see - * ua.org.jplayer.javcodec.h264.H264BitInputStream#readUE(java.lang.String) - */ - public int readUE(String message) throws IOException { - int res = readUE(); - - trace(message, String.valueOf(res)); - - return res; - } - - public int readSE(String message) throws IOException { - int val = readUE(); - - int sign = ((val & 0x1) << 1) - 1; - val = ((val >> 1) + (val & 0x1)) * sign; - - trace(message, String.valueOf(val)); - - return val; - } - - public boolean readBool(String message) throws IOException { - - boolean res = read1Bit() == 0 ? false : true; - - trace(message, res ? "1" : "0"); - - return res; - } - - public int readU(int i, String string) throws IOException { - return (int) readNBit(i, string); - } - - public byte[] read(int payloadSize) throws IOException { - byte[] result = new byte[payloadSize]; - for (int i = 0; i < payloadSize; i++) { - result[i] = (byte) readByte(); - } - return result; - } - - public boolean readAE() { - // TODO: do it!! - throw new UnsupportedOperationException("Stan"); - } - - public int readTE(int max) throws IOException { - if (max > 1) - return readUE(); - return ~read1Bit() & 0x1; - } - - public int readAEI() { - // TODO: do it!! - throw new UnsupportedOperationException("Stan"); - } - - public int readME(String string) throws IOException { - return readUE(string); - } - - public Object readCE(BTree bt, String message) throws IOException { - while (true) { - int bit = read1Bit(); - bt = bt.down(bit); - if (bt == null) { - throw new RuntimeException("Illegal code"); - } - Object i = bt.getValue(); - if (i != null) { - trace(message, i.toString()); - return i; - } - } - } - - public int readZeroBitCount(String message) throws IOException { - int count = 0; - while (read1Bit() == 0) - count++; - - trace(message, String.valueOf(count)); - - return count; - } - - public void readTrailingBits() throws IOException { - read1Bit(); - readRemainingByte(); - } - - private void trace(String message, String val) { - StringBuilder traceBuilder = new StringBuilder(); - int spaces; - String pos = String.valueOf(bitsRead - debugBits.length()); - spaces = 8 - pos.length(); - - traceBuilder.append("@" + pos); - - for (int i = 0; i < spaces; i++) - traceBuilder.append(' '); - - traceBuilder.append(message); - spaces = 100 - traceBuilder.length() - debugBits.length(); - for (int i = 0; i < spaces; i++) - traceBuilder.append(' '); - traceBuilder.append(debugBits); - traceBuilder.append(" (" + val + ")"); - debugBits.clear(); - - println(traceBuilder.toString()); - } -} \ No newline at end of file diff --git a/android-aac-enc/src/main/java/com/googlecode/mp4parser/h264/write/BitstreamWriter.java b/android-aac-enc/src/main/java/com/googlecode/mp4parser/h264/write/BitstreamWriter.java deleted file mode 100644 index b382400a8..000000000 --- a/android-aac-enc/src/main/java/com/googlecode/mp4parser/h264/write/BitstreamWriter.java +++ /dev/null @@ -1,108 +0,0 @@ -/* -Copyright (c) 2011 Stanislav Vitvitskiy - -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. -*/ -package com.googlecode.mp4parser.h264.write; - -import com.googlecode.mp4parser.h264.Debug; - -import java.io.IOException; -import java.io.OutputStream; - -/** - * A dummy implementation of H264 RBSP output stream - * - * @author Stanislav Vitvitskiy - */ -public class BitstreamWriter { - - private final OutputStream os; - private int[] curByte = new int[8]; - private int curBit; - - public BitstreamWriter(OutputStream out) { - this.os = out; - } - - /* - * (non-Javadoc) - * - * @see ua.org.jplayer.javcodec.h264.H264BitOutputStream#flush() - */ - public void flush() throws IOException { - for (int i = curBit; i < 8; i++) { - curByte[i] = 0; - } - curBit = 0; - writeCurByte(); - } - - private void writeCurByte() throws IOException { - int toWrite = (curByte[0] << 7) | (curByte[1] << 6) | (curByte[2] << 5) - | (curByte[3] << 4) | (curByte[4] << 3) | (curByte[5] << 2) - | (curByte[6] << 1) | curByte[7]; - os.write(toWrite); - } - - /* - * (non-Javadoc) - * - * @see ua.org.jplayer.javcodec.h264.H264BitOutputStream#write1Bit(int) - */ - public void write1Bit(int value) throws IOException { - Debug.print(value); - if (curBit == 8) { - curBit = 0; - writeCurByte(); - } - curByte[curBit++] = value; - } - - /* - * (non-Javadoc) - * - * @see ua.org.jplayer.javcodec.h264.H264BitOutputStream#writeNBit(long, - * int) - */ - public void writeNBit(long value, int n) throws IOException { - for (int i = 0; i < n; i++) { - write1Bit((int) (value >> (n - i - 1)) & 0x1); - } - } - - /* - * (non-Javadoc) - * - * @see - * ua.org.jplayer.javcodec.h264.H264BitOutputStream#writeRemainingZero() - */ - public void writeRemainingZero() throws IOException { - writeNBit(0, 8 - curBit); - } - - /* - * (non-Javadoc) - * - * @see ua.org.jplayer.javcodec.h264.H264BitOutputStream#writeByte(int) - */ - public void writeByte(int b) throws IOException { - os.write(b); - - } -} \ No newline at end of file diff --git a/android-aac-enc/src/main/java/com/googlecode/mp4parser/h264/write/CAVLCWriter.java b/android-aac-enc/src/main/java/com/googlecode/mp4parser/h264/write/CAVLCWriter.java deleted file mode 100644 index c4e0026d3..000000000 --- a/android-aac-enc/src/main/java/com/googlecode/mp4parser/h264/write/CAVLCWriter.java +++ /dev/null @@ -1,100 +0,0 @@ -/* -Copyright (c) 2011 Stanislav Vitvitskiy - -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. -*/ -package com.googlecode.mp4parser.h264.write; - -import com.googlecode.mp4parser.h264.Debug; - -import java.io.IOException; -import java.io.OutputStream; - - -/** - * A class responsible for outputting exp-Golumb values into binary stream - * - * @author Stanislav Vitvitskiy - */ -public class CAVLCWriter extends BitstreamWriter { - - public CAVLCWriter(OutputStream out) { - super(out); - } - - public void writeU(int value, int n, String string) throws IOException { - Debug.print(string + "\t"); - writeNBit(value, n); - Debug.println("\t" + value); - } - - public void writeUE(int value) throws IOException { - int bits = 0; - int cumul = 0; - for (int i = 0; i < 15; i++) { - if (value < cumul + (1 << i)) { - bits = i; - break; - } - cumul += (1 << i); - } - writeNBit(0, bits); - write1Bit(1); - writeNBit(value - cumul, bits); - } - - public void writeUE(int value, String string) throws IOException { - Debug.print(string + "\t"); - writeUE(value); - Debug.println("\t" + value); - } - - public void writeSE(int value, String string) throws IOException { - Debug.print(string + "\t"); - writeUE((value << 1) * (value < 0 ? -1 : 1) + (value > 0 ? 1 : 0)); - Debug.println("\t" + value); - } - - public void writeBool(boolean value, String string) throws IOException { - Debug.print(string + "\t"); - write1Bit(value ? 1 : 0); - Debug.println("\t" + value); - } - - public void writeU(int i, int n) throws IOException { - writeNBit(i, n); - } - - public void writeNBit(long value, int n, String string) throws IOException { - Debug.print(string + "\t"); - for (int i = 0; i < n; i++) { - write1Bit((int) (value >> (n - i - 1)) & 0x1); - } - Debug.println("\t" + value); - } - - public void writeTrailingBits() throws IOException { - write1Bit(1); - writeRemainingZero(); - flush(); - } - - public void writeSliceTrailingBits() { - throw new IllegalStateException("todo"); - } -} \ No newline at end of file diff --git a/android-aac-enc/src/main/java/com/googlecode/mp4parser/srt/SrtParser.java b/android-aac-enc/src/main/java/com/googlecode/mp4parser/srt/SrtParser.java deleted file mode 100644 index 3e3a3b974..000000000 --- a/android-aac-enc/src/main/java/com/googlecode/mp4parser/srt/SrtParser.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright 2011 Sebastian Annies, Hamburg - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.googlecode.mp4parser.srt; - -import com.googlecode.mp4parser.authoring.tracks.TextTrackImpl; - -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.LineNumberReader; - -/** - * Parses a .srt file and creates a Track for it. - */ -public class SrtParser { - public static TextTrackImpl parse(InputStream is) throws IOException { - LineNumberReader r = new LineNumberReader(new InputStreamReader(is, "UTF-8")); - TextTrackImpl track = new TextTrackImpl(); - String numberString; - while ((numberString = r.readLine()) != null) { - String timeString = r.readLine(); - String lineString = ""; - String s; - while (!((s = r.readLine()) == null || s.trim().equals(""))) { - lineString += s + "\n"; - } - - long startTime = parse(timeString.split("-->")[0]); - long endTime = parse(timeString.split("-->")[1]); - - track.getSubs().add(new TextTrackImpl.Line(startTime, endTime, lineString)); - - } - return track; - } - - private static long parse(String in) { - long hours = Long.parseLong(in.split(":")[0].trim()); - long minutes = Long.parseLong(in.split(":")[1].trim()); - long seconds = Long.parseLong(in.split(":")[2].split(",")[0].trim()); - long millies = Long.parseLong(in.split(":")[2].split(",")[1].trim()); - - return hours * 60 * 60 * 1000 + minutes * 60 * 1000 + seconds * 1000 + millies; - - } -} diff --git a/android-aac-enc/src/main/java/com/googlecode/mp4parser/util/ByteBufferByteChannel.java b/android-aac-enc/src/main/java/com/googlecode/mp4parser/util/ByteBufferByteChannel.java deleted file mode 100644 index 9f3264b7e..000000000 --- a/android-aac-enc/src/main/java/com/googlecode/mp4parser/util/ByteBufferByteChannel.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright 2012 Sebastian Annies, Hamburg - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.googlecode.mp4parser.util; - -import java.io.EOFException; -import java.io.IOException; -import java.nio.ByteBuffer; -import java.nio.channels.ByteChannel; - -/** - * Creates a ReadableByteChannel that is backed by a ByteBuffer. - */ -public class ByteBufferByteChannel implements ByteChannel { - ByteBuffer byteBuffer; - - public ByteBufferByteChannel(ByteBuffer byteBuffer) { - this.byteBuffer = byteBuffer; - } - - public int read(ByteBuffer dst) throws IOException { - byte[] b = dst.array(); - int r = dst.remaining(); - if (byteBuffer.remaining() >= r) { - byteBuffer.get(b, dst.position(), r); - return r; - } else { - throw new EOFException("Reading beyond end of stream"); - } - } - - public boolean isOpen() { - return true; - } - - public void close() throws IOException { - } - - public int write(ByteBuffer src) throws IOException { - int r = src.remaining(); - byteBuffer.put(src); - return r; - } -} diff --git a/android-aac-enc/src/main/java/com/googlecode/mp4parser/util/CastUtils.java b/android-aac-enc/src/main/java/com/googlecode/mp4parser/util/CastUtils.java deleted file mode 100644 index 2dd011ae8..000000000 --- a/android-aac-enc/src/main/java/com/googlecode/mp4parser/util/CastUtils.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright 2012 Sebastian Annies, Hamburg - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.googlecode.mp4parser.util; - - -public class CastUtils { - /** - * Casts a long to an int. In many cases I use a long for a UInt32 but this cannot be used to allocate - * ByteBuffers or arrays since they restricted to Integer.MAX_VALUE this cast-method will throw - * a RuntimeException if the cast would cause a loss of information. - * - * @param l the long value - * @return the long value as int - */ - public static int l2i(long l) { - if (l > Integer.MAX_VALUE || l < Integer.MIN_VALUE) { - throw new RuntimeException("A cast to int has gone wrong. Please contact the mp4parser discussion group (" + l + ")"); - } - return (int) l; - } -} diff --git a/android-aac-enc/src/main/java/com/googlecode/mp4parser/util/Math.java b/android-aac-enc/src/main/java/com/googlecode/mp4parser/util/Math.java deleted file mode 100644 index 27fd4b27d..000000000 --- a/android-aac-enc/src/main/java/com/googlecode/mp4parser/util/Math.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.googlecode.mp4parser.util; - -public class Math { - public static long gcd(long a, long b) { - while (b > 0) { - long temp = b; - b = a % b; // % is remainder - a = temp; - } - return a; - } - - public static int gcd(int a, int b) { - while (b > 0) { - int temp = b; - b = a % b; // % is remainder - a = temp; - } - return a; - } - - public static long lcm(long a, long b) { - return a * (b / gcd(a, b)); - } - - public static int lcm(int a, int b) { - return a * (b / gcd(a, b)); - } - -} diff --git a/android-aac-enc/src/main/java/com/googlecode/mp4parser/util/Path.java b/android-aac-enc/src/main/java/com/googlecode/mp4parser/util/Path.java deleted file mode 100644 index c20d3b3a3..000000000 --- a/android-aac-enc/src/main/java/com/googlecode/mp4parser/util/Path.java +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Copyright 2012 Sebastian Annies, Hamburg - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.googlecode.mp4parser.util; - - -import java.util.Collections; -import java.util.LinkedList; -import java.util.List; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import com.coremedia.iso.IsoFile; -import com.coremedia.iso.boxes.Box; -import com.coremedia.iso.boxes.ContainerBox; - -public class Path { - - IsoFile isoFile; - - public Path(IsoFile isoFile) { - this.isoFile = isoFile; - } - - private static Pattern component = Pattern.compile("(....)(\\[(.*)\\])?"); - - public String createPath(Box box) { - return createPath(box, ""); - } - - private String createPath(Box box, String path) { - if (box instanceof IsoFile) { - assert box == isoFile; - return path; - } else { - List boxesOfBoxType = box.getParent().getBoxes(box.getClass()); - int index = boxesOfBoxType.indexOf(box); - path = String.format("/%s[%d]", box.getType(), index) + path; - - return createPath(box.getParent(), path); - } - } - - public Box getPath(String path) { - List all = getPath(isoFile, path); - return all.isEmpty() ?null:all.get(0); - } - - public List getPaths(String path) { - return getPath(isoFile, path); - } - - public boolean isContained(Box box, String path) { - return getPath(isoFile, path).contains(box); - } - - private List getPath(Box box, String path) { - if (path.startsWith("/")) { - path = path.substring(1); - } - if (path.length() == 0) { - return Collections.singletonList(box); - } else { - String later; - String now; - if (path.contains("/")) { - later = path.substring(path.indexOf('/')); - now = path.substring(0, path.indexOf('/')); - } else { - now = path; - later = ""; - } - - Matcher m = component.matcher(now); - if (m.matches()) { - String type = m.group(1); - int index = -1; - if (m.group(2) != null) { - // we have a specific index - String indexString = m.group(3); - index = Integer.parseInt(indexString); - } - List children = new LinkedList(); - int currentIndex = 0; - for (Box box1 : ((ContainerBox) box).getBoxes()) { - if (box1.getType().equals(type)) { - if (index == -1 || index == currentIndex) { - children.addAll(getPath(box1, later)); - } - currentIndex++; - } - } - return children; - - } else { - throw new RuntimeException("invalid path."); - } - } - - } -} diff --git a/android-aac-enc/src/main/java/com/googlecode/mp4parser/util/UUIDConverter.java b/android-aac-enc/src/main/java/com/googlecode/mp4parser/util/UUIDConverter.java deleted file mode 100644 index 635e4c17b..000000000 --- a/android-aac-enc/src/main/java/com/googlecode/mp4parser/util/UUIDConverter.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright 2012 Sebastian Annies, Hamburg - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.googlecode.mp4parser.util; - -import java.nio.ByteBuffer; -import java.nio.ByteOrder; -import java.util.UUID; - -/** - * UUID from/to byte array. - */ -public class UUIDConverter { - public static byte[] convert(UUID uuid) { - - long msb = uuid.getMostSignificantBits(); - long lsb = uuid.getLeastSignificantBits(); - byte[] buffer = new byte[16]; - - for (int i = 0; i < 8; i++) { - buffer[i] = (byte) (msb >>> 8 * (7 - i)); - } - for (int i = 8; i < 16; i++) { - buffer[i] = (byte) (lsb >>> 8 * (7 - i)); - } - - return buffer; - - } - - public static UUID convert(byte[] uuidBytes) { - ByteBuffer b = ByteBuffer.wrap(uuidBytes); - b.order(ByteOrder.BIG_ENDIAN); - return new UUID(b.getLong(), b.getLong()); - } -} diff --git a/android-aac-enc/src/main/java/com/todoroo/aacenc/AACEncoder.java b/android-aac-enc/src/main/java/com/todoroo/aacenc/AACEncoder.java deleted file mode 100644 index b7bd5369a..000000000 --- a/android-aac-enc/src/main/java/com/todoroo/aacenc/AACEncoder.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.todoroo.aacenc; - -public class AACEncoder { - - /** - * Native JNI - initialize AAC encoder - * - */ - public native void init(int bitrate, int channels, - int sampleRate, int bitsPerSample, String outputFile); - - /** - * Native JNI - encode one or more frames - * - */ - public native void encode(byte[] inputArray); - - /** - * Native JNI - uninitialize AAC encoder and flush file - * - */ - public native void uninit(); - - static { - System.loadLibrary("aac-encoder"); - } - -} diff --git a/android-aac-enc/src/main/java/com/todoroo/aacenc/AACRecorder.java b/android-aac-enc/src/main/java/com/todoroo/aacenc/AACRecorder.java deleted file mode 100644 index f476f7aa6..000000000 --- a/android-aac-enc/src/main/java/com/todoroo/aacenc/AACRecorder.java +++ /dev/null @@ -1,100 +0,0 @@ -package com.todoroo.aacenc; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; - -import android.content.Context; -import android.media.AudioFormat; -import android.media.AudioRecord; -import android.media.MediaRecorder.AudioSource; - -/** - * This class combines an Android AudioRecord and our own AACEncoder - * to directly record an AAC audio file from the mic. Users should call - * startRecording() and stopRecording() in sequence, and then listen - * for the encodingFinished() callback to perform final actions like - * converting to M4A format. - * @author Sam - * - */ -public class AACRecorder { - - private AudioRecord audioRecord; - private AACEncoder encoder; - - private boolean recording; - private AACRecorderCallbacks listener; - - private static final int SAMPLE_RATE = 8000; - private static final int NOTIFICATION_PERIOD = 160; - private static final int MIN_BUFFER_SIZE = AudioRecord.getMinBufferSize(SAMPLE_RATE, - AudioFormat.CHANNEL_CONFIGURATION_MONO, AudioFormat.ENCODING_PCM_16BIT) * 10; - - public interface AACRecorderCallbacks { - public void encodingFinished(); - } - - private Thread readerThread = new Thread() { - private byte[] readBuffer = new byte[NOTIFICATION_PERIOD * 2]; - public void run() { - ByteArrayOutputStream baos = new ByteArrayOutputStream(SAMPLE_RATE * 2); - int bytesRead = 0; - while(recording) { - bytesRead = audioRecord.read(readBuffer, 0, readBuffer.length); - try { - baos.write(readBuffer); - } catch (IOException e) { - // - } - if (bytesRead <= 0) - break; - } - encoder.encode(baos.toByteArray()); - finishRecording(); - baos.reset(); - } - }; - - - public AACRecorder() { - encoder = new AACEncoder(); - } - - public synchronized void startRecording(String tempFile) { - if (recording) - return; - - audioRecord = new AudioRecord(AudioSource.MIC, SAMPLE_RATE, AudioFormat.CHANNEL_CONFIGURATION_MONO, - AudioFormat.ENCODING_PCM_16BIT, MIN_BUFFER_SIZE); - - - audioRecord.setPositionNotificationPeriod(NOTIFICATION_PERIOD); - - encoder.init(64000, 1, SAMPLE_RATE, 16, tempFile); - - recording = true; - audioRecord.startRecording(); - - readerThread.start(); - } - - public synchronized void stopRecording() { - if (!recording) - return; - - audioRecord.stop(); - } - - public synchronized void finishRecording() { - recording = false; - audioRecord.release(); - encoder.uninit(); - if (listener != null) - listener.encodingFinished(); - } - - public void setListener(AACRecorderCallbacks listener) { - this.listener = listener; - } - -} diff --git a/android-aac-enc/src/main/java/com/todoroo/aacenc/AACToM4A.java b/android-aac-enc/src/main/java/com/todoroo/aacenc/AACToM4A.java deleted file mode 100644 index bb5672f75..000000000 --- a/android-aac-enc/src/main/java/com/todoroo/aacenc/AACToM4A.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.todoroo.aacenc; - -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.PushbackInputStream; - -import android.content.Context; - -import com.coremedia.iso.IsoFile; -import com.googlecode.mp4parser.authoring.Movie; -import com.googlecode.mp4parser.authoring.Track; -import com.googlecode.mp4parser.authoring.builder.DefaultMp4Builder; -import com.googlecode.mp4parser.authoring.tracks.AACTrackImpl; - -public class AACToM4A { - - private static Context context; - - public static Context getContext() { - return context; - } - - public void convert(Context context, String infile, String outfile) throws IOException { - AACToM4A.context = context; - - InputStream input = new FileInputStream(infile); - - PushbackInputStream pbi = new PushbackInputStream(input, 100); - - System.err.println("well you got " + input.available()); - Movie movie = new Movie(); - - Track audioTrack = new AACTrackImpl(pbi); - movie.addTrack(audioTrack); - - IsoFile out = new DefaultMp4Builder().build(movie); - FileOutputStream output = new FileOutputStream(outfile); - out.getBox(output.getChannel()); - output.close(); - } - -} diff --git a/android-aac-enc/src/main/java/com/todoroo/aacenc/ContextManager.java b/android-aac-enc/src/main/java/com/todoroo/aacenc/ContextManager.java deleted file mode 100644 index b4e54193f..000000000 --- a/android-aac-enc/src/main/java/com/todoroo/aacenc/ContextManager.java +++ /dev/null @@ -1,65 +0,0 @@ -/** - * Copyright (c) 2012 Todoroo Inc - * - * See the file "LICENSE" for the full license governing this code. - */ -package com.todoroo.aacenc; - -import android.app.Activity; -import android.content.Context; -import android.content.res.Resources; - -/** - * Singleton class to manage current application context - * b - * @author Tim Su - * - */ -public final class ContextManager { - - /** - * Global application context - */ - private static Context context = null; - - /** - * Sets the global context - * - * @param context - */ - public static void setContext(Context context) { - if(context == null || context.getApplicationContext() == null) - return; - if(ContextManager.context != null && !(context instanceof Activity)) - return; - ContextManager.context = context; - } - - /** - * Gets the global context - */ - public static Context getContext() { - return context; - } - - /** - * Convenience method to read a string from the resources - * - * @param resId resource - * @param parameters % arguments - * @return resource string - */ - public static String getString(int resId, Object... formatArgs) { - return context.getString(resId, formatArgs); - } - - /** - * Convenience method to read resources - * - * @return resources object - */ - public static Resources getResources() { - return context.getResources(); - } - -} diff --git a/android-aac-enc/src/main/res/drawable-hdpi/ic_launcher.png b/android-aac-enc/src/main/res/drawable-hdpi/ic_launcher.png deleted file mode 100644 index 8074c4c57..000000000 Binary files a/android-aac-enc/src/main/res/drawable-hdpi/ic_launcher.png and /dev/null differ diff --git a/android-aac-enc/src/main/res/drawable-ldpi/ic_launcher.png b/android-aac-enc/src/main/res/drawable-ldpi/ic_launcher.png deleted file mode 100644 index 1095584ec..000000000 Binary files a/android-aac-enc/src/main/res/drawable-ldpi/ic_launcher.png and /dev/null differ diff --git a/android-aac-enc/src/main/res/drawable-mdpi/ic_launcher.png b/android-aac-enc/src/main/res/drawable-mdpi/ic_launcher.png deleted file mode 100644 index a07c69fa5..000000000 Binary files a/android-aac-enc/src/main/res/drawable-mdpi/ic_launcher.png and /dev/null differ diff --git a/android-aac-enc/src/main/res/layout/main.xml b/android-aac-enc/src/main/res/layout/main.xml deleted file mode 100644 index 7fbd3e681..000000000 --- a/android-aac-enc/src/main/res/layout/main.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - -