2

I'm trying to read the exemplary ADTF file. When reading the chunk header I see that chunk size is 96bytes, subtracting the header length (32) it leaves us with 64bytes for the actual data.

Now the data structure for the stream says we need only 43 bytes to express the data. I'm not sure how to apply padding there. The actual 64 bytes of data seems to have some padding - I cannot just read the data and push it into structures. I'm not sure how to guess the extra padding sizes. All the extracted values should be equal to 41 (decimal).

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

Here are the 64 data bytes:

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
Piotr Reszke
  • 1,576
  • 9
  • 21

2 Answers2

1

I don't really understand what you want to achieve... First of all, you don't need any padding in DDL, the bytepos follows the previous element size. You have to know, that the Description contains the serialized (bytepos, byteorder) and deserialized structure (alignment), please have a look at https://support.digitalwerk.net/adtf/v2/adtf_sdk_html_docs/page_a_utils_indexedfileformat.html. To access the data (read/write), just access via DDL (https://support.digitalwerk.net/adtf/v2/adtf_sdk_html_docs/page_ddl_usage_howto.html), also have a look at the example (https://support.digitalwerk.net/adtf/v2/adtf_sdk_html_docs/page_demo_media_desc_coder.html)

C-3PFLO
  • 311
  • 2
  • 4
  • 1
    I want to write a parser outside of the ADTF framework. What I discovered is that first 17 bytes has to be skipped if you are reading a structure. Then the rest matches the provided DDL perfectly. I guess the initial 17 bytes contains something like 1 + 8 + 8 bytes of metadata. (I din't yet figured out what it is - except that first byte is always "3" ). Anyway in the provided example - the byte with offset 17 is 41 - and it's matching the first byte of the structure: name="ui8Val" type="tUInt8" and aligns with all the following data in the structure. – Piotr Reszke Jun 08 '18 at 05:15
1

There is also a data offset as well as chunk headers, please have a look at https://support.digitalwerk.net/adtf_libraries/adtf-streaming-library/v2/DATFileFormatSpecification.pdf

But you don't have to care about the indexed file format to use DDL outside ADTF Framework. For that in ADTF 2.x there is the Streaming Library provided 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

In ADTF 3.x the ADTF File Library (which comes Open Source and can also handle Files from 2.x) https://support.digitalwerk.net/adtf_libraries/adtf-file-library/html/index.html

Both Libs support Read and Write of (ADTF)DAT Files, so I guess exactly what you need and don't need to reinvent.

Please have a look at the Media Descritpion Example: https://support.digitalwerk.net/adtf_libraries/adtf-streaming-library/v2/api/page_mediadescription.html

And also the Reader itself: https://support.digitalwerk.net/adtf_libraries/adtf-streaming-library/v2/api/classadtfstreaming_1_1_i_a_d_t_f_file_reader.html

C-3PFLO
  • 311
  • 2
  • 4