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

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:
    611
    senthil
    Mar 4, 2004
  2. Tommy

    HOW TO OPTIMIZE CONTROLS?

    Tommy, Nov 10, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    415
    Tommy
    Nov 10, 2003
  3. Reddy
    Replies:
    3
    Views:
    2,202
    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:
    545
    Brock Allen
    Apr 21, 2005
  5. TCB

    Optimize Website

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

    Warning and how to optimize code

    Aaron, Jan 19, 2006, in forum: ASP .Net
    Replies:
    2
    Views:
    1,334
    =?Utf-8?B?Sm9l?=
    Jan 19, 2006
  7. Duane Morin

    Do you optimize?

    Duane Morin, Jul 30, 2003, in forum: Java
    Replies:
    24
    Views:
    1,046
    Daniel Dyer
    Aug 7, 2003
  8. Blaise

    [image] Optimize image load

    Blaise, Oct 6, 2003, in forum: Java
    Replies:
    3
    Views:
    886
    Blaise
    Oct 7, 2003
Loading...