cros-codecs icon indicating copy to clipboard operation
cros-codecs copied to clipboard

Get reference to decoded frame from `StatelessVideoDecoder`

Open yuv418 opened this issue 1 year ago • 0 comments

Hi, I'm new to this library, so I apologise in advance if I'm using it wrong. Please feel free to point out any usage errors if that is the case.

I am trying to use a StatelessVideoDecoder to decode an H264 video stream. I've set this up and am repeatedly calling decode on the StatelessVideoDecoder and checking for events using next_event. On the FrameReady event, I call dyn_picture on the given DecodedHandle and then dyn_mappable_handle on the DynHandle.

Now, I can get data from the frame, but only using the read function. As far as I can tell, I can't downcast the DynHandle to an Image (although I'm not sure if that is the only implementation of the DynHandle trait), meaning I cannot get a direct [u8] reference to the buffer with the decoded frame.

As my application is performance-sensitive, I am trying to reduce the number of copies and would like to avoid copying the buffer on my end, so the read function won't cut it. Am I using the library wrong, or is something like this not possible at the moment? I would be interested in contributing a PR if this is the case.

yuv418 avatar Jul 06 '24 03:07 yuv418