10c1bc742181ded4930842b46e9507372f0b1b963James Dong;//
20c1bc742181ded4930842b46e9507372f0b1b963James Dong;//
30c1bc742181ded4930842b46e9507372f0b1b963James Dong;// File Name:  armVCCOMM_s.h
40c1bc742181ded4930842b46e9507372f0b1b963James Dong;// OpenMAX DL: v1.0.2
50c1bc742181ded4930842b46e9507372f0b1b963James Dong;// Revision:   12290
60c1bc742181ded4930842b46e9507372f0b1b963James Dong;// Date:       Wednesday, April 9, 2008
70c1bc742181ded4930842b46e9507372f0b1b963James Dong;//
80c1bc742181ded4930842b46e9507372f0b1b963James Dong;// (c) Copyright 2007-2008 ARM Limited. All Rights Reserved.
90c1bc742181ded4930842b46e9507372f0b1b963James Dong;//
100c1bc742181ded4930842b46e9507372f0b1b963James Dong;//
110c1bc742181ded4930842b46e9507372f0b1b963James Dong;//
120c1bc742181ded4930842b46e9507372f0b1b963James Dong;// ARM optimized OpenMAX AC header file
130c1bc742181ded4930842b46e9507372f0b1b963James Dong;//
140c1bc742181ded4930842b46e9507372f0b1b963James Dong;// Formula used:
150c1bc742181ded4930842b46e9507372f0b1b963James Dong;// MACRO for calculating median for three values.
160c1bc742181ded4930842b46e9507372f0b1b963James Dong
170c1bc742181ded4930842b46e9507372f0b1b963James Dong
180c1bc742181ded4930842b46e9507372f0b1b963James Dong
190c1bc742181ded4930842b46e9507372f0b1b963James Dong    IF :LNOT::DEF:ARMVCCOMM_S_H
200c1bc742181ded4930842b46e9507372f0b1b963James Dong        INCLUDE armCOMM_s.h
210c1bc742181ded4930842b46e9507372f0b1b963James Dong    M_VARIANTS      CortexA8, ARM1136JS
220c1bc742181ded4930842b46e9507372f0b1b963James Dong
230c1bc742181ded4930842b46e9507372f0b1b963James Dong    IF ARM1136JS :LOR: CortexA8
240c1bc742181ded4930842b46e9507372f0b1b963James Dong
250c1bc742181ded4930842b46e9507372f0b1b963James Dong     ;///*
260c1bc742181ded4930842b46e9507372f0b1b963James Dong     ;// * Macro: M_MEDIAN3
270c1bc742181ded4930842b46e9507372f0b1b963James Dong     ;// *
280c1bc742181ded4930842b46e9507372f0b1b963James Dong     ;// * Description: Finds the median of three numbers
290c1bc742181ded4930842b46e9507372f0b1b963James Dong     ;// *
300c1bc742181ded4930842b46e9507372f0b1b963James Dong     ;// * Remarks:
310c1bc742181ded4930842b46e9507372f0b1b963James Dong     ;// *
320c1bc742181ded4930842b46e9507372f0b1b963James Dong     ;// * Parameters:
330c1bc742181ded4930842b46e9507372f0b1b963James Dong     ;// * [in] x     First entry for the list of three numbers.
340c1bc742181ded4930842b46e9507372f0b1b963James Dong     ;// * [in] y     Second entry for the list of three numbers.
350c1bc742181ded4930842b46e9507372f0b1b963James Dong     ;// *            Input value may be corrupted at the end of
360c1bc742181ded4930842b46e9507372f0b1b963James Dong     ;// *            the execution of this macro.
370c1bc742181ded4930842b46e9507372f0b1b963James Dong     ;// * [in] z     Third entry of the list of three numbers.
380c1bc742181ded4930842b46e9507372f0b1b963James Dong     ;// *            Input value corrupted at the end of the
390c1bc742181ded4930842b46e9507372f0b1b963James Dong     ;// *            execution of this macro.
400c1bc742181ded4930842b46e9507372f0b1b963James Dong     ;// * [in] t     Temporary scratch  register.
410c1bc742181ded4930842b46e9507372f0b1b963James Dong     ;// * [out]z     Median of the three numbers.
420c1bc742181ded4930842b46e9507372f0b1b963James Dong     ;// */
430c1bc742181ded4930842b46e9507372f0b1b963James Dong
440c1bc742181ded4930842b46e9507372f0b1b963James Dong     MACRO
450c1bc742181ded4930842b46e9507372f0b1b963James Dong
460c1bc742181ded4930842b46e9507372f0b1b963James Dong     M_MEDIAN3 $x, $y, $z, $t
470c1bc742181ded4930842b46e9507372f0b1b963James Dong
480c1bc742181ded4930842b46e9507372f0b1b963James Dong     SUBS  $t, $y, $z; // if (y < z)
490c1bc742181ded4930842b46e9507372f0b1b963James Dong     ADDLT $z, $z, $t; //  swap y and z
500c1bc742181ded4930842b46e9507372f0b1b963James Dong     SUBLT $y, $y, $t;
510c1bc742181ded4930842b46e9507372f0b1b963James Dong
520c1bc742181ded4930842b46e9507372f0b1b963James Dong     ;// Now z' <= y', so there are three cases for the
530c1bc742181ded4930842b46e9507372f0b1b963James Dong     ;// median value, depending on x.
540c1bc742181ded4930842b46e9507372f0b1b963James Dong
550c1bc742181ded4930842b46e9507372f0b1b963James Dong     ;// 1) x <= z'      <= y'      : median value is z'
560c1bc742181ded4930842b46e9507372f0b1b963James Dong     ;// 2)      z' <= x <= y'      : median value is x
570c1bc742181ded4930842b46e9507372f0b1b963James Dong     ;// 3)      z'      <= y' <= x : median value is y'
580c1bc742181ded4930842b46e9507372f0b1b963James Dong
590c1bc742181ded4930842b46e9507372f0b1b963James Dong     CMP   $z, $x;     // if ( x > min(y,z) )
600c1bc742181ded4930842b46e9507372f0b1b963James Dong     MOVLT $z, $x;     // ans = x
610c1bc742181ded4930842b46e9507372f0b1b963James Dong
620c1bc742181ded4930842b46e9507372f0b1b963James Dong     CMP   $x, $y;     // if ( x > max(y,z) )
630c1bc742181ded4930842b46e9507372f0b1b963James Dong     MOVGT $z, $y;     // ans = max(y,z)
640c1bc742181ded4930842b46e9507372f0b1b963James Dong
650c1bc742181ded4930842b46e9507372f0b1b963James Dong     MEND
660c1bc742181ded4930842b46e9507372f0b1b963James Dong    ENDIF
670c1bc742181ded4930842b46e9507372f0b1b963James Dong
680c1bc742181ded4930842b46e9507372f0b1b963James Dong
690c1bc742181ded4930842b46e9507372f0b1b963James Dong
700c1bc742181ded4930842b46e9507372f0b1b963James Dong    ENDIF ;// ARMACCOMM_S_H
710c1bc742181ded4930842b46e9507372f0b1b963James Dong
720c1bc742181ded4930842b46e9507372f0b1b963James Dong END