at a res of 1280*720
7237
private function stitchThumbs($episode, $cache_asset)
    {
        $path = $this->asset_helper->getPath($cache_asset, true);
        // calculate total number of thumbs based on length and timeinterval.
        $numberOfSprites = ceil($episode->getDuration()/$this->sprite_interval);
        //one long image, with every image below it.
        $spriteImage = imagecreatetruecolor($this->sprite_width, $numberOfSprites*$this->sprite_height);

        // create a long image containing all thumbnails on top of each other
        for ($number = 1; $number <= $numberOfSprites; $number++) {
            $currentSprite = sprintf($path, $number);
            $image = \imagecreatefromjpeg($currentSprite);
            imagecopy(
                $spriteImage, // destination image
                $image,       // image to copy onto destination image
                0,            // start point x on destination
                $this->sprite_height*($number-1),   // start point y on destination
                0,            // start point x on image
                0,            // start point y on image
                $this->sprite_width, // width of image to copy onto destination
                $this->sprite_height // height of image to copy onto destinaion
            );
        }

        // get final image content
        ob_start();
            header('Content-Type: image/jpeg');
            imagejpeg($spriteImage);
            $sprite = ob_get_contents();
        ob_end_clean();

        $filesystem = $this->asset_helper->getFilesystem($cache_asset->getAdapter());

        // delete thumbnails
        for ($number = 0; $number <= $numberOfSprites; $number++) {
            if ($filesystem->has(sprintf($cache_asset->getFilekey(), $number+1))) {
                $filesystem->delete(sprintf($cache_asset->getFilekey(), $number+1));
            }
        }

        // finalize asset, write to adapter, link to episode
        $cache_asset->setFilekey(uniqID());
        $filesystem->write($cache_asset, $sprite);
        $this->getContainer()->get('oktolab_media_helper')->deleteEpisodeSprite($episode);
        $episode->setSprite($cache_asset);
        $em = $this->getContainer()->get('doctrine.orm.entity_manager');
        $em->persist($episode);
        $em->flush();

        // move sprite to correct destination
        $this->getContainer()->get('bprs.asset_job')->addMoveAssetJob(
            $cache_asset,
            $this->getContainer()->getParameter('oktolab_media.sprite_filesystem'),
            $this->getContainer()->getParameter('oktolab_media.sprite_worker_queue')
        );
    }
1275684
def pretty_bytes(num):
    
    for unit in ['', 'KB', 'MB', 'GB']:
        if num < 1024.0:
            if unit == '':
                return "%d" % (num)
            else:
                return "%3.1f%s" % (num, unit)
        num /= 1024.0
    return "%3.1f%s" % (num, 'TB')
1209401
function format(res) {
  return res.hz.toLocaleString ('en', {maximumFractionDigits: 0}) + ' Hz '
       + '±' + res.stats.rme.toFixed (2) + '% '
       + '(n ' + String (res.stats.sample.length) + ')';
}
692210
def encode_uvarint(n, data):
    ''''''
    if n < 0:
        raise ValueError('only support positive integer')
    while True:
        this_byte = n & 127
        n >>= 7
        if n == 0:
            data.append(this_byte)
            break
        data.append(this_byte | 128)
1203874
def _get_dst_resolution(self, dst_res=None):
        """"""
        if dst_res is None:
            dst_res = min(self._res_indices.keys())
        return dst_res
284514
def inttoLEB128(intinput):
    '''
    
    '''

    binstr = str(bin(intinput)) \
             .lstrip("0b").replace("b","").replace("L","") \
             .replace("'","").replace('"',"")
    if len(binstr) % 7:
        binstr = binstr.zfill(len(binstr) + 7 - (len(binstr) % 7))
    bytelist = ""
    for i in range(len(binstr) // 7):
        if i < ((len(binstr) // 7) - 1):
            pad = "1"
        else:
            pad = "0"
        currbyte = binstr[(len(binstr) - (7*i + 7)):(len(binstr) - (7*i))]
        currbyte = pad + currbyte
        currbyte = dechex(int(currbyte,2))
        # assert len(currbyte) == 2
        bytelist = bytelist + currbyte
    return bytelist
1020877
private void scaleToOutputResolution(Image image) {

        float factor = m_sharedContext.getDotsPerPixel();
        if (factor != 1.0f) {
            image.scaleAbsolute(image.getPlainWidth() * factor, image.getPlainHeight() * factor);
        }
    }
1104207
def to_s
      #check whether any `high` bits are set
      @bmp[0] = false
      65.upto(128) {|i|
        if self[i]
          # if so, set continuation bit
          @bmp[0] = true
          break
        end
      }
      str = "".force_encoding("ASCII-8BIT")
      1.upto(self[1] ? 128 : 64) {|i|
        str << (self[i] ? "1" : "0")
      }
      str
    end
1069831
public static void bufferedToPlanar_U8(DataBufferInt buffer, WritableRaster src, Planar<GrayU8> dst) {
		int[] srcData = buffer.getData();

		int srcStride = stride(src);
		int srcOffset = getOffset(src);

		int numBands = src.getNumBands();
		byte[] data1 = dst.getBand(0).data;
		byte[] data2 = dst.getBand(1).data;
		byte[] data3 = dst.getBand(2).data;

		if( numBands == 3 ) {
			//CONCURRENT_BELOW BoofConcurrency.loopFor(0, dst.height, y -> {
			for (int y = 0; y < dst.height; y++) {
				int indexSrc = srcOffset + y*srcStride;
				int indexDst = dst.startIndex + y * dst.stride;
				for (int x = 0; x < dst.width; x++, indexDst++) {

					int rgb = srcData[indexSrc++];

					data1[indexDst] = (byte) (rgb >>> 16);
					data2[indexDst] = (byte) (rgb >>> 8);
					data3[indexDst] = (byte) rgb;
				}
			}
			//CONCURRENT_ABOVE });
		} else if( numBands == 4 ) {
			byte[] data4 = dst.getBand(3).data;

			//CONCURRENT_BELOW BoofConcurrency.loopFor(0, dst.height, y -> {
			for (int y = 0; y < dst.height; y++) {
				int indexSrc = srcOffset + y*srcStride;
				int indexDst = dst.startIndex + y * dst.stride;
				for (int x = 0; x < dst.width; x++, indexDst++) {

					int rgb = srcData[indexSrc++];

					data1[indexDst] = (byte) (rgb >>> 24);
					data2[indexDst] = (byte) (rgb >>> 16);
					data3[indexDst] = (byte) (rgb >>> 8);
					data4[indexDst] = (byte) rgb;
				}
			}
			//CONCURRENT_ABOVE });
		}
	}
307049
public int  nonzeros(int [] res){
    if(!isSparse())
      for( int i = 0; i < _len; ++i)
        res[i] = i;
    else {
      int j = 0;
      for (int i = nextNZ(-1); i < _len; i = nextNZ(i))
        res[j++] = i;
      assert res.length == j;
    }
    return _len;
  }
966537
function (cp) {
	        return (cp < 0x10000) ? String.fromCharCode(cp) :
	            String.fromCharCode(0xD800 + ((cp - 0x10000) >> 10)) +
	                String.fromCharCode(0xDC00 + ((cp - 0x10000) & 1023));
	    }
441645
def set_res(self,res):
        
        if isinstance(res,str):
            res = pst_utils.read_resfile(res)
        self.__res = res
708565
private int bytesPerPixel() {
		long fileSize = data.getFile().length();
		long pixelMax = getXPixels() * (long) getYPixels();
		// ceil result, because it is a maximum that we use to divide
		return (int) Math.ceil(fileSize / (double) pixelMax);
	}
410631
def _rescale(ar):
    """"""
    max = np.nanmax(ar)
    min = np.nanmin(ar)
    midpoint = (max + min) / 2.0
    return 2.0 * (ar - midpoint) / (max - min)
297077
public function readU29() {

            $count = 1;
            $u29 = 0;

            $byte = $this->stream->readByte();
  
            while((($byte & 0x80) != 0) && $count < 4) {
                $u29 <<= 7;
                $u29 |= ($byte & 0x7f);
                $byte = $this->stream->readByte();
                $count++;
            }
            
            if ($count < 4) {
                $u29 <<= 7;
                $u29 |= $byte;
            } else {
                // Use all 8 bits from the 4th byte
                $u29 <<= 8;
                $u29 |= $byte;
            }
            
            return $u29;
         
        }
272287
function() {
        // set up properties for Mercator - assume EPSG:900913
        this.RESOLUTIONS = [];
        var maxResolution = 156543.03390625;
        for(var zoom=0; zoom<=this.MAX_ZOOM_LEVEL; ++zoom) {
            this.RESOLUTIONS[zoom] = maxResolution / Math.pow(2, zoom);
        }
        this.units = "m";
        this.projection = this.projection || "EPSG:900913";
    }
1350594
def rescale_pixel_values(images, order="C"):
    
    images = np.asarray(images, order=order).astype("float32")
    images -= images.min()
    images /= images.max()
    return images