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

Use FFmpeg's 12-bit non-linear to 16-bit linear conversion #3

Open
sapperlott opened this issue Dec 26, 2024 · 1 comment
Open

Use FFmpeg's 12-bit non-linear to 16-bit linear conversion #3

sapperlott opened this issue Dec 26, 2024 · 1 comment

Comments

@sapperlott
Copy link

I was researching the non-linear 12-bit sample format used for the DAT LP mode (and for DV video as well) when I noticed that there are a couple of different conversion strategies used in different software packages out there. The LUT in your code seems to have been generated using the same algorithm used in DATlib and VLC. One characteristic of this method is that the positive and negative value ranges of the resulting signed 16-bit integer are non-symmetrical (-32768..32704) which might cause some distortion (correct me if I'm wrong here).

I've found that FFmpeg / libavcodec uses a different algorithm which results in symmetrical ranges (-32705..32704):
https://github.com/FFmpeg/FFmpeg/blob/3778b1f6f102c7fda82b83f19db0bf48151d496b/libavcodec/dvaudiodec.c#L68

I've re-created the LUT using FFmpeg's algorithm - the corresponding patch is attached:
ffmpeg-conv.patch

@sapperlott
Copy link
Author

The difference between the two algorithms is whether 0s or 1s get shifted in from the right for negative values. Both seem to be valid solutions according to patent US5325240A since the shifted in values are basically "don't cares".

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