25#ifndef AVCODEC_LOONGARCH_CABAC_H
26#define AVCODEC_LOONGARCH_CABAC_H
32#define GET_CABAC_LOONGARCH_UNCBSR \
33 "ld.bu %[bit], %[state], 0x0 \n\t" \
34 "andi %[tmp0], %[c_range], 0xC0 \n\t" \
35 "slli.d %[tmp0], %[tmp0], 0x01 \n\t" \
36 "add.d %[tmp0], %[tmp0], %[tables] \n\t" \
37 "add.d %[tmp0], %[tmp0], %[bit] \n\t" \
39 "ld.bu %[tmp1], %[tmp0], %[lps_off] \n\t" \
41 "sub.d %[c_range], %[c_range], %[tmp1] \n\t" \
42 "slli.d %[tmp0], %[c_range], 0x11 \n\t" \
43 "bge %[tmp0], %[c_low], 1f \n\t" \
44 "move %[c_range], %[tmp1] \n\t" \
45 "nor %[bit], %[bit], %[bit] \n\t" \
46 "sub.d %[c_low], %[c_low], %[tmp0] \n\t" \
50 "add.d %[tmp0], %[tables], %[bit] \n\t" \
51 "ld.bu %[tmp1], %[tmp0], %[mlps_off] \n\t" \
53 "add.d %[tmp0], %[tables], %[c_range] \n\t" \
54 "ld.bu %[tmp2], %[tmp0], %[norm_off] \n\t" \
56 "andi %[bit], %[bit], 0x01 \n\t" \
57 "st.b %[tmp1], %[state], 0x0 \n\t" \
58 "sll.d %[c_range], %[c_range], %[tmp2] \n\t" \
59 "sll.d %[c_low], %[c_low], %[tmp2] \n\t" \
61 "and %[tmp1], %[c_low], %[cabac_mask] \n\t" \
62 "bnez %[tmp1], 1f \n\t" \
63 "ld.hu %[tmp1], %[c_bytestream], 0x0 \n\t" \
64 "ctz.d %[tmp0], %[c_low] \n\t" \
65 "addi.d %[tmp2], %[tmp0], -16 \n\t" \
66 "revb.2h %[tmp0], %[tmp1] \n\t" \
67 "slli.d %[tmp0], %[tmp0], 0x01 \n\t" \
68 "sub.d %[tmp0], %[tmp0], %[cabac_mask] \n\t" \
69 "sll.d %[tmp0], %[tmp0], %[tmp2] \n\t" \
70 "add.d %[c_low], %[c_low], %[tmp0] \n\t" \
71 "addi.d %[c_bytestream], %[c_bytestream], 0x02 \n\t" \
74#define GET_CABAC_LOONGARCH \
75 "ld.bu %[bit], %[state], 0x0 \n\t" \
76 "andi %[tmp0], %[c_range], 0xC0 \n\t" \
77 "slli.d %[tmp0], %[tmp0], 0x01 \n\t" \
78 "add.d %[tmp0], %[tmp0], %[tables] \n\t" \
79 "add.d %[tmp0], %[tmp0], %[bit] \n\t" \
81 "ld.bu %[tmp1], %[tmp0], %[lps_off] \n\t" \
83 "sub.d %[c_range], %[c_range], %[tmp1] \n\t" \
84 "slli.d %[tmp0], %[c_range], 0x11 \n\t" \
85 "bge %[tmp0], %[c_low], 1f \n\t" \
86 "move %[c_range], %[tmp1] \n\t" \
87 "nor %[bit], %[bit], %[bit] \n\t" \
88 "sub.d %[c_low], %[c_low], %[tmp0] \n\t" \
92 "add.d %[tmp0], %[tables], %[bit] \n\t" \
93 "ld.bu %[tmp1], %[tmp0], %[mlps_off] \n\t" \
95 "add.d %[tmp0], %[tables], %[c_range] \n\t" \
96 "ld.bu %[tmp2], %[tmp0], %[norm_off] \n\t" \
98 "andi %[bit], %[bit], 0x01 \n\t" \
99 "st.b %[tmp1], %[state], 0x0 \n\t" \
100 "sll.d %[c_range], %[c_range], %[tmp2] \n\t" \
101 "sll.d %[c_low], %[c_low], %[tmp2] \n\t" \
103 "and %[tmp1], %[c_low], %[cabac_mask] \n\t" \
104 "bnez %[tmp1], 1f \n\t" \
105 "ld.hu %[tmp1], %[c_bytestream], 0x0 \n\t" \
106 "ctz.d %[tmp0], %[c_low] \n\t" \
107 "addi.d %[tmp2], %[tmp0], -16 \n\t" \
108 "revb.2h %[tmp0], %[tmp1] \n\t" \
109 "slli.d %[tmp0], %[tmp0], 0x01 \n\t" \
110 "sub.d %[tmp0], %[tmp0], %[cabac_mask] \n\t" \
111 "sll.d %[tmp0], %[tmp0], %[tmp2] \n\t" \
113 "add.d %[c_low], %[c_low], %[tmp0] \n\t" \
115 "slt %[tmp0], %[c_bytestream], %[c_bytestream_end] \n\t" \
116 "add.d %[c_bytestream], %[c_bytestream], %[tmp0] \n\t" \
117 "add.d %[c_bytestream], %[c_bytestream], %[tmp0] \n\t" \
120#define get_cabac_inline get_cabac_inline_loongarch
127#if UNCHECKED_BITSTREAM_READER
132 : [
bit]
"=&r"(
bit), [tmp0]
"=&r"(tmp0), [tmp1]
"=&r"(tmp1), [tmp2]
"=&r"(tmp2),
133 [c_range]
"+&r"(
c->range), [c_low]
"+&r"(
c->low),
134 [c_bytestream]
"+&r"(
c->bytestream)
136#if !UNCHECKED_BITSTREAM_READER
137 [c_bytestream_end]
"r"(
c->bytestream_end),
149#define get_cabac_bypass get_cabac_bypass_loongarch
155 "slli.d %[c_low], %[c_low], 0x01 \n\t"
156 "and %[tmp0], %[c_low], %[cabac_mask] \n\t"
157 "bnez %[tmp0], 1f \n\t"
158 "ld.hu %[tmp1], %[c_bytestream], 0x0 \n\t"
159#if UNCHECKED_BITSTREAM_READER
160 "addi.d %[c_bytestream], %[c_bytestream], 0x02 \n\t"
162 "slt %[tmp0], %[c_bytestream], %[c_bytestream_end] \n\t"
163 "add.d %[c_bytestream], %[c_bytestream], %[tmp0] \n\t"
164 "add.d %[c_bytestream], %[c_bytestream], %[tmp0] \n\t"
166 "revb.2h %[tmp1], %[tmp1] \n\t"
167 "slli.d %[tmp1], %[tmp1], 0x01 \n\t"
168 "sub.d %[tmp1], %[tmp1], %[cabac_mask] \n\t"
169 "add.d %[c_low], %[c_low], %[tmp1] \n\t"
171 "slli.d %[tmp1], %[c_range], 0x11 \n\t"
172 "slt %[tmp0], %[c_low], %[tmp1] \n\t"
173 "sub.d %[tmp1], %[c_low], %[tmp1] \n\t"
174 "masknez %[tmp2], %[one], %[tmp0] \n\t"
175 "maskeqz %[res], %[res], %[tmp0] \n\t"
176 "or %[res], %[res], %[tmp2] \n\t"
177 "masknez %[tmp2], %[tmp1], %[tmp0] \n\t"
178 "maskeqz %[c_low], %[c_low], %[tmp0] \n\t"
179 "or %[c_low], %[c_low], %[tmp2] \n\t"
180 : [tmp0]
"=&r"(tmp0), [tmp1]
"=&r"(tmp1), [tmp2]
"=&r"(tmp2),
181 [c_range]
"+&r"(
c->range), [c_low]
"+&r"(
c->low),
182 [c_bytestream]
"+&r"(
c->bytestream), [res]
"+&r"(res)
184#if !UNCHECKED_BITSTREAM_READER
185 [c_bytestream_end]
"r"(
c->bytestream_end),
193#define get_cabac_bypass_sign get_cabac_bypass_sign_loongarch
200 "slli.d %[c_low], %[c_low], 0x01 \n\t"
201 "and %[tmp0], %[c_low], %[cabac_mask] \n\t"
202 "bnez %[tmp0], 1f \n\t"
203 "ld.hu %[tmp1], %[c_bytestream], 0x0 \n\t"
204#if UNCHECKED_BITSTREAM_READER
205 "addi.d %[c_bytestream], %[c_bytestream], 0x02 \n\t"
207 "slt %[tmp0], %[c_bytestream], %[c_bytestream_end] \n\t"
208 "add.d %[c_bytestream], %[c_bytestream], %[tmp0] \n\t"
209 "add.d %[c_bytestream], %[c_bytestream], %[tmp0] \n\t"
211 "revb.2h %[tmp1], %[tmp1] \n\t"
212 "slli.d %[tmp1], %[tmp1], 0x01 \n\t"
213 "sub.d %[tmp1], %[tmp1], %[cabac_mask] \n\t"
214 "add.d %[c_low], %[c_low], %[tmp1] \n\t"
216 "slli.d %[tmp1], %[c_range], 0x11 \n\t"
217 "slt %[tmp0], %[c_low], %[tmp1] \n\t"
218 "sub.d %[tmp1], %[c_low], %[tmp1] \n\t"
219 "masknez %[tmp1], %[tmp1], %[tmp0] \n\t"
220 "maskeqz %[c_low], %[c_low], %[tmp0] \n\t"
221 "or %[c_low], %[c_low], %[tmp1] \n\t"
222 "sub.d %[tmp1], %[zero], %[res] \n\t"
223 "maskeqz %[tmp1], %[tmp1], %[tmp0] \n\t"
224 "masknez %[res], %[res], %[tmp0] \n\t"
225 "or %[res], %[res], %[tmp1] \n\t"
226 : [tmp0]
"=&r"(tmp0), [tmp1]
"=&r"(tmp1), [res]
"+&r"(res),
227 [c_range]
"+&r"(
c->range), [c_low]
"+&r"(
c->low),
228 [c_bytestream]
"+&r"(
c->bytestream)
230#if !UNCHECKED_BITSTREAM_READER
231 [c_bytestream_end]
"r"(
c->bytestream_end),
static double val(void *priv, double ch)
__asm__(".macro parse_r var r\n\t" "\\var = -1\n\t" _IFC_REG(0) _IFC_REG(1) _IFC_REG(2) _IFC_REG(3) _IFC_REG(4) _IFC_REG(5) _IFC_REG(6) _IFC_REG(7) _IFC_REG(8) _IFC_REG(9) _IFC_REG(10) _IFC_REG(11) _IFC_REG(12) _IFC_REG(13) _IFC_REG(14) _IFC_REG(15) _IFC_REG(16) _IFC_REG(17) _IFC_REG(18) _IFC_REG(19) _IFC_REG(20) _IFC_REG(21) _IFC_REG(22) _IFC_REG(23) _IFC_REG(24) _IFC_REG(25) _IFC_REG(26) _IFC_REG(27) _IFC_REG(28) _IFC_REG(29) _IFC_REG(30) _IFC_REG(31) ".iflt \\var\n\t" ".error \"Unable to parse register name \\r\"\n\t" ".endif\n\t" ".endm")
Context Adaptive Binary Arithmetic Coder.
#define H264_LPS_RANGE_OFFSET
#define H264_MLPS_STATE_OFFSET
#define H264_NORM_SHIFT_OFFSET
const uint8_t ff_h264_cabac_tables[512+4 *2 *64+4 *64+63]
#define bit(string, value)
static struct @346255127015250356166251341105367306144006377143 state
static int zero(InterplayACMContext *s, unsigned ind, unsigned col)
Macro definitions for various function/variable attributes.
static av_always_inline int get_cabac_bypass_loongarch(CABACContext *c)
#define GET_CABAC_LOONGARCH_UNCBSR
static av_always_inline int get_cabac_bypass_sign_loongarch(CABACContext *c, int val)
#define GET_CABAC_LOONGARCH
static av_always_inline int get_cabac_inline_loongarch(CABACContext *c, uint8_t *const state)
static const uint8_t *const tables[]