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

Additional space in the buffer #6

Closed
lgrahl opened this issue Mar 30, 2020 · 4 comments
Closed

Additional space in the buffer #6

lgrahl opened this issue Mar 30, 2020 · 4 comments

Comments

@lgrahl
Copy link

lgrahl commented Mar 30, 2020

It would be useful to allow the user to request additional bytes to be prepended and appended for each frame, so adding a header/footer/nonce/whatever kind of additional data does not require to copy into a new ArrayBuffer which can be expensive and may require garbage collection.

This is useful for e.g. encryption modes with additional MACs and nonces that need to be transmitted.

Could look like:

createEncodedVideoStreams(optional EncodedVideoStreamsParameters)

dictionary EncodedVideoStreamsParameters {
  unsigned byteHeadroom = 0;
  unsigned byteLegroom = 0;
};
@fippo
Copy link
Collaborator

fippo commented Apr 1, 2020

On a second thought I am not sure that it really buys us much. If you encrypt you'll have to copy the ciphertext (which is larger than the plaintext in many cases) into your new packet anyway unless webcrypto offers a way to do things in-place

@lgrahl
Copy link
Author

lgrahl commented Jun 15, 2020

In-place encryption can be done with tweetnacl and perhaps webcrypto can do it in the future, too. However, there are obviously use cases beyond double crypto that can make use of this, e.g. metadata.

@alvestrand
Copy link
Contributor

In raw-videoframe-land, the tendency seems to be to declare the input object immutable and create a new buffer for the output object, given that any transform has to read from the input and write to the output (two memory accesses) anyway.
The videoframe object has a destroy() operation that declares its backing store freed; I wonder if it's possible to declare a destroyAndTakeOverAndTransform() operation that creates a new frame while doing an in-place operation on the buffer.

Seems hard.

@alvestrand
Copy link
Contributor

On the assumption that we're going to update the spec to use EncodedVideoChunk from WebCodecs, I'm closing this issue here. Please reopen an issue in WebCodecs if this is still relevant.
(EncodedVideoChunk has its "data" member immutable.)

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

3 participants