void x264_sei_pic_timing_write( x264_t *h, bs_t *s ) { x264_sps_t *sps = h->sps; bs_t q; uint8_t tmp_buf[100]; bs_init( &q, tmp_buf, 100 ); bs_realign( &q ); if( sps->vui.b_nal_hrd_parameters_present || sps->vui.b_vcl_hrd_parameters_present ) { bs_write( &q, sps->vui.hrd.i_cpb_removal_delay_length, h->fenc->i_cpb_delay - h->i_cpb_delay_pir_offset ); bs_write( &q, sps->vui.hrd.i_dpb_output_delay_length, h->fenc->i_dpb_output_delay ); } if( sps->vui.b_pic_struct_present ) { bs_write( &q, 4, h->fenc->i_pic_struct-1 ); // We use index 0 for "Auto" // These clock timestamps are not standardised so we don't set them // They could be time of origin, capture or alternative ideal display for( int i = 0; i < num_clock_ts[h->fenc->i_pic_struct]; i++ ) bs_write1( &q, 0 ); // clock_timestamp_flag } bs_align_10( &q ); bs_flush( &q ); x264_sei_write( s, tmp_buf, bs_pos( &q ) / 8, SEI_PIC_TIMING ); }
static void write_invalid( bs_t *s ) { bs_write1( s, 0 ); // cc_valid bs_write( s, 2, 2 ); // cc_type bs_write( s, 8, 0 ); // c_data_1 bs_write( s, 8, 0 ); // c_data_2 }
static int write_rtp_pkt( hnd_t handle, uint8_t *data, int len, int64_t timestamp ) { obe_rtp_ctx *p_rtp = handle; uint8_t pkt[RTP_HEADER_SIZE+TS_PACKETS_SIZE]; bs_t s; bs_init( &s, pkt, RTP_HEADER_SIZE+TS_PACKETS_SIZE ); bs_write( &s, 2, RTP_VERSION ); // version bs_write1( &s, 0 ); // padding bs_write1( &s, 0 ); // extension bs_write( &s, 4, 0 ); // CSRC count bs_write1( &s, 0 ); // marker bs_write( &s, 7, MPEG_TS_PAYLOAD_TYPE ); // payload type bs_write( &s, 16, p_rtp->seq++ ); // sequence number bs_write32( &s, timestamp / 300 ); // timestamp bs_write32( &s, p_rtp->ssrc ); // ssrc bs_flush( &s ); memcpy( &pkt[RTP_HEADER_SIZE], data, len ); if( udp_write( p_rtp->udp_handle, pkt, RTP_HEADER_SIZE+TS_PACKETS_SIZE ) < 0 ) return -1; p_rtp->pkt_cnt++; p_rtp->octet_cnt += len; return 0; }
void x264_sei_pic_timing_write( x264_t *h, bs_t *s ) { x264_sps_t *sps = h->sps; bs_realign( s ); uint8_t *p_start = x264_sei_write_header( s, SEI_PIC_TIMING ); if( sps->vui.b_nal_hrd_parameters_present || sps->vui.b_vcl_hrd_parameters_present ) { bs_write( s, sps->vui.hrd.i_cpb_removal_delay_length, h->fenc->i_cpb_delay ); bs_write( s, sps->vui.hrd.i_dpb_output_delay_length, h->fenc->i_dpb_output_delay ); } if( sps->vui.b_pic_struct_present ) { bs_write( s, 4, h->fenc->i_pic_struct-1 ); // We use index 0 for "Auto" // These clock timestamps are not standardised so we don't set them // They could be time of origin, capture or alternative ideal display for( int i = 0; i < num_clock_ts[h->fenc->i_pic_struct]; i++ ) bs_write1( s, 0 ); // clock_timestamp_flag } x264_sei_write( s, p_start ); bs_flush( s ); }
void x264_sei_version_write( x264_t *h, bs_t *s ) { int i; // random ID number generated according to ISO-11578 const uint8_t uuid[16] = { 0xdc, 0x45, 0xe9, 0xbd, 0xe6, 0xd9, 0x48, 0xb7, 0x96, 0x2c, 0xd8, 0x20, 0xd9, 0x23, 0xee, 0xef }; char *opts = x264_param2string( &h->param, 0 ); char *version = x264_malloc( 200 + strlen(opts) ); int length; sprintf( version, "x264 - core %d%s - H.264/MPEG-4 AVC codec - " "Copyleft 2003-2008 - http://www.videolan.org/x264.html - options: %s", X264_BUILD, X264_VERSION, opts ); length = strlen(version)+1+16; bs_write( s, 8, 0x5 ); // payload_type = user_data_unregistered // payload_size for( i = 0; i <= length-255; i += 255 ) bs_write( s, 8, 255 ); bs_write( s, 8, length-i ); for( i = 0; i < 16; i++ ) bs_write( s, 8, uuid[i] ); for( i = 0; i < length-16; i++ ) bs_write( s, 8, version[i] ); bs_rbsp_trailing( s ); x264_free( opts ); x264_free( version ); }
static void scaling_list_write( bs_t *s, x264_pps_t *pps, int idx ) { const int len = idx<4 ? 16 : 64; const uint8_t *zigzag = idx<4 ? x264_zigzag_scan4[0] : x264_zigzag_scan8[0]; const uint8_t *list = pps->scaling_list[idx]; const uint8_t *def_list = (idx==CQM_4IC) ? pps->scaling_list[CQM_4IY] : (idx==CQM_4PC) ? pps->scaling_list[CQM_4PY] : x264_cqm_jvt[idx]; if( !memcmp( list, def_list, len ) ) bs_write( s, 1, 0 ); // scaling_list_present_flag else if( !memcmp( list, x264_cqm_jvt[idx], len ) ) { bs_write( s, 1, 1 ); // scaling_list_present_flag bs_write_se( s, -8 ); // use jvt list } else { int j, run; bs_write( s, 1, 1 ); // scaling_list_present_flag // try run-length compression of trailing values for( run = len; run > 1; run-- ) if( list[zigzag[run-1]] != list[zigzag[run-2]] ) break; if( run < len && len - run < bs_size_se( (int8_t)-list[zigzag[run]] ) ) run = len; for( j = 0; j < run; j++ ) bs_write_se( s, (int8_t)(list[zigzag[j]] - (j>0 ? list[zigzag[j-1]] : 8)) ); // delta if( run < len ) bs_write_se( s, (int8_t)-list[zigzag[run]] ); } }
void xavs_sei_version_write (xavs_t * h, bs_t * s) { int i; // random ID number generated according to ISO-11578 const uint8_t uuid[16] = { 0xdc, 0x45, 0xe9, 0xbd, 0xe6, 0xd9, 0x48, 0xb7, 0x96, 0x2c, 0xd8, 0x20, 0xd9, 0x23, 0xee, 0xef }; char version[1200]; int length; char *opts = xavs_param2string (&h->param, 0); sprintf (version, "xavs - %d%s - AVS video codec - " "Copyleft 2009 - http://xavs.sourceforge.net - options: %s", XAVS_BUILD, XAVS_VERSION, opts); xavs_free (opts); length = (int) strlen (version) + 1 + 16; bs_write (s, 8, 0x5); // payload_type = user_data_unregistered // payload_size for (i = 0; i <= length - 255; i += 255) bs_write (s, 8, 255); bs_write (s, 8, length - i); for (i = 0; i < 16; i++) bs_write (s, 8, uuid[i]); for (i = 0; i < length - 16; i++) bs_write (s, 8, version[i]); bs_rbsp_trailing (s); }
void x264_sei_version_write( bs_t *s ) { int i; // random ID number generated according to ISO-11578 const uint8_t uuid[16] = { 0xdc, 0x45, 0xe9, 0xbd, 0xe6, 0xd9, 0x48, 0xb7, 0x96, 0x2c, 0xd8, 0x20, 0xd9, 0x23, 0xee, 0xef }; char version[256]; int length; sprintf( version, "x264 - core %d%s - H.264/MPEG-4 AVC codec - Copyleft 2005 - http://www.videolan.org/x264.html", X264_BUILD, X264_VERSION ); length = strlen(version)+1+16; bs_write( s, 8, 0x5 ); // payload_type = user_data_unregistered while( length > 255 ) bs_write( s, 8, 255 ), length -= 255; bs_write( s, 8, length ); // payload_size for( i = 0; i < 16; i++ ) bs_write( s, 8, uuid[i] ); for( i = 0; i < length-16; i++ ) bs_write( s, 8, version[i] ); bs_rbsp_trailing( s ); }
static int write_rtcp_pkt( hnd_t handle ) { obe_rtp_ctx *p_rtp = handle; uint64_t ntp_time = obe_ntp_time(); uint8_t pkt[100]; bs_t s; bs_init( &s, pkt, RTCP_PACKET_SIZE ); bs_write( &s, 2, RTP_VERSION ); // version bs_write1( &s, 0 ); // padding bs_write( &s, 5, 0 ); // reception report count bs_write( &s, 8, RTCP_SR_PACKET_TYPE ); // packet type bs_write( &s, 8, 6 ); // length (length in words - 1) bs_write32( &s, p_rtp->ssrc ); // ssrc bs_write32( &s, ntp_time / 1000000 ); // NTP timestamp, most significant word bs_write32( &s, ((ntp_time % 1000000) << 32) / 1000000 ); // NTP timestamp, least significant word bs_write32( &s, 0 ); // RTP timestamp FIXME bs_write32( &s, p_rtp->pkt_cnt ); // sender's packet count bs_write32( &s, p_rtp->octet_cnt ); // sender's octet count bs_flush( &s ); if( udp_write( p_rtp->udp_handle, pkt, RTCP_PACKET_SIZE ) < 0 ) return -1; return 0; }
static void write_itu_t_codes( bs_t *s ) { const int country_code = 0xb5; const int provider_code = 0x31; bs_write( s, 8, country_code ); // itu_t_t35_country_code bs_write( s, 16, provider_code ); // itu_t_t35_provider_code }
static uint8_t *x264_sei_write_header( bs_t *s, int payload_type ) { bs_write( s, 8, payload_type ); bs_flush( s ); uint8_t *p_start = s->p; bs_realign( s ); bs_write( s, 8, 0 ); return p_start; }
//7.3.2.11 RBSP trailing bits syntax void write_rbsp_trailing_bits(bs_t* b) { int rbsp_stop_one_bit = 1; int rbsp_alignment_zero_bit = 0; bs_write(b, 1, rbsp_stop_one_bit); // equal to 1 while (!bs_byte_aligned(b)) { bs_write(b, 1, rbsp_alignment_zero_bit); // equal to 0 } }
void x264_sei_recovery_point_write( x264_t *h, bs_t *s, int recovery_frame_cnt ) { bs_realign( s ); uint8_t *p_start = x264_sei_write_header( s, SEI_RECOVERY_POINT ); bs_write_ue( s, recovery_frame_cnt ); // recovery_frame_cnt bs_write( s, 1, 1 ); //exact_match_flag 1 bs_write( s, 1, 0 ); //broken_link_flag 0 bs_write( s, 2, 0 ); //changing_slice_group 0 x264_sei_write( s, p_start ); bs_flush( s ); }
static int write_708_cc( obe_user_data_t *user_data, uint8_t *start, int cc_count ) { bs_t s; uint8_t temp[1000]; const char *user_identifier = "GA94"; const int data_type_code = 0x03; /* TODO: when MPEG-2 is added make this do the right thing */ /* FIXME: enable echostar captions and add more types */ bs_init( &s, temp, 1000 ); /* N.B MPEG-4 only */ write_itu_t_codes( &s ); for( int i = 0; i < 4; i++ ) bs_write( &s, 8, user_identifier[i] ); // user_identifier bs_write( &s, 8, data_type_code ); // user_data_type_code // user_data_type_structure (echostar) // cc_data bs_write1( &s, 1 ); // reserved bs_write1( &s, 1 ); // process_cc_data_flag bs_write1( &s, 0 ); // zero_bit / additional_data_flag bs_write( &s, 5, cc_count ); // cc_count bs_write( &s, 8, 0xff ); // reserved write_bytes( &s, start, cc_count*3 ); bs_write( &s, 8, 0xff ); // marker_bits bs_flush( &s ); user_data->type = USER_DATA_AVC_REGISTERED_ITU_T35; user_data->len = bs_pos( &s ) >> 3; free( user_data->data ); user_data->data = malloc( user_data->len ); if( !user_data->data ) { syslog( LOG_ERR, "Malloc failed\n" ); return -1; } memcpy( user_data->data, temp, user_data->len ); return 0; }
void x264_sps_write( bs_t *s, x264_sps_t *sps ) { bs_realign( s ); bs_write( s, 8, sps->i_profile_idc ); bs_write1( s, sps->b_constraint_set0 ); bs_write1( s, sps->b_constraint_set1 ); bs_write1( s, sps->b_constraint_set2 ); bs_write1( s, sps->b_constraint_set3 ); bs_write( s, 4, 0 ); /* reserved */ bs_write( s, 8, sps->i_level_idc ); bs_write_ue( s, sps->i_id ); if( sps->i_profile_idc >= PROFILE_HIGH ) { bs_write_ue( s, sps->i_chroma_format_idc ); if( sps->i_chroma_format_idc == CHROMA_444 ) bs_write1( s, 0 ); // separate_colour_plane_flag bs_write_ue( s, BIT_DEPTH-8 ); // bit_depth_luma_minus8 bs_write_ue( s, BIT_DEPTH-8 ); // bit_depth_chroma_minus8 bs_write1( s, sps->b_qpprime_y_zero_transform_bypass ); bs_write1( s, 0 ); // seq_scaling_matrix_present_flag } bs_write_ue( s, sps->i_log2_max_frame_num - 4 ); bs_write_ue( s, sps->i_poc_type ); if( sps->i_poc_type == 0 ) bs_write_ue( s, sps->i_log2_max_poc_lsb - 4 ); bs_write_ue( s, sps->i_num_ref_frames ); bs_write1( s, sps->b_gaps_in_frame_num_value_allowed ); bs_write_ue( s, sps->i_mb_width - 1 ); bs_write_ue( s, (sps->i_mb_height >> !sps->b_frame_mbs_only) - 1); bs_write1( s, sps->b_frame_mbs_only ); if( !sps->b_frame_mbs_only ) bs_write1( s, sps->b_mb_adaptive_frame_field ); bs_write1( s, sps->b_direct8x8_inference ); bs_write1( s, sps->b_crop ); if( sps->b_crop ) { int h_shift = sps->i_chroma_format_idc == CHROMA_420 || sps->i_chroma_format_idc == CHROMA_422; int v_shift = sps->i_chroma_format_idc == CHROMA_420; bs_write_ue( s, sps->crop.i_left >> h_shift ); bs_write_ue( s, sps->crop.i_right >> h_shift ); bs_write_ue( s, sps->crop.i_top >> v_shift ); bs_write_ue( s, sps->crop.i_bottom >> v_shift ); }
void x264_sei_buffering_period_write( x264_t *h, bs_t *s ) { x264_sps_t *sps = h->sps; bs_realign( s ); uint8_t *p_start = x264_sei_write_header( s, SEI_BUFFERING_PERIOD ); bs_write_ue( s, sps->i_id ); if( sps->vui.b_nal_hrd_parameters_present ) { bs_write( s, sps->vui.hrd.i_initial_cpb_removal_delay_length, h->initial_cpb_removal_delay ); bs_write( s, sps->vui.hrd.i_initial_cpb_removal_delay_length, h->initial_cpb_removal_delay_offset ); } x264_sei_write( s, p_start ); bs_flush( s ); }
static void scaling_list_write( bs_t *s, x264_pps_t *pps, int idx ) { const int len = idx<4 ? 16 : 64; const int *zigzag = idx<4 ? x264_zigzag_scan4 : x264_zigzag_scan8; const uint8_t *list = pps->scaling_list[idx]; const uint8_t *def_list = (idx==CQM_4IC) ? pps->scaling_list[CQM_4IY] : (idx==CQM_4PC) ? pps->scaling_list[CQM_4PY] : x264_cqm_jvt[idx]; int j; if( memcmp( list, def_list, len ) ) { bs_write( s, 1, 1 ); // scaling_list_present_flag for( j = 0; j < len; j++ ) bs_write_se( s, list[zigzag[j]] - (j>0 ? list[zigzag[j-1]] : 8) ); // delta } else bs_write( s, 1, 0 ); // scaling_list_present_flag }
int x264_sei_version_write( x264_t *h, bs_t *s ) { int i; // random ID number generated according to ISO-11578 static const uint8_t uuid[16] = { 0xdc, 0x45, 0xe9, 0xbd, 0xe6, 0xd9, 0x48, 0xb7, 0x96, 0x2c, 0xd8, 0x20, 0xd9, 0x23, 0xee, 0xef }; char *opts = x264_param2string( &h->param, 0 ); char *version; int length; if( !opts ) return -1; CHECKED_MALLOC( version, 200 + strlen( opts ) ); sprintf( version, "x264 - core %d%s - H.264/MPEG-4 AVC codec - " "Copyleft 2003-2010 - http://www.videolan.org/x264.html - options: %s", X264_BUILD, X264_VERSION, opts ); length = strlen(version)+1+16; bs_realign( s ); bs_write( s, 8, SEI_USER_DATA_UNREGISTERED ); // payload_size for( i = 0; i <= length-255; i += 255 ) bs_write( s, 8, 255 ); bs_write( s, 8, length-i ); for( int j = 0; j < 16; j++ ) bs_write( s, 8, uuid[j] ); for( int j = 0; j < length-16; j++ ) bs_write( s, 8, version[j] ); bs_rbsp_trailing( s ); bs_flush( s ); x264_free( opts ); x264_free( version ); return 0; fail: x264_free( opts ); return -1; }
void x264_filler_write( x264_t *h, bs_t *s, int filler ) { bs_realign( s ); for( int i = 0; i < filler; i++ ) bs_write( s, 8, 0xff ); bs_rbsp_trailing( s ); bs_flush( s ); }
void x264_sei_write( bs_t *s, uint8_t *payload, int payload_size, int payload_type ) { int i; bs_realign( s ); for( i = 0; i <= payload_type-255; i += 255 ) bs_write( s, 8, 255 ); bs_write( s, 8, payload_type-i ); for( i = 0; i <= payload_size-255; i += 255 ) bs_write( s, 8, 255 ); bs_write( s, 8, payload_size-i ); for( i = 0; i < payload_size; i++ ) bs_write( s, 8, payload[i] ); bs_rbsp_trailing( s ); bs_flush( s ); }
void x264_sei_buffering_period_write( x264_t *h, bs_t *s ) { x264_sps_t *sps = h->sps; bs_t q; uint8_t tmp_buf[100]; bs_init( &q, tmp_buf, 100 ); bs_realign( &q ); bs_write_ue( &q, sps->i_id ); if( sps->vui.b_nal_hrd_parameters_present ) { bs_write( &q, sps->vui.hrd.i_initial_cpb_removal_delay_length, h->initial_cpb_removal_delay ); bs_write( &q, sps->vui.hrd.i_initial_cpb_removal_delay_length, h->initial_cpb_removal_delay_offset ); } bs_align_10( &q ); bs_flush( &q ); x264_sei_write( s, tmp_buf, bs_pos( &q ) / 8, SEI_BUFFERING_PERIOD ); }
void xavs_i_picture_write (bs_t * s, xavs_i_pic_header_t * ih, xavs_seq_header_t * sqh) { bs_write (s, 8, 0xB3); //ih->i_i_picture_start_code); bs_write (s, 16, ih->i_bbv_delay); bs_write1 (s, ih->b_time_code_flag); if (ih->b_time_code_flag) bs_write (s, 24, ih->i_time_code); bs_write1 (s, 1); //marker bit bs_write (s, 8, ih->i_picture_distance); if (sqh->b_low_delay) bs_write_ue (s, 1); //ih->i_bbv_check_times); bs_write1 (s, ih->b_progressive_frame); if (!ih->b_progressive_frame) bs_write1 (s, ih->b_picture_structure); bs_write1 (s, 1); //ih->b_top_field_first); bs_write1 (s, 0); //ih->b_repeat_first_field); bs_write1 (s, ih->b_fixed_picture_qp); bs_write (s, 6, ih->i_picture_qp); //if(!ih->b_progressive_frame && !ih->b_picture_structure) //bs_write1( s, ih->b_skip_mode_flag); bs_write (s, 4, ih->i_reserved_bits); bs_write1 (s, ih->b_loop_filter_disable); if (!ih->b_loop_filter_disable) bs_write1 (s, ih->b_loop_filter_parameter_flag); if (ih->b_loop_filter_parameter_flag) { bs_write_se (s, ih->i_alpha_c_offset); bs_write_se (s, ih->i_beta_offset); } bs_rbsp_trailing (s); }
void xavs_pb_picture_write (bs_t * s, xavs_pb_pic_header_t * pbh, xavs_seq_header_t * sqh) { bs_write (s, 8, pbh->i_pb_picture_start_code); bs_write (s, 16, pbh->i_bbv_delay); bs_write (s, 2, pbh->i_picture_coding_type); bs_write (s, 8, pbh->i_picture_distance); if (sqh->b_low_delay) bs_write_ue (s, 1); //pbh->i_bbv_check_times); bs_write1 (s, 1); //pbh->b_progressive_frame); /*if(!pbh->b_progressive_frame){ bs_write1( s, pbh->b_picture_structure); if(!pbh->b_picture_structure) bs_write1( s, pbh->b_advanced_pred_mode_disable); } */ bs_write1 (s, 0); //pbh->b_top_field_first); bs_write1 (s, 0); //pbh->b_repeat_first_field); bs_write1 (s, pbh->b_fixed_picture_qp); bs_write (s, 6, pbh->i_picture_qp); if (pbh->i_picture_coding_type == 1) bs_write1 (s, pbh->b_picture_reference_flag); //bs_write1( s, pbh->b_no_forward_reference_flag); bs_write (s, 4, 0); //reserved bits bs_write1 (s, 1); //pbh->b_skip_mode_flag); bs_write1 (s, pbh->b_loop_filter_disable); if (!pbh->b_loop_filter_disable) bs_write1 (s, pbh->b_loop_filter_parameter_flag); if (pbh->b_loop_filter_parameter_flag) { bs_write_se (s, pbh->i_alpha_c_offset); bs_write_se (s, pbh->i_beta_offset); } bs_rbsp_trailing (s); }
void flacHeader::writeStreamInfo(uint8_t* buf, FLAC__StreamMetadata *meta) { bs_t bits; bs_init( &bits, (void*)buf, 18 ); bs_write( &bits, 16, meta->data.stream_info.min_blocksize ); bs_write( &bits, 16, meta->data.stream_info.max_blocksize ); bs_write( &bits, 24, meta->data.stream_info.min_framesize ); bs_write( &bits, 24, meta->data.stream_info.max_framesize ); bs_write( &bits, 20, meta->data.stream_info.sample_rate ); bs_write( &bits, 3, meta->data.stream_info.channels - 1); bs_write( &bits, 5, meta->data.stream_info.bits_per_sample - 1); bs_write( &bits, 36, meta->data.stream_info.total_samples ); memcpy( buf+18, meta->data.stream_info.md5sum, 16 ); }
void bs_flush_byte(struct bitstream_st *bs) { u_int8_t *endp; assert(INRANGE(bs->byte_end, bs->byte_window, AFTER_OF(bs->byte_window))); assert(INRANGE(bs->byte_p, bs->byte_window, bs->byte_end)); endp = bs->byte_p; bs->byte_p = bs->byte_window; if (bs->blocked) return; bs_write(bs, bs->byte_window, endp - bs->byte_window); } /* bs_flush_byte */
static PyObject * bus_write_2(PyObject *self, PyObject *args) { long ofs; int rid; uint16_t val; if (!PyArg_ParseTuple(args, "ilH", &rid, &ofs, &val)) return (NULL); if (!bs_write(rid, ofs, &val, sizeof(val))) { PyErr_SetString(PyExc_IOError, strerror(errno)); return (NULL); } Py_RETURN_NONE; }
void x264_pps_write( bs_t *s, x264_pps_t *pps ) { bs_realign( s ); bs_write_ue( s, pps->i_id ); bs_write_ue( s, pps->i_sps_id ); bs_write1( s, pps->b_cabac ); bs_write1( s, pps->b_pic_order ); bs_write_ue( s, pps->i_num_slice_groups - 1 ); bs_write_ue( s, pps->i_num_ref_idx_l0_default_active - 1 ); bs_write_ue( s, pps->i_num_ref_idx_l1_default_active - 1 ); bs_write1( s, pps->b_weighted_pred ); bs_write( s, 2, pps->b_weighted_bipred ); bs_write_se( s, pps->i_pic_init_qp - 26 - QP_BD_OFFSET ); bs_write_se( s, pps->i_pic_init_qs - 26 - QP_BD_OFFSET ); bs_write_se( s, pps->i_chroma_qp_index_offset ); bs_write1( s, pps->b_deblocking_filter_control ); bs_write1( s, pps->b_constrained_intra_pred ); bs_write1( s, pps->b_redundant_pic_cnt ); if( pps->b_transform_8x8_mode || pps->i_cqm_preset != X264_CQM_FLAT ) { bs_write1( s, pps->b_transform_8x8_mode ); bs_write1( s, (pps->i_cqm_preset != X264_CQM_FLAT) ); if( pps->i_cqm_preset != X264_CQM_FLAT ) { scaling_list_write( s, pps, CQM_4IY ); scaling_list_write( s, pps, CQM_4IC ); bs_write1( s, 0 ); // Cr = Cb scaling_list_write( s, pps, CQM_4PY ); scaling_list_write( s, pps, CQM_4PC ); bs_write1( s, 0 ); // Cr = Cb if( pps->b_transform_8x8_mode ) { scaling_list_write( s, pps, CQM_8IY+4 ); scaling_list_write( s, pps, CQM_8PY+4 ); } } bs_write_se( s, pps->i_chroma_qp_index_offset ); } bs_rbsp_trailing( s ); bs_flush( s ); }
void x264_sei_recovery_point_write( x264_t *h, bs_t *s, int recovery_frame_cnt ) { bs_t q; uint8_t tmp_buf[100]; bs_init( &q, tmp_buf, 100 ); bs_realign( &q ); bs_write_ue( &q, recovery_frame_cnt ); // recovery_frame_cnt bs_write1( &q, 1 ); //exact_match_flag 1 bs_write1( &q, 0 ); //broken_link_flag 0 bs_write( &q, 2, 0 ); //changing_slice_group 0 bs_align_10( &q ); bs_flush( &q ); x264_sei_write( s, tmp_buf, bs_pos( &q ) / 8, SEI_RECOVERY_POINT ); }
//Appendix E.1.2 HRD parameters syntax void write_hrd_parameters(sps_t *sps, bs_t* b) { int SchedSelIdx; bs_write_ue(b, sps->hrd.cpb_cnt_minus1); bs_write(b, 4, sps->hrd.bit_rate_scale); bs_write(b, 4, sps->hrd.cpb_size_scale); for (SchedSelIdx = 0; SchedSelIdx <= sps->hrd.cpb_cnt_minus1; SchedSelIdx++) { bs_write_ue(b, sps->hrd.bit_rate_value_minus1[SchedSelIdx]); bs_write_ue(b, sps->hrd.cpb_size_value_minus1[SchedSelIdx]); bs_write(b, 1, sps->hrd.cbr_flag[SchedSelIdx]); } bs_write(b, 5, sps->hrd.initial_cpb_removal_delay_length_minus1); bs_write(b, 5, sps->hrd.cpb_removal_delay_length_minus1); bs_write(b, 5, sps->hrd.dpb_output_delay_length_minus1); bs_write(b, 5, sps->hrd.time_offset_length); }
void x264_sei_frame_packing_write( x264_t *h, bs_t *s ) { bs_t q; uint8_t tmp_buf[100]; bs_init( &q, tmp_buf, 100 ); bs_realign( &q ); bs_write_ue( &q, 0 ); // frame_packing_arrangement_id bs_write1( &q, 0 ); // frame_packing_arrangement_cancel_flag bs_write ( &q, 7, h->param.i_frame_packing ); // frame_packing_arrangement_type bs_write1( &q, 0 ); // quincunx_sampling_flag // 0: views are unrelated, 1: left view is on the left, 2: left view is on the right bs_write ( &q, 6, 1 ); // content_interpretation_type bs_write1( &q, 0 ); // spatial_flipping_flag bs_write1( &q, 0 ); // frame0_flipped_flag bs_write1( &q, 0 ); // field_views_flag bs_write1( &q, h->param.i_frame_packing == 5 && !(h->fenc->i_frame&1) ); // current_frame_is_frame0_flag bs_write1( &q, 0 ); // frame0_self_contained_flag bs_write1( &q, 0 ); // frame1_self_contained_flag if ( /* quincunx_sampling_flag == 0 && */ h->param.i_frame_packing != 5 ) { bs_write( &q, 4, 0 ); // frame0_grid_position_x bs_write( &q, 4, 0 ); // frame0_grid_position_y bs_write( &q, 4, 0 ); // frame1_grid_position_x bs_write( &q, 4, 0 ); // frame1_grid_position_y } bs_write( &q, 8, 0 ); // frame_packing_arrangement_reserved_byte bs_write_ue( &q, 1 ); // frame_packing_arrangement_repetition_period bs_write1( &q, 0 ); // frame_packing_arrangement_extension_flag bs_align_10( &q ); bs_flush( &q ); x264_sei_write( s, tmp_buf, bs_pos( &q ) / 8, SEI_FRAME_PACKING ); }