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

Avoid copy of image data from decoder to avifImage. #5

Closed
dalecurtis opened this issue Jul 17, 2019 · 3 comments
Closed

Avoid copy of image data from decoder to avifImage. #5

dalecurtis opened this issue Jul 17, 2019 · 3 comments

Comments

@dalecurtis
Copy link

Helps with memory pressure and avoids expensive copies on larger images. Currently both the libaom and libdav1d based decoders appear to make copies of the image data.

@joedrago
Copy link
Collaborator

Yes, definitely.

I am planning to stubbornly keep my basic avifDecoderRead() as a braindead-simple path for people that aren't trying to use image sequences or squeak out extra performance, as it allows for avifImage objects to be decoupled almost entirely from encoders and decoders.

That said, I'm in the process now of putting in image sequence support, and a side effect of that medium-sized code reorg, I'm planning to make avifDecoderRead() simply call 3-4 other avifDecoder functions which ends up with a copy of the first image, with functions that perform something like:

  • Begin the decode/parse
  • "get" the first image, which will be owned by the decoder (decoder->image will be a not-copied avifImage)
  • "copy" decoder->image into the passed in image ptr

I plan to reuse the decoder->image structure as you "get" the next image, so if you want YUV copies of multiple frames, you're going to have to copy it anyways, but I imagine you just want to take the current decoder->image and run it through your own YUV->RGB pipeline, in which decoder->image can be safely reused, right?

@dalecurtis
Copy link
Author

That break up sounds good.

Yes in the ideal case we can output directly to YUV8 planes, but we can't reuse the buffers from dav1d/libavif for that. We do have to copy into them. In the less ideal case (where RBG8/RGB_F16) is required we have to convert into a new structure.

So I don't think we can ever get to a zero copy solution, but a one copy one would be fine too.

@joedrago
Copy link
Collaborator

This is done, see the Advanced Decoding section of the README.

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