Results 1 to 4 of 4
  1. #1
    whytheheckme is offline Member
    Join Date
    Jul 2011
    Posts
    2
    Rep Power
    0

    Default Thoughts about how to bit shift large amounts of data

    Hello!

    I'm new to the forums , so go easy, eh?

    I'm trying to write an application that does the following:
    • Recieve UDP Packet
    • Sequence with remainder of previous packet
    • Find start bits, read following 100 bytes
    • Reformat these bytes from 12 bits -> 16 bits
    • Rebroadcast 512 byte segments


    Let me explain the situation further.

    Each UDP packet comes in with 512 bytes of data. Somewhere in the data are some start bits (a 24 bit word). I need to find this word, and then read the 100 bytes following this word. The data contained within these 100 bytes are in 12 bit format, so I need to recondition the data such that there are 4 leading 0s on each piece (making the values 2 bytes a piece). I then need to rebroadcast this data.

    Here are some of the issues:

    Data will always be split between packets; including the synch word sometimes. I need to be able to double buffer the packets, and remove data away as this happens (I'm not so worried about being able to do this part)

    What I AM having trouble with, is how to handle this data in a bit-wise fashion. While the synch word DOES fit nicely into 3 bytes, it's not guaranteed that it will fall spatially into 3 bytes (e.x. if the synch word was 000000000000000000000001, the word that i'm looking for COULD be 00 00 01, or (XXX0) 00 00 0 (001X), or (XX00) 00 00 0(01XX), etc. I would think that I need to start at the beginning, bitshift all of the data and read 24 bytes until I find my synch word.

    I also need some help thinking about how to recondition those 12 bit values into two bytes.

    I know its a lot! Thanks for any help that anyone can give

    Jacob

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,412
    Rep Power
    25

    Default

    how to recondition those 12 bit values into two bytes.
    0123.4567 89AB.0123 4567.89AB => 0000.0123 4567.89AB 0000.0123 4567.89AB
    Every 3 bytes go to 4 bytes

    How does that fit into 100 bytes? It's not a multiple of 3?
    Last edited by Norm; 07-07-2011 at 11:30 PM.

  3. #3
    whytheheckme is offline Member
    Join Date
    Jul 2011
    Posts
    2
    Rep Power
    0

    Default

    Quote Originally Posted by Norm View Post
    0123.4567 89AB.0123 4567.89AB => 0000.0123 4567.89AB 0000.0123 4567.89AB
    Every 3 bytes go to 4 bytes

    How does that fit into 100 bytes? It's not a multiple of 3?
    I'm sorry, I wasn't clear.
    There will be 100 bytes worth of data in the end.. 75 bytes worth of data to start with.

  4. #4
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,412
    Rep Power
    25

    Default

    To get an algorithm, write out the input bits/bytes on one line and the output bits/bytes on a line below and map from one to the other.
    Looks like a few shifts and some ANDs and ORs will be involved.
    Use two arrays of bytes. Take 3 bytes from one and convert them to 4 bytes in the other.

Similar Threads

  1. How to save large amounts of similar objects?
    By nieuwenhuizen-jk in forum New To Java
    Replies: 12
    Last Post: 05-13-2011, 03:21 PM
  2. Spliting Large String Data (upto 2 GB)
    By piyush@java in forum Advanced Java
    Replies: 5
    Last Post: 01-12-2011, 02:23 PM
  3. Large data over RMI
    By JavaDesigner in forum New To Java
    Replies: 7
    Last Post: 10-16-2009, 08:48 PM
  4. Replies: 6
    Last Post: 01-19-2009, 08:28 PM
  5. Replies: 1
    Last Post: 12-28-2008, 10:25 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •