1 /*****************************************************************************
2 * cabac.h: h264 encoder library
3 *****************************************************************************
4 * Copyright (C) 2003 Laurent Aimar
5 * $Id: cabac.h,v 1.1 2004/06/03 19:27:06 fenrir Exp $
7 * Authors: Laurent Aimar <fenrir@via.ecp.fr>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
22 *****************************************************************************/
37 int i_bits_outstanding;
38 int f8_bits_encoded; // only if using x264_cabac_size_decision()
43 /* init the contexts given i_slice_type, the quantif and the model */
44 void x264_cabac_context_init( x264_cabac_t *cb, int i_slice_type, int i_qp, int i_model );
46 /* decoder only (unused): */
47 void x264_cabac_decode_init ( x264_cabac_t *cb, bs_t *s );
48 int x264_cabac_decode_decision( x264_cabac_t *cb, int i_ctx_idx );
49 int x264_cabac_decode_bypass ( x264_cabac_t *cb );
50 int x264_cabac_decode_terminal( x264_cabac_t *cb );
53 void x264_cabac_encode_init ( x264_cabac_t *cb, bs_t *s );
54 void x264_cabac_encode_decision( x264_cabac_t *cb, int i_ctx_idx, int b );
55 void x264_cabac_encode_bypass( x264_cabac_t *cb, int b );
56 void x264_cabac_encode_terminal( x264_cabac_t *cb, int b );
57 void x264_cabac_encode_flush( x264_cabac_t *cb );
59 /* internal only. these don't write the bitstream, just calculate bit cost: */
60 void x264_cabac_size_decision( x264_cabac_t *cb, int i_ctx, int b );
61 int x264_cabac_size_decision2( uint8_t *state, int b );
62 int x264_cabac_size_decision_noup( uint8_t *state, int b );
64 static inline int x264_cabac_pos( x264_cabac_t *cb )
66 return bs_pos( cb->s ) + cb->i_bits_outstanding;