com.google.android.exoplayer2.util.NalUnitUtil.SpsData Java Examples

The following examples show how to use com.google.android.exoplayer2.util.NalUnitUtil.SpsData. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: H264Reader.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
public void setAll(SpsData spsData, int nalRefIdc, int sliceType, int frameNum,
    int picParameterSetId, boolean fieldPicFlag, boolean bottomFieldFlagPresent,
    boolean bottomFieldFlag, boolean idrPicFlag, int idrPicId, int picOrderCntLsb,
    int deltaPicOrderCntBottom, int deltaPicOrderCnt0, int deltaPicOrderCnt1) {
  this.spsData = spsData;
  this.nalRefIdc = nalRefIdc;
  this.sliceType = sliceType;
  this.frameNum = frameNum;
  this.picParameterSetId = picParameterSetId;
  this.fieldPicFlag = fieldPicFlag;
  this.bottomFieldFlagPresent = bottomFieldFlagPresent;
  this.bottomFieldFlag = bottomFieldFlag;
  this.idrPicFlag = idrPicFlag;
  this.idrPicId = idrPicId;
  this.picOrderCntLsb = picOrderCntLsb;
  this.deltaPicOrderCntBottom = deltaPicOrderCntBottom;
  this.deltaPicOrderCnt0 = deltaPicOrderCnt0;
  this.deltaPicOrderCnt1 = deltaPicOrderCnt1;
  isComplete = true;
  hasSliceType = true;
}
 
Example #2
Source File: H264Reader.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
public void setAll(SpsData spsData, int nalRefIdc, int sliceType, int frameNum,
    int picParameterSetId, boolean fieldPicFlag, boolean bottomFieldFlagPresent,
    boolean bottomFieldFlag, boolean idrPicFlag, int idrPicId, int picOrderCntLsb,
    int deltaPicOrderCntBottom, int deltaPicOrderCnt0, int deltaPicOrderCnt1) {
  this.spsData = spsData;
  this.nalRefIdc = nalRefIdc;
  this.sliceType = sliceType;
  this.frameNum = frameNum;
  this.picParameterSetId = picParameterSetId;
  this.fieldPicFlag = fieldPicFlag;
  this.bottomFieldFlagPresent = bottomFieldFlagPresent;
  this.bottomFieldFlag = bottomFieldFlag;
  this.idrPicFlag = idrPicFlag;
  this.idrPicId = idrPicId;
  this.picOrderCntLsb = picOrderCntLsb;
  this.deltaPicOrderCntBottom = deltaPicOrderCntBottom;
  this.deltaPicOrderCnt0 = deltaPicOrderCnt0;
  this.deltaPicOrderCnt1 = deltaPicOrderCnt1;
  isComplete = true;
  hasSliceType = true;
}
 
Example #3
Source File: H264Reader.java    From K-Sonic with MIT License 6 votes vote down vote up
public void setAll(SpsData spsData, int nalRefIdc, int sliceType, int frameNum,
    int picParameterSetId, boolean fieldPicFlag, boolean bottomFieldFlagPresent,
    boolean bottomFieldFlag, boolean idrPicFlag, int idrPicId, int picOrderCntLsb,
    int deltaPicOrderCntBottom, int deltaPicOrderCnt0, int deltaPicOrderCnt1) {
  this.spsData = spsData;
  this.nalRefIdc = nalRefIdc;
  this.sliceType = sliceType;
  this.frameNum = frameNum;
  this.picParameterSetId = picParameterSetId;
  this.fieldPicFlag = fieldPicFlag;
  this.bottomFieldFlagPresent = bottomFieldFlagPresent;
  this.bottomFieldFlag = bottomFieldFlag;
  this.idrPicFlag = idrPicFlag;
  this.idrPicId = idrPicId;
  this.picOrderCntLsb = picOrderCntLsb;
  this.deltaPicOrderCntBottom = deltaPicOrderCntBottom;
  this.deltaPicOrderCnt0 = deltaPicOrderCnt0;
  this.deltaPicOrderCnt1 = deltaPicOrderCnt1;
  isComplete = true;
  hasSliceType = true;
}
 
Example #4
Source File: H264Reader.java    From MediaSDK with Apache License 2.0 5 votes vote down vote up
public void setAll(
    SpsData spsData,
    int nalRefIdc,
    int sliceType,
    int frameNum,
    int picParameterSetId,
    boolean fieldPicFlag,
    boolean bottomFieldFlagPresent,
    boolean bottomFieldFlag,
    boolean idrPicFlag,
    int idrPicId,
    int picOrderCntLsb,
    int deltaPicOrderCntBottom,
    int deltaPicOrderCnt0,
    int deltaPicOrderCnt1) {
  this.spsData = spsData;
  this.nalRefIdc = nalRefIdc;
  this.sliceType = sliceType;
  this.frameNum = frameNum;
  this.picParameterSetId = picParameterSetId;
  this.fieldPicFlag = fieldPicFlag;
  this.bottomFieldFlagPresent = bottomFieldFlagPresent;
  this.bottomFieldFlag = bottomFieldFlag;
  this.idrPicFlag = idrPicFlag;
  this.idrPicId = idrPicId;
  this.picOrderCntLsb = picOrderCntLsb;
  this.deltaPicOrderCntBottom = deltaPicOrderCntBottom;
  this.deltaPicOrderCnt0 = deltaPicOrderCnt0;
  this.deltaPicOrderCnt1 = deltaPicOrderCnt1;
  isComplete = true;
  hasSliceType = true;
}
 
Example #5
Source File: AvcConfig.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Parses AVC configuration data.
 *
 * @param data A {@link ParsableByteArray}, whose position is set to the start of the AVC
 *     configuration data to parse.
 * @return A parsed representation of the HEVC configuration data.
 * @throws ParserException If an error occurred parsing the data.
 */
public static AvcConfig parse(ParsableByteArray data) throws ParserException {
  try {
    data.skipBytes(4); // Skip to the AVCDecoderConfigurationRecord (defined in 14496-15)
    int nalUnitLengthFieldLength = (data.readUnsignedByte() & 0x3) + 1;
    if (nalUnitLengthFieldLength == 3) {
      throw new IllegalStateException();
    }
    List<byte[]> initializationData = new ArrayList<>();
    int numSequenceParameterSets = data.readUnsignedByte() & 0x1F;
    for (int j = 0; j < numSequenceParameterSets; j++) {
      initializationData.add(buildNalUnitForChild(data));
    }
    int numPictureParameterSets = data.readUnsignedByte();
    for (int j = 0; j < numPictureParameterSets; j++) {
      initializationData.add(buildNalUnitForChild(data));
    }

    int width = Format.NO_VALUE;
    int height = Format.NO_VALUE;
    float pixelWidthAspectRatio = 1;
    if (numSequenceParameterSets > 0) {
      byte[] sps = initializationData.get(0);
      SpsData spsData = NalUnitUtil.parseSpsNalUnit(initializationData.get(0),
          nalUnitLengthFieldLength, sps.length);
      width = spsData.width;
      height = spsData.height;
      pixelWidthAspectRatio = spsData.pixelWidthAspectRatio;
    }
    return new AvcConfig(initializationData, nalUnitLengthFieldLength, width, height,
        pixelWidthAspectRatio);
  } catch (ArrayIndexOutOfBoundsException e) {
    throw new ParserException("Error parsing AVC config", e);
  }
}
 
Example #6
Source File: H264Reader.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
public void setAll(
    SpsData spsData,
    int nalRefIdc,
    int sliceType,
    int frameNum,
    int picParameterSetId,
    boolean fieldPicFlag,
    boolean bottomFieldFlagPresent,
    boolean bottomFieldFlag,
    boolean idrPicFlag,
    int idrPicId,
    int picOrderCntLsb,
    int deltaPicOrderCntBottom,
    int deltaPicOrderCnt0,
    int deltaPicOrderCnt1) {
  this.spsData = spsData;
  this.nalRefIdc = nalRefIdc;
  this.sliceType = sliceType;
  this.frameNum = frameNum;
  this.picParameterSetId = picParameterSetId;
  this.fieldPicFlag = fieldPicFlag;
  this.bottomFieldFlagPresent = bottomFieldFlagPresent;
  this.bottomFieldFlag = bottomFieldFlag;
  this.idrPicFlag = idrPicFlag;
  this.idrPicId = idrPicId;
  this.picOrderCntLsb = picOrderCntLsb;
  this.deltaPicOrderCntBottom = deltaPicOrderCntBottom;
  this.deltaPicOrderCnt0 = deltaPicOrderCnt0;
  this.deltaPicOrderCnt1 = deltaPicOrderCnt1;
  isComplete = true;
  hasSliceType = true;
}
 
Example #7
Source File: AvcConfig.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Parses AVC configuration data.
 *
 * @param data A {@link ParsableByteArray}, whose position is set to the start of the AVC
 *     configuration data to parse.
 * @return A parsed representation of the HEVC configuration data.
 * @throws ParserException If an error occurred parsing the data.
 */
public static AvcConfig parse(ParsableByteArray data) throws ParserException {
  try {
    data.skipBytes(4); // Skip to the AVCDecoderConfigurationRecord (defined in 14496-15)
    int nalUnitLengthFieldLength = (data.readUnsignedByte() & 0x3) + 1;
    if (nalUnitLengthFieldLength == 3) {
      throw new IllegalStateException();
    }
    List<byte[]> initializationData = new ArrayList<>();
    int numSequenceParameterSets = data.readUnsignedByte() & 0x1F;
    for (int j = 0; j < numSequenceParameterSets; j++) {
      initializationData.add(buildNalUnitForChild(data));
    }
    int numPictureParameterSets = data.readUnsignedByte();
    for (int j = 0; j < numPictureParameterSets; j++) {
      initializationData.add(buildNalUnitForChild(data));
    }

    int width = Format.NO_VALUE;
    int height = Format.NO_VALUE;
    float pixelWidthAspectRatio = 1;
    if (numSequenceParameterSets > 0) {
      byte[] sps = initializationData.get(0);
      SpsData spsData = NalUnitUtil.parseSpsNalUnit(initializationData.get(0),
          nalUnitLengthFieldLength, sps.length);
      width = spsData.width;
      height = spsData.height;
      pixelWidthAspectRatio = spsData.pixelWidthAspectRatio;
    }
    return new AvcConfig(initializationData, nalUnitLengthFieldLength, width, height,
        pixelWidthAspectRatio);
  } catch (ArrayIndexOutOfBoundsException e) {
    throw new ParserException("Error parsing AVC config", e);
  }
}
 
Example #8
Source File: H264Reader.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
public void setAll(
    SpsData spsData,
    int nalRefIdc,
    int sliceType,
    int frameNum,
    int picParameterSetId,
    boolean fieldPicFlag,
    boolean bottomFieldFlagPresent,
    boolean bottomFieldFlag,
    boolean idrPicFlag,
    int idrPicId,
    int picOrderCntLsb,
    int deltaPicOrderCntBottom,
    int deltaPicOrderCnt0,
    int deltaPicOrderCnt1) {
  this.spsData = spsData;
  this.nalRefIdc = nalRefIdc;
  this.sliceType = sliceType;
  this.frameNum = frameNum;
  this.picParameterSetId = picParameterSetId;
  this.fieldPicFlag = fieldPicFlag;
  this.bottomFieldFlagPresent = bottomFieldFlagPresent;
  this.bottomFieldFlag = bottomFieldFlag;
  this.idrPicFlag = idrPicFlag;
  this.idrPicId = idrPicId;
  this.picOrderCntLsb = picOrderCntLsb;
  this.deltaPicOrderCntBottom = deltaPicOrderCntBottom;
  this.deltaPicOrderCnt0 = deltaPicOrderCnt0;
  this.deltaPicOrderCnt1 = deltaPicOrderCnt1;
  isComplete = true;
  hasSliceType = true;
}
 
Example #9
Source File: AvcConfig.java    From K-Sonic with MIT License 5 votes vote down vote up
/**
 * Parses AVC configuration data.
 *
 * @param data A {@link ParsableByteArray}, whose position is set to the start of the AVC
 *     configuration data to parse.
 * @return A parsed representation of the HEVC configuration data.
 * @throws ParserException If an error occurred parsing the data.
 */
public static AvcConfig parse(ParsableByteArray data) throws ParserException {
  try {
    data.skipBytes(4); // Skip to the AVCDecoderConfigurationRecord (defined in 14496-15)
    int nalUnitLengthFieldLength = (data.readUnsignedByte() & 0x3) + 1;
    if (nalUnitLengthFieldLength == 3) {
      throw new IllegalStateException();
    }
    List<byte[]> initializationData = new ArrayList<>();
    int numSequenceParameterSets = data.readUnsignedByte() & 0x1F;
    for (int j = 0; j < numSequenceParameterSets; j++) {
      initializationData.add(buildNalUnitForChild(data));
    }
    int numPictureParameterSets = data.readUnsignedByte();
    for (int j = 0; j < numPictureParameterSets; j++) {
      initializationData.add(buildNalUnitForChild(data));
    }

    int width = Format.NO_VALUE;
    int height = Format.NO_VALUE;
    float pixelWidthAspectRatio = 1;
    if (numSequenceParameterSets > 0) {
      byte[] sps = initializationData.get(0);
      SpsData spsData = NalUnitUtil.parseSpsNalUnit(initializationData.get(0),
          nalUnitLengthFieldLength, sps.length);
      width = spsData.width;
      height = spsData.height;
      pixelWidthAspectRatio = spsData.pixelWidthAspectRatio;
    }
    return new AvcConfig(initializationData, nalUnitLengthFieldLength, width, height,
        pixelWidthAspectRatio);
  } catch (ArrayIndexOutOfBoundsException e) {
    throw new ParserException("Error parsing AVC config", e);
  }
}
 
Example #10
Source File: AvcConfig.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Parses AVC configuration data.
 *
 * @param data A {@link ParsableByteArray}, whose position is set to the start of the AVC
 *     configuration data to parse.
 * @return A parsed representation of the HEVC configuration data.
 * @throws ParserException If an error occurred parsing the data.
 */
public static AvcConfig parse(ParsableByteArray data) throws ParserException {
  try {
    data.skipBytes(4); // Skip to the AVCDecoderConfigurationRecord (defined in 14496-15)
    int nalUnitLengthFieldLength = (data.readUnsignedByte() & 0x3) + 1;
    if (nalUnitLengthFieldLength == 3) {
      throw new IllegalStateException();
    }
    List<byte[]> initializationData = new ArrayList<>();
    int numSequenceParameterSets = data.readUnsignedByte() & 0x1F;
    for (int j = 0; j < numSequenceParameterSets; j++) {
      initializationData.add(buildNalUnitForChild(data));
    }
    int numPictureParameterSets = data.readUnsignedByte();
    for (int j = 0; j < numPictureParameterSets; j++) {
      initializationData.add(buildNalUnitForChild(data));
    }

    int width = Format.NO_VALUE;
    int height = Format.NO_VALUE;
    float pixelWidthAspectRatio = 1;
    if (numSequenceParameterSets > 0) {
      byte[] sps = initializationData.get(0);
      SpsData spsData = NalUnitUtil.parseSpsNalUnit(initializationData.get(0),
          nalUnitLengthFieldLength, sps.length);
      width = spsData.width;
      height = spsData.height;
      pixelWidthAspectRatio = spsData.pixelWidthAspectRatio;
    }
    return new AvcConfig(initializationData, nalUnitLengthFieldLength, width, height,
        pixelWidthAspectRatio);
  } catch (ArrayIndexOutOfBoundsException e) {
    throw new ParserException("Error parsing AVC config", e);
  }
}
 
Example #11
Source File: AvcConfig.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Parses AVC configuration data.
 *
 * @param data A {@link ParsableByteArray}, whose position is set to the start of the AVC
 *     configuration data to parse.
 * @return A parsed representation of the HEVC configuration data.
 * @throws ParserException If an error occurred parsing the data.
 */
public static AvcConfig parse(ParsableByteArray data) throws ParserException {
  try {
    data.skipBytes(4); // Skip to the AVCDecoderConfigurationRecord (defined in 14496-15)
    int nalUnitLengthFieldLength = (data.readUnsignedByte() & 0x3) + 1;
    if (nalUnitLengthFieldLength == 3) {
      throw new IllegalStateException();
    }
    List<byte[]> initializationData = new ArrayList<>();
    int numSequenceParameterSets = data.readUnsignedByte() & 0x1F;
    for (int j = 0; j < numSequenceParameterSets; j++) {
      initializationData.add(buildNalUnitForChild(data));
    }
    int numPictureParameterSets = data.readUnsignedByte();
    for (int j = 0; j < numPictureParameterSets; j++) {
      initializationData.add(buildNalUnitForChild(data));
    }

    int width = Format.NO_VALUE;
    int height = Format.NO_VALUE;
    float pixelWidthAspectRatio = 1;
    if (numSequenceParameterSets > 0) {
      byte[] sps = initializationData.get(0);
      SpsData spsData = NalUnitUtil.parseSpsNalUnit(initializationData.get(0),
          nalUnitLengthFieldLength, sps.length);
      width = spsData.width;
      height = spsData.height;
      pixelWidthAspectRatio = spsData.pixelWidthAspectRatio;
    }
    return new AvcConfig(initializationData, nalUnitLengthFieldLength, width, height,
        pixelWidthAspectRatio);
  } catch (ArrayIndexOutOfBoundsException e) {
    throw new ParserException("Error parsing AVC config", e);
  }
}
 
Example #12
Source File: AvcConfig.java    From MediaSDK with Apache License 2.0 5 votes vote down vote up
/**
 * Parses AVC configuration data.
 *
 * @param data A {@link ParsableByteArray}, whose position is set to the start of the AVC
 *     configuration data to parse.
 * @return A parsed representation of the HEVC configuration data.
 * @throws ParserException If an error occurred parsing the data.
 */
public static AvcConfig parse(ParsableByteArray data) throws ParserException {
  try {
    data.skipBytes(4); // Skip to the AVCDecoderConfigurationRecord (defined in 14496-15)
    int nalUnitLengthFieldLength = (data.readUnsignedByte() & 0x3) + 1;
    if (nalUnitLengthFieldLength == 3) {
      throw new IllegalStateException();
    }
    List<byte[]> initializationData = new ArrayList<>();
    int numSequenceParameterSets = data.readUnsignedByte() & 0x1F;
    for (int j = 0; j < numSequenceParameterSets; j++) {
      initializationData.add(buildNalUnitForChild(data));
    }
    int numPictureParameterSets = data.readUnsignedByte();
    for (int j = 0; j < numPictureParameterSets; j++) {
      initializationData.add(buildNalUnitForChild(data));
    }

    int width = Format.NO_VALUE;
    int height = Format.NO_VALUE;
    float pixelWidthAspectRatio = 1;
    if (numSequenceParameterSets > 0) {
      byte[] sps = initializationData.get(0);
      SpsData spsData = NalUnitUtil.parseSpsNalUnit(initializationData.get(0),
          nalUnitLengthFieldLength, sps.length);
      width = spsData.width;
      height = spsData.height;
      pixelWidthAspectRatio = spsData.pixelWidthAspectRatio;
    }
    return new AvcConfig(initializationData, nalUnitLengthFieldLength, width, height,
        pixelWidthAspectRatio);
  } catch (ArrayIndexOutOfBoundsException e) {
    throw new ParserException("Error parsing AVC config", e);
  }
}
 
Example #13
Source File: H264Reader.java    From K-Sonic with MIT License 4 votes vote down vote up
public void putSps(NalUnitUtil.SpsData spsData) {
  sps.append(spsData.seqParameterSetId, spsData);
}
 
Example #14
Source File: H264Reader.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
public void putSps(NalUnitUtil.SpsData spsData) {
  sps.append(spsData.seqParameterSetId, spsData);
}
 
Example #15
Source File: H264Reader.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
public void putSps(NalUnitUtil.SpsData spsData) {
  sps.append(spsData.seqParameterSetId, spsData);
}
 
Example #16
Source File: H264Reader.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
public void putSps(NalUnitUtil.SpsData spsData) {
  sps.append(spsData.seqParameterSetId, spsData);
}
 
Example #17
Source File: H264Reader.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
public void putSps(NalUnitUtil.SpsData spsData) {
  sps.append(spsData.seqParameterSetId, spsData);
}
 
Example #18
Source File: H264Reader.java    From MediaSDK with Apache License 2.0 4 votes vote down vote up
public void putSps(SpsData spsData) {
  sps.append(spsData.seqParameterSetId, spsData);
}