O3DGCErrorCode LoadBinAC(Vector<long> & data, const BinaryStream & bstream, unsigned long & iterator) { size_t sizeSize = bstream.ReadUInt32Bin(iterator) - 8; size_t size = bstream.ReadUInt32Bin(iterator); if (size == 0) { return O3DGC_OK; } unsigned char * buffer = 0; bstream.GetBuffer(iterator, buffer); iterator += sizeSize; data.Allocate(size); Arithmetic_Codec acd; acd.set_buffer(sizeSize, buffer); acd.start_decoder(); Adaptive_Bit_Model bModel; #ifdef DEBUG_VERBOSE printf("-----------\nsize %i\n", size); fprintf(g_fileDebugTF, "size %i\n", size); #endif //DEBUG_VERBOSE for(size_t i = 0; i < size; ++i) { data.PushBack(acd.decode(bModel)); #ifdef DEBUG_VERBOSE printf("%i\t%i\n", i, data[i]); fprintf(g_fileDebugTF, "%i\t%i\n", i, data[i]); #endif //DEBUG_VERBOSE } return O3DGC_OK; }
O3DGCErrorCode LoadUIntAC(Vector<long> & data, const unsigned long M, const BinaryStream & bstream, unsigned long & iterator) { unsigned long sizeSize = bstream.ReadUInt32Bin(iterator) - 12; unsigned long size = bstream.ReadUInt32Bin(iterator); if (size == 0) { return O3DGC_OK; } long minValue = bstream.ReadUInt32Bin(iterator); unsigned char * buffer = 0; bstream.GetBuffer(iterator, buffer); iterator += sizeSize; data.Allocate(size); Arithmetic_Codec acd; acd.set_buffer(sizeSize, buffer); acd.start_decoder(); Adaptive_Data_Model mModelValues(M+1); #ifdef DEBUG_VERBOSE printf("-----------\nsize %i\n", size); fprintf(g_fileDebugTF, "size %i\n", size); #endif //DEBUG_VERBOSE for(unsigned long i = 0; i < size; ++i) { data.PushBack(acd.decode(mModelValues)+minValue); #ifdef DEBUG_VERBOSE printf("%i\t%i\n", i, data[i]); fprintf(g_fileDebugTF, "%i\t%i\n", i, data[i]); #endif //DEBUG_VERBOSE } return O3DGC_OK; }
O3DGCErrorCode LoadIntACEGC(Vector<long> & data, const unsigned long M, const BinaryStream & bstream, unsigned long & iterator) { size_t sizeSize = bstream.ReadUInt32Bin(iterator) - 12; size_t size = bstream.ReadUInt32Bin(iterator); if (size == 0) { return O3DGC_OK; } long minValue = bstream.ReadUInt32Bin(iterator) - O3DGC_MAX_LONG; unsigned char * buffer = 0; bstream.GetBuffer(iterator, buffer); iterator += sizeSize; data.Allocate(size); Arithmetic_Codec acd; acd.set_buffer(sizeSize, buffer); acd.start_decoder(); Adaptive_Data_Model mModelValues(M+2); Static_Bit_Model bModel0; Adaptive_Bit_Model bModel1; unsigned long value; #ifdef DEBUG_VERBOSE printf("-----------\nsize %i\n", size); fprintf(g_fileDebugTF, "size %i\n", size); #endif //DEBUG_VERBOSE for(size_t i = 0; i < size; ++i) { value = acd.decode(mModelValues); if ( value == M) { value += acd.ExpGolombDecode(0, bModel0, bModel1); } data.PushBack(value + minValue); #ifdef DEBUG_VERBOSE printf("%i\t%i\n", i, data[i]); fprintf(g_fileDebugTF, "%i\t%i\n", i, data[i]); #endif //DEBUG_VERBOSE } #ifdef DEBUG_VERBOSE fflush(g_fileDebugTF); #endif //DEBUG_VERBOSE return O3DGC_OK; }