10c1bc742181ded4930842b46e9507372f0b1b963James Dong;//
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;//
1678e52bfac041d71ce53b5b13c2abf78af742b09dLajos Molnar;//
170c1bc742181ded4930842b46e9507372f0b1b963James Dong;//
180c1bc742181ded4930842b46e9507372f0b1b963James Dong;// File Name:  armVCM4P10_UnpackBlock4x4_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
270c1bc742181ded4930842b46e9507372f0b1b963James Dong
280c1bc742181ded4930842b46e9507372f0b1b963James Dong        INCLUDE omxtypes_s.h
290c1bc742181ded4930842b46e9507372f0b1b963James Dong        INCLUDE armCOMM_s.h
300c1bc742181ded4930842b46e9507372f0b1b963James Dong
310c1bc742181ded4930842b46e9507372f0b1b963James Dong;// Define the processor variants supported by this file
320c1bc742181ded4930842b46e9507372f0b1b963James Dong
330c1bc742181ded4930842b46e9507372f0b1b963James Dong        M_VARIANTS ARM1136JS
340c1bc742181ded4930842b46e9507372f0b1b963James Dong
350c1bc742181ded4930842b46e9507372f0b1b963James Dong
360c1bc742181ded4930842b46e9507372f0b1b963James Dong        IF ARM1136JS
370c1bc742181ded4930842b46e9507372f0b1b963James Dong
380c1bc742181ded4930842b46e9507372f0b1b963James Dong;//--------------------------------------
390c1bc742181ded4930842b46e9507372f0b1b963James Dong;// Input Arguments and their scope/usage
400c1bc742181ded4930842b46e9507372f0b1b963James Dong;//--------------------------------------
410c1bc742181ded4930842b46e9507372f0b1b963James DongppSrc           RN 0    ;// Persistent variable
420c1bc742181ded4930842b46e9507372f0b1b963James DongpDst            RN 1    ;// Persistent variable
430c1bc742181ded4930842b46e9507372f0b1b963James Dong
440c1bc742181ded4930842b46e9507372f0b1b963James Dong;//--------------------------------
450c1bc742181ded4930842b46e9507372f0b1b963James Dong;// Variables and their scope/usage
460c1bc742181ded4930842b46e9507372f0b1b963James Dong;//--------------------------------
470c1bc742181ded4930842b46e9507372f0b1b963James DongpSrc            RN 2    ;// Persistent variables
480c1bc742181ded4930842b46e9507372f0b1b963James DongFlag            RN 3
490c1bc742181ded4930842b46e9507372f0b1b963James DongValue           RN 4
500c1bc742181ded4930842b46e9507372f0b1b963James DongValue2          RN 5
510c1bc742181ded4930842b46e9507372f0b1b963James DongstrOffset       RN 6
520c1bc742181ded4930842b46e9507372f0b1b963James DongcstOffset       RN 7
530c1bc742181ded4930842b46e9507372f0b1b963James Dong
540c1bc742181ded4930842b46e9507372f0b1b963James Dong
550c1bc742181ded4930842b46e9507372f0b1b963James Dong        M_START armVCM4P10_UnpackBlock4x4, r7
560c1bc742181ded4930842b46e9507372f0b1b963James Dong
570c1bc742181ded4930842b46e9507372f0b1b963James Dong        LDR     pSrc, [ppSrc]                       ;// Load pSrc
580c1bc742181ded4930842b46e9507372f0b1b963James Dong        MOV     cstOffset, #31                      ;// To be used in the loop, to compute offset
590c1bc742181ded4930842b46e9507372f0b1b963James Dong
600c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;//-----------------------------------------------------------------------
610c1bc742181ded4930842b46e9507372f0b1b963James Dong        ; Firstly, fill all the coefficient values on the <pDst> buffer by zero
620c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;//-----------------------------------------------------------------------
630c1bc742181ded4930842b46e9507372f0b1b963James Dong
640c1bc742181ded4930842b46e9507372f0b1b963James Dong        MOV      Value,  #0                         ;// Initialize the zero value
650c1bc742181ded4930842b46e9507372f0b1b963James Dong        MOV      Value2, #0                         ;// Initialize the zero value
660c1bc742181ded4930842b46e9507372f0b1b963James Dong        LDRB     Flag,  [pSrc], #1                  ;// Preload <Flag> before <unpackLoop>
670c1bc742181ded4930842b46e9507372f0b1b963James Dong
680c1bc742181ded4930842b46e9507372f0b1b963James Dong        STRD     Value, [pDst, #0]                  ;// pDst[0]  = pDst[1]  = pDst[2]  = pDst[3]  = 0
690c1bc742181ded4930842b46e9507372f0b1b963James Dong        STRD     Value, [pDst, #8]                  ;// pDst[4]  = pDst[5]  = pDst[6]  = pDst[7]  = 0
700c1bc742181ded4930842b46e9507372f0b1b963James Dong        STRD     Value, [pDst, #16]                 ;// pDst[8]  = pDst[9]  = pDst[10] = pDst[11] = 0
710c1bc742181ded4930842b46e9507372f0b1b963James Dong        STRD     Value, [pDst, #24]                 ;// pDst[12] = pDst[13] = pDst[14] = pDst[15] = 0
720c1bc742181ded4930842b46e9507372f0b1b963James Dong
730c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;//----------------------------------------------------------------------------
740c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// The loop below parses and unpacks the input stream. The C-model has
750c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// a somewhat complicated logic for sign extension.  But in the v6 version,
760c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// that can be easily taken care by loading the data from <pSrc> stream as
770c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// SIGNED byte/halfword. So, based on the first TST instruction, 8-bits or
780c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// 16-bits are read.
790c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;//
800c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// Next, to compute the offset, where the unpacked value needs to be stored,
810c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// we modify the computation to perform [(Flag & 15) < 1] as [(Flag < 1) & 31]
820c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// This results in a saving of one cycle.
830c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;//----------------------------------------------------------------------------
840c1bc742181ded4930842b46e9507372f0b1b963James Dong
850c1bc742181ded4930842b46e9507372f0b1b963James DongunpackLoop
860c1bc742181ded4930842b46e9507372f0b1b963James Dong        TST      Flag,  #0x10                        ;// Computing (Flag & 0x10)
870c1bc742181ded4930842b46e9507372f0b1b963James Dong        LDRSBNE  Value2,[pSrc,#1]                    ;// Load byte wise to avoid unaligned access
880c1bc742181ded4930842b46e9507372f0b1b963James Dong        LDRBNE   Value, [pSrc], #2
890c1bc742181ded4930842b46e9507372f0b1b963James Dong        AND      strOffset, cstOffset, Flag, LSL #1  ;// strOffset = (Flag & 15) < 1;
900c1bc742181ded4930842b46e9507372f0b1b963James Dong        LDRSBEQ  Value, [pSrc], #1                   ;// Value = (OMX_U8)  *pSrc++
910c1bc742181ded4930842b46e9507372f0b1b963James Dong        ORRNE    Value,Value,Value2, LSL #8          ;// Value = (OMX_U16) *pSrc++
920c1bc742181ded4930842b46e9507372f0b1b963James Dong
930c1bc742181ded4930842b46e9507372f0b1b963James Dong        TST      Flag,  #0x20                        ;// Computing (Flag & 0x20) to check, if we're done
940c1bc742181ded4930842b46e9507372f0b1b963James Dong        LDRBEQ   Flag,  [pSrc], #1                   ;// Flag  = (OMX_U8) *pSrc++, for next iteration
950c1bc742181ded4930842b46e9507372f0b1b963James Dong        STRH     Value, [pDst, strOffset]            ;// Store <Value> at offset <strOffset>
960c1bc742181ded4930842b46e9507372f0b1b963James Dong        BEQ      unpackLoop                          ;// Branch to the loop beginning
970c1bc742181ded4930842b46e9507372f0b1b963James Dong
980c1bc742181ded4930842b46e9507372f0b1b963James Dong        STR      pSrc, [ppSrc]                       ;// Update the bitstream pointer
990c1bc742181ded4930842b46e9507372f0b1b963James Dong        M_END
1000c1bc742181ded4930842b46e9507372f0b1b963James Dong
1010c1bc742181ded4930842b46e9507372f0b1b963James Dong    ENDIF
1020c1bc742181ded4930842b46e9507372f0b1b963James Dong
1030c1bc742181ded4930842b46e9507372f0b1b963James Dong
1040c1bc742181ded4930842b46e9507372f0b1b963James Dong
1050c1bc742181ded4930842b46e9507372f0b1b963James Dong    END
10678e52bfac041d71ce53b5b13c2abf78af742b09dLajos Molnar
107