// buf void matrix_put(char* s, int dx, int dy, int dw, int dh) { unsigned char src[8]; decode2(s, src); for (int i = 0; i < dw; i++) { for (int j = 0; j < dh; j++) { int x = dx + i; int y = dy + j; if (x < 0 || y < 0 || x > 7 || y > 7) continue; PRESET(x, y); int n = (src[i] >> j) & 1; if (n) { PSET(x, y); } } } /* // dx = dy = 0; // dw = dh = 8; int mask = ((1 << dh) - 1) >> (8 - dh + dy); for (int i = 0; i < dw; i++) { int y = dx + i; if (y < 0 || y > 7) continue; buf[y] &= ~mask; buf[y] |= (src[i] >> dy) & mask; } */ }
int main( int argc, char const *const argv[] ) { curlCache_t &cache = getCurlCache(); curlFile_t f1( cache.get( "http://linuxbox/effects/push.mp3" ) ); curlFile_t f2( cache.get( "http://linuxbox/effects/release.mp3" ) ); if( f1.isOpen() && f2.isOpen() ) { pthread_t tHandle ; int const create = pthread_create( &tHandle, 0, audioOutputThread, 0 ); if( 0 == create ) { struct sched_param tsParam ; tsParam.__sched_priority = 1 ; pthread_setschedparam( tHandle, SCHED_FIFO, &tsParam ); threadHandle_ = (void *)tHandle ; madDecoder_t decode1( f1.getData(), f1.getSize() ); if( decode1.worked() ) { madDecoder_t decode2( f2.getData(), f2.getSize() ); if( decode2.worked() ) { item_t item1 ; item1.sampleRate_ = decode1.headers().playbackRate(); item1.numChannels_ = decode1.headers().numChannels(); item1.data_ = decode1.getSamples(); item1.length_ = decode1.numSamples(); item_t item2 ; item2.sampleRate_ = decode2.headers().playbackRate(); item2.numChannels_ = decode2.headers().numChannels(); item2.data_ = decode2.getSamples(); item2.length_ = decode2.numSamples(); int uS = ( 2 == argc ) ? atoi( argv[1] ) : 20000 ; while( 1 ) { printf( "playback\n" ); queue_.push( item1 ); usleep( uS ); queue_.push( item2 ); sleep( 5 ); } } else fprintf( stderr, "Error decoding file2\n" ); } else fprintf( stderr, "Error decoding file1\n" ); } else fprintf( stderr, "Error %m creating curl-reader thread\n" ); } else fprintf( stderr, "Error opening test files\n" ); return 0 ; }
int main(){ int r = decode2(1,2,5); printf("Result: %i\nHex: %x\n", r, r); }
Surface ShpFile::decodeDune(uint16_t fileIndex) { uint8_t *imageOut, slices; uint16_t flags, fileSize, imageSize, imageOutSize, width, height; std::vector<uint8_t> palOffsets, decodeDestination; _stream.seekg(_index.at(fileIndex).startOffset, std::ios::beg); flags = _stream.getU16LE(); slices = _stream.get(); width = _stream.getU16LE(); height = _stream.get(); fileSize = _stream.getU16LE(); /* size and also checksum */ imageSize = _stream.getU16LE(); imageOut = new uint8_t[imageOutSize = width*height]; LOG_INFO("ShpFile", "File Nr.: %d (Size: %dx%d)",fileIndex,width,height); switch(flags) { case 0: decodeDestination.resize(imageSize); if(decode80(&decodeDestination.front(), imageSize) == -1) LOG_WARNING("ShpFile","Checksum-Error in Shp-File"); decode2(decodeDestination, imageOut); break; case 1: decodeDestination.resize(imageSize); palOffsets.resize(16); _stream.read(reinterpret_cast<char*>(&palOffsets.front()), palOffsets.size()); if(decode80(&decodeDestination.front(), imageSize) == -1) LOG_WARNING("ShpFile", "Checksum-Error in Shp-File"); decode2(decodeDestination, imageOut); apply_pal_offsets(palOffsets,imageOut, imageOutSize); break; case 2: #if 0 //FIXME decode2(_stream, imageOut, imageSize); #else decodeDestination.resize(imageSize); _stream.read(reinterpret_cast<char*>(&decodeDestination.front()), imageSize); decode2(decodeDestination, imageOut); #endif break; case 3: palOffsets.resize(16); _stream.read(reinterpret_cast<char*>(&palOffsets.front()), palOffsets.size()); #if 0 //FIXME decode2(_stream, imageOut, imageSize); #else decodeDestination.resize(imageSize); _stream.read(reinterpret_cast<char*>(&decodeDestination.front()), imageSize); decode2(decodeDestination, imageOut); #endif apply_pal_offsets(palOffsets, imageOut, imageOutSize); break; default: throw(Exception(LOG_ERROR, "ShpFile", "Type %d in SHP-Files not supported!", flags)); } return Surface(imageOut, width, height, 8, _palette); }