Lines Matching full:s
31 static void bs_init(struct bs *s, void *buf, int size) in bs_init() argument
33 s->buf = buf; in bs_init()
34 s->ptr = buf; in bs_init()
35 s->buf_end = s->ptr + size; in bs_init()
36 s->bits_left = 8; in bs_init()
39 static int bs_len(struct bs *s) in bs_len() argument
41 return s->ptr - s->buf; in bs_len()
44 static void bs_write(struct bs *s, int count, u32 bits) in bs_write() argument
46 if (s->ptr >= s->buf_end - 4) in bs_write()
51 if (count < s->bits_left) { in bs_write()
52 *s->ptr = (*s->ptr << count) | bits; in bs_write()
53 s->bits_left -= count; in bs_write()
56 *s->ptr = (*s->ptr << s->bits_left) | in bs_write()
57 (bits >> (count - s->bits_left)); in bs_write()
58 count -= s->bits_left; in bs_write()
59 s->ptr++; in bs_write()
60 s->bits_left = 8; in bs_write()
64 static void bs_write1(struct bs *s, u32 bit) in bs_write1() argument
66 if (s->ptr < s->buf_end) { in bs_write1()
67 *s->ptr <<= 1; in bs_write1()
68 *s->ptr |= bit; in bs_write1()
69 s->bits_left--; in bs_write1()
70 if (s->bits_left == 0) { in bs_write1()
71 s->ptr++; in bs_write1()
72 s->bits_left = 8; in bs_write1()
77 static void bs_write_ue(struct bs *s, u32 val) in bs_write_ue() argument
80 bs_write1(s, 1); in bs_write_ue()
83 bs_write(s, 2 * fls(val) - 1, val); in bs_write_ue()
87 static void bs_write_se(struct bs *s, int val) in bs_write_se() argument
89 bs_write_ue(s, val <= 0 ? -val * 2 : val * 2 - 1); in bs_write_se()
92 static void bs_rbsp_trailing(struct bs *s) in bs_rbsp_trailing() argument
94 bs_write1(s, 1); in bs_rbsp_trailing()
95 if (s->bits_left != 8) in bs_rbsp_trailing()
96 bs_write(s, s->bits_left, 0x00); in bs_rbsp_trailing()
103 struct bs bs, *s; in tw5864_h264_gen_sps_rbsp() local
105 s = &bs; in tw5864_h264_gen_sps_rbsp()
106 bs_init(s, buf, size); in tw5864_h264_gen_sps_rbsp()
107 bs_write(s, 8, 0x42); /* profile_idc, baseline */ in tw5864_h264_gen_sps_rbsp()
108 bs_write(s, 1, 1); /* constraint_set0_flag */ in tw5864_h264_gen_sps_rbsp()
109 bs_write(s, 1, 1); /* constraint_set1_flag */ in tw5864_h264_gen_sps_rbsp()
110 bs_write(s, 1, 0); /* constraint_set2_flag */ in tw5864_h264_gen_sps_rbsp()
111 bs_write(s, 5, 0); /* reserved_zero_5bits */ in tw5864_h264_gen_sps_rbsp()
112 bs_write(s, 8, 0x1e); /* level_idc */ in tw5864_h264_gen_sps_rbsp()
113 bs_write_ue(s, 0); /* seq_parameter_set_id */ in tw5864_h264_gen_sps_rbsp()
114 bs_write_ue(s, ilog2(MAX_GOP_SIZE) - 4); /* log2_max_frame_num_minus4 */ in tw5864_h264_gen_sps_rbsp()
115 bs_write_ue(s, 0); /* pic_order_cnt_type */ in tw5864_h264_gen_sps_rbsp()
117 bs_write_ue(s, ilog2(MAX_GOP_SIZE) - 4); in tw5864_h264_gen_sps_rbsp()
118 bs_write_ue(s, 1); /* num_ref_frames */ in tw5864_h264_gen_sps_rbsp()
119 bs_write(s, 1, 0); /* gaps_in_frame_num_value_allowed_flag */ in tw5864_h264_gen_sps_rbsp()
120 bs_write_ue(s, width / 16 - 1); /* pic_width_in_mbs_minus1 */ in tw5864_h264_gen_sps_rbsp()
121 bs_write_ue(s, height / 16 - 1); /* pic_height_in_map_units_minus1 */ in tw5864_h264_gen_sps_rbsp()
122 bs_write(s, 1, 1); /* frame_mbs_only_flag */ in tw5864_h264_gen_sps_rbsp()
123 bs_write(s, 1, 0); /* direct_8x8_inference_flag */ in tw5864_h264_gen_sps_rbsp()
124 bs_write(s, 1, 0); /* frame_cropping_flag */ in tw5864_h264_gen_sps_rbsp()
125 bs_write(s, 1, 0); /* vui_parameters_present_flag */ in tw5864_h264_gen_sps_rbsp()
126 bs_rbsp_trailing(s); in tw5864_h264_gen_sps_rbsp()
127 return bs_len(s); in tw5864_h264_gen_sps_rbsp()
132 struct bs bs, *s; in tw5864_h264_gen_pps_rbsp() local
134 s = &bs; in tw5864_h264_gen_pps_rbsp()
135 bs_init(s, buf, size); in tw5864_h264_gen_pps_rbsp()
136 bs_write_ue(s, 0); /* pic_parameter_set_id */ in tw5864_h264_gen_pps_rbsp()
137 bs_write_ue(s, 0); /* seq_parameter_set_id */ in tw5864_h264_gen_pps_rbsp()
138 bs_write(s, 1, 0); /* entropy_coding_mode_flag */ in tw5864_h264_gen_pps_rbsp()
139 bs_write(s, 1, 0); /* pic_order_present_flag */ in tw5864_h264_gen_pps_rbsp()
140 bs_write_ue(s, 0); /* num_slice_groups_minus1 */ in tw5864_h264_gen_pps_rbsp()
141 bs_write_ue(s, 0); /* i_num_ref_idx_l0_active_minus1 */ in tw5864_h264_gen_pps_rbsp()
142 bs_write_ue(s, 0); /* i_num_ref_idx_l1_active_minus1 */ in tw5864_h264_gen_pps_rbsp()
143 bs_write(s, 1, 0); /* weighted_pred_flag */ in tw5864_h264_gen_pps_rbsp()
144 bs_write(s, 2, 0); /* weighted_bipred_idc */ in tw5864_h264_gen_pps_rbsp()
145 bs_write_se(s, qp - 26); /* pic_init_qp_minus26 */ in tw5864_h264_gen_pps_rbsp()
146 bs_write_se(s, qp - 26); /* pic_init_qs_minus26 */ in tw5864_h264_gen_pps_rbsp()
147 bs_write_se(s, 0); /* chroma_qp_index_offset */ in tw5864_h264_gen_pps_rbsp()
148 bs_write(s, 1, 0); /* deblocking_filter_control_present_flag */ in tw5864_h264_gen_pps_rbsp()
149 bs_write(s, 1, 0); /* constrained_intra_pred_flag */ in tw5864_h264_gen_pps_rbsp()
150 bs_write(s, 1, 0); /* redundant_pic_cnt_present_flag */ in tw5864_h264_gen_pps_rbsp()
151 bs_rbsp_trailing(s); in tw5864_h264_gen_pps_rbsp()
152 return bs_len(s); in tw5864_h264_gen_pps_rbsp()
160 struct bs bs, *s; in tw5864_h264_gen_slice_head() local
163 s = &bs; in tw5864_h264_gen_slice_head()
164 bs_init(s, buf, size); in tw5864_h264_gen_slice_head()
165 bs_write_ue(s, 0); /* first_mb_in_slice */ in tw5864_h264_gen_slice_head()
166 bs_write_ue(s, is_i_frame ? 2 : 5); /* slice_type - I or P */ in tw5864_h264_gen_slice_head()
167 bs_write_ue(s, 0); /* pic_parameter_set_id */ in tw5864_h264_gen_slice_head()
168 bs_write(s, ilog2(MAX_GOP_SIZE), frame_gop_seqno); /* frame_num */ in tw5864_h264_gen_slice_head()
170 bs_write_ue(s, idr_pic_id); in tw5864_h264_gen_slice_head()
173 bs_write(s, ilog2(MAX_GOP_SIZE), frame_gop_seqno); in tw5864_h264_gen_slice_head()
176 bs_write1(s, 0); /* no_output_of_prior_pics_flag */ in tw5864_h264_gen_slice_head()
177 bs_write1(s, 0); /* long_term_reference_flag */ in tw5864_h264_gen_slice_head()
179 bs_write1(s, 0); /* num_ref_idx_active_override_flag */ in tw5864_h264_gen_slice_head()
180 bs_write1(s, 0); /* ref_pic_list_reordering_flag_l0 */ in tw5864_h264_gen_slice_head()
181 bs_write1(s, 0); /* adaptive_ref_pic_marking_mode_flag */ in tw5864_h264_gen_slice_head()
184 bs_write_se(s, 0); /* slice_qp_delta */ in tw5864_h264_gen_slice_head()
186 if (s->bits_left != 8) { in tw5864_h264_gen_slice_head()
187 *tail = ((s->ptr[0]) << s->bits_left); in tw5864_h264_gen_slice_head()
188 *tail_nb_bits = 8 - s->bits_left; in tw5864_h264_gen_slice_head()
194 return bs_len(s); in tw5864_h264_gen_slice_head()