void test_DCT_and_IDCT_with_quantization_and_dequantization(){ float imageMatrix[8][8] = {{139, 144, 149, 153, 155, 155, 155, 155}, {144, 151, 153, 156, 159, 156, 156, 156}, {150, 155, 160, 163, 158, 156, 156, 156}, {159, 161, 162, 160, 160, 159, 159, 159}, {159, 160, 161, 162, 162, 155, 155, 155}, {161, 161, 161, 161, 160, 157, 157, 157}, {162, 162, 161, 163, 162, 157, 157, 157}, {162, 162, 161, 161, 163, 158, 158, 158}}; int size = 8; int i, j; normalizeMatrix(size, imageMatrix); twoD_DCT(size, imageMatrix); // dumpMatrix(size,imageMatrix); quantizationFunction50(size, imageMatrix); // dumpMatrix(size,imageMatrix); // printf("\n"); dequantizationFunction50(size, imageMatrix); // dumpMatrix(size,imageMatrix); twoD_IDCT(size, imageMatrix); // dumpMatrix(size,imageMatrix); denormalizeMatrix(size, imageMatrix); // dumpMatrix(size, imageMatrix); }
VglImage* vglColorDeconv(VglImage *imagevgl, double *mInitial, int find3rdColor /*=0*/) { double *mNormal = (double *) malloc(9*sizeof(double)); double *mInverse = (double *) malloc(9*sizeof(double)); double log255 = log(255.0); if(find3rdColor != 0) { normalizeMatrix3x3(mInitial, mNormal); invertMatrix3x3(mNormal, mInverse); } else { normalizeMatrix(mInitial, mNormal); rightInverseMatrix2x3(mNormal, mInverse); } convertBGRToRGB(imagevgl); //vglPrintImageInfo(imagevgl); // Creation of structure for the new image VglImage *newimagevgl; newimagevgl = vglCreate3dImage(cvSize(imagevgl->shape[0], imagevgl->shape[1]), imagevgl->depth, imagevgl->nChannels, imagevgl->shape[2]); // Composition of the new image int nPixels = imagevgl->shape[0]*imagevgl->shape[1]; for(int j = 0; j < nPixels; j++) { // log transform the RGB data unsigned char r = ((unsigned char *)imagevgl->ndarray)[j*3]; unsigned char g = ((unsigned char *)imagevgl->ndarray)[j*3+1]; unsigned char b = ((unsigned char *)imagevgl->ndarray)[j*3+2]; double rLog = -((255.0 * log(((double)r+1)/255.0))/log255); double gLog = -((255.0 * log(((double)g+1)/255.0))/log255); double bLog = -((255.0 * log(((double)b+1)/255.0))/log255); for(int i = 0; i < 3; i++) { double rScaled = rLog * mInverse[i*3]; double gScaled = gLog * mInverse[i*3+1]; double bScaled = bLog * mInverse[i*3+2]; double output = exp(-((rScaled + gScaled + bScaled) - 255.0) * log255 / 255.0); if(output > 255) output = 255; ((unsigned char *)newimagevgl->ndarray)[j*3+i] = (unsigned char)output; } } convertRGBToBGR(newimagevgl); return newimagevgl; }
/** Function to save three RGB images, one for each deconvolved color */ void vglSaveColorDeconv(VglImage *imagevgl, double *mInitial, char *outFilename, int find3rdColor /*=0*/) { double *mNormal = (double *) malloc(9*sizeof(double)); if(find3rdColor != 0) normalizeMatrix3x3(mInitial, mNormal); else normalizeMatrix(mInitial, mNormal); convertBGRToRGB(imagevgl); VglImage *newimagevgl[3]; for(int i = 0; i < 3; i++) newimagevgl[i] = vglCreate3dImage(cvSize(imagevgl->shape[0], imagevgl->shape[1]), imagevgl->depth, imagevgl->nChannels, imagevgl->shape[2]); int nPixels = imagevgl->shape[0]*imagevgl->shape[1]; for(int j = 0; j < nPixels; j++) for(int i = 0; i < 3; i++) { unsigned char gray = ((unsigned char *)imagevgl->ndarray)[j*3+i]; double rLut = 255.0 - ((255.0 - ((double)gray)) * mNormal[i]); double gLut = 255.0 - ((255.0 - ((double)gray)) * mNormal[i+3*1]); double bLut = 255.0 - ((255.0 - ((double)gray)) * mNormal[i+3*2]); ((unsigned char *)newimagevgl[i]->ndarray)[j*3] = ((unsigned char)rLut); ((unsigned char *)newimagevgl[i]->ndarray)[j*3+1] = ((unsigned char)gLut); ((unsigned char *)newimagevgl[i]->ndarray)[j*3+2] = ((unsigned char)bLut); } int lStart = 0; int lEnd = 0; for(int i = 0; i < 3; i++) { convertRGBToBGR(newimagevgl[i]); char outname[1024]; sprintf(outname, outFilename, i); vglSave3dImage(newimagevgl[i], outname, lStart, lEnd); } }
void test_two_D_DCT_transform_array_of_8_elements_and_should_invert_back_to_original_by_IDCT_with_normalization(){ float imageMatrix[8][8] = {{154, 123, 123, 123, 123, 123, 123, 136}, {192, 180, 136, 154, 154, 154, 136, 110}, {254, 198, 154, 154, 180, 154, 123, 123}, {239, 180, 136, 180, 180, 166, 123, 123}, {180, 154, 136, 167, 166, 149, 136, 136}, {128, 136, 123, 136, 154, 180, 198, 154}, {123, 105, 110, 149, 136, 136, 180, 166}, {110, 136, 123, 123, 123, 136, 154, 136}}; float expectMatrix[8][8] ={{154, 123, 123, 123, 123, 123, 123, 136}, {192, 180, 136, 154, 154, 154, 136, 110}, {254, 198, 154, 154, 180, 154, 123, 123}, {239, 180, 136, 180, 180, 166, 123, 123}, {180, 154, 136, 167, 166, 149, 136, 136}, {128, 136, 123, 136, 154, 180, 198, 154}, {123, 105, 110, 149, 136, 136, 180, 166}, {110, 136, 123, 123, 123, 136, 154, 136}}; int size = 8; int i, j; normalizeMatrix(size, imageMatrix); twoD_DCT(size, imageMatrix); // dumpMatrix(size,imageMatrix); // printf("\n"); twoD_IDCT(size, imageMatrix); denormalizeMatrix(size, imageMatrix); // dumpMatrix(size, imageMatrix); TEST_ASSERT_EQUAL_MATRIX(expectMatrix, imageMatrix); }
MStatus sgHair_controlJoint::setOutput() { MStatus status; m_vectorArrTransJoint.setLength( m_mtxArrGravityAdd.length() ); m_vectorArrRotateJoint.setLength( m_mtxArrGravityAdd.length() ); MMatrix mtxLocal; MMatrix parentInverse = m_mtxJointParentBase.inverse(); MMatrixArray mtxArrInParent, mtxArrInParentNormalize; mtxArrInParent.setLength( m_mtxArrGravityAdd.length() ); mtxArrInParentNormalize.setLength( m_mtxArrGravityAdd.length() ); for( int i=0; i< m_mtxArrGravityAdd.length(); i++ ) { mtxArrInParent[i] = m_mtxArrGravityAdd[i] * parentInverse; mtxArrInParentNormalize[i] = mtxArrInParent[i]; normalizeMatrix( mtxArrInParentNormalize[i] ); } MTransformationMatrix trMtx( mtxArrInParent[0] ); m_vectorArrTransJoint[0] = trMtx.translation( MSpace::kTransform ); m_vectorArrRotateJoint[0] = trMtx.eulerRotation().asVector(); for( int i=1; i< m_mtxArrGravityAdd.length(); i++ ) { mtxLocal = mtxArrInParent[i] * mtxArrInParentNormalize[i-1].inverse(); MTransformationMatrix trMtx( mtxLocal ); m_vectorArrTransJoint[i] = trMtx.translation( MSpace::kTransform ); m_vectorArrRotateJoint[i] = trMtx.eulerRotation().asVector(); } return MS::kSuccess; }
void test_release_compression_logic(){ CEXCEPTION_T error; Stream *inStream = NULL; Stream *outStream = NULL; State yProgress = {.state = 0, .index = 0}; State cbProgress = {.state = 0, .index = 0}; State crProgress = {.state = 0, .index = 0}; float inputMatrixA[8][8], inputMatrixB[8][8], inputMatrixC[8][8]; short int outMatrixA[8][8], outMatrixB[8][8], outMatrixC[8][8]; int size = 8; uint32 bytesToWrite; RGB colorRGB; YCbCr lumaChrom; uint8 R[8][8], G[8][8], B[8][8]; uint8 Y[8][8], Cb[8][8], Cr[8][8]; colorRGB.red = &R; colorRGB.green = &G; colorRGB.blue = &B; lumaChrom.Y = &Y; lumaChrom.Cb = &Cb; lumaChrom.Cr = &Cr; Try{ inStream = openStream("test/Data/Water lilies.7z.010", "rb"); outStream = openStream("test/Data/outputData.7z.010", "wb"); }Catch(error){ TEST_ASSERT_EQUAL(ERR_FILE_NOT_EXIST, error); } readFileToRGB(inStream,R,G,B); convertToLuma(&colorRGB, &lumaChrom); convertToChromaB(&colorRGB, &lumaChrom); convertToChromaR(&colorRGB, &lumaChrom); convertUINT8ToFloat(Y, inputMatrixA); convertUINT8ToFloat(Cb, inputMatrixB); convertUINT8ToFloat(Cr, inputMatrixC); normalizeMatrix(8,inputMatrixA); normalizeMatrix(8,inputMatrixB); normalizeMatrix(8,inputMatrixC); twoD_DCT(8,inputMatrixA); twoD_DCT(8,inputMatrixB); twoD_DCT(8,inputMatrixC); quantizationFunction50(8,inputMatrixA); //Y array quantizationFunction50(8,inputMatrixB); //Cb array quantizationFunction50(8,inputMatrixC); //Cr array convertToUINT16(inputMatrixA, outMatrixA); convertToUINT16(inputMatrixB, outMatrixB); convertToUINT16(inputMatrixC, outMatrixC); bytesToWrite = huffmanEncodePull(&yProgress, outMatrixA, dcLuminanceTable); write4Bytes(outStream, bytesToWrite); while(yProgress.index != 64){ bytesToWrite = huffmanEncodePull(&yProgress, outMatrixA, acLuminanceTable); write4Bytes(outStream, bytesToWrite); } bytesToWrite = huffmanEncodePull(&cbProgress, outMatrixB, dcChrominanceTable); write4Bytes(outStream, bytesToWrite); while(cbProgress.index != 64){ bytesToWrite = huffmanEncodePull(&cbProgress, outMatrixB, acChrominanceTable); write4Bytes(outStream, bytesToWrite); } bytesToWrite = huffmanEncodePull(&crProgress, outMatrixC, dcChrominanceTable); write4Bytes(outStream, bytesToWrite); while(crProgress.index != 64){ bytesToWrite = huffmanEncodePull(&crProgress, outMatrixC, acChrominanceTable); write4Bytes(outStream, bytesToWrite); } //To Encoder..... can only detect state.index to stop when it is 64 //To Byte Stuff, output to file in Y, Cb, Cr //Repeat process until (!feof(inStream)) closeStream(inStream); closeStream(outStream); } // convertToLuma(&colorRGB, &lumaChrom); convertToChromaB(&colorRGB, &lumaChrom); convertToChromaR(&colorRGB, &lumaChrom); // dumpMatrixUINT8(8,Y); dumpMatrixUINT8(8,Cb); dumpMatrixUINT8(8,Cr); // dumpMatrixUINT8(8,R); dumpMatrixUINT8(8,G); dumpMatrixUINT8(8,B); // printf("\n"); // convertToRed(&colorRGB, &lumaChrom); convertToBlue(&colorRGB, &lumaChrom); convertToGreen(&colorRGB, &lumaChrom); // dumpMatrixUINT8(8,R); dumpMatrixUINT8(8,G); dumpMatrixUINT8(8,B); // dumpMatrix(8, inputMatrixA); // dumpMatrix(8, inputMatrixB); // dumpMatrix(8, inputMatrixC); void xtest_release_decompression_logic(){ //Huffman decoder //To Run Length Decode //Loop 3 times to get Y Cb Cr arrays //De-Q - IDCT - Denormalization - Color Conversion back to RGB //Output to file again }
/* * Raw file DCT output * ----- ----- * | | read+chop write | | * | | ----> DCT ----> Quantization ----> | | * | | | | * ----- ----- * DCT output IDCT result * ----- ----- * | | read+chop write | | * | | ----> Dequantization ----> IDCT ----> | | * | | | | * ----- ----- */ void test_release2(){ CEXCEPTION_T error; Stream *inStream = NULL; Stream *outStream = NULL; float inputMatrix[8][8]; int size = 8, count = 0; Try{ inStream = openStream("test/Data/Water lilies.7z.010", "rb"); outStream = openStream("test/Data/Water lilies_RE2.7z.010", "wb"); }Catch(error){ TEST_ASSERT_EQUAL(ERR_END_OF_FILE, error); } Try{ while(1){ readBlock(inStream, size, inputMatrix); //printf("%.3f", inputMatrix[0][0]); normalizeMatrix(size, inputMatrix); // dumpMatrix(size, inputMatrix); twoD_DCT(size, inputMatrix); // printf("%.3f", inputMatrix[0][0]); // dumpMatrix(size, inputMatrix); quantizationFunction50(size, inputMatrix); // dumpMatrix(size, inputMatrix); writeBlock11Bit(outStream, size, inputMatrix); if( feof(inStream->file) ) { break ; } } }Catch(error){ TEST_ASSERT_EQUAL(ERR_END_OF_FILE, error); } closeStream(inStream); closeStream(outStream); // printf("\n"); Stream *inStream2 = NULL; Stream *outStream2 = NULL; count = 0; short int inputMatrixIDCT[8][8]; Try{ inStream2 = openStream("test/Data/Water lilies_RE2.7z.010", "rb"); outStream2 = openStream("test/Data/Water lilies_RE2Out.7z.010", "wb"); }Catch(error){ TEST_ASSERT_EQUAL(ERR_END_OF_FILE, error); } Try{ while(1){ readBlock11Bit(inStream2, size, inputMatrixIDCT); // dumpMatrixInt(size, inputMatrixIDCT); convertToFloat(inputMatrixIDCT, inputMatrix); dequantizationFunction50(size, inputMatrix); //dumpMatrix(size, inputMatrix); twoD_IDCT(size, inputMatrix); denormalizeMatrix(size, inputMatrix); // dumpMatrix(size, inputMatrix); writeBlock(outStream2, size, inputMatrix); if( feof(inStream2->file) ) { break ; } } }Catch(error){ TEST_ASSERT_EQUAL(ERR_END_OF_FILE, error); } closeStream(inStream2); closeStream(outStream2); }
/** * Check if connection is an anomaly */ void TfdAnomalyDetector::checkConnection(Connection* conn) { uint32_t flowStartSec = 0; // starttime of flow (seconds) uint64_t flowStartMillisec = 0; // starttime of flow (milliseconds) uint32_t host = 0; // host in local network (srcIP or dstIP) string hostString; // host displayed as string bool isSrc = false; float numFlowPackets; // number of packets for current flow uint32_t srcIP; uint32_t dstIP; uint16_t srcPort; uint16_t dstPort; int odPair = 0; map<int, PortList>::iterator hostIt; // check if src or dst of current flow is local host if ((conn->srcIP & subnetmask) == subnet) { host = conn->srcIP; isSrc = true; } else if ((conn->dstIP & subnetmask) == subnet) { host = conn->dstIP; isSrc = false; } else { return; } // get number of packets for current flow numFlowPackets = ntohll(conn->srcPackets); // calc starttime for current flow flowStartMillisec = conn->srcTimeStart; flowStartSec = (flowStartMillisec + 500) / 1000; // srcTimeStart -rounded- to seconds // get appropriate timebin for array if (((flowStartSec - lastFlowStartSec) >= binSize) && lastFlowStartSec != 0) { // todo: variable interval lengths (currently 1 sec) -> binSize timeBin++; // next timebin if (timeBin >= TIMEBINS) { calculateEntropy(); normalizeMatrix(srcIpEntropy, TIMEBINS); normalizeMatrix(dstIpEntropy, TIMEBINS); normalizeMatrix(srcPortEntropy, TIMEBINS); normalizeMatrix(dstPortEntropy, TIMEBINS); calculateSingleWayMatrix(); calculateExpectationMaximation(); // restart calculation initTempArrays(); // init and delete IP/Port arrays timeBin = 0; // set counter back } lastFlowStartSec = flowStartSec; lastFlowStartMilliSec = flowStartMillisec; } // get OD-value for array hostString = IPToString(host); int pos; for (int i = 0; i < 3; i++) { // cut host into substrings, only use last part as index for array pos = hostString.find("."); hostString = hostString.substr(pos+1); } odPair = atoi(hostString.c_str()); // convert host-substring to int // save flowStart to calculate next timebin lastFlowStartSec = flowStartSec; // **** save number of packets to IP-Arrays if (isSrc) { srcIpPackets[timeBin][odPair] += numFlowPackets; } else { dstIpPackets[timeBin][odPair] += numFlowPackets; } // **** source port srcPort = ntohs(conn->srcPort); hostIt = srcPortMap.find(odPair); if(hostIt != srcPortMap.end()) { // host found in Map -> add port to vector PortListIterator portIt = find((hostIt->second).begin(), (hostIt->second).end(), srcPort); if (portIt != (hostIt->second).end()) { } else { (hostIt->second).push_back(srcPort); srcPortNum[timeBin][odPair] += 1; } } else { // host not yet in Map -> add it // create new port list PortList srcPortList(srcPort); srcPortMap.insert ( pair<int, PortList>(odPair, srcPortList) ); srcPortNum[timeBin][odPair] = 1; } // **** destination port dstPort = ntohs(conn->dstPort); hostIt = dstPortMap.find(odPair); if(hostIt != dstPortMap.end()) { // host found in Map -> add port to vector PortListIterator portIt = find((hostIt->second).begin(), (hostIt->second).end(), dstPort); if (portIt != (hostIt->second).end()) { } else { (hostIt->second).push_back(dstPort); dstPortNum[timeBin][odPair] += 1; } } else { // host not yet in Map -> add it // create new port list PortList dstPortList(dstPort); dstPortMap.insert ( pair<int, PortList>(odPair, dstPortList) ); dstPortNum[timeBin][odPair] = 1; } }
void test_release_compression_logic(){ CEXCEPTION_T error; Stream *inStream = NULL; Stream *outStream = NULL; State yProgress = {.state = 0, .index = 0}; State cbProgress = {.state = 0, .index = 0}; State crProgress = {.state = 0, .index = 0}; float inputMatrixA[8][8], inputMatrixB[8][8], inputMatrixC[8][8]; short int outMatrixA[8][8], outMatrixB[8][8], outMatrixC[8][8]; int size = 8; uint32 bytesToWrite; RGB colorRGB; YCbCr lumaChrom; uint8 R[8][8], G[8][8], B[8][8]; uint8 Y[8][8], Cb[8][8], Cr[8][8]; colorRGB.red = &R; colorRGB.green = &G; colorRGB.blue = &B; lumaChrom.Y = &Y; lumaChrom.Cb = &Cb; lumaChrom.Cr = &Cr; Try{ inStream = openStream("test/Data/Water lilies.7z.010", "rb"); outStream = openStream("test/Data/outputData.7z.010", "wb"); }Catch(error){ TEST_ASSERT_EQUAL(ERR_FILE_NOT_EXIST, error); } readFileToRGB(inStream,R,G,B); convertToLuma(&colorRGB, &lumaChrom); convertToChromaB(&colorRGB, &lumaChrom); convertToChromaR(&colorRGB, &lumaChrom); convertUINT8ToFloat(Y, inputMatrixA); convertUINT8ToFloat(Cb, inputMatrixB); convertUINT8ToFloat(Cr, inputMatrixC); normalizeMatrix(8,inputMatrixA); normalizeMatrix(8,inputMatrixB); normalizeMatrix(8,inputMatrixC); twoD_DCT(8,inputMatrixA); twoD_DCT(8,inputMatrixB); twoD_DCT(8,inputMatrixC); quantizationFunction50(8,inputMatrixA); //Y array quantizationFunction50(8,inputMatrixB); //Cb array quantizationFunction50(8,inputMatrixC); //Cr array convertToUINT16(inputMatrixA, outMatrixA); convertToUINT16(inputMatrixB, outMatrixB); convertToUINT16(inputMatrixC, outMatrixC); bytesToWrite = huffmanEncodePull(&yProgress, outMatrixA, dcLuminanceTable); write4Bytes(outStream, bytesToWrite); while(yProgress.index != 64){ bytesToWrite = huffmanEncodePull(&yProgress, outMatrixA, acLuminanceTable); write4Bytes(outStream, bytesToWrite); } bytesToWrite = huffmanEncodePull(&cbProgress, outMatrixB, dcChrominanceTable); write4Bytes(outStream, bytesToWrite); while(cbProgress.index != 64){ bytesToWrite = huffmanEncodePull(&cbProgress, outMatrixB, acChrominanceTable); write4Bytes(outStream, bytesToWrite); } bytesToWrite = huffmanEncodePull(&crProgress, outMatrixC, dcChrominanceTable); write4Bytes(outStream, bytesToWrite); while(crProgress.index != 64){ bytesToWrite = huffmanEncodePull(&crProgress, outMatrixC, acChrominanceTable); write4Bytes(outStream, bytesToWrite); } //To Encoder..... can only detect state.index to stop when it is 64 //To Byte Stuff, output to file in Y, Cb, Cr //Repeat process until (!feof(inStream)) closeStream(inStream); closeStream(outStream); } // convertToLuma(&colorRGB, &lumaChrom); convertToChromaB(&colorRGB, &lumaChrom); convertToChromaR(&colorRGB, &lumaChrom); // dumpMatrixUINT8(8,Y); dumpMatrixUINT8(8,Cb); dumpMatrixUINT8(8,Cr); // dumpMatrixUINT8(8,R); dumpMatrixUINT8(8,G); dumpMatrixUINT8(8,B); // printf("\n"); // convertToRed(&colorRGB, &lumaChrom); convertToBlue(&colorRGB, &lumaChrom); convertToGreen(&colorRGB, &lumaChrom); // dumpMatrixUINT8(8,R); dumpMatrixUINT8(8,G); dumpMatrixUINT8(8,B); // dumpMatrix(8, inputMatrixA); // dumpMatrix(8, inputMatrixB); // dumpMatrix(8, inputMatrixC); void xtest_release_decompression_logic(){ CEXCEPTION_T error; Stream *inStream = NULL; Stream *outStream = NULL; CodeTable *dcDecodeLumTable = createTable(DCLumTable, 0, sizeof(DCLumTable)/sizeof(RunSizeCode)); CodeTable *dcDecodeChromTable = createTable(DCChromTable, 0, sizeof(DCChromTable)/sizeof(RunSizeCode)); CodeTable *acDecodeLumTable = createTable(ACLumTable, 0, sizeof(ACLumTable)/sizeof(RunSizeCode)); CodeTable *acDecodeChromTable = createTable(ACChromTable, 0, sizeof(ACChromTable)/sizeof(RunSizeCode)); uint32 bytesToRead, catAndSymbol, runAndDecodedSymbol; uint16 codeWord, symbol, runLength, category; uint8 runAndSize; int16 valueDecodedSymbol; int count = 0; Try{ inStream = openStream("test/Data/outputData.7z.010", "rb"); outStream = openStream("test/Data/outputDataDecompress.7z.010", "wb"); }Catch(error){ TEST_ASSERT_EQUAL(ERR_FILE_NOT_EXIST, error); } /*bytesToRead = read4Bytes(inStream); codeWord = bytesToRead >> 16; symbol = bytesToRead & 0xffff; runAndSize = huffmanDecode(codeWord, dcDecodeLumTable); runLength = runAndSize >> 4; category = runAndSize & 0xf; catAndSymbol = category; catAndSymbol = (catAndSymbol << 16) | symbol; valueDecodedSymbol = valueDecoding(catAndSymbol); runAndDecodedSymbol = runLength; runAndDecodedSymbol = (runAndDecodedSymbol << 16) | valueDecodedSymbol; //runAndDecodedSymbol to run-length decode while(count < 63){ bytesToRead = read4Bytes(inStream); codeWord = bytesToRead >> 16; symbol = bytesToRead & 0xffff; runAndSize = huffmanDecode(codeWord, acDecodeLumTable); runLength = runAndSize >> 4; category = runAndSize & 0xf; catAndSymbol = category; catAndSymbol = (catAndSymbol << 16) | symbol; valueDecodedSymbol = valueDecoding(catAndSymbol); runAndDecodedSymbol = runLength; runAndDecodedSymbol = (runAndDecodedSymbol << 16) | valueDecodedSymbol; //runAndDecodedSymbol to run-length decode count++; } bytesToRead = read4Bytes(inStream); codeWord = bytesToRead >> 16; symbol = bytesToRead & 0xffff; runAndSize = huffmanDecode(codeWord, dcDecodeChromTable); runLength = runAndSize >> 4; category = runAndSize & 0xf; catAndSymbol = category; catAndSymbol = (catAndSymbol << 16) | symbol; valueDecodedSymbol = valueDecoding(catAndSymbol); runAndDecodedSymbol = runLength; runAndDecodedSymbol = (runAndDecodedSymbol << 16) | valueDecodedSymbol; //runAndDecodedSymbol to run-length decode while(count < 63){ bytesToRead = read4Bytes(inStream); codeWord = bytesToRead >> 16; symbol = bytesToRead & 0xffff; runAndSize = huffmanDecode(codeWord, acDecodeChromTable); runLength = runAndSize >> 4; category = runAndSize & 0xf; catAndSymbol = category; catAndSymbol = (catAndSymbol << 16) | symbol; valueDecodedSymbol = valueDecoding(catAndSymbol); runAndDecodedSymbol = runLength; runAndDecodedSymbol = (runAndDecodedSymbol << 16) | valueDecodedSymbol; //runAndDecodedSymbol to run-length decode count++; } bytesToRead = read4Bytes(inStream); codeWord = bytesToRead >> 16; symbol = bytesToRead & 0xffff; runAndSize = huffmanDecode(codeWord, dcDecodeChromTable); runLength = runAndSize >> 4; category = runAndSize & 0xf; catAndSymbol = category; catAndSymbol = (catAndSymbol << 16) | symbol; valueDecodedSymbol = valueDecoding(catAndSymbol); runAndDecodedSymbol = runLength; runAndDecodedSymbol = (runAndDecodedSymbol << 16) | valueDecodedSymbol; //runAndDecodedSymbol to run-length decode while(count < 63){ bytesToRead = read4Bytes(inStream); codeWord = bytesToRead >> 16; symbol = bytesToRead & 0xffff; runAndSize = huffmanDecode(codeWord, acDecodeChromTable); runLength = runAndSize >> 4; category = runAndSize & 0xf; catAndSymbol = category; catAndSymbol = (catAndSymbol << 16) | symbol; valueDecodedSymbol = valueDecoding(catAndSymbol); runAndDecodedSymbol = runLength; runAndDecodedSymbol = (runAndDecodedSymbol << 16) | valueDecodedSymbol; //runAndDecodedSymbol to run-length decode count++; }*/ closeStream(inStream); closeStream(outStream); //Huffman decoder //To Run Length Decode //Loop 3 times to get Y Cb Cr arrays //De-Q - IDCT - Denormalization - Color Conversion back to RGB //Output to file again }