-
Notifications
You must be signed in to change notification settings - Fork 139
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
Streaming image decoding #13
Comments
To the possible WebIDL I added this: partial interface ImageData { Which would allow the data to stream (the pixel data), at least from the decoder. I'm interested to hear what you mean by "streaming frames" That makes it sound a lot like a video decoder, which is hopefully well supported by the previous portions of the explainer. Is there something different you area looking for? Perhaps what you mean is different quality versions of the same image rather than different frames over time? |
By yielding frames I mean animated gif/webp. Maybe that could be handled by the video decoder, but the platform doesn't treat these things the same elsewhere.
Nah, "yielding pixel data with increasing detail (progressive/interlaced)" was supposed to cover that case. |
I don't think that makes sense as |
A couple of different things at once:
|
I'm not sure. But we don't allow
I think that would be better handled by a helper that converts an array/sequence to a stream. But, I don't see the benefit. The benefit of streaming is you can do things in chunks, or ideally in parallel, so a streaming encoder/decoder is only useful if it can provide meaningful data before the whole operation is complete.
Good question, and the answer would take a lot of careful design, but here are some half-baked ideas: If the image format only touches pixels once during decode (baseline jpeg, webp), I'd expect the stream to yield data structures like this:
I guess 'multi-scan' formats would have the same format, but the target x & y would always be 0, and the target width & height would be the same as the final width & height. |
On Tue, Sep 3, 2019 at 9:33 AM Jake Archibald ***@***.***> wrote:
Other than containerization (which is an interesting topic for video vs.
image codecs in its own right), how is an animated webp file different than
a vp8 video?
I'm not sure. But we don't allow <video> to play gifs, or <img> to play
muted mp4s. It'd be great if that changed IMO 😄.
For ImageData.readable, my intention was to allow a WHATWG stream version
of .data. I was hoping it could then be piped through transform streams (to
edit the image) before being piped elsewhere (such as an encoder).
I think that would be better handled by a helper that converts an
array/sequence to a stream. But, I don't see the benefit.
The benefit of streaming is you can do things in chunks, or ideally in
parallel, so a streaming encoder/decoder is only useful if it can provide
meaningful data before the whole operation is complete.
How useful that will be for images is still definitely uncertain. So far,
it's just an idea to possibly explore.
How could a progress stream of raw/unencoded bytes of increasing quality
work?
Good question, and the answer would take a lot of careful design, but here
are some half-baked ideas:
If the image format only touches pixels once during decode (baseline jpeg,
webp), I'd expect the stream to yield data structures like this:
- Final image width.
- Final image height.
- ImageData of some decoded data.
- Target x position of image data.
- Target y position of image data.
- Target width of image data.
- Target height of image data.
I guess 'multi-scan' formats would have the same format, but the target x
& y would always be 0, and the target width & height would be the same as
the final width & height.
You originally said stream of bytes, but you just described a stream of
data structures. I agree a stream of data structure may make sense. It
was the stream of bytes that had me confused. But you make it sound like
you mean stream of data structures, which would clear up my confusion.
… —
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#13>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AB3J76X3HH3HJWGL5NDCTD3QH2GXHANCNFSM4IS5LJ7Q>
.
|
Note, The first list item below is an insidious bug. The only way that was able to achieve expected result, before reading the second list item which clarified what the issue is, was to assign
|
Every browser has taken advantage of streaming decoding for over a decade now. I think its usefulness has been well proven.
I think I said pixel data. But yes, there needs to be metadata that tells the developer where that data exists in the overall image. I guess what I'm trying to say, at a higher level, is: All browsers ship streaming image decoders that allow them to improve performance by handling image data of partially decoded images. Let's give developers access to this. |
@guest271314 this issue is about streaming image decoding, not getting images from a video. Please start another issue, or post on an existing relevant issue, if you have something different to discuss. |
Only posted here because you mentioned using or modifying |
@guest271314 The existence of an implementation bug in one browser does not justify the creation of a whole new standard/API. |
I meant more specifically the .readable attribute on ImageData giving a stream of bytes rather than .data for an array of bytes. The "stream of data structures" thing that you meant (and I misunderstood at first) is something different.
Ah.... my mistake, then.
I think we're on the same page now. Let's see if I can take a shot at what the WebIDL would look like: interface ImageDecoder { interface DecodedImage { That could probably be cleaned up a bit, but first let's make sure that's generally what you're looking for (and if it's implementable :). |
It should probably be a transform stream rather than a function that takes a readable, but seems good! However, I haven't looked at how streaming codecs actually work, and what they output. They might do something much better, or cater for something we're missing. |
OK, how about this:
|
👍 This doesn't cater for animated formats, but yeah, it does feel like the video stuff (or something similar) would be in a better position to handle that. |
I think what I'll do is remove what is there currently for images (I meant it to be a PR and just pushed to the wrong branch anyway) and then make a PR like this. |
As I'm updating the explainer to represent this, I had the following question: What is it that the browser can do here that you can't do already in wasm/JS? |
In terms of the things discussed in this thread, it can all be done if you throw enough wasm at it. However, the browser already has well-optimised steaming image decoders, so why not let developers use those rather than importing their own? |
Is this issue aiming for something similar to http://www.http2demo.io and https://http2.akamai.com/demo? Does not HTTP require the entire resource to be downloaded, e.g., using If the total size of |
FYI wikionary is not a primary source for the etymology or meaning of English words, terms or phrases. In fact no such primary source exists, as English is an equivocal language. There is no prohibition to arbitrary creation and re-defining of words or terms, or not providing any definition at all. One example is the term "justice", where the term is not defined in U.S. or State law. Similar to the term "justify" or "justifiable". E.g., the phrase "justifiable homocide" can have vastly different interpretations depending on who is being evaluated for the action and whose life was taken. The State can conclude "justifiable" the family can reject such an assertion, for example in the case of Stephon Clark in Sacramento, California. Another example is the term "cheaper by the dozen" https://english.stackexchange.com/q/486088 which has several different interpretations, or "etymology", if you prefer. The closest you can get to a primary source for the meaning of a word, term or phrase in English is a technical document, e.g., a specification or standard, or a law enacted by a legislative body, where the codified rules of statutory construction apply. |
No.
No.
No.
Yes but you'd still want to know when pixels changed, and what changed. For progressive/interlaced formats, your proposal doesn't let you provide your own interpolation. |
Have had the concept of, if the pixel dimension of the image to be displayed are the same, to create a single "array" for the purposes of this use case, and replace each pixel that is different in the original array when a new "chunk" arrives, avoiding the creation of multiple Now, mapping which pixel changed would at least require creating a map and keeping track of which pixels change in both directions, which may or may not consume just as much resources as creation of multiple For an animation use case would consider utilizing Web Animation API, where images or pixels could be "streamed" to be displayed at
Am far more best suited to trying to solve challenging use cases where the use case is clear and at least some code exists to test and determine what the bugs are and what is ultimately not possible using current technologies. What are you not able to achieve right now? |
I appreciate you trying to help, but given that you don't understand the streaming nature of HTTP or image decoders, I don't think this conversation is constructive, and will only continue to derail the thread for the rest of us. Rather than ask me questions about what HTTP and images can/can't do, perhaps do some research. You can get answers to the things you've asked with some pretty basic tests, or by putting your query to a search engine. |
Have done research. That is why posted the previous link describing HTTP/2. It is not clear what you are trying to achieve that you cannot do right now. If you have an incoming stream of data The accusation of "derail" is not correct at all. Am asking specific questions attempting to gather what you are actually trying to do that you are not capable of doing right now. The questions posed are no different than any other questions on any board. If you already had the answers to your own question then there would be no need for you to file this issue in the first place, due to that fact we a re in the exact same space relevant to asking questions. |
@jakearchibald Am at the front-end. "the rest of us" since you are speaking for everybody other than yourself as well should be able to figure out what you are actually trying to do and to solve the problem that is not clear to this novice coder that just writes code. Do not really care at all if you or anyone or entity like the questions posed or not. Am not here to make friends. Am asking technical questions for own edification. If answering such basic questions is beyond the scale of your status then just state that: you are over-qualified to answer such question. Which again, leads back to why you even need to file this issue in the first place. You can solve your own inquiry with using your own expertiese. Am certain in the final analysis the outcome will be useful and clear. Best of luck with your project. |
HI, we at Philips-Algotec developing a medical imaging application would benefit very much from this proposed WebCodecs extension for using the browser's decoders in our own code.
Actually supporting non-streaming inputs as part of the ImageDecoder interface makes sense in this case. |
There are two separate things here:
The first I believe you can do already today. No new APIs are needed. The second is somewhat interesting, but in that case, what is the advantage of using the img tag instead of canvas? |
I've written an explainer and implemented a prototype of how this might work: Please take a look and let me know if that approach sounds good. If so, we may eventually want to merge it with the WebCodecs explainer/spec. |
Just want to say that I'm starting to try to build a demo of JPEG-XL's native progressiveness, and how it might be useful for low-quality image placeholders or even single-file responsive images. I would absolutely love an ImageDecoder that dealt in Streams! |
ImageDecoder can already do that. You just give it the ReadableStream as data value. |
Old issue. Dale's explainer supports streaming, is now implemented in Chrome behind the WebCodecs flag/origin trial, and actively being spec'ed (tracked in #50). |
The above (from the explainer) suggests that decoding doesn't stream, which feels like a missed opportunity.
In its current state, it feels like it'd be better to change
createImageBitmap
so it could accept a stream.Maybe that should happen, whereas a whole new API could provide expose streamed image decoding.
Images can stream in a few ways:
This would allow partially-loaded images to be used in things like
<canvas>
.The text was updated successfully, but these errors were encountered: