static void OSMemory_setShortArray(JNIEnv* env, jclass, jint dstAddress, jshortArray src, jint offset, jint length, jboolean swap) { jshort* dst = cast<jshort*>(dstAddress); env->GetShortArrayRegion(src, offset, length, dst); if (swap) { swapShorts(dst, length); } }
bool Reader::readProperty(PropertyInfo& prop) { size_t num = prop.size * prop.width; size_t bytes = num * dataSize(prop.type); char* buffer = 0; // // Cache the offset pointer // if( m_currentReadOffset == 0 ) { // Offset can never be zero here, so it must be // uninitialized. Set it to the real file position. m_currentReadOffset = tell(); } prop.offset = m_currentReadOffset; bool readok = false; if (prop.requested) { if ((buffer = (char*)data(prop, bytes))) { if(prop.index < m_dataOffsets.size()) { seekTo(prop); } else { // Do we need to be somewhere else? if(m_currentReadOffset != tell()) { // If so, move the actual file pointer there. seekForward(m_currentReadOffset - tell()); } } read(buffer, bytes); readok = true; } } // Move the 'virtual' file offset forward by the data // size of this property, whether we read it or not. m_currentReadOffset += bytes; if (m_error) return false; if (readok) { if (m_swapped) { switch (prop.type) { case Gto::Int: case Gto::String: case Gto::Float: swapWords(buffer, num); break; case Gto::Short: case Gto::Half: swapShorts(buffer, num); break; case Gto::Double: swapWords(buffer, num * 2); break; case Gto::Byte: case Gto::Boolean: break; } } dataRead(prop); } return true; }
bool Reader::readProperty(PropertyInfo& prop) { size_t num = prop.size * elementSize(prop.dims); size_t bytes = dataSizeInBytes(prop.type) * num; char* buffer = 0; // // Cache the offset pointer // prop.offset = tell(); bool readok = false; if (prop.requested) { if ((buffer = (char*)data(prop, bytes))) { read(buffer, bytes); if (!m_error) readok = true; } else { seekForward(bytes); } } else { seekForward(bytes); } if (m_error) return false; if (readok) { if (m_swapped) { switch (prop.type) { case Gto::Int: case Gto::String: case Gto::Float: swapWords(buffer, num); break; case Gto::Short: case Gto::Half: swapShorts(buffer, num); break; case Gto::Double: swapWords(buffer, num * 2); break; case Gto::Byte: case Gto::Boolean: break; } } dataRead(prop); } return true; }