SWIGEXPORT jint JNICALL Java_org_scilab_modules_graphic_1objects_DataLoaderJNI_getDataSize(JNIEnv *jenv, jclass jcls, jint jarg1) { jint jresult = 0 ; int arg1 ; int result; (void)jenv; (void)jcls; arg1 = (int)jarg1; result = (int)getDataSize(arg1); jresult = (jint)result; return jresult; }
uint8_t *TR::X86DataSnippet::emitSnippetBody() { uint8_t *cursor = cg()->getBinaryBufferCursor(); // align to 16 bytes if (getDataSize() % 16 == 0) { cursor = (uint8_t*)(((intptrj_t)(cursor + 15)) & ((-1)<<4)); } getSnippetLabel()->setCodeLocation(cursor); memcpy(cursor, getRawData(), getDataSize()); addMetaDataForCodeAddress(cursor); cursor += getDataSize(); return cursor; }
TextTable * makeTextTable (TextTableData *ttd) { TextTable *table = malloc(sizeof(*table)); if (table) { table->header.fields = getTextTableHeader(ttd); table->size = getDataSize(ttd->area); resetDataArea(ttd->area); } return table; }
bool TypedValue::isPlausibleInstanceOf(const TypeSignature type) const { TypeID type_id = getTypeID(); if (type_id != type.id) { return false; } if (isNull()) { return type.nullable; } switch (type_id) { case kInt: case kLong: case kFloat: case kDouble: case kDatetime: case kDatetimeInterval: case kYearMonthInterval: return true; case kChar: { size_t data_size = getDataSize(); if (data_size == type.length) { return true; } else if (data_size < type.length) { // If the data is shorter than the max size for a CHAR type, make sure // it is null-terminated. return (memchr(value_union_.out_of_line_data, '\0', data_size) != nullptr); } else { return false; } } case kVarChar: return getDataSize() <= (type.length + 1); default: { size_t data_size = getDataSize(); return (data_size <= type.length); } } }
void Sound::play(int flag) { Audio::SoundHandle *handle = getHandle(); if (g_fp->_mixer->isSoundHandleActive(*handle)) return; byte *soundData = loadData(); Common::MemoryReadStream *dataStream = new Common::MemoryReadStream(soundData, getDataSize()); Audio::RewindableAudioStream *wav = Audio::makeWAVStream(dataStream, DisposeAfterUse::YES); Audio::AudioStream *audioStream = new Audio::LoopingAudioStream(wav, (flag == 1) ? 0 : 1); g_fp->_mixer->playStream(Audio::Mixer::kSFXSoundType, handle, audioStream); }
//! (internal) void StringData::initJumpTable()const{ std::vector<size_t> jumpTable; size_t codePointCursor = 0; const size_t numBytes = getDataSize(); for(size_t byteCursor = 0; byteCursor<numBytes; byteCursor += getUTF8CodePointLength(data->s.c_str()+byteCursor) ){ if( (codePointCursor%JUMP_TABLE_STEP_SIZE)==0 && byteCursor>0) // skip the initial 0 jumpTable.emplace_back(byteCursor); ++codePointCursor; } data->numCodePoints = codePointCursor; if(codePointCursor == getDataSize()){ data->dataType = Data::ASCII; }else{ data->dataType = Data::UNICODE_WITH_JUMTABLE; if(!jumpTable.empty()) data->jumpTable.reset(new std::vector<size_t>(std::move(jumpTable))); } }
BOOL LLImageTGA::decodeTruecolorRle8( LLImageRaw* raw_image ) { llassert( getComponents() == 1 ); U8* dst = raw_image->getData(); U8* src = getData() + mDataOffset; U8* last_src = src + getDataSize(); U8* last_dst = dst + getHeight() * getWidth() - 1; while( dst <= last_dst ) { // Read RLE block header if (src >= last_src) return FALSE; U8 block_header_byte = *src; src++; U8 block_pixel_count = (block_header_byte & 0x7F) + 1; if( block_header_byte & 0x80 ) { if (src >= last_src) return FALSE; // Encoded (duplicate-pixel) block memset( dst, *src, block_pixel_count ); dst += block_pixel_count; src++; } else { // Unencoded block do { if (src >= last_src) return FALSE; *dst = *src; dst++; src++; block_pixel_count--; } while( block_pixel_count > 0 ); } } return TRUE; }
/** * @return The size of the domain to be created. */ size_t FitMD::getDomainSize() const { setParameters(); if (!m_IMDWorkspace) throw std::runtime_error("FitMD: workspace wasn't defined"); auto iterator = m_IMDWorkspace->createIterator(); size_t n = iterator->getDataSize(); delete iterator; if (m_count != 0) { if (m_startIndex + m_count > n) throw std::range_error("FitMD: index is out of range"); n = m_count; } return n; }
BOOL LLImageBMP::decode(LLImageRaw* raw_image, F32 decode_time) { llassert_always(raw_image); resetLastError(); // Check to make sure that this instance has been initialized with data U8* mdata = getData(); if (!mdata || (0 == getDataSize())) { setLastError("llimagebmp trying to decode an image with no data!"); return FALSE; } raw_image->resize(getWidth(), getHeight(), 3); U8* src = mdata + mBitmapOffset; U8* dst = raw_image->getData(); BOOL success = FALSE; switch( mBitsPerPixel ) { case 8: if( mColorPaletteColors >= 256 ) { success = decodeColorTable8( dst, src ); } break; case 16: success = decodeColorMask16( dst, src ); break; case 24: success = decodeTruecolor24( dst, src ); break; case 32: success = decodeColorMask32( dst, src ); break; } if( success && mOriginAtTop ) { raw_image->verticalFlip(); } return success; }
void LLImageRaw::setDataAndSize(U8 *data, S32 width, S32 height, S8 components) { if(data == getData()) { return ; } deleteData(); LLImageBase::setSize(width, height, components) ; LLImageBase::setDataAndSize(data, width * height * components) ; sGlobalRawMemory += getDataSize(); }
/** * Удаляет все найденые ключи, тоесть ищет их командой keys и удаляет каждый найденый ключь. * @param key * @return Вернёт -1 или количество удалёных ключей * @todo Реализовать более быстрый способ работы */ int SimpleRedisClient::delete_keys( const char *key) { if(keys(key)) { if(getDataSize() < 1 || getBufferSize() < 1) { return 0; } char **ptr_data = new char*[getDataSize()]; // Выделяем память для buf_data char *buf_data = new char[ getBufferSize() ]; memcpy(buf_data, getData(), getBufferSize()); long int offset = buf_data - getData(); // Опасное дело! int num_keys = getDataSize(); for(int i =0; i< num_keys; i++) { ptr_data[i] = getData(i) + offset; } for(int i =0; i< num_keys; i++) { printf("del[%d]:'%s'\n", i, ptr_data[i]); del(ptr_data[i]); } // [SimpleRedisClient.cpp:1171]: (error) Mismatching allocation and deallocation: buf_data // Очищаем buf_data delete[] buf_data; delete[] ptr_data; return num_keys; } return -1; }
bool Packet::updateAnalogIn2(const CmtAnalogInData& data, const uint16_t index) { if (getDataSize(index) == 0) return false; if (m_infoList[index].m_analogIn2 == CMT_DATA_ITEM_NOT_AVAILABLE) { // add m_infoList[index].m_analogIn2 = m_msg.getDataSize(); m_msg.resizeData(m_msg.getDataSize() + 2); m_infoList[index].m_size += 2; } // update m_msg.setDataShort(data.m_data, m_infoList[index].m_analogIn2); return true; }
void TR::X86DataSnippet::print(TR::FILE* pOutFile, TR_Debug* debug) { if (pOutFile == NULL) return; uint8_t *bufferPos = getSnippetLabel()->getCodeLocation(); debug->printSnippetLabel(pOutFile, getSnippetLabel(), bufferPos, debug->getName(this)); debug->printPrefix(pOutFile, NULL, bufferPos, getDataSize()); const char* toString; switch (getDataSize()) { case 8: toString = dqString(); break; case 4: toString = ddString(); break; case 2: toString = dwString(); break; default: toString = dbString(); break; } trfprintf(pOutFile, "%s \t%s", toString, hexPrefixString()); for (int i=getDataSize()-1; i >= 0; i--) { trfprintf(pOutFile, "%02x", bufferPos[i]); } trfprintf(pOutFile,"%s\t%s ", hexSuffixString(), commentString()); printValue(pOutFile, debug); }
bool Packet::updateRawTemp(const uint16_t temp, const uint16_t index) { if (getDataSize(index) == 0) return false; if (m_infoList[index].m_rawTemp == CMT_DATA_ITEM_NOT_AVAILABLE) { // add m_infoList[index].m_rawTemp = m_msg.getDataSize(); m_msg.resizeData(m_msg.getDataSize() + 2); m_infoList[index].m_size += 2; } // update m_msg.setDataShort(temp, m_infoList[index].m_rawTemp); return true; }
bool Packet::updateSampleCounter(const uint16_t counter, const uint16_t index) { if (getDataSize(index) == 0) return false; if (m_infoList[index].m_sc == CMT_DATA_ITEM_NOT_AVAILABLE) { // add m_infoList[index].m_sc = m_msg.getDataSize(); m_msg.resizeData(m_msg.getDataSize() + 2); m_infoList[index].m_size += 2; } // update m_msg.setDataShort(counter, m_infoList[index].m_sc); return true; }
bool Packet::updateRawMag(const CmtShortVector& vec, const uint16_t index) { if (getDataSize(index) == 0) return false; if (m_infoList[index].m_rawMag == CMT_DATA_ITEM_NOT_AVAILABLE) { // add m_infoList[index].m_rawMag = m_msg.getDataSize(); m_msg.resizeData(m_msg.getDataSize() + 3*2); m_infoList[index].m_size += 3*2; } // update for (uint16_t i=0;i<3;++i) m_msg.setDataShort(vec.m_data[i], m_infoList[index].m_rawMag + (2*i)); return true; }
bool Packet::updateStatus(const uint8_t data, const uint16_t index) { if (getDataSize(index) == 0) return false; if (m_infoList[index].m_status == CMT_DATA_ITEM_NOT_AVAILABLE) { // add m_infoList[index].m_status = m_msg.getDataSize(); m_msg.resizeData(m_msg.getDataSize() + 1); m_infoList[index].m_size += 1; } // update m_msg.setDataByte(data,m_infoList[index].m_status); return true; }
ATOM_BaseResourceLoader::LOADRESULT ATOM_ModelLoader::loadFromDisk (void) { ATOM_STACK_TRACE(ATOM_ModelLoader::loadFromDisk); ATOM_BaseResourceLoader::LOADRESULT result = ATOM_BaseResourceLoader::loadFromDisk (); if (result != ATOM_BaseResourceLoader::LOADERR_OK) { return result; } if (!_model->memload (ATOM_GetRenderDevice(), getData(), getDataSize(), false, false)) { return ATOM_BaseResourceLoader::LOADERR_FAILED; } return ATOM_BaseResourceLoader::LOADERR_OK; }
TextTable * makeTextTable (TextTableData *ttd) { TextTable *table = malloc(sizeof(*table)); if (table) { memset(table, 0, sizeof(*table)); table->header.fields = getTextTableHeader(ttd); table->size = getDataSize(ttd->area); table->options.tryBaseCharacter = 1; resetDataArea(ttd->area); } return table; }
bool Packet::updateTemp(const double& temp, const uint16_t index) { if (getDataSize(index) == 0) return false; uint16_t ds = getFPValueSize(index); if (m_infoList[index].m_temp == CMT_DATA_ITEM_NOT_AVAILABLE) { // add m_infoList[index].m_temp = m_msg.getDataSize(); m_msg.resizeData(m_msg.getDataSize() + ds); m_infoList[index].m_size += ds; } // update m_msg.setDataFPValue(m_formatList[index].m_outputSettings, temp, m_infoList[index].m_temp); return true; }
bool Packet::updateOriQuat(const CmtQuat& data, const uint16_t index) { const uint16_t numValues = 4; if (getDataSize(index) == 0) return false; uint16_t ds = getFPValueSize(index); if (m_infoList[index].m_oriQuat == CMT_DATA_ITEM_NOT_AVAILABLE) { // add m_infoList[index].m_oriQuat = m_msg.getDataSize(); m_msg.resizeData(m_msg.getDataSize() + numValues*ds); m_infoList[index].m_size += numValues*ds; } // update m_msg.setDataFPValue(m_formatList[index].m_outputSettings, &data.m_data[0], m_infoList[index].m_oriQuat, numValues); return true; }
bool Packet::updateCalMag(const CmtVector& vec, const uint16_t index) { const uint16_t numValues = 3; if (getDataSize(index) == 0) return false; uint16_t ds = getFPValueSize(index); if (m_infoList[index].m_calMag == CMT_DATA_ITEM_NOT_AVAILABLE) { // add m_infoList[index].m_calMag = m_msg.getDataSize(); m_msg.resizeData(m_msg.getDataSize() + numValues*ds); m_infoList[index].m_size += numValues*ds; } // update m_msg.setDataFPValue(m_formatList[index].m_outputSettings, &vec.m_data[0], m_infoList[index].m_calMag, numValues); return true; }
BOOL LLImageTGA::decode(LLImageRaw* raw_image, F32 decode_time) { llassert_always(raw_image); // Check to make sure that this instance has been initialized with data if (!getData() || (0 == getDataSize())) { setLastError("LLImageTGA trying to decode an image with no data!"); return FALSE; } // Copy everything after the header. raw_image->resize(getWidth(), getHeight(), getComponents()); if( (getComponents() != 1) && (getComponents() != 3) && (getComponents() != 4) ) { setLastError("TGA images with a number of components other than 1, 3, and 4 are not supported."); return FALSE; } if( mOriginRightBit ) { setLastError("TGA images with origin on right side are not supported."); return FALSE; } BOOL flipped = (mOriginTopBit != 0); BOOL rle_compressed = ((mImageType & 0x08) != 0); if( mColorMap ) { return decodeColorMap( raw_image, rle_compressed, flipped ); } else { return decodeTruecolor( raw_image, rle_compressed, flipped ); } }
void ICMPv4PacketImpl::initPacket() { if (_seq >= MAX_SEQ_VALUE) resetSequence(); Header* icp = (Header*) packet(false); icp->type = ECHO_REQUEST; icp->code = 0; icp->checksum = 0; icp->seq = ++_seq; #if defined(POCO_VXWORKS) icp->id = 0; #else icp->id = static_cast<UInt16>(Poco::Process::id()); #endif struct timeval* ptp = (struct timeval *) (icp + 1); *ptp = time(); icp->checksum = checksum((UInt16*) icp, getDataSize() + sizeof(Header)); }
PicturePtr FFMPEGVideoFrameConverter::convert( const FFMPEGFrame& srcFrame, const TextureFormat format ) { auto picture = std::make_shared<FFMPEGPicture>( srcFrame.getWidth(), srcFrame.getHeight(), format ); const auto avFormat = _toAVPixelFormat( format ); _impl->swsContext = sws_getCachedContext( _impl->swsContext, srcFrame.getWidth(), srcFrame.getHeight(), srcFrame.getAVPixelFormat(), picture->getWidth(), picture->getHeight(), avFormat, SWS_FAST_BILINEAR, nullptr, nullptr, nullptr ); if( !_impl->swsContext ) return PicturePtr(); uint8_t* dstData[3]; int linesize[3]; for( size_t i = 0; i < 3; ++i ) { dstData[i] = picture->getData( i ); // width of image plane in pixels * bytes per pixel linesize[i] = picture->getDataSize( i ) / picture->getTextureSize( i ).height(); } const auto outputHeight = sws_scale( _impl->swsContext, srcFrame.getAVFrame().data, srcFrame.getAVFrame().linesize, 0, srcFrame.getHeight(), dstData, linesize ); if( outputHeight != picture->getHeight( )) return PicturePtr(); return picture; }
bool Packet::updateOriEuler(const CmtEuler& data, const uint16_t index) { const uint16_t numValues = 3; if (getDataSize(index) == 0) return false; uint16_t ds = getFPValueSize(index); if (m_infoList[index].m_oriEul == CMT_DATA_ITEM_NOT_AVAILABLE) { // add m_infoList[index].m_oriEul = m_msg.getDataSize(); m_msg.resizeData(m_msg.getDataSize() + numValues*ds); m_infoList[index].m_size += numValues*ds; } // update m_msg.setDataFPValue(m_formatList[index].m_outputSettings, data.m_roll, m_infoList[index].m_oriEul); m_msg.setDataFPValue(m_formatList[index].m_outputSettings, data.m_pitch, m_infoList[index].m_oriEul + ds); m_msg.setDataFPValue(m_formatList[index].m_outputSettings, data.m_yaw, m_infoList[index].m_oriEul + 2*ds); return true; }
bool Packet::updateRawData(const CmtRawData& data, const uint16_t index) { if (getDataSize(index) == 0) return false; if (m_infoList[index].m_rawData == CMT_DATA_ITEM_NOT_AVAILABLE) { // add m_infoList[index].m_rawData = m_msg.getDataSize(); m_msg.resizeData(m_msg.getDataSize() + 3* 3*2 + 2); m_infoList[index].m_rawAcc = m_infoList[index].m_rawData; m_infoList[index].m_rawGyr = m_infoList[index].m_rawData + 3*2; m_infoList[index].m_rawMag = m_infoList[index].m_rawData + 6*2; m_infoList[index].m_rawTemp= m_infoList[index].m_rawData + 9*2; m_infoList[index].m_size += 3* 3*2 + 2; } // update int16_t* bare = (int16_t*) &data; for (uint16_t i=0;i<10;++i) m_msg.setDataShort(bare[i], m_infoList[index].m_rawData + (2*i)); return true; }
bool Packet::updateRawGpsData(const CmtRawGpsData& data, const uint16_t index) { if (getDataSize(index) == 0) return false; if (m_infoList[index].m_rawGpsData == CMT_DATA_ITEM_NOT_AVAILABLE) { // add m_infoList[index].m_rawGpsData = m_msg.getDataSize(); m_msg.resizeData(m_msg.getDataSize() + (2+1) + (40 + 1)); m_infoList[index].m_rawGpsPressure = m_infoList[index].m_rawGpsData; m_infoList[index].m_rawGpsPressureAge = m_infoList[index].m_rawGpsData + 2; m_infoList[index].m_rawGpsGpsData = m_infoList[index].m_rawGpsData + 3; m_infoList[index].m_rawGpsItow = m_infoList[index].m_rawGpsData + 3; m_infoList[index].m_rawGpsLatitude = m_infoList[index].m_rawGpsData + 3 + 4; m_infoList[index].m_rawGpsLongitude = m_infoList[index].m_rawGpsData + 3 + 8; m_infoList[index].m_rawGpsHeight = m_infoList[index].m_rawGpsData + 3 + 12; m_infoList[index].m_rawGpsVeln = m_infoList[index].m_rawGpsData + 3 + 16; m_infoList[index].m_rawGpsVele = m_infoList[index].m_rawGpsData + 3 + 20; m_infoList[index].m_rawGpsVeld = m_infoList[index].m_rawGpsData + 3 + 24; m_infoList[index].m_rawGpsHacc = m_infoList[index].m_rawGpsData + 3 + 28; m_infoList[index].m_rawGpsVacc = m_infoList[index].m_rawGpsData + 3 + 32; m_infoList[index].m_rawGpsSacc = m_infoList[index].m_rawGpsData + 3 + 36; m_infoList[index].m_rawGpsGpsAge = m_infoList[index].m_rawGpsData + 3 + 40; m_infoList[index].m_size += (2+1) + (40 + 1); } // update m_msg.setDataShort(data.m_pressure, m_infoList[index].m_rawGpsPressure); m_msg.setDataByte(data.m_pressureAge, m_infoList[index].m_rawGpsPressureAge); // lon,lat,height,hacc,vacc,veln,vele,veld int32_t* bareln = (int32_t*)&data.m_itow; for (uint16_t i=0; i<10;++i) m_msg.setDataLong(bareln[i],m_infoList[index].m_rawGpsGpsData + (4*i)); // gpsAge m_msg.setDataByte(data.m_gpsAge, m_infoList[index].m_rawGpsGpsAge); return true; }
bool Packet::updateOriMatrix(const CmtMatrix& data, const uint16_t index) { const uint16_t numValues = 9; if (getDataSize(index) == 0) return false; uint16_t ds = getFPValueSize(index); if (m_infoList[index].m_oriMat == CMT_DATA_ITEM_NOT_AVAILABLE) { // add m_infoList[index].m_oriMat = m_msg.getDataSize(); m_msg.resizeData(m_msg.getDataSize() + numValues*ds); m_infoList[index].m_size += numValues*ds; } // update uint16_t k = 0; for (int32_t i=0;i<3;++i) for (int32_t j=0;j<3;++j, k+=ds) m_msg.setDataFPValue(m_formatList[index].m_outputSettings, data.m_data[i][j], m_infoList[index].m_oriMat+k); return true; }
// Virtual // Decode an in-memory PNG image into the raw RGB or RGBA format // used within SecondLife. BOOL LLImagePNG::decode(LLImageRaw* raw_image, F32 decode_time) { llassert_always(raw_image); resetLastError(); // Check to make sure that this instance has been initialized with data if (!getData() || (0 == getDataSize())) { setLastError("LLImagePNG trying to decode an image with no data!"); return FALSE; } // Decode the PNG data into the raw image LLPngWrapper pngWrapper; if (! pngWrapper.readPng(getData(), raw_image)) { setLastError(pngWrapper.getErrorMessage()); return FALSE; } return TRUE; }