// write the values stored in ledStatus to the cube, ideally this method should // be called atleast once every millisecond for multiplexing to give a smooth // image and avoid flickering. // displays 1 layer at a time at a high frequency to give a smooth image. void CubeInterface::writeCube() { // 9th shift register controls cathodes for(byte i = 0; i < 8; i++) { if(CATHODE_PINS[i] == currentLayer) highBit(); else lowBit(); } // for // first 8 shift registers control anodes for(byte i = 0; i < 64; i++) if(ledStatus[ANODE_PINS[i][0]] [ANODE_PINS[i][1]] [currentLayer] == HIGH) highBit(); else lowBit(); if(currentLayer < 7) currentLayer++; else currentLayer = 0; latch(); } // writeCube
void ioGrowSignalQueue( int n ) { #if SQ_DYNAMIC_QUEUE_SIZE // ignore, if queue size is static /* only to grow */ if (maxPendingSignals < n) { extern sqInt highBit(sqInt); int sz = 1 << highBit(n-1); assert(sz >= n); sqInt * newBuf = realloc(signalQueue, sz * sizeof(sqInt)); /* we should lock queue when growing, so nobody can access the queue buffer when we mutate the pointer */ lockSignalQueue(); signalQueue = newBuf; unlockSignalQueue(); maxPendingSignals = sz; } #endif }
0x2018, 0x2019, // general punctuation 0x201c, 0x201d, 0x2039, 0x203a, 0x3008, 0x3009, // chinese paired punctuation 0x300a, 0x300b, 0x300c, 0x300d, 0x300e, 0x300f, 0x3010, 0x3011, 0x3014, 0x3015, 0x3016, 0x3017, 0x3018, 0x3019, 0x301a, 0x301b }; const int32_t ScriptRun::pairedCharCount = UPRV_LENGTHOF(pairedChars); const int32_t ScriptRun::pairedCharPower = 1 << highBit(pairedCharCount); const int32_t ScriptRun::pairedCharExtra = pairedCharCount - pairedCharPower; int8_t ScriptRun::highBit(int32_t value) { if (value <= 0) { return -32; } int8_t bit = 0; if (value >= 1 << 16) { value >>= 16; bit += 16; }
void transformsChain::runTransform( const ptr<image>& inputImage, std::uint32_t inputTopLeftX, std::uint32_t inputTopLeftY, std::uint32_t inputWidth, std::uint32_t inputHeight, const ptr<image>& outputImage, std::uint32_t outputTopLeftX, std::uint32_t outputTopLeftY) { if(isEmpty()) { ptr<transformHighBit> highBit(new transformHighBit); highBit->runTransform(inputImage, inputTopLeftX, inputTopLeftY, inputWidth, inputHeight, outputImage, outputTopLeftX, outputTopLeftY); return; } if(m_transformsList.size() == 1) { m_transformsList.front()->runTransform(inputImage, inputTopLeftX, inputTopLeftY, inputWidth, inputHeight, outputImage, outputTopLeftX, outputTopLeftY); return; } // Get the position of the last transform /////////////////////////////////////////////////////////// tTransformsList::iterator lastTransform(m_transformsList.end()); --lastTransform; std::wstring inputColorSpace(inputImage->getColorSpace()); image::bitDepth inputDepth(inputImage->getDepth()); std::uint32_t inputHighBit(inputImage->getHighBit()); std::wstring outputColorSpace(outputImage->getColorSpace()); image::bitDepth outputDepth(outputImage->getDepth()); std::uint32_t outputHighBit(outputImage->getHighBit()); std::uint32_t allocateRows = 65536 / inputWidth; if(allocateRows < 1) { allocateRows = 1; } if(allocateRows > inputHeight) { allocateRows = inputHeight; } // Allocate temporary images /////////////////////////////////////////////////////////// if( m_inputWidth != inputWidth || m_inputHeight != inputHeight || m_inputColorSpace != inputColorSpace || m_inputDepth != inputDepth || m_inputHighBit != inputHighBit || m_outputColorSpace != outputColorSpace || m_outputDepth != outputDepth || m_outputHighBit != outputHighBit) { m_inputWidth = inputWidth; m_inputHeight = inputHeight; m_inputColorSpace = inputColorSpace; m_inputDepth = inputDepth; m_inputHighBit = inputHighBit; m_outputColorSpace = outputColorSpace; m_outputDepth = outputDepth; m_outputHighBit = outputHighBit; m_temporaryImages.clear(); tTransformsList::iterator scanTransforms(m_transformsList.begin()); m_temporaryImages.push_back((*scanTransforms)->allocateOutputImage(inputImage, inputWidth, allocateRows)); while(++scanTransforms != lastTransform) { m_temporaryImages.push_back((*scanTransforms)->allocateOutputImage(m_temporaryImages.back(), inputWidth, allocateRows)); } } // Run all the transforms. Split the images into several // parts /////////////////////////////////////////////////////////// while(inputHeight != 0) { std::uint32_t rows = allocateRows; if(rows > inputHeight) { rows = inputHeight; } inputHeight -= rows; tTransformsList::iterator scanTransforms(m_transformsList.begin()); tTemporaryImagesList::iterator scanTemporaryImages(m_temporaryImages.begin()); (*scanTransforms)->runTransform(inputImage, inputTopLeftX, inputTopLeftY, inputWidth, rows, *scanTemporaryImages, 0, 0); inputTopLeftY += rows; while(++scanTransforms != lastTransform) { ptr<image> temporaryInput(*(scanTemporaryImages++)); ptr<image> temporaryOutput(*scanTemporaryImages); (*scanTransforms)->runTransform(temporaryInput, 0, 0, inputWidth, rows, temporaryOutput, 0, 0); } m_transformsList.back()->runTransform(*scanTemporaryImages, 0, 0, inputWidth, rows, outputImage, outputTopLeftX, outputTopLeftY); outputTopLeftY += rows; } }
ptr<image> modalityVOILUT::allocateOutputImage(ptr<image> pInputImage, std::uint32_t width, std::uint32_t height) { if(isEmpty()) { ptr<image> newImage(new image()); newImage->create(width, height, pInputImage->getDepth(), pInputImage->getColorSpace(), pInputImage->getHighBit()); return newImage; } // LUT /////////////////////////////////////////////////////////// if(m_voiLut != 0 && m_voiLut->getSize() != 0 && m_voiLut->checkValidDataRange()) { std::uint8_t bits(m_voiLut->getBits()); // Look for negative outputs bool bNegative(false); for(std::int32_t index(m_voiLut->getFirstMapped()), size(m_voiLut->getSize()); !bNegative && size != 0; --size, ++index) { bNegative = (m_voiLut->mappedValue(index) < 0); } image::bitDepth depth; if(bNegative) { if(bits > 16) { depth = image::depthS32; } else if(bits > 8) { depth = image::depthS16; } else { depth = image::depthS8; } } else { if(bits > 16) { depth = image::depthU32; } else if(bits > 8) { depth = image::depthU16; } else { depth = image::depthU8; } } ptr<image> returnImage(new image); returnImage->create(width, height, depth, pInputImage->getColorSpace(), bits - 1); return returnImage; } // Rescale /////////////////////////////////////////////////////////// if(m_rescaleSlope == 0) { ptr<image> returnImage(new image); returnImage->create(width, height, pInputImage->getDepth(), pInputImage->getColorSpace(), pInputImage->getHighBit()); return returnImage; } image::bitDepth inputDepth(pInputImage->getDepth()); std::uint32_t highBit(pInputImage->getHighBit()); std::int32_t value0 = 0; std::int32_t value1 = ((std::int32_t)1 << (highBit + 1)) - 1; if(inputDepth == image::depthS16 || inputDepth == image::depthS8) { value0 = ((std::int32_t)(-1) << highBit); value1 = ((std::int32_t)1 << highBit); } std::int32_t finalValue0((std::int32_t) ((double)value0 * m_rescaleSlope + m_rescaleIntercept + 0.5) ); std::int32_t finalValue1((std::int32_t) ((double)value1 * m_rescaleSlope + m_rescaleIntercept + 0.5) ); std::int32_t minValue, maxValue; if(finalValue0 < finalValue1) { minValue = finalValue0; maxValue = finalValue1; } else { minValue = finalValue1; maxValue = finalValue0; } ptr<image> returnImage(new image); if(minValue >= 0 && maxValue <= 255) { returnImage->create(width, height, image::depthU8, pInputImage->getColorSpace(), 7); return returnImage; } if(minValue >= -128 && maxValue <= 127) { returnImage->create(width, height, image::depthS8, pInputImage->getColorSpace(), 7); return returnImage; } if(minValue >= 0 && maxValue <= 65535) { returnImage->create(width, height, image::depthU16, pInputImage->getColorSpace(), 15); return returnImage; } if(minValue >= -32768 && maxValue <= 32767) { returnImage->create(width, height, image::depthS16, pInputImage->getColorSpace(), 15); return returnImage; } returnImage->create(width, height, image::depthS32, pInputImage->getColorSpace(), 31); return returnImage; }