Source:
<code>public static HevcConfig parse(ParsableByteArray data) throws ParserException { try { data.skipBytes(21); int lengthSizeMinusOne = data.readUnsignedByte() & 0x03; int numberOfArrays = data.readUnsignedByte(); int csdLength = 0; int csdStartPosition = data.getPosition(); for (int i = 0; i < numberOfArrays; i++) { data.skipBytes(1); int numberOfNalUnits = data.readUnsignedShort(); for (int j = 0; j < numberOfNalUnits; j++) { int nalUnitLength = data.readUnsignedShort(); csdLength += 4 + nalUnitLength; data.skipBytes(nalUnitLength); } } @Nullable String codecs = null; data.setPosition(csdStartPosition); byte[] buffer = new byte[csdLength]; int bufferPosition = 0; for (int i = 0; i < numberOfArrays; i++) { final int nalUnitType = (data.getData()[data.getPosition()] & 0x7F); data.skipBytes(1); int numberOfNalUnits = data.readUnsignedShort(); for (int j = 0; j < numberOfNalUnits; j++) { int nalUnitLength = data.readUnsignedShort(); System.arraycopy(NalUnitUtil.NAL_START_CODE, 0, buffer, bufferPosition, NalUnitUtil.NAL_START_CODE.length); bufferPosition += NalUnitUtil.NAL_START_CODE.length; System.arraycopy( data.getData(), data.getPosition(), buffer, bufferPosition, nalUnitLength); bufferPosition += nalUnitLength; if (nalUnitType == SPS_NUT && j == 0) { codecs = buildCodecString(data, nalUnitLength); } data.skipBytes(nalUnitLength); } } @Nullable List<byte[]> initializationData = csdLength == 0 ? null : Collections.singletonList(buffer); return new HevcConfig(initializationData, lengthSizeMinusOne + 1, codecs); } catch (ArrayIndexOutOfBoundsException e) { throw new ParserException("Error parsing HEVC config", e); } <START> } <END></code><technical_language>@equeim I order of bits in resulting int is reversed compared needed build codecs string. Please confirm consistent understanding if missing something? I care of making change if needed merging this, please is correct. Thanks</technical_language>

Target:
public static HevcConfig parse(ParsableByteArray data) throws ParserException { try { data.skipBytes(1); final String codecs = buildCodecString(data); data.skipBytes(20); int lengthSizeMinusOne = data.readUnsignedByte() & 0x03; int numberOfArrays = data.readUnsignedByte(); int csdLength = 0; int csdStartPosition = data.getPosition(); for (int i = 0; i < numberOfArrays; i++) { data.skipBytes(1); int numberOfNalUnits = data.readUnsignedShort(); for (int j = 0; j < numberOfNalUnits; j++) { int nalUnitLength = data.readUnsignedShort(); csdLength += 4 + nalUnitLength; data.skipBytes(nalUnitLength); } } data.setPosition(csdStartPosition); byte[] buffer = new byte[csdLength]; int bufferPosition = 0; for (int i = 0; i < numberOfArrays; i++) { data.skipBytes(1); int numberOfNalUnits = data.readUnsignedShort(); for (int j = 0; j < numberOfNalUnits; j++) { int nalUnitLength = data.readUnsignedShort(); System.arraycopy(NalUnitUtil.NAL_START_CODE, 0, buffer, bufferPosition, NalUnitUtil.NAL_START_CODE.length); bufferPosition += NalUnitUtil.NAL_START_CODE.length; System.arraycopy( data.getData(), data.getPosition(), buffer, bufferPosition, nalUnitLength); bufferPosition += nalUnitLength; data.skipBytes(nalUnitLength); } } @Nullable List<byte[]> initializationData = csdLength == 0 ? null : Collections.singletonList(buffer); return new HevcConfig(initializationData, lengthSizeMinusOne + 1, codecs); } catch (ArrayIndexOutOfBoundsException e) { throw new ParserException("Error parsing HEVC config", e); } }