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

Determining optimal decompression buffer size #18

Closed
heisters opened this issue Sep 5, 2016 · 3 comments
Closed

Determining optimal decompression buffer size #18

heisters opened this issue Sep 5, 2016 · 3 comments

Comments

@heisters
Copy link

heisters commented Sep 5, 2016

What is the best way to determine the size of the output buffer passed to HapDecode? Looking at HapDecode itself, it seems like there is no real way to know the correct size ahead of time, so one simply has to make a good guess. After a little experimentation, I settled on simply multiplying the size of the compressed buffer by a factor of 2, but that may fail with a different encoder (this source is FFMPEG), or a different Hap codec (this is Snappy + DXT5 YCoCg). Setting it too high obviously impacts performance, as the runtime needs to find too much contiguous memory.

https://github.com/heisters/libglvideo/blob/master/src/decoders/hap.cpp#L24

@bangnoise
Copy link
Collaborator

Usually (ie always for mov or avi) dimensions are stored independently in the container, so armed with those and the texture format (from HapGetFrameTextureFormat()) you can calculate it exactly (round dimensions up to a multiple of four, apply known DXT block size).

@bangnoise
Copy link
Collaborator

Also note that the texture format is constant for a file for most (all?) Hap encoders, so you should be able to allocate a buffer once and reuse it.

@heisters
Copy link
Author

heisters commented Sep 6, 2016

thanks!

@heisters heisters closed this as completed Sep 6, 2016
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

2 participants