当前位置: 首页>>代码示例>>C++>>正文


C++ read_bit函数代码示例

本文整理汇总了C++中read_bit函数的典型用法代码示例。如果您正苦于以下问题:C++ read_bit函数的具体用法?C++ read_bit怎么用?C++ read_bit使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了read_bit函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: getbuttonstate

int getbuttonstate()
{
	FILE *in;
	int ret;

#ifdef HAVE_STORM
	ret = read_bit(60);
#elif HAVE_WG302V1
	ret = read_bit(13);
#elif HAVE_WG302
	ret = read_bit(3);
#elif HAVE_MI424WR
	ret = read_bit(10);
#elif HAVE_USR8200
	ret = read_bit(12);
#elif HAVE_CAMBRIA
	if (isGW2350())
		ret = read_bit(4);
	else
		ret = read_bit(20);
#else
	if (isCompex())
		ret = read_bit(0);
	if (isGW2369())
		ret = read_bit(3);
	else
		ret = read_bit(4);
#endif
#ifdef HAVE_TONZE
	return ret == 0 ? 0 : 1;
#else
	return ret == 0 ? 1 : 0;
#endif
}
开发者ID:rogerhu,项目名称:dd-wrt,代码行数:34,代码来源:resetbutton.c

示例2: parse_pes

/*!
 * \brief Parse PES packet.
 * \param *bitstr: The bitstream to use.
 * \param *header: A pointer to a PES header structure.
 * \param *packet: A pointer to a PES packet structure.
 * \return 1 if succeed, 0 otherwise.
 *
 * From 'ISO/IEC 13818-1' specification:
 * 2.4.3.6 PES packet.
 * Table 2-17 – PES packet.
 *
 * Parse both MPEG-1 (ISO/IEC 11172-1) and MPEG-2 (ISO/IEC 13818-1) PES packets.
 */
int parse_pes(Bitstream_t *bitstr, PesHeader_t *header, PesPacket_t *packet)
{
    TRACE_2(MPS, "> parse_pes()");
    int retcode = SUCCESS;

    TRACE_INFO(MPS, "parse_pes() 0x%X @ %lli",
               header->start_code, bitstream_get_absolute_byte_offset(bitstr));

    // "regular" PES packet?
    if ((header->stream_id != SID_PROGRAM_STREAM_MAP) &&
        (header->stream_id != SID_PADDING) &&
        (header->stream_id != SID_PRIVATE_STREAM_2) &&
        (header->stream_id != SID_ECM_STREAM) &&
        (header->stream_id != SID_EMM_STREAM) &&
        (header->stream_id != SID_PROGRAM_STREAM_DIRECTORY) &&
        (header->stream_id != SID_DSMCC_STREAM) &&
        (header->stream_id != SID_2221E))
    {
        unsigned checkversion = next_bits(bitstr, 2);

        // Parse MPEG-2 PES header
        if ((checkversion & 0x02) == 0x02)
        {
            packet->mpeg_version = 2;

            if (read_bits(bitstr, 2) != 2)
            {
                TRACE_ERROR(MPS, "wrong 'marker_bits'");
                return FAILURE;
            }

            packet->PES_scrambling_control = read_bits(bitstr, 2);
            packet->PES_priority = read_bit(bitstr);
            packet->data_alignment_indicator = read_bit(bitstr);
            packet->copyright = read_bit(bitstr);
            packet->original_or_copy = read_bit(bitstr);
            packet->PTS_DTS_flag = read_bits(bitstr, 2);
            packet->ESCR_flag = read_bit(bitstr);
            packet->ES_rate_flag = read_bit(bitstr);
            packet->DSM_trick_mode_flag = read_bit(bitstr);
            packet->additional_copy_info_flag = read_bit(bitstr);
            packet->PES_CRC_flag = read_bit(bitstr);
            packet->PES_extension_flag = read_bit(bitstr);
            packet->PES_header_data_length = read_bits(bitstr, 8);

            if (packet->PTS_DTS_flag == 2)
            {
                if (read_bits(bitstr, 4) != 2)
                {
                    TRACE_ERROR(MPS, "wrong 'marker_bit'");
                    return FAILURE;
                }
                packet->PTS = read_bits(bitstr, 3) << 30;
                MARKER_BIT
                packet->PTS += read_bits(bitstr, 15) << 15;
                MARKER_BIT
                packet->PTS += read_bits(bitstr, 15);
                MARKER_BIT
            }
            else if (packet->PTS_DTS_flag == 3)
开发者ID:emericg,项目名称:MiniVideo,代码行数:73,代码来源:pes.cpp

示例3: read_chunk_regs

void read_chunk_regs(void *fptr, int action)
{
    struct user user;
    struct cp_sparc_window_regs or;
    int stopped;
    read_bit(fptr, &user, sizeof(struct user));
    read_bit(fptr, &stopped, sizeof(int));
    read_bit(fptr, &or, sizeof(struct cp_sparc_window_regs));
    /*
    if (action & ACTION_PRINT) {
	fprintf(stderr, "(registers): Process was %sstopped\n",
		stopped?"":"not ");
	fprintf(stderr, "\teax: 0x%08lx ebx: 0x%08lx ecx: 0x%08lx edx: 0x%08lx\n",
		user.regs.eax, user.regs.ebx, user.regs.ecx, user.regs.edx);
	fprintf(stderr, "\tesi: 0x%08lx edi: 0x%08lx ebp: 0x%08lx esp: 0x%08lx\n",
		user.regs.esi, user.regs.edi, user.regs.ebp, user.regs.esp);
	fprintf(stderr, "\t ds: 0x%08x  es: 0x%08x  fs: 0x%08x  gs: 0x%08x\n",
		user.regs.ds, user.regs.es, user.regs.fs, user.regs.gs);
	fprintf(stderr, "\teip: 0x%08lx eflags: 0x%08lx",
		user.regs.eip, user.regs.eflags);
    }
    */
    if (action & ACTION_LOAD)
	load_chunk_regs(&user, &or, stopped);
}
开发者ID:seanjensengrey,项目名称:cryopid.stable,代码行数:25,代码来源:cp_r_regs.c

示例4: pin_write_handler

static void pin_write_handler(ble_lbs_t * p_lbs, uint8_t * pin_state)
{  
    
    // Sets motor values for every motor.

    twi_set_motor(pin_state);

    // Sets the color for every RGB-LED.

    uint8_t web_color_data = read_byte(pin_state, 5);
    set_rgb_color(web_color_data);

    // Shoots IR-signal.
    if (read_bit(pin_state, 1, 0))
    {
        ir_shooting(pin_state);
        playNote(536);
        nrf_delay_ms(50);
        playNote(536);
    }
    
    // Turns laser on when game session is active
    if(read_bit(pin_state, 1, 1))
    {
       nrf_gpio_pin_set(LASER_TRANSISTOR);
    }
    else
       nrf_gpio_pin_clear(LASER_TRANSISTOR);

    write_car_id(pin_state[19]);
    unique_car_ID = pin_state[19];
}
开发者ID:jtguggedal,项目名称:Physical_Web_Toy_SDK_11,代码行数:32,代码来源:main.c

示例5: TRACE_INFO

/*!
 * \param *dc The current DecodingContext.
 * \param *slice structure.
 * \return *rplm_t initialized data structure.
 */
static rplm_t *decodeRPLM(DecodingContext_t *dc, slice_t *slice)
{
    TRACE_INFO(SLICE, "  > " BLD_GREEN "decodeRPLM()\n" CLR_RESET);

    // RPLM allocation
    ////////////////////////////////////////////////////////////////////////////

    rplm_t *rplm = (rplm_t*)calloc(1, sizeof(rplm_t));
    if (rplm == NULL)
    {
        TRACE_ERROR(SLICE, "Unable to alloc new RPLM!\n");
    }
    else
    {
        // RPLM decoding
        ////////////////////////////////////////////////////////////////////////

        if (slice->slice_type % 5 != 2 && slice->slice_type % 5 != 4)
        {
            rplm->ref_pic_list_modification_flag_l0 = read_bit(dc->bitstr);
            if (rplm->ref_pic_list_modification_flag_l0)
            {
                do {
                    rplm->modification_of_pic_nums_idc = read_ue(dc->bitstr);
                    if (rplm->modification_of_pic_nums_idc == 0 ||
                        rplm->modification_of_pic_nums_idc == 1)
                    {
                        rplm->abs_diff_pic_num_minus1 = read_ue(dc->bitstr);
                    }
                    else if (rplm->modification_of_pic_nums_idc == 2)
                    {
                        rplm->long_term_pic_num = read_ue(dc->bitstr);
                    }
                } while (rplm->modification_of_pic_nums_idc != 3);
            }
        }

        if (slice->slice_type % 5 == 1)
        {
            rplm->ref_pic_list_modification_flag_l1 = read_bit(dc->bitstr);
            if (rplm->ref_pic_list_modification_flag_l1)
            {
                do {
                    rplm->modification_of_pic_nums_idc = read_ue(dc->bitstr);
                    if (rplm->modification_of_pic_nums_idc == 0 ||
                        rplm->modification_of_pic_nums_idc == 1)
                    {
                        rplm->abs_diff_pic_num_minus1 = read_ue(dc->bitstr);
                    }
                    else if (rplm->modification_of_pic_nums_idc == 2)
                    {
                        rplm->long_term_pic_num = read_ue(dc->bitstr);
                    }
                } while (rplm->modification_of_pic_nums_idc != 3);
            }
        }
    }

    return rplm;
}
开发者ID:seanvk,项目名称:MiniVideo,代码行数:65,代码来源:h264_slice.c

示例6: parse_ue

AM_ERR CMp4Builder::get_pic_order(unsigned char* pBuffer, int size, int nal_unit_type, int* pic_order_cnt_lsb) {
  AM_U8* pSlice_header = pBuffer;
  AM_U8 bit_pos = 0;
  AM_INT first_mb_in_slice;
  AM_INT slice_type;
  AM_INT pic_parameter_set_id;
  AM_INT frame_num;
  pSlice_header += parse_ue(pSlice_header,&first_mb_in_slice,&bit_pos);
  pSlice_header += parse_ue(pSlice_header,&slice_type,&bit_pos);
  switch (slice_type) {
    case SLICE_P_0:
    case SLICE_P_1:
      if (_last_p_num == -1) {
        _last_p_num = mVideoCnt;
      } else {
        if (mH264Info.M == 0) {
          mH264Info.M = mVideoCnt - _last_p_num;
        }
      }
      break;
    case SLICE_I_0:
    case SLICE_I_1:
      if (_last_i_num == -1) {
        _last_i_num = mVideoCnt;
      } else {
        if (mH264Info.N == 0) {
          mH264Info.N = mVideoCnt - _last_i_num;
        }
      }
      break;
    default:
      break;
  }

  pSlice_header += parse_ue(pSlice_header,&pic_parameter_set_id,&bit_pos);
  pSlice_header += read_bit(pSlice_header,&frame_num,&bit_pos,
                            mSpsInfo.log2_max_frame_num_minus4+4);

  if (!mSpsInfo.frame_mbs_only_flag) {
    AM_BOOL field_pic_flag;
    AM_BOOL bottom_field_flag;
    pSlice_header += read_bit(pSlice_header, (AM_INT *)&field_pic_flag,&bit_pos);
    if (field_pic_flag)
      pSlice_header += read_bit(pSlice_header, (AM_INT *)&bottom_field_flag,&bit_pos);
  }
  if (nal_unit_type == NAL_IDR) {
    AM_INT idr_pic_id;
    pSlice_header += parse_ue(pSlice_header,&idr_pic_id,&bit_pos);
  }
  if( mSpsInfo.pic_order_cnt_type == 0 ) {
    pSlice_header += read_bit(pSlice_header,pic_order_cnt_lsb,&bit_pos,
                              mSpsInfo.log2_max_pic_order_cnt_lsb_minus4+4);
    int max_pic_order_cnt_lsb = 1<<(mSpsInfo.log2_max_pic_order_cnt_lsb_minus4+4);
    if (*pic_order_cnt_lsb > max_pic_order_cnt_lsb/2) {
      *pic_order_cnt_lsb -= max_pic_order_cnt_lsb;
    }
  }
  return ME_OK;
}
开发者ID:ShawnOfMisfit,项目名称:ambarella,代码行数:59,代码来源:mp4_builder.cpp

示例7: parse_program_stream_directory

/*!
 * \brief Parse a program stream directory structure.
 * \param *bitstr The bitstream to use.
 * \param *packet A program stream directory structure.
 * \return 1 if succeed, 0 otherwise.
 *
 * From 'ISO/IEC 13818-1' specification:
 * 2.5.5 Program Stream directory
 * Table 2-36 – Program Stream directory packet
 */
static int parse_program_stream_directory(Bitstream_t *bitstr, PesHeader_t *header, ProgramStreamDirectory_t *packet)
{
    TRACE_INFO(MPS, BLD_GREEN "parse_program_stream_directory()" CLR_RESET " @ %lli",
               header->offset_start);
    int retcode = SUCCESS;

    packet->number_of_access_units = read_bits(bitstr, 15);
    MARKER_BIT

    packet->prev_directory_offset = read_bits(bitstr, 15) << 30;
    MARKER_BIT
    packet->prev_directory_offset += read_bits(bitstr, 15) << 15;
    MARKER_BIT
    packet->prev_directory_offset += read_bits(bitstr, 15);
    MARKER_BIT

    packet->next_directory_offset = read_bits(bitstr, 15) << 30;
    MARKER_BIT
    packet->next_directory_offset += read_bits(bitstr, 15) << 15;
    MARKER_BIT
    packet->next_directory_offset += read_bits(bitstr, 15);
    MARKER_BIT

    for (uint16_t i = 0; i < packet->number_of_access_units; i++)
    {
        // TODO stack it?
        packet->packet_stream_id = read_bits(bitstr, 8);
        packet->PES_header_position_offset_sign = read_bit(bitstr);

        packet->PES_header_position_offset = read_bits(bitstr, 14) << 30;
        MARKER_BIT
        packet->PES_header_position_offset += read_bits(bitstr, 15) << 15;
        MARKER_BIT
        packet->PES_header_position_offset += read_bits(bitstr, 15);
        MARKER_BIT

        packet->reference_offset = read_bits(bitstr, 16);
        MARKER_BIT
        /*unsigned reserved1 =*/ read_bits(bitstr, 3);

        packet->PTS = read_bits(bitstr, 3) << 30;
        MARKER_BIT
        packet->PTS += read_bits(bitstr, 15) << 15;
        MARKER_BIT
        packet->PTS += read_bits(bitstr, 15);
        MARKER_BIT

        packet->byes_to_read = read_bits(bitstr, 15) << 15;
        MARKER_BIT
        packet->byes_to_read += read_bits(bitstr, 8);
        MARKER_BIT

        packet->intra_coded_indicator = read_bit(bitstr);
        packet->coding_parameters_indicator = read_bits(bitstr, 2);
        /*unsigned reserved2 =*/ read_bits(bitstr, 4);
    }

    return retcode;
}
开发者ID:emericg,项目名称:MiniVideo,代码行数:69,代码来源:ps.cpp

示例8: read_result

static int read_result(hx711_task* task)
{
	int result;

	result = -read_bit(task);
	for(int i=0;i<23;i++)
	{
		result <<= 1;
		result |= read_bit(task);
	}
	return result;
}
开发者ID:lantti,项目名称:RestessbarKSreporter,代码行数:12,代码来源:measure.c

示例9: rebuild_tree

static void rebuild_tree(LHAPM2Decoder *decoder)
{
	switch (decoder->tree_state) {

		// Initial tree build, from start of stream:

		case PM2_REBUILD_UNBUILT:
			read_code_tree(decoder);
			read_offset_tree(decoder, 5);
			decoder->tree_state = PM2_REBUILD_BUILD1;
			decoder->tree_rebuild_remaining = 1024;
			break;

		// Tree rebuild after 1KiB of data has been read:

		case PM2_REBUILD_BUILD1:
			read_offset_tree(decoder, 6);
			decoder->tree_state = PM2_REBUILD_BUILD2;
			decoder->tree_rebuild_remaining = 1024;
			break;

		// Tree rebuild after 2KiB of data has been read:

		case PM2_REBUILD_BUILD2:
			read_offset_tree(decoder, 7);
			decoder->tree_state = PM2_REBUILD_BUILD3;
			decoder->tree_rebuild_remaining = 2048;
			break;

		// Tree rebuild after 4KiB of data has been read:

		case PM2_REBUILD_BUILD3:
			if (read_bit(&decoder->bit_stream_reader) == 1) {
				read_code_tree(decoder);
			}
			read_offset_tree(decoder, 8);
			decoder->tree_state = PM2_REBUILD_CONTINUING;
			decoder->tree_rebuild_remaining = 4096;
			break;

		// Tree rebuild after 8KiB of data has been read,
		// and every 4KiB after that:

		case PM2_REBUILD_CONTINUING:
			if (read_bit(&decoder->bit_stream_reader) == 1) {
				read_code_tree(decoder);
				read_offset_tree(decoder, 8);
			}
			decoder->tree_rebuild_remaining = 4096;
			break;
	}
}
开发者ID:djdron,项目名称:zxtune,代码行数:52,代码来源:pm2_decoder.c

示例10: while

void compressed_file_reader::get_next()
{
    uint64_t numberBits = 0;
    while (status_ == 0 && !read_bit())
        ++numberBits;

    current_value_ = 0;
    for (int64_t bit = numberBits - 1; status_ == 0 && bit >= 0; --bit)
    {
        if (read_bit())
            current_value_ |= (1 << bit);
    }

    current_value_ |= (1 << numberBits);
}
开发者ID:AlexOcculate,项目名称:meta,代码行数:15,代码来源:compressed_file_reader.cpp

示例11: clock_setup_pulses

static void clock_setup_pulses(hx711_task* task)
{
	int setup_pulses;

	switch (task->op)
	{
		case A128:
			setup_pulses = 1;
			break;
		case A64:
			setup_pulses = 3;
			break;
		case B32:
			setup_pulses = 2;
			break;
		default:
			setup_pulses = 1;
	}

	for (int i=0;i<setup_pulses;i++)
	{
		read_bit(task);
	}

}
开发者ID:lantti,项目名称:RestessbarKSreporter,代码行数:25,代码来源:measure.c

示例12: lha_pm2_decoder_read

static size_t lha_pm2_decoder_read(void *data, uint8_t *buf)
{
	LHAPM2Decoder *decoder = data;
	size_t result;
	int code;

	// On first pass through, build initial lookup trees.

	if (decoder->tree_state == PM2_REBUILD_UNBUILT) {

		// First bit in stream is discarded?

		read_bit(&decoder->bit_stream_reader);
		rebuild_tree(decoder);
	}

	result = 0;

	code = read_from_tree(&decoder->bit_stream_reader, decoder->code_tree);

	if (code < 0) {
		return 0;
	}

	if (code < 8) {
		read_single_byte(decoder, (unsigned int) code, buf, &result);
	} else {
		copy_from_history(decoder, (unsigned int) code - 8,
		                  buf, &result);
	}

	return result;
}
开发者ID:djdron,项目名称:zxtune,代码行数:33,代码来源:pm2_decoder.c

示例13: while

int BinaryFileReader::read_omega() {
	int number = 1;
	while (read_bit() == 1) {
		number = read_binary(number);
	}
	return number;
}
开发者ID:tructvt,项目名称:Android-Project,代码行数:7,代码来源:binary_file_reader.cpp

示例14: funzip

int funzip()
{
	PHuftree_node p;
	unsigned char b,byte;

	p=&huftree[512];

	while (p->num != 256)
	{
		b=read_bit(F_SRC);

		if (b)
			p=&huftree[p->rchild];
		else
			p=&huftree[p->lchild];

		if (p->num < 256)
		{
			byte=(unsigned char)(p->num);
			write_byte(F_DST,&byte);
			p=&huftree[512];
		}
	}
	return 0;
}
开发者ID:vigoals,项目名称:dataStruct,代码行数:25,代码来源:haf.c

示例15: output_rxd

void compucolor_floppy_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
{
	if (!m_sel && !m_rw)
	{
		output_rxd(read_bit());
	}
}
开发者ID:DanielAeolusLaude,项目名称:mame,代码行数:7,代码来源:floppy.c


注:本文中的read_bit函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。