Parsing 使用DDL结构从ADTF2读取数据

Parsing 使用DDL结构从ADTF2读取数据,parsing,adtf,Parsing,Adtf,我正在尝试读取示例性ADTF文件。当读取块头时,我看到块大小是96字节,减去头长度(32),实际数据剩下64字节 现在流的数据结构表明,我们只需要43个字节来表示数据。我不知道如何在那里使用填充物。实际的64字节数据似乎有一些填充-我不能仅仅读取数据并将其推入结构中。我不知道如何猜测额外的填充尺寸。所有提取的值应等于41(十进制) 我真的不明白你想要实现什么。。。首先,在DDL中不需要任何填充,bytepos遵循前面的元素大小。您必须知道,描述包含序列化(bytepos、byteorder)和反

我正在尝试读取示例性ADTF文件。当读取块头时,我看到块大小是96字节,减去头长度(32),实际数据剩下64字节

现在流的数据结构表明,我们只需要43个字节来表示数据。我不知道如何在那里使用填充物。实际的64字节数据似乎有一些填充-我不能仅仅读取数据并将其推入结构中。我不知道如何猜测额外的填充尺寸。所有提取的值应等于41(十进制)


我真的不明白你想要实现什么。。。首先,在DDL中不需要任何填充,bytepos遵循前面的元素大小。您必须知道,描述包含序列化(bytepos、byteorder)和反序列化结构(对齐),请查看。要访问数据(读/写),只需通过DDL()访问,还可以查看示例()

还有一个数据偏移量和块头,请查看

但是在ADTF框架之外使用DDL不必关心索引文件格式。在ADTF2.x中,提供了流媒体库

在ADTF3.x中,ADTF文件库(它是开源的,也可以处理2.x中的文件)

这两个库都支持读取和写入(ADTF)DAT文件,所以我猜您需要什么,不需要重新创建什么

请看媒体描述示例:

以及读者本身:

我想在ADTF框架之外编写一个解析器。我发现,如果要读取结构,必须跳过前17个字节。然后,其余部分与提供的DDL完全匹配。我猜最初的17个字节包含1+8+8字节的元数据。(我还没有弄清楚它是什么——除了第一个字节总是“3”)。无论如何,在提供的示例中,偏移量为17的字节是41,它与结构的第一个字节匹配:name=“ui8Val”type=“tUInt8”,并与结构中的以下所有数据对齐。
<stream description="streamid_2" name="NESTED_STRUCT" type="adtf.core.media_type">
    <struct bytepos="0" name="tNestedStruct" type="tNestedStruct"/>
</stream>

<struct alignment="1" name="tNestedStruct" version="1">
    <element alignment="1" arraysize="1" byteorder="LE" bytepos="0" name="sHeaderStruct" type="tHeaderStruct"/>
    <element alignment="1" arraysize="1" byteorder="LE" bytepos="12" name="sSimpleStruct" type="tSimpleStruct"/>
</struct>

<struct alignment="1" name="tHeaderStruct" version="1">
    <element alignment="1" arraysize="1" byteorder="LE" bytepos="0" name="ui32HeaderVal" type="tUInt32"/>
    <element alignment="1" arraysize="1" byteorder="LE" bytepos="4" name="f64HeaderVal" type="tFloat64"/>
</struct>

<struct alignment="1" name="tSimpleStruct" version="1">
    <element alignment="1" arraysize="1" byteorder="LE" bytepos="0" name="ui8Val" type="tUInt8"/>
    <element alignment="1" arraysize="1" byteorder="LE" bytepos="1" name="ui16Val" type="tUInt16"/>
    <element alignment="1" arraysize="1" byteorder="LE" bytepos="3" name="ui32Val" type="tUInt32"/>
    <element alignment="1" arraysize="1" byteorder="LE" bytepos="7" name="i32Val" type="tInt32"/>
    <element alignment="1" arraysize="1" byteorder="LE" bytepos="11" name="i64Val" type="tInt64"/>
    <element alignment="1" arraysize="1" byteorder="LE" bytepos="19" name="f64Val" type="tFloat64"/>
    <element alignment="1" arraysize="1" byteorder="LE" bytepos="27" name="f32Val" type="tFloat32"/>
</struct>
index = value (decimal)
0 = 3
1 = 43
2 = 0
3 = 0
4 = 0
5 = -57
6 = -120
7 = 31
8 = 0
9 = 0
10 = 0
11 = 0
12 = 0
13 = 0
14 = 0
15 = 0
16 = 0
17 = 41
18 = 0
19 = 0
20 = 0
21 = 0
22 = 0
23 = 0
24 = 0
25 = 0
26 = -128
27 = 68
28 = 64
29 = 41
30 = 41
31 = 0
32 = 41
33 = 0
34 = 0
35 = 0
36 = 41
37 = 0
38 = 0
39 = 0
40 = 41
41 = 0
42 = 0
43 = 0
44 = 0
45 = 0
46 = 0
47 = 0
48 = 0
49 = 0
50 = 0
51 = 0
52 = 0
53 = -128
54 = 68
55 = 64
56 = 0
57 = 0
58 = 36
59 = 66
60 = 0
61 = 0
62 = 0
63 = 0