Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to get OBU data from packet? #7

Open
MarcinWad opened this issue Oct 17, 2023 · 1 comment
Open

How to get OBU data from packet? #7

MarcinWad opened this issue Oct 17, 2023 · 1 comment

Comments

@MarcinWad
Copy link

MarcinWad commented Oct 17, 2023

Hi,
I try to open ivf file and get raw obu data from packet. In documentation you write that parameter offset should get offet in buffer. But how to understand those values?

{"packet_number": 0, "packet_size": 4242}
{"obu_type": 2, "offset": 2, "obu_size": 0, "temporal_id": 0, "spatial_id": 0}
{"obu_type": 1, "offset": 2, "obu_size": 11, "temporal_id": 0, "spatial_id": 0}
{"obu_type": 6, "offset": 3, "obu_size": 4224, "temporal_id": 0, "spatial_id": 0}
{"packet_number": 1, "packet_size": 75}
{"obu_type": 2, "offset": 2, "obu_size": 0, "temporal_id": 0, "spatial_id": 0}
{"obu_type": 6, "offset": 2, "obu_size": 31, "temporal_id": 0, "spatial_id": 0}
{"obu_type": 6, "offset": 2, "obu_size": 38, "temporal_id": 0, "spatial_id": 0}

Packet 0 = 4224 + 11 != 4242
Why two OBUs has same offset?

@dwbuiten
Copy link
Owner

dwbuiten commented Oct 18, 2023

That looks like JSON output from the examples in tools/? obuparse is a C library, and intended to be used as such.

As per the doc (https://github.com/dwbuiten/obuparse/blob/master/obuparse.h#L542C40-L542C40), offset is the OBU's offset into the buffer you pass to obp_get_next_obu(), not the offset into whole packet. obu_size is the size excluding the OBU header.

Each call to obp_get_next_obu() will have a different buffer pointer, so the offset can be the same, as it points to the start of that OBU's data inside the buffer, after the OBU header. You can see that it changes here in the example file: https://github.com/dwbuiten/obuparse/blob/master/tools/obudump.c#L232.

In your example above, the first packet contains:

  • OBU of type 2, with size 0, offset of 2. (It's empty)
  • OBU of type 1, with size 11, offset of 2.
  • OBU of type 6, wiith size 4224, offset of 3.

2 + 0 + 2 + 11 + 3 + 4224 = 4242.

Example diagram of that packet:

-----------------------------------------------------------------------------------------------------------------------------------------
| Header 1 (2 bytes) | OBU Data 1 (0 bytes) | Header 2 (2 bytes) | OBU Data 2 (11 bytes) | Header 3 (3 bytes) | OBU Data 3 (4224 bytes) |
-----------------------------------------------------------------------------------------------------------------------------------------

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants