frame-size: 3-byte integer, size of frame, big endian encoded (excludes
 padding)
772047
def body_size(padded=false)
      l = enc_cmd_id.size + payload.size
      padded ? Utils.ceil16(l) : l
    end
1153937
def endianSwapU16(bytes):
    """"""
    for b in range(0, len(bytes), 2):
        bytes[b], bytes[b + 1] = bytes[b + 1], bytes[b]
    return bytes
1011947
def getCameraFrameSize(self, nDeviceIndex, eFrameType):
        """"""

        fn = self.function_table.getCameraFrameSize
        pnWidth = c_uint32()
        pnHeight = c_uint32()
        pnFrameBufferSize = c_uint32()
        result = fn(nDeviceIndex, eFrameType, byref(pnWidth), byref(pnHeight), byref(pnFrameBufferSize))
        return result, pnWidth.value, pnHeight.value, pnFrameBufferSize.value
987638
function readInt32W(buffer, offset, isBigEndian, noAssert) {
  var neg, val;

  if (!noAssert) {
    assert.ok(typeof (isBigEndian) === 'boolean',
        'missing or invalid endian');

    assert.ok(offset !== undefined && offset !== null,
        'missing offset');

    assert.ok(offset + 3 < buffer.length,
        'Trying to read beyond buffer length');
  }

  val = readUInt32W(buffer, offset, isBigEndian, noAssert);
  neg = val & 0x80000000;
  if (!neg) {
    return (val);
  }

  return (0xffffffff - val + 1) * -1;
}
931893
public static void writeLongLittleEndian(ByteBuffer io, long value) {
		io.put((byte)(value & 0xFF));
		io.put((byte)((value >> 8) & 0xFF));
		io.put((byte)((value >> 16) & 0xFF));
		io.put((byte)((value >> 24) & 0xFF));
		io.put((byte)((value >> 32) & 0xFF));
		io.put((byte)((value >> 40) & 0xFF));
		io.put((byte)((value >> 48) & 0xFF));
		io.put((byte)((value >> 56) & 0xFF));
	}
357041
def SizeInBytes(sized_field, length, encoder=ENC_INT_DEFAULT, fuzzable=False, name=None):
    '''
    
    '''
    return Size(sized_field=sized_field, length=length, calc_func=lambda x: len(x) // 8, encoder=encoder, fuzzable=fuzzable, name=name)
627429
def _long2bytes(n, blocksize=0):
    

    # After much testing, this algorithm was deemed to be the fastest.
    s = ''
    pack = struct.pack
    while n > 0:
        ### CHANGED FROM '>I' TO '<I'. (DCG)
        s = pack('<I', n & 0xffffffffL) + s
        ### --------------------------
        n = n >> 32

    # Strip off leading zeros.
    for i in range(len(s)):
        if s[i] <> '\000':
            break
    else:
        # Only happens when n == 0.
        s = '\000'
        i = 0

    s = s[i:]

    # Add back some pad bytes. This could be done more efficiently
    # w.r.t. the de-padding being done above, but sigh...
    if blocksize > 0 and len(s) % blocksize:
        s = (blocksize - len(s) % blocksize) * '\000' + s

    return s
869952
def convert_bytes(value):
    
    n = np.rint(len(str(value))/4).astype(int)
    return value/(1024**n), sizes[n]
883608
function lengthInUtf8Bytes(str) {
		const m = encodeURIComponent(str).match(/%[89ABab]/g);
		return str.length + (m ? m.length : 0);
	}
1213485
int read_frame_data(int bytesize) throws BitstreamException
	{
 		int	numread = 0;
		numread = readFully(frame_bytes, 0, bytesize);
		framesize = bytesize;
		wordpointer = -1;
	    bitindex = -1;
	    return numread;
	}
530742
def btc_tx_der_encode_length(l):
    
    if l < 0:
        raise ValueError("length cannot be negative")

    if l < 0x80:
        return int2byte(l)
    s = ("%x" % l).encode()
    if len(s) % 2:
        s = b("0") + s
    s = binascii.unhexlify(s)
    llen = len(s)
    return int2byte(0x80 | llen) + s
1161309
def from_frame(cls, frame):
        """"""
        # TODO: Check length
        ipframe = cls(frame[2] * 256 + frame[3])
        ipframe.body = frame[6:]
        return ipframe
303328
def wr_long(f, x):
    """"""
    if PYTHON3:
        f.write(bytes([x        & 0xff]))
        f.write(bytes([(x >> 8)  & 0xff]))
        f.write(bytes([(x >> 16) & 0xff]))
        f.write(bytes([(x >> 24) & 0xff]))
    else:
        f.write(chr( x        & 0xff))
        f.write(chr((x >> 8)  & 0xff))
        f.write(chr((x >> 16) & 0xff))
        f.write(chr((x >> 24) & 0xff))
839464
def _numpy24to32bit(data:np.ndarray, bigendian:bool=False) -> np.ndarray:
    
    target = np.zeros((data.shape[0] * 4 / 3,), dtype=np.ubyte)
    if not bigendian:
        target[3::4] = data[2::3]
        target[2::4] = data[1::3]
        target[1::4] = data[0::3]
    else:
        target[1::4] = data[2::3]
        target[2::4] = data[1::3]
        target[3::4] = data[0::3]
    del data
    targetraw = target.tostring()
    del target
    data = np.fromstring(targetraw, dtype=np.int32)
    return data
703362
def encode(i, *, width=-1):
        
        if i < 0:
            raise ValueError("value is negative")
        assert width != 0
        data = bytearray()
        while i:
            data.append(i & 127)
            i >>= 7
        if width > 0 and len(data) > width:
            raise ValueError("Integer too large")
        if len(data) < abs(width):
            data.extend([0] * (abs(width) - len(data)))
        data.reverse()
        return data
186602
def _var_uint64_byte_size_no_tag(uint64):
    
    if uint64 > UINT64_MAX:
        raise errors.EncodeError('Value out of range: %d' % uint64)
    bytes = 1
    while uint64 > 0x7f:
        bytes += 1
        uint64 >>= 7
    return bytes
1340645
def long_to_bytes(n, blocksize=0):
    
    # after much testing, this algorithm was deemed to be the fastest
    s = b''
    if USING_PYTHON2:
        n = long(n)  # noqa
    pack = struct.pack
    while n > 0:
        s = pack(b'>I', n & 0xffffffff) + s
        n = n >> 32
    # strip off leading zeros
    for i in range(len(s)):
        if s[i] != b'\000'[0]:
            break
    else:
        # only happens when n == 0
        s = b'\000'
        i = 0
    s = s[i:]
    # add back some pad bytes.  this could be done more efficiently w.r.t. the
    # de-padding being done above, but sigh...
    if blocksize > 0 and len(s) % blocksize:
        s = (blocksize - len(s) % blocksize) * b'\000' + s
    return s