178e52bfac041d71ce53b5b13c2abf78af742b09dLajos Molnar;//
278e52bfac041d71ce53b5b13c2abf78af742b09dLajos Molnar;// Copyright (C) 2007-2008 ARM Limited
378e52bfac041d71ce53b5b13c2abf78af742b09dLajos Molnar;//
478e52bfac041d71ce53b5b13c2abf78af742b09dLajos Molnar;// Licensed under the Apache License, Version 2.0 (the "License");
578e52bfac041d71ce53b5b13c2abf78af742b09dLajos Molnar;// you may not use this file except in compliance with the License.
678e52bfac041d71ce53b5b13c2abf78af742b09dLajos Molnar;// You may obtain a copy of the License at
778e52bfac041d71ce53b5b13c2abf78af742b09dLajos Molnar;//
878e52bfac041d71ce53b5b13c2abf78af742b09dLajos Molnar;//      http://www.apache.org/licenses/LICENSE-2.0
978e52bfac041d71ce53b5b13c2abf78af742b09dLajos Molnar;//
1078e52bfac041d71ce53b5b13c2abf78af742b09dLajos Molnar;// Unless required by applicable law or agreed to in writing, software
1178e52bfac041d71ce53b5b13c2abf78af742b09dLajos Molnar;// distributed under the License is distributed on an "AS IS" BASIS,
1278e52bfac041d71ce53b5b13c2abf78af742b09dLajos Molnar;// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1378e52bfac041d71ce53b5b13c2abf78af742b09dLajos Molnar;// See the License for the specific language governing permissions and
1478e52bfac041d71ce53b5b13c2abf78af742b09dLajos Molnar;// limitations under the License.
1578e52bfac041d71ce53b5b13c2abf78af742b09dLajos Molnar;//
160c1bc742181ded4930842b46e9507372f0b1b963James Dong; **********
170c1bc742181ded4930842b46e9507372f0b1b963James Dong; *
180c1bc742181ded4930842b46e9507372f0b1b963James Dong; * File Name:  omxVCM4P2_PredictReconCoefIntra_s.s
190c1bc742181ded4930842b46e9507372f0b1b963James Dong; * OpenMAX DL: v1.0.2
200c1bc742181ded4930842b46e9507372f0b1b963James Dong; * Revision:   9641
210c1bc742181ded4930842b46e9507372f0b1b963James Dong; * Date:       Thursday, February 7, 2008
220c1bc742181ded4930842b46e9507372f0b1b963James Dong; *
230c1bc742181ded4930842b46e9507372f0b1b963James Dong; *
240c1bc742181ded4930842b46e9507372f0b1b963James Dong; *
250c1bc742181ded4930842b46e9507372f0b1b963James Dong; *
260c1bc742181ded4930842b46e9507372f0b1b963James Dong; * Description:
270c1bc742181ded4930842b46e9507372f0b1b963James Dong; * Contains module for DC/AC coefficient prediction
280c1bc742181ded4930842b46e9507372f0b1b963James Dong; *
290c1bc742181ded4930842b46e9507372f0b1b963James Dong; *
300c1bc742181ded4930842b46e9507372f0b1b963James Dong; * Function: omxVCM4P2_PredictReconCoefIntra
310c1bc742181ded4930842b46e9507372f0b1b963James Dong; *
320c1bc742181ded4930842b46e9507372f0b1b963James Dong; * Description:
330c1bc742181ded4930842b46e9507372f0b1b963James Dong; * Performs adaptive DC/AC coefficient prediction for an intra block. Prior
340c1bc742181ded4930842b46e9507372f0b1b963James Dong; * to the function call, prediction direction (predDir) should be selected
350c1bc742181ded4930842b46e9507372f0b1b963James Dong; * as specified in subclause 7.4.3.1 of ISO/IEC 14496-2.
360c1bc742181ded4930842b46e9507372f0b1b963James Dong; *
370c1bc742181ded4930842b46e9507372f0b1b963James Dong; * Remarks:
380c1bc742181ded4930842b46e9507372f0b1b963James Dong; *
390c1bc742181ded4930842b46e9507372f0b1b963James Dong; * Parameters:
400c1bc742181ded4930842b46e9507372f0b1b963James Dong; * [in]  pSrcDst      pointer to the coefficient buffer which contains the
410c1bc742181ded4930842b46e9507372f0b1b963James Dong; *                    quantized coefficient residuals (PQF) of the current
420c1bc742181ded4930842b46e9507372f0b1b963James Dong; *                    block; must be aligned on a 4-byte boundary. The
430c1bc742181ded4930842b46e9507372f0b1b963James Dong; *                    output coefficients are saturated to the range
440c1bc742181ded4930842b46e9507372f0b1b963James Dong; *                    [-2048, 2047].
450c1bc742181ded4930842b46e9507372f0b1b963James Dong; * [in]  pPredBufRow  pointer to the coefficient row buffer; must be aligned
460c1bc742181ded4930842b46e9507372f0b1b963James Dong; *                    on a 4-byte boundary.
470c1bc742181ded4930842b46e9507372f0b1b963James Dong; * [in]  pPredBufCol  pointer to the coefficient column buffer; must be
480c1bc742181ded4930842b46e9507372f0b1b963James Dong; *                    aligned on a 4-byte boundary.
490c1bc742181ded4930842b46e9507372f0b1b963James Dong; * [in]  curQP        quantization parameter of the current block. curQP may
500c1bc742181ded4930842b46e9507372f0b1b963James Dong; *                    equal to predQP especially when the current block and
510c1bc742181ded4930842b46e9507372f0b1b963James Dong; *                    the predictor block are in the same macroblock.
520c1bc742181ded4930842b46e9507372f0b1b963James Dong; * [in]  predQP       quantization parameter of the predictor block
530c1bc742181ded4930842b46e9507372f0b1b963James Dong; * [in]  predDir      indicates the prediction direction which takes one
540c1bc742181ded4930842b46e9507372f0b1b963James Dong; *                    of the following values:
550c1bc742181ded4930842b46e9507372f0b1b963James Dong; *                    OMX_VIDEO_HORIZONTAL    predict horizontally
560c1bc742181ded4930842b46e9507372f0b1b963James Dong; *                    OMX_VIDEO_VERTICAL        predict vertically
570c1bc742181ded4930842b46e9507372f0b1b963James Dong; * [in]  ACPredFlag   a flag indicating if AC prediction should be
580c1bc742181ded4930842b46e9507372f0b1b963James Dong; *                    performed. It is equal to ac_pred_flag in the bit
590c1bc742181ded4930842b46e9507372f0b1b963James Dong; *                    stream syntax of MPEG-4
600c1bc742181ded4930842b46e9507372f0b1b963James Dong; * [in]  videoComp    video component type (luminance, chrominance or
610c1bc742181ded4930842b46e9507372f0b1b963James Dong; *                    alpha) of the current block
620c1bc742181ded4930842b46e9507372f0b1b963James Dong; * [out] pSrcDst      pointer to the coefficient buffer which contains
630c1bc742181ded4930842b46e9507372f0b1b963James Dong; *                    the quantized coefficients (QF) of the current
640c1bc742181ded4930842b46e9507372f0b1b963James Dong; *                    block
650c1bc742181ded4930842b46e9507372f0b1b963James Dong; * [out] pPredBufRow  pointer to the updated coefficient row buffer
660c1bc742181ded4930842b46e9507372f0b1b963James Dong; * [out] pPredBufCol  pointer to the updated coefficient column buffer
670c1bc742181ded4930842b46e9507372f0b1b963James Dong; * Return Value:
680c1bc742181ded4930842b46e9507372f0b1b963James Dong; * OMX_Sts_NoErr - no error
690c1bc742181ded4930842b46e9507372f0b1b963James Dong; * OMX_Sts_BadArgErr - Bad arguments
700c1bc742181ded4930842b46e9507372f0b1b963James Dong; * - At least one of the pointers is NULL: pSrcDst, pPredBufRow, or pPredBufCol.
710c1bc742181ded4930842b46e9507372f0b1b963James Dong; * - At least one the following cases: curQP <= 0, predQP <= 0, curQP >31,
720c1bc742181ded4930842b46e9507372f0b1b963James Dong; *   predQP > 31, preDir exceeds [1,2].
730c1bc742181ded4930842b46e9507372f0b1b963James Dong; * - At least one of the pointers pSrcDst, pPredBufRow, or pPredBufCol is not
740c1bc742181ded4930842b46e9507372f0b1b963James Dong; *   4-byte aligned.
750c1bc742181ded4930842b46e9507372f0b1b963James Dong; *
760c1bc742181ded4930842b46e9507372f0b1b963James Dong; *********
770c1bc742181ded4930842b46e9507372f0b1b963James Dong
780c1bc742181ded4930842b46e9507372f0b1b963James Dong        INCLUDE omxtypes_s.h
790c1bc742181ded4930842b46e9507372f0b1b963James Dong        INCLUDE armCOMM_s.h
800c1bc742181ded4930842b46e9507372f0b1b963James Dong
810c1bc742181ded4930842b46e9507372f0b1b963James Dong       M_VARIANTS ARM1136JS
820c1bc742181ded4930842b46e9507372f0b1b963James Dong
830c1bc742181ded4930842b46e9507372f0b1b963James Dong
840c1bc742181ded4930842b46e9507372f0b1b963James Dong
850c1bc742181ded4930842b46e9507372f0b1b963James Dong       IMPORT        armVCM4P2_Reciprocal_QP_S32
860c1bc742181ded4930842b46e9507372f0b1b963James Dong       IMPORT        armVCM4P2_Reciprocal_QP_S16
870c1bc742181ded4930842b46e9507372f0b1b963James Dong       IMPORT        armVCM4P2_DCScaler
880c1bc742181ded4930842b46e9507372f0b1b963James Dong
890c1bc742181ded4930842b46e9507372f0b1b963James Dong
900c1bc742181ded4930842b46e9507372f0b1b963James Dong
910c1bc742181ded4930842b46e9507372f0b1b963James Dong        IF ARM1136JS
920c1bc742181ded4930842b46e9507372f0b1b963James Dong
930c1bc742181ded4930842b46e9507372f0b1b963James Dong
940c1bc742181ded4930842b46e9507372f0b1b963James Dong;// Input Arguments
950c1bc742181ded4930842b46e9507372f0b1b963James Dong
960c1bc742181ded4930842b46e9507372f0b1b963James DongpSrcDst          RN 0
970c1bc742181ded4930842b46e9507372f0b1b963James DongpPredBufRow      RN 1
980c1bc742181ded4930842b46e9507372f0b1b963James DongpPredBufCol      RN 2
990c1bc742181ded4930842b46e9507372f0b1b963James DongcurQP            RN 3
1000c1bc742181ded4930842b46e9507372f0b1b963James DongQP               RN 3
1010c1bc742181ded4930842b46e9507372f0b1b963James DongpredQP           RN 4
1020c1bc742181ded4930842b46e9507372f0b1b963James DongpredDir          RN 5
1030c1bc742181ded4930842b46e9507372f0b1b963James DongACPredFlag       RN 6
1040c1bc742181ded4930842b46e9507372f0b1b963James DongvideoComp        RN 7
1050c1bc742181ded4930842b46e9507372f0b1b963James Dong
1060c1bc742181ded4930842b46e9507372f0b1b963James Dong;// Local Variables
1070c1bc742181ded4930842b46e9507372f0b1b963James Dong
1080c1bc742181ded4930842b46e9507372f0b1b963James Dongtemp2            RN 5
1090c1bc742181ded4930842b46e9507372f0b1b963James DongnegCurQP         RN 7
1100c1bc742181ded4930842b46e9507372f0b1b963James DongnegdcScaler      RN 7
1110c1bc742181ded4930842b46e9507372f0b1b963James DongtempPred         RN 8
1120c1bc742181ded4930842b46e9507372f0b1b963James Dong
1130c1bc742181ded4930842b46e9507372f0b1b963James DongdcScaler         RN 4
1140c1bc742181ded4930842b46e9507372f0b1b963James DongCoeffTable       RN 9
1150c1bc742181ded4930842b46e9507372f0b1b963James DongabsCoeffDC       RN 9
1160c1bc742181ded4930842b46e9507372f0b1b963James Dongtemp3            RN 6
1170c1bc742181ded4930842b46e9507372f0b1b963James DongabsCoeffAC       RN 6
1180c1bc742181ded4930842b46e9507372f0b1b963James Dong
1190c1bc742181ded4930842b46e9507372f0b1b963James DongshortVideoHeader RN 9
1200c1bc742181ded4930842b46e9507372f0b1b963James DongpredCoeffTable   RN 10
1210c1bc742181ded4930842b46e9507372f0b1b963James DongCount            RN 10
1220c1bc742181ded4930842b46e9507372f0b1b963James Dongtemp1            RN 12
1230c1bc742181ded4930842b46e9507372f0b1b963James Dongindex            RN 12
1240c1bc742181ded4930842b46e9507372f0b1b963James DongRem              RN 14
1250c1bc742181ded4930842b46e9507372f0b1b963James Dongtemp             RN 11
1260c1bc742181ded4930842b46e9507372f0b1b963James DongReturn           RN 0
1270c1bc742181ded4930842b46e9507372f0b1b963James Dong
1280c1bc742181ded4930842b46e9507372f0b1b963James Dong
1290c1bc742181ded4930842b46e9507372f0b1b963James Dong
1300c1bc742181ded4930842b46e9507372f0b1b963James Dong       M_START   omxVCM4P2_PredictReconCoefIntra,r12
1310c1bc742181ded4930842b46e9507372f0b1b963James Dong
1320c1bc742181ded4930842b46e9507372f0b1b963James Dong       ;// Assigning pointers to Input arguments on Stack
1330c1bc742181ded4930842b46e9507372f0b1b963James Dong
1340c1bc742181ded4930842b46e9507372f0b1b963James Dong       M_ARG           predQPonStack,4
1350c1bc742181ded4930842b46e9507372f0b1b963James Dong       M_ARG           predDironStack,4
1360c1bc742181ded4930842b46e9507372f0b1b963James Dong       M_ARG           ACPredFlagonStack,4
1370c1bc742181ded4930842b46e9507372f0b1b963James Dong       M_ARG           videoComponStack,4
1380c1bc742181ded4930842b46e9507372f0b1b963James Dong
1390c1bc742181ded4930842b46e9507372f0b1b963James Dong       ;// DC Prediction
1400c1bc742181ded4930842b46e9507372f0b1b963James Dong
1410c1bc742181ded4930842b46e9507372f0b1b963James Dong       M_LDR           videoComp,videoComponStack                     ;// Load videoComp From Stack
1420c1bc742181ded4930842b46e9507372f0b1b963James Dong
1430c1bc742181ded4930842b46e9507372f0b1b963James Dong       M_LDR           predDir,predDironStack                         ;// Load Prediction direction
1440c1bc742181ded4930842b46e9507372f0b1b963James Dong
1450c1bc742181ded4930842b46e9507372f0b1b963James Dong       ;// dcScaler Calculation
1460c1bc742181ded4930842b46e9507372f0b1b963James Dong
1470c1bc742181ded4930842b46e9507372f0b1b963James Dong       LDR             index, =armVCM4P2_DCScaler
1480c1bc742181ded4930842b46e9507372f0b1b963James Dong       ADD             index,index,videoComp,LSL #5
1490c1bc742181ded4930842b46e9507372f0b1b963James Dong       LDRB            dcScaler,[index,QP]
1500c1bc742181ded4930842b46e9507372f0b1b963James Dong
1510c1bc742181ded4930842b46e9507372f0b1b963James Dong
1520c1bc742181ded4930842b46e9507372f0b1b963James DongcalDCVal
1530c1bc742181ded4930842b46e9507372f0b1b963James Dong
1540c1bc742181ded4930842b46e9507372f0b1b963James Dong
1550c1bc742181ded4930842b46e9507372f0b1b963James Dong       LDR             predCoeffTable, =armVCM4P2_Reciprocal_QP_S16   ;// Loading the table with entries 32767/(1 to 63)
1560c1bc742181ded4930842b46e9507372f0b1b963James Dong
1570c1bc742181ded4930842b46e9507372f0b1b963James Dong       CMP             predDir,#2                                     ;// Check if the Prediction direction is vertical
1580c1bc742181ded4930842b46e9507372f0b1b963James Dong
1590c1bc742181ded4930842b46e9507372f0b1b963James Dong       ;// Caulucate temp pred by performing Division
1600c1bc742181ded4930842b46e9507372f0b1b963James Dong
1610c1bc742181ded4930842b46e9507372f0b1b963James Dong       LDREQSH         absCoeffDC,[pPredBufRow]                       ;// If vetical load the coeff from Row Prediction Buffer
1620c1bc742181ded4930842b46e9507372f0b1b963James Dong       LDRNESH         absCoeffDC,[pPredBufCol]                       ;// If horizontal load the coeff from column Prediction Buffer
1630c1bc742181ded4930842b46e9507372f0b1b963James Dong
1640c1bc742181ded4930842b46e9507372f0b1b963James Dong       RSB             negdcScaler,dcScaler,#0                        ;// negdcScaler=-dcScaler
1650c1bc742181ded4930842b46e9507372f0b1b963James Dong
1660c1bc742181ded4930842b46e9507372f0b1b963James Dong       MOV             temp1,absCoeffDC                               ;// temp1=prediction coeff
1670c1bc742181ded4930842b46e9507372f0b1b963James Dong       CMP             temp1,#0
1680c1bc742181ded4930842b46e9507372f0b1b963James Dong       RSBLT           absCoeffDC,temp1,#0                            ;//absCoeffDC=abs(temp1)
1690c1bc742181ded4930842b46e9507372f0b1b963James Dong
1700c1bc742181ded4930842b46e9507372f0b1b963James Dong       ADD             temp,dcScaler,dcScaler
1710c1bc742181ded4930842b46e9507372f0b1b963James Dong       LDRH            temp,[predCoeffTable,temp]                     ;// Load value from coeff table for performing division using multiplication
1720c1bc742181ded4930842b46e9507372f0b1b963James Dong
1730c1bc742181ded4930842b46e9507372f0b1b963James Dong       SMULBB          tempPred,temp,absCoeffDC                       ;// tempPred=pPredBufRow(Col)[0]*32767/dcScaler
1740c1bc742181ded4930842b46e9507372f0b1b963James Dong       ADD             temp3,dcScaler,#1
1750c1bc742181ded4930842b46e9507372f0b1b963James Dong       LSR             tempPred,tempPred,#15                          ;// tempPred=pPredBufRow(Col)[0]/dcScaler
1760c1bc742181ded4930842b46e9507372f0b1b963James Dong       LSR             temp3,temp3,#1                                 ;// temp3=round(dcScaler/2)
1770c1bc742181ded4930842b46e9507372f0b1b963James Dong
1780c1bc742181ded4930842b46e9507372f0b1b963James Dong       MLA             Rem,negdcScaler,tempPred,absCoeffDC            ;// Rem = pPredBufRow(Col)[0]-tempPred*dcScaler
1790c1bc742181ded4930842b46e9507372f0b1b963James Dong
1800c1bc742181ded4930842b46e9507372f0b1b963James Dong
1810c1bc742181ded4930842b46e9507372f0b1b963James Dong       LDRH            temp,[pPredBufCol]
1820c1bc742181ded4930842b46e9507372f0b1b963James Dong       CMP             Rem,temp3
1830c1bc742181ded4930842b46e9507372f0b1b963James Dong       ADDGE           tempPred,#1                                    ;// If Rem>=round(dcScaler/2);tempPred=tempPred+1
1840c1bc742181ded4930842b46e9507372f0b1b963James Dong       CMP             temp1,#0
1850c1bc742181ded4930842b46e9507372f0b1b963James Dong       RSBLT           tempPred,tempPred,#0                            ;/ if pPredBufRow(Col)[0]<0; tempPred=-tempPred
1860c1bc742181ded4930842b46e9507372f0b1b963James Dong
1870c1bc742181ded4930842b46e9507372f0b1b963James Dong
1880c1bc742181ded4930842b46e9507372f0b1b963James Dong       STRH            temp,[pPredBufRow,#-16]
1890c1bc742181ded4930842b46e9507372f0b1b963James Dong
1900c1bc742181ded4930842b46e9507372f0b1b963James Dong       LDRH            temp,[pSrcDst]                                 ;// temp=pSrcDst[0]
1910c1bc742181ded4930842b46e9507372f0b1b963James Dong       M_LDR           ACPredFlag,ACPredFlagonStack
1920c1bc742181ded4930842b46e9507372f0b1b963James Dong       ADD             temp,temp,tempPred                             ;// temp=pSrcDst[0]+tempPred
1930c1bc742181ded4930842b46e9507372f0b1b963James Dong       SSAT16          temp,#12,temp                                  ;// clip temp to [-2048,2047]
1940c1bc742181ded4930842b46e9507372f0b1b963James Dong
1950c1bc742181ded4930842b46e9507372f0b1b963James Dong       SMULBB          temp1,temp,dcScaler                            ;// temp1=clipped(pSrcDst[0])*dcScaler
1960c1bc742181ded4930842b46e9507372f0b1b963James Dong       M_LDR           predQP,predQPonStack
1970c1bc742181ded4930842b46e9507372f0b1b963James Dong       STRH            temp,[pSrcDst]
1980c1bc742181ded4930842b46e9507372f0b1b963James Dong       CMP             ACPredFlag,#1                                  ;// Check if the AC prediction flag is set or not
1990c1bc742181ded4930842b46e9507372f0b1b963James Dong       STRH            temp1,[pPredBufCol]                            ;// store temp1 to pPredBufCol
2000c1bc742181ded4930842b46e9507372f0b1b963James Dong
2010c1bc742181ded4930842b46e9507372f0b1b963James Dong       ;// AC Prediction
2020c1bc742181ded4930842b46e9507372f0b1b963James Dong
2030c1bc742181ded4930842b46e9507372f0b1b963James Dong
2040c1bc742181ded4930842b46e9507372f0b1b963James Dong       BNE             Exit                                           ;// If not set Exit
2050c1bc742181ded4930842b46e9507372f0b1b963James Dong
2060c1bc742181ded4930842b46e9507372f0b1b963James Dong       LDR             predCoeffTable, =armVCM4P2_Reciprocal_QP_S32   ;// Loading the table with entries 0x1ffff/(1 to 63)
2070c1bc742181ded4930842b46e9507372f0b1b963James Dong       MOV             temp1,#4
2080c1bc742181ded4930842b46e9507372f0b1b963James Dong       MUL             temp1,curQP,temp1
2090c1bc742181ded4930842b46e9507372f0b1b963James Dong       CMP             predDir,#2                                     ;// Check the Prediction direction
2100c1bc742181ded4930842b46e9507372f0b1b963James Dong       RSB             negCurQP,curQP,#0
2110c1bc742181ded4930842b46e9507372f0b1b963James Dong       LDR             CoeffTable,[predCoeffTable,temp1]              ;// CoeffTable=0x1ffff/curQP
2120c1bc742181ded4930842b46e9507372f0b1b963James Dong       ADD             curQP,curQP,#1                                 ;// curQP=curQP+1
2130c1bc742181ded4930842b46e9507372f0b1b963James Dong       LSR             curQP,curQP,#1                                 ;// curQP=round(curQP/2)
2140c1bc742181ded4930842b46e9507372f0b1b963James Dong       MOV             Count,#2                                       ;// Initializing the Loop Count
2150c1bc742181ded4930842b46e9507372f0b1b963James Dong       BNE             Horizontal                                     ;// If the Prediction direction is horizontal branch to Horizontal
2160c1bc742181ded4930842b46e9507372f0b1b963James Dong
2170c1bc742181ded4930842b46e9507372f0b1b963James Dong
2180c1bc742181ded4930842b46e9507372f0b1b963James Dong
2190c1bc742181ded4930842b46e9507372f0b1b963James Dongloop1
2200c1bc742181ded4930842b46e9507372f0b1b963James Dong       ;// Calculate tempPred
2210c1bc742181ded4930842b46e9507372f0b1b963James Dong
2220c1bc742181ded4930842b46e9507372f0b1b963James Dong       LDRSH           absCoeffAC,[pPredBufRow,Count]                 ;// absCoeffAC=pPredBufRow[i], 1=<i<=7
2230c1bc742181ded4930842b46e9507372f0b1b963James Dong       MOV             temp1,absCoeffAC
2240c1bc742181ded4930842b46e9507372f0b1b963James Dong       CMP             temp1,#0                                       ;// compare pPredBufRow[i] with zero, 1=<i<=7
2250c1bc742181ded4930842b46e9507372f0b1b963James Dong       RSBLT           absCoeffAC,temp1,#0                            ;// absCoeffAC= abs(pPredBufRow[i])
2260c1bc742181ded4930842b46e9507372f0b1b963James Dong
2270c1bc742181ded4930842b46e9507372f0b1b963James Dong       SMULBB          absCoeffAC,absCoeffAC,predQP                   ;// temp1=pPredBufRow[i]*predQP
2280c1bc742181ded4930842b46e9507372f0b1b963James Dong       MUL             tempPred,absCoeffAC,CoeffTable                 ;// tempPred=pPredBufRow[i]*predQP*0x1ffff/curQP
2290c1bc742181ded4930842b46e9507372f0b1b963James Dong       LSR             tempPred,tempPred,#17
2300c1bc742181ded4930842b46e9507372f0b1b963James Dong
2310c1bc742181ded4930842b46e9507372f0b1b963James Dong       MLA             Rem,negCurQP,tempPred,absCoeffAC               ;// Rem=abs(pPredBufRow[i])-tempPred*curQP
2320c1bc742181ded4930842b46e9507372f0b1b963James Dong       LDRH            temp,[pSrcDst,Count]                           ;// temp=pSrcDst[i],1<=i<8
2330c1bc742181ded4930842b46e9507372f0b1b963James Dong
2340c1bc742181ded4930842b46e9507372f0b1b963James Dong       CMP             Rem,curQP
2350c1bc742181ded4930842b46e9507372f0b1b963James Dong       ADDGE           tempPred,#1                                    ;// if Rem>=round(curQP/2); tempPred=tempPred+1
2360c1bc742181ded4930842b46e9507372f0b1b963James Dong       CMP             temp1,#0
2370c1bc742181ded4930842b46e9507372f0b1b963James Dong       RSBLT           tempPred,tempPred,#0                           ;// if pPredBufRow[i]<0 ; tempPred=-tempPred
2380c1bc742181ded4930842b46e9507372f0b1b963James Dong
2390c1bc742181ded4930842b46e9507372f0b1b963James Dong       ;// Update source and Row Prediction buffers
2400c1bc742181ded4930842b46e9507372f0b1b963James Dong
2410c1bc742181ded4930842b46e9507372f0b1b963James Dong       ADD             temp,temp,tempPred                             ;// temp=tempPred+pSrcDst[i]
2420c1bc742181ded4930842b46e9507372f0b1b963James Dong       SSAT16          temp,#12,temp                                  ;// Clip temp to [-2048,2047]
2430c1bc742181ded4930842b46e9507372f0b1b963James Dong       STRH            temp,[pSrcDst,Count]
2440c1bc742181ded4930842b46e9507372f0b1b963James Dong       STRH            temp,[pPredBufRow,Count]                       ;// pPredBufRow[i]=temp
2450c1bc742181ded4930842b46e9507372f0b1b963James Dong       ADD             Count,Count,#2                                 ;// i=i+1
2460c1bc742181ded4930842b46e9507372f0b1b963James Dong       CMP             Count,#16                                      ;// compare if i=8
2470c1bc742181ded4930842b46e9507372f0b1b963James Dong       BLT             loop1
2480c1bc742181ded4930842b46e9507372f0b1b963James Dong       B               Exit                                           ;// Branch to exit
2490c1bc742181ded4930842b46e9507372f0b1b963James Dong
2500c1bc742181ded4930842b46e9507372f0b1b963James DongHorizontal
2510c1bc742181ded4930842b46e9507372f0b1b963James Dong
2520c1bc742181ded4930842b46e9507372f0b1b963James Dong       MOV             Count,#16                                      ;// Initializing i=8
2530c1bc742181ded4930842b46e9507372f0b1b963James Dong
2540c1bc742181ded4930842b46e9507372f0b1b963James Dongloop2
2550c1bc742181ded4930842b46e9507372f0b1b963James Dong
2560c1bc742181ded4930842b46e9507372f0b1b963James Dong       LSR             temp2,Count,#3                                 ;// temp2=i>>3
2570c1bc742181ded4930842b46e9507372f0b1b963James Dong
2580c1bc742181ded4930842b46e9507372f0b1b963James Dong       ;// Calculate tempPred
2590c1bc742181ded4930842b46e9507372f0b1b963James Dong
2600c1bc742181ded4930842b46e9507372f0b1b963James Dong       LDRH            absCoeffAC,[pPredBufCol,temp2]                 ;// absCoefAC=pPredBufCol[i>>3]
2610c1bc742181ded4930842b46e9507372f0b1b963James Dong       MOV             temp1,absCoeffAC
2620c1bc742181ded4930842b46e9507372f0b1b963James Dong       CMP             temp1,#0                                       ;// compare pPredBufRow[i] with zero, 1=<i<=7
2630c1bc742181ded4930842b46e9507372f0b1b963James Dong       RSBLT           absCoeffAC,temp1,#0                            ;// absCoeffAC=abs(pPredBufCol[i>>3])
2640c1bc742181ded4930842b46e9507372f0b1b963James Dong
2650c1bc742181ded4930842b46e9507372f0b1b963James Dong       SMULBB          absCoeffAC,absCoeffAC,predQP                   ;// temp1=pPredBufCol[i>>3]*predQP
2660c1bc742181ded4930842b46e9507372f0b1b963James Dong       MUL             tempPred,absCoeffAC,CoeffTable                 ;// tempPred=pPredBufCol[i>>3]*predQP*0x1ffff/curQP
2670c1bc742181ded4930842b46e9507372f0b1b963James Dong       LSR             tempPred,tempPred,#17                          ;// tempPred=pPredBufCol[i>>3]*predQP/curQP
2680c1bc742181ded4930842b46e9507372f0b1b963James Dong
2690c1bc742181ded4930842b46e9507372f0b1b963James Dong       MLA             Rem,negCurQP,tempPred,absCoeffAC
2700c1bc742181ded4930842b46e9507372f0b1b963James Dong       LDRH            temp,[pSrcDst,Count]                           ;// temp=pSrcDst[i]
2710c1bc742181ded4930842b46e9507372f0b1b963James Dong
2720c1bc742181ded4930842b46e9507372f0b1b963James Dong       CMP             Rem,curQP                                      ;// Compare Rem with round(curQP/2)
2730c1bc742181ded4930842b46e9507372f0b1b963James Dong       ADDGE           tempPred,#1                                    ;// tempPred=tempPred+1 if Rem>=round(curQP/2)
2740c1bc742181ded4930842b46e9507372f0b1b963James Dong       CMP             temp1,#0
2750c1bc742181ded4930842b46e9507372f0b1b963James Dong       RSBLT           tempPred,tempPred,#0                           ;// if pPredBufCol[i>>3 <0 tempPred=-tempPred
2760c1bc742181ded4930842b46e9507372f0b1b963James Dong
2770c1bc742181ded4930842b46e9507372f0b1b963James Dong       ;// Update source and Row Prediction buffers
2780c1bc742181ded4930842b46e9507372f0b1b963James Dong
2790c1bc742181ded4930842b46e9507372f0b1b963James Dong       ADD             temp,temp,tempPred                             ;// temp=pSrcDst[i]+tempPred
2800c1bc742181ded4930842b46e9507372f0b1b963James Dong       SSAT16          temp,#12,temp                                  ;// Clip temp to [-2048,2047]
2810c1bc742181ded4930842b46e9507372f0b1b963James Dong       STRH            temp,[pSrcDst,Count]                           ;// pSrcDst[0]= clipped value
2820c1bc742181ded4930842b46e9507372f0b1b963James Dong       STRH            temp,[pPredBufCol,temp2]                       ;// pPredBufCol[i>>3]=temp
2830c1bc742181ded4930842b46e9507372f0b1b963James Dong       ADD             Count,Count,#16                                ;// i=i+8
2840c1bc742181ded4930842b46e9507372f0b1b963James Dong       CMP             Count,#128                                     ;// compare i with 64
2850c1bc742181ded4930842b46e9507372f0b1b963James Dong       BLT             loop2
2860c1bc742181ded4930842b46e9507372f0b1b963James Dong
2870c1bc742181ded4930842b46e9507372f0b1b963James Dong
2880c1bc742181ded4930842b46e9507372f0b1b963James DongExit
2890c1bc742181ded4930842b46e9507372f0b1b963James Dong
2900c1bc742181ded4930842b46e9507372f0b1b963James Dong       MOV             Return,#OMX_Sts_NoErr
2910c1bc742181ded4930842b46e9507372f0b1b963James Dong
2920c1bc742181ded4930842b46e9507372f0b1b963James Dong       M_END
2930c1bc742181ded4930842b46e9507372f0b1b963James Dong       ENDIF
2940c1bc742181ded4930842b46e9507372f0b1b963James Dong       END
2950c1bc742181ded4930842b46e9507372f0b1b963James Dong
2960c1bc742181ded4930842b46e9507372f0b1b963James Dong
2970c1bc742181ded4930842b46e9507372f0b1b963James Dong
298