从整数到数组的解释



请帮助

我知道你正在读这篇文章,如果我没有答案,我将感激你的评论,因为我觉得我是一个人在试图弄清楚这个问题。

这是如何工作的?

我已经通读了这份文件。它提到了一个名为TimestampScale的元素。我已经下载了大约30个WebM示例文件,并且看到HEX后面的值{0x2AD7B12AD7B1['2A','D7','B1']}或非十六进制整数{42215177[42, 215, 177]}总是相同的:HEX{0x830F4240830F4240['83', '0F', '42', '40']}或非十六进制整数{131156664[131,15,66,64]}。所有的值都应该是默认的1000000,如Matroska元素规范中所述。所以问题是…0x830F4240怎么变成了1000000?

上面的Incase对你来说太草率了,或者你想要更多的解释:

The TimestampScale identifier is equal to 0x2AD7B1. This is in Hexadecimal formatting.
The ways I format it in HEX are:
0x2AD7B1
2A D7 B1
['2A','D7','B1']
The ways I format it in Integers are:
42 215 177
[42, 215, 177]

Its preceding values are taken from a Uint8Array: | 131, 15, 66, 64 |
after the Hexadecimal values are taken. This is NOT in Hexadecimal formatting.
The reason why is because that is the raw data and I want to be
as open with you as possible.
The ways I format it in HEX are:
0x830F4240
83 0F 42 40
['83','0F','42','40']
The ways I format it in Integers are:
131 15 66 64
[131,15,66,64]
So question is: how does | 131, 15, 66, 64 | or 0x830F4240 equal 1000000?

如何在HEX和integer中显示所有值:

Hex: 2A D7 B1 83 0F 42 40
Integers: 42 215 177 131 15 66 64

目标:

目标是弄清楚如何将值转换为1000000,这样我就可以在Matroska元素规范中的其他元素上使用这种转换(如持续时间转换)。

WebM容器格式是Matroska容器格式的子集。

Matroska基于EBML(可扩展二进制元语言)。

一个EBML文档是由元素组成的。

元素由元素ID、元素数据大小和元素数据组成。

元素数据大小是一个可变大小的整数。(元素ID也是一个可变大小的整数)

可变大小整数使用如下所示的位模式,其中前导位表示使用了多少字节,x位存储实际值。

  • 1字节:1xxxxxxx
  • 2字节:01xxxxxx xxxxxxxx3字节:001xxxxx xxxxxxxx xxxxxxxx4字节:0001xxxx xxxxxxxx xxxxxxxx xxxxxxxx

等等

您提到的TimestampScale元素是由

组成的
  • 元素ID2A D7 B1
  • 元素数据大小83(一个1字节可变大小的整数,表示元素数据后面有3字节)
  • 元素数据0F 42 40(十进制1000000的大端编码)