整数到数组的说明 [英] Explanation on Integer to Array

查看:82
本文介绍了整数到数组的说明的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道您正在阅读此书,如果没有答案,我将不胜感激,因为我觉得自己很想找出答案.

I know that you are reading this, and I would appreciate a comment if do not have an answer because I feel that I am alone in trying to figure this out.

我已经仔细阅读了本文档.它提到了一个称为TimestampScale的元素.我已经下载了大约三十个WebM示例文件,并且看到 HEX { 0x2AD7B1 2A D7 B1 ['2A','D7','B1'] }或非十六进制整数 { 42 215 177 [42,215,177] }始终相同: HEX { 0x830F4240 83 0F 42 40 ['83','0F','42','40'] }或非十六进制整数 { 131 15 66 64 [131,15,66,64] }.如Matroska元素规范中所述,所有值均应为默认值 1000000 .所以问题是... 0x830F4240 如何最终变成 1000000 ?

I have thoroughly read this document. It mentions an element called TimestampScale. I have downloaded probably thirty WebM example files and seen that the values following the HEX { 0x2AD7B1 or 2A D7 B1 or ['2A','D7','B1'] } or NON-HEX integers { 42 215 177 or [42, 215, 177] } are always the same: HEX { 0x830F4240 or 83 0F 42 40 or ['83', '0F', '42', '40'] } or NON-HEX integers { 131 15 66 64 or [131,15,66,64] }. The values all SHOULD be the default of 1000000 as stated in the Matroska Element Specification. So the question is... How does 0x830F4240 end up as 1000000?

上面的情况对于您来说太草率或您想要更多的解释:

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: 2A D7 B1 83 0F 42 40
    Integers: 42 215 177 131 15 66 64

目标:

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

The Goal:

The goal is to figure out how to convert the values to make 1000000, that way I can use this conversion on other elements in the Matroska Element Specification (like duration conversion).

推荐答案

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

The WebM container format is a subset of the Matroska container format.

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

Matroska is based on EBML (Extensible Binary Meta Language).

EBML文档由元素组成.

An EBML Document is made of Elements.

元素由元素ID,元素数据大小和元素数据组成.

An Element is made of an Element ID, an Element Data Size, and Element Data.

元素数据大小是可变大小整数.(元素ID也是可变大小整数.)

An Element Data Size is a Variable-Size Integer. (An Element ID is also a Variable-Size Integer.)

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

A Variable-Size Integer uses the kind of bit patterns shown below, where the leading bits indicate how many bytes are used and the x bits store the actual value.

  • 1个字节: 1xxxxxxx
  • 2字节: 01xxxxxx xxxxxxxx
  • 3字节: 001xxxxx xxxxxxxx xxxxxxxx
  • 4个字节: 0001xxxx xxxxxxxx xxxxxxxx xxxxxxxx

以此类推

您提到的TimestampScale元素由

The TimestampScale Element you mentioned is made of

  • 元素ID 2A D7 B1
  • 元素数据大小 83 (后跟一个1字节的可变大小整数,指示元素数据的3个字节)
  • 元素数据 0F 42 40 (十进制1000000的大端编码)
  • Element ID 2A D7 B1
  • Element Data Size 83 (a 1-byte Variable-Size Integer indicating 3 bytes of Element Data follow)
  • Element Data 0F 42 40 (a big endian encoding of decimal 1000000)

这篇关于整数到数组的说明的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆