1 /*****************************************************************************
2 * cabac-a.S: aarch64 cabac
3 *****************************************************************************
4 * Copyright (C) 2014-2015 x264 project
6 * Authors: Janne Grunau <janne-x264@jannau.net>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA.
22 * This program is also available under a commercial proprietary license.
23 * For more information, contact us at licensing@x264.com.
24 *****************************************************************************/
27 #include "asm-offsets.h"
29 // w11 holds x264_cabac_t.i_low
30 // w12 holds x264_cabac_t.i_range
32 function x264_cabac_encode_decision_asm, export=1
33 movrel x8, X(x264_cabac_range_lps)
34 movrel x9, X(x264_cabac_transition)
35 add w10, w1, #CABAC_STATE
36 ldrb w3, [x0, x10] // i_state
37 ldr w12, [x0, #CABAC_I_RANGE]
40 add x8, x8, x4, lsl #1
42 eor w6, w2, w3 // b ^ i_state
43 ldrb w4, [x8, x5] // i_range_lps
44 ldr w11, [x0, #CABAC_I_LOW]
46 tbz w6, #0, 1f // (b ^ i_state) & 1
50 orr w4, w2, w3, lsl #1
52 strb w9, [x0, x10] // i_state
56 ldr w2, [x0, #CABAC_I_QUEUE]
62 str w12, [x0, #CABAC_I_RANGE]
68 asr w4, w11, w12 // out
73 ldr w6, [x0, #CABAC_I_BYTES_OUTSTANDING]
74 str w2, [x0, #CABAC_I_QUEUE]
78 str w11, [x0, #CABAC_I_LOW]
79 str w6, [x0, #CABAC_I_BYTES_OUTSTANDING]
83 ldr x7, [x0, #CABAC_P]
84 asr w5, w4, #8 // carry
96 str wzr, [x0, #CABAC_I_BYTES_OUTSTANDING]
97 str x7, [x0, #CABAC_P]
99 str w11, [x0, #CABAC_I_LOW]
100 str w2, [x0, #CABAC_I_QUEUE]
104 function x264_cabac_encode_bypass_asm, export=1
105 ldr w12, [x0, #CABAC_I_RANGE]
106 ldr w11, [x0, #CABAC_I_LOW]
107 ldr w2, [x0, #CABAC_I_QUEUE]
109 add w11, w1, w11, lsl #1
112 str w11, [x0, #CABAC_I_LOW]
113 str w2, [x0, #CABAC_I_QUEUE]
117 function x264_cabac_encode_terminal_asm, export=1
118 ldr w12, [x0, #CABAC_I_RANGE]
119 ldr w11, [x0, #CABAC_I_LOW]
121 b cabac_encode_renorm