Lines Matching refs:cabac_ctx
166 void h265e_cabac_resetBits(H265eCabacCtx *cabac_ctx) in h265e_cabac_resetBits() argument
170 cabac_ctx->m_low = 0; in h265e_cabac_resetBits()
171 cabac_ctx->m_bitsLeft = -12; in h265e_cabac_resetBits()
172 cabac_ctx->m_numBufferedBytes = 0; in h265e_cabac_resetBits()
173 cabac_ctx->m_bufferedByte = 0xff; in h265e_cabac_resetBits()
174 cabac_ctx->m_fracBits = 0; in h265e_cabac_resetBits()
179 void h265e_cabac_start(H265eCabacCtx *cabac_ctx) in h265e_cabac_start() argument
182 cabac_ctx->m_low = 0; in h265e_cabac_start()
183 cabac_ctx->m_range = 510; in h265e_cabac_start()
184 cabac_ctx->m_bitsLeft = -12; in h265e_cabac_start()
185 cabac_ctx->m_numBufferedBytes = 0; in h265e_cabac_start()
186 cabac_ctx->m_bufferedByte = 0xff; in h265e_cabac_start()
189 void h265e_cabac_init(H265eCabacCtx *cabac_ctx, MppWriteCtx * bitIf) in h265e_cabac_init() argument
192 cabac_ctx->m_bitIf = bitIf; in h265e_cabac_init()
193 h265e_cabac_start(cabac_ctx); in h265e_cabac_init()
197 void h265e_cabac_writeOut(H265eCabacCtx *cabac_ctx) in h265e_cabac_writeOut() argument
199 MppWriteCtx* s = cabac_ctx->m_bitIf; in h265e_cabac_writeOut()
200 RK_U32 leadByte = cabac_ctx->m_low >> (13 + cabac_ctx->m_bitsLeft); in h265e_cabac_writeOut()
201 RK_U32 low_mask = (RK_U32)(~0) >> (11 + 8 - cabac_ctx->m_bitsLeft); in h265e_cabac_writeOut()
204 cabac_ctx->m_bitsLeft -= 8; in h265e_cabac_writeOut()
205 cabac_ctx->m_low &= low_mask; in h265e_cabac_writeOut()
208 cabac_ctx->m_numBufferedBytes++; in h265e_cabac_writeOut()
210 RK_U32 numBufferedBytes = cabac_ctx->m_numBufferedBytes; in h265e_cabac_writeOut()
213 RK_U32 byteTowrite = cabac_ctx->m_bufferedByte + carry; in h265e_cabac_writeOut()
223 cabac_ctx->m_numBufferedBytes = 1; in h265e_cabac_writeOut()
224 cabac_ctx->m_bufferedByte = (uint8_t)leadByte; in h265e_cabac_writeOut()
236 void h265e_cabac_encodeBin(H265eCabacCtx *cabac_ctx, H265eContextModel_t *ctxModel, RK_U32 binValue) in h265e_cabac_encodeBin() argument
246 RK_U32 range = cabac_ctx->m_range; in h265e_cabac_encodeBin()
255 RK_U32 low = cabac_ctx->m_low; in h265e_cabac_encodeBin()
272 cabac_ctx->m_low = (low << numBits); in h265e_cabac_encodeBin()
273 cabac_ctx->m_range = (range << numBits); in h265e_cabac_encodeBin()
274 cabac_ctx->m_bitsLeft += numBits; in h265e_cabac_encodeBin()
277 if (cabac_ctx->m_bitsLeft >= 0) { in h265e_cabac_encodeBin()
278 h265e_cabac_writeOut(cabac_ctx); in h265e_cabac_encodeBin()
284 void h265e_cabac_encodeBinTrm(H265eCabacCtx *cabac_ctx, RK_U32 binValue) in h265e_cabac_encodeBinTrm() argument
289 cabac_ctx->m_range -= 2; in h265e_cabac_encodeBinTrm()
291 cabac_ctx->m_low += cabac_ctx->m_range; in h265e_cabac_encodeBinTrm()
292 cabac_ctx->m_low <<= 7; in h265e_cabac_encodeBinTrm()
293 cabac_ctx->m_range = 2 << 7; in h265e_cabac_encodeBinTrm()
294 cabac_ctx->m_bitsLeft += 7; in h265e_cabac_encodeBinTrm()
295 } else if (cabac_ctx->m_range >= 256) { in h265e_cabac_encodeBinTrm()
298 cabac_ctx->m_low <<= 1; in h265e_cabac_encodeBinTrm()
299 cabac_ctx->m_range <<= 1; in h265e_cabac_encodeBinTrm()
300 cabac_ctx->m_bitsLeft++; in h265e_cabac_encodeBinTrm()
303 if (cabac_ctx->m_bitsLeft >= 0) { in h265e_cabac_encodeBinTrm()
304 h265e_cabac_writeOut(cabac_ctx); in h265e_cabac_encodeBinTrm()
310 void h265e_cabac_finish(H265eCabacCtx *cabac_ctx) in h265e_cabac_finish() argument
312 MppWriteCtx* s = cabac_ctx->m_bitIf; in h265e_cabac_finish()
316 if (cabac_ctx->m_low >> (21 + cabac_ctx->m_bitsLeft)) { in h265e_cabac_finish()
318 mpp_writer_put_bits(s, cabac_ctx->m_bufferedByte + 1, 8); in h265e_cabac_finish()
319 while (cabac_ctx->m_numBufferedBytes > 1) { in h265e_cabac_finish()
321 cabac_ctx->m_numBufferedBytes--; in h265e_cabac_finish()
324 cabac_ctx->m_low -= 1 << (21 + cabac_ctx->m_bitsLeft); in h265e_cabac_finish()
326 if (cabac_ctx->m_numBufferedBytes > 0) { in h265e_cabac_finish()
328 mpp_writer_put_bits(s, cabac_ctx->m_bufferedByte , 8); in h265e_cabac_finish()
330 while (cabac_ctx->m_numBufferedBytes > 1) { in h265e_cabac_finish()
332 cabac_ctx->m_numBufferedBytes--; in h265e_cabac_finish()
335 mpp_writer_put_bits(s, cabac_ctx->m_low >> 8 , 13 + cabac_ctx->m_bitsLeft); in h265e_cabac_finish()
340 void h265e_cabac_flush(H265eCabacCtx *cabac_ctx) in h265e_cabac_flush() argument
342 MppWriteCtx* s = cabac_ctx->m_bitIf; in h265e_cabac_flush()
346 h265e_cabac_encodeBinTrm(cabac_ctx, 1); in h265e_cabac_flush()
347 h265e_cabac_finish(cabac_ctx); in h265e_cabac_flush()
350 h265e_cabac_start(cabac_ctx); in h265e_cabac_flush()