I need some help to understand the avcC
atom structure of a particular mp4 sample I am trying to analyze.
Hex dump:
00 00 00 38 61 76 63 43 01 64 00 1F FF E1 00 1C 67 64 00 1F AC D9 80 50 05 BB 01 6A 02 02 02 80 00 00 03 00 80 00 00 1E 07 8C 18 CD 01 00 05 68 E9 7B 2C 8B FD F8 F8 00 00 00 00 13 63 6F 6C 72
This is what I understand from the above:
00 00 00 38
Size of avcC atom
61 76 63 43
avcC signature
01
configurationVersion
64
AVCProfileIndication
00
profile_compatibility
1F
AVCLevelIndication
FF
111111b + lengthSizeMinusOne
E1
111b + numOfSequenceParameterSets (in this case, 1 SPS)
00 1C
SPS length (in this case, 28 bytes)
67 64 00 1F AC D9 80 50 05 BB 01 6A 02 02 02 80 00 00 03 00 80 00 00 1E 07 8C 18 CD
SPS data (28 bytes as per above)
01
numOfPictureParameterSets (in this case, 1 PPS)
00 05
PPS length
This is where the problem begins. Based on the PPS length given by the previous bytes, the next 5 bytes should be the PPS data: 68 E9 7B 2C 8B
However according to the avcC header, the total length of the atom is 56 bytes (0x38
), which means that the following 4 bytes should be included: FD F8 F8 00
But the problem is that the PPS length is given as 5 bytes (0x05
). So what exactly are these final 4 bytes?
Then follows the header of the colr
atom:
00 00 00 13
size of colr atom
63 6F 6C 72
colr signature
Which I have checked and is indeed 19 bytes in length (0x13
).
The problem is with the avcC atom and with that particular mp4 sample I am analyzing (I've checked other samples too and they didn't have this peculiarity).
You can find the sample here.
EDIT
mp4info
tool from the bento4 suite reports the following as the avcC atom's size: 8+48
And mp4dump
reports:
AVC SPS: [6764001facd9805005bb016a02020280000003008000001e078c18cd]
AVC PPS: [68e97b2c8b]
So it correctly reports the total size of the atom as 56 bytes (0x38) based on what is found in the avcC header, but the SPS/PPS data are analyzed the same way as above. I still don't understand what the final 4 bytes are or where do they belong.
I dind't get any answer but fortunately a bit more careful reading of ISO 14496-15
solved this issue:
if( profile_idc == 100 || profile_idc == 110 ||
profile_idc == 122 || profile_idc == 144 )
{
bit(6) reserved = ‘111111’b;
unsigned int(2) chroma_format;
bit(5) reserved = ‘11111’b;
unsigned int(3) bit_depth_luma_minus8;
bit(5) reserved = ‘11111’b;
unsigned int(3) bit_depth_chroma_minus8;
unsigned int(8) numOfSequenceParameterSetExt;
for (i=0; i< numOfSequenceParameterSetExt; i++) {
unsigned int(16) sequenceParameterSetExtLength;
bit(8*sequenceParameterSetExtLength) sequenceParameterSetExtNALUnit;
}
}
Apparently a sequence of 4+ bytes may exist at the end of an avcC atom depending on the profile used. In my sample above the profile is 100 (0x64
), hence it meets the criteria. So the last 4 bytes are:
FD
= bits 111111
are reserved, remaining 01
means chroma subsampling 4:2:0
F8
= bits 11111
are reserved, remaining 000
means luma bit depth is 8
F8
= bits 11111
are reserved, remaining 000
means chroma bit depth is 8
00
= zero SPS extensions