From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,435e65f4acf8bd X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-01-14 07:10:16 PST Path: supernews.google.com!sn-xit-02!sn-xit-04!supernews.com!xfer13.netnews.com!netnews.com!feed2.onemain.com!feed1.onemain.com!news-out.cwix.com!newsfeed.cwix.com!sjc-peer.news.verio.net!news.verio.net!iad-read.news.verio.net.POSTED!kilgallen From: Kilgallen@eisner.decus.org.nospam (Larry Kilgallen) Newsgroups: comp.lang.ada Subject: Re: bitstreams Message-ID: References: <93se2v$nen$1@eol.dd.chalmers.se> Organization: LJK Software Date: 14 Jan 2001 10:10:11 -0500 NNTP-Posting-Host: 216.44.122.34 X-Complaints-To: abuse@verio.net X-Trace: iad-read.news.verio.net 979485014 216.44.122.34 (Sun, 14 Jan 2001 15:10:14 GMT) NNTP-Posting-Date: Sun, 14 Jan 2001 15:10:14 GMT Xref: supernews.google.com comp.lang.ada:3999 Date: 2001-01-14T10:10:11-05:00 List-Id: In article <93se2v$nen$1@eol.dd.chalmers.se>, "Daniel Nilsson" writes: > In my mp3 decoder I will have to search for bit-patterns in a buffer of > bytes, how is this best done, and How can I "shift" in a sequence of bits > into a byte, or word efficiently? (I want ex. take 5 bits from a buffer and > put them rightadjusted in a unsigned_32) Step 1. Use a sequence of statements that correctly describes what you want. Step 2. Use a computer that can accomplish your goal efficiently. Step 3. Use a compiler that will optimize your statements into efficient machine instructions. If your choice of computer or compiler is limited by some other constraint that you failed to mention, play with it to get the best performance. If a compiler is really great you will not be able to affect performance by changing between reasonable source code representations (other than those specifically documented to affect performance, such as certain pragmas). In theory the compiler _should_ choose the most efficient representation that correctly implements your source statement.