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


C++ read_16bitBE函数代码示例

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


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

示例1: thp_block_update

/* set up for the block at the given offset */
void thp_block_update(off_t block_offset, VGMSTREAM * vgmstream) {
    int i,j;
	STREAMFILE *streamFile=vgmstream->ch[0].streamfile;
	off_t	start_offset;
	int32_t	nextFrameSize;

	vgmstream->current_block_offset = block_offset;
	nextFrameSize=read_32bitBE(vgmstream->current_block_offset,streamFile);

	vgmstream->next_block_offset = vgmstream->current_block_offset
		                         + vgmstream->full_block_size;
	vgmstream->full_block_size = nextFrameSize;

	start_offset=vgmstream->current_block_offset
		         + read_32bitBE(vgmstream->current_block_offset+0x08,streamFile)+0x10;
	vgmstream->current_block_size=read_32bitBE(start_offset,streamFile);
	start_offset+=8;

	for(i=0;i<vgmstream->channels;i++) {
		for(j=0;j<16;j++) {
			vgmstream->ch[i].adpcm_coef[j]=read_16bitBE(start_offset+(i*0x20)+(j*2),streamFile);
		}
		vgmstream->ch[i].adpcm_history1_16=read_16bitBE(start_offset + (0x20*vgmstream->channels) + (i*4),streamFile);
		vgmstream->ch[i].adpcm_history2_16=read_16bitBE(start_offset + (0x20*vgmstream->channels) + (i*4) + 2,streamFile);
        vgmstream->ch[i].offset = start_offset + (0x24*vgmstream->channels)+(i*vgmstream->current_block_size);
	}
}
开发者ID:benladen,项目名称:vgmstream,代码行数:28,代码来源:thp_blocked.c

示例2: init_vgmstream_g1l

VGMSTREAM * init_vgmstream_g1l(STREAMFILE *streamFile) {
	VGMSTREAM * vgmstream = NULL;
	char filename[260];

	coding_t coding_type;

	off_t head_offset;

	int channel_count;
	int loop_flag;
	off_t start_offset;

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


	/* check header */
	if ((uint32_t)read_32bitBE(0, streamFile) != 0x47314C5F) /* "G1L_" */
		goto fail;
	if ((uint32_t)read_32bitBE(0x1c, streamFile) != 0x57696942) /* "WiiB" */
		goto fail;

	/* check type details */
//	loop_flag = read_8bit(head_offset + 0x21, streamFile);
	if (read_32bitBE(0x30, streamFile) > 0)
		loop_flag = 1;
	else
		loop_flag = 0;
	channel_count = read_8bit(0x3f, streamFile);


	coding_type = coding_NGC_DSP;
	

	if (channel_count < 1) goto fail;

	/* build the VGMSTREAM */

	vgmstream = allocate_vgmstream(channel_count, loop_flag);
	if (!vgmstream) goto fail;

	/* fill in the vital statistics */
	vgmstream->num_samples = read_32bitBE(0x2c, streamFile);
	vgmstream->sample_rate = (uint16_t)read_16bitBE(0x42, streamFile);
	/* channels and loop flag are set by allocate_vgmstream */
	
	vgmstream->loop_start_sample = read_32bitBE(0x30, streamFile);
	vgmstream->loop_end_sample = vgmstream->num_samples;
	

	vgmstream->coding_type = coding_type;
	if (channel_count == 1)
		vgmstream->layout_type = layout_none;
	
	vgmstream->layout_type = layout_interleave_byte;
	
	vgmstream->meta_type = meta_G1L;

	vgmstream->interleave_block_size = 0x1;	

	if (vgmstream->coding_type == coding_NGC_DSP) {
		off_t coef_offset = 0x78;
		
		int i, j;
		int coef_spacing = 0x60;


		for (j = 0; j<vgmstream->channels; j++) {
			for (i = 0; i<16; i++) {
				vgmstream->ch[j].adpcm_coef[i] = read_16bitBE(coef_offset + j*coef_spacing + i * 2, streamFile);
			}
		}
	}

	if (vgmstream->coding_type == coding_NGC_DSP)
		start_offset = 0x81c;
	else // Will add AT3 G1L support later
		goto fail;



	/* open the file for reading by each channel */
	{
		int i;
		for (i = 0; i<channel_count; i++) {
			if (vgmstream->layout_type == layout_interleave_shortblock)
				vgmstream->ch[i].streamfile = streamFile->open(streamFile, filename,
				vgmstream->interleave_block_size);
			else if (vgmstream->layout_type == layout_interleave)
				vgmstream->ch[i].streamfile = streamFile->open(streamFile, filename,
				STREAMFILE_DEFAULT_BUFFER_SIZE);
			else
				vgmstream->ch[i].streamfile = streamFile->open(streamFile, filename,
				0x1000);

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

			vgmstream->ch[i].channel_start_offset =
//.........这里部分代码省略.........
开发者ID:Paxxi,项目名称:audiodecoder.vgmstream,代码行数:101,代码来源:g1l.c

示例3: init_vgmstream_afc

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

    int loop_flag;
    const int channel_count = 2;    /* .afc seems to be stereo only */

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

    /* don't grab AIFF-C with .afc extension */
    if ((uint32_t)read_32bitBE(0x0,streamFile)==0x464F524D) /* FORM */
        goto fail;

    /* we will get a sample rate, that's as close to checking as I think
     * we can get */

    /* build the VGMSTREAM */

    loop_flag = read_32bitBE(0x10,streamFile);

    vgmstream = allocate_vgmstream(channel_count,loop_flag);
    if (!vgmstream) goto fail;

    /* fill in the vital statistics */
    vgmstream->num_samples = read_32bitBE(0x04,streamFile);
    vgmstream->sample_rate = (uint16_t)read_16bitBE(0x08,streamFile);
    /* channels and loop flag are set by allocate_vgmstream */
    vgmstream->loop_start_sample = read_32bitBE(0x14,streamFile);
    vgmstream->loop_end_sample = vgmstream->num_samples;

    vgmstream->coding_type = coding_NGC_AFC;
    vgmstream->layout_type = layout_interleave;
    vgmstream->meta_type = meta_AFC;

    /* frame-level interleave (9 bytes) */
    vgmstream->interleave_block_size = 9;

    /* open the file for reading by each channel */
    {
        STREAMFILE *chstreamfile;
        int i;

        /* both channels use same buffer, as interleave is so small */
        chstreamfile = streamFile->open(streamFile,filename,STREAMFILE_DEFAULT_BUFFER_SIZE);
        if (!chstreamfile) goto fail;

        for (i=0;i<channel_count;i++) {
            vgmstream->ch[i].streamfile = chstreamfile;

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

    return vgmstream;

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

示例4: init_vgmstream_utf_dsp

/* CRI's UTF wrapper around DSP */
VGMSTREAM * init_vgmstream_utf_dsp(STREAMFILE *streamFile) {
    
	VGMSTREAM * vgmstream = NULL;
    char filename[1024];
    int table_error = 0;

    int loop_flag = 0;

    const long top_offset = 0;

    int channel_count;
    int sample_rate;
    long sample_count;

    long top_data_offset, segment_count;
    long body_offset, body_size;
    long header_offset, header_size;

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

    /* get entry count, data offset */
    {
        struct utf_query_result result;
        long top_string_table_offset;
        long top_string_table_size;
        long name_offset;
       
        result = query_utf_nofail(streamFile, top_offset, NULL, &table_error);
        if (table_error) goto fail;
        segment_count = result.rows;
        if (segment_count != 1) goto fail; // only simple stuff for now
        top_string_table_offset = top_offset + 8 + result.string_table_offset;
        top_data_offset = top_offset + 8 + result.data_offset;
        top_string_table_size = top_data_offset - top_string_table_offset;

        if (result.name_offset+10 > top_string_table_size) goto fail;

        name_offset = top_string_table_offset + result.name_offset;
        if (read_32bitBE(name_offset, streamFile) != 0x41445043   ||// "ADPC"
            read_32bitBE(name_offset+4, streamFile) != 0x4D5F5749 ||// "M_WI"
            read_16bitBE(name_offset+8, streamFile) != 0x4900)      // "I\0"
            goto fail;
    }

    {
        struct offset_size_pair offset_size;

        offset_size = query_utf_data(streamFile, top_offset, 0, "data", &table_error);
        if (table_error) goto fail;
        body_offset = top_data_offset + offset_size.offset;
        body_size = offset_size.size;

        offset_size = query_utf_data(streamFile, top_offset, 0, "header", &table_error);
        if (table_error) goto fail;
        header_offset = top_data_offset + offset_size.offset;
        header_size = offset_size.size;
    }

    channel_count = query_utf_1byte(streamFile, top_offset, 0, "nch", &table_error);
    sample_count = query_utf_4byte(streamFile, top_offset, 0, "nsmpl", &table_error);
    sample_rate = query_utf_4byte(streamFile, top_offset, 0, "sfreq", &table_error);
    if (table_error) goto fail;
    if (channel_count != 1 && channel_count != 2) goto fail;
    if (header_size != channel_count * 0x60) goto fail;

    vgmstream = allocate_vgmstream(channel_count,loop_flag);

    vgmstream->num_samples = sample_count;
    vgmstream->sample_rate = sample_rate;

    vgmstream->coding_type = coding_NGC_DSP;
    vgmstream->layout_type = layout_none;
    vgmstream->meta_type = meta_UTF_DSP;

    {
        int i,j;
        long channel_size = (body_size+7)/8*8/channel_count;
        for (i = 0; i < channel_count; i++)
        {
            vgmstream->ch[i].streamfile = streamFile->open(streamFile,filename,STREAMFILE_DEFAULT_BUFFER_SIZE);
            if (!vgmstream->ch[i].streamfile) goto fail;
            vgmstream->ch[i].channel_start_offset =
                vgmstream->ch[i].offset = body_offset + i * channel_size;
            for (j=0;j<16;j++)
            {
                vgmstream->ch[i].adpcm_coef[j] =
                    read_16bitBE(header_offset + 0x60*i + 0x1c + j*2, streamFile);
            }
        }
    }

    return vgmstream;

    /* clean up anything we may have opened */
fail:
    if (vgmstream) close_vgmstream(vgmstream);
    return NULL;
//.........这里部分代码省略.........
开发者ID:Sappharad,项目名称:modizer,代码行数:101,代码来源:aax.c

示例5: init_vgmstream_ads

/* ADS (from Gauntlet Dark Legends (GC)) */
VGMSTREAM * init_vgmstream_ads(STREAMFILE *streamFile) {
    VGMSTREAM * vgmstream = NULL;
    char filename[PATH_LIMIT];
    off_t start_offset;
    int loop_flag;
    int channel_count;
    int identifer_byte;

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

    /* check dhSS Header */
    if (read_32bitBE(0x00,streamFile) != 0x64685353)
        goto fail;

    /* check dbSS Header */
    if (read_32bitBE(0x20,streamFile) != 0x64625353)
        goto fail;
    
    loop_flag = 1;
    channel_count = read_32bitBE(0x10,streamFile);

    if (channel_count > 0x2)
        goto fail;

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

    /* fill in the vital statistics */
    identifer_byte = read_32bitBE(0x08,streamFile);
    switch (identifer_byte) {
        case 0x00000020:
            start_offset = 0xE8;
            vgmstream->channels = channel_count;
            vgmstream->sample_rate = read_32bitBE(0x0c,streamFile);
            vgmstream->coding_type = coding_NGC_DSP;
            vgmstream->num_samples = read_32bitBE(0x28,streamFile);
        if (loop_flag) {
            vgmstream->loop_start_sample = 0;
            vgmstream->loop_end_sample = vgmstream->num_samples;
        }
        
        if (channel_count == 1){
            vgmstream->layout_type = layout_none;
        } else if (channel_count == 2){
            vgmstream->layout_type = layout_interleave;
            vgmstream->interleave_block_size = read_32bitBE(0x14,streamFile);
        }
    break;
        case 0x00000021:
            start_offset = 0x28;
            vgmstream->channels = channel_count;
            vgmstream->sample_rate = read_32bitBE(0x0c,streamFile);
            vgmstream->coding_type = coding_INT_XBOX;
            vgmstream->num_samples = (read_32bitBE(0x24,streamFile) / 36 *64 / vgmstream->channels)-64; // to avoid the "pop" at the loop point
            vgmstream->layout_type = layout_interleave;
            vgmstream->interleave_block_size = 0x24;
        if (loop_flag) {
            vgmstream->loop_start_sample = 0;
            vgmstream->loop_end_sample = vgmstream->num_samples;
        }
        break;
    default:
goto fail;
}

    vgmstream->meta_type = meta_ADS;

        {
        int i;
        for (i=0;i<16;i++)
            vgmstream->ch[0].adpcm_coef[i] = read_16bitBE(0x44+i*2,streamFile);
        if (channel_count == 2) {
        for (i=0;i<16;i++)
            vgmstream->ch[1].adpcm_coef[i] = read_16bitBE(0xA4+i*2,streamFile);
    }
        }


    /* open the file for reading */
    if (vgmstream->coding_type == coding_NGC_DSP) {
        int i,c;
        for (c=0;c<channel_count;c++) {
            for (i=0;i<16;i++) {
                vgmstream->ch[c].adpcm_coef[i] =
                    read_16bitBE(0x44+c*0x60 +i*2,streamFile);
            }
        }
    }

    /* 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++) {
//.........这里部分代码省略.........
开发者ID:jpmac26,项目名称:PGE-Project,代码行数:101,代码来源:ads.c

示例6: init_vgmstream_ios_psnd

/* PSND (from Crash Bandicoot Nitro Kart 2 (iOS) */
VGMSTREAM * init_vgmstream_ios_psnd(STREAMFILE *streamFile) {
    VGMSTREAM * vgmstream = NULL;
    char filename[PATH_LIMIT];
    off_t start_offset;

    int loop_flag;
   int channel_count;

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

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

    if (read_16bitBE(0xC,streamFile)==0x2256){
		loop_flag = 1;
	}
	else {
		loop_flag = 0;
	}
	channel_count = read_8bit(0xE,streamFile);

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

   /* fill in the vital statistics */
    start_offset = 0x10;
    vgmstream->channels = channel_count;
	
	if (read_16bitBE(0xC,streamFile)==0x44AC){
		vgmstream->sample_rate = 44100;
	}
	else {
        vgmstream->sample_rate = read_16bitLE(0xC,streamFile);
	}

    vgmstream->coding_type = coding_PCM16LE;
    vgmstream->num_samples = (read_32bitLE(0x4,streamFile)-8)/4;
	if (loop_flag) {
        vgmstream->loop_start_sample = 0;
       vgmstream->loop_end_sample = vgmstream->num_samples;
    }
    vgmstream->layout_type = layout_interleave;
    vgmstream->interleave_block_size = 2;
    vgmstream->meta_type = meta_IOS_PSND;

    /* 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:Deinonychus71,项目名称:vgmstream,代码行数:73,代码来源:ios_psnd.c

示例7: init_vgmstream_ngc_lps

/* LPS (found in Rave Master (Groove Adventure Rave)(GC) */
VGMSTREAM * init_vgmstream_ngc_lps(STREAMFILE *streamFile) {
    VGMSTREAM * vgmstream = NULL;
    char filename[260];
    off_t start_offset;
	int loop_flag;
	int channel_count;

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

    /* check header */
    if (read_32bitBE(0x8,streamFile) != 0x10000000)
		goto fail;

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

	/* fill in the vital statistics */
  start_offset = 0x60;
	vgmstream->channels = channel_count;
    vgmstream->sample_rate = read_32bitBE(0x28,streamFile);
    vgmstream->coding_type = coding_NGC_DSP;
    vgmstream->num_samples = (read_32bitBE(0x34,streamFile))/16*14;
    if (loop_flag) {
        vgmstream->loop_start_sample = (read_32bitBE(0x30,streamFile))/16*14;
        vgmstream->loop_end_sample = vgmstream->num_samples;
    }

    vgmstream->layout_type = layout_none;
    vgmstream->meta_type = meta_NGC_LPS;

    if (vgmstream->coding_type == coding_NGC_DSP) {
        int i;
        for (i=0;i<16;i++) {
            vgmstream->ch[0].adpcm_coef[i] = read_16bitBE(0x3C+i*2,streamFile);
        }
    }
    /* 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:9a3eedi,项目名称:Droidsound,代码行数:66,代码来源:ngc_lps.c

示例8: init_vgmstream_ast

VGMSTREAM * init_vgmstream_ast(STREAMFILE *streamFile) {
    VGMSTREAM * vgmstream = NULL;
    char filename[260];

    coding_t coding_type;

    int codec_number;
    int channel_count;
    int loop_flag;

    size_t max_block;

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

    /* check header */
    if ((uint32_t)read_32bitBE(0,streamFile)!=0x5354524D || /* "STRM" */
            read_16bitBE(0xa,streamFile)!=0x10 ||
            /* check that file = header (0x40) + data */
            read_32bitBE(4,streamFile)+0x40!=get_streamfile_size(streamFile))
        goto fail;
    
    /* check for a first block */
    if (read_32bitBE(0x40,streamFile)!=0x424C434B)  /* "BLCK" */
        goto fail;

    /* check type details */
    codec_number = read_16bitBE(8,streamFile);
    loop_flag = read_16bitBE(0xe,streamFile);
    channel_count = read_16bitBE(0xc,streamFile);
    max_block = read_32bitBE(0x20,streamFile);

    switch (codec_number) {
        case 0:
            coding_type = coding_NGC_AFC;
            break;
        case 1:
            coding_type = coding_PCM16BE;
            break;
        default:
            goto fail;
    }

    /* build the VGMSTREAM */

    vgmstream = allocate_vgmstream(channel_count,loop_flag);
    if (!vgmstream) goto fail;

    /* fill in the vital statistics */
    vgmstream->num_samples = read_32bitBE(0x14,streamFile);
    vgmstream->sample_rate = read_32bitBE(0x10,streamFile);
    /* channels and loop flag are set by allocate_vgmstream */
    vgmstream->loop_start_sample = read_32bitBE(0x18,streamFile);
    vgmstream->loop_end_sample = read_32bitBE(0x1c,streamFile);

    vgmstream->coding_type = coding_type;
    vgmstream->layout_type = layout_ast_blocked;
    vgmstream->meta_type = meta_AST;

    /* open the file for reading by each channel */
    {
        int i;
        for (i=0;i<channel_count;i++) {
            vgmstream->ch[i].streamfile = streamFile->open(streamFile,filename,
                    (i==0?
                     max_block+0x20-4: /* first buffer a bit bigger to 
                                         read block header without
                                         inefficiency */
                     max_block
                    )
                    );

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

    /* start me up */
    ast_block_update(0x40,vgmstream);

    return vgmstream;

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

示例9: init_vgmstream_bfstm

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

	coding_t coding_type;

	off_t info_offset, seek_offset, data_offset, regn_offset, pdat_offset;
	size_t info_size, seek_size, data_size, regn_size, pdat_size;
	uint16_t temp_id;
	int codec_number;
	int channel_count;
	int loop_flag;
	int i, j;
	int ima = 0;
	off_t start_offset;
	int founddata;
	off_t tempoffset1;

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


	/* check header */
	if ((uint32_t)read_32bitBE(0, streamFile) != 0x4653544D) /* "FSTM" */
		goto fail;
	if ((uint16_t)read_16bitBE(4, streamFile) != 0xFEFF)
		goto fail;

	int section_count = read_16bitBE(0x10, streamFile);
	for (i = 0; i < section_count; i++) {
		temp_id = read_16bitBE(0x14 + i * 0xc, streamFile);
		switch(temp_id) {
			case 0x4000:
				info_offset = read_32bitBE(0x18 + i * 0xc, streamFile);
				info_size = read_32bitBE(0x1c + i * 0xc, streamFile);
				break;
			case 0x4001:
				seek_offset = read_32bitBE(0x18 + i * 0xc, streamFile);
				seek_size = read_32bitBE(0x1c + i * 0xc, streamFile);
				break;
			case 0x4002:
				data_offset = read_32bitBE(0x18 + i * 0xc, streamFile);
				data_size = read_32bitBE(0x1c + i * 0xc, streamFile);
				break;
			case 0x4003:
				regn_offset = read_32bitBE(0x18 + i * 0xc, streamFile);
				regn_size = read_32bitBE(0x1c + i * 0xc, streamFile);
				break;
			case 0x4004:
				pdat_offset = read_32bitBE(0x18 + i * 0xc, streamFile);
				pdat_size = read_32bitBE(0x1c + i * 0xc, streamFile);
				break;
			default:
				break;				
		}
	}
	

	if ((uint32_t)read_32bitBE(info_offset, streamFile) != 0x494E464F) /* "INFO" */
		goto fail;


	/* check type details */
	codec_number = read_8bit(info_offset + 0x20, streamFile);
	loop_flag = read_8bit(info_offset + 0x21, streamFile);
	channel_count = read_8bit(info_offset + 0x22, streamFile);

	switch (codec_number) {
	case 0:
		coding_type = coding_PCM8;
		break;
	case 1:
		coding_type = coding_PCM16BE;
		break;
	case 2:
		coding_type = coding_NGC_DSP;
		break;
	default:
		goto fail;
	}

	if (channel_count < 1) goto fail;

	/* build the VGMSTREAM */

	vgmstream = allocate_vgmstream(channel_count, loop_flag);
	if (!vgmstream) goto fail;

	/* fill in the vital statistics */
	vgmstream->num_samples = read_32bitBE(info_offset + 0x2c, streamFile);
	vgmstream->sample_rate = (uint16_t)read_16bitBE(info_offset + 0x26, streamFile);
	/* channels and loop flag are set by allocate_vgmstream */
	if (ima) //Shift the loop points back slightly to avoid stupid pops in some IMA streams due to DC offsetting
	{
		vgmstream->loop_start_sample = read_32bitBE(info_offset + 0x28, streamFile);
		if (vgmstream->loop_start_sample > 10000)
		{
			vgmstream->loop_start_sample -= 5000;
//.........这里部分代码省略.........
开发者ID:Deinonychus71,项目名称:vgmstream,代码行数:101,代码来源:bfstm.c

示例10: find_key

/* return 0 if not found, 1 if found and set parameters */
static int find_key(STREAMFILE *file, uint8_t type, uint16_t *xor_start, uint16_t *xor_mult, uint16_t *xor_add)
{
    uint16_t * scales = NULL;
    uint16_t * prescales = NULL;
    int bruteframe=0,bruteframecount=-1;
    int startoff, endoff;
    int rc = 0;

    startoff=read_16bitBE(2, file)+4;
    endoff=(read_32bitBE(12, file)+31)/32*18*read_8bit(7, file)+startoff;

    /* how many scales? */
    {
        int framecount=(endoff-startoff)/18;
        if (framecount<bruteframecount || bruteframecount<0)
            bruteframecount=framecount;
    }

    /* find longest run of nonzero frames */
    {
        int longest=-1,longest_length=-1;
        int i;
        int length=0;
        for (i=0;i<bruteframecount;i++) {
            static const unsigned char zeroes[18]={0};
            unsigned char buf[18];
            read_streamfile(buf, startoff+i*18, 18, file);
            if (memcmp(zeroes,buf,18)) length++;
            else length=0;
            if (length > longest_length) {
                longest_length=length;
                longest=i-length+1;
                if (longest_length >= 0x8000) break;
            }
        }
        if (longest==-1) {
            goto find_key_cleanup;
        }
        bruteframecount = longest_length;
        bruteframe = longest;
    }

    {
        /* try to guess key */
#define MAX_FRAMES (INT_MAX/0x8000)
        int scales_to_do;
        int key_id;

        /* allocate storage for scales */
        scales_to_do = (bruteframecount > MAX_FRAMES ? MAX_FRAMES : bruteframecount);
        scales = malloc(scales_to_do*sizeof(uint16_t));
        if (!scales) {
            goto find_key_cleanup;
        }
        /* prescales are those scales before the first frame we test
         * against, we use these to compute the actual start */
        if (bruteframe > 0) {
            int i;
            /* allocate memory for the prescales */
            prescales = malloc(bruteframe*sizeof(uint16_t));
            if (!prescales) {
                goto find_key_cleanup;
            }
            /* read the prescales */
            for (i=0; i<bruteframe; i++) {
                prescales[i] = read_16bitBE(startoff+i*18, file);
            }
        }

        /* read in the scales */
        {
            int i;
            for (i=0; i < scales_to_do; i++) {
                scales[i] = read_16bitBE(startoff+(bruteframe+i)*18, file);
            }
        }

        if (type == 8)
        {
            /* guess each of the keys */
            for (key_id=0;key_id<keys_8_count;key_id++) {
                /* test pre-scales */
                uint16_t xor = keys_8[key_id].start;
                uint16_t mult = keys_8[key_id].mult;
                uint16_t add = keys_8[key_id].add;
                int i;

                for (i=0;i<bruteframe &&
                        ((prescales[i]&0x6000)==(xor&0x6000) ||
                         prescales[i]==0);
                        i++) {
                    xor = xor * mult + add;
                }

                if (i == bruteframe)
                {
                    /* test */
                    for (i=0;i<scales_to_do &&
                            (scales[i]&0x6000)==(xor&0x6000);i++) {
//.........这里部分代码省略.........
开发者ID:Deinonychus71,项目名称:vgmstream,代码行数:101,代码来源:adx_header.c

示例11: init_vgmstream_adx

VGMSTREAM * init_vgmstream_adx(STREAMFILE *streamFile) {
    VGMSTREAM * vgmstream = NULL;
    off_t stream_offset;
    uint16_t version_signature;
    int loop_flag=0;
    int channel_count, i, j, channel_header_spacing;
    int32_t loop_start_sample=0;
    int32_t loop_end_sample=0;
    meta_t header_type;
    int16_t coef1, coef2;
    uint16_t cutoff;
    char filename[PATH_LIMIT];
    int coding_type = coding_CRI_ADX;
    uint16_t xor_start=0,xor_mult=0,xor_add=0;
	/* Xenoblade Chronicles 3D uses an adx extension as with
	   the Wii version, but it's actually DSP ADPCM. Adding 
	   this flag to account for it. */
	int xb3d_flag = 0;
	
    /* check extension, case insensitive */
    streamFile->get_name(streamFile,filename,sizeof(filename));
    if (strcasecmp("adx",filename_extension(filename))) goto fail;

    /* check first 2 bytes */
    if ((uint16_t)read_16bitBE(0,streamFile)!=0x8000) {
		if (read_8bit(0,streamFile)!=2)goto fail;
		else {xb3d_flag = 1; coding_type = coding_NGC_DSP;}
	}
	
	if (xb3d_flag) {
		channel_count = read_32bitLE(0, streamFile);
		loop_flag = read_16bitLE(0x6e, streamFile);
		channel_header_spacing = 0x34;
	}
	else {
		/* get stream offset, check for CRI signature just before */
		stream_offset = (uint16_t)read_16bitBE(2,streamFile) + 4;
		if ((uint16_t)read_16bitBE(stream_offset-6,streamFile)!=0x2863 ||/* "(c" */
			(uint32_t)read_32bitBE(stream_offset-4,streamFile)!=0x29435249 /* ")CRI" */
		   ) goto fail;

		/* check for encoding type */
		/* 2 is for some unknown fixed filter, 3 is standard ADX, 4 is
		 * ADX with exponential scale, 0x11 is AHX */
		if (read_8bit(4,streamFile) != 3) goto fail;

		/* check for frame size (only 18 is supported at the moment) */
		if (read_8bit(5,streamFile) != 18) goto fail;

		/* check for bits per sample? (only 4 makes sense for ADX) */
		if (read_8bit(6,streamFile) != 4) goto fail;

		/* check version signature, read loop info */
		version_signature = read_16bitBE(0x12,streamFile);
		/* encryption */
		if (version_signature == 0x0408) {
			if (find_key(streamFile, 8, &xor_start, &xor_mult, &xor_add))
			{
				coding_type = coding_CRI_ADX_enc_8;
				version_signature = 0x0400;
			}
		}
		else if (version_signature == 0x0409) {
			if (find_key(streamFile, 9, &xor_start, &xor_mult, &xor_add))
			{
				coding_type = coding_CRI_ADX_enc_9;
				version_signature = 0x0400;
			}
		}

		if (version_signature == 0x0300) {      /* type 03 */
			header_type = meta_ADX_03;
			if (stream_offset-6 >= 0x2c) {   /* enough space for loop info? */
				loop_flag = (read_32bitBE(0x18,streamFile) != 0);
				loop_start_sample = read_32bitBE(0x1c,streamFile);
				//loop_start_offset = read_32bitBE(0x20,streamFile);
				loop_end_sample = read_32bitBE(0x24,streamFile);
				//loop_end_offset = read_32bitBE(0x28,streamFile);
			}
		} else if (version_signature == 0x0400) {

			off_t	ainf_info_length=0;

			if((uint32_t)read_32bitBE(0x24,streamFile)==0x41494E46) /* AINF Header */
				ainf_info_length = (off_t)read_32bitBE(0x28,streamFile);

			header_type = meta_ADX_04;
			if (stream_offset-ainf_info_length-6 >= 0x38) {   /* enough space for loop info? */
			if (read_32bitBE(0x24,streamFile) == 0xFFFEFFFE)
				loop_flag = 0;
			else
				loop_flag = (read_32bitBE(0x24,streamFile) != 0);

				loop_start_sample = read_32bitBE(0x28,streamFile);
				//loop_start_offset = read_32bitBE(0x2c,streamFile);
				loop_end_sample = read_32bitBE(0x30,streamFile);
				//loop_end_offset = read_32bitBE(0x34,streamFile);
			}
		} else if (version_signature == 0x0500) {			 /* found in some SFD : Buggy Heat, appears to have no loop */
			header_type = meta_ADX_05;
//.........这里部分代码省略.........
开发者ID:Deinonychus71,项目名称:vgmstream,代码行数:101,代码来源:adx_header.c

示例12: init_vgmstream_wii_ras

/* RAS (from Donkey Kong Country Returns) */
VGMSTREAM * init_vgmstream_wii_ras(STREAMFILE *streamFile) {
    VGMSTREAM * vgmstream = NULL;
    char filename[260];
    off_t start_offset;

    int loop_flag;
   int channel_count;

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

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

    loop_flag = 0;
    if (read_32bitBE(0x30,streamFile) != 0 ||
        read_32bitBE(0x34,streamFile) != 0 ||
        read_32bitBE(0x38,streamFile) != 0 ||
        read_32bitBE(0x3C,streamFile) != 0) {
        loop_flag = 1;
    }
    channel_count = 2;

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

   /* fill in the vital statistics */
    start_offset = read_32bitBE(0x18,streamFile);
    vgmstream->channels = channel_count;
    vgmstream->sample_rate = read_32bitBE(0x14,streamFile);
    vgmstream->coding_type = coding_NGC_DSP;
    vgmstream->num_samples = read_32bitBE(0x1c,streamFile)/channel_count/8*14;
    vgmstream->layout_type = layout_interleave;
	vgmstream->interleave_block_size = read_32bitBE(0x20,streamFile);
    vgmstream->meta_type = meta_WII_RAS;

    if (loop_flag) {
        // loop is block + samples into block
        vgmstream->loop_start_sample = 
        read_32bitBE(0x30,streamFile)*vgmstream->interleave_block_size/8*14 + 
            read_32bitBE(0x34,streamFile);
        vgmstream->loop_end_sample =
        read_32bitBE(0x38,streamFile)*vgmstream->interleave_block_size/8*14 +
            read_32bitBE(0x3C,streamFile);
    }

	 if (vgmstream->coding_type == coding_NGC_DSP) {
         int i;
         for (i=0;i<16;i++) {
            vgmstream->ch[0].adpcm_coef[i] = read_16bitBE(0x40+i*2,streamFile);
        }
	if (channel_count == 2) {
		  for (i=0;i<16;i++)
			vgmstream->ch[1].adpcm_coef[i] = read_16bitBE(0x70+i*2,streamFile);
				}
    } else {
        goto fail;
    }

    /* open the file for reading */
   {
        int i;
        for (i=0;i<channel_count;i++) {
            if (vgmstream->layout_type==layout_interleave_shortblock)
                vgmstream->ch[i].streamfile = streamFile->open(streamFile,filename,
                    vgmstream->interleave_block_size);
            else
                vgmstream->ch[i].streamfile = streamFile->open(streamFile,filename,
                    0x1000);

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

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

    return vgmstream;

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

示例13: init_vgmstream_genh


//.........这里部分代码省略.........
                                streamFile->open(streamFile,filename,interleave);
                        } else {
                            if (!chstreamfile)
                                chstreamfile =
                                    streamFile->open(streamFile,filename,STREAMFILE_DEFAULT_BUFFER_SIZE);
                        }
                        chstart_offset =
                            start_offset+vgmstream->interleave_block_size*i;
                    } else {
                        chstreamfile =
                            streamFile->open(streamFile,filename,
                                    STREAMFILE_DEFAULT_BUFFER_SIZE);
                    }
                    break;
                case coding_XBOX:
                case coding_MSADPCM:
                    /* xbox's "interleave" is a lie, all channels start at same
                     * offset */
                    chstreamfile =
                        streamFile->open(streamFile,filename,
                                STREAMFILE_DEFAULT_BUFFER_SIZE);
                    break;
                case coding_NGC_DTK:
                    if (!chstreamfile) 
                        chstreamfile =
                            streamFile->open(streamFile,filename,32*0x400);
                    break;
                case coding_NGC_DSP:
                    if (!chstreamfile) 
                        chstreamfile =
                            streamFile->open(streamFile,filename,STREAMFILE_DEFAULT_BUFFER_SIZE);

					for (j=0;j<16;j++) 
            			vgmstream->ch[i].adpcm_coef[j] = read_16bitBE(coef[i]+j*2,streamFile);
							chstart_offset =start_offset+vgmstream->interleave_block_size*i;
					break;

#ifdef VGM_USE_MPEG
                case coding_MPEG1_L3:
                    if (!chstreamfile)
                        chstreamfile =
                            streamFile->open(streamFile,filename,MPEG_BUFFER_SIZE);
                    break;
#endif
            }

            if (!chstreamfile) goto fail;

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

            vgmstream->ch[i].channel_start_offset=
                vgmstream->ch[i].offset=chstart_offset;
        }
    }

#ifdef VGM_USE_MPEG
    if (coding == coding_MPEG1_L3) {
        int rc;
        off_t read_offset;
        data = calloc(1,sizeof(mpeg_codec_data));
        if (!data) goto mpeg_fail;

        data->m = mpg123_new(NULL,&rc);
        if (rc==MPG123_NOT_INITIALIZED) {
            if (mpg123_init()!=MPG123_OK) goto mpeg_fail;
            data->m = mpg123_new(NULL,&rc);
开发者ID:Emiyasviel,项目名称:Arianrhod,代码行数:67,代码来源:genh.c

示例14: init_vgmstream_brstm

VGMSTREAM * init_vgmstream_brstm(STREAMFILE *streamFile) {
    VGMSTREAM * vgmstream = NULL;
    char filename[260];

    coding_t coding_type;

    off_t head_offset;
    int codec_number;
    int channel_count;
    int loop_flag;
    /* Certain Super Paper Mario tracks have a 44.1KHz sample rate in the
     * header, but they should be played at 22.05KHz. We will make this
     * correction if we see a file with a .brstmspm extension. */
    int spm_flag = 0;
    /* Trauma Center Second Opinion has an odd, semi-corrupt header */
    int atlus_shrunken_head = 0;

    off_t start_offset;

    /* check extension, case insensitive */
    streamFile->get_name(streamFile,filename,sizeof(filename));
    if (strcasecmp("brstm",filename_extension(filename))) {
        if (strcasecmp("brstmspm",filename_extension(filename))) goto fail;
        else spm_flag = 1;
    }

    /* check header */
    if ((uint32_t)read_32bitBE(0,streamFile)!=0x5253544D) /* "RSTM" */
        goto fail;
    if ((uint32_t)read_32bitBE(4,streamFile)!=0xFEFF0100)
    {
        if ((uint32_t)read_32bitBE(4,streamFile)!=0xFEFF0001)
            goto fail;
        else
            atlus_shrunken_head = 1;
    }

    /* get head offset, check */
    head_offset = read_32bitBE(0x10,streamFile);
    if (atlus_shrunken_head)
    {
        /* the HEAD chunk is where we would expect to find the offset of that
         * chunk... */

        if ((uint32_t)head_offset!=0x48454144 || read_32bitBE(0x14,streamFile) != 8)
            goto fail;

        head_offset = -8;   /* most of the normal Nintendo RSTM offsets work
                               with this assumption */
    }
    else
    {
    if ((uint32_t)read_32bitBE(head_offset,streamFile)!=0x48454144) /* "HEAD" */
        goto fail;
    }

    /* check type details */
    codec_number = read_8bit(head_offset+0x20,streamFile);
    loop_flag = read_8bit(head_offset+0x21,streamFile);
    channel_count = read_8bit(head_offset+0x22,streamFile);

    switch (codec_number) {
        case 0:
            coding_type = coding_PCM8;
            break;
        case 1:
            coding_type = coding_PCM16BE;
            break;
        case 2:
            coding_type = coding_NGC_DSP;
            break;
        default:
            goto fail;
    }

    if (channel_count < 1) goto fail;

    /* build the VGMSTREAM */

    vgmstream = allocate_vgmstream(channel_count,loop_flag);
    if (!vgmstream) goto fail;

    /* fill in the vital statistics */
    vgmstream->num_samples = read_32bitBE(head_offset+0x2c,streamFile);
    vgmstream->sample_rate = (uint16_t)read_16bitBE(head_offset+0x24,streamFile);
    /* channels and loop flag are set by allocate_vgmstream */
    vgmstream->loop_start_sample = read_32bitBE(head_offset+0x28,streamFile);
    vgmstream->loop_end_sample = vgmstream->num_samples;

    vgmstream->coding_type = coding_type;
    if (channel_count==1)
        vgmstream->layout_type = layout_none;
    else
        vgmstream->layout_type = layout_interleave_shortblock;
    vgmstream->meta_type = meta_RSTM;
    if (atlus_shrunken_head)
        vgmstream->meta_type = meta_RSTM_shrunken;

    if (spm_flag&& vgmstream->sample_rate == 44100) {
        vgmstream->meta_type = meta_RSTM_SPM;
//.........这里部分代码省略.........
开发者ID:flyingtime,项目名称:boxee,代码行数:101,代码来源:brstm.c

示例15: init_vgmstream_ngc_gcub

/* GCUB - found in 'Sega Soccer Slam' */
VGMSTREAM * init_vgmstream_ngc_gcub(STREAMFILE *streamFile) {
    VGMSTREAM * vgmstream = NULL;
    char filename[PATH_LIMIT];
    off_t start_offset;
    int loop_flag;
    int channel_count;

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

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

    loop_flag = 0;
    channel_count = read_32bitBE(0x04,streamFile);

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

    /* fill in the vital statistics */
    if (read_32bitBE(0x60,streamFile) == 0x47437878) /* "GCxx" */
    {
        start_offset = 0x88;
    }
    else
    {
        start_offset = 0x60;
    }

    vgmstream->channels = channel_count;
    vgmstream->sample_rate = read_32bitBE(0x08,streamFile);
    vgmstream->coding_type = coding_NGC_DSP;
    vgmstream->num_samples = (read_32bitBE(0x0C,streamFile)-start_offset)/8/channel_count*14;
    if (loop_flag) {
        vgmstream->loop_start_sample = 0;
        vgmstream->loop_end_sample = (read_32bitBE(0x0C,streamFile)-start_offset)/8/channel_count*14;
    }


    if (channel_count == 1)
    {
        vgmstream->layout_type = layout_none;
    }
    else
    {
        vgmstream->layout_type = layout_interleave;
        vgmstream->interleave_block_size = 0x8000; // read_32bitBE(0x04,streamFile);
    }

    vgmstream->meta_type = meta_NGC_GCUB;


    if (vgmstream->coding_type == coding_NGC_DSP) {
        int i;
        for (i=0; i<16; i++) {
            vgmstream->ch[0].adpcm_coef[i] = read_16bitBE(0x10+i*2,streamFile);
        }
        if (vgmstream->channels == 2) {
            for (i=0; i<16; i++) {
                vgmstream->ch[1].adpcm_coef[i] = read_16bitBE(0x30+i*2,streamFile);
            }
        }
    }

    /* 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;

            /* The first channel */
            vgmstream->ch[0].channel_start_offset=
                vgmstream->ch[0].offset=start_offset;

            /* The second channel */
            if (channel_count == 2) {
                vgmstream->ch[1].streamfile = streamFile->open(streamFile,filename,STREAMFILE_DEFAULT_BUFFER_SIZE);

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

                vgmstream->ch[1].channel_start_offset=
                    vgmstream->ch[1].offset=start_offset+vgmstream->interleave_block_size;
            }
        }
    }

    return vgmstream;

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


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