[mndiff]: r78 - in trunk/noe: bytestream.h filerw.c filerw.h galois.c gfft.c noe.c noe_internal.h rs.c rw.c rw.h test.c
Author: michael Date: Tue Jul 10 00:20:07 2007 New Revision: 78 Log: version from 2003-09-24 00:02 Added: trunk/noe/bytestream.h trunk/noe/noe.c Modified: trunk/noe/filerw.c trunk/noe/filerw.h trunk/noe/galois.c trunk/noe/gfft.c trunk/noe/noe_internal.h trunk/noe/rs.c trunk/noe/rw.c trunk/noe/rw.h trunk/noe/test.c Added: trunk/noe/bytestream.h ============================================================================== --- (empty file) +++ trunk/noe/bytestream.h Tue Jul 10 00:20:07 2007 @@ -0,0 +1,153 @@ +/* + * Copyright (C) 2003 Michael Niedermayer <michaelni@gmx.at> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +typedef struct ByteStream{ + uint8_t *buf; + uint8_t *buf_ptr; +// int length; + uint8_t *buf_end; +}ByteStream; + +static inline void initByteStream(ByteStream *bc, uint8_t *buf, int length){ + bc->buf= + bc->buf_ptr= buf; +// bc->length= length; + bc->buf_end= bc->buf + length; +} + +static inline int spaceLeft(ByteStream *bc){ +// return bc->length - ((int)(bc->buf_ptr - bc->buf)); + return ((int)(bc->buf_end - bc->buf_ptr)); +} + +/** + * + * @return <0 if an error occured + */ +static inline uint64_t get_v(ByteStream *bc){ + uint64_t val= 0; + + for(; spaceLeft(bc) > 0; ){ + int tmp= *(bc->buf_ptr++); + if(tmp&0x80) + val= (val<<7) + tmp - 0x80; + else + return (val<<7) + tmp; + } + + return -1; +} + +/** + * + * @return <0 if an error occured + */ +static inline int put_v(ByteStream *bc, uint64_t val){ + int i; + + if(spaceLeft(bc) < 9) return -1; //FIXME + + val &= 0x7FFFFFFFFFFFFFFFULL; // FIXME can only encode upto 63 bits currently + for(i=7; ; i+=7){ + if(val>>i == 0) break; + } + + for(i-=7; i>0; i-=7){ + *(bc->buf_ptr++)= 0x80 | (val>>i); + } + *(bc->buf_ptr++)= val&0x7F; + + return 0; +} + +/** + * + */ +static inline uint64_t get_c(ByteStream *bc, int length){ + uint64_t val= 0; + + for(i=length-1; i>=0; i--){ + val |= (*(bc->buf_ptr++)) << (8*i) ; + } + return val; +} + +/** + * + */ +static inline void put_c(ByteStream *bc, uint64_t val, int length){ + int i; + + for(i=length-1; i>=0; i--){ + *(bc->buf_ptr++)= val >> (i*8); + } +} + +/** + * + * @return <0 if an error occured + */ +static inline int get_buffer(ByteStream *bc, uint8_t *dst, int length){ + int i; + + if(length > spaceLeft(bc) || length<0) return -1; + + for(i=0; i<length; i++){ + dst[i]= *(bc->buf_ptr++); + } + + return 0; +} + +/** + * + * @return <0 if an error occured + */ +static inline int put_buffer(ByteStream *bc, uint8_t *src, int length){ + int i; + + if(length > spaceLeft(bc)) return -1; + + for(i=0; i<length; i++){ + *(bc->buf_ptr++)= src[i]; + } + + return 0; +} + +#if 1 // just do a *_v() *_buffer() +/** + * + * @return <0 if an error occured + */ +static inline int get_b(ByteStream *bc, uint8_t *dst, int max_length){ + const int length= get_v(bc); + if(length > max_length) return -1; + + return get_buffer(bc, dst, length); +} + +/** + * + * @return <0 if an error occured + */ +static inline int put_b(ByteStream *bc, uint8_t *src, int length){ + put_v(bc, length); + return put_buffer(bc, src, length); +} +#endif \ No newline at end of file Modified: trunk/noe/filerw.c ============================================================================== --- trunk/noe/filerw.c (original) +++ trunk/noe/filerw.c Tue Jul 10 00:20:07 2007 @@ -1,5 +1,5 @@ /* - * Copyright (C) 2002 Michael Niedermayer <michaelni@gmx.at> + * Copyright (C) 2003 Michael Niedermayer <michaelni@gmx.at> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -19,6 +19,7 @@ #include <inttypes.h> #include <stdio.h> #include <stdlib.h> +#include <string.h> #include "rw.h" #include "filerw.h" @@ -34,18 +35,21 @@ static uint64_t fsize(FILE *f){ return size; } -static int fileRead(noe_RwContext *c, uint8_t *data, uint64_t pos, int len){ +static int fileIO(noe_RwContext *c, uint8_t *data, uint64_t pos, int len, int write){ int i; - noe_FileRwContext *p= (noe_FileRwContext *)c->priv; + noe_FileRwContext *p= (noe_FileRwContext *)c; for(i=0; i<p->fileCount; i++){ - if(p->offset[i] > pos){ + if(p->end[i] > pos){ int e; - uint64_t currentLen= pos - p->offset[i]; + uint64_t currentLen= pos - p->end[i]; if(currentLen > len) currentLen= len; if(currentLen <= 0) return -1; - e= fread(data, currentLen, 1, p->file[i]); + if(write) + e= fwrite(data, currentLen, 1, p->file[i]); + else + e= fread(data, currentLen, 1, p->file[i]); if(e!=1) return -1; len -= currentLen; @@ -57,51 +61,48 @@ static int fileRead(noe_RwContext *c, ui return -1; } -static int fileWrite(noe_RwContext *c, uint8_t *data, uint64_t pos, int len){ - return -1; -} - static void fileUninit(noe_RwContext *c){ int i; - noe_FileRwContext *p; + noe_FileRwContext *p= (noe_FileRwContext *)c; if(c==NULL) return; - p = (noe_FileRwContext *)c->priv; - for(i=0; i<p->fileCount; i++){ fclose(p->file[i]); } free(p->file); - free(p->offset); + free(p->end); + memset(p, 0, sizeof(noe_FileRwContext)); free(p); - free(c); } noe_RwContext *noe_getFileRwContext(char **fileNames, int fileCount, char *access){ int i; uint64_t pos; - noe_RwContext *c= malloc(sizeof(noe_RwContext)); noe_FileRwContext *p= malloc(sizeof(noe_FileRwContext)); + noe_RwContext *c= (noe_RwContext *)p; - c->priv= p; c->parent= NULL; p->file= malloc(sizeof(FILE)*fileCount); - p->offset= malloc(sizeof(uint64_t)*fileCount); + p->end= malloc(sizeof(uint64_t)*fileCount); - c->read= fileRead; - c->write= fileWrite; + c->io= fileIO; c->uninit= fileUninit; pos=0; for(i=0; i<fileCount; i++){ p->file[i]= fopen(fileNames[i], access); - if(p->file[i]==NULL) return NULL; + if(p->file[i]==NULL) goto fail; pos+= fsize(p->file[i]); - p->offset[i]= pos; + p->end[i]= pos; } + p->size= pos; return c; + + fail: + fileUninit(c); + return NULL; } Modified: trunk/noe/filerw.h ============================================================================== --- trunk/noe/filerw.h (original) +++ trunk/noe/filerw.h Tue Jul 10 00:20:07 2007 @@ -1,5 +1,5 @@ /* - * Copyright (C) 2002 Michael Niedermayer <michaelni@gmx.at> + * Copyright (C) 2003 Michael Niedermayer <michaelni@gmx.at> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -17,9 +17,14 @@ */ typedef struct noe_FileRwContext{ + noe_RwContext rw; FILE **file; - uint64_t *offset; + + /** + * end of the ith file. + */ + uint64_t *end; int fileCount; }noe_FileRwContext; -//FIXME move to .c if this is the only thing here \ No newline at end of file +//FIXME move to .c if this is the only thing here Modified: trunk/noe/galois.c ============================================================================== --- trunk/noe/galois.c (original) +++ trunk/noe/galois.c Tue Jul 10 00:20:07 2007 @@ -1,5 +1,5 @@ /* - * Copyright (C) 2002 Michael Niedermayer <michaelni@gmx.at> + * Copyright (C) 2003 Michael Niedermayer <michaelni@gmx.at> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -21,6 +21,7 @@ #include <inttypes.h> #include <assert.h> #include <stdio.h> +#include <string.h> #include "noe_internal.h" #include "galois.h" Modified: trunk/noe/gfft.c ============================================================================== --- trunk/noe/gfft.c (original) +++ trunk/noe/gfft.c Tue Jul 10 00:20:07 2007 @@ -1,5 +1,5 @@ /* - * Copyright (C) 2002 Michael Niedermayer <michaelni@gmx.at> + * Copyright (C) 2003 Michael Niedermayer <michaelni@gmx.at> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -19,6 +19,7 @@ #include <inttypes.h> #include <assert.h> #include <stdio.h> +#include <string.h> #include "noe_internal.h" #include "galois.h" Added: trunk/noe/noe.c ============================================================================== --- (empty file) +++ trunk/noe/noe.c Tue Jul 10 00:20:07 2007 @@ -0,0 +1,281 @@ +/* + * Copyright (C) 2003 Michael Niedermayer <michaelni@gmx.at> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include <inttypes.h> + +static const uint8_t startcode[8]={0xAB, 0x2C, 0xE2, 0x47, 0x15, 'N', 'O', 'E'}; +//#define STARTCODE (0xAB2CE24715000000ULL + ('N'<<16) + ('O'<<8) + 'E') +#define STARTCODE_THRESHOLD 6 +#define HEADER_PARITY_LENGTH 26 +#define HEADER_LENGTH (38 + HEADER_PARITY_LENGTH) +#define BUFFER_LENGTH 262144 + +typedef struct NoeContext{ + int debug; + int fileId; + int fileChecksum; + int fileIdThreshold; + int seqNum; + int headerCount; + int parityCount; + int fingerprintCount; + int flags; + int dataSize; + int header[HEADER_LENGTH][256]; +}NoeContext; + +const static uint8_t parity[256]={ +0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0, +1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1, +1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1, +0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0, +1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1, +0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0, +0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0, +1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1, +1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1, +0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0, +0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0, +1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1, +0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0, +1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1, +1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1, +0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0, +}; + +/** + * + * @return length if not found + */ +static uint64_t find_header(NoeContext *n, uint8_t *buffer, uint64_t length){ + int i; + + for(i=0; i + HEADER_LENGTH < length; i++){ + int j; + int score=8; + + for(j=0; j<8; j++){ + if(buffer[i + j] != startcode[j]){ + score--; + if(score < STARTCODE_THRESHOLD) break; + } + } + if(score < STARTCODE_THRESHOLD) continue; + + score=8; + for(j=0; j<4; j++){ //FIXME cleaner? + if(buffer[i + 12 + j] != ((n->fileChecksum >> (24 - 8*j)) & 0xFF)) + score--; + } + for(j=0; j<4; j++){ + if(buffer[i + 16+ j] != ((n->fileId >> (24 - 8*j)) & 0xFF)) + score--; + } + if(score < n->fileIdThreshold) continue; + + return i; + } + + return length; +} + +static int decode_header(NoeContext *n, uint8_t *buffer){ + ByteStream bc; + int erasedCount=0; //FIXME + const int n= SIZE - 1; + const int k= SIZE - 1 - HEADER_PARITY_LENGTH; + GFF4Element erased[HEADER_PARITY_LENGTH]; + GFF4Element code[n]; + int i,j; + + for(j=0; j<8; j++){ + buffer[j] = startcode[j]; + } + + for(i=12; i<HEADER_LENGTH - HEADER_PARITY_LENGTH; i++){ + int best=0; + int bestScore=0; + + for(j=0; j<256; j++){ + const int score= n->header[i][j]; + if(score > bestScore){ + bestScore= score; + best= j; + } + } + buffer[i]= best; //FIXME dont modify it / load into code directly + } + + initByteStream(&bc, buffer, HEADER_LENGTH); + + memset(code, 0, sizeof(GFF4Element)*n); + for(i=0; 2*i<HEADER_LENGTH - HEADER_PARITY_LENGTH; i++){ + code[i ]= get_c(bc, 2); + } + for(i=0; 2*i<HEADER_PARITY_LENGTH; i++){ + code[k+i]= get_c(bc, 2); + } + + if(noe_rsDecode(code, erased, erasedCount, HEADER_PARITY_LENGTH) < 0) + return -1; + + for(i=HEADER_LENGTH - HEADER_PARITY_LENGTH; i<k; i++){ + if(code[i] != 0) + return -2; + } + for(i=0; i<8; i++){ + if(buffer[i] != startcode[i]) + return -2; + } + + // noe_printPoly(gen, i); + // noe_printPoly(syn, i-1); + + for(i=0; 2*i<HEADER_LENGTH - HEADER_PARITY_LENGTH; i++){ + buffer[2*i+0]= code[ i] >> 8; + buffer[2*i+1]= code[ i]; + } + for(i=0; 2*i<HEADER_PARITY_LENGTH; i++){ + const int j= i + (HEADER_LENGTH - HEADER_PARITY_LENGTH)/2; + buffer[2*j+0]= code[k+i] >> 8; + buffer[2*j+1]= code[k+i]; + } + + initByteStream(&bc, buffer, HEADER_LENGTH); + + get_c(bc, 8); + n->seqNum= get_c(bc, 4); + n->fileChecksum= get_c(bc, 4); + n->fileId= get_c(bc, 4); + n->version= get_c(bc, 1); + if(n->version > 0) + return -3; + + n->flags= get_c(bc, 1); + n->headerCount= get_c(bc, 4); + if(n->seqNum >= n->headerCount) + return -2; + + n->parityCount= get_c(bc, 2); + n->fingerprintCount= get_c(bc, 2); + n->dataSize= get_c(bc, 8); + + for(i=12; i<HEADER_LENGTH - HEADER_PARITY_LENGTH; i++){ + n->header[i][ buffer[i] ]= INT_MAX/2; + } + + return n->seqNum; +} + + +/** + * + * @return -1 if not found + */ +static int find_and_decode_global_header(NoeContext *n, noe_RwContext *rw){ + int length= BUFFER_LENGTH + uint64_t i; + uint8_t buffer[length]; + + for(i=rw->size; i>=0; i-= length - HEADER_LENGTH){ + int pos; + + if(i < length) length= i; + rw->io(rw, buffer, i - length, length, 0); + + for(pos=0; ; pos++){ + int j; + pos += find_header(n, buffer + pos, length - pos); + if(pos >= length) break; + + for(j=0; j<HEADER_LENGTH; j++){ //FIXME bitwise histogram? + const int c= buffer[pos + j] + n->header[j][c]++; + } + + if( decode_header(n, buffer + pos) >= 0) + return 0; + } + length= BUFFER_LENGTH; + } + + return -1; +} + +static inline int getChecksum(unsigned int fingerprint, unsigned int pos){ + return (fingerprint ^ pos) % 251; +} + +static int decode_fingerprints(NoeContext *n, uint8_t *buffer, int length){ + int i, count; + ByteStream bc; + + count= MIN(n->fingerprintCount, length/5); + + initByteStream(&bc, buffer, 5*count); + for(i=0; i<count; i++){ + const unsigned int c= get_c(bc, 4); + const int checksum= get_c(bc, 1); + const int index= n->seqNum + i*n->headerCount; + const int expectedChecksum= getChecksum(c, index); + + if(expectedChecksum == checksum){ + n->fingerprintOk[index]= 1; + n->fingerprint[index]= c; + }//FIXME resync + } +} + +/** + * + * @return -1 if not found + */ +static int find_and_decode_packets(NoeContext *n, noe_RwContext *rw){ + int length= BUFFER_LENGTH + const int packetLength= HEADER_LENGTH + 5*n->fingerprintCount; + uint64_t i; + uint8_t buffer[length]; + + n->fingerprint = malloc(n->fingerprintCount*n->headerCount * sizeof(int)); + n->fingerprintOk= malloc(n->fingerprintCount*n->headerCount); + memset(n->fingerprintOk, 0, n->fingerprintCount*n->headerCount); + + for(i=rw->size; i>=0; i-= length - packetLength){ + int pos; + + if(i < length) length= i; + rw->io(rw, buffer, i - length, length, 0); + + for(pos=0; ; pos++){ + int j; + pos += find_header(n, buffer + pos, length - pos); + if(pos >= length) break; + + if( decode_header(n, buffer + pos) < 0 ) + continue; + pos += HEADER_LENGTH; + + decode_fingerprints(n, buffer + pos, length - pos); + } + length= BUFFER_LENGTH; + + //FIXME detect if enough packets + } + + return -1; +} Modified: trunk/noe/noe_internal.h ============================================================================== --- trunk/noe/noe_internal.h (original) +++ trunk/noe/noe_internal.h Tue Jul 10 00:20:07 2007 @@ -1,5 +1,5 @@ /* - * Copyright (C) 2002 Michael Niedermayer <michaelni@gmx.at> + * Copyright (C) 2003 Michael Niedermayer <michaelni@gmx.at> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -47,4 +47,6 @@ if(tcount<2 || tend - tstart < 4*tsum/tc if(256*256*256*64%tcount==0){\ fprintf(stderr, "%Ld dezicycles, %d runs, %d skips\n", tsum*10/tcount, tcount, tskip_count);\ fflush(stderr);\ -} \ No newline at end of file +} + + Modified: trunk/noe/rs.c ============================================================================== --- trunk/noe/rs.c (original) +++ trunk/noe/rs.c Tue Jul 10 00:20:07 2007 @@ -1,5 +1,5 @@ /* - * Copyright (C) 2002 Michael Niedermayer <michaelni@gmx.at> + * Copyright (C) 2003 Michael Niedermayer <michaelni@gmx.at> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -20,6 +20,7 @@ #include <assert.h> #include <malloc.h> #include <stdio.h> +#include <string.h> #include "noe_internal.h" #include "galois.h" Modified: trunk/noe/rw.c ============================================================================== --- trunk/noe/rw.c (original) +++ trunk/noe/rw.c Tue Jul 10 00:20:07 2007 @@ -1,5 +1,5 @@ /* - * Copyright (C) 2002 Michael Niedermayer <michaelni@gmx.at> + * Copyright (C) 2003 Michael Niedermayer <michaelni@gmx.at> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -17,24 +17,21 @@ */ #include <inttypes.h> +#include <stdlib.h> +#include <string.h> #include "rw.h" -typedef struct noe_Map{ - uint64_t src; - uint64_t dst; - uint64_t len; -}noe_Map; - typedef struct noe_RemapRwContext{ - Map *map; + noe_RwContext rw; + noe_Map *map; int count; }noe_RemapRwContext; -static int noe_remapRead(noe_RwContext *c, uint8_t *data, uint64_t pos, int len){ +static int remapIO(noe_RwContext *c, uint8_t *data, uint64_t pos, int len, int write){ int i; - noe_RemapRwContext *p= (noe_RemapRwContext *)c->priv; + noe_RemapRwContext * const p= (noe_RemapRwContext *)c; noe_RwContext *parent= c->parent; //FIXME do binary search or cache last @@ -45,7 +42,7 @@ static int noe_remapRead(noe_RwContext * uint64_t currentLen= p->map[i].src + p->map[i].len - pos; if(currentLen > len) currentLen= len; - parent->read(parent, data, pos + diff, currentLen); + parent->io(parent, data, pos + diff, currentLen, write); data+= currentLen; pos+= currentLen; @@ -58,35 +55,28 @@ static int noe_remapRead(noe_RwContext * } static void remapUninit(noe_RwContext *c){ - int i; - noe_RemapRwContext *p; + noe_RemapRwContext * const p= (noe_RemapRwContext *)c; if(c==NULL) return; - p = (noe_RemapRwContext *)c->priv; - free(p->map); + memset(p, 0, sizeof(noe_RemapRwContext)); free(p); - free(c); } -noe_RwContext *noe_getRemapRwContext(noe_RwContext *parent, uint64_t *map, int count){ - int i; - uint64_t pos; - noe_RwContext *c= malloc(sizeof(noe_RwContext)); +noe_RwContext *noe_getRemapRwContext(noe_RwContext *parent, noe_Map *map, int count){ noe_RemapRwContext *p= malloc(sizeof(noe_RemapRwContext)); + noe_RwContext *c= (noe_RwContext*)p; - c->priv= p; c->parent= parent; p->map= malloc(sizeof(noe_Map)*count); memcpy(p->map, map, sizeof(noe_Map)*count); p->count= count; - //FIXME sort map ? + //FIXME sort map - c->read= remapRead; - c->write= remapWrite; + c->io= remapIO; c->uninit= remapUninit; return c; Modified: trunk/noe/rw.h ============================================================================== --- trunk/noe/rw.h (original) +++ trunk/noe/rw.h Tue Jul 10 00:20:07 2007 @@ -1,5 +1,5 @@ /* - * Copyright (C) 2002 Michael Niedermayer <michaelni@gmx.at> + * Copyright (C) 2003 Michael Niedermayer <michaelni@gmx.at> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -17,9 +17,21 @@ */ typedef struct noe_RwContext{ - int (*read )(struct noe_RwContext *context, uint8_t *data, uint64_t pos, int len); - int (*write)(struct noe_RwContext *context, uint8_t *data, uint64_t pos, int len); + uint64_t size; + + /** + * reads or writes some data. + * @returns <0 if an error occured + */ + int (*io )(struct noe_RwContext *context, uint8_t *data, uint64_t pos, int len, int write); + void (*uninit)(struct noe_RwContext *context); struct noe_RwContext *parent; - void *priv; -}noe_RwContext; \ No newline at end of file +}noe_RwContext; + +typedef struct noe_Map{ + uint64_t src; + uint64_t dst; + uint64_t len; +}noe_Map; + Modified: trunk/noe/test.c ============================================================================== --- trunk/noe/test.c (original) +++ trunk/noe/test.c Tue Jul 10 00:20:07 2007 @@ -1,5 +1,5 @@ /* - * Copyright (C) 2002 Michael Niedermayer <michaelni@gmx.at> + * Copyright (C) 2003 Michael Niedermayer <michaelni@gmx.at> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -21,11 +21,13 @@ #include <stdio.h> #include <time.h> #include <stdlib.h> +#include <string.h> #include "noe_internal.h" #include "galois.h" #include "gfft.h" #include "rs.h" +#include "bytestream.h" static const unsigned int gfftChecksums[20]={ 0xFCB3E495, @@ -187,7 +189,7 @@ int main(){ for(i=1; i<2000; i+=100){ int n= SIZE - 1; int k= SIZE - 1 - i; - GFF4Element syn[n]; +// GFF4Element syn[n]; GFF4Element erased[i]; GFF4Element data[k]; GFF4Element code[n]; @@ -250,7 +252,32 @@ int main(){ } noe_freeRsEncoder(encoder); } + { + uint8_t buffer[20000]; + uint32_t val[2000]; + ByteStream bs; + printf("\nTesting v coder"); + + initByteStream(&bs, buffer, 20000); + for(i=0; i<2000; i++){ + int len= rand()%32; + val[i] = rand() % (1<<len); + put_v(&bs, val[i]); + if(i%100 == 0) printf("."); + } + + initByteStream(&bs, buffer, 20000); + for(i=0; i<2000; i++){ + if(val[i] != get_v(&bs)){ + printf("FAIL\n"); + break; + } + if(i%100 == 0) printf("."); + } + } + + printf("\n"); return 0; printf("Testing erasure decoding\n");
participants (1)
-
michael