User Guide
128-Bit Media and Scientific Programming 151
24592—Rev. 3.15—November 2009 AMD64 Technology
operand1[i] = ((operand1[i] + operand2[i]) + 1) ÷ 2
where: i = 0 to n – 1
The PAVGB instruction is useful for MPEG decoding, in which motion compensation performs many
byte-averaging operations between and within macroblocks. In addition to speeding up these
operations, PAVGB can free up registers and make it possible to unroll the averaging loops.
Sum of Absolute Differences.
• PSADBW—Packed Sum of Absolute Differences of Bytes into a Word
The PSADBW instruction computes the absolute values of the differences of corresponding 8-bit
signed integer values in the two quadword halves of both source operands, sums the differences for
each quadword half, and writes the two unsigned 16-bit integer results in the destination. The sum for
the high-order half is written in the least-significant word of the destination’s high-order quadword,
with the remaining bytes cleared to all 0s. The sum for the low-order half is written in the least-
significant word of the destination’s low-order quadword, with the remaining bytes cleared to all 0s.
Figure 4-29 shows the PSADBW operation. Sums of absolute differences are useful, for example, in
computing the L1 norm in motion-estimation algorithms for video compression.
Figure 4-29. PSADBW Sum-of-Absolute-Differences Operation
513-155.eps
operand 1
. . . . . .. . . . . .. . . . . .. . . . . .
. . . . . . . . . . . .
127 0
operand 2
127 0
result
00
127 0
low-order
intermediate result
high-order
intermediate result
ABS ΔABS Δ
ΣΣ
ABS Δ ABS Δ