http://www.alphalinux.org/wiki/index.php?title=Motion_Video_Instructions&feed=atom&action=historyMotion Video Instructions - Revision history2024-03-28T19:34:13ZRevision history for this page on the wikiMediaWiki 1.31.7http://www.alphalinux.org/wiki/index.php?title=Motion_Video_Instructions&diff=84&oldid=prevGareth: Imported from http://web.archive.org/web/20100713090023/http://www.alphalinux.org/wiki/index.php?title=Motion_Video_Instructions&action=edit2019-08-29T18:17:06Z<p>Imported from http://web.archive.org/web/20100713090023/http://www.alphalinux.org/wiki/index.php?title=Motion_Video_Instructions&action=edit</p>
<p><b>New page</b></p><div>Beginning with the [[Processors#PCA56|PCA56]] processor, [[Digital|DEC]] added the Motion Video Instructions (MVI) to accelerate algorithms related to motion video formats such as MPEG1 and MPEG2<ref>{{cite web<br />
| url = http://www.alasir.com/articles/alpha_history/press/samsung_ev6_announce.html<br />
| title = Samsung Introduces Alpha 21264, World's Fastest Microprocessor -- Sets Standards for 64-bit Visual and Enterprise Computing<br />
| accessdate = Nov 29, 2008<br />
| date = April 6, 1998<br />
| publisher = Samsung Semiconductor<br />
}}</ref>. Compared to other [http://en.wikipedia.org/wiki/SIMD SIMD] instruction sets of the time, MVI is very simple. In order to prevent complicating the instruction decode logic, the MVI extension contains only 13 SIMD instructions.<br />
<br />
Unlike Intel's MMX and SSE SIMD extensions, MVIs use the Alpha's general purpose registers.<br />
<br />
== Added Instructions ==<br />
<br />
{| class="wikitable" style="font-size:97%;"<br />
! Mnemonic<br />
! Description<br />
|-<br />
! minub8<br />
| minimum of packed unsigned bytes<br />
|-<br />
! maxub8<br />
| maximum of packed unsigned bytes<br />
|-<br />
! minsb8<br />
| minimum of packed signed bytes<br />
|-<br />
! maxsb8<br />
| maximum of packed signed bytes<br />
|-<br />
! minuw4<br />
| minimum of packed unsigned words<br />
|-<br />
! maxuw4<br />
| maximum of packed unsigned words<br />
|-<br />
! minsw4<br />
| minimum of packed signed words<br />
|-<br />
! maxsw4<br />
| maximum of packed signed words<br />
|-<br />
! pkwb<br />
| pack words into bytes<br />
|-<br />
! unpkwb<br />
| unpack words into bytes<br />
|-<br />
! pklb<br />
| pack longs into bytes<br />
|-<br />
! unpklb<br />
| unpack longs into bytes<br />
|-<br />
! perr<br />
| sum the absolute differences of each byte (pixel error)<ref>{{cite web|url=http://www.alphalinux.org/docs/MVI-full.html|title=Motion Video Instructions (MVI)|author=James Hicks|coauthors=Richard Weiss|year=1999|month=February|format=HTML|publisher=Compaq Computer Corporation}}</ref><br />
|}<br />
<br />
== Determining Presence ==<br />
<br />
To determine the presence of MVI, use the [[amask]] instruction.<br />
<br />
== Latency and Slotting ==<br />
<br />
On the in-order PCA56, all MVIs have a latency of 2 cycles. This means, at least one instruction must separate MVIs to prevent stalling. On the out-of-order [[Processors#EV6|EV6]] and newer, MVIs have a latency of 3 cycles and are slotted U0<ref>{{cite web|url=http://h18002.www1.hp.com/alphaserver/technology/literature/cmpwrgd.pdf|title=Compiler Writer’s Guide for the Alpha 21264|year=1999|month=June|format=PDF|publisher=Compaq Computer Corporation|pages=35-38}}</ref>.<br />
<br />
== Usage ==<br />
<br />
=== Unsigned Saturated Arithmetic ===<br />
<br />
By using the packed minimum, packed unsigned saturated addition and subtraction can be easily performed.<br />
<br />
For instance, to add the packed unsigned bytes stored in $16 with those in $17 with saturation and store the result in $0:<br />
<br />
<pre>ornot $31,$16,$1<br />
minub8 $17,$1,$17<br />
addq $16,$17,$0</pre><br />
<br />
To subtract the packed unsigned bytes stored in $16 with those in $17 with saturation and store the result in $0:<br />
<br />
<pre>minub8 $17,$16,$17<br />
subq $16,$17,$0</pre><br />
<br />
Note, these are not optimized for register usage or latency.<br />
<br />
To use this in C, the following functions may be used.<br />
<br />
<pre>#define __minub8 __builtin_alpha_minub8<br />
#define __minuw4 __builtin_alpha_minuw4<br />
<br />
/* Add the 8-bit values in M1 to the 8-bit values in M2 using unsigned<br />
* saturated arithmetic (MMX equivalent: paddusb) */<br />
static inline __m64<br />
addusb8(__m64 m1, __m64 m2) {<br />
return m1 + __minub8(m2, ~m1);<br />
}<br />
<br />
/* Add the 16-bit values in M1 to the 16-bit values in M2 using unsigned<br />
* saturating arithmetic (MMX equilvant: paddusw) */<br />
static inline __m64<br />
addusw4(__m64 m1, __m64 m2) {<br />
return m1 + __minuw4(m2, ~m1);<br />
}<br />
<br />
/* Subtract the 8-bit values in M1 to the 8-bit values in M2 using unsigned<br />
* saturated arithmetic (MMX equivalent: psubusb) */<br />
static inline __m64<br />
subusb8(__m64 m1, __m64 m2) {<br />
return m1 - __minub8(m2, m1);<br />
}<br />
<br />
/* Subtract the 16-bit values in M1 to the 16-bit values in M2 using unsigned<br />
* saturating arithmetic (MMX equivalent: psubusw) */<br />
static inline __m64<br />
subusw4(__m64 m1, __m64 m2) {<br />
return m1 - __minuw4(m2, m1);<br />
}</pre><br />
<br />
== External Links ==<br />
* [http://alphalinux.org/documents/mvi-code-ex.pdf MVI Code Examples]<br />
* [http://alphalinux.org/documents/pmvi.pdf Digital's Motion Video Instruction Extensions for Alpha Whitepaper]<br />
* [http://alphalinux.org/documents/digi_add_multimedia.pdf ''Digital, MIPS Add Multimedia Extensions'']<br />
* [http://alphalinux.org/documents/1997DEC01_MSD_TAC19.pdf ''Real Time MPEG-I and MPEG-II Compression with the Alpha Microprocessors'']<br />
<br />
== References ==<br />
<references/><br />
<br />
[[Category:Programming]]</div>Gareth