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

Frame header padding bit incorrectly set #39

Open
autobalance opened this issue Sep 29, 2022 · 0 comments
Open

Frame header padding bit incorrectly set #39

autobalance opened this issue Sep 29, 2022 · 0 comments

Comments

@autobalance
Copy link

When encoding a 32khz WAV at a bitrate of 48kbps, shine generates a frame header of FF FB 3A C4 instead of the expected FF FB 38 C4; the padding bit is incorrectly being set.

It seems to narrow down to non-associativity of the floating-point calculation of avg_slots_per_frame in layer3.c. The calculation with samplerate=32000 and bitr=48 gives a double of 215.999999999999972... which consequently truncates incorrectly to 215.

Setting whole_slots_per_frame by first truncating to a float before converting to an int:

config->mpeg.whole_slots_per_frame = (int)(float)avg_slots_per_frame;

seems to work now and various other WAV files still convert properly. May not be the best solution however as floating point errors may still occur elsewhere.

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

No branches or pull requests

1 participant