Skip to content

Instantly share code, notes, and snippets.

@yohhoy
Last active December 12, 2023 14:27
Show Gist options
  • Save yohhoy/2abc28b611797e7b407ae98faa7430e7 to your computer and use it in GitHub Desktop.
Save yohhoy/2abc28b611797e7b407ae98faa7430e7 to your computer and use it in GitHub Desktop.
ISO Base Media File Format

AAC

ISO/IEC 14496-3, 1.6.2.1 AudioSpecificConfig

AudioSpecificConfig() {
	audioObjectType = GetAudioObjectType();
	samplingFrequencyIndex; // 4 bslbf
	if (samplingFrequencyIndex == 0xf) {
		samplingFrequency; // 24 uimsbf
	}
	channelConfiguration; // 4 bslbf
	sbrPresentFlag = -1;
	psPresentFlag = -1;
	if (audioObjectType == 5 || audioObjectType == 29) {
		// ...
	}
	else {
		extensionAudioObjectType = 0;
	}
	switch (audioObjectType) {
	case 1: case 2: case 3: case 4: //...
		GASpecificConfig();
		break:
	case ...:
		//...
	}
	if (extensionAudioObjectType != 5 && bits_to_decode() >= 16) {
		//...
	}
GetAudioObjectType() {
	audioObjectType; // 5 uimsbf
	if (audioObjectType == 31) {
		audioObjectType = 32 + audioObjectTypeExt; // 6 uimsbf
	}
	return audioObjectType;
}

ISO/IEC 14496-3, 1.5.1.1 Audio object type definition

ID Type
0 Null
1 AAC main
2 AAC LC
3 AAC SSR
4 AAC LTP
5 SSR
... ...

ISO/IEC 14496-3, 1.6.3.4 samplingFrequencyIndex

index value
0x0 96000
0x1 88200
0x2 64000
0x3 48000
0x4 44100
0x5 32000
0x6 24000
0x7 22050
0x8 16000
0x9 12000
0xa 11025
0xb 8000
0xc 7350
0xd reserved
0xe reserved
0xf escape value

H.264/AVC

ISO/IEC 14496-15, 5.3.3.1.2 Syntax

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;
	}
	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;
		}
	}
}

ITU-T H.264(ISO/IEC 14496-10), A.2 Profiles

idc Profile
66 Baseline
77 Main
88 Extended
100 High
110 High 10
122 High 4:2:2
144 (High 4:4:4; removed)
244 High 4:4:4 Predictive

ITU-T H.264(ISO/IEC 14496-10), A.3 Levels

Defined level_idc: 10, 91, 11, 12, 13, 20, 21, 22, 30, 31, 32, 40, 41, 42, 50, 51, 52

H.265/HEVC

ISO/IEC 14496-15, 8.3.3.1.2 Syntax

aligned(8) class HEVCDecoderConfigurationRecord {
	unsigned int(8) configurationVersion = 1;
	unsigned int(2) general_profile_space;
	unsigned int(1) general_tier_flag;
	unsigned int(5) general_profile_idc;
	unsigned int(32) general_profile_compatibility_flags;
	unsigned int(48) general_constraint_indicator_flags;
	unsigned int(8) general_level_idc;
	bit(4) reserved = ‘1111’b;
	unsigned int(12) min_spatial_segmentation_idc;
	bit(6) reserved = ‘111111’b;
	unsigned int(2) parallelismType;
	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) temporalIdNested;
	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;
		}
	}
}

ITU-T H.265(ISO/IEC 23008-2), A.3 Profiles

idc Profile
1 Main
2 Main 10
3 Main Still Picture

ITU-T H.265(ISO/IEC 23008-2), A.4 Tiers and levels

flag Tier
0 Main
1 High
idc Level
30 1
60 2
63 2.1
90 3
93 3.1
120 4
123 4.1
150 5
153 5.1
156 5.2
180 6
183 6.1
186 6.2

Footnotes

  1. level_idc==9 represents "Leve 1b" unless Baseline(Constrained Baseline), Main, or Extended profiles.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment