使用DDL结构从ADTF 2读取数据

时间:2018-05-24 13:37:24

标签: parsing adtf

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

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

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

以下是64个数据字节:

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

2 个答案:

答案 0 :(得分:1)

我真的不明白你想要实现的目标......首先,你不需要在DDL中填充任何内容,bytepos遵循前面的元素大小。您必须知道,Description包含序列化(bytepos,byteorder)和反序列化结构(对齐),请查看https://support.digitalwerk.net/adtf/v2/adtf_sdk_html_docs/page_a_utils_indexedfileformat.html。要访问数据(读/写),只需通过DDL(https://support.digitalwerk.net/adtf/v2/adtf_sdk_html_docs/page_ddl_usage_howto.html)访问,也可以查看示例(https://support.digitalwerk.net/adtf/v2/adtf_sdk_html_docs/page_demo_media_desc_coder.html

答案 1 :(得分:1)

还有数据偏移量和块头,请查看https://support.digitalwerk.net/adtf_libraries/adtf-streaming-library/v2/DATFileFormatSpecification.pdf

但是,您不必关心索引文件格式以在ADTF Framework之外使用DDL。对于ADTF 2.x中的那个,提供了流媒体库 https://support.digitalwerk.net/adtf_libraries/adtf-streaming-library/v2/api/index.html

https://support.digitalwerk.net/adtf_libraries/adtf-streaming-library/v2/StreamingLibrary.pdf

在ADTF 3.x中的ADTF文件库(它来自开源,也可以处理来自2.x的文件) https://support.digitalwerk.net/adtf_libraries/adtf-file-library/html/index.html

两个Lib都支持读取和写入(ADTF)DAT文件,所以我猜你确实需要什么,不需要重新发明。

请查看Media Descritpion示例: https://support.digitalwerk.net/adtf_libraries/adtf-streaming-library/v2/api/page_mediadescription.html

还有读者本身: https://support.digitalwerk.net/adtf_libraries/adtf-streaming-library/v2/api/classadtfstreaming_1_1_i_a_d_t_f_file_reader.html