How to optimize?

Discussion in 'C Programming' started by filia&sofia, Apr 9, 2008.

  1. filia&sofia

    filia&sofia Guest

    Hello, I am using bitwise operations in my data compression algorithm.
    Basically, I have a buffer of n bytes from which the algorithm reads m
    bits (m<=n). If m doesn't divide n, there will be some bits that need
    to be transferred from end to start, because all bits must be used.
    Now, the problem is that my algorithm uses many bit operations to do
    this. I wish to do this as fast as possible.

    Example.
    n=2, m=3 and the data to the buffer from a file:

    01001101 00101001 01111011 01110010 01110010

    1. Fill the buffer B. B={01001101 00101001}
    2. Read m bits for x times. After x=5, buffer will contain B={1} (of
    course, the length of the buffer is still two bytes).
    3. Now, we have to fill the buffer again. The actual problem arises
    when the last bit needs to be moved to the start. If the buffer is
    large, the algorithm will sequentially put one bit into a new byte
    from previous byte and seven bits from the next byte. That is, B={1
    0111101} and again one bit has to be moved to the next byte...

    I would like to avoid this. Any suggestions? Design patterns?
     
    filia&sofia, Apr 9, 2008
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. senthil
    Replies:
    0
    Views:
    493
    senthil
    Mar 4, 2004
  2. Tommy

    HOW TO OPTIMIZE CONTROLS?

    Tommy, Nov 10, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    301
    Tommy
    Nov 10, 2003
  3. Reddy
    Replies:
    3
    Views:
    1,986
    Alvin Bruney
    Jan 20, 2004
  4. =?Utf-8?B?U2FjaGk=?=

    Best choice to optimize datagrid paging and sort ??

    =?Utf-8?B?U2FjaGk=?=, Apr 21, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    451
    Brock Allen
    Apr 21, 2005
  5. TCB

    Optimize Website

    TCB, Dec 19, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    338
    Wiktor Zychla [C# MVP]
    Dec 19, 2005
Loading...

Share This Page