static int imageReadData(FILE * const fileP, IMAGE * const imgP, uint32_t const end_offset) { int retval; size_t dataSize; uint8_t * buffer; readCompressed(imgP, end_offset, fileP, &dataSize, &buffer, &retval); if (retval == 0) { /* * Compressed data can cross row boundaries so we decompress * the data here to avoid messiness in the row access functions. */ if (dataSize != ipdb_img_size(imgP)) { decompress(buffer, dataSize, ipdb_img_size(imgP), &imgP->data); if (imgP->data == NULL) retval = ENOMEM; else imgP->compressed = true; free(buffer); } else { imgP->compressed = false; imgP->data = buffer; /* Storage at 'buffer' now belongs to *imgP */ } } return retval; }
ssize_t Compress::read(char *buf, size_t size, off_t offset) const { assert (m_fd != -1); assert (size >= 0); rDebug("Compress::read size: 0x%lx, offset: 0x%lx", (long int) size, (long int) offset); if (m_IsCompressed == false) { return pread(m_fd, buf, size, offset); } else { return readCompressed(buf, size, offset, m_fd); } }
off_t Compress::copy(int readFd, off_t writeOffset, int writeFd, LayerMap& writeLm) { boost::scoped_array<char> buf(new char[g_BufferedMemorySize]); ssize_t bytes; // Start reading from the begining of the file. off_t readOffset = 0; while ((bytes = readCompressed(buf.get(), g_BufferedMemorySize, readOffset, readFd)) > 0) { writeOffset = writeCompressed(writeLm, readOffset, writeOffset, buf.get(), bytes, writeFd, writeOffset); if (writeOffset == -1) return -1; assert (writeOffset == bytes); readOffset += bytes; } return writeOffset; }
/* * Class: com_sun_media_protocol_sunvideo_XILCapture * Method: xilRead * Signature: ([BI)I */ JNIEXPORT jint JNICALL Java_com_sun_media_protocol_sunvideo_XILCapture_xilRead(JNIEnv *env, jobject jxil, jbyteArray jbuf, jint jlen) { void *buf; int len; InstanceState *inst = (InstanceState *) GetLongField(env, jxil, "peer"); if (inst == NULL) return -1; if (!inst->started) { /* Debug Message */ PRINT("XILCapture xilRead() not started \n"); return -1; } /* Debug Message*/ /* PRINT("In xilRead\n"); */ buf = (void *) (*env)->GetByteArrayElements(env, jbuf, 0); if (inst->xil_cis) { len = readCompressed(inst, buf, (int)jlen); } else { len = readRaw(inst, buf, (int)jlen); if (inst->firstRawRead) { setFormat(env, jxil, inst); inst->firstRawRead = 0; } } (*env)->ReleaseByteArrayElements(env, jbuf, buf, 0); return len; }