Lines Matching refs:bs

175 bitstream_start(bitstream *bs)  in bitstream_start()  argument
177 bs->max_size_in_dword = BITSTREAM_ALLOCATE_STEPPING; in bitstream_start()
178 bs->buffer = calloc(bs->max_size_in_dword * sizeof(int), 1); in bitstream_start()
179 bs->bit_offset = 0; in bitstream_start()
183 bitstream_end(bitstream *bs) in bitstream_end() argument
185 int pos = (bs->bit_offset >> 5); in bitstream_end()
186 int bit_offset = (bs->bit_offset & 0x1f); in bitstream_end()
190 bs->buffer[pos] = swap32((bs->buffer[pos] << bit_left)); in bitstream_end()
195 bitstream_put_ui(bitstream *bs, unsigned int val, int size_in_bits) in bitstream_put_ui() argument
197 int pos = (bs->bit_offset >> 5); in bitstream_put_ui()
198 int bit_offset = (bs->bit_offset & 0x1f); in bitstream_put_ui()
207 bs->bit_offset += size_in_bits; in bitstream_put_ui()
210 bs->buffer[pos] = (bs->buffer[pos] << size_in_bits | val); in bitstream_put_ui()
213 bs->buffer[pos] = (bs->buffer[pos] << bit_left) | (val >> size_in_bits); in bitstream_put_ui()
214 bs->buffer[pos] = swap32(bs->buffer[pos]); in bitstream_put_ui()
216 if (pos + 1 == bs->max_size_in_dword) { in bitstream_put_ui()
217 bs->max_size_in_dword += BITSTREAM_ALLOCATE_STEPPING; in bitstream_put_ui()
218 bs->buffer = realloc(bs->buffer, bs->max_size_in_dword * sizeof(unsigned int)); in bitstream_put_ui()
221 bs->buffer[pos + 1] = val; in bitstream_put_ui()
226 bitstream_byte_aligning(bitstream *bs, int bit) in bitstream_byte_aligning() argument
228 int bit_offset = (bs->bit_offset & 0x7); in bitstream_byte_aligning()
242 bitstream_put_ui(bs, new_val, bit_left); in bitstream_byte_aligning()
282 bitstream *bs) in sps_rbsp() argument
287 bitstream_put_ui(bs, START_CODE_SEQ, 32); in sps_rbsp()
288 bitstream_put_ui(bs, seq_param->picture_width, 12); in sps_rbsp()
289 bitstream_put_ui(bs, seq_param->picture_height, 12); in sps_rbsp()
290 bitstream_put_ui(bs, seq_param->aspect_ratio_information, 4); in sps_rbsp()
291 bitstream_put_ui(bs, frame_rate_code, 4); /* frame_rate_code */ in sps_rbsp()
292 …bitstream_put_ui(bs, (seq_param->bits_per_second + 399) / 400, 18); /* the low 18 bits of bit_rate… in sps_rbsp()
293 bitstream_put_ui(bs, 1, 1); /* marker_bit */ in sps_rbsp()
294 bitstream_put_ui(bs, seq_param->vbv_buffer_size, 10); in sps_rbsp()
295 bitstream_put_ui(bs, 0, 1); /* constraint_parameter_flag, always 0 for MPEG-2 */ in sps_rbsp()
296 bitstream_put_ui(bs, 0, 1); /* load_intra_quantiser_matrix */ in sps_rbsp()
297 bitstream_put_ui(bs, 0, 1); /* load_non_intra_quantiser_matrix */ in sps_rbsp()
299 bitstream_byte_aligning(bs, 0); in sps_rbsp()
301 bitstream_put_ui(bs, START_CODE_EXT, 32); in sps_rbsp()
302 bitstream_put_ui(bs, 1, 4); /* sequence_extension id */ in sps_rbsp()
303 bitstream_put_ui(bs, seq_param->sequence_extension.bits.profile_and_level_indication, 8); in sps_rbsp()
304 bitstream_put_ui(bs, seq_param->sequence_extension.bits.progressive_sequence, 1); in sps_rbsp()
305 bitstream_put_ui(bs, seq_param->sequence_extension.bits.chroma_format, 2); in sps_rbsp()
306 bitstream_put_ui(bs, seq_param->picture_width >> 12, 2); in sps_rbsp()
307 bitstream_put_ui(bs, seq_param->picture_height >> 12, 2); in sps_rbsp()
308 …bitstream_put_ui(bs, ((seq_param->bits_per_second + 399) / 400) >> 18, 12); /* bit_rate_extension … in sps_rbsp()
309 bitstream_put_ui(bs, 1, 1); /* marker_bit */ in sps_rbsp()
310 bitstream_put_ui(bs, seq_param->vbv_buffer_size >> 10, 8); in sps_rbsp()
311 bitstream_put_ui(bs, seq_param->sequence_extension.bits.low_delay, 1); in sps_rbsp()
312 bitstream_put_ui(bs, seq_param->sequence_extension.bits.frame_rate_extension_n, 2); in sps_rbsp()
313 bitstream_put_ui(bs, seq_param->sequence_extension.bits.frame_rate_extension_d, 5); in sps_rbsp()
315 bitstream_byte_aligning(bs, 0); in sps_rbsp()
319 bitstream_put_ui(bs, START_CODE_GOP, 32); in sps_rbsp()
320 bitstream_put_ui(bs, seq_param->gop_header.bits.time_code, 25); in sps_rbsp()
321 bitstream_put_ui(bs, seq_param->gop_header.bits.closed_gop, 1); in sps_rbsp()
322 bitstream_put_ui(bs, seq_param->gop_header.bits.broken_link, 1); in sps_rbsp()
324 bitstream_byte_aligning(bs, 0); in sps_rbsp()
331 bitstream *bs) in pps_rbsp() argument
340 bitstream_put_ui(bs, START_CODE_PICUTRE, 32); in pps_rbsp()
341 bitstream_put_ui(bs, pic_param->temporal_reference, 10); in pps_rbsp()
342 bitstream_put_ui(bs, in pps_rbsp()
346 bitstream_put_ui(bs, 0xFFFF, 16); /* vbv_delay, always 0xFFFF */ in pps_rbsp()
350 bitstream_put_ui(bs, 0, 1); /* full_pel_forward_vector, always 0 for MPEG-2 */ in pps_rbsp()
351 bitstream_put_ui(bs, 7, 3); /* forward_f_code, always 7 for MPEG-2 */ in pps_rbsp()
355 bitstream_put_ui(bs, 0, 1); /* full_pel_backward_vector, always 0 for MPEG-2 */ in pps_rbsp()
356 bitstream_put_ui(bs, 7, 3); /* backward_f_code, always 7 for MPEG-2 */ in pps_rbsp()
359 bitstream_put_ui(bs, 0, 1); /* extra_bit_picture, 0 */ in pps_rbsp()
361 bitstream_byte_aligning(bs, 0); in pps_rbsp()
363 bitstream_put_ui(bs, START_CODE_EXT, 32); in pps_rbsp()
364 bitstream_put_ui(bs, 8, 4); /* Picture Coding Extension ID: 8 */ in pps_rbsp()
365 bitstream_put_ui(bs, pic_param->f_code[0][0], 4); in pps_rbsp()
366 bitstream_put_ui(bs, pic_param->f_code[0][1], 4); in pps_rbsp()
367 bitstream_put_ui(bs, pic_param->f_code[1][0], 4); in pps_rbsp()
368 bitstream_put_ui(bs, pic_param->f_code[1][1], 4); in pps_rbsp()
370 bitstream_put_ui(bs, pic_param->picture_coding_extension.bits.intra_dc_precision, 2); in pps_rbsp()
371 bitstream_put_ui(bs, pic_param->picture_coding_extension.bits.picture_structure, 2); in pps_rbsp()
372 bitstream_put_ui(bs, pic_param->picture_coding_extension.bits.top_field_first, 1); in pps_rbsp()
373 bitstream_put_ui(bs, pic_param->picture_coding_extension.bits.frame_pred_frame_dct, 1); in pps_rbsp()
374 bitstream_put_ui(bs, pic_param->picture_coding_extension.bits.concealment_motion_vectors, 1); in pps_rbsp()
375 bitstream_put_ui(bs, pic_param->picture_coding_extension.bits.q_scale_type, 1); in pps_rbsp()
376 bitstream_put_ui(bs, pic_param->picture_coding_extension.bits.intra_vlc_format, 1); in pps_rbsp()
377 bitstream_put_ui(bs, pic_param->picture_coding_extension.bits.alternate_scan, 1); in pps_rbsp()
378 bitstream_put_ui(bs, pic_param->picture_coding_extension.bits.repeat_first_field, 1); in pps_rbsp()
379 bitstream_put_ui(bs, chroma_420_type, 1); in pps_rbsp()
380 bitstream_put_ui(bs, pic_param->picture_coding_extension.bits.progressive_frame, 1); in pps_rbsp()
381 bitstream_put_ui(bs, pic_param->picture_coding_extension.bits.composite_display_flag, 1); in pps_rbsp()
383 bitstream_byte_aligning(bs, 0); in pps_rbsp()
391 bitstream bs; in build_packed_pic_buffer() local
393 bitstream_start(&bs); in build_packed_pic_buffer()
394 pps_rbsp(seq_param, pic_param, &bs); in build_packed_pic_buffer()
395 bitstream_end(&bs); in build_packed_pic_buffer()
397 *header_buffer = (unsigned char *)bs.buffer; in build_packed_pic_buffer()
398 return bs.bit_offset; in build_packed_pic_buffer()
406 bitstream bs; in build_packed_seq_buffer() local
408 bitstream_start(&bs); in build_packed_seq_buffer()
409 sps_rbsp(ctx, seq_param, &bs); in build_packed_seq_buffer()
410 bitstream_end(&bs); in build_packed_seq_buffer()
412 *header_buffer = (unsigned char *)bs.buffer; in build_packed_seq_buffer()
413 return bs.bit_offset; in build_packed_seq_buffer()