ByteStream included

BitStream removed

git-svn-id: https://svn.code.sf.net/p/openv2g/code/trunk@19 d9f2db14-54d0-4bde-b00c-16405c910529
This commit is contained in:
sebastiankb 2010-10-22 15:36:23 +00:00
parent 32f7bfd532
commit fa292b984e
2 changed files with 12 additions and 34 deletions

View file

@ -33,13 +33,12 @@
#include "EXITypes.h"
#ifndef BIT_STREAM_C
#define BIT_STREAM_C
#ifndef BYTE_STREAM_C
#define BYTE_STREAM_C
int toBitstream(const char * filename, bitstream_t* bitstream) {
int readBytesFromFile(const char * filename, uint8_t* data, size_t size, size_t pos) {
FILE* f;
int character;
size_t len = 0, pos = 0, i;
f = fopen(filename, "rb");
@ -47,32 +46,18 @@ int toBitstream(const char * filename, bitstream_t* bitstream) {
printf("\n[Error] no valid file handle !\n");
return -1;
} else {
/* detect file size */
/* read bytes */
while ((character = getc(f)) != EOF) {
if (pos >= size) {
return -1;
}
data[pos++] = (uint8_t) character;
/* printf("%u \n", character); */
len++;
}
fclose(f);
/* printf("%u Zeichen", len); */
/* setup stream */
bitstream->data = malloc(sizeof(uint8_t) * len);
bitstream->size = len;
bitstream->pos = &pos;
bitstream->buffer = 0;
bitstream->capacity = 8;
/* read file byte per byte */
f = fopen(filename, "rb");
i = 0;
while ((character = getc(f)) != EOF) {
bitstream->data[i] = (uint8_t) character;
i++;
}
fclose(f);
}
return 0;
return pos;
}
int writeBytesToFile(uint8_t* data, size_t len, const char * filename) {
@ -93,11 +78,6 @@ int writeBytesToFile(uint8_t* data, size_t len, const char * filename) {
}
}
int writeBitstreamToFile(bitstream_t* bitsream, const char * filename) {
return writeBytesToFile(bitsream->data, bitsream->size, filename);
}
#endif

View file

@ -31,14 +31,12 @@ extern "C" {
#include "EXITypes.h"
#ifndef BIT_STREAM_H
#define BIT_STREAM_H
#ifndef BYTE_STREAM_H
#define BYTE_STREAM_H
int writeBytesToFile(uint8_t* data, size_t len, const char * filename);
int writeBitstreamToFile(bitstream_t* bitsream, const char * filename);
int toBitstream(const char * filename, bitstream_t* bitstream);
int readBytesFromFile(const char * filename, uint8_t* data, size_t size, size_t pos);
#endif