10c1bc742181ded4930842b46e9507372f0b1b963James Dong@
20c1bc742181ded4930842b46e9507372f0b1b963James Dong@ Copyright (C) 2009 The Android Open Source Project
30c1bc742181ded4930842b46e9507372f0b1b963James Dong@
40c1bc742181ded4930842b46e9507372f0b1b963James Dong@ Licensed under the Apache License, Version 2.0 (the "License");
50c1bc742181ded4930842b46e9507372f0b1b963James Dong@ you may not use this file except in compliance with the License.
60c1bc742181ded4930842b46e9507372f0b1b963James Dong@ You may obtain a copy of the License at
70c1bc742181ded4930842b46e9507372f0b1b963James Dong@
80c1bc742181ded4930842b46e9507372f0b1b963James Dong@      http://www.apache.org/licenses/LICENSE-2.0
90c1bc742181ded4930842b46e9507372f0b1b963James Dong@
100c1bc742181ded4930842b46e9507372f0b1b963James Dong@ Unless required by applicable law or agreed to in writing, software
110c1bc742181ded4930842b46e9507372f0b1b963James Dong@ distributed under the License is distributed on an "AS IS" BASIS,
120c1bc742181ded4930842b46e9507372f0b1b963James Dong@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
130c1bc742181ded4930842b46e9507372f0b1b963James Dong@ See the License for the specific language governing permissions and
140c1bc742181ded4930842b46e9507372f0b1b963James Dong@ limitations under the License.
150c1bc742181ded4930842b46e9507372f0b1b963James Dong@
160c1bc742181ded4930842b46e9507372f0b1b963James Dong
170c1bc742181ded4930842b46e9507372f0b1b963James Dong#include "asm_common.S"
180c1bc742181ded4930842b46e9507372f0b1b963James Dong
190c1bc742181ded4930842b46e9507372f0b1b963James Dong    preserve8
200c1bc742181ded4930842b46e9507372f0b1b963James Dong
210c1bc742181ded4930842b46e9507372f0b1b963James Dong    .arm
220c1bc742181ded4930842b46e9507372f0b1b963James Dong    .text
230c1bc742181ded4930842b46e9507372f0b1b963James Dong
240c1bc742181ded4930842b46e9507372f0b1b963James Dong/* Input / output registers */
250c1bc742181ded4930842b46e9507372f0b1b963James Dong#define pStrmData       r0
260c1bc742181ded4930842b46e9507372f0b1b963James Dong#define numBits         r1
270c1bc742181ded4930842b46e9507372f0b1b963James Dong#define readBits        r2
280c1bc742181ded4930842b46e9507372f0b1b963James Dong#define strmBuffSize    r3
290c1bc742181ded4930842b46e9507372f0b1b963James Dong#define pStrmBuffStart  r1
300c1bc742181ded4930842b46e9507372f0b1b963James Dong#define pStrmCurrPos    r2
310c1bc742181ded4930842b46e9507372f0b1b963James Dong#define bitPosInWord    r1
320c1bc742181ded4930842b46e9507372f0b1b963James Dong
330c1bc742181ded4930842b46e9507372f0b1b963James Dong/* Input / output registers */
340c1bc742181ded4930842b46e9507372f0b1b963James Dong
350c1bc742181ded4930842b46e9507372f0b1b963James Dong
360c1bc742181ded4930842b46e9507372f0b1b963James Dong
370c1bc742181ded4930842b46e9507372f0b1b963James Dong/*------------------------------------------------------------------------------
380c1bc742181ded4930842b46e9507372f0b1b963James Dong
390c1bc742181ded4930842b46e9507372f0b1b963James Dong    Function: h264bsdFlushBits
400c1bc742181ded4930842b46e9507372f0b1b963James Dong
410c1bc742181ded4930842b46e9507372f0b1b963James Dong        Functional description:
420c1bc742181ded4930842b46e9507372f0b1b963James Dong
430c1bc742181ded4930842b46e9507372f0b1b963James Dong        Inputs:
440c1bc742181ded4930842b46e9507372f0b1b963James Dong
450c1bc742181ded4930842b46e9507372f0b1b963James Dong        Outputs:
460c1bc742181ded4930842b46e9507372f0b1b963James Dong
470c1bc742181ded4930842b46e9507372f0b1b963James Dong        Returns:
480c1bc742181ded4930842b46e9507372f0b1b963James Dong
490c1bc742181ded4930842b46e9507372f0b1b963James Dong------------------------------------------------------------------------------*/
500c1bc742181ded4930842b46e9507372f0b1b963James Dongfunction h264bsdFlushBits, export=1
510c1bc742181ded4930842b46e9507372f0b1b963James Dong
520c1bc742181ded4930842b46e9507372f0b1b963James Dong    LDR readBits, [pStrmData, #0x10]
530c1bc742181ded4930842b46e9507372f0b1b963James Dong    LDR strmBuffSize, [pStrmData, #0xC]
540c1bc742181ded4930842b46e9507372f0b1b963James Dong
550c1bc742181ded4930842b46e9507372f0b1b963James Dong    ADD readBits, readBits, numBits
560c1bc742181ded4930842b46e9507372f0b1b963James Dong    AND bitPosInWord, readBits, #7
570c1bc742181ded4930842b46e9507372f0b1b963James Dong
580c1bc742181ded4930842b46e9507372f0b1b963James Dong    STR readBits, [pStrmData, #0x10]
590c1bc742181ded4930842b46e9507372f0b1b963James Dong    STR bitPosInWord, [pStrmData, #0x8]
600c1bc742181ded4930842b46e9507372f0b1b963James Dong
610c1bc742181ded4930842b46e9507372f0b1b963James Dong    LDR pStrmBuffStart, [pStrmData, #0x0]
620c1bc742181ded4930842b46e9507372f0b1b963James Dong
630c1bc742181ded4930842b46e9507372f0b1b963James Dong    CMP readBits, strmBuffSize, LSL #3
640c1bc742181ded4930842b46e9507372f0b1b963James Dong
650c1bc742181ded4930842b46e9507372f0b1b963James Dong    BHI end_of_stream
660c1bc742181ded4930842b46e9507372f0b1b963James Dong
670c1bc742181ded4930842b46e9507372f0b1b963James Dong    ADD pStrmCurrPos, pStrmBuffStart, readBits, LSR #3
680c1bc742181ded4930842b46e9507372f0b1b963James Dong    STR pStrmCurrPos, [pStrmData, #0x4]
690c1bc742181ded4930842b46e9507372f0b1b963James Dong    MOV r0, #0
700c1bc742181ded4930842b46e9507372f0b1b963James Dong    BX  lr
710c1bc742181ded4930842b46e9507372f0b1b963James Dong
720c1bc742181ded4930842b46e9507372f0b1b963James Dongend_of_stream:
730c1bc742181ded4930842b46e9507372f0b1b963James Dong    MVN r0, #0
740c1bc742181ded4930842b46e9507372f0b1b963James Dong    BX  lr
750c1bc742181ded4930842b46e9507372f0b1b963James Dong
760c1bc742181ded4930842b46e9507372f0b1b963James Dongendfunction
770c1bc742181ded4930842b46e9507372f0b1b963James Dong
780c1bc742181ded4930842b46e9507372f0b1b963James Dong
79