13749f6f435e79624f72841e866245d84195551cdHarinarayanan K K/****************************************************************************** 23749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * 33749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * Copyright (C) 2015 The Android Open Source Project 43749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * 53749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * Licensed under the Apache License, Version 2.0 (the "License"); 63749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * you may not use this file except in compliance with the License. 73749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * You may obtain a copy of the License at: 83749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * 93749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * http://www.apache.org/licenses/LICENSE-2.0 103749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * 113749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * Unless required by applicable law or agreed to in writing, software 123749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * distributed under the License is distributed on an "AS IS" BASIS, 133749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 143749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * See the License for the specific language governing permissions and 153749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * limitations under the License. 163749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * 173749f6f435e79624f72841e866245d84195551cdHarinarayanan K K ***************************************************************************** 183749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore 193749f6f435e79624f72841e866245d84195551cdHarinarayanan K K*/ 203749f6f435e79624f72841e866245d84195551cdHarinarayanan K K 213749f6f435e79624f72841e866245d84195551cdHarinarayanan K K/** 223749f6f435e79624f72841e866245d84195551cdHarinarayanan K K ******************************************************************************* 233749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * @file 243749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * ih264e_cabac_structs.h 253749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * 263749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * @brief 273749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * This file contains cabac related macros, enums, tables and function declarations. 283749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * 293749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * @author 303749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * Doney Alex 313749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * 323749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * @remarks 333749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * none 343749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * 353749f6f435e79624f72841e866245d84195551cdHarinarayanan K K ******************************************************************************* 363749f6f435e79624f72841e866245d84195551cdHarinarayanan K K */ 373749f6f435e79624f72841e866245d84195551cdHarinarayanan K K 383749f6f435e79624f72841e866245d84195551cdHarinarayanan K K#ifndef IH264E_CABAC_H_ 393749f6f435e79624f72841e866245d84195551cdHarinarayanan K K#define IH264E_CABAC_H_ 403749f6f435e79624f72841e866245d84195551cdHarinarayanan K K 413749f6f435e79624f72841e866245d84195551cdHarinarayanan K K 423749f6f435e79624f72841e866245d84195551cdHarinarayanan K K 433749f6f435e79624f72841e866245d84195551cdHarinarayanan K K/******************************************************************************* 443749f6f435e79624f72841e866245d84195551cdHarinarayanan K K@brief Bit precision of cabac engine; 453749f6f435e79624f72841e866245d84195551cdHarinarayanan K K******************************************************************************* 463749f6f435e79624f72841e866245d84195551cdHarinarayanan K K*/ 473749f6f435e79624f72841e866245d84195551cdHarinarayanan K K#define CABAC_BITS 9 483749f6f435e79624f72841e866245d84195551cdHarinarayanan K K 493749f6f435e79624f72841e866245d84195551cdHarinarayanan K K 503749f6f435e79624f72841e866245d84195551cdHarinarayanan K K/** 513749f6f435e79624f72841e866245d84195551cdHarinarayanan K K****************************************************************************** 523749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * @macro Reverse bits in an unsigned integer 533749f6f435e79624f72841e866245d84195551cdHarinarayanan K K****************************************************************************** 543749f6f435e79624f72841e866245d84195551cdHarinarayanan K K*/ 553749f6f435e79624f72841e866245d84195551cdHarinarayanan K K#define REV(u4_input, u4_output) \ 563749f6f435e79624f72841e866245d84195551cdHarinarayanan K K{ \ 573749f6f435e79624f72841e866245d84195551cdHarinarayanan K K UWORD32 u4_temp = (u4_input); \ 583749f6f435e79624f72841e866245d84195551cdHarinarayanan K K WORD8 i; \ 593749f6f435e79624f72841e866245d84195551cdHarinarayanan K K u4_output = 0; \ 603749f6f435e79624f72841e866245d84195551cdHarinarayanan K K for (i = 0; i < 32; i++) \ 613749f6f435e79624f72841e866245d84195551cdHarinarayanan K K { \ 623749f6f435e79624f72841e866245d84195551cdHarinarayanan K K u4_output = (u4_output << 1) + \ 633749f6f435e79624f72841e866245d84195551cdHarinarayanan K K ((u4_temp >> i) & 0x01); \ 643749f6f435e79624f72841e866245d84195551cdHarinarayanan K K } \ 653749f6f435e79624f72841e866245d84195551cdHarinarayanan K K} 663749f6f435e79624f72841e866245d84195551cdHarinarayanan K K 673749f6f435e79624f72841e866245d84195551cdHarinarayanan K K/** 683749f6f435e79624f72841e866245d84195551cdHarinarayanan K K****************************************************************************** 693749f6f435e79624f72841e866245d84195551cdHarinarayanan K K*! Bit manipulation macros 703749f6f435e79624f72841e866245d84195551cdHarinarayanan K K****************************************************************************** 713749f6f435e79624f72841e866245d84195551cdHarinarayanan K K*/ 723749f6f435e79624f72841e866245d84195551cdHarinarayanan K K#define SETBIT(a, i) ((a) |= (1 << (i))) 733749f6f435e79624f72841e866245d84195551cdHarinarayanan K K#define CLEARBIT(a, i) ((a) &= ~(1 << (i))) 743749f6f435e79624f72841e866245d84195551cdHarinarayanan K K 753749f6f435e79624f72841e866245d84195551cdHarinarayanan K K 763749f6f435e79624f72841e866245d84195551cdHarinarayanan K K/** 773749f6f435e79624f72841e866245d84195551cdHarinarayanan K K****************************************************************************** 783749f6f435e79624f72841e866245d84195551cdHarinarayanan K K*! Cabac module expect atlesat MIN_STREAM_SIZE_MB bytes left in stream buffer 793749f6f435e79624f72841e866245d84195551cdHarinarayanan K K*! for encoding an MB 803749f6f435e79624f72841e866245d84195551cdHarinarayanan K K****************************************************************************** 813749f6f435e79624f72841e866245d84195551cdHarinarayanan K K*/ 823749f6f435e79624f72841e866245d84195551cdHarinarayanan K K#define MIN_STREAM_SIZE_MB 1024 833749f6f435e79624f72841e866245d84195551cdHarinarayanan K K 843749f6f435e79624f72841e866245d84195551cdHarinarayanan K K 853749f6f435e79624f72841e866245d84195551cdHarinarayanan K K 863749f6f435e79624f72841e866245d84195551cdHarinarayanan K K/*****************************************************************************/ 873749f6f435e79624f72841e866245d84195551cdHarinarayanan K K/* Function Declarations */ 883749f6f435e79624f72841e866245d84195551cdHarinarayanan K K/*****************************************************************************/ 893749f6f435e79624f72841e866245d84195551cdHarinarayanan K K 903749f6f435e79624f72841e866245d84195551cdHarinarayanan K K 913749f6f435e79624f72841e866245d84195551cdHarinarayanan K K/** 923749f6f435e79624f72841e866245d84195551cdHarinarayanan K K ******************************************************************************* 933749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * 943749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * @brief 953749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * Initialize default context values and pointers. 963749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * 973749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * @param[in] ps_ent_ctxt 983749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * Pointer to entropy context structure 993749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * 1003749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * @returns 1013749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * 1023749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * @remarks 1033749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * None 1043749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * 1053749f6f435e79624f72841e866245d84195551cdHarinarayanan K K ******************************************************************************* 1063749f6f435e79624f72841e866245d84195551cdHarinarayanan K K */ 1073749f6f435e79624f72841e866245d84195551cdHarinarayanan K Kvoid ih264e_init_cabac_table(entropy_ctxt_t *ps_ent_ctxt); 1083749f6f435e79624f72841e866245d84195551cdHarinarayanan K K 1093749f6f435e79624f72841e866245d84195551cdHarinarayanan K K 1103749f6f435e79624f72841e866245d84195551cdHarinarayanan K K/** 1113749f6f435e79624f72841e866245d84195551cdHarinarayanan K K ******************************************************************************* 1123749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * 1133749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * @brief 1143749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * Initialize cabac context: Intitalize all contest with init values given in the spec. 1153749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * Called at the beginning of entropy coding of each slice for CABAC encoding. 1163749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * 1173749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * @param[in] ps_ent_ctxt 1183749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * Pointer to entropy context structure 1193749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * 1203749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * @returns 1213749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * 1223749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * @remarks 1233749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * None 1243749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * 1253749f6f435e79624f72841e866245d84195551cdHarinarayanan K K ******************************************************************************* 1263749f6f435e79624f72841e866245d84195551cdHarinarayanan K K */ 1273749f6f435e79624f72841e866245d84195551cdHarinarayanan K Kvoid ih264e_init_cabac_ctxt(entropy_ctxt_t *ps_ent_ctxt); 1283749f6f435e79624f72841e866245d84195551cdHarinarayanan K K 1293749f6f435e79624f72841e866245d84195551cdHarinarayanan K K 1303749f6f435e79624f72841e866245d84195551cdHarinarayanan K K 1313749f6f435e79624f72841e866245d84195551cdHarinarayanan K K/** 1323749f6f435e79624f72841e866245d84195551cdHarinarayanan K K ******************************************************************************* 1333749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * 1343749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * @brief 1353749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * k-th order Exp-Golomb (UEGk) binarization process: Implements concatenated 1363749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * unary/ k-th order Exp-Golomb (UEGk) binarization process, 1373749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * where k = 0 as defined in 9.3.2.3 of ITU_T_H264-201402 1383749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * 1393749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * @param[in] i2_sufs 1403749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * Suffix bit string 1413749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * 1423749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * @param[in] pi1_bins_len 1433749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * Pointer to length of the string 1443749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * 1453749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * @returns Binarized value 1463749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * 1473749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * @remarks 1483749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * None 1493749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * 1503749f6f435e79624f72841e866245d84195551cdHarinarayanan K K ******************************************************************************* 1513749f6f435e79624f72841e866245d84195551cdHarinarayanan K K */ 1523749f6f435e79624f72841e866245d84195551cdHarinarayanan K KUWORD32 ih264e_cabac_UEGk0_binarization(WORD16 i2_sufs, WORD8 *pi1_bins_len); 1533749f6f435e79624f72841e866245d84195551cdHarinarayanan K K 1543749f6f435e79624f72841e866245d84195551cdHarinarayanan K K 1553749f6f435e79624f72841e866245d84195551cdHarinarayanan K K/** 1563749f6f435e79624f72841e866245d84195551cdHarinarayanan K K ******************************************************************************* 1573749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * 1583749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * @brief 1593749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * Get cabac context for the MB :calculates the pointers to Top and left 1603749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * cabac neighbor context depending upon neighbor availability. 1613749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * 1623749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * @param[in] ps_ent_ctxt 1633749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * Pointer to entropy context structure 1643749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * 1653749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * @param[in] u4_mb_type 1663749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * Type of MB 1673749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * 1683749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * @returns 1693749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * 1703749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * @remarks 1713749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * None 1723749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * 1733749f6f435e79624f72841e866245d84195551cdHarinarayanan K K ******************************************************************************* 1743749f6f435e79624f72841e866245d84195551cdHarinarayanan K K */ 1753749f6f435e79624f72841e866245d84195551cdHarinarayanan K Kvoid ih264e_get_cabac_context(entropy_ctxt_t *ps_ent_ctxt, WORD32 u4_mb_type); 1763749f6f435e79624f72841e866245d84195551cdHarinarayanan K K 1773749f6f435e79624f72841e866245d84195551cdHarinarayanan K K 1783749f6f435e79624f72841e866245d84195551cdHarinarayanan K K/** 1793749f6f435e79624f72841e866245d84195551cdHarinarayanan K K ******************************************************************************* 1803749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * @brief 1813749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * flushing at termination: Explained in flowchart 9-12(ITU_T_H264-201402). 1823749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * 1833749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * @param[in] ps_cabac_ctxt 1843749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * pointer to cabac context (handle) 1853749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * 1860574be65f4b2376e32bdf979650d8e5f168b68b7Doney Alex * @returns none 1873749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * 1883749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * @remarks 1893749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * None 1903749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * 1913749f6f435e79624f72841e866245d84195551cdHarinarayanan K K ******************************************************************************* 1923749f6f435e79624f72841e866245d84195551cdHarinarayanan K K */ 1930574be65f4b2376e32bdf979650d8e5f168b68b7Doney Alexvoid ih264e_cabac_flush(cabac_ctxt_t *ps_cabac_ctxt); 1943749f6f435e79624f72841e866245d84195551cdHarinarayanan K K 1953749f6f435e79624f72841e866245d84195551cdHarinarayanan K K 1963749f6f435e79624f72841e866245d84195551cdHarinarayanan K K/** 1973749f6f435e79624f72841e866245d84195551cdHarinarayanan K K ****************************************************************************** 1983749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * 1993749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * @brief Puts new byte (and outstanding bytes) into bitstream after cabac 2003749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * renormalization 2013749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * 2023749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * @par Description 2033749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * 1. Extract the leading byte of low(L) 2043749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * 2. If leading byte=0xff increment outstanding bytes and return 2053749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * (as the actual bits depend on carry propogation later) 2063749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * 3. If leading byte is not 0xff check for any carry propogation 2073749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * 4. Insert the carry (propogated in previous byte) along with outstanding 2083749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * bytes (if any) and leading byte 2093749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * 2103749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * 2113749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * @param[inout] ps_cabac_ctxt 2123749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * pointer to cabac context (handle) 2133749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * 2143749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * @return 2153749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * 2163749f6f435e79624f72841e866245d84195551cdHarinarayanan K K ****************************************************************************** 2173749f6f435e79624f72841e866245d84195551cdHarinarayanan K K */ 2183749f6f435e79624f72841e866245d84195551cdHarinarayanan K Kvoid ih264e_cabac_put_byte(cabac_ctxt_t *ps_cabac_ctxt); 2193749f6f435e79624f72841e866245d84195551cdHarinarayanan K K 2203749f6f435e79624f72841e866245d84195551cdHarinarayanan K K 2213749f6f435e79624f72841e866245d84195551cdHarinarayanan K K/** 2223749f6f435e79624f72841e866245d84195551cdHarinarayanan K K ****************************************************************************** 2233749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * 2243749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * @brief Codes a bin based on probablilty and mps packed context model 2253749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * 2263749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * @par Description 2273749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * 1. Apart from encoding bin, context model is updated as per state transition 2283749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * 2. Range and Low renormalization is done based on bin and original state 2293749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * 3. After renorm bistream is updated (if required) 2303749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * 2313749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * @param[inout] ps_cabac 2323749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * pointer to cabac context (handle) 2333749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * 2343749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * @param[in] bin 2353749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * bin(boolean) to be encoded 2363749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * 2373749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * @param[in] pu1_bin_ctxts 2383749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * index of cabac context model containing pState[bits 5-0] | MPS[bit6] 2393749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * 2403749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * @return 2413749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * 2423749f6f435e79624f72841e866245d84195551cdHarinarayanan K K ****************************************************************************** 2433749f6f435e79624f72841e866245d84195551cdHarinarayanan K K */ 2443749f6f435e79624f72841e866245d84195551cdHarinarayanan K Kvoid ih264e_cabac_encode_bin(cabac_ctxt_t *ps_cabac, WORD32 bin, 2453749f6f435e79624f72841e866245d84195551cdHarinarayanan K K bin_ctxt_model *pu1_bin_ctxts); 2463749f6f435e79624f72841e866245d84195551cdHarinarayanan K K 2473749f6f435e79624f72841e866245d84195551cdHarinarayanan K K 2483749f6f435e79624f72841e866245d84195551cdHarinarayanan K K 2493749f6f435e79624f72841e866245d84195551cdHarinarayanan K K/** 2503749f6f435e79624f72841e866245d84195551cdHarinarayanan K K ******************************************************************************* 2513749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * 2523749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * @brief 2533749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * Encoding process for a binary decision :implements encoding process of a decision 2543749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * as defined in 9.3.4.2 . This function encodes multiple bins, of a symbol. Implements 2553749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * flowchart Figure 9-7( ITU_T_H264-201402) 2563749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * 2573749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * @param[in] u4_bins 2583749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * array of bin values 2593749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * 2603749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * @param[in] i1_bins_len 2613749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * Length of bins, maximum 32 2623749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * 2633749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * @param[in] u4_ctx_inc 2643749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * CtxInc, byte0- bin0, byte1-bin1 .. 2653749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * 2663749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * @param[in] i1_valid_len 2673749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * valid length of bins, after that CtxInc is constant 2683749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * 2693749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * @param[in] pu1_bin_ctxt_type 2703749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * Pointer to binary contexts 2713749f6f435e79624f72841e866245d84195551cdHarinarayanan K K 2723749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * @param[in] ps_cabac 2733749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * Pointer to cabac_context_structure 2743749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * 2753749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * @returns 2763749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * 2773749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * @remarks 2783749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * None 2793749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * 2803749f6f435e79624f72841e866245d84195551cdHarinarayanan K K ******************************************************************************* 2813749f6f435e79624f72841e866245d84195551cdHarinarayanan K K */ 2823749f6f435e79624f72841e866245d84195551cdHarinarayanan K Kvoid ih264e_encode_decision_bins(UWORD32 u4_bins, WORD8 i1_bins_len, 2833749f6f435e79624f72841e866245d84195551cdHarinarayanan K K UWORD32 u4_ctx_inc, WORD8 i1_valid_len, 2843749f6f435e79624f72841e866245d84195551cdHarinarayanan K K bin_ctxt_model *pu1_bin_ctxt_type, 2853749f6f435e79624f72841e866245d84195551cdHarinarayanan K K cabac_ctxt_t *ps_cabac); 2863749f6f435e79624f72841e866245d84195551cdHarinarayanan K K 2873749f6f435e79624f72841e866245d84195551cdHarinarayanan K K/** 2883749f6f435e79624f72841e866245d84195551cdHarinarayanan K K ******************************************************************************* 2893749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * @brief 2903749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * Encoding process for a binary decision before termination:Encoding process 2913749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * of a termination(9.3.4.5 :ITU_T_H264-201402) . Explained in flowchart 9-11. 2923749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * 2933749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * @param[in] ps_cabac 2943749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * Pointer to cabac structure 2953749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * 2963749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * @param[in] term_bin 2973749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * Symbol value, end of slice or not, term_bin is binary 2983749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * 2993749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * @returns 3003749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * 3013749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * @remarks 3023749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * None 3033749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * 3043749f6f435e79624f72841e866245d84195551cdHarinarayanan K K ******************************************************************************* 3053749f6f435e79624f72841e866245d84195551cdHarinarayanan K K */ 3063749f6f435e79624f72841e866245d84195551cdHarinarayanan K Kvoid ih264e_cabac_encode_terminate(cabac_ctxt_t *ps_cabac, WORD32 term_bin); 3073749f6f435e79624f72841e866245d84195551cdHarinarayanan K K 3083749f6f435e79624f72841e866245d84195551cdHarinarayanan K K 3093749f6f435e79624f72841e866245d84195551cdHarinarayanan K K/** 3103749f6f435e79624f72841e866245d84195551cdHarinarayanan K K ******************************************************************************* 3113749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * @brief 3123749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * Bypass encoding process for binary decisions: Explained (9.3.4.4 :ITU_T_H264-201402) 3133749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * , flowchart 9-10. 3143749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * 3153749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * @param[in] ps_cabac : pointer to cabac context (handle) 3163749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * 3173749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * @param[in] bin : bypass bin(0/1) to be encoded 3183749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * 3193749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * @returns 3203749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * 3213749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * @remarks 3223749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * None 3233749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * 3243749f6f435e79624f72841e866245d84195551cdHarinarayanan K K ******************************************************************************* 3253749f6f435e79624f72841e866245d84195551cdHarinarayanan K K */ 3263749f6f435e79624f72841e866245d84195551cdHarinarayanan K K 3273749f6f435e79624f72841e866245d84195551cdHarinarayanan K Kvoid ih264e_cabac_encode_bypass_bin(cabac_ctxt_t *ps_cabac, WORD32 bin); 3283749f6f435e79624f72841e866245d84195551cdHarinarayanan K K 3293749f6f435e79624f72841e866245d84195551cdHarinarayanan K K 3303749f6f435e79624f72841e866245d84195551cdHarinarayanan K K 3313749f6f435e79624f72841e866245d84195551cdHarinarayanan K K/** 3323749f6f435e79624f72841e866245d84195551cdHarinarayanan K K ****************************************************************************** 3333749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * 3343749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * @brief Encodes a series of bypass bins (FLC bypass bins) 3353749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * 3363749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * @par Description 3373749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * This function is more optimal than calling ih264e_cabac_encode_bypass_bin() 3383749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * in a loop as cabac low, renorm and generating the stream (8bins at a time) 3393749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * can be done in one operation 3403749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * 3413749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * @param[inout]ps_cabac 3423749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * pointer to cabac context (handle) 3433749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * 3443749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * @param[in] u4_bins 3453749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * syntax element to be coded (as FLC bins) 3463749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * 3473749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * @param[in] num_bins 3483749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * This is the FLC length for u4_sym 3493749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * 3503749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * @return 3513749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * 3523749f6f435e79624f72841e866245d84195551cdHarinarayanan K K ****************************************************************************** 3533749f6f435e79624f72841e866245d84195551cdHarinarayanan K K */ 3543749f6f435e79624f72841e866245d84195551cdHarinarayanan K K 3553749f6f435e79624f72841e866245d84195551cdHarinarayanan K Kvoid ih264e_cabac_encode_bypass_bins(cabac_ctxt_t *ps_cabac, UWORD32 u4_bins, 3563749f6f435e79624f72841e866245d84195551cdHarinarayanan K K WORD32 num_bins); 3573749f6f435e79624f72841e866245d84195551cdHarinarayanan K K 3583749f6f435e79624f72841e866245d84195551cdHarinarayanan K K 3593749f6f435e79624f72841e866245d84195551cdHarinarayanan K K 3603749f6f435e79624f72841e866245d84195551cdHarinarayanan K K 3613749f6f435e79624f72841e866245d84195551cdHarinarayanan K K 3623749f6f435e79624f72841e866245d84195551cdHarinarayanan K K/** 3633749f6f435e79624f72841e866245d84195551cdHarinarayanan K K ******************************************************************************* 3643749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * 3653749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * @brief 3663749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * This function generates CABAC coded bit stream for an Intra Slice. 3673749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * 3683749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * @description 3693749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * The mb syntax layer for intra slices constitutes luma mb mode, luma sub modes 3703749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * (if present), mb qp delta, coded block pattern, chroma mb mode and 3713749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * luma/chroma residue. These syntax elements are written as directed by table 3723749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * 7.3.5 of h264 specification. 3733749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * 3743749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * @param[in] ps_ent_ctxt 3753749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * pointer to entropy context 3763749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * 3773749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * @returns error code 3783749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * 3793749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * @remarks none 3803749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * 3813749f6f435e79624f72841e866245d84195551cdHarinarayanan K K ******************************************************************************* 3823749f6f435e79624f72841e866245d84195551cdHarinarayanan K K */ 3833749f6f435e79624f72841e866245d84195551cdHarinarayanan K KIH264E_ERROR_T ih264e_write_islice_mb_cabac(entropy_ctxt_t *ps_ent_ctxt); 3843749f6f435e79624f72841e866245d84195551cdHarinarayanan K K 3853749f6f435e79624f72841e866245d84195551cdHarinarayanan K K 3863749f6f435e79624f72841e866245d84195551cdHarinarayanan K K/** 3873749f6f435e79624f72841e866245d84195551cdHarinarayanan K K ******************************************************************************* 3883749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * 3893749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * @brief 3903749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * This function generates CABAC coded bit stream for Inter slices 3913749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * 3923749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * @description 3933749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * The mb syntax layer for inter slices constitutes luma mb mode, luma sub modes 3943749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * (if present), mb qp delta, coded block pattern, chroma mb mode and 3953749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * luma/chroma residue. These syntax elements are written as directed by table 3963749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * 7.3.5 of h264 specification 3973749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * 3983749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * @param[in] ps_ent_ctxt 3993749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * pointer to entropy context 4003749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * 4013749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * @returns error code 4023749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * 4033749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * @remarks none 4043749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * 4053749f6f435e79624f72841e866245d84195551cdHarinarayanan K K ******************************************************************************* 4063749f6f435e79624f72841e866245d84195551cdHarinarayanan K K */ 4073749f6f435e79624f72841e866245d84195551cdHarinarayanan K KIH264E_ERROR_T ih264e_write_pslice_mb_cabac(entropy_ctxt_t *ps_ent_ctxt); 4083749f6f435e79624f72841e866245d84195551cdHarinarayanan K K 4093749f6f435e79624f72841e866245d84195551cdHarinarayanan K K 4103749f6f435e79624f72841e866245d84195551cdHarinarayanan K K/** 4113749f6f435e79624f72841e866245d84195551cdHarinarayanan K K ******************************************************************************* 4123749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * 4133749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * @brief 4143749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * This function generates CABAC coded bit stream for B slices 4153749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * 4163749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * @description 4173749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * The mb syntax layer for inter slices constitutes luma mb mode, 4183749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * mb qp delta, coded block pattern, chroma mb mode and 4193749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * luma/chroma residue. These syntax elements are written as directed by table 4203749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * 7.3.5 of h264 specification 4213749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * 4223749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * @param[in] ps_ent_ctxt 4233749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * pointer to entropy context 4243749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * 4253749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * @returns error code 4263749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * 4273749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * @remarks none 4283749f6f435e79624f72841e866245d84195551cdHarinarayanan K K * 4293749f6f435e79624f72841e866245d84195551cdHarinarayanan K K ******************************************************************************* 4303749f6f435e79624f72841e866245d84195551cdHarinarayanan K K */ 4313749f6f435e79624f72841e866245d84195551cdHarinarayanan K KIH264E_ERROR_T ih264e_write_bslice_mb_cabac(entropy_ctxt_t *ps_ent_ctxt); 4323749f6f435e79624f72841e866245d84195551cdHarinarayanan K K 4333749f6f435e79624f72841e866245d84195551cdHarinarayanan K K 4343749f6f435e79624f72841e866245d84195551cdHarinarayanan K K#endif /* IH264E_CABAC_H_ */ 435