Phil, in case you're interested, the ISOBMFF project decodes the HEVC Configuration record. The data is as follows (all big endian):
int8u: ConfigurationVersion
in8u: [GeneralProfileSpace:6-7, GeneralTierFlag:5, GeneralProfileIDC:0-4]
int8u[4]: GeneralProfileCompatibilityFlags
int8u[3]: GeneralConstraintIndicatorFlags
int8u: GeneralLevelIDC
int16u: MinSpatialSegmentationIDC:0-11
int8u: ParallelismType:0-1
int8u: ChromaFormat:0-1
int8u: BitDepthLumaMinus8:0-3
int8u: BitDepthChromaMinus8:0-3
int16u: AvgFrameRate
int8u: [ConstantFrameRate:6-7, NumTemporalLayers:3-5, TemporalIdNested:2, LengthSizeMinusOne:0-1]
int8u: NrArrays
Followed by the Arrays, each Array set up as follows:
int8u: ArrayCompleteness:7, NALUnitType:0-5
int16u: NrNALUnits
Followed by the NAL unit, each NAL Unit set up as follows:
int16u: NalUnitSize
int8u[NalUnitSize]: data
A Tag name followed by a colon and number (range) indicates the bits to use of the data.
Hope this helps,
Hayo
P.S. Don't ask me what these things mean as I don't know more than the names of the tags ;)
Hi Hayo,
Thanks. This looks potentially useful, but it seems as if this is stored in the video stream, which I try to avoid parsing if possible. I try to draw a line at parsing metadata, although the line is blurry at times.
- Phil
Hi Phil,
The HEVC configuration records are found in the Item Property Containers, e.g. in the -v3 output you do list the HEVC configuration record as follows:
| | 2) HEVCConfiguration = ..p.Z..........@......p....Zp$.."B...p....Z....X...U7....[snip]
| | - Tag 'hvcC' (104 bytes):
| | 0791: 01 03 70 00 00 00 b0 00 00 00 00 00 5a f0 00 fc [..p.........Z...]
| | 07a1: fd f8 f8 00 00 0b 03 a0 00 01 00 17 40 01 0c 01 [............@...]
| | 07b1: ff ff 03 70 00 00 03 00 b0 00 00 03 00 00 03 00 [...p............]
| | 07c1: 5a 70 24 a1 00 01 00 22 42 01 01 03 70 00 00 03 [Zp$...."B...p...]
| | 07d1: 00 b0 00 00 03 00 00 03 00 5a a0 04 02 00 80 58 [.........Z.....X]
| | [snip 24 bytes]
So I figure you already have the data at that point, making decoding relatively straightforward (I should think).
Ah. Sorry, I misunderstood. I'll look into this.
Thanks.
- Phil
I found this documentation:
aligned(8) class HEVCDecoderConfigurationRecord {
unsigned int(8) configurationVersion = 1;
unsigned int(3) profile_space;
unsigned int(5) profile_idc;
unsigned int(16) constraint_indicator_flags;
unsigned int(8) level_idc;
unsigned int(32) profile_compatibility_indications;
bit(6) reserved = '111111'b;
unsigned int(2) chromaFormat;
bit(5) reserved = '11111'b;
unsigned int(3) bitDepthLumaMinus8;
bit(5) reserved = '11111'b;
unsigned int(3) bitDepthChromaMinus8;
bit(16) avgFrameRate;
bit(2) constantFrameRate;
bit(3) numTemporalLayers;
bit(1) reserved = '1'b;
unsigned int(2) lengthSizeMinusOne;
unsigned int(8) numOfArrays;
for (j=0; j < numOfArrays; j++) {
bit(1) array_completeness;
unsigned int(1) reserved = 0;
unsigned int(6) NAL_unit_type;
unsigned int(16) numNalus;
for (i=0; i< numNalus; i++) {
unsigned int(16) nalUnitLength;
bit(8*nalUnitLength) nalUnit;
}
}
}
profile_space, profile_idc, constraint_indicator_flags, level_idc, profile_compatibility_indications contain the matching values for the same fields as defined in ISO/IEC 23008-2, for the stream to which this configuration record applies.
chromaFormat contains the chroma_format indicator as defined by the chroma_format_idc parameter in ISO/IEC 23008-2, for the stream to which this configuration record applies.
bitDepthLumaMinus8 contains the luma bit depth indicator as defined by the bit_depth_luma_minus8 parameter in ISO/IEC 23008-2, for the stream to which this configuration record applies.
bitDepthChromaMinus8 contains the chroma bit depth indicator as defined by the bit_depth_chroma_minus8 in ISO/IEC 23008-2, for the stream to which this configuration record applies.
avgFrameRate gives the average frame rate in units of frames/(256 seconds), for the stream to which this configuration record applies. Value 0 indicates an unspecified average frame rate.
constantFrameRate equal to 1 indicates that the stream to which this configuration record applies is of constant frame rate. Value 2 indicates that the representation of each temporal layer in the stream is of constant frame rate. Value 0 indicates that the stream may or may not be of constant frame rate.
numTemporalLayers greater than 1 indicates that the stream to which this configuration record applies is temporally scalable and the contained number of layers is equal to numTemporalLayers. Value 1 indicates that the stream is not temporally scalable. Value 0 indicates that it is unknown whether the stream is temporally scalable.
lengthSizeMinusOne plus 1 indicates the length in bytes of the NALUnitLength field in an HEVC video sample in the stream to which this configuration record applies. For example, a size of one byte is indicated with a value of 0. The value of this field shall be one of 0, 1, or 3 corresponding to a length encoded with 1, 2, or 4 bytes, respectively.
numArrays indicates the number of arrays of NAL units of the indicated type(s)
array_completeness when equal to 1 indicates that all NAL units of the given type are in the following array and none are in the stream; when equal to 0 indicates that additional NAL units of the indicated type may be in the stream; the default and permitted values are constrained by the sample entry code;
NAL_unit_type indicates the type of the NAL units in the following array (which must be all of that type); it takes a value as defined in ISO/IEC 23008-2; it is restricted to take one of the values indicating an SPS, PPS, APS, or SEI;
numNalus indicates the number of NAL units of the indicated type included in the configuration record for the stream to which this configuration record applies. The SEI array must only contain SEI messages of a 'declarative' nature, that is, those that provide information about the stream as a whole. An example of such an SEI is a user-data SEI.
nalUnitLength indicates the length in bytes of the NAL unit.
nalUnit contains an SPS, PPS, APS or declarative SEI NAL unit, as specified in ISO/IEC 23008-2.
Edit: Note that ISO/IEC 23008-2 costs $455. This is why I hate the ISO.
Nice!
QuoteEdit: Note that ISO/IEC 23008-2 costs $455. This is why I hate the ISO.
Yeah, I always found it strange you have to pay for something that I think is (or at least is intended as) a public standard. Sometimes you are lucky and there's a public document with the same content.
Note though that there are a number of discrepancies between the two. Not sure which one is right though...
Yes there are. Turns out that your definition matches the observed values with the exception that GeneralConstraintIndicatorFlags is 6 bytes, not 3. So I'll see about decoding this.
- Phil
Quote from: Phil Harvey on July 09, 2019, 08:37:03 AM
Turns out that your definition matches the observed values with the exception that GeneralConstraintIndicatorFlags is 6 bytes, not 3. So I'll see about decoding this.
Excellent; that was my finding too. The 6 vs 3 is my bad; a typo made when translating from the isobmff code to pseudo code that is more usable for exiftool.
Cheers,
Hayo