Thursday, March 18, 2010

Blackberry Resource Error - Looking for rrh file after SVN checkin

I have no idea why Blackberry Resource Builder is asking for rrh file in a .svn folder. But, this error will prevent you from building your Eclipse workspace. The workaround is to exclude the following at your Build path

Eclipse -> Right click on your source -> Build Path -> Configure Build Path -> Double click on Excluded -> Click Add -> add in **/.svn/**

You should be able to build your workspace after that.

Wednesday, March 17, 2010

AAC Configuration

AAC is MPEG4 part 3 and it comes with a configuration data before it can be decoded by a decoder. This configuration data can usually be found in the SDP, under audio track -> config. Normally, it is a 2 bytes in hexadecimal. Below is a sample of the information which may be contains in the configuration data.


1210 = 0001 0010 0001 0000

5 bits for object type = 00010 = 2 = AAC low complexity

4 bits for sampling rate = 0100 = 44100hz

4 bit for channel = 0010 = 2 channel

1 bit for frame length flag = 0 for 1024 sample

1 bit for depends on core coder = 0

1 bit for extension flag = 0

frame length flag:
0: Each packet contains 1024 samples
1: Each packet contains 960 samples

The full specification for AudioSpecificConfig is stated in ISO 14496-3 Section 1.6.2.1

See http://wiki.multimedia.cx/index.php?title=MPEG-4_Audio for complete list.

Tuesday, March 16, 2010

CL and Link commands

You can compile and link c/c++ code via cl and link
Generic Examples
cl /Od /D /D_DEBUG /Yd /Zi /EHsc /MTd /GS /Fo"build/" /W3 /nologo /c
/I "ANY INCLUDE FOLDER" /D "ANY DEFINED MARCO" "SOURCE FILES"

Important note for above example

/c - compile only. Without this, it will tries to link as well
/I - add 1 include folder
/D - add 1 user define marco
/D_DEBUG - add debug information

link /DEBUG /OUT:"OUTPUT NAME" /INCREMENTAL:NO /NOLOGO
/LIBPATH:"ADDITIONAL LIBRARY PATH" /DLL /SUBSYSTEM:WINDOWS
/OPT:REF /OPT:ICF /IMPLIB:"LIBRARY OUTPUT" /MACHINE:X86 "LIBRARY FILES"


Important note for above example

/DEBUG - link with debug information
>/OUT - output name and location
/LIBPATH - add 1 library path

Sample Usage




cl /Od /D /D_DEBUG /Yd /Zi /EHsc /MTd /GS /Fo"build/" /W3 /nologo /c
/I "include" /I "test\include" /D "MY_MARCO1" /D "MY_MARCO2" src\*.c src\*.cpp

link /DEBUG /OUT:"output\my.dll" /INCREMENTAL:NO /NOLOGO
/LIBPATH:"lib" /LIBPATH:"my\lib" /DLL /SUBSYSTEM:WINDOWS /OPT:REF /OPT:ICF /IMPLIB:"output\my.lib" /MACHINE:X86 first.lib second.lib



For convenience, I copied the full cl and link options below

cl.exe:


C/C++ COMPILER OPTIONS

-OPTIMIZATION-

/O1 minimize space

/O2 maximize speed

/Ob<n> inline expansion (default n=0)

/Od disable optimizations (default)

/Og enable global optimization

/Oi[-] enable intrinsic functions

/Os favor code space

/Ot favor code speed

/Ox maximum optimizations

/Oy[-] enable frame pointer omission


-CODE GENERATION-

/GF enable read-only string pooling

/Gm[-] enable minimal rebuild

/Gy[-] separate functions for linker

/GS[-] enable security checks

/GR[-] enable C++ RTTI

/GX[-] enable C++ EH (same as /EHsc)

/EHs enable C++ EH (no SEH exceptions)

/EHa enable C++ EH (w/ SEH exceptions)

/EHc extern "C" defaults to nothrow

/fp:<except[-]|fast|precise|strict> choose floating-point model:
except[-] - consider floating-point exceptions when generating code
fast - "fast" floating-point model; results are less predictable
precise - "precise" floating-point model; results are predictable
strict - "strict" floating-point model (implies /fp:except)

/GL[-] enable link-time code generation

/GA optimize for Windows Application

/Ge force stack checking for all funcs

/Gs[num] control stack checking calls

/Gh enable _penter function call

/GH enable _pexit function call

/GT generate fiber-safe TLS accesses

/RTC1 Enable fast checks (/RTCsu)

/RTCc Convert to smaller type checks

/RTCs Stack Frame runtime checking

/RTCu Uninitialized local usage checks

/clr[:option] compile for common language runtime, where option is:
pure - produce IL-only output file (no native executable code)
safe - produce IL-only verifiable output file
oldSyntax - accept the Managed Extensions syntax from Visual C++ 2002/2003
initialAppDomain - enable initial AppDomain behavior of Visual C++ 2002
noAssembly - do not produce an assembly

/Gd __cdecl calling convention

/Gr __fastcall calling convention

/Gz __stdcall calling convention

/GZ Enable stack checks (/RTCs)

/QIfist[-] use FIST instead of ftol()

/hotpatch ensure function padding for hotpatchable images

/arch:<SSE|SSE2> minimum CPU architecture requirements, one of:
SSE - enable use of instructions available with SSE enabled CPUs
SSE2 - enable use of instructions available with SSE2 enabled CPUs

-OUTPUT FILES-

/Fa[file] name assembly listing file

/FA[scu] configure assembly listing

/Fd[file] name .PDB file

/Fe<file> name executable file

/Fm[file] name map file

/Fo<file> name object file

/Fp<file> name precompiled header file

/Fr[file] name source browser file

/FR[file] name extended .SBR file

/doc[file] process XML documentation comments and optionally name the .xdc file

-PREPROCESSOR-

/AI<dir> add to assembly search path

/FU<file> forced using assembly/module

/C don't strip comments

/D<name>{=|#}<text> define macro

/E preprocess to stdout

/EP preprocess to stdout, no #line

/P preprocess to file

/Fx merge injected code to file

/FI<file> name forced include file

/U<name> remove predefined macro

/u remove all predefined macros

/I<dir> add to include search path

/X ignore "standard places"


-LANGUAGE-

/Zi enable debugging information

/Z7 enable old-style debug info

/Zp[n] pack structs on n-byte boundary

/Za disable extensions

/Ze enable extensions (default)

/Zl omit default library name in .OBJ

/Zg generate function prototypes

/Zs syntax check only

/vd{0|1|2} disable/enable vtordisp

/vm<x> type of pointers to members

/Zc:arg1[,arg2] C++ language conformance, where arguments can be:
forScope[-] - enforce Standard C++ for scoping rules
wchar_t[-] - wchar_t is the native type, not a typedef

/ZI enable Edit and Continue debug info

/openmp enable OpenMP 2.0 language extensions

-MISCELLANEOUS-

@<file> options response file

/?, /help print this help message

/bigobj generate extended object format

/c compile only, no link

/errorReport:option Report internal compiler errors to Microsoft
none - do not send report
prompt - prompt to immediately send report
queue - at next admin logon, prompt to send report (default)
send - send report automatically

/FC use full pathnames in diagnostics

/H<num> max external name length

/J default char type is unsigned

/nologo suppress copyright message

/showIncludes show include file names

/Tc<source file> compile file as .c

/Tp<source file> compile file as .cpp

/TC compile all files as .c

/TP compile all files as .cpp

/V<string> set version string

/w disable all warnings

/wd<n> disable warning n

/we<n> treat warning n as an error

/wo<n> issue warning n once

/w<l><n> set warning level 1-4 for n

/W<n> set warning level (default n=1)

/Wall enable all warnings

/WL enable one line diagnostics

/WX treat warnings as errors

/Yc[file] create .PCH file

/Yd put debug info in every .OBJ

/Yl[sym] inject .PCH ref for debug lib

/Yu[file] use .PCH file

/Y- disable all PCH options

/Zm<n> max memory alloc (% of default)

/Wp64 enable 64 bit porting warnings


-LINKING-

/LD Create .DLL

/LDd Create .DLL debug library

/LN Create a .netmodule

/F<num> set stack size

/link [linker options and libraries]

/MD link with MSVCRT.LIB

/MT link with LIBCMT.LIB

/MDd link with MSVCRTD.LIB debug lib

/MTd link with LIBCMTD.LIB debug lib




Visual C++ Linker Options
Linker Options

LINK is a tool that links Common Object File Format (COFF) object files and libraries to create a executable (.exe) file or dynamic-link library (DLL).

The table below is a comprehensive list of options for LINK.exe. This section also includes information on:

Linker options specified on the command line are not case sensitive: /base and /BASE mean the same thing.

You can specify some linker options via the comment pragma.


Option

Purpose

@

Specifies a response file

/ALIGN

Specifies the alignment of each section

/ALLOWBIND

Specifies that a DLL cannot be bound

/ALLOWISOLATION

Specifies behavior for manifest lookup.

/ASSEMBLYDEBUG

Adds the DebuggableAttribute to a managed image.

/ASSEMBLYLINKRESOURCE

Create a link to a managed resource.

/ASSEMBLYMODULE

Specifies that a Microsoft Intermediate Language (MSIL) module should be imported into the assembly

/ASSEMBLYRESOURCE

Embeds a managed resource file to an assembly

/BASE

Sets a base address for the program

/CLRIMAGETYPE

Sets the type (IJW, pure, or safe) of a CLR image.

/CLRSUPPORTLASTERROR

Preserves the last error code of functions called through the P/Invoke mechanism.

/CLRTHREADATTRIBUTE

Specify which threading attribute you want applied to the entry point of your CLR program.

/CLRUNMANAGEDCODECHECK

/CLRUNMANAGEDCODECHECK specifies whether the linker will apply the SuppressUnmanagedCodeSecurity attribute to linker-generated PInvoke stubs that call from managed code into native DLLs.

/DEBUG

Creates debugging information

/DEF

Passes a module-definition (.def) file to the linker

/DEFAULTLIB

Searches the specified library when resolving external references

/DELAY

Controls the delayed loading of DLLs

/DELAYLOAD

Causes the delayed loading of the specified DLL

/DELAYSIGN

Partially sign an assembly.

/DLL

Builds a DLL

/DRIVER

Creates a Windows NT kernel mode driver

/ENTRY

Sets the starting address

/errorReport

Report internal linker errors to Microsoft.

/EXPORT

Exports a function

/FIXED

Creates a program that can be loaded only at its preferred base address

/FORCE

Forces a link to complete in spite of unresolved or symbols defined more than once

/FUNCTIONPADMIN

Creates a hotpatchable image.

/HEAP

Sets the size of the heap in bytes

/IDLOUT

Specifies the name of the .idl file and other MIDL output files

/IGNOREIDL

Prevents processing attribute information into an .idl file

/IMPLIB

Overrides the default import library name

/INCLUDE

Forces symbol references

/INCREMENTAL

Controls incremental linking

/KEYCONTAINER

Specify a key container to sign an assembly.

/KEYFILE

Specify key or key pair to sign an assembly.

/LARGEADDRESSAWARE

Tells the compiler that the application supports addresses larger than two gigabytes

/LIBPATH

Allows the user to override the environmental library path

/LTCG

Specifies link-time code generation

/MACHINE

Specifies the target platform

/MANIFEST

Create a side-by-side manifest file.

/MANIFESTDEPENDENCY

Specify a <dependentAssembly> section in your manifest file.

/MANIFESTFILE (Name Manifest File)

Change the default name of the manifest file.

/MAP

Creates a mapfile

/MAPINFO

Includes the specified information in the mapfile

/MERGE

Combines sections

/MIDL

Specifies MIDL command line options

/NOASSEMBLY

Suppresses the creation of a .NET Framework assembly

/NODEFAULTLIB

Ignores all (or specified) default libraries when resolving external references

/NOENTRY

Creates a resource-only DLL

/NOLOGO

Suppresses startup banner

/NXCOMPAT

Marks an executable as having been tested to be compatible with Windows Data Execution Prevention feature.

/OPT

Controls LINK optimizations

/ORDER

Places COMDATs into the image in a predetermined order

/OUT

Specifies the output file name

/PDB

Creates a program database (PDB) file

/PDBSTRIPPED

Creates a program database (PDB) file with no private symbols

/PGD

Specify .pgd file for profile guided optionizations.

/PROFILE

Produces an output file that can be used with the Performance Tools profiler.

/RELEASE

Sets the Checksum in the .exe header

/SAFESEH

Specify that the image will contain a table of safe exception handlers.

/SECTION

Overrides the attributes of a section

/STACK

Sets the size of the stack in bytes

/STUB

Attaches an MS-DOS stub program to a Win32 program

/SUBSYSTEM

Tells the operating system how to run the .exe file

/SWAPRUN

Tells the operating system to copy the linker output to a swap file before running it

/TLBID

Allows you to specify the resource ID of the linker-generated type library

/TLBOUT

Specifies the name of the .tlb file and other MIDL output files

/TSAWARE

Creates an application that is specifically designed to run under Terminal Server

/VERBOSE

Prints linker progress messages

/VERSION

Assigns a version number

/WX

Treat linker warnings as errors.

Saturday, March 13, 2010

RFC 3640 for AAC

RFC 3640 defined the rtp payload format for transport MPEG4 elementary stream. More importantly, I am only interested how to setup SDP for AAC High Bitrate and Low Bitrate

First, you need to have a AU header section in the RTP payload. In the AU header section, it has a 2 bytes AU headers length field that denote the length of the all AU headers in bits. For each AU header, it has a list of optional information. You will mostly only interested in AU size and Au index. See section 3.2.1 for details

Next, the SDP define the structure of the RTP payload. If mode exists, RFC 3640 has to be used. I will be focusing on AAC-lbr and AAC-hbr.

mode=AAC-lbr

  • The maximum size of the frame is 63 bytes
  • AAC frames must not be fragment
  • 6 bits of AU size
  • 2 bits to AU index (-delta)
  • AU index field must be 0
  • SDP must present sizeLength, indexLength, indexDeltaLength
  • config is the hexadecimal of AudioSpecificConfig of 14496-3
Sample SDP entry

m=audio 49230 RTP/AVP 96 a=rtpmap:96 mpeg4-generic/22050/1 a=fmtp:96 streamtype=5; profile-level-id=14; mode=AAC-lbr; config= 1388; sizeLength=6; indexLength=2; indexDeltaLength=2; constantDuration=1024; maxDisplacement=5

See 3.3.5 for detail

mode=AAC-hbr

  • The maximum size of the frame is 8191 bytes
  • AAC frames can be interleaved and hence receivers must support de-interleaving
  • 13 bits of AU size
  • 3 bits to AU index (-delta)
  • AU index field must be 0
  • SDP must present sizeLength, indexLength, indexDeltaLength
  • config is the hexadecimal of AudioSpecificConfig of 14496-3

Sample SDP entry

m=audio 49230 RTP/AVP 96 a=rtpmap:96 mpeg4-generic/48000/6 a=fmtp:96 streamtype=5; profile-level-id=16; mode=AAC-hbr; config=11B0; sizeLength=13; indexLength=3; indexDeltaLength=3; constantDuration=1024
Since each RTP AAC payload can be independently decoded, you can extract the raw AAC data in the rtp packet as follow

1. Since at AU header section, there is 2 bytes of AU headers length which denote the all AU headers length in bits, all you need is to read the 2 bytes value into integer and divided by 8. That will tell you the size of all raw AAC data size

2. Next, base on the sizeLength in SDP, you will know the size of each raw AAC data in the payload. Parse each AAC raw data according to the respective size denoted in each AU header

See 3.3.6 for detail