1bebc99d6fa433c04139294a5057f8439d772dbd9James Dong; **********
2bebc99d6fa433c04139294a5057f8439d772dbd9James Dong; *
3bebc99d6fa433c04139294a5057f8439d772dbd9James Dong; * File Name:  omxVCM4P2_PredictReconCoefIntra_s.s
4bebc99d6fa433c04139294a5057f8439d772dbd9James Dong; * OpenMAX DL: v1.0.2
5bebc99d6fa433c04139294a5057f8439d772dbd9James Dong; * Revision:   9641
6bebc99d6fa433c04139294a5057f8439d772dbd9James Dong; * Date:       Thursday, February 7, 2008
7bebc99d6fa433c04139294a5057f8439d772dbd9James Dong; *
8bebc99d6fa433c04139294a5057f8439d772dbd9James Dong; * (c) Copyright 2007-2008 ARM Limited. All Rights Reserved.
9bebc99d6fa433c04139294a5057f8439d772dbd9James Dong; *
10bebc99d6fa433c04139294a5057f8439d772dbd9James Dong; *
11bebc99d6fa433c04139294a5057f8439d772dbd9James Dong; *
12bebc99d6fa433c04139294a5057f8439d772dbd9James Dong; * Description:
13bebc99d6fa433c04139294a5057f8439d772dbd9James Dong; * Contains module for DC/AC coefficient prediction
14bebc99d6fa433c04139294a5057f8439d772dbd9James Dong; *
15bebc99d6fa433c04139294a5057f8439d772dbd9James Dong; *
16bebc99d6fa433c04139294a5057f8439d772dbd9James Dong; * Function: omxVCM4P2_PredictReconCoefIntra
17bebc99d6fa433c04139294a5057f8439d772dbd9James Dong; *
18bebc99d6fa433c04139294a5057f8439d772dbd9James Dong; * Description:
19bebc99d6fa433c04139294a5057f8439d772dbd9James Dong; * Performs adaptive DC/AC coefficient prediction for an intra block. Prior
20bebc99d6fa433c04139294a5057f8439d772dbd9James Dong; * to the function call, prediction direction (predDir) should be selected
21bebc99d6fa433c04139294a5057f8439d772dbd9James Dong; * as specified in subclause 7.4.3.1 of ISO/IEC 14496-2.
22bebc99d6fa433c04139294a5057f8439d772dbd9James Dong; *
23bebc99d6fa433c04139294a5057f8439d772dbd9James Dong; * Remarks:
24bebc99d6fa433c04139294a5057f8439d772dbd9James Dong; *
25bebc99d6fa433c04139294a5057f8439d772dbd9James Dong; * Parameters:
26bebc99d6fa433c04139294a5057f8439d772dbd9James Dong; * [in]  pSrcDst      pointer to the coefficient buffer which contains the
27bebc99d6fa433c04139294a5057f8439d772dbd9James Dong; *                    quantized coefficient residuals (PQF) of the current
28bebc99d6fa433c04139294a5057f8439d772dbd9James Dong; *                    block; must be aligned on a 4-byte boundary. The
29bebc99d6fa433c04139294a5057f8439d772dbd9James Dong; *                    output coefficients are saturated to the range
30bebc99d6fa433c04139294a5057f8439d772dbd9James Dong; *                    [-2048, 2047].
31bebc99d6fa433c04139294a5057f8439d772dbd9James Dong; * [in]  pPredBufRow  pointer to the coefficient row buffer; must be aligned
32bebc99d6fa433c04139294a5057f8439d772dbd9James Dong; *                    on a 4-byte boundary.
33bebc99d6fa433c04139294a5057f8439d772dbd9James Dong; * [in]  pPredBufCol  pointer to the coefficient column buffer; must be
34bebc99d6fa433c04139294a5057f8439d772dbd9James Dong; *                    aligned on a 4-byte boundary.
35bebc99d6fa433c04139294a5057f8439d772dbd9James Dong; * [in]  curQP        quantization parameter of the current block. curQP may
36bebc99d6fa433c04139294a5057f8439d772dbd9James Dong; *                    equal to predQP especially when the current block and
37bebc99d6fa433c04139294a5057f8439d772dbd9James Dong; *                    the predictor block are in the same macroblock.
38bebc99d6fa433c04139294a5057f8439d772dbd9James Dong; * [in]  predQP       quantization parameter of the predictor block
39bebc99d6fa433c04139294a5057f8439d772dbd9James Dong; * [in]  predDir      indicates the prediction direction which takes one
40bebc99d6fa433c04139294a5057f8439d772dbd9James Dong; *                    of the following values:
41bebc99d6fa433c04139294a5057f8439d772dbd9James Dong; *                    OMX_VIDEO_HORIZONTAL    predict horizontally
42bebc99d6fa433c04139294a5057f8439d772dbd9James Dong; *                    OMX_VIDEO_VERTICAL        predict vertically
43bebc99d6fa433c04139294a5057f8439d772dbd9James Dong; * [in]  ACPredFlag   a flag indicating if AC prediction should be
44bebc99d6fa433c04139294a5057f8439d772dbd9James Dong; *                    performed. It is equal to ac_pred_flag in the bit
45bebc99d6fa433c04139294a5057f8439d772dbd9James Dong; *                    stream syntax of MPEG-4
46bebc99d6fa433c04139294a5057f8439d772dbd9James Dong; * [in]  videoComp    video component type (luminance, chrominance or
47bebc99d6fa433c04139294a5057f8439d772dbd9James Dong; *                    alpha) of the current block
48bebc99d6fa433c04139294a5057f8439d772dbd9James Dong; * [out] pSrcDst      pointer to the coefficient buffer which contains
49bebc99d6fa433c04139294a5057f8439d772dbd9James Dong; *                    the quantized coefficients (QF) of the current
50bebc99d6fa433c04139294a5057f8439d772dbd9James Dong; *                    block
51bebc99d6fa433c04139294a5057f8439d772dbd9James Dong; * [out] pPredBufRow  pointer to the updated coefficient row buffer
52bebc99d6fa433c04139294a5057f8439d772dbd9James Dong; * [out] pPredBufCol  pointer to the updated coefficient column buffer
53bebc99d6fa433c04139294a5057f8439d772dbd9James Dong; * Return Value:
54bebc99d6fa433c04139294a5057f8439d772dbd9James Dong; * OMX_Sts_NoErr - no error
55bebc99d6fa433c04139294a5057f8439d772dbd9James Dong; * OMX_Sts_BadArgErr - Bad arguments
56bebc99d6fa433c04139294a5057f8439d772dbd9James Dong; * - At least one of the pointers is NULL: pSrcDst, pPredBufRow, or pPredBufCol.
57bebc99d6fa433c04139294a5057f8439d772dbd9James Dong; * - At least one the following cases: curQP <= 0, predQP <= 0, curQP >31,
58bebc99d6fa433c04139294a5057f8439d772dbd9James Dong; *   predQP > 31, preDir exceeds [1,2].
59bebc99d6fa433c04139294a5057f8439d772dbd9James Dong; * - At least one of the pointers pSrcDst, pPredBufRow, or pPredBufCol is not
60bebc99d6fa433c04139294a5057f8439d772dbd9James Dong; *   4-byte aligned.
61bebc99d6fa433c04139294a5057f8439d772dbd9James Dong; *
62bebc99d6fa433c04139294a5057f8439d772dbd9James Dong; *********
63bebc99d6fa433c04139294a5057f8439d772dbd9James Dong
64bebc99d6fa433c04139294a5057f8439d772dbd9James Dong        INCLUDE omxtypes_s.h
65bebc99d6fa433c04139294a5057f8439d772dbd9James Dong        INCLUDE armCOMM_s.h
66bebc99d6fa433c04139294a5057f8439d772dbd9James Dong
67bebc99d6fa433c04139294a5057f8439d772dbd9James Dong       M_VARIANTS ARM1136JS
68bebc99d6fa433c04139294a5057f8439d772dbd9James Dong
69bebc99d6fa433c04139294a5057f8439d772dbd9James Dong
70bebc99d6fa433c04139294a5057f8439d772dbd9James Dong
71bebc99d6fa433c04139294a5057f8439d772dbd9James Dong       IMPORT        armVCM4P2_Reciprocal_QP_S32
72bebc99d6fa433c04139294a5057f8439d772dbd9James Dong       IMPORT        armVCM4P2_Reciprocal_QP_S16
73bebc99d6fa433c04139294a5057f8439d772dbd9James Dong       IMPORT        armVCM4P2_DCScaler
74bebc99d6fa433c04139294a5057f8439d772dbd9James Dong
75bebc99d6fa433c04139294a5057f8439d772dbd9James Dong
76bebc99d6fa433c04139294a5057f8439d772dbd9James Dong
77bebc99d6fa433c04139294a5057f8439d772dbd9James Dong        IF ARM1136JS
78bebc99d6fa433c04139294a5057f8439d772dbd9James Dong
79bebc99d6fa433c04139294a5057f8439d772dbd9James Dong
80bebc99d6fa433c04139294a5057f8439d772dbd9James Dong;// Input Arguments
81bebc99d6fa433c04139294a5057f8439d772dbd9James Dong
82bebc99d6fa433c04139294a5057f8439d772dbd9James DongpSrcDst          RN 0
83bebc99d6fa433c04139294a5057f8439d772dbd9James DongpPredBufRow      RN 1
84bebc99d6fa433c04139294a5057f8439d772dbd9James DongpPredBufCol      RN 2
85bebc99d6fa433c04139294a5057f8439d772dbd9James DongcurQP            RN 3
86bebc99d6fa433c04139294a5057f8439d772dbd9James DongQP               RN 3
87bebc99d6fa433c04139294a5057f8439d772dbd9James DongpredQP           RN 4
88bebc99d6fa433c04139294a5057f8439d772dbd9James DongpredDir          RN 5
89bebc99d6fa433c04139294a5057f8439d772dbd9James DongACPredFlag       RN 6
90bebc99d6fa433c04139294a5057f8439d772dbd9James DongvideoComp        RN 7
91bebc99d6fa433c04139294a5057f8439d772dbd9James Dong
92bebc99d6fa433c04139294a5057f8439d772dbd9James Dong;// Local Variables
93bebc99d6fa433c04139294a5057f8439d772dbd9James Dong
94bebc99d6fa433c04139294a5057f8439d772dbd9James Dongtemp2            RN 5
95bebc99d6fa433c04139294a5057f8439d772dbd9James DongnegCurQP         RN 7
96bebc99d6fa433c04139294a5057f8439d772dbd9James DongnegdcScaler      RN 7
97bebc99d6fa433c04139294a5057f8439d772dbd9James DongtempPred         RN 8
98bebc99d6fa433c04139294a5057f8439d772dbd9James Dong
99bebc99d6fa433c04139294a5057f8439d772dbd9James DongdcScaler         RN 4
100bebc99d6fa433c04139294a5057f8439d772dbd9James DongCoeffTable       RN 9
101bebc99d6fa433c04139294a5057f8439d772dbd9James DongabsCoeffDC       RN 9
102bebc99d6fa433c04139294a5057f8439d772dbd9James Dongtemp3            RN 6
103bebc99d6fa433c04139294a5057f8439d772dbd9James DongabsCoeffAC       RN 6
104bebc99d6fa433c04139294a5057f8439d772dbd9James Dong
105bebc99d6fa433c04139294a5057f8439d772dbd9James DongshortVideoHeader RN 9
106bebc99d6fa433c04139294a5057f8439d772dbd9James DongpredCoeffTable   RN 10
107bebc99d6fa433c04139294a5057f8439d772dbd9James DongCount            RN 10
108bebc99d6fa433c04139294a5057f8439d772dbd9James Dongtemp1            RN 12
109bebc99d6fa433c04139294a5057f8439d772dbd9James Dongindex            RN 12
110bebc99d6fa433c04139294a5057f8439d772dbd9James DongRem              RN 14
111bebc99d6fa433c04139294a5057f8439d772dbd9James Dongtemp             RN 11
112bebc99d6fa433c04139294a5057f8439d772dbd9James DongReturn           RN 0
113bebc99d6fa433c04139294a5057f8439d772dbd9James Dong
114bebc99d6fa433c04139294a5057f8439d772dbd9James Dong
115bebc99d6fa433c04139294a5057f8439d772dbd9James Dong
116bebc99d6fa433c04139294a5057f8439d772dbd9James Dong       M_START   omxVCM4P2_PredictReconCoefIntra,r12
117bebc99d6fa433c04139294a5057f8439d772dbd9James Dong
118bebc99d6fa433c04139294a5057f8439d772dbd9James Dong       ;// Assigning pointers to Input arguments on Stack
119bebc99d6fa433c04139294a5057f8439d772dbd9James Dong
120bebc99d6fa433c04139294a5057f8439d772dbd9James Dong       M_ARG           predQPonStack,4
121bebc99d6fa433c04139294a5057f8439d772dbd9James Dong       M_ARG           predDironStack,4
122bebc99d6fa433c04139294a5057f8439d772dbd9James Dong       M_ARG           ACPredFlagonStack,4
123bebc99d6fa433c04139294a5057f8439d772dbd9James Dong       M_ARG           videoComponStack,4
124bebc99d6fa433c04139294a5057f8439d772dbd9James Dong
125bebc99d6fa433c04139294a5057f8439d772dbd9James Dong       ;// DC Prediction
126bebc99d6fa433c04139294a5057f8439d772dbd9James Dong
127bebc99d6fa433c04139294a5057f8439d772dbd9James Dong       M_LDR           videoComp,videoComponStack                     ;// Load videoComp From Stack
128bebc99d6fa433c04139294a5057f8439d772dbd9James Dong
129bebc99d6fa433c04139294a5057f8439d772dbd9James Dong       M_LDR           predDir,predDironStack                         ;// Load Prediction direction
130bebc99d6fa433c04139294a5057f8439d772dbd9James Dong
131bebc99d6fa433c04139294a5057f8439d772dbd9James Dong       ;// dcScaler Calculation
132bebc99d6fa433c04139294a5057f8439d772dbd9James Dong
133bebc99d6fa433c04139294a5057f8439d772dbd9James Dong       LDR             index, =armVCM4P2_DCScaler
134bebc99d6fa433c04139294a5057f8439d772dbd9James Dong       ADD             index,index,videoComp,LSL #5
135bebc99d6fa433c04139294a5057f8439d772dbd9James Dong       LDRB            dcScaler,[index,QP]
136bebc99d6fa433c04139294a5057f8439d772dbd9James Dong
137bebc99d6fa433c04139294a5057f8439d772dbd9James Dong
138bebc99d6fa433c04139294a5057f8439d772dbd9James DongcalDCVal
139bebc99d6fa433c04139294a5057f8439d772dbd9James Dong
140bebc99d6fa433c04139294a5057f8439d772dbd9James Dong
141bebc99d6fa433c04139294a5057f8439d772dbd9James Dong       LDR             predCoeffTable, =armVCM4P2_Reciprocal_QP_S16   ;// Loading the table with entries 32767/(1 to 63)
142bebc99d6fa433c04139294a5057f8439d772dbd9James Dong
143bebc99d6fa433c04139294a5057f8439d772dbd9James Dong       CMP             predDir,#2                                     ;// Check if the Prediction direction is vertical
144bebc99d6fa433c04139294a5057f8439d772dbd9James Dong
145bebc99d6fa433c04139294a5057f8439d772dbd9James Dong       ;// Caulucate temp pred by performing Division
146bebc99d6fa433c04139294a5057f8439d772dbd9James Dong
147bebc99d6fa433c04139294a5057f8439d772dbd9James Dong       LDREQSH         absCoeffDC,[pPredBufRow]                       ;// If vetical load the coeff from Row Prediction Buffer
148bebc99d6fa433c04139294a5057f8439d772dbd9James Dong       LDRNESH         absCoeffDC,[pPredBufCol]                       ;// If horizontal load the coeff from column Prediction Buffer
149bebc99d6fa433c04139294a5057f8439d772dbd9James Dong
150bebc99d6fa433c04139294a5057f8439d772dbd9James Dong       RSB             negdcScaler,dcScaler,#0                        ;// negdcScaler=-dcScaler
151bebc99d6fa433c04139294a5057f8439d772dbd9James Dong
152bebc99d6fa433c04139294a5057f8439d772dbd9James Dong       MOV             temp1,absCoeffDC                               ;// temp1=prediction coeff
153bebc99d6fa433c04139294a5057f8439d772dbd9James Dong       CMP             temp1,#0
154bebc99d6fa433c04139294a5057f8439d772dbd9James Dong       RSBLT           absCoeffDC,temp1,#0                            ;//absCoeffDC=abs(temp1)
155bebc99d6fa433c04139294a5057f8439d772dbd9James Dong
156bebc99d6fa433c04139294a5057f8439d772dbd9James Dong       ADD             temp,dcScaler,dcScaler
157bebc99d6fa433c04139294a5057f8439d772dbd9James Dong       LDRH            temp,[predCoeffTable,temp]                     ;// Load value from coeff table for performing division using multiplication
158bebc99d6fa433c04139294a5057f8439d772dbd9James Dong
159bebc99d6fa433c04139294a5057f8439d772dbd9James Dong       SMULBB          tempPred,temp,absCoeffDC                       ;// tempPred=pPredBufRow(Col)[0]*32767/dcScaler
160bebc99d6fa433c04139294a5057f8439d772dbd9James Dong       ADD             temp3,dcScaler,#1
161bebc99d6fa433c04139294a5057f8439d772dbd9James Dong       LSR             tempPred,tempPred,#15                          ;// tempPred=pPredBufRow(Col)[0]/dcScaler
162bebc99d6fa433c04139294a5057f8439d772dbd9James Dong       LSR             temp3,temp3,#1                                 ;// temp3=round(dcScaler/2)
163bebc99d6fa433c04139294a5057f8439d772dbd9James Dong
164bebc99d6fa433c04139294a5057f8439d772dbd9James Dong       MLA             Rem,negdcScaler,tempPred,absCoeffDC            ;// Rem = pPredBufRow(Col)[0]-tempPred*dcScaler
165bebc99d6fa433c04139294a5057f8439d772dbd9James Dong
166bebc99d6fa433c04139294a5057f8439d772dbd9James Dong
167bebc99d6fa433c04139294a5057f8439d772dbd9James Dong       LDRH            temp,[pPredBufCol]
168bebc99d6fa433c04139294a5057f8439d772dbd9James Dong       CMP             Rem,temp3
169bebc99d6fa433c04139294a5057f8439d772dbd9James Dong       ADDGE           tempPred,#1                                    ;// If Rem>=round(dcScaler/2);tempPred=tempPred+1
170bebc99d6fa433c04139294a5057f8439d772dbd9James Dong       CMP             temp1,#0
171bebc99d6fa433c04139294a5057f8439d772dbd9James Dong       RSBLT           tempPred,tempPred,#0                            ;/ if pPredBufRow(Col)[0]<0; tempPred=-tempPred
172bebc99d6fa433c04139294a5057f8439d772dbd9James Dong
173bebc99d6fa433c04139294a5057f8439d772dbd9James Dong
174bebc99d6fa433c04139294a5057f8439d772dbd9James Dong       STRH            temp,[pPredBufRow,#-16]
175bebc99d6fa433c04139294a5057f8439d772dbd9James Dong
176bebc99d6fa433c04139294a5057f8439d772dbd9James Dong       LDRH            temp,[pSrcDst]                                 ;// temp=pSrcDst[0]
177bebc99d6fa433c04139294a5057f8439d772dbd9James Dong       M_LDR           ACPredFlag,ACPredFlagonStack
178bebc99d6fa433c04139294a5057f8439d772dbd9James Dong       ADD             temp,temp,tempPred                             ;// temp=pSrcDst[0]+tempPred
179bebc99d6fa433c04139294a5057f8439d772dbd9James Dong       SSAT16          temp,#12,temp                                  ;// clip temp to [-2048,2047]
180bebc99d6fa433c04139294a5057f8439d772dbd9James Dong
181bebc99d6fa433c04139294a5057f8439d772dbd9James Dong       SMULBB          temp1,temp,dcScaler                            ;// temp1=clipped(pSrcDst[0])*dcScaler
182bebc99d6fa433c04139294a5057f8439d772dbd9James Dong       M_LDR           predQP,predQPonStack
183bebc99d6fa433c04139294a5057f8439d772dbd9James Dong       STRH            temp,[pSrcDst]
184bebc99d6fa433c04139294a5057f8439d772dbd9James Dong       CMP             ACPredFlag,#1                                  ;// Check if the AC prediction flag is set or not
185bebc99d6fa433c04139294a5057f8439d772dbd9James Dong       STRH            temp1,[pPredBufCol]                            ;// store temp1 to pPredBufCol
186bebc99d6fa433c04139294a5057f8439d772dbd9James Dong
187bebc99d6fa433c04139294a5057f8439d772dbd9James Dong       ;// AC Prediction
188bebc99d6fa433c04139294a5057f8439d772dbd9James Dong
189bebc99d6fa433c04139294a5057f8439d772dbd9James Dong
190bebc99d6fa433c04139294a5057f8439d772dbd9James Dong       BNE             Exit                                           ;// If not set Exit
191bebc99d6fa433c04139294a5057f8439d772dbd9James Dong
192bebc99d6fa433c04139294a5057f8439d772dbd9James Dong       LDR             predCoeffTable, =armVCM4P2_Reciprocal_QP_S32   ;// Loading the table with entries 0x1ffff/(1 to 63)
193bebc99d6fa433c04139294a5057f8439d772dbd9James Dong       MOV             temp1,#4
194bebc99d6fa433c04139294a5057f8439d772dbd9James Dong       MUL             temp1,curQP,temp1
195bebc99d6fa433c04139294a5057f8439d772dbd9James Dong       CMP             predDir,#2                                     ;// Check the Prediction direction
196bebc99d6fa433c04139294a5057f8439d772dbd9James Dong       RSB             negCurQP,curQP,#0
197bebc99d6fa433c04139294a5057f8439d772dbd9James Dong       LDR             CoeffTable,[predCoeffTable,temp1]              ;// CoeffTable=0x1ffff/curQP
198bebc99d6fa433c04139294a5057f8439d772dbd9James Dong       ADD             curQP,curQP,#1                                 ;// curQP=curQP+1
199bebc99d6fa433c04139294a5057f8439d772dbd9James Dong       LSR             curQP,curQP,#1                                 ;// curQP=round(curQP/2)
200bebc99d6fa433c04139294a5057f8439d772dbd9James Dong       MOV             Count,#2                                       ;// Initializing the Loop Count
201bebc99d6fa433c04139294a5057f8439d772dbd9James Dong       BNE             Horizontal                                     ;// If the Prediction direction is horizontal branch to Horizontal
202bebc99d6fa433c04139294a5057f8439d772dbd9James Dong
203bebc99d6fa433c04139294a5057f8439d772dbd9James Dong
204bebc99d6fa433c04139294a5057f8439d772dbd9James Dong
205bebc99d6fa433c04139294a5057f8439d772dbd9James Dongloop1
206bebc99d6fa433c04139294a5057f8439d772dbd9James Dong       ;// Calculate tempPred
207bebc99d6fa433c04139294a5057f8439d772dbd9James Dong
208bebc99d6fa433c04139294a5057f8439d772dbd9James Dong       LDRSH           absCoeffAC,[pPredBufRow,Count]                 ;// absCoeffAC=pPredBufRow[i], 1=<i<=7
209bebc99d6fa433c04139294a5057f8439d772dbd9James Dong       MOV             temp1,absCoeffAC
210bebc99d6fa433c04139294a5057f8439d772dbd9James Dong       CMP             temp1,#0                                       ;// compare pPredBufRow[i] with zero, 1=<i<=7
211bebc99d6fa433c04139294a5057f8439d772dbd9James Dong       RSBLT           absCoeffAC,temp1,#0                            ;// absCoeffAC= abs(pPredBufRow[i])
212bebc99d6fa433c04139294a5057f8439d772dbd9James Dong
213bebc99d6fa433c04139294a5057f8439d772dbd9James Dong       SMULBB          absCoeffAC,absCoeffAC,predQP                   ;// temp1=pPredBufRow[i]*predQP
214bebc99d6fa433c04139294a5057f8439d772dbd9James Dong       MUL             tempPred,absCoeffAC,CoeffTable                 ;// tempPred=pPredBufRow[i]*predQP*0x1ffff/curQP
215bebc99d6fa433c04139294a5057f8439d772dbd9James Dong       LSR             tempPred,tempPred,#17
216bebc99d6fa433c04139294a5057f8439d772dbd9James Dong
217bebc99d6fa433c04139294a5057f8439d772dbd9James Dong       MLA             Rem,negCurQP,tempPred,absCoeffAC               ;// Rem=abs(pPredBufRow[i])-tempPred*curQP
218bebc99d6fa433c04139294a5057f8439d772dbd9James Dong       LDRH            temp,[pSrcDst,Count]                           ;// temp=pSrcDst[i],1<=i<8
219bebc99d6fa433c04139294a5057f8439d772dbd9James Dong
220bebc99d6fa433c04139294a5057f8439d772dbd9James Dong       CMP             Rem,curQP
221bebc99d6fa433c04139294a5057f8439d772dbd9James Dong       ADDGE           tempPred,#1                                    ;// if Rem>=round(curQP/2); tempPred=tempPred+1
222bebc99d6fa433c04139294a5057f8439d772dbd9James Dong       CMP             temp1,#0
223bebc99d6fa433c04139294a5057f8439d772dbd9James Dong       RSBLT           tempPred,tempPred,#0                           ;// if pPredBufRow[i]<0 ; tempPred=-tempPred
224bebc99d6fa433c04139294a5057f8439d772dbd9James Dong
225bebc99d6fa433c04139294a5057f8439d772dbd9James Dong       ;// Update source and Row Prediction buffers
226bebc99d6fa433c04139294a5057f8439d772dbd9James Dong
227bebc99d6fa433c04139294a5057f8439d772dbd9James Dong       ADD             temp,temp,tempPred                             ;// temp=tempPred+pSrcDst[i]
228bebc99d6fa433c04139294a5057f8439d772dbd9James Dong       SSAT16          temp,#12,temp                                  ;// Clip temp to [-2048,2047]
229bebc99d6fa433c04139294a5057f8439d772dbd9James Dong       STRH            temp,[pSrcDst,Count]
230bebc99d6fa433c04139294a5057f8439d772dbd9James Dong       STRH            temp,[pPredBufRow,Count]                       ;// pPredBufRow[i]=temp
231bebc99d6fa433c04139294a5057f8439d772dbd9James Dong       ADD             Count,Count,#2                                 ;// i=i+1
232bebc99d6fa433c04139294a5057f8439d772dbd9James Dong       CMP             Count,#16                                      ;// compare if i=8
233bebc99d6fa433c04139294a5057f8439d772dbd9James Dong       BLT             loop1
234bebc99d6fa433c04139294a5057f8439d772dbd9James Dong       B               Exit                                           ;// Branch to exit
235bebc99d6fa433c04139294a5057f8439d772dbd9James Dong
236bebc99d6fa433c04139294a5057f8439d772dbd9James DongHorizontal
237bebc99d6fa433c04139294a5057f8439d772dbd9James Dong
238bebc99d6fa433c04139294a5057f8439d772dbd9James Dong       MOV             Count,#16                                      ;// Initializing i=8
239bebc99d6fa433c04139294a5057f8439d772dbd9James Dong
240bebc99d6fa433c04139294a5057f8439d772dbd9James Dongloop2
241bebc99d6fa433c04139294a5057f8439d772dbd9James Dong
242bebc99d6fa433c04139294a5057f8439d772dbd9James Dong       LSR             temp2,Count,#3                                 ;// temp2=i>>3
243bebc99d6fa433c04139294a5057f8439d772dbd9James Dong
244bebc99d6fa433c04139294a5057f8439d772dbd9James Dong       ;// Calculate tempPred
245bebc99d6fa433c04139294a5057f8439d772dbd9James Dong
246bebc99d6fa433c04139294a5057f8439d772dbd9James Dong       LDRH            absCoeffAC,[pPredBufCol,temp2]                 ;// absCoefAC=pPredBufCol[i>>3]
247bebc99d6fa433c04139294a5057f8439d772dbd9James Dong       MOV             temp1,absCoeffAC
248bebc99d6fa433c04139294a5057f8439d772dbd9James Dong       CMP             temp1,#0                                       ;// compare pPredBufRow[i] with zero, 1=<i<=7
249bebc99d6fa433c04139294a5057f8439d772dbd9James Dong       RSBLT           absCoeffAC,temp1,#0                            ;// absCoeffAC=abs(pPredBufCol[i>>3])
250bebc99d6fa433c04139294a5057f8439d772dbd9James Dong
251bebc99d6fa433c04139294a5057f8439d772dbd9James Dong       SMULBB          absCoeffAC,absCoeffAC,predQP                   ;// temp1=pPredBufCol[i>>3]*predQP
252bebc99d6fa433c04139294a5057f8439d772dbd9James Dong       MUL             tempPred,absCoeffAC,CoeffTable                 ;// tempPred=pPredBufCol[i>>3]*predQP*0x1ffff/curQP
253bebc99d6fa433c04139294a5057f8439d772dbd9James Dong       LSR             tempPred,tempPred,#17                          ;// tempPred=pPredBufCol[i>>3]*predQP/curQP
254bebc99d6fa433c04139294a5057f8439d772dbd9James Dong
255bebc99d6fa433c04139294a5057f8439d772dbd9James Dong       MLA             Rem,negCurQP,tempPred,absCoeffAC
256bebc99d6fa433c04139294a5057f8439d772dbd9James Dong       LDRH            temp,[pSrcDst,Count]                           ;// temp=pSrcDst[i]
257bebc99d6fa433c04139294a5057f8439d772dbd9James Dong
258bebc99d6fa433c04139294a5057f8439d772dbd9James Dong       CMP             Rem,curQP                                      ;// Compare Rem with round(curQP/2)
259bebc99d6fa433c04139294a5057f8439d772dbd9James Dong       ADDGE           tempPred,#1                                    ;// tempPred=tempPred+1 if Rem>=round(curQP/2)
260bebc99d6fa433c04139294a5057f8439d772dbd9James Dong       CMP             temp1,#0
261bebc99d6fa433c04139294a5057f8439d772dbd9James Dong       RSBLT           tempPred,tempPred,#0                           ;// if pPredBufCol[i>>3 <0 tempPred=-tempPred
262bebc99d6fa433c04139294a5057f8439d772dbd9James Dong
263bebc99d6fa433c04139294a5057f8439d772dbd9James Dong       ;// Update source and Row Prediction buffers
264bebc99d6fa433c04139294a5057f8439d772dbd9James Dong
265bebc99d6fa433c04139294a5057f8439d772dbd9James Dong       ADD             temp,temp,tempPred                             ;// temp=pSrcDst[i]+tempPred
266bebc99d6fa433c04139294a5057f8439d772dbd9James Dong       SSAT16          temp,#12,temp                                  ;// Clip temp to [-2048,2047]
267bebc99d6fa433c04139294a5057f8439d772dbd9James Dong       STRH            temp,[pSrcDst,Count]                           ;// pSrcDst[0]= clipped value
268bebc99d6fa433c04139294a5057f8439d772dbd9James Dong       STRH            temp,[pPredBufCol,temp2]                       ;// pPredBufCol[i>>3]=temp
269bebc99d6fa433c04139294a5057f8439d772dbd9James Dong       ADD             Count,Count,#16                                ;// i=i+8
270bebc99d6fa433c04139294a5057f8439d772dbd9James Dong       CMP             Count,#128                                     ;// compare i with 64
271bebc99d6fa433c04139294a5057f8439d772dbd9James Dong       BLT             loop2
272bebc99d6fa433c04139294a5057f8439d772dbd9James Dong
273bebc99d6fa433c04139294a5057f8439d772dbd9James Dong
274bebc99d6fa433c04139294a5057f8439d772dbd9James DongExit
275bebc99d6fa433c04139294a5057f8439d772dbd9James Dong
276bebc99d6fa433c04139294a5057f8439d772dbd9James Dong       MOV             Return,#OMX_Sts_NoErr
277bebc99d6fa433c04139294a5057f8439d772dbd9James Dong
278bebc99d6fa433c04139294a5057f8439d772dbd9James Dong       M_END
279bebc99d6fa433c04139294a5057f8439d772dbd9James Dong       ENDIF
280bebc99d6fa433c04139294a5057f8439d772dbd9James Dong       END
281bebc99d6fa433c04139294a5057f8439d772dbd9James Dong
282bebc99d6fa433c04139294a5057f8439d772dbd9James Dong
283bebc99d6fa433c04139294a5057f8439d772dbd9James Dong
284