/*****************************************************************************1* cabac-a.S: aarch64 cabac2*****************************************************************************3* Copyright (C) 2014-2016 x264 project4*5* Authors: Janne Grunau <[email protected]>6*7* This program is free software; you can redistribute it and/or modify8* it under the terms of the GNU General Public License as published by9* the Free Software Foundation; either version 2 of the License, or10* (at your option) any later version.11*12* This program is distributed in the hope that it will be useful,13* but WITHOUT ANY WARRANTY; without even the implied warranty of14* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the15* GNU General Public License for more details.16*17* You should have received a copy of the GNU General Public License18* along with this program; if not, write to the Free Software19* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA.20*21* This program is also available under a commercial proprietary license.22* For more information, contact us at [email protected].23*****************************************************************************/2425#include "asm.S"26#include "asm-offsets.h"2728// w11 holds x264_cabac_t.i_low29// w12 holds x264_cabac_t.i_range3031function x264_cabac_encode_decision_asm, export=132movrel x8, X(x264_cabac_range_lps)33movrel x9, X(x264_cabac_transition)34add w10, w1, #CABAC_STATE35ldrb w3, [x0, x10] // i_state36ldr w12, [x0, #CABAC_I_RANGE]37and x4, x3, #~138asr w5, w12, #639add x8, x8, x4, lsl #140sub w5, w5, #441eor w6, w2, w3 // b ^ i_state42ldrb w4, [x8, x5] // i_range_lps43ldr w11, [x0, #CABAC_I_LOW]44sub w12, w12, w445tbz w6, #0, 1f // (b ^ i_state) & 146add w11, w11, w1247mov w12, w4481:49orr w4, w2, w3, lsl #150ldrb w9, [x9, x4]51strb w9, [x0, x10] // i_state5253cabac_encode_renorm:54clz w5, w1255ldr w2, [x0, #CABAC_I_QUEUE]56sub w5, w5, #2357lsl w12, w12, w558lsl w11, w11, w5592:60adds w2, w2, w561str w12, [x0, #CABAC_I_RANGE]62b.lt 0f63cabac_putbyte:64mov w13, #0x40065add w12, w2, #1066lsl w13, w13, w267asr w4, w11, w12 // out68sub w2, w2, #869sub w13, w13, #170subs w5, w4, #0xff71and w11, w11, w1372ldr w6, [x0, #CABAC_I_BYTES_OUTSTANDING]73str w2, [x0, #CABAC_I_QUEUE]74b.ne 1f7576add w6, w6, #177str w11, [x0, #CABAC_I_LOW]78str w6, [x0, #CABAC_I_BYTES_OUTSTANDING]79ret80811:82ldr x7, [x0, #CABAC_P]83asr w5, w4, #8 // carry84ldrb w8, [x7, #-1]85add w8, w8, w586sub w5, w5, #187strb w8, [x7, #-1]88cbz w6, 3f892:90subs w6, w6, #191strb w5, [x7], #192b.gt 2b933:94strb w4, [x7], #195str wzr, [x0, #CABAC_I_BYTES_OUTSTANDING]96str x7, [x0, #CABAC_P]970:98str w11, [x0, #CABAC_I_LOW]99str w2, [x0, #CABAC_I_QUEUE]100ret101endfunc102103function x264_cabac_encode_bypass_asm, export=1104ldr w12, [x0, #CABAC_I_RANGE]105ldr w11, [x0, #CABAC_I_LOW]106ldr w2, [x0, #CABAC_I_QUEUE]107and w1, w1, w12108add w11, w1, w11, lsl #1109adds w2, w2, #1110b.ge cabac_putbyte111str w11, [x0, #CABAC_I_LOW]112str w2, [x0, #CABAC_I_QUEUE]113ret114endfunc115116function x264_cabac_encode_terminal_asm, export=1117ldr w12, [x0, #CABAC_I_RANGE]118ldr w11, [x0, #CABAC_I_LOW]119sub w12, w12, #2120b cabac_encode_renorm121endfunc122123124