瀏覽代碼

添加avcC盒子编码器

tags/v1.1.0
SmallChi(Koike) 4 年之前
父節點
當前提交
6ddfa37fd2
共有 1 個檔案被更改,包括 37 行新增23 行删除
  1. +37
    -23
      src/JT1078.FMp4/Boxs/AVCConfigurationBox.cs

+ 37
- 23
src/JT1078.FMp4/Boxs/AVCConfigurationBox.cs 查看文件

@@ -17,27 +17,33 @@ namespace JT1078.FMp4
public AVCConfigurationBox() : base("avcC")
{
}

#region
//public const int LengthSizeMinusOnePaddingBits = 63;
//public const int NumberOfSequenceParameterSetsPaddingBits = 7;
//public const int ChromaFormatPaddingBits = 31;
//public const int BitDepthLumaMinus8PaddingBits = 31;
//public const int BitDepthChromaMinus8PaddingBits = 31;
#endregion
//AVCDecoderConfigurationRecord 结构的定义:
//aligned(8) class AVCDecoderConfigurationRecord
//{
//unsigned int (8) configurationVersion = 1;
//unsigned int (8) AVCProfileIndication;
//unsigned int (8) profile_compatibility;
//unsigned int (8) AVCLevelIndication;
//bit(6) reserved = ‘111111’b;
//unsigned int (2) lengthSizeMinusOne;
//bit(3) reserved = ‘111’b;
//unsigned int (5) numOfSequenceParameterSets;
//for (i=0; i<numOfSequenceParameterSets; i++) {
//unsigned int (16) sequenceParameterSetLength ;
//bit(8*sequenceParameterSetLength) sequenceParameterSetNALUnit;
//}
//unsigned int (8) numOfPictureParameterSets;
//for (i=0; i<numOfPictureParameterSets; i++) {
//unsigned int (16) pictureParameterSetLength;
//bit(8*pictureParameterSetLength) pictureParameterSetNALUnit;
//}
//unsigned int (8) configurationVersion = 1;
//unsigned int (8) AVCProfileIndication;
//unsigned int (8) profile_compatibility;
//unsigned int (8) AVCLevelIndication;
//bit(6) reserved = ‘111111’b;
//unsigned int (2) lengthSizeMinusOne;
//bit(3) reserved = ‘111’b;
//unsigned int (5) numOfSequenceParameterSets;
//for (i=0; i<numOfSequenceParameterSets; i++) {
//unsigned int (16) sequenceParameterSetLength ;
//bit(8*sequenceParameterSetLength) sequenceParameterSetNALUnit;
//}
//unsigned int (8) numOfPictureParameterSets;
//for (i=0; i<numOfPictureParameterSets; i++) {
//unsigned int (16) pictureParameterSetLength;
//bit(8*pictureParameterSetLength) pictureParameterSetNALUnit;
//}
//}
public byte ConfigurationVersion { get; set; } = 1;
public byte AVCProfileIndication { get; set; }
@@ -45,18 +51,26 @@ namespace JT1078.FMp4
public byte AVCLevelIndication { get; set; }
public int LengthSizeMinusOne { get; set; }
public int NumOfSequenceParameterSets { get; set; }
public List<(ushort SequenceParameterSetLength,byte[] SequenceParameterSetNALUnit)> SPS { get; set; }
//public List<(ushort SequenceParameterSetLength,byte[] SequenceParameterSetNALUnit)> SPS { get; set; }
public byte[] SPSBuffer { get; set; }
public byte NumOfPictureParameterSets { get; set; } = 1;
public List<(ushort PictureParameterSetLength,byte[] PictureParameterSetNALUnit)> PPS { get; set; }
//public List<(ushort PictureParameterSetLength,byte[] PictureParameterSetNALUnit)> PPS { get; set; }
public byte[] PPSBuffer { get; set; }

public void ToBuffer(ref FMp4MessagePackWriter writer)
{
Start(ref writer);
//todo:AVCConfigurationBox


writer.WriteByte(ConfigurationVersion);
writer.WriteByte(AVCProfileIndication);
writer.WriteByte(ProfileCompatibility);
writer.WriteByte(AVCLevelIndication);
writer.WriteByte((byte)(0xfc | LengthSizeMinusOne));
writer.WriteByte((byte)(0xE0 | NumOfSequenceParameterSets));
writer.WriteUInt16((ushort)SPSBuffer.Length);
writer.WriteArray(SPSBuffer);
writer.WriteByte(NumOfPictureParameterSets);
writer.WriteUInt16((ushort)PPSBuffer.Length);
writer.WriteArray(PPSBuffer);
End(ref writer);
}
}


Loading…
取消
儲存