以下内容皆翻译自官方pdf,同时增加了自己的理解
这篇文章讲述的是STSD BOX下的SampleEntry的编码格式
8.16 Sample Description Box
8.16.1 Definition
BoxTypes: ‘stsd’
Container: Sample Table Box (‘stbl’) Mandatory: Yes
Quantity: Exactly one
8.16.2 Syntax(语法)
aligned(8) abstract class SampleEntry (unsigned int(32) format) extends Box(format){
const unsigned int(8)[6] reserved = 0; 首先6个字节的保留位 值都是0
unsigned int(16) data_reference_index; ///一个2个字节来描述的 数据索引
}
///如果是一个空的entry,则追加一个字节的空数据
class HintSampleEntry() extends SampleEntry (protocol) {
unsigned int(8) data [];
}
// Visual Sequences 视频entry
class VisualSampleEntry(codingname) extends SampleEntry (codingname){
unsigned int(16) pre_defined = 0; //2个字节的保留位
const unsigned int(16) reserved = 0; //2个字节的保留位
unsigned int(32)[3] pre_defined = 0; //3*4个字节的保留位
unsigned int(16) width; //2个字节的宽度
unsigned int(16) height; //2个字节的高度
template unsigned int(32) horizresolution = 0x00480000; // 72 dpi //纵向dpi,4字节
template unsigned int(32) vertresolution = 0x00480000; // 72 dpi //横向dpi 4字节
const unsigned int(32) reserved = 0; //4字节保留位
template unsigned int(16) frame_count = 1; //2字节的frame_count
string[32] compressorname; //32字节的compressorname
//这个地方特殊说明,这个地方需要32个8bit位置,0x00 *32
第一个8bit来表明字符长度,后面31个8bit来表明压缩的内容,
例子:
0x04, // strlen compressorname: 32 bytes String[32]
//32个8 bit 第一个8bit表示长度,剩下31个8bit表示内容
0x67, 0x31, 0x31, 0x31, // compressorname: 32 bytes 翻译过来是g111
0x00, 0x00, 0x00, 0x00,//
0x00, 0x00, 0x00, 0x00,//
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00,
template unsigned int(16) depth = 0x0018; //2字节的色彩深度
int(16) pre_defined = -1; //2字节的pre_defined
}
// Audio Sequences 音频entry
class AudioSampleEntry(codingname) extends SampleEntry (codingname){
const unsigned int(32)[2] reserved = 0; //2*4字节保留位
template unsigned int(16) channelcount = 2; //2字节的channelcount
template unsigned int(16) samplesize = 16; //2字节的 samplesize
unsigned int(16) pre_defined = 0; //2字节的pre_defined
const unsigned int(16) reserved = 0 ; //2字节保留位
template unsigned int(32) samplerate = {timescale of media}<<16; //4字节声音赫兹
}
8.16.3 Semantics(语义)
version is an integer that specifies the version of this box 版本是一个整数指定版本的这个盒子 entry_count is an integer that gives the number of entries in the following table entry_count是整数,让在下表条目的数量 SampleEntry is the appropriate sample entry. data_reference_index is an integer that contains the index of the data reference to use to retrieve data associated with samples that use this sample description. Data references are stored in Data Reference Boxes. The index ranges from 1 to the number of data references. data_reference_index是一个整数包含索引的数据引用使用使用这个示例的检索数据与样本描述。数据引用存储在数据参考。该指数范围从1到数据引用的数量。
ChannelCount is either 1 (mono) or 2 (stereo) 单声道 SampleSize is in bits, and takes the default value of 16 SampleRate is the sampling rate expressed as a 16.16 fixed-point number (hi.lo) resolution fields give the resolution of the image in pixels-per-inch, as a fixed 16.16 number frame_count indicates how many frames of compressed video are stored in each sample. The default is 1, for one frame per sample; it may be more than 1 for multiple frames per sample frame_count表明多少帧压缩视频存储在每个样本。默认是1,每样一帧;它可能超过1每个样本的多个帧数
Compressorname is a name, for informative purposes. It is formatted in a fixed 32-byte field, with the first byte set to the number of bytes to be displayed, followed by that number of bytes of displayable data, and then padding to complete 32 bytes total (including the size byte). The field may be set to 0.
Compressorname是一个名字,因为信息的目的。在固定32字节的字段是格式化的,第一个字节设置为显示的字节数,其次是可显示的数据的字节数,然后填充完成32字节总数(包括字节大小)。可能被设置为0。
depth takes one of the following values 0x0018 – images are in colour with no alpha width and height are the maximum visual width and height of the stream described by this sample description, in pixels