全部文本 #298428 原始 编辑

Miscellany

公开 text v1 · 不可变
·已发布 2006-12-31 22:49 UTC
渲染后的文本正文
FOOIDAPI int fp_calculate(t_fooid *fi, int songlen, unsigned char* buff)

{        

    /*
        we need at least 10 seconds of usable data or so
	 || fi->outpos < (8000 * 10)
    */    

    if (songlen < 1000 || !fi->soundfound) {
        return -1;
    }

    fi->fp.length = songlen;    
    get_params(fi);    
    
    /*
        now pack our structure into the minimal space
        possible
    */ 
    buff = malloc(sizeof(buff));
    memmove(buff, &(fi->fp.version), sizeof(short));

    buff += sizeof(short);
    memcpy(buff, &(fi->fp.length), sizeof(int));

    buff += sizeof(int);
    memcpy(buff, &(fi->fp.avg_fit), sizeof(short));

    buff += sizeof(short);
    memcpy(buff, &(fi->fp.avg_dom), sizeof(short));

    buff += sizeof(short);
    memcpy(buff, &(fi->fp.r), sizeof(unsigned char) * 348);

    buff += sizeof(unsigned char) * 348;
    memcpy(buff, &(fi->fp.dom), sizeof(unsigned char) * 66);

    buff += sizeof(unsigned char) * 66;     

    return 0;

}