void NetControlIntern::DataPackage::read(const SmartPointer<NetControlIntern>& con, CBytestream& bs, bool withTypeInfo) { if(withTypeInfo) type = (NetControlIntern::DataPackage::Type) bs.readByte(); nodeId = nodeMustBeSet() ? readEliasGammaNr(bs) : INVALID_NODE_ID; node = NULL; size_t len = readEliasGammaNr(bs); data = BitStream( bs.getRawData( bs.GetPos(), bs.GetPos() + len ) ); bs.Skip(len); }
int main(int argc, char **argv) { if (argc < 3){ fprintf(stderr, "Usage: wavCopy <input file> <output file>\n"); return -1; } SF_INFO soundInfoIn; /* Input sound file Info */ uint i; short sample[2]; short tmp[2]; std::string file = "testfile"; std::string fileIn(argv[argc-2]); std::string fileOut(argv[2]); // long valAvg = 0; // long diffAvg = 0; { Predictor p(100); SFReader sfReader(fileIn); sfReader.open(); sfReader.printInfo(); BitStream bs1 = BitStream(file, BitStream::WRITE); if (bs1.open() != 0){ printf("Error closing!\n"); } for (i = 0; i < sfReader.getNFrames() ; i++) { sfReader.nextFrame(sample); p.predict(tmp); Golomb::encode(VAL_M, tmp[0] - sample[0], bs1); Golomb::encode(VAL_M, tmp[1] - sample[1], bs1); // valAvg += 2*abs(sample[0]); // valAvg += 2*abs(sample[1]); // diffAvg += abs(2*(prevSample[0] - sample[0])); // diffAvg += abs(2*(prevSample[1] - sample[1])); p.update(sample); } // printf("%ld, %ld\n", valAvg/(long)frames*2, diffAvg/(long)frames*2); if (bs1.close() != 0){ printf("Error closing!\n"); } sfReader.close(); soundInfoIn = sfReader.getInfo(); } { Predictor p(100); SFWriter sfWriter(fileOut, soundInfoIn.frames, soundInfoIn.samplerate, soundInfoIn.channels); BitStream bs2 = BitStream(file, BitStream::READ); if (bs2.open() != 0){ printf("Error opening!\n"); return -1; } sfWriter.printInfo(); sfWriter.open(); int smp = 0; while (true){ p.predict(tmp); if (Golomb::decode(VAL_M, &smp, bs2)!=0) break; sample[0] = tmp[0] - (short)smp; if (Golomb::decode(VAL_M, &smp, bs2)!=0) break; sample[1] = tmp[1] - (short)smp; sfWriter.writeFrame(sample); p.update(sample); } bs2.close(); sfWriter.close(); } char dumbness[50]; strcpy(dumbness, "cmp "); strcat(dumbness, argv[1]); strcat(dumbness, " "); strcat(dumbness, argv[2]); if (system(dumbness) != 0) printf("uh oh\n"); else { printf("files match\n"); strcpy(dumbness, "ls -sh -1 "); strcat(dumbness, argv[1]); strcat(dumbness, " "); strcat(dumbness, file.c_str()); system(dumbness); } return 0; }
int main( int argc, char** argv ){ if (argc != 2) { printf("USAGE: %s <input>\n", argv[0]); return -1; } char* file = (char *)"file"; int nFrames; uint rows, cols, fps, type; uint qY = 8, qU = 16, qV = 16; uint mode = 7; BitStream bs = BitStream(file, BitStream::WRITE); YuvReader reader(argv[1]); printf("%d\n", reader.open()); printf("%d\n", reader.readHeader()); rows = reader.getNRows(); cols = reader.getNCols(); fps = reader.getFps(); type = reader.getType(); printf("%d, %d, %d, %d, %d, %d, %d, %d\n", cols, rows, fps, type, mode, qY, qU, qV); printf("%d\n", bs.open()); YuvFrame frame1(type, rows, cols); IntraCoder::writeHeader(rows, cols, fps, type, mode, qY, qU, qV, bs); while (reader.readFrame(frame1) == 0){ printf("frame #%d\n",nFrames++); IntraCoder::encode(frame1, bs, mode, qY, qU, qV); } bs.close(); printf("Done! %d frames!\n",nFrames); nFrames = rows = cols = fps = type = qY = qU = qV = mode = 0; BitStream bs1 = BitStream(file, BitStream::READ); printf("%d\n", bs1.open()); printf("%d\n", IntraCoder::readHeader(bs1, &rows, &cols, &fps, &type, &mode, &qY, &qU, &qV)); YuvFrame frame2(type, rows, cols); YuvDisplay display((char*)"YuvShow", fps, rows, cols); printf("%d, %d, %d, %d, %d, %d, %d, %d\n", cols, rows, fps, type, mode, qY, qU, qV); display.start(); while (IntraCoder::decode(bs1, frame2, mode, qY, qU, qV) == 0){ printf("frame #%d\n",nFrames++); display.displayFrame(frame2); } bs1.close(); return 0; }
static Event NodeRemoved(Net_ConnID c) { return Event(eNet_EventRemoved, eNet_RoleAuthority /* TODO? */, c, BitStream()); }
static Event NodeInit(Net_ConnID c) { return Event(eNet_EventInit, eNet_RoleAuthority /* TODO? */, c, BitStream()); }