Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize ADPCM (sosCODEC) decompression #884

Merged

Conversation

giulianobelinassi
Copy link
Collaborator

This commit optimizes ADPCM decompression in game by:

  • Removing any unsupported modes that the game do not use.
  • Using a table of possible values instead of computing them on each iteration.

This new table is built by employing a dynamic programming techinque. The possible values are bound and the product of the dimensions are small, hence this techinque is quite effective in optimizing things by precomputing the values.

Signed-off-by: Giuliano Belinassi [email protected]

@isojalka
Copy link
Contributor

For what it's worth, I've tested this patch with a few missions of TD and RA and found no functional issues.

@tomsons26
Copy link
Contributor

tomsons26 commented Feb 24, 2023

what i'd want to see here is

typedef struct _tagCOMPRESS_CHANNEL_INFO
{
    unsigned int dwSampleIndex;
    int dwPredicted;
    int dwDifference;
    short wCodeBuf;
    short wCode;
    short wStep;
    short wIndex;
} _COMPRESS_CHANNEL_INFO;

typedef struct _tagCOMPRESS_INFO
{
    char* lpSource;
    char* lpDest;
    unsigned int dwCompSize;
    unsigned int dwUnCompSize;
    _COMPRESS_CHANNEL_INFO Channels[2];
    short wBitSize;
    short wChannels; // added BP for # of channels
} _SOS_COMPRESS_INFO;

that way you can get the code cleaner mostly likey with less duplication

@giulianobelinassi
Copy link
Collaborator Author

Ping

This commit optimizes ADPCM decompression in game by:

* Removing any unsupported modes that the game do not use.
* Using a table of possible values instead of computing them on each
  iteration.
* Generating a custom function for 16 bit stereo and mono by using
  a template function.

This new table is built by employing a dynamic programming techinque.
The possible values are bound and the product of the dimensions are
small, hence this techinque is quite effective in optimizing things
by precomputing the values.

Both mono 8-bits and stereo 8-bits function are not generated as no
sample ingame uses them.

Signed-off-by: Giuliano Belinassi <[email protected]>
@OmniBlade OmniBlade merged commit 7e25f07 into TheAssemblyArmada:vanilla Jun 12, 2024
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants