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


C++ read_8bit函数代码示例

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


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

示例1: init_vgmstream_ps3_sgd

VGMSTREAM * init_vgmstream_ps3_sgd(STREAMFILE *streamFile) {
    VGMSTREAM * vgmstream = NULL;
    char filename[260];
    off_t start_offset;
    int loop_flag = 0;
	int channel_count;

    /* check extension, case insensitive */
    streamFile->get_name(streamFile,filename,sizeof(filename));
    if (strcasecmp("sgd",filename_extension(filename))) goto fail;

    /* check header */
    if (read_32bitBE(0x00,streamFile) != 0x53475844) /* "SGXD" */
        goto fail;

    loop_flag = (read_32bitLE(0x44,streamFile) != 0xFFFFFFFF);
    channel_count = read_8bit(0x29,streamFile);
    
	/* build the VGMSTREAM */
    vgmstream = allocate_vgmstream(channel_count,loop_flag);
    if (!vgmstream) goto fail;

	/* fill in the vital statistics */
    start_offset = read_32bitLE(0x8,streamFile);
	vgmstream->channels = channel_count;
    vgmstream->sample_rate = read_32bitLE(0x2C,streamFile);
    vgmstream->coding_type = coding_PSX;
    vgmstream->num_samples = read_32bitLE(0x40,streamFile)/16/channel_count*28;
    if (loop_flag) {
        vgmstream->loop_start_sample = read_32bitLE(0x44,streamFile);
        vgmstream->loop_end_sample = read_32bitLE(0x48,streamFile);
    }

    vgmstream->layout_type = layout_interleave;
    vgmstream->interleave_block_size = read_8bit(0x39,streamFile); // just a guess, all of my samples seem to be 0x10 interleave
    vgmstream->meta_type = meta_PS3_SGX;

    /* open the file for reading */
    {
        int i;
        STREAMFILE * file;
        file = streamFile->open(streamFile,filename,STREAMFILE_DEFAULT_BUFFER_SIZE);
        if (!file) goto fail;
        for (i=0;i<channel_count;i++) {
            vgmstream->ch[i].streamfile = file;

            vgmstream->ch[i].channel_start_offset=
                vgmstream->ch[i].offset=start_offset+
                vgmstream->interleave_block_size*i;

        }
    }

    return vgmstream;

    /* clean up anything we may have opened */
fail:
	if (vgmstream) close_vgmstream(vgmstream);
    return NULL;
}
开发者ID:Paxxi,项目名称:audiodecoder.vgmstream,代码行数:60,代码来源:ps3_sgh_sgb.c

示例2: init_vgmstream_xbox_xmu

VGMSTREAM * init_vgmstream_xbox_xmu(STREAMFILE *streamFile) {
    VGMSTREAM * vgmstream = NULL;
    char filename[PATH_LIMIT];

    int loop_flag=0;
	int channel_count;
    int i;

    /* check extension, case insensitive */
    streamFile->get_name(streamFile,filename,sizeof(filename));
    if (strcasecmp("xmu",filename_extension(filename))) goto fail;

	if((read_32bitBE(0x00,streamFile)!=0x584D5520) && 
	   (read_32bitBE(0x08,streamFile)!=0x46524D54))
		goto fail;

    /* No Loop found atm */
	loop_flag = read_8bit(0x16,streamFile);;
    
	/* Always stereo files */
	channel_count=read_8bit(0x14,streamFile);
    
	/* build the VGMSTREAM */
    vgmstream = allocate_vgmstream(channel_count,loop_flag);
    if (!vgmstream) goto fail;

	/* fill in the vital statistics */
	vgmstream->channels = channel_count;
    vgmstream->sample_rate = read_32bitLE(0x10,streamFile);

	vgmstream->coding_type = coding_XBOX;
    vgmstream->num_samples = read_32bitLE(0x7FC,streamFile) / 36 * 64 / vgmstream->channels;
    vgmstream->layout_type = layout_none;
    vgmstream->meta_type = meta_XBOX_XMU;

	if(loop_flag) {
		vgmstream->loop_start_sample=0;
		vgmstream->loop_end_sample=vgmstream->num_samples;
	}
	
	/* open the file for reading by each channel */
    {
        for (i=0;i<channel_count;i++) {
            vgmstream->ch[i].streamfile = streamFile->open(streamFile,filename,36);
            vgmstream->ch[i].offset = 0x800;

            if (!vgmstream->ch[i].streamfile) goto fail;
        }
    }

    return vgmstream;

    /* clean up anything we may have opened */
fail:
    if (vgmstream) close_vgmstream(vgmstream);
    return NULL;
}
开发者ID:jpmac26,项目名称:PGE-Project,代码行数:57,代码来源:xbox_xmu.c

示例3: decode_hevag

/**
 * Sony's HEVAG (High Efficiency VAG) ADPCM, used in PSVita games (hardware decoded).
 * Evolution of the regular VAG (same flags and frames), uses 4 history samples and a bigger table.
 *
 * Original research and algorithm by id-daemon / daemon1.
 */
void decode_hevag(VGMSTREAMCHANNEL * stream, sample * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do) {

    uint8_t predict_nr, shift, flag, byte;
    int32_t scale = 0;

    int32_t sample;
    int32_t hist1 = stream->adpcm_history1_32;
    int32_t hist2 = stream->adpcm_history2_32;
    int32_t hist3 = stream->adpcm_history3_32;
    int32_t hist4 = stream->adpcm_history4_32;

    int i, sample_count;


    int framesin = first_sample / 28;

    /* 4 byte header: predictor = 3rd and 1st, shift = 2nd, flag = 4th */
    byte = (uint8_t)read_8bit(stream->offset+framesin*16+0,stream->streamfile);
    predict_nr   = byte >> 4;
    shift = byte & 0x0f;
    byte = (uint8_t)read_8bit(stream->offset+framesin*16+1,stream->streamfile);
    predict_nr = (byte & 0xF0) | predict_nr;
    flag = byte & 0x0f; /* no change in flags */

    first_sample = first_sample % 28;

    if (first_sample & 1) { /* if first sample is odd, read byte first */
        byte = read_8bit(stream->offset+(framesin*16)+2+first_sample/2,stream->streamfile);
    }

    for (i = first_sample, sample_count = 0; i < first_sample + samples_to_do; i++, sample_count += channelspacing) {
        sample = 0;

        if (flag < 7 && predict_nr < 128) {

            if (i & 1) {/* odd/even nibble */
                scale = byte >> 4;
            } else {
                byte = read_8bit(stream->offset+(framesin*16)+2+i/2,stream->streamfile);
                scale = byte & 0x0f;
            }
            if (scale > 7) { /* sign extend */
                scale = scale - 16;
            }

            sample = (hist1 * HEVAG_coefs[predict_nr][0] +
                      hist2 * HEVAG_coefs[predict_nr][1] +
                      hist3 * HEVAG_coefs[predict_nr][2] +
                      hist4 * HEVAG_coefs[predict_nr][3] ) / 32;
            sample = (sample + (scale << (20 - shift)) + 128) >> 8;
        }
开发者ID:benladen,项目名称:vgmstream,代码行数:57,代码来源:psv_decoder.c

示例4: init_vgmstream_ss_stream

VGMSTREAM * init_vgmstream_ss_stream(STREAMFILE *streamFile) {
    VGMSTREAM * vgmstream = NULL;
    char filename[260];
    int loop_flag=0;
	int channel_count;
    int i;

    /* check extension, case insensitive */
    streamFile->get_name(streamFile,filename,sizeof(filename));
    if (strcasecmp("ss7",filename_extension(filename))) goto fail;

	loop_flag = 0;
	channel_count=read_8bit(0x0C,streamFile)+1;
    
	/* build the VGMSTREAM */
    vgmstream = allocate_vgmstream(channel_count,loop_flag);
    if (!vgmstream) goto fail;

	/* fill in the vital statistics */
	vgmstream->channels = channel_count;
	vgmstream->sample_rate = 44100;
	
	if(channel_count==1)
		vgmstream->coding_type = coding_IMA;
	else
		vgmstream->coding_type = coding_EACS_IMA;

    vgmstream->num_samples = (int32_t)((get_streamfile_size(streamFile) -0x44)* 2 / vgmstream->channels);
    vgmstream->layout_type = layout_none;
	
    vgmstream->meta_type = meta_XBOX_WAVM;
	vgmstream->get_high_nibble=0;

    /* open the file for reading by each channel */
    {
        for (i=0;i<channel_count;i++) {
            vgmstream->ch[i].streamfile = streamFile->open(streamFile,filename,36);
            vgmstream->ch[i].offset = 0x44;
			vgmstream->ch[i].adpcm_history1_32=(int32_t)read_16bitLE(0x10+i*4,streamFile);
			vgmstream->ch[i].adpcm_step_index =(int)read_8bit(0x12+i*4,streamFile);
            if (!vgmstream->ch[i].streamfile) goto fail;
        }
    }

    return vgmstream;

    /* clean up anything we may have opened */
fail:
    if (vgmstream) close_vgmstream(vgmstream);
    return NULL;
}
开发者ID:1c0n,项目名称:xbmc,代码行数:51,代码来源:ss_stream.c

示例5: readPatch

uint32_t readPatch(STREAMFILE* streamFile, off_t* offset) {
	
	uint32_t	result=0;
	uint8_t		byteCount;

	byteCount = read_8bit(*offset,streamFile);
	(*offset)++;
	
	for(;byteCount>0;byteCount--) {
		result <<=8;
		result+=(uint8_t)read_8bit(*offset,streamFile);
		(*offset)++;
	}
	return result;
}
开发者ID:1c0n,项目名称:xbmc,代码行数:15,代码来源:ea_header.c

示例6: get_streamfile_dos_line

/* Read a line into dst. The source files are MS-DOS style,
 * separated (not terminated) by CRLF. Return 1 if the full line was
 * retrieved (if it could fit in dst), 0 otherwise. In any case the result
 * will be properly terminated. The CRLF will be removed if there is one.
 * Return the number of bytes read (including CRLF line ending). Note that
 * this is not the length of the string, and could be larger than the buffer.
 * *line_done_ptr is set to 1 if the complete line was read into dst,
 * otherwise it is set to 0. line_done_ptr can be NULL if you aren't
 * interested in this info.
 */
size_t get_streamfile_dos_line(int dst_length, char * dst, off_t offset,
        STREAMFILE * infile, int *line_done_ptr)
{
    int i;
    off_t file_length = get_streamfile_size(infile);
    /* how many bytes over those put in the buffer were read */
    int extra_bytes = 0;

    if (line_done_ptr) *line_done_ptr = 0;

    for (i=0;i<dst_length-1 && offset+i < file_length;i++)
    {
        char in_char = read_8bit(offset+i,infile);
        /* check for end of line */
        if (in_char == 0x0d &&
                read_8bit(offset+i+1,infile) == 0x0a)
        {
            extra_bytes = 2;
            if (line_done_ptr) *line_done_ptr = 1;
            break;
        }

        dst[i]=in_char;
    }
    
    dst[i]='\0';

    /* did we fill the buffer? */
    if (i==dst_length) {
        /* did the bytes we missed just happen to be the end of the line? */
        if (read_8bit(offset+i,infile) == 0x0d &&
                read_8bit(offset+i+1,infile) == 0x0a)
        {
            extra_bytes = 2;
            /* if so be proud! */
            if (line_done_ptr) *line_done_ptr = 1;
        }
    }

    /* did we hit the file end? */
    if (offset+i == file_length)
    {
        /* then we did in fact finish reading the last line */
        if (line_done_ptr) *line_done_ptr = 1;
    }

    return i+extra_bytes;
}
开发者ID:9a3eedi,项目名称:Droidsound,代码行数:58,代码来源:streamfile.c

示例7: init_vgmstream_ngc_adpdtk

VGMSTREAM * init_vgmstream_ngc_adpdtk(STREAMFILE *streamFile) {
    VGMSTREAM * vgmstream = NULL;
    STREAMFILE * chstreamfile;
    char filename[PATH_LIMIT];
    
    size_t file_size;
    int i;

    /* check extension, case insensitive */
    streamFile->get_name(streamFile,filename,sizeof(filename));
    if (strcasecmp("adp",filename_extension(filename)) && 
		strcasecmp("dtk",filename_extension(filename))) goto fail;

    /* file size is the only way to determine sample count */
    file_size = get_streamfile_size(streamFile);

    /* .adp files have no header, so all we can do is look for a valid first frame */
    if (read_8bit(0,streamFile)!=read_8bit(2,streamFile) || read_8bit(1,streamFile)!=read_8bit(3,streamFile)) goto fail;

    /* Hopefully we haven't falsely detected something else... */
    /* build the VGMSTREAM */
    vgmstream = allocate_vgmstream(2,0);    /* always stereo, no loop */
    if (!vgmstream) goto fail;

    vgmstream->num_samples = file_size/32*28;
    vgmstream->sample_rate = 48000;
    vgmstream->coding_type = coding_NGC_DTK;
    vgmstream->layout_type = layout_dtk_interleave;
    vgmstream->meta_type = meta_NGC_ADPDTK;

    /* locality is such that two streamfiles is silly */
    chstreamfile = streamFile->open(streamFile,filename,32*0x400);
    if (!chstreamfile) goto fail;

    for (i=0;i<2;i++) {
        vgmstream->ch[i].channel_start_offset =
            vgmstream->ch[i].offset = 0;

        vgmstream->ch[i].streamfile = chstreamfile;
    }

    return vgmstream;

    /* clean up anything we may have opened */
fail:
    if (vgmstream) close_vgmstream(vgmstream);
    return NULL;
}
开发者ID:Deinonychus71,项目名称:vgmstream,代码行数:48,代码来源:ngc_adpdtk.c

示例8: TM1650_read

/*******************读按键命令************************/
uchar TM1650_read()
{
	uchar key;
	TM1650_START();
    write_8bit(0x49);//读按键指令	
	key=read_8bit();
	TM1650_STOP();
	return key;
} 
开发者ID:mwei0321,项目名称:STCode,代码行数:10,代码来源:TM1650.c

示例9: xa_block_update

/* set up for the block at the given offset */
void xa_block_update(off_t block_offset, VGMSTREAM * vgmstream) {

	int i;
	int8_t currentChannel=0;
	int8_t subAudio=0;
	
	init_get_high_nibble(vgmstream);

	if(vgmstream->samples_into_block!=0)
		// don't change this variable in the init process
		vgmstream->xa_sector_length+=128;

	// We get to the end of a sector ?
	if(vgmstream->xa_sector_length==(18*128)) {
		vgmstream->xa_sector_length=0;

		// 0x30 of unused bytes/sector :(
		block_offset+=0x30;
begin:
		// Search for selected channel & valid audio
		currentChannel=read_8bit(block_offset-7,vgmstream->ch[0].streamfile);
		subAudio=read_8bit(block_offset-6,vgmstream->ch[0].streamfile);

		// audio is coded as 0x64
		if(!((subAudio==0x64) && (currentChannel==vgmstream->xa_channel))) {
			// go to next sector
			block_offset+=2352;
			if(currentChannel!=-1) goto begin;
		} 
	}

	vgmstream->current_block_offset = block_offset;

	// Quid : how to stop the current channel ???
	// i set up 0 to current_block_size to make vgmstream not playing bad samples
	// another way to do it ??? 
	// (as the number of samples can be false in cd-xa due to multi-channels)
	vgmstream->current_block_size = (currentChannel==-1?0:112);
	
	vgmstream->next_block_offset = vgmstream->current_block_offset+128;
	for (i=0;i<vgmstream->channels;i++) {
	    vgmstream->ch[i].offset = vgmstream->current_block_offset;
	}		
}
开发者ID:1c0n,项目名称:xbmc,代码行数:45,代码来源:xa_blocked.c

示例10: init_vgmstream_ngc_adpdtk

VGMSTREAM * init_vgmstream_ngc_adpdtk(STREAMFILE *streamFile) {
    VGMSTREAM * vgmstream = NULL;
    off_t start_offset = 0;
    int channel_count = 2, loop_flag = 0; /* always stereo, no loop */

    /* check extension, case insensitive */
    if ( !check_extensions(streamFile,"dtk,adp"))
        goto fail;

    /* .adp files have no header, and the ext is common, so all we can do is look for valid first frames */
    if (check_extensions(streamFile,"adp")) {
        int i;
        for (i = 0; i < 10; i++) { /* try a bunch of frames */
            if (read_8bit(0x00 + i*0x20,streamFile) != read_8bit(0x02 + i*0x20,streamFile) ||
                read_8bit(0x01 + i*0x20,streamFile) != read_8bit(0x03 + i*0x20,streamFile))
                goto fail;
        }
    }


    /* build the VGMSTREAM */
    vgmstream = allocate_vgmstream(channel_count, loop_flag);
    if (!vgmstream) goto fail;

    vgmstream->num_samples = get_streamfile_size(streamFile) / 32 * 28;
    vgmstream->sample_rate = 48000;
    vgmstream->coding_type = coding_NGC_DTK;
    vgmstream->layout_type = layout_none;
    vgmstream->meta_type = meta_NGC_ADPDTK;


    /* open the file for reading */
    if ( !vgmstream_open_stream(vgmstream, streamFile, start_offset) )
        goto fail;

    return vgmstream;

fail:
    close_vgmstream(vgmstream);
    return NULL;
}
开发者ID:benladen,项目名称:vgmstream,代码行数:41,代码来源:ngc_adpdtk.c

示例11: init_xa_channel

off_t init_xa_channel(int* channel,STREAMFILE* streamFile) {
	
	off_t block_offset=0x44;
	size_t filelength=get_streamfile_size(streamFile);

	int8_t currentChannel;
	int8_t subAudio;

	// 0 can't be a correct value
	if(block_offset>=(off_t)filelength)
		return 0;

	currentChannel=read_8bit(block_offset-7,streamFile);
	subAudio=read_8bit(block_offset-6,streamFile);
	*channel=currentChannel;
	//if (!((currentChannel==channel) && (subAudio==0x64))) {
	//	block_offset+=2352;
	//	goto begin;
	//}
	return block_offset;
}
开发者ID:Sappharad,项目名称:modizer,代码行数:21,代码来源:psx_cdxa.c

示例12: decode_ngc_dsp

void decode_ngc_dsp(VGMSTREAMCHANNEL * stream, sample * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do) {
    int i=first_sample;
    int32_t sample_count;

    int framesin = first_sample/14;

    int8_t header = read_8bit(framesin*8+stream->offset,stream->streamfile);
    int32_t scale = 1 << (header & 0xf);
    int coef_index = (header >> 4) & 0xf;
    int32_t hist1 = stream->adpcm_history1_16;
    int32_t hist2 = stream->adpcm_history2_16;
    int coef1 = stream->adpcm_coef[coef_index*2];
    int coef2 = stream->adpcm_coef[coef_index*2+1];

    first_sample = first_sample%14;

    for (i=first_sample,sample_count=0; i<first_sample+samples_to_do; i++,sample_count+=channelspacing) {
        int sample_byte = read_8bit(framesin*8+stream->offset+1+i/2,stream->streamfile);

#ifdef DEBUG
        if (hist1==stream->loop_history1 && hist2==stream->loop_history2) fprintf(stderr,"yo! %#x (start %#x) %d\n",stream->offset+framesin*8+i/2,stream->channel_start_offset,stream->samples_done);
        stream->samples_done++;
#endif

        outbuf[sample_count] = clamp16((
                 (((i&1?
                    get_low_nibble_signed(sample_byte):
                    get_high_nibble_signed(sample_byte)
                   ) * scale)<<11) + 1024 +
                 (coef1 * hist1 + coef2 * hist2))>>11
                );

        hist2 = hist1;
        hist1 = outbuf[sample_count];
    }

    stream->adpcm_history1_16 = hist1;
    stream->adpcm_history2_16 = hist2;
}
开发者ID:1c0n,项目名称:xbmc,代码行数:39,代码来源:ngc_dsp_decoder.c

示例13: init_vgmstream_ps2_omu

// OMU is a PS2 .INT file with header ...
// found in Alter Echo
VGMSTREAM * init_vgmstream_ps2_omu(STREAMFILE *streamFile) {
    VGMSTREAM * vgmstream = NULL;
    char filename[1024];
	int i,channel_count;

    /* check extension, case insensitive */
    streamFile->get_name(streamFile,filename,sizeof(filename));
    if (strcasecmp("omu",filename_extension(filename))) goto fail;

	/* check header */
	if((read_32bitBE(0,streamFile)!=0x4F4D5520) && (read_32bitBE(0x08,streamFile)!=0x46524D54))
		goto fail;

	channel_count = (int)read_8bit(0x14,streamFile);

    /* build the VGMSTREAM */
    vgmstream = allocate_vgmstream(channel_count,1);
    if (!vgmstream) goto fail;

    /* fill in the vital statistics */
	vgmstream->channels=channel_count;
    vgmstream->sample_rate = read_32bitLE(0x10,streamFile);
    vgmstream->coding_type = coding_PCM16LE;
    vgmstream->num_samples = (int32_t)(read_32bitLE(0x3C,streamFile)/(vgmstream->channels*2));
    vgmstream->interleave_block_size = 0x200;
    vgmstream->layout_type = layout_interleave;
    vgmstream->meta_type = meta_PS2_OMU;

	vgmstream->loop_start_sample=0;
	vgmstream->loop_end_sample=vgmstream->num_samples;

    /* open the file for reading by each channel */
    {
        for (i=0;i<vgmstream->channels;i++) {
            vgmstream->ch[i].streamfile = streamFile->open(streamFile,filename,0x8000);

            if (!vgmstream->ch[i].streamfile) goto fail;

            vgmstream->ch[i].channel_start_offset=
                vgmstream->ch[i].offset=0x40+(i*vgmstream->interleave_block_size);
        }
    }

    return vgmstream;

    /* clean up anything we may have opened */
fail:
    if (vgmstream) close_vgmstream(vgmstream);
    return NULL;
}
开发者ID:Sappharad,项目名称:modizer,代码行数:52,代码来源:ps2_int.c

示例14: decode_sdx2_int

void decode_sdx2_int(VGMSTREAMCHANNEL * stream, sample * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do) {

	int32_t hist = stream->adpcm_history1_32;

	int i;
	int32_t sample_count;
	
	for (i=first_sample,sample_count=0; i<first_sample+samples_to_do; i++,sample_count+=channelspacing) {
        int8_t sample_byte = read_8bit(stream->offset+i*channelspacing,stream->streamfile);
        int16_t sample;

        if (!(sample_byte & 1)) hist = 0;
        sample = hist + squares[sample_byte+128];

		hist = outbuf[sample_count] = clamp16(sample);
	}
	stream->adpcm_history1_32=hist;
}
开发者ID:1c0n,项目名称:xbmc,代码行数:18,代码来源:sdx2_decoder.c

示例15: read_string

/* reads a c-string, up to maxsize or NULL, returning size. buf is optional. */
int read_string(char * buf, size_t maxsize, off_t offset, STREAMFILE *streamFile) {
    int i;

    for (i=0; i < maxsize; i++) {
        char c = read_8bit(offset + i, streamFile);
        if (buf) buf[i] = c;
        if (c == '\0')
            return i;
        if (i+1 == maxsize) { /* null at maxsize and don't validate (expected to be garbage) */
            if (buf) buf[i] = '\0';
            return maxsize;
        }
        if (c < 0x20 || c > 0xA5)
            goto fail;
    }

fail:
    if (buf) buf[0] = '\0';
    return 0;
}
开发者ID:soneek,项目名称:vgmstream,代码行数:21,代码来源:streamfile.c


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