Code Monkey home page Code Monkey logo

adpcm-68k's People

Contributors

kalmalyzer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

adpcm-68k's Issues

Optimization opportunities

Hi!

Just wanted to share some optimization opportunities I've discovered while adapting your code for the work I'm doing for the SegaCD.

The first one is by using a precomputed table for all index*nibble permutations, you can git completely eliminate the need to do clipping of the index value. The table is computed like so:

    int16_t adpcm_ima_indices[89*16];
...
    for (i = 0; i < 89; i++) {
        for (j = 0; j < 16; j++) {
            int newindex = i + indices[j];
            if (newindex < 0) {
                newindex = 0;
            }
            if (newindex > 88) {
                newindex = 88;
            }
            adpcm_ima_indices[i*16+j] = newindex << 5;
        }
    }

Note the << 5 instead of the <<6 because we do the additional multiply by 2 in the assembler portion of the code. This saves a significant amount of cycles + a couple of registers.

Another opportunity, which is probably less useful in your case, is that if you switch to unsigned samples, clamping against 0 becomes more trivial via spl+ext+and. Clamping against 0xffff also becomes more trivial since you can get away with a testing bit 16 on the result. This will also save you a couple of registers. The reason it's probably less useful in your case, is that will still have to sub 32768 from the result to go back to signed samples.

Sorry for not doing a proper PR, but I don't currently have a proper setup to incorporate all of my changes that would also allow me to test the results properly. Here you can find my version of the code, which is tailor to my SegaCD-specific needs: https://gist.github.com/viciious/0b8b0ee75dfd6deaebadfb5ef1eef6ff

All in all, I hope will find this information useful.

Regards,
Victor

Code license

Hi!

Just wanted to ask you which license the 680x0 code is distributed under.

Thanks for your work!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.