Takes id3v2.4 frame data and determines if ints or bitpaddedints
    should be used for parsing. Needed because iTunes used to write
    normal ints for frame sizes.
779461
def determine_bpi(data, frames, EMPTY=b"\x00" * 10):
    

    # count number of tags found as BitPaddedInt and how far past
    o = 0
    asbpi = 0
    while o < len(data) - 10:
        part = data[o:o + 10]
        if part == EMPTY:
            bpioff = -((len(data) - o) % 10)
            break
        name, size, flags = struct.unpack('>4sLH', part)
        size = BitPaddedInt(size)
        o += 10 + size
        if PY3:
            try:
                name = name.decode("ascii")
            except UnicodeDecodeError:
                continue
        if name in frames:
            asbpi += 1
    else:
        bpioff = o - len(data)

    # count number of tags found as int and how far past
    o = 0
    asint = 0
    while o < len(data) - 10:
        part = data[o:o + 10]
        if part == EMPTY:
            intoff = -((len(data) - o) % 10)
            break
        name, size, flags = struct.unpack('>4sLH', part)
        o += 10 + size
        if PY3:
            try:
                name = name.decode("ascii")
            except UnicodeDecodeError:
                continue
        if name in frames:
            asint += 1
    else:
        intoff = o - len(data)

    # if more tags as int, or equal and bpi is past and int is not
    if asint > asbpi or (asint == asbpi and (bpioff >= 1 and intoff <= 1)):
        return int
    return BitPaddedInt
1117034
function __deserializeInt32(buffer, start, options) {
	let end = start + 4;
	let dataView = new DataView(buffer);
	let data = dataView.getInt32(start, true);
	return { anchor: end, value:options.use_native_types ? data : Int32.from(data) };
}
524438
private int readID3v2Header(InputStream in) throws IOException
	{		
		byte[] id3header = new byte[4];
		int size = -10;
		in.read(id3header,0,3);
		// Look for ID3v2
		if ( (id3header[0]=='I') && (id3header[1]=='D') && (id3header[2]=='3'))
		{
			in.read(id3header,0,3);
			//int majorVersion = id3header[0];
			//int revision = id3header[1];
			in.read(id3header,0,4);
			size = (int) (id3header[0] << 21) + (id3header[1] << 14) + (id3header[2] << 7) + (id3header[3]);
		}
		return (size+10);
	}
155822
def _determine_datatype(fields):
    """"""

    # Convert the NRRD type string identifier into a NumPy string identifier using a map
    np_typestring = _TYPEMAP_NRRD2NUMPY[fields['type']]

    # This is only added if the datatype has more than one byte and is not using ASCII encoding
    # Note: Endian is not required for ASCII encoding
    if np.dtype(np_typestring).itemsize > 1 and fields['encoding'] not in ['ASCII', 'ascii', 'text', 'txt']:
        if 'endian' not in fields:
            raise NRRDError('Header is missing required field: "endian".')
        elif fields['endian'] == 'big':
            np_typestring = '>' + np_typestring
        elif fields['endian'] == 'little':
            np_typestring = '<' + np_typestring
        else:
            raise NRRDError('Invalid endian value in header: "%s"' % fields['endian'])

    return np.dtype(np_typestring)
177405
def variable_length_int(i):
    
    if not isinstance(i, (int,long)):
        raise Exception('i must be an integer')

    if i < (2**8-3):
        return chr(i) # pack the integer into one byte
    elif i < (2**16):
        return chr(253) + struct.pack('<H', i) # pack into 2 bytes
    elif i < (2**32):
        return chr(254) + struct.pack('<I', i) # pack into 4 bytes
    elif i < (2**64):
        return chr(255) + struct.pack('<Q', i) # pack into 8 bites
    else:
        raise Exception('Integer cannot exceed 8 bytes in length.')
884082
private static int parseNanos(long serialized)
    {
        int zeros = ((int) serialized) & 0b111;
        int result = (int) (serialized >>> 3);
        if (zeros != 0) {
            for (int i = 0; i <= zeros; ++i) {
                result *= 10;
            }
        }
        return result;
    }
843915
private boolean isDatatype( DdlTokenStream tokens,
                                int type ) throws ParsingException {
        // Loop through the registered statement start string arrays and look for exact matches.

        switch (type) {
            case DataTypes.DTYPE_CODE_CHAR_STRING: {
                for (String[] stmts : basicCharStringTypes) {
                    if (tokens.matches(stmts)) return true;
                }
            }
                break;
            case DataTypes.DTYPE_CODE_NCHAR_STRING: {
                for (String[] stmts : basicNationalCharStringTypes) {
                    if (tokens.matches(stmts)) return true;
                }
            }
                break;
            case DataTypes.DTYPE_CODE_BIT_STRING: {
                for (String[] stmts : basicBitStringTypes) {
                    if (tokens.matches(stmts)) return true;
                }
            }
                break;
            case DataTypes.DTYPE_CODE_EXACT_NUMERIC: {
                for (String[] stmts : basicExactNumericTypes) {
                    if (tokens.matches(stmts)) return true;
                }
            }
                break;
            case DataTypes.DTYPE_CODE_APROX_NUMERIC: {
                for (String[] stmts : basicApproxNumericStringTypes) {
                    if (tokens.matches(stmts)) return true;
                }
            }
                break;
            case DataTypes.DTYPE_CODE_DATE_TIME: {
                for (String[] stmts : basicDateTimeTypes) {
                    if (tokens.matches(stmts)) return true;
                }
            }
                break;
            case DataTypes.DTYPE_CODE_MISC: {
                for (String[] stmts : basicMiscTypes) {
                    if (tokens.matches(stmts)) return true;
                }
            }
                break;
        }

        return false;
    }
803618
private static boolean checkIpv4(byte[] bytes, int pos, int length) {
		int start = pos;
		for (int i = pos; i < length; i++) {
			// assume at least one more symbol is present after dot
			if (i == length - 1 && bytes[i] == '.') {
				return false;
			}
			if (bytes[i] == '.' || i == length - 1) {
				int v;
				if (i - start == 0 && i != length - 1) {
					return false;
				}
				try {
					v = trimAndDecodePositiveInt(bytes, start, i - start);
				} catch (ParseException e) {
					return false;
				}
				if (v < 0 || v > 255) return false;
				start = i + 1;
			}
		}
		return true;
	}
378419
private static int getPID()
    {
        if (tc.isEntryEnabled())
            Tr.entry(tc, "getPID");

        short spid = 0;
        int ipid = 0;

        try
        {
            spid = Short.parseShort(com.ibm.ejs.ras.RasHelper.getProcessId());
        } catch (Throwable t)
        {
            // No FFDC code needed.

            if (tc.isEventEnabled())
                Tr.event(tc, "Caught throwable parsing PID", t);
            spid = (short) (new java.util.Random().nextInt() & 0x0000FFFF); // (i.e. keep 16 bits)
        }

        // Convert the spid value (a 16 bit short that could be posivive or negative)
        // into an integer without allowing java to perform sign extension. This is required
        // as the value will be bit-wise ORed onto a larger structure during the
        // generation of individual UUIDs. If the number was negative then the sign extension
        // would cause the two most significant bytes to be FF and this would damage the
        // larger structure (these bytes MUST be 00)
        ipid = (spid & 0x0000FFFF);

        if (tc.isEntryEnabled())
            Tr.exit(tc, "getPID", Integer.valueOf(ipid));

        return ipid;
    }
115056
def check_tag_data(data):
    ""
    if len(data) < 10:
        raise ValueError("Tag too short")
    if data[0:3] != b"ID3":
        raise ValueError("Missing ID3 identifier")
    if data[3] >= 5 or data[4] != 0:
        raise ValueError("Unknown ID3 version")
    length = stagger.conversion.Syncsafe.decode(data[6:10]) + 10
    if len(data) != length:
        raise ValueError("Tag size mismatch")
31361
public static int cudnnGetRNNDataDescriptor(
        cudnnRNNDataDescriptor RNNDataDesc, 
        int[] dataType, 
        int[] layout, 
        int[] maxSeqLength, 
        int[] batchSize, 
        int[] vectorSize, 
        int arrayLengthRequested, 
        int[] seqLengthArray, 
        Pointer paddingFill)
    {
        return checkResult(cudnnGetRNNDataDescriptorNative(RNNDataDesc, dataType, layout, maxSeqLength, batchSize, vectorSize, arrayLengthRequested, seqLengthArray, paddingFill));
    }
995446
public final boolean isDatatype( DdlTokenStream tokens ) throws ParsingException {
        // Loop through the registered statement start string arrays and look for exact matches.

        for (String[] stmts : basicCharStringTypes) {
            if (tokens.matches(stmts)) return true;
        }

        for (String[] stmts : basicNationalCharStringTypes) {
            if (tokens.matches(stmts)) return true;
        }

        for (String[] stmts : basicBitStringTypes) {
            if (tokens.matches(stmts)) return true;
        }

        for (String[] stmts : basicExactNumericTypes) {
            if (tokens.matches(stmts)) return true;
        }

        for (String[] stmts : basicApproxNumericStringTypes) {
            if (tokens.matches(stmts)) return true;
        }

        for (String[] stmts : basicDateTimeTypes) {
            if (tokens.matches(stmts)) return true;
        }

        for (String[] stmts : basicMiscTypes) {
            if (tokens.matches(stmts)) return true;
        }

        // If no type is found, assume it's a custom type
        return isCustomDataType(tokens);
    }
202146
private void loadID3v2(InputStream in)
	{		
		int size = -1;
		try
		{
			// Read ID3v2 header (10 bytes).
			in.mark(10);			
			size = readID3v2Header(in);
			header_pos = size;			
		}
		catch (IOException e)
		{}
		finally
		{
			try
			{
				// Unread ID3v2 header (10 bytes).
				in.reset();
			}
			catch (IOException e)
			{}
		}
		// Load ID3v2 tags.
		try
		{
			if (size > 0)
			{
				rawid3v2 = new byte[size];
				in.read(rawid3v2,0,rawid3v2.length);
			}			
		}
		catch (IOException e)
		{}
	}
804328
private int parseLength() throws IOException {
        int curLen = 0;
        if (dataPos == dataSize)
            return curLen;
        int lenByte = data[dataPos++] & 0xff;
        if (isIndefinite(lenByte)) {
            ndefsList.add(new Integer(dataPos));
            unresolved++;
            return curLen;
        }
        if (isLongForm(lenByte)) {
            lenByte &= LEN_MASK;
            if (lenByte > 4) {
                throw new IOException("Too much data");
            }
            if ((dataSize - dataPos) < (lenByte + 1)) {
                throw new IOException("Too little data");
            }
            for (int i = 0; i < lenByte; i++) {
                curLen = (curLen << 8) + (data[dataPos++] & 0xff);
            }
            if (curLen < 0) {
                throw new IOException("Invalid length bytes");
            }
        } else {
           curLen = (lenByte & LEN_MASK);
        }
        return curLen;
    }
105153
private void xdr_int(int i) {
    buffer[offset++] = (byte)((i >> 24) & 0xff);
    buffer[offset++] = (byte)((i >> 16) & 0xff);
    buffer[offset++] = (byte)((i >> 8) & 0xff);
    buffer[offset++] = (byte)(i & 0xff);
  }
1132413
private static int readCode(boolean[] rawbits, int startIndex, int length) {
    int res = 0;
    for (int i = startIndex; i < startIndex + length; i++) {
      res <<= 1;
      if (rawbits[i]) {
        res |= 0x01;
      }
    }
    return res;
  }
419
public int readRawLittleEndian32() throws IOException
    {
        final byte[] buffer = this.buffer;
        int offset = this.offset;

        final byte b1 = buffer[offset++];
        final byte b2 = buffer[offset++];
        final byte b3 = buffer[offset++];
        final byte b4 = buffer[offset++];

        this.offset = offset;

        return (((int) b1 & 0xff)) |
                (((int) b2 & 0xff) << 8) |
                (((int) b3 & 0xff) << 16) |
                (((int) b4 & 0xff) << 24);
    }