
TM1100 Preliminary Data Book
Philips Semiconductors
4-8
PRELIMINARY INFORMATION
File: cstm.fm5, modified 7/26/99
almost always improves the chances of realizing maxi-
mum performance on the TM1100 CPU.
The code in
Figure 4-8 illustrates several aspects of us-
ing custom operations in C-language source code. First,
the custom operations require no special declarations or
syntax; they appear to be simple function calls. Second,
there is no need to explicitly specify register assignments
for sources, destinations, and intermediate results; the
compiler and scheduler assign registers for custom oper-
ations just as they would for built-in language operations
such as integer addition. Third, the scheduler packs cus-
tom operations into TM1100 VLIW instructions as effec-
tively as it packs operations generated by the compiler
for native language constructs.
Thus, although the burden of making effective use of
custom operations falls on the programmer, that burden
consists only of discovering the opportunities for exploit-
ing the operations and then coding them using standard
C-language notation. The compiler and scheduler take
care of the rest.
4.4
EXAMPLE 3: MOTION-ESTIMATION
KERNEL
Another part of the MPEG coding algorithm is motion es-
timation. The purpose of motion estimation is to reduce
the cost of storing a frame of video by expressing the
contents of the frame in terms of adjacent frames. A giv-
en frame is reduced to small blocks, and a subsequent
frame is represented by specifying how these small
blocks change position and appearance; usually, storing
the difference information is cheaper than storing a
whole block. For example, in a video sequence where
the camera pans across a static scene, some frames can
be expressed simply as displaced versions of their pre-
decessor frames. To create a subsequent frame, most
blocks are simply displaced relative to the output screen.
The code in this example is for a match-cost calculation,
a small kernel of the complete motion-estimation code.
As with the previous example, this code provides an ex-
cellent example of how to transform source code to make
the best use of TM1100’s custom operations.
Figure 4-9 shows the original source code for the match-
cost loop. Unlike the previous example, the code is not a
self-contained function. Somewhere early in the code,
the arrays A[][] and B[][] are declared; somewhere be-
tween those declarations and the loop of interest, the ar-
rays are filled with data.
4.4.1
A Simple Transformation
First, we will look at the simplest way to use a TM1100
custom operation.
We start by noticing that the computation in the loop of
Figure 4-9 involves the absolute value of the difference
of two unsigned characters (bytes). By now, we are fa-
miliar with the fact that TM1100 includes a number of op-
erations that process all four bytes in a 32-bit word simul-
taneously.
Since
the
match-cost
calculation
is
fundamental to the MPEG algorithm, it is not surprising
to find a custom operation—ume8uu—that implements
this operation exactly.
To understand how ume8uu can be used in this case, we
need to transform the code as in the previous example.
void reconstruct (unsigned char *back,
unsigned char *forward,
char *idct,
unsigned char *destination)
{
int i;
int *i_back
= (int *) back;
int *i_forward = (int *) forward;
int *i_idct
= (int *) idct;
int *i_dest
= (int *) destination;
for (i = 0; i < 16; i += 1)
i_dest[i] = DSPUQUADADDUI(QUADAVG(i_back[i], i_forward[i]), i_idct[i]);
}
Figure 4-8. Final version of the frame-reconstruction code.
unsigned char A[16][16];
unsigned char B[16][16];
.
for (row = 0; row < 16; row += 1)
{
for (col = 0; col < 16; col += 1)
cost += abs(A[row][col] – B[row][col]);
}
Figure 4-9. Match-cost loop for MPEG motion estimation.