Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
52867 views
1
/*****************************************************************************
2
* cabac-a.S: aarch64 cabac
3
*****************************************************************************
4
* Copyright (C) 2014-2016 x264 project
5
*
6
* Authors: Janne Grunau <[email protected]>
7
*
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.
12
*
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.
17
*
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.
21
*
22
* This program is also available under a commercial proprietary license.
23
* For more information, contact us at [email protected].
24
*****************************************************************************/
25
26
#include "asm.S"
27
#include "asm-offsets.h"
28
29
// w11 holds x264_cabac_t.i_low
30
// w12 holds x264_cabac_t.i_range
31
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]
38
and x4, x3, #~1
39
asr w5, w12, #6
40
add x8, x8, x4, lsl #1
41
sub w5, w5, #4
42
eor w6, w2, w3 // b ^ i_state
43
ldrb w4, [x8, x5] // i_range_lps
44
ldr w11, [x0, #CABAC_I_LOW]
45
sub w12, w12, w4
46
tbz w6, #0, 1f // (b ^ i_state) & 1
47
add w11, w11, w12
48
mov w12, w4
49
1:
50
orr w4, w2, w3, lsl #1
51
ldrb w9, [x9, x4]
52
strb w9, [x0, x10] // i_state
53
54
cabac_encode_renorm:
55
clz w5, w12
56
ldr w2, [x0, #CABAC_I_QUEUE]
57
sub w5, w5, #23
58
lsl w12, w12, w5
59
lsl w11, w11, w5
60
2:
61
adds w2, w2, w5
62
str w12, [x0, #CABAC_I_RANGE]
63
b.lt 0f
64
cabac_putbyte:
65
mov w13, #0x400
66
add w12, w2, #10
67
lsl w13, w13, w2
68
asr w4, w11, w12 // out
69
sub w2, w2, #8
70
sub w13, w13, #1
71
subs w5, w4, #0xff
72
and w11, w11, w13
73
ldr w6, [x0, #CABAC_I_BYTES_OUTSTANDING]
74
str w2, [x0, #CABAC_I_QUEUE]
75
b.ne 1f
76
77
add w6, w6, #1
78
str w11, [x0, #CABAC_I_LOW]
79
str w6, [x0, #CABAC_I_BYTES_OUTSTANDING]
80
ret
81
82
1:
83
ldr x7, [x0, #CABAC_P]
84
asr w5, w4, #8 // carry
85
ldrb w8, [x7, #-1]
86
add w8, w8, w5
87
sub w5, w5, #1
88
strb w8, [x7, #-1]
89
cbz w6, 3f
90
2:
91
subs w6, w6, #1
92
strb w5, [x7], #1
93
b.gt 2b
94
3:
95
strb w4, [x7], #1
96
str wzr, [x0, #CABAC_I_BYTES_OUTSTANDING]
97
str x7, [x0, #CABAC_P]
98
0:
99
str w11, [x0, #CABAC_I_LOW]
100
str w2, [x0, #CABAC_I_QUEUE]
101
ret
102
endfunc
103
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]
108
and w1, w1, w12
109
add w11, w1, w11, lsl #1
110
adds w2, w2, #1
111
b.ge cabac_putbyte
112
str w11, [x0, #CABAC_I_LOW]
113
str w2, [x0, #CABAC_I_QUEUE]
114
ret
115
endfunc
116
117
function x264_cabac_encode_terminal_asm, export=1
118
ldr w12, [x0, #CABAC_I_RANGE]
119
ldr w11, [x0, #CABAC_I_LOW]
120
sub w12, w12, #2
121
b cabac_encode_renorm
122
endfunc
123
124