Jump to content

  • Log In with Google      Sign In   
  • Create Account

bit stream to structure


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
No replies to this topic

#1 fanaticlatic   Members   -  Reputation: 473

Like
0Likes
Like

Posted 25 October 2012 - 09:33 AM

Hi all,

I am wondering what the best practice is for placing a series of bits and bytes read in from a file/external source into a packed structure.

For example the program header from an mpeg stream:

00 00 01 BA 7F FF FF 8A D4 01 86 66 CF F8

Should fill these variables in my packed structure:
uint32 sync_bytes;
unsigned mask1 : 2;
unsigned system_clock_ref1 : 3;
unsigned mask2 : 1;
unsigned system_clock_ref2 : 15;
unsigned mask3 : 1;
unsigned system_clock_ref3 : 15;
unsigned mask4 : 1;
unsigned system_ext : 9;
unsigned mask5 : 1;
unsigned mux_rate : 22;
unsigned mask6 : 2;
unsigned reserved : 5;
unsigned stuffing_length : 3;

The masks should be like the purple values shown here: http://dvd.sourcefor...fo/packhdr.html

I think I am going wrong with the endianness of the system.

I have also thought about serialisation of the data and literally stepping through each bit, this seems overly cautious and slow.

I'd be happy to hear any thoughts on this.

Thanks in advance.

hinchy
"I have more fingers in more pies than a leper at a bakery!"

Sponsor:



Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS