diff options
author | David Schleef <ds@schleef.org> | 2010-08-20 12:15:14 -0700 |
---|---|---|
committer | David Schleef <ds@schleef.org> | 2010-08-20 12:15:14 -0700 |
commit | 02ec311f66e21d23541830424bdb735a4d2df484 (patch) | |
tree | 022db8ec4ac72884074c4281dd478343f71af1c6 /doc | |
parent | 241a7ad309ee2969672500792933f6c0afe330ee (diff) |
Update documentation, add tutorial
Diffstat (limited to 'doc')
-rw-r--r-- | doc/Makefile.am | 2 | ||||
-rw-r--r-- | doc/building.xml | 8 | ||||
-rw-r--r-- | doc/opcode_table.xml | 280 | ||||
-rw-r--r-- | doc/orc-docs.sgml | 1 | ||||
-rw-r--r-- | doc/table.xml | 659 | ||||
-rw-r--r-- | doc/tutorial.xml | 510 |
6 files changed, 1284 insertions, 176 deletions
diff --git a/doc/Makefile.am b/doc/Makefile.am index df67359..1de8cd8 100644 --- a/doc/Makefile.am +++ b/doc/Makefile.am @@ -66,7 +66,7 @@ HTML_IMAGES= # Extra SGML files that are included by $(DOC_MAIN_SGML_FILE). # e.g. content_files=running.sgml building.sgml changes-2.0.sgml -content_files=building.xml concepts.xml opcode_table.xml opcodes.xml table.xml +content_files=building.xml concepts.xml opcode_table.xml opcodes.xml tutorial.xml table.xml # SGML files where gtk-doc abbrevations (#GtkWidget) are expanded # These files must be listed here *and* in content_files diff --git a/doc/building.xml b/doc/building.xml index d65e10c..8c989a2 100644 --- a/doc/building.xml +++ b/doc/building.xml @@ -50,9 +50,11 @@ How to build Orc and applications using it. </para> <para> - Future releases will have configure options that allow Orc - to be compiled in a minimal configuration for embedded systems. - This functionality is not yet available for general use. + By default, code generators for all targets are built into the + library. Embedded system developers may wish to use the + --enable-backed option, which will disable all other code + generators, saving about 200 kB in binary size. Outside of + embedded systems, using --enable-backend is not recommended. </para> </refsect1> diff --git a/doc/opcode_table.xml b/doc/opcode_table.xml index 4bf216b..b20d9fe 100644 --- a/doc/opcode_table.xml +++ b/doc/opcode_table.xml @@ -101,6 +101,78 @@ <entry>a</entry> </row> <row> +<entry>loadb</entry> +<entry>1</entry> +<entry>1</entry> +<entry></entry> +<entry>load from memory</entry> +<entry>array[i]</entry> +</row> +<row> +<entry>loadoffb</entry> +<entry>1</entry> +<entry>1</entry> +<entry>4S</entry> +<entry>load from memory with offset</entry> +<entry>array[i+offset]</entry> +</row> +<row> +<entry>loadupdb</entry> +<entry>1</entry> +<entry>1</entry> +<entry></entry> +<entry>load upsampled duplicate</entry> +<entry>array[i>>1]</entry> +</row> +<row> +<entry>loadupib</entry> +<entry>1</entry> +<entry>1</entry> +<entry></entry> +<entry>load upsampled interpolate</entry> +<entry>(array[i>>1] + array[(i+1)>>1] + 1)>>1</entry> +</row> +<row> +<entry>loadpb</entry> +<entry>1</entry> +<entry>1</entry> +<entry></entry> +<entry>load parameter or constant</entry> +<entry>scalar</entry> +</row> +<row> +<entry>ldresnearb</entry> +<entry>1</entry> +<entry>1</entry> +<entry>4S</entry> +<entry>load, nearest neighbor resampled</entry> +<entry>array[(b+c*i)>>8]</entry> +</row> +<row> +<entry>ldresnearl</entry> +<entry>4</entry> +<entry>4</entry> +<entry>4S</entry> +<entry>load, nearest neighbor resampled</entry> +<entry>array[(b+c*i)>>8]</entry> +</row> +<row> +<entry>ldreslinb</entry> +<entry>1</entry> +<entry>1</entry> +<entry>4S</entry> +<entry>load, bilinear resampled</entry> +<entry>special</entry> +</row> +<row> +<entry>ldreslinl</entry> +<entry>4</entry> +<entry>4</entry> +<entry>4S</entry> +<entry>load, bilinear resampled</entry> +<entry>special</entry> +</row> +<row> <entry>maxsb</entry> <entry>1</entry> <entry>1</entry> @@ -197,6 +269,14 @@ <entry>sign(a)</entry> </row> <row> +<entry>storeb</entry> +<entry>1</entry> +<entry>1</entry> +<entry></entry> +<entry>store to memory</entry> +<entry>special</entry> +</row> +<row> <entry>subb</entry> <entry>1</entry> <entry>1</entry> @@ -317,6 +397,46 @@ <entry>a</entry> </row> <row> +<entry>div255w</entry> +<entry>2</entry> +<entry>2</entry> +<entry></entry> +<entry>divide by 255</entry> +<entry>a/255</entry> +</row> +<row> +<entry>divluw</entry> +<entry>2</entry> +<entry>2</entry> +<entry>2</entry> +<entry>saturated unsigned divide 16-bit by 8-bit</entry> +<entry>clamp(a/(b & 255),0,255)</entry> +</row> +<row> +<entry>loadw</entry> +<entry>2</entry> +<entry>2</entry> +<entry></entry> +<entry>load from memory</entry> +<entry>array[i]</entry> +</row> +<row> +<entry>loadoffw</entry> +<entry>2</entry> +<entry>2</entry> +<entry>4S</entry> +<entry>load from memory with offset</entry> +<entry>array[i+offset]</entry> +</row> +<row> +<entry>loadpw</entry> +<entry>2</entry> +<entry>2</entry> +<entry></entry> +<entry>load parameter or constant</entry> +<entry>scalar</entry> +</row> +<row> <entry>maxsw</entry> <entry>2</entry> <entry>2</entry> @@ -413,6 +533,14 @@ <entry>sign(a)</entry> </row> <row> +<entry>storew</entry> +<entry>2</entry> +<entry>2</entry> +<entry></entry> +<entry>store to memory</entry> +<entry>special</entry> +</row> +<row> <entry>subw</entry> <entry>2</entry> <entry>2</entry> @@ -533,6 +661,30 @@ <entry>a</entry> </row> <row> +<entry>loadl</entry> +<entry>4</entry> +<entry>4</entry> +<entry></entry> +<entry>load from memory</entry> +<entry>array[i]</entry> +</row> +<row> +<entry>loadoffl</entry> +<entry>4</entry> +<entry>4</entry> +<entry>4S</entry> +<entry>load from memory with offset</entry> +<entry>array[i+offset]</entry> +</row> +<row> +<entry>loadpl</entry> +<entry>4</entry> +<entry>4</entry> +<entry></entry> +<entry>load parameter or constant</entry> +<entry>scalar</entry> +</row> +<row> <entry>maxsl</entry> <entry>4</entry> <entry>4</entry> @@ -629,6 +781,14 @@ <entry>sign(a)</entry> </row> <row> +<entry>storel</entry> +<entry>4</entry> +<entry>4</entry> +<entry></entry> +<entry>store to memory</entry> +<entry>special</entry> +</row> +<row> <entry>subl</entry> <entry>4</entry> <entry>4</entry> @@ -661,6 +821,38 @@ <entry>a ^ b</entry> </row> <row> +<entry>loadq</entry> +<entry>8</entry> +<entry>8</entry> +<entry></entry> +<entry>load from memory</entry> +<entry>array[i]</entry> +</row> +<row> +<entry>loadpq</entry> +<entry>8</entry> +<entry>8</entry> +<entry></entry> +<entry>load parameter or constant</entry> +<entry>scalar</entry> +</row> +<row> +<entry>storeq</entry> +<entry>8</entry> +<entry>8</entry> +<entry></entry> +<entry>store to memory</entry> +<entry>special</entry> +</row> +<row> +<entry>splatw3q</entry> +<entry>8</entry> +<entry>8</entry> +<entry></entry> +<entry>duplicates high 16-bits to lower 48 bits</entry> +<entry>special</entry> +</row> +<row> <entry>convsbw</entry> <entry>2</entry> <entry>1</entry> @@ -677,6 +869,22 @@ <entry>a</entry> </row> <row> +<entry>splatbw</entry> +<entry>2</entry> +<entry>1</entry> +<entry></entry> +<entry>duplicates 8 bits to both halfs of 16 bits</entry> +<entry>special</entry> +</row> +<row> +<entry>splatbl</entry> +<entry>4</entry> +<entry>1</entry> +<entry></entry> +<entry>duplicates 8 bits to all parts of 32 bits</entry> +<entry>special</entry> +</row> +<row> <entry>convswl</entry> <entry>4</entry> <entry>2</entry> @@ -693,6 +901,22 @@ <entry>a</entry> </row> <row> +<entry>convslq</entry> +<entry>8</entry> +<entry>4</entry> +<entry></entry> +<entry>signed convert</entry> +<entry>a</entry> +</row> +<row> +<entry>convulq</entry> +<entry>8</entry> +<entry>4</entry> +<entry></entry> +<entry>unsigned convert</entry> +<entry>a</entry> +</row> +<row> <entry>convwb</entry> <entry>1</entry> <entry>2</entry> @@ -701,6 +925,14 @@ <entry>a</entry> </row> <row> +<entry>convhwb</entry> +<entry>1</entry> +<entry>2</entry> +<entry></entry> +<entry>shift and convert</entry> +<entry>a>>8</entry> +</row> +<row> <entry>convssswb</entry> <entry>1</entry> <entry>2</entry> @@ -741,6 +973,14 @@ <entry>a</entry> </row> <row> +<entry>convhlw</entry> +<entry>2</entry> +<entry>4</entry> +<entry></entry> +<entry>shift and convert</entry> +<entry>a>>16</entry> +</row> +<row> <entry>convssslw</entry> <entry>2</entry> <entry>4</entry> @@ -773,6 +1013,46 @@ <entry>clamp(a)</entry> </row> <row> +<entry>convql</entry> +<entry>4</entry> +<entry>8</entry> +<entry></entry> +<entry></entry> +<entry></entry> +</row> +<row> +<entry>convsssql</entry> +<entry>4</entry> +<entry>8</entry> +<entry></entry> +<entry>convert signed to unsigned with saturation</entry> +<entry>clamp(a)</entry> +</row> +<row> +<entry>convsusql</entry> +<entry>4</entry> +<entry>8</entry> +<entry></entry> +<entry>convert signed to signed with saturation</entry> +<entry>clamp(a)</entry> +</row> +<row> +<entry>convussql</entry> +<entry>4</entry> +<entry>8</entry> +<entry></entry> +<entry>convert unsigned to unsigned with saturation</entry> +<entry>clamp(a)</entry> +</row> +<row> +<entry>convuusql</entry> +<entry>4</entry> +<entry>8</entry> +<entry></entry> +<entry>convert unsigned to signed with saturation</entry> +<entry>clamp(a)</entry> +</row> +<row> <entry>mulsbw</entry> <entry>2</entry> <entry>1</entry> diff --git a/doc/orc-docs.sgml b/doc/orc-docs.sgml index f031172..a9170ae 100644 --- a/doc/orc-docs.sgml +++ b/doc/orc-docs.sgml @@ -18,6 +18,7 @@ <title>Overview</title> <xi:include href="building.xml"/> <xi:include href="concepts.xml"/> + <xi:include href="tutorial.xml"/> </chapter> <chapter> diff --git a/doc/table.xml b/doc/table.xml index 601ca44..d914dbd 100644 --- a/doc/table.xml +++ b/doc/table.xml @@ -20,195 +20,276 @@ <entry>no</entry> <entry>no</entry> <entry>yes</entry> -<entry>yes</entry> +<entry>no</entry> </row> <row> <entry>addb</entry> <entry>yes</entry> <entry>yes</entry> <entry>yes</entry> -<entry>no</entry> <entry>yes</entry> <entry>yes</entry> +<entry>no</entry> </row> <row> <entry>addssb</entry> <entry>yes</entry> <entry>yes</entry> <entry>yes</entry> -<entry>no</entry> <entry>yes</entry> <entry>yes</entry> +<entry>no</entry> </row> <row> <entry>addusb</entry> <entry>yes</entry> <entry>yes</entry> <entry>yes</entry> -<entry>no</entry> <entry>yes</entry> <entry>yes</entry> +<entry>no</entry> </row> <row> <entry>andb</entry> <entry>yes</entry> <entry>yes</entry> <entry>yes</entry> -<entry>no</entry> <entry>yes</entry> <entry>yes</entry> +<entry>no</entry> </row> <row> <entry>andnb</entry> <entry>yes</entry> <entry>yes</entry> <entry>yes</entry> -<entry>no</entry> <entry>yes</entry> <entry>yes</entry> +<entry>no</entry> </row> <row> <entry>avgsb</entry> <entry>yes</entry> <entry>yes</entry> <entry>yes</entry> -<entry>no</entry> <entry>yes</entry> <entry>yes</entry> +<entry>no</entry> </row> <row> <entry>avgub</entry> <entry>yes</entry> <entry>yes</entry> <entry>yes</entry> -<entry>no</entry> <entry>yes</entry> <entry>yes</entry> +<entry>no</entry> </row> <row> <entry>cmpeqb</entry> <entry>yes</entry> <entry>yes</entry> <entry>yes</entry> -<entry>no</entry> <entry>yes</entry> <entry>yes</entry> +<entry>no</entry> </row> <row> <entry>cmpgtsb</entry> <entry>yes</entry> <entry>yes</entry> <entry>yes</entry> -<entry>no</entry> <entry>yes</entry> <entry>yes</entry> +<entry>no</entry> </row> <row> <entry>copyb</entry> <entry>yes</entry> <entry>yes</entry> <entry>yes</entry> -<entry>no</entry> <entry>yes</entry> <entry>yes</entry> +<entry>no</entry> </row> <row> -<entry>maxsb</entry> +<entry>loadb</entry> <entry>yes</entry> <entry>yes</entry> <entry>yes</entry> -<entry>no</entry> <entry>yes</entry> <entry>yes</entry> +<entry>no</entry> </row> <row> -<entry>maxub</entry> -<entry>yes</entry> +<entry>loadoffb</entry> <entry>yes</entry> <entry>yes</entry> <entry>no</entry> +<entry>no</entry> <entry>yes</entry> -<entry>yes</entry> +<entry>no</entry> </row> <row> -<entry>minsb</entry> -<entry>yes</entry> +<entry>loadupdb</entry> <entry>yes</entry> <entry>yes</entry> <entry>no</entry> +<entry>no</entry> +<entry>no</entry> +<entry>no</entry> +</row> +<row> +<entry>loadupib</entry> <entry>yes</entry> <entry>yes</entry> +<entry>no</entry> +<entry>no</entry> +<entry>no</entry> +<entry>no</entry> </row> <row> -<entry>minub</entry> +<entry>loadpb</entry> <entry>yes</entry> <entry>yes</entry> <entry>yes</entry> -<entry>no</entry> <entry>yes</entry> <entry>yes</entry> +<entry>no</entry> </row> <row> -<entry>mullb</entry> +<entry>ldresnearb</entry> +<entry>no</entry> +<entry>no</entry> <entry>no</entry> <entry>no</entry> -<entry>yes</entry> <entry>no</entry> -<entry>yes</entry> <entry>no</entry> </row> <row> -<entry>mulhsb</entry> +<entry>ldresnearl</entry> +<entry>no</entry> <entry>no</entry> <entry>no</entry> -<entry>yes</entry> <entry>no</entry> <entry>no</entry> <entry>no</entry> </row> <row> -<entry>mulhub</entry> +<entry>ldreslinb</entry> +<entry>no</entry> <entry>no</entry> <entry>no</entry> -<entry>yes</entry> <entry>no</entry> <entry>no</entry> <entry>no</entry> </row> <row> -<entry>orb</entry> +<entry>ldreslinl</entry> +<entry>no</entry> +<entry>no</entry> +<entry>no</entry> +<entry>no</entry> +<entry>no</entry> +<entry>no</entry> +</row> +<row> +<entry>maxsb</entry> <entry>yes</entry> <entry>yes</entry> <entry>yes</entry> <entry>no</entry> <entry>yes</entry> -<entry>yes</entry> +<entry>no</entry> </row> <row> -<entry>shlb</entry> -<entry>no</entry> -<entry>no</entry> +<entry>maxub</entry> +<entry>yes</entry> +<entry>yes</entry> +<entry>yes</entry> <entry>no</entry> +<entry>yes</entry> <entry>no</entry> +</row> +<row> +<entry>minsb</entry> +<entry>yes</entry> +<entry>yes</entry> +<entry>yes</entry> <entry>no</entry> +<entry>yes</entry> <entry>no</entry> </row> <row> -<entry>shrsb</entry> +<entry>minub</entry> +<entry>yes</entry> +<entry>yes</entry> +<entry>yes</entry> <entry>no</entry> +<entry>yes</entry> <entry>no</entry> +</row> +<row> +<entry>mullb</entry> +<entry>yes</entry> +<entry>yes</entry> +<entry>yes</entry> +<entry>yes</entry> +<entry>yes</entry> <entry>no</entry> +</row> +<row> +<entry>mulhsb</entry> +<entry>yes</entry> +<entry>yes</entry> +<entry>yes</entry> +<entry>yes</entry> +<entry>yes</entry> <entry>no</entry> +</row> +<row> +<entry>mulhub</entry> +<entry>yes</entry> +<entry>yes</entry> +<entry>yes</entry> <entry>no</entry> +<entry>yes</entry> <entry>no</entry> </row> <row> -<entry>shrub</entry> +<entry>orb</entry> +<entry>yes</entry> +<entry>yes</entry> +<entry>yes</entry> +<entry>yes</entry> +<entry>yes</entry> <entry>no</entry> +</row> +<row> +<entry>shlb</entry> +<entry>yes</entry> +<entry>yes</entry> +<entry>yes</entry> +<entry>yes</entry> +<entry>yes</entry> <entry>no</entry> +</row> +<row> +<entry>shrsb</entry> +<entry>yes</entry> +<entry>yes</entry> +<entry>yes</entry> <entry>no</entry> +<entry>yes</entry> <entry>no</entry> +</row> +<row> +<entry>shrub</entry> +<entry>yes</entry> +<entry>yes</entry> +<entry>yes</entry> <entry>no</entry> +<entry>yes</entry> <entry>no</entry> </row> <row> @@ -217,24 +298,33 @@ <entry>yes</entry> <entry>yes</entry> <entry>no</entry> +<entry>yes</entry> <entry>no</entry> +</row> +<row> +<entry>storeb</entry> +<entry>yes</entry> +<entry>yes</entry> +<entry>yes</entry> +<entry>yes</entry> <entry>yes</entry> +<entry>no</entry> </row> <row> <entry>subb</entry> <entry>yes</entry> <entry>yes</entry> <entry>yes</entry> -<entry>no</entry> <entry>yes</entry> <entry>yes</entry> +<entry>no</entry> </row> <row> <entry>subssb</entry> <entry>yes</entry> <entry>yes</entry> <entry>yes</entry> -<entry>no</entry> +<entry>yes</entry> <entry>yes</entry> <entry>no</entry> </row> @@ -243,7 +333,7 @@ <entry>yes</entry> <entry>yes</entry> <entry>yes</entry> -<entry>no</entry> +<entry>yes</entry> <entry>yes</entry> <entry>no</entry> </row> @@ -252,18 +342,18 @@ <entry>yes</entry> <entry>yes</entry> <entry>yes</entry> -<entry>no</entry> <entry>yes</entry> <entry>yes</entry> +<entry>no</entry> </row> <row> <entry>absw</entry> <entry>yes</entry> <entry>yes</entry> <entry>no</entry> +<entry>no</entry> <entry>yes</entry> -<entry>yes</entry> -<entry>yes</entry> +<entry>no</entry> </row> <row> <entry>addw</entry> @@ -272,7 +362,7 @@ <entry>yes</entry> <entry>yes</entry> <entry>yes</entry> -<entry>yes</entry> +<entry>no</entry> </row> <row> <entry>addssw</entry> @@ -281,7 +371,7 @@ <entry>yes</entry> <entry>yes</entry> <entry>yes</entry> -<entry>yes</entry> +<entry>no</entry> </row> <row> <entry>addusw</entry> @@ -290,7 +380,7 @@ <entry>yes</entry> <entry>yes</entry> <entry>yes</entry> -<entry>yes</entry> +<entry>no</entry> </row> <row> <entry>andw</entry> @@ -299,7 +389,7 @@ <entry>yes</entry> <entry>yes</entry> <entry>yes</entry> -<entry>yes</entry> +<entry>no</entry> </row> <row> <entry>andnw</entry> @@ -308,16 +398,16 @@ <entry>yes</entry> <entry>yes</entry> <entry>yes</entry> -<entry>yes</entry> +<entry>no</entry> </row> <row> <entry>avgsw</entry> <entry>yes</entry> <entry>yes</entry> <entry>yes</entry> +<entry>no</entry> <entry>yes</entry> -<entry>yes</entry> -<entry>yes</entry> +<entry>no</entry> </row> <row> <entry>avguw</entry> @@ -326,7 +416,7 @@ <entry>yes</entry> <entry>yes</entry> <entry>yes</entry> -<entry>yes</entry> +<entry>no</entry> </row> <row> <entry>cmpeqw</entry> @@ -335,7 +425,7 @@ <entry>yes</entry> <entry>yes</entry> <entry>yes</entry> -<entry>yes</entry> +<entry>no</entry> </row> <row> <entry>cmpgtsw</entry> @@ -344,7 +434,7 @@ <entry>yes</entry> <entry>yes</entry> <entry>yes</entry> -<entry>yes</entry> +<entry>no</entry> </row> <row> <entry>copyw</entry> @@ -353,43 +443,88 @@ <entry>yes</entry> <entry>yes</entry> <entry>yes</entry> +<entry>no</entry> +</row> +<row> +<entry>div255w</entry> +<entry>yes</entry> <entry>yes</entry> +<entry>no</entry> +<entry>no</entry> +<entry>yes</entry> +<entry>no</entry> </row> <row> -<entry>maxsw</entry> +<entry>divluw</entry> <entry>yes</entry> <entry>yes</entry> +<entry>no</entry> +<entry>no</entry> +<entry>no</entry> +<entry>no</entry> +</row> +<row> +<entry>loadw</entry> +<entry>yes</entry> <entry>yes</entry> <entry>yes</entry> <entry>yes</entry> <entry>yes</entry> +<entry>no</entry> </row> <row> -<entry>maxuw</entry> +<entry>loadoffw</entry> +<entry>yes</entry> +<entry>yes</entry> +<entry>no</entry> +<entry>no</entry> <entry>yes</entry> +<entry>no</entry> +</row> +<row> +<entry>loadpw</entry> <entry>yes</entry> <entry>yes</entry> <entry>yes</entry> <entry>yes</entry> <entry>yes</entry> +<entry>no</entry> </row> <row> -<entry>minsw</entry> +<entry>maxsw</entry> <entry>yes</entry> <entry>yes</entry> <entry>yes</entry> +<entry>no</entry> +<entry>yes</entry> +<entry>no</entry> +</row> +<row> +<entry>maxuw</entry> <entry>yes</entry> <entry>yes</entry> <entry>yes</entry> +<entry>no</entry> +<entry>yes</entry> +<entry>no</entry> </row> <row> -<entry>minuw</entry> +<entry>minsw</entry> +<entry>yes</entry> <entry>yes</entry> <entry>yes</entry> +<entry>no</entry> <entry>yes</entry> +<entry>no</entry> +</row> +<row> +<entry>minuw</entry> <entry>yes</entry> <entry>yes</entry> <entry>yes</entry> +<entry>no</entry> +<entry>yes</entry> +<entry>no</entry> </row> <row> <entry>mullw</entry> @@ -398,7 +533,7 @@ <entry>yes</entry> <entry>yes</entry> <entry>yes</entry> -<entry>yes</entry> +<entry>no</entry> </row> <row> <entry>mulhsw</entry> @@ -406,17 +541,17 @@ <entry>yes</entry> <entry>yes</entry> <entry>yes</entry> -<entry>no</entry> <entry>yes</entry> +<entry>no</entry> </row> <row> <entry>mulhuw</entry> <entry>yes</entry> <entry>yes</entry> <entry>yes</entry> +<entry>no</entry> <entry>yes</entry> -<entry>yes</entry> -<entry>yes</entry> +<entry>no</entry> </row> <row> <entry>orw</entry> @@ -425,33 +560,33 @@ <entry>yes</entry> <entry>yes</entry> <entry>yes</entry> -<entry>yes</entry> +<entry>no</entry> </row> <row> <entry>shlw</entry> -<entry>no</entry> -<entry>no</entry> -<entry>no</entry> -<entry>no</entry> -<entry>no</entry> +<entry>yes</entry> +<entry>yes</entry> +<entry>yes</entry> +<entry>yes</entry> +<entry>yes</entry> <entry>no</entry> </row> <row> <entry>shrsw</entry> +<entry>yes</entry> +<entry>yes</entry> +<entry>yes</entry> <entry>no</entry> -<entry>no</entry> -<entry>no</entry> -<entry>no</entry> -<entry>no</entry> +<entry>yes</entry> <entry>no</entry> </row> <row> <entry>shruw</entry> -<entry>no</entry> -<entry>no</entry> -<entry>no</entry> -<entry>no</entry> -<entry>no</entry> +<entry>yes</entry> +<entry>yes</entry> +<entry>yes</entry> +<entry>yes</entry> +<entry>yes</entry> <entry>no</entry> </row> <row> @@ -459,9 +594,18 @@ <entry>yes</entry> <entry>yes</entry> <entry>yes</entry> +<entry>no</entry> +<entry>yes</entry> +<entry>no</entry> +</row> +<row> +<entry>storew</entry> +<entry>yes</entry> +<entry>yes</entry> <entry>yes</entry> <entry>yes</entry> <entry>yes</entry> +<entry>no</entry> </row> <row> <entry>subw</entry> @@ -470,7 +614,7 @@ <entry>yes</entry> <entry>yes</entry> <entry>yes</entry> -<entry>yes</entry> +<entry>no</entry> </row> <row> <entry>subssw</entry> @@ -479,7 +623,7 @@ <entry>yes</entry> <entry>yes</entry> <entry>yes</entry> -<entry>yes</entry> +<entry>no</entry> </row> <row> <entry>subusw</entry> @@ -488,7 +632,7 @@ <entry>yes</entry> <entry>yes</entry> <entry>yes</entry> -<entry>yes</entry> +<entry>no</entry> </row> <row> <entry>xorw</entry> @@ -497,7 +641,7 @@ <entry>yes</entry> <entry>yes</entry> <entry>yes</entry> -<entry>yes</entry> +<entry>no</entry> </row> <row> <entry>absl</entry> @@ -506,195 +650,222 @@ <entry>no</entry> <entry>no</entry> <entry>yes</entry> -<entry>yes</entry> +<entry>no</entry> </row> <row> <entry>addl</entry> <entry>yes</entry> <entry>yes</entry> <entry>yes</entry> -<entry>no</entry> <entry>yes</entry> <entry>yes</entry> +<entry>no</entry> </row> <row> <entry>addssl</entry> -<entry>no</entry> -<entry>no</entry> <entry>yes</entry> -<entry>no</entry> <entry>yes</entry> <entry>yes</entry> +<entry>yes</entry> +<entry>yes</entry> +<entry>no</entry> </row> <row> <entry>addusl</entry> -<entry>no</entry> -<entry>no</entry> <entry>yes</entry> -<entry>no</entry> <entry>yes</entry> <entry>yes</entry> +<entry>yes</entry> +<entry>yes</entry> +<entry>no</entry> </row> <row> <entry>andl</entry> <entry>yes</entry> <entry>yes</entry> <entry>yes</entry> -<entry>no</entry> <entry>yes</entry> <entry>yes</entry> +<entry>no</entry> </row> <row> <entry>andnl</entry> <entry>yes</entry> <entry>yes</entry> <entry>yes</entry> -<entry>no</entry> <entry>yes</entry> <entry>yes</entry> +<entry>no</entry> </row> <row> <entry>avgsl</entry> -<entry>no</entry> -<entry>no</entry> <entry>yes</entry> -<entry>no</entry> <entry>yes</entry> <entry>yes</entry> +<entry>no</entry> +<entry>yes</entry> +<entry>no</entry> </row> <row> <entry>avgul</entry> -<entry>no</entry> -<entry>no</entry> <entry>yes</entry> -<entry>no</entry> <entry>yes</entry> <entry>yes</entry> +<entry>no</entry> +<entry>yes</entry> +<entry>no</entry> </row> <row> <entry>cmpeql</entry> <entry>yes</entry> <entry>yes</entry> <entry>yes</entry> -<entry>no</entry> <entry>yes</entry> <entry>yes</entry> +<entry>no</entry> </row> <row> <entry>cmpgtsl</entry> <entry>yes</entry> <entry>yes</entry> <entry>yes</entry> -<entry>no</entry> <entry>yes</entry> <entry>yes</entry> +<entry>no</entry> </row> <row> <entry>copyl</entry> <entry>yes</entry> <entry>yes</entry> <entry>yes</entry> +<entry>yes</entry> +<entry>yes</entry> <entry>no</entry> +</row> +<row> +<entry>loadl</entry> <entry>yes</entry> <entry>yes</entry> +<entry>yes</entry> +<entry>yes</entry> +<entry>yes</entry> +<entry>no</entry> </row> <row> -<entry>maxsl</entry> +<entry>loadoffl</entry> <entry>yes</entry> <entry>yes</entry> +<entry>no</entry> +<entry>no</entry> <entry>yes</entry> <entry>no</entry> +</row> +<row> +<entry>loadpl</entry> +<entry>yes</entry> <entry>yes</entry> <entry>yes</entry> +<entry>yes</entry> +<entry>yes</entry> +<entry>no</entry> </row> <row> -<entry>maxul</entry> +<entry>maxsl</entry> +<entry>yes</entry> +<entry>yes</entry> <entry>yes</entry> <entry>yes</entry> <entry>yes</entry> <entry>no</entry> +</row> +<row> +<entry>maxul</entry> <entry>yes</entry> <entry>yes</entry> +<entry>yes</entry> +<entry>yes</entry> +<entry>yes</entry> +<entry>no</entry> </row> <row> <entry>minsl</entry> <entry>yes</entry> <entry>yes</entry> <entry>yes</entry> -<entry>no</entry> <entry>yes</entry> <entry>yes</entry> +<entry>no</entry> </row> <row> <entry>minul</entry> <entry>yes</entry> <entry>yes</entry> <entry>yes</entry> -<entry>no</entry> <entry>yes</entry> <entry>yes</entry> +<entry>no</entry> </row> <row> <entry>mulll</entry> -<entry>no</entry> -<entry>no</entry> +<entry>yes</entry> <entry>no</entry> <entry>no</entry> <entry>yes</entry> <entry>yes</entry> +<entry>no</entry> </row> <row> <entry>mulhsl</entry> +<entry>yes</entry> <entry>no</entry> <entry>no</entry> -<entry>no</entry> -<entry>no</entry> -<entry>no</entry> <entry>yes</entry> +<entry>yes</entry> +<entry>no</entry> </row> <row> <entry>mulhul</entry> -<entry>no</entry> -<entry>no</entry> +<entry>yes</entry> <entry>no</entry> <entry>no</entry> <entry>no</entry> <entry>yes</entry> +<entry>no</entry> </row> <row> <entry>orl</entry> <entry>yes</entry> <entry>yes</entry> <entry>yes</entry> -<entry>no</entry> <entry>yes</entry> <entry>yes</entry> +<entry>no</entry> </row> <row> <entry>shll</entry> -<entry>no</entry> -<entry>no</entry> -<entry>no</entry> -<entry>no</entry> -<entry>no</entry> +<entry>yes</entry> +<entry>yes</entry> +<entry>yes</entry> +<entry>yes</entry> +<entry>yes</entry> <entry>no</entry> </row> <row> <entry>shrsl</entry> -<entry>no</entry> -<entry>no</entry> -<entry>no</entry> -<entry>no</entry> -<entry>no</entry> +<entry>yes</entry> +<entry>yes</entry> +<entry>yes</entry> +<entry>yes</entry> +<entry>yes</entry> <entry>no</entry> </row> <row> <entry>shrul</entry> -<entry>no</entry> -<entry>no</entry> -<entry>no</entry> -<entry>no</entry> -<entry>no</entry> +<entry>yes</entry> +<entry>yes</entry> +<entry>yes</entry> +<entry>yes</entry> +<entry>yes</entry> <entry>no</entry> </row> <row> @@ -703,53 +874,98 @@ <entry>yes</entry> <entry>yes</entry> <entry>no</entry> +<entry>yes</entry> <entry>no</entry> +</row> +<row> +<entry>storel</entry> +<entry>yes</entry> <entry>yes</entry> +<entry>yes</entry> +<entry>yes</entry> +<entry>yes</entry> +<entry>no</entry> </row> <row> <entry>subl</entry> <entry>yes</entry> <entry>yes</entry> <entry>yes</entry> -<entry>no</entry> <entry>yes</entry> <entry>yes</entry> +<entry>no</entry> </row> <row> <entry>subssl</entry> +<entry>yes</entry> +<entry>yes</entry> +<entry>yes</entry> <entry>no</entry> +<entry>yes</entry> <entry>no</entry> +</row> +<row> +<entry>subusl</entry> +<entry>yes</entry> +<entry>yes</entry> +<entry>yes</entry> +<entry>yes</entry> <entry>yes</entry> <entry>no</entry> +</row> +<row> +<entry>xorl</entry> <entry>yes</entry> <entry>yes</entry> +<entry>yes</entry> +<entry>yes</entry> +<entry>yes</entry> +<entry>no</entry> </row> <row> -<entry>subusl</entry> +<entry>loadq</entry> +<entry>yes</entry> +<entry>yes</entry> <entry>no</entry> <entry>no</entry> <entry>yes</entry> <entry>no</entry> +</row> +<row> +<entry>loadpq</entry> <entry>yes</entry> <entry>yes</entry> +<entry>no</entry> +<entry>no</entry> +<entry>yes</entry> +<entry>no</entry> </row> <row> -<entry>xorl</entry> +<entry>storeq</entry> <entry>yes</entry> <entry>yes</entry> +<entry>no</entry> +<entry>no</entry> <entry>yes</entry> <entry>no</entry> +</row> +<row> +<entry>splatw3q</entry> +<entry>yes</entry> <entry>yes</entry> +<entry>no</entry> +<entry>no</entry> <entry>yes</entry> +<entry>no</entry> </row> <row> <entry>convsbw</entry> <entry>yes</entry> <entry>yes</entry> <entry>yes</entry> -<entry>no</entry> <entry>yes</entry> <entry>yes</entry> +<entry>no</entry> </row> <row> <entry>convubw</entry> @@ -758,25 +974,61 @@ <entry>yes</entry> <entry>no</entry> <entry>yes</entry> +<entry>no</entry> +</row> +<row> +<entry>splatbw</entry> <entry>yes</entry> +<entry>yes</entry> +<entry>no</entry> +<entry>no</entry> +<entry>yes</entry> +<entry>no</entry> </row> <row> -<entry>convswl</entry> +<entry>splatbl</entry> <entry>yes</entry> <entry>yes</entry> +<entry>no</entry> +<entry>no</entry> <entry>yes</entry> +<entry>no</entry> +</row> +<row> +<entry>convswl</entry> <entry>yes</entry> <entry>yes</entry> <entry>yes</entry> +<entry>no</entry> +<entry>yes</entry> +<entry>no</entry> </row> <row> <entry>convuwl</entry> <entry>yes</entry> <entry>yes</entry> <entry>yes</entry> +<entry>no</entry> +<entry>yes</entry> +<entry>no</entry> +</row> +<row> +<entry>convslq</entry> +<entry>yes</entry> +<entry>yes</entry> +<entry>no</entry> +<entry>no</entry> +<entry>yes</entry> +<entry>no</entry> +</row> +<row> +<entry>convulq</entry> <entry>yes</entry> <entry>yes</entry> +<entry>no</entry> +<entry>no</entry> <entry>yes</entry> +<entry>no</entry> </row> <row> <entry>convwb</entry> @@ -785,7 +1037,16 @@ <entry>yes</entry> <entry>yes</entry> <entry>yes</entry> +<entry>no</entry> +</row> +<row> +<entry>convhwb</entry> +<entry>yes</entry> +<entry>yes</entry> +<entry>no</entry> +<entry>no</entry> <entry>yes</entry> +<entry>no</entry> </row> <row> <entry>convssswb</entry> @@ -794,7 +1055,7 @@ <entry>yes</entry> <entry>yes</entry> <entry>yes</entry> -<entry>yes</entry> +<entry>no</entry> </row> <row> <entry>convsuswb</entry> @@ -803,34 +1064,43 @@ <entry>yes</entry> <entry>yes</entry> <entry>yes</entry> -<entry>yes</entry> +<entry>no</entry> </row> <row> <entry>convusswb</entry> <entry>no</entry> <entry>no</entry> <entry>no</entry> -<entry>yes</entry> +<entry>no</entry> <entry>no</entry> <entry>no</entry> </row> <row> <entry>convuuswb</entry> -<entry>no</entry> -<entry>no</entry> <entry>yes</entry> <entry>yes</entry> <entry>yes</entry> <entry>no</entry> +<entry>yes</entry> +<entry>no</entry> </row> <row> <entry>convlw</entry> <entry>yes</entry> <entry>yes</entry> <entry>yes</entry> +<entry>yes</entry> +<entry>yes</entry> <entry>no</entry> +</row> +<row> +<entry>convhlw</entry> +<entry>yes</entry> <entry>yes</entry> +<entry>no</entry> +<entry>no</entry> <entry>yes</entry> +<entry>no</entry> </row> <row> <entry>convssslw</entry> @@ -839,14 +1109,14 @@ <entry>yes</entry> <entry>no</entry> <entry>yes</entry> -<entry>yes</entry> +<entry>no</entry> </row> <row> <entry>convsuslw</entry> <entry>no</entry> <entry>no</entry> <entry>yes</entry> -<entry>no</entry> +<entry>yes</entry> <entry>yes</entry> <entry>no</entry> </row> @@ -869,40 +1139,85 @@ <entry>no</entry> </row> <row> -<entry>mulsbw</entry> +<entry>convql</entry> <entry>yes</entry> -<entry>no</entry> <entry>yes</entry> <entry>no</entry> +<entry>no</entry> <entry>yes</entry> +<entry>no</entry> +</row> +<row> +<entry>convsssql</entry> +<entry>no</entry> +<entry>no</entry> +<entry>no</entry> +<entry>no</entry> <entry>yes</entry> +<entry>no</entry> </row> <row> -<entry>mulubw</entry> +<entry>convsusql</entry> +<entry>no</entry> +<entry>no</entry> +<entry>no</entry> +<entry>no</entry> <entry>yes</entry> <entry>no</entry> +</row> +<row> +<entry>convussql</entry> +<entry>no</entry> +<entry>no</entry> +<entry>no</entry> +<entry>no</entry> +<entry>no</entry> +<entry>no</entry> +</row> +<row> +<entry>convuusql</entry> +<entry>no</entry> +<entry>no</entry> +<entry>no</entry> +<entry>no</entry> <entry>yes</entry> <entry>no</entry> +</row> +<row> +<entry>mulsbw</entry> +<entry>yes</entry> <entry>yes</entry> <entry>yes</entry> +<entry>yes</entry> +<entry>yes</entry> +<entry>no</entry> </row> <row> -<entry>mulswl</entry> +<entry>mulubw</entry> +<entry>yes</entry> <entry>yes</entry> <entry>yes</entry> +<entry>no</entry> +<entry>yes</entry> +<entry>no</entry> +</row> +<row> +<entry>mulswl</entry> <entry>yes</entry> <entry>yes</entry> <entry>yes</entry> +<entry>no</entry> <entry>yes</entry> +<entry>no</entry> </row> <row> <entry>muluwl</entry> -<entry>no</entry> -<entry>no</entry> <entry>yes</entry> <entry>yes</entry> <entry>yes</entry> +<entry>no</entry> <entry>yes</entry> +<entry>no</entry> </row> <row> <entry>accw</entry> @@ -911,7 +1226,7 @@ <entry>no</entry> <entry>no</entry> <entry>yes</entry> -<entry>yes</entry> +<entry>no</entry> </row> <row> <entry>accl</entry> @@ -920,16 +1235,16 @@ <entry>yes</entry> <entry>no</entry> <entry>yes</entry> -<entry>yes</entry> +<entry>no</entry> </row> <row> <entry>accsadubl</entry> -<entry>no</entry> +<entry>yes</entry> <entry>yes</entry> <entry>no</entry> <entry>no</entry> <entry>yes</entry> -<entry>yes</entry> +<entry>no</entry> </row> <row> <entry>swapw</entry> @@ -938,87 +1253,87 @@ <entry>no</entry> <entry>yes</entry> <entry>yes</entry> -<entry>yes</entry> +<entry>no</entry> </row> <row> <entry>swapl</entry> <entry>yes</entry> <entry>yes</entry> <entry>no</entry> -<entry>no</entry> <entry>yes</entry> <entry>yes</entry> +<entry>no</entry> </row> <row> <entry>select0wb</entry> <entry>yes</entry> <entry>yes</entry> +<entry>no</entry> <entry>yes</entry> <entry>yes</entry> -<entry>yes</entry> -<entry>yes</entry> +<entry>no</entry> </row> <row> <entry>select1wb</entry> <entry>yes</entry> <entry>yes</entry> +<entry>no</entry> <entry>yes</entry> <entry>yes</entry> -<entry>yes</entry> -<entry>yes</entry> +<entry>no</entry> </row> <row> <entry>select0lw</entry> <entry>yes</entry> <entry>yes</entry> -<entry>yes</entry> <entry>no</entry> <entry>yes</entry> <entry>yes</entry> +<entry>no</entry> </row> <row> <entry>select1lw</entry> <entry>yes</entry> <entry>yes</entry> -<entry>yes</entry> <entry>no</entry> <entry>yes</entry> <entry>yes</entry> +<entry>no</entry> </row> <row> <entry>mergewl</entry> <entry>yes</entry> <entry>yes</entry> +<entry>no</entry> <entry>yes</entry> <entry>yes</entry> -<entry>yes</entry> -<entry>yes</entry> +<entry>no</entry> </row> <row> <entry>mergebw</entry> <entry>yes</entry> <entry>yes</entry> -<entry>yes</entry> +<entry>no</entry> <entry>no</entry> <entry>yes</entry> -<entry>yes</entry> +<entry>no</entry> </row> <row> <entry>splitlw</entry> <entry>yes</entry> +<entry>yes</entry> <entry>no</entry> <entry>no</entry> -<entry>no</entry> -<entry>no</entry> +<entry>yes</entry> <entry>no</entry> </row> <row> <entry>splitwb</entry> <entry>yes</entry> +<entry>yes</entry> <entry>no</entry> <entry>no</entry> -<entry>no</entry> -<entry>no</entry> +<entry>yes</entry> <entry>no</entry> </row> <row> @@ -1028,7 +1343,7 @@ <entry>no</entry> <entry>no</entry> <entry>yes</entry> -<entry>yes</entry> +<entry>no</entry> </row> <row> <entry>subf</entry> @@ -1037,7 +1352,7 @@ <entry>no</entry> <entry>no</entry> <entry>yes</entry> -<entry>yes</entry> +<entry>no</entry> </row> <row> <entry>mulf</entry> @@ -1046,7 +1361,7 @@ <entry>no</entry> <entry>no</entry> <entry>yes</entry> -<entry>yes</entry> +<entry>no</entry> </row> <row> <entry>divf</entry> @@ -1055,7 +1370,7 @@ <entry>no</entry> <entry>no</entry> <entry>no</entry> -<entry>yes</entry> +<entry>no</entry> </row> <row> <entry>sqrtf</entry> @@ -1064,7 +1379,7 @@ <entry>no</entry> <entry>no</entry> <entry>no</entry> -<entry>yes</entry> +<entry>no</entry> </row> <row> <entry>maxf</entry> @@ -1073,7 +1388,7 @@ <entry>no</entry> <entry>no</entry> <entry>yes</entry> -<entry>yes</entry> +<entry>no</entry> </row> <row> <entry>minf</entry> @@ -1082,7 +1397,7 @@ <entry>no</entry> <entry>no</entry> <entry>yes</entry> -<entry>yes</entry> +<entry>no</entry> </row> <row> <entry>cmpeqf</entry> @@ -1091,7 +1406,7 @@ <entry>no</entry> <entry>no</entry> <entry>yes</entry> -<entry>yes</entry> +<entry>no</entry> </row> <row> <entry>cmpltf</entry> @@ -1100,7 +1415,7 @@ <entry>no</entry> <entry>no</entry> <entry>no</entry> -<entry>yes</entry> +<entry>no</entry> </row> <row> <entry>cmplef</entry> @@ -1109,7 +1424,7 @@ <entry>no</entry> <entry>no</entry> <entry>no</entry> -<entry>yes</entry> +<entry>no</entry> </row> <row> <entry>convfl</entry> @@ -1118,7 +1433,7 @@ <entry>no</entry> <entry>no</entry> <entry>yes</entry> -<entry>yes</entry> +<entry>no</entry> </row> <row> <entry>convlf</entry> @@ -1127,7 +1442,7 @@ <entry>no</entry> <entry>no</entry> <entry>yes</entry> -<entry>yes</entry> +<entry>no</entry> </row> </tbody> </tgroup> diff --git a/doc/tutorial.xml b/doc/tutorial.xml new file mode 100644 index 0000000..c8b8a62 --- /dev/null +++ b/doc/tutorial.xml @@ -0,0 +1,510 @@ +<?xml version="1.0"?> +<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN" + "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd" [ +<!ENTITY % version-entities SYSTEM "version.entities"> +%version-entities; +<!ENTITY % local.common.attrib "xmlns:xi CDATA #FIXED 'http://www.w3.org/2003/XInclude'"> +]> +<refentry id="orc-tutorial" revision="29 may 2009"> +<refmeta> +<refentrytitle>Orc Tutorial</refentrytitle> +<manvolnum>3</manvolnum> +<refmiscinfo>Orc</refmiscinfo> +</refmeta> + +<refnamediv> +<refname>Orc Tutorial</refname> +<refpurpose> +Getting started writing Orc code. +</refpurpose> +</refnamediv> + +<refsect1> +<title>Orc Tutorial</title> + + <para> + This section walks you through several examples of increasing + complexity to get you started working with Orc. Each of these + examples are available in the Orc source code, in the examples + directory. The first three examples use static Orc code that + is in a source file, and is compiled into intermediate C code + by the orcc tool. + </para> + + <para> + The first example demonstrates how to add two arrays of 16-bit + signed integers together. A possible use case for this is + combining two stereo audio streams together. + </para> + + <para> + The second example builds from the first, replacing one of the + stereo input streams with a mono stream, converting it to stereo + in the process, and also adjusting the volume of the stream. + </para> + + <para> + The third example shows how to convert a planar 4:2:0 video + image into a packed 4:4:4 video image with an alpha channel. + </para> + +</refsect1> + +<refsect1> +<title>Example 1</title> + +<para> + This example demonstrates combining two stereo audio streams + by adding. Uncompressed audio streams (i.e., PCM format) can + be in a variety of formats, but one of the most common is + interleaved signed 16-bit integers, and we will choose that + for the purposes of this example. Extending to other formats + is left as an exercise for the reader. Interleaved means that + left and right channel samples are consecutive: in memory, the + data look like LRLRLR... The sampling rate is unimportant, as + long as both streams are the same. +</para> + +<para> + One important feature/limitation of signed 16-bit audio samples + is that adding two together could cause an overflow. For example, + adding the value 25000 to 10000 gives 35000, but this overflows + 16 bits, so a standard addition would instead give the value + -30536 (35000-65536). Overflows handled this way sound like + crackling or worse, so we would like a better solution. One + solution is to use saturating addition: in this case, the addition + of 25000 and 10000 would be limited by the upper end of signed + 16-bit values to give 32767. Although this still causes + distortion in the output signal, it is much less audible and + annoying. +</para> + +<para> + In normal C code, 16-bit saturating addition is difficult to express + without using 32-bit intermediates. In Orc, saturating addition + is a basic operation with opcodes for each size, both signed and + unsigned. In this case, we want "addssw", for "add signed saturated + word". +</para> + +<para> + Also, we're going to make a one simplification: Adding two + interleaved stereo streams is the same as adding two mono streams + with twice as many samples. So we'll use 2*n_samples in the calling + code. +</para> + +<para> + To the code: + +<programlisting> +.function audio_add_s16 +.dest 2 d1 +.source 2 s1 +.source 2 s2 + +addssw d1, s1, s2 +</programlisting> +</para> + +<para> + Line by line: + +<programlisting> +.function audio_add_s16 +</programlisting> + + This starts a function. A function (represented internally by the + object OrcProgram) is equivalent to a C function. When you generate + C code from this Orc exmaple using the orcc tool, it generates a C + stub function called "audio_add_s16()", which at runtime will + generate an OrcProgram object corresponding to the above code, + compile it, and then run it. + +<programlisting> +.dest 2 d1 short +</programlisting> + + This specifies that you want a destination (output) array named "d1", + with the element size being 2. Orc does not differentiate between + signed and unsigned arrays (or even floating point), however, you + may optionally specify a type afterwards that will be used in any + autogenerated C code. + +<programlisting> +.source 2 s1 short +.source 2 s2 short +</programlisting> + + This specifies that you want two source (input) arrays, "s1" and "s2", + similar to the destination array. + +<programlisting> +addssw d1, s1, s2 +</programlisting> + + This specifies the (only) opcode that we want for this program: signed + saturated addition of each member of the two source arrays, and store + the result in the destination array. +</para> + +<para> + A few notes about the above program: The loop over the array members + is implied. Everything that Orc does is based on looping over each + array element and executing the opcodes in a program. +</para> + +<para> + When you generate C code from the above Orc code using + 'orcc --implementation example1.orc', + you get a bunch of boilerplate code, plus three C functions: + +<programlisting> +/* audio_add_s16 */ +#ifdef DISABLE_ORC +void +audio_add_s16 (int16 * d1, const int16 * s1, const int16 * s2, int n) +{ + ... +} +</programlisting> + + This function is used if DISABLE_ORC is defined. As one might guess, + if you define DISABLE_ORC, no runtime Orc features are used, and all + calls to audio_add_s16() use this function. The interior of the function + is a for() loop that implements the Orc function. The generated code + may not necessarily be easy to read, but it is straightforward: all + the verbosity and use of unions is to avoid compiler warnings without + making the compiler too complex. But this is the place to go if you + are trying to understand what Orc is doing. + +<programlisting> +#else +static void +_backup_audio_add_s16 (OrcExecutor * ORC_RESTRICT ex) +{ + ... +} +</programlisting> + + This function is used when runtime Orc is enabled, but Orc was unable + to generate code for the function at runtime. There are various + reasons why that might happen -- unimplemented rules for a target, or + more temporary variables used than available registers. + +<programlisting> +void +audio_add_s16 (short * d1, const short * s1, const short * s2, int n) +{ + ... +} +</programlisting> + + The third generated function is the important part: It is used when + Orc is enabled at runtime, and creates the OrcProgram corresponding + to the function you defined. Then it compiles the function and + calls it. +</para> + +<para> + After generating the C code, you should generate the header file, + using: 'orcc --header example1orc.orc -o example1orc.h'. + After similar boilerplate code, there is the expected declaration + of audio_add_s16(): + +<programlisting> +void audio_add_s16 (short * d1, const short * s1, const short * s2, int n); +</programlisting> + + +</para> + +<para> + Some C code to generate sample data, call the generated code, and + print out the results: + +<programlisting> +#include <stdio.h> +#include "example1orc.h" + +#define N 10 + +short a[N]; +short b[N]; +short c[N]; + +int +main (int argc, char *argv[]) +{ + int i; + + /* Create some data in the source arrays */ + for(i=0;i < N;i++){ + a[i] = 100*i; + b[i] = 32000; + } + + /* Call a function that uses Orc */ + audio_add_s16 (c, a, b, N); + + /* Print the results */ + for(i=0;i < N;i++){ + printf("%d: %d %d -> %d\n", i, a[i], b[i], c[i]); + } + + return 0; +} +</programlisting> +</para> + +<para> + The output of the program: + +<programlisting> +0: 0 32000 -> 32000 +1: 100 32000 -> 32100 +2: 200 32000 -> 32200 +3: 300 32000 -> 32300 +4: 400 32000 -> 32400 +5: 500 32000 -> 32500 +6: 600 32000 -> 32600 +7: 700 32000 -> 32700 +8: 800 32000 -> 32767 +9: 900 32000 -> 32767 +</programlisting> +</para> + +<para> + +</para> + +</refsect1> + +<refsect1> +<title>Example 2</title> + +<para> + In this example, we will expand on the previous example by making + one of the input arrays a mono stream, and also scale the mono + input stream by a volume. Rather than iterating over each + signed 16-bit value, in this example we will iterate over samples, + meaning the member size for the stereo arrays is 4, since each + array member contains a left and right 16 bit value. +</para> + +<para> +<programlisting> +.function audio_add_mono_to_stereo_scaled_s16 +.dest 4 d1 short +.source 4 s1 short +.source 2 s2 short +.param 2 volume +.temp 4 s2_scaled +.temp 2 t +.temp 4 s2_stereo + +mulswl s2_scaled, s2, volume +shrsl s2_scaled, s2_scaled, 12 +convssslw t, s2_scaled +mergewl s2_stereo, t, t +x2 addssw d1, s1, s2_stereo +</programlisting> + + Piece by piece: + +<programlisting> +.function audio_add_mono_to_stereo_scaled_s16 +.dest 4 d1 short +.source 4 s1 short +.source 2 s2 short +</programlisting> + + This is the same as the previous example, except that the stereo + arrays are increased in size to 4. However, we'll use the short + type, since Orc does not care what type we use, and short is + the type of the array we want to use in the C code. + +<programlisting> +.param 2 volume +</programlisting> + + This specifies a parameter, which is an integer that is passed to + an Orc function. In the generated C code, parameters are always of + type int. There are also float parameters for the floating point + equivalent. + +<programlisting> +.temp 4 s2_scaled +.temp 2 t +.temp 4 s2_stereo +</programlisting> + + This specifies a few temporary variables that are used later in the + code. These definitions are similar to defining local variables in + C code. Note that the size is important: each opcode has + specific sizes for source and destination operands, and it is + important to match these correctly with temporary variables. + +<programlisting> +mulswl s2_scaled, s2, volume +shrsl s2_scaled, s2_scaled, 12 +</programlisting> + + This scales the mono input: signed multiply of s2 and volume, giving + a 32-bit value, and then a signed right shift by 12. Since the + second operand of mulswl is 16-bit, only the lower 16 bits of + volume will be used in the multiply. The right shift is + effectively the same as dividing by 4096. Thus, a neutral scaling + that does not increase or decrease the mono input would correspond + to calling the function with a parameter value of 4096. + +<programlisting> +convssslw t, s2_scaled +mergewl s2_stereo, t, t +</programlisting> + + The first instruction is "convert saturated signed 32-bit to signed + 16-bit", and the second merges the two values of (16 bit) t into the + high and low halves of s2_stereo. This duplicates the mono signal + into the right and left channels. It is important to use the + saturated conversion, since the effective scaling value may have + been greater than 1.0, thus the larger values may need to be clipped. + +<programlisting> +x2 addssw d1, s1, s2_stereo +</programlisting> + + The "x2" prefix indicates that we want the operation specified to be + done twice, first to the upper half of all operands, and again + separately to the lower half of all operands. Since addssw is + normally a 16-bit operation, the x2 prefix causes it to be a 32-bit + operation. And so, it adds the newly created right and left values + of the scaled mono signal into the s1 signal. +</para> + +<para> + There are several variations of the above program that might be + more suitable for a particular application. This function only + handles a limited dynamic range of volume scaling factors, however, + by changing the shift constant, or turning the shift into a + parameter, the dynamic range can be increased significantly. +</para> + + +</refsect1> + +<refsect1> +<title>Example 3</title> + +<para> + The third example shows how to convert a planar 4:2:0 video + image into a packed 4:4:4 video image with an alpha channel. The + first format is often referred to as I420 and the second as AYUV. +</para> + +<para> + For simplicity in the following discussion, we'll assume that the + image dimensions are 640x480. The 4:2:0 subsampling means the + input chroma planes are 320x240 (subsampled by 2 in each direction). + These need to be upsampled to 640x480, then repacked with the input + Y plane, with an added dummy alpha value. There are many ways to + perform upsampling; the simplest is to duplicate each value + horizontally and vertically. The result is low quality, but + adequate for demonstration purposes. +</para> + +<para> + There are several choices for the Orc array size and dimensionality. + Iterating vertically can be done in the C code or in the Orc code. If + done in the Orc code, we would need to use an array size of 240 and + have two separate arrays for the even and odd Y rows. If done in the + C code, there is no such limitation. Horizontally, the story is + different: we can use the loadupsdb opcode to duplicate each byte in + the U and V arrays, so we can iterate over 640 array elements. It + is also possible to iterate over 320 elements and duplicate the U + and V elements using mergebw. There is a very slight speed + advantage to iterating vertically in Orc, and for demonstration + purposes, we will choose to use the loadupsdb opcode, thus we will + be iterating over 320x240 elements. +</para> + +<para> + The code: + +<programlisting> +.function convert_I420_AYUV +.flags 2d +.dest 4 d1 +.dest 4 d2 +.source 1 y1 +.source 1 y2 +.source 1 u +.source 1 v +.const 1 c255 255 +.temp 2 uv +.temp 2 ay +.temp 1 tu +.temp 1 tv + +loadupdb tu, u +loadupdb tv, v +mergebw uv, tu, tv +mergebw ay, c255, y1 +mergewl d1, ay, uv +mergebw ay, c255, y2 +mergewl d2, ay, uv +</programlisting> + + A few things of note: The ".flags 2d" line is used to indicate that + Orc should iterate over two dimensions, and generate a prototype that + includes row strides for each array and a size parameter for the + second dimension. +</para> + +<para> + Since we are working on two input Y lines and two output AYUV lines + at a time, we need two source and destination arrays corresponding + to the even and odd lines. The row strides for these are doubled + compared to the normal 2-D array. +</para> + +<para> + The mergebw and mergewl opcodes join two 8-bit values into one 16-bit + value (or 16-bit values into a 32-bit value) by concatinating them + in memory order. Thus, to get AYUV in memory order, we merge AY and + UV, and to get UV, we merge U and V. Since we're duplicating each + U and V line, we use the same UV value for the even and odd output + lines. +</para> + +<para> + The prototype that is generated is: + +<programlisting> +void convert_I420_AYUV (orc_uint32 * d1, int d1_stride, orc_uint32 * d2, + int d2_stride, const orc_uint8 * s1, int s1_stride, const orc_uint8 * s2, + int s2_stride, const orc_uint8 * s3, int s3_stride, const orc_uint8 * s4, + int s4_stride, int n, int m); +</programlisting> + + The orcc tool unhelpfully changed the names of the parameters, + however, the order is standard: first destinations, then sources, then + parameters, then array sizes. Think of it like memcpy() or memset(). +</para> + +<para> + Calling the function: + +<programlisting> +convert_I420_AYUV (output, 1280*4, output + 640, 1280 * 4, + input_y, 1280, input_y + 640, 1280, + input_u, 320, input_v, 320, + 320, 240); +</programlisting> + +</para> + +</refsect1> + +</refentry> + |