mp4: fill reserved fields properly (#307)

This commit is contained in:
Alessandro Ros
2026-02-17 16:42:07 +01:00
committed by GitHub
parent 809e67e842
commit fa0cf2e395
3 changed files with 19 additions and 12 deletions
+7
View File
@@ -710,10 +710,15 @@ func WriteCodecBoxes(w *Writer, codec codecs.Codec, trackID int, info *CodecInfo
codec.SPS[10], codec.SPS[11], codec.SPS[12],
},
GeneralLevelIdc: info.H265SPS.ProfileTierLevel.GeneralLevelIdc,
Reserved1: 0b1111,
// MinSpatialSegmentationIdc
Reserved2: 0b111111,
// ParallelismType
Reserved3: 0b111111,
ChromaFormatIdc: uint8(info.H265SPS.ChromaFormatIdc),
Reserved4: 0b11111,
BitDepthLumaMinus8: uint8(info.H265SPS.BitDepthLumaMinus8),
Reserved5: 0b11111,
BitDepthChromaMinus8: uint8(info.H265SPS.BitDepthChromaMinus8),
// AvgFrameRate
// ConstantFrameRate
@@ -780,7 +785,9 @@ func WriteCodecBoxes(w *Writer, codec codecs.Codec, trackID int, info *CodecInfo
Profile: info.H264SPS.ProfileIdc,
ProfileCompatibility: codec.SPS[2],
Level: info.H264SPS.LevelIdc,
Reserved: 0b111111,
LengthSizeMinusOne: 3,
Reserved2: 0b111,
NumOfSequenceParameterSets: 1,
SequenceParameterSets: []amp4.AVCParameterSet{
{
+7 -7
View File
@@ -308,7 +308,7 @@ var casesInit = []struct {
0x18, 0xff, 0xff, 0x00, 0x00, 0x00, 0x5d, 0x68,
0x76, 0x63, 0x43, 0x01, 0x01, 0x60, 0x00, 0x00,
0x00, 0x03, 0x00, 0x90, 0x00, 0x00, 0x03, 0x78,
0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
0xf0, 0x00, 0xfc, 0xfd, 0xf8, 0xf8, 0x00, 0x00,
0x13, 0x03, 0x20, 0x00, 0x01, 0x00, 0x04, 0x01,
0x02, 0x03, 0x04, 0x21, 0x00, 0x01, 0x00, 0x2a,
0x42, 0x01, 0x01, 0x01, 0x60, 0x00, 0x00, 0x03,
@@ -435,8 +435,8 @@ var casesInit = []struct {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x18, 0xff, 0xff, 0x00, 0x00, 0x00, 0x2d, 0x61,
0x76, 0x63, 0x43, 0x01, 0x42, 0xc0, 0x28, 0x03,
0x01, 0x00, 0x19, 0x67, 0x42, 0xc0, 0x28, 0xd9,
0x76, 0x63, 0x43, 0x01, 0x42, 0xc0, 0x28, 0xff,
0xe1, 0x00, 0x19, 0x67, 0x42, 0xc0, 0x28, 0xd9,
0x00, 0x78, 0x02, 0x27, 0xe5, 0x84, 0x00, 0x00,
0x03, 0x00, 0x04, 0x00, 0x00, 0x03, 0x00, 0xf0,
0x3c, 0x60, 0xc9, 0x20, 0x01, 0x00, 0x01, 0x08,
@@ -1561,8 +1561,8 @@ var casesInit = []struct {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x18, 0xff, 0xff, 0x00, 0x00, 0x00, 0x2d, 0x61,
0x76, 0x63, 0x43, 0x01, 0x42, 0xc0, 0x28, 0x03,
0x01, 0x00, 0x19, 0x67, 0x42, 0xc0, 0x28, 0xd9,
0x76, 0x63, 0x43, 0x01, 0x42, 0xc0, 0x28, 0xff,
0xe1, 0x00, 0x19, 0x67, 0x42, 0xc0, 0x28, 0xd9,
0x00, 0x78, 0x02, 0x27, 0xe5, 0x84, 0x00, 0x00,
0x03, 0x00, 0x04, 0x00, 0x00, 0x03, 0x00, 0xf0,
0x3c, 0x60, 0xc9, 0x20, 0x01, 0x00, 0x01, 0x08,
@@ -1731,8 +1731,8 @@ var casesInit = []struct {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x18, 0xff, 0xff, 0x00, 0x00, 0x00, 0x30, 0x61,
0x76, 0x63, 0x43, 0x01, 0x42, 0xc0, 0x1f, 0x03,
0x01, 0x00, 0x19, 0x67, 0x42, 0xc0, 0x1f, 0xd9,
0x76, 0x63, 0x43, 0x01, 0x42, 0xc0, 0x1f, 0xff,
0xe1, 0x00, 0x19, 0x67, 0x42, 0xc0, 0x1f, 0xd9,
0x00, 0xf0, 0x11, 0x7e, 0xf0, 0x11, 0x00, 0x00,
0x03, 0x00, 0x01, 0x00, 0x00, 0x03, 0x00, 0x30,
0x8f, 0x18, 0x32, 0x48, 0x01, 0x00, 0x04, 0x68,
+5 -5
View File
@@ -327,7 +327,7 @@ var casesPresentation = []struct {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x18, 0xff, 0xff, 0x00,
0x00, 0x00, 0x30, 0x61, 0x76, 0x63, 0x43, 0x01,
0x42, 0xc0, 0x28, 0x03, 0x01, 0x00, 0x19, 0x67,
0x42, 0xc0, 0x28, 0xff, 0xe1, 0x00, 0x19, 0x67,
0x42, 0xc0, 0x28, 0xd9, 0x00, 0x78, 0x02, 0x27,
0xe5, 0x84, 0x00, 0x00, 0x03, 0x00, 0x04, 0x00,
0x00, 0x03, 0x00, 0xf0, 0x3c, 0x60, 0xc9, 0x20,
@@ -406,8 +406,8 @@ var casesPresentation = []struct {
0x00, 0x00, 0x00, 0x18, 0xff, 0xff, 0x00, 0x00,
0x00, 0x5d, 0x68, 0x76, 0x63, 0x43, 0x01, 0x01,
0x60, 0x00, 0x00, 0x00, 0x03, 0x00, 0x90, 0x00,
0x00, 0x03, 0x78, 0x00, 0x00, 0x00, 0x01, 0x00,
0x00, 0x00, 0x00, 0x13, 0x03, 0x20, 0x00, 0x01,
0x00, 0x03, 0x78, 0xf0, 0x00, 0xfc, 0xfd, 0xf8,
0xf8, 0x00, 0x00, 0x13, 0x03, 0x20, 0x00, 0x01,
0x00, 0x04, 0x01, 0x02, 0x03, 0x04, 0x21, 0x00,
0x01, 0x00, 0x2a, 0x42, 0x01, 0x01, 0x01, 0x60,
0x00, 0x00, 0x03, 0x00, 0x90, 0x00, 0x00, 0x03,
@@ -1210,8 +1210,8 @@ var casesPresentation = []struct {
0x00, 0x00, 0x00, 0x00, 0x18, 0xff, 0xff, 0x00,
0x00, 0x00, 0x5d, 0x68, 0x76, 0x63, 0x43, 0x01,
0x01, 0x60, 0x00, 0x00, 0x00, 0x03, 0x00, 0x90,
0x00, 0x00, 0x03, 0x78, 0x00, 0x00, 0x00, 0x01,
0x00, 0x00, 0x00, 0x00, 0x13, 0x03, 0x20, 0x00,
0x00, 0x00, 0x03, 0x78, 0xf0, 0x00, 0xfc, 0xfd,
0xf8, 0xf8, 0x00, 0x00, 0x13, 0x03, 0x20, 0x00,
0x01, 0x00, 0x04, 0x01, 0x02, 0x03, 0x04, 0x21,
0x00, 0x01, 0x00, 0x2a, 0x42, 0x01, 0x01, 0x01,
0x60, 0x00, 0x00, 0x03, 0x00, 0x90, 0x00, 0x00,