843 points · by mjs · 12y ago · 328 comments
So we don't like HVEC due to patent worries? Fine, we can swap in another format and use the same technique.
We don't have an I-frame format for Daala that's finalized yet? Fine, we can use work-in-progress. The format does not need to be finalized. If you update it, you rebuild your images and bundle a new JavaScript decoder.
The ability to ship media along with a sandboxed, runnable decoder is awesome, and I'm surprised it hasn't caught on until now. I remember Google a while back implemented their own "video" codec in JavaScript using JPEGs and primitive inter-frame processing, exactly because there wasn't a universal video codec format they could use.
If you needed this for any page that loaded lots of images, all of the above would significantly increase page-load time, and memory usage. Especially on a mobile browser, it would use more resources (hence more battery), than otherwise. So personally I wouldn't like to see this be the future. Maybe just as a fall back, but detection for that might be a little hard.
Right now, it would appear that the with a hard reload of the demo: http://bellard.org/bpg/lena.html on chromium, the BPG images are initially loaded with the page, then the posts.js file scans through the page's images to find the ones who's src ends in '.bpg', then posts.js re-downloads the same files with ajax, which are then decoded to PNG files rendered in canvas tags with no identifying information.
The extra request to re-download images is unnecessary but easily removed to just process the data loaded with the initial page load.
>> Can CSS reference them without javascript changing the styles?
Not from what I can see. The images are being rendered to canvas elements without any identifying information. The decoder will need to be modified to add identifying id's or classes. This again is an easy fix.
>> Can they be cached locally if downloaded directly?
This is what I perceive to be an issue. Try downloading the image rendered to the 5kb bpg example... The image that is being rendered is a 427.5kb PNG and that's for a 512x512 image size.
PNGs aren't lossy... so any difference in file size is going to be the product of rendering size or how much the bpg compression has simplified the source image. ( I'm guessing the file size follows something like a logarithmic curve where it jumps initially based on rendered image dimensions and then approaches a limit as the compression approaches lossless. )
Because of the rendered out PNGs' large file size, I would expect that if you are rendering out large images or a lot of images, you would definitely use more resources than with comparable quality JPGs regardless of whether you cache the BPGs for rendering and you would indeed experience the drawbacks you mentioned in both memory and page-load time.
That being said, this is a cool idea, an incredible proof of concept and I'm very thankful to Fabrice for putting it out there.
Are you sure you are not inspecting with the cache disabled. If the appropriate cache headers are applied, this shouldn't issue another request.
Still, to become truly widespread you need to have support in all kinds of software out there, "everything you need is js plugin" is unreasonable optimism in my opinion. And, anyway, decoding using js isn't fast enough to be one and only solution forever, you need to get to have browser and other software support sooner or later, and for that you need 1 standardized format, not "whatever your plugin supports" as thread-starter suggests.
The only problem I see for now is SEO. Ofcourse the title and alt attributes can give some context but the images wont get indexed
Still, it is quite amazing.
This is the software video decoder, by the way: https://github.com/brion/ogv.js
the demos reminded me what browsing on dialup was like. in fact dialup was better cause at least the decoding/loading was progressive/incremental, which doesnt seem to be the case here. i assume it's just the way the decoder is implemented?
Not quite production-ready, I think.
If only the rightclick menu could be customized by JS. Adding only a limited number of entries to the menu seems like it'd be okay.
Google Animated doodle with JPEG and opacity
http://zoompf.com/blog/2012/04/how-do-google-animated-doodle...
Even the things he does just for fun are impressive. Have you ever booted up Linux inside your browser? http://bellard.org/jslinux/
Would this have been less interesting or valuable if it hadn't been made by a hacker celebrity?
> Based on a subset of the HEVC open video compression standard.
So BPG is patent-encumbered, right?
tl;dr (obviously tl;dr): This format is very, very easy to implement despite the patent risk, simply by assuming that any device new enough to be considering including it will have already licensed the relevant patents.
Having alpha channel support, 14 bits and better compression would be lovely.
I would much rather someone revived the Fractal Image format, which is now out of patent. It's very expensive to encode, but that's nowhere near as big a problem as it used to be. It's very fast to decode, very small, and the files are resolution independent: http://en.wikipedia.org/wiki/Fractal_compression
I was blown away when I encountered it at PC Magazine in the 90s and it seems like it would be very responsive to the needs of today's web.
(And note my phrasing of "got more hype than was justified by its ability to perform"... it isn't that it has no ability, just that it got more hype than it should have. Same thing happened to "wavelets". Yes, I know about JPEG2000... again, the point isn't that they are "bad" or "can't work" but that they got more hype than their real performance justified.)
At the time, encoding required a) an expensive license and (IIRC) b) an accelerator board if you intended to do anything other than leave your CPU churning overnight - obvious disadvantages relative to formats like jpeg.
you should read the Talk page of the wikipedia entry, where it's obvious there are some misinformed/deceptive folks took control of the page. See the comp.compression FAQ is a much better resource, as is the paper Brendt Wohlberg and Gerhard de Jager, "A review of the fractal image coding literature", IEEE Transactions on Image Processing, vol. 8, no. 12, pp. 1716--1729, Dec 1999 in particular " purely fractal-based schemes are not competitive with the current state of the art"
Unfortunately I can't find a free PDF at the moment.
http://pointersgonewild.com/2014/01/02/tile-based-image-comp...
They have a 6-minute figure on their page. I wonder what modern hardware could do with it? Anybody care to give it a whirl?
In terms of optimizations we have SIMD and GPGPUs to make it even faster. Not unrealistic to think we could bring that 6 minute figure down to one second... And then, of course, there might be algorithmic tweaks that help us even more. Get 100 people looking at that code, and for sure they'd find ways to speed it up.
Figure 2 absolutely does not contain the level of detail reproduced in the--supposedly--fractal compressed versions in figure 3 and 4.
http://justinmayer.com/bpg-test/
Size of PNG before conversion: 186K
Size after conversion to JPEG: 52K
Size after conversion to BPG: 9K
I took the liberty of submitting a Homebrew formula, so hopefully this will soon be a quick "brew install libbpg" away. (^_^)
I get "bpgdec.c:35:17: warning: png.h: No such file or directory" and lots of other errors.
When the file size gets larger at the end, it looks like there might be a little loss of detail. Ideally I'd like to compare them by switching back and forth using the original image and the .bpg as Photoshop layers...
Maybe I'm reading it wrong.
extension_tag ue7(32)
...
'extension_tag' is the extension tag. The following values are defined:
1: EXIF data.
PS. I think I understand now. It's just meant as a shortcut. Not sure why this is done when EXIF fits just as well.sRGB is designed for an 8 bit per channel encoding, so while it makes sense to support 10bpc to mitigate quantization effects of higher compression, it makes little sense to support more than 10bpc unless wider gamut spaces are supported. If the intent is for BPG to replace JPEG in-camera renderings, rather than converting existing JPEG and PNG to BPG, then it needs to support spaces other than sRGB. This doesn't require explicitly embedding ICC profiles but the spec needs to, well, specify at least one way of preserving this metadata. Otherwise there's no guidance for encoding or decoding the information, and then it's lost. And at that point it's a huge regression from what we have now, and thus no point in implementing it.
His accomplishments are impressive: QEMU, FFMPEG, TCC, JSLinux, the list goes on
I have been wishing there was a JPEG equivalent with an alpha channel for like forever. That allows better compositing to arbitrary background images or patterns. Now the question is how long before browsers might support it natively.
It's also supported natively on all newish (4.0+) Android devices and Chrome.
JPEG 2000 works in Safari. JPEG XR in IE. A gracefully-degrading JPEG XT is in the works: http://www.jpeg.org/jpegxt/index.html
Lossy PNG with alpha works in all browsers: http://pngquant.org (not equivalent in compression ratios, but still 4 times better than normal PNG).
Does anyone know if he has a day job or does he just lock himself away and work on these interesting projects?
Some of the HEVC algorithms may be protected by patents in some countries
There have been some patent disputes over JPEG, but I don't think replacing it with another possibly patented format is a good idea, even if it's technically superior in some ways.
I don't know if that suggestion makes much sense, but you missed it in your quote.
But the vast majority of people right now don't have support for HEVC encoding and won't have for 5+ years.
Edit: decoder, not encoder
Royalties only get involved when distributing encoders & decoders.
See page 7 here http://www.mpegla.com/main/programs/HEVC/Documents/HEVCweb.p...
I hope browser vendors take note. The patent issues are concerning, but if that can be worked around and a new spec designed, then we might just actually have a new image format for the web which really is better than what we've already got.
I'd really like to know that. Because I'd really like to use this.
The coolest thing is this javascript program that can decode and display the pictures on-the-fly.
Definitely an image format that could save storage space and bandwith, IMHO.
[1] http://x265.org
Yeah, who am I kidding, I'll just buy more hard drives to keep the originals :)
1. Why a Subset of HEVC Still Picture Profile? Why not just a use HEVC Picture instead?
2. Since JS sources are readable and being interpreted by VM ( Free Speech ), patents issues should not be a problem?
3. I am assuming the quality of BGP still has Lots and Lots improvement to be made? Since all H.265 encoder hasn't had the time to be tuned. ( Compared to x264 )
It gets to Lena's head in the first image, then becomes brigtly multi-coloured, though it looks like the difference between colours right... as if maybe an int overflow in the browser's JS implementation?
186,967 ==> 29,872 and indistinguishable, 6.25:1
(and pls tell me if it breaks on your browser - I want to push this live!!!)
adam
Edit: it's particularly noticeable in the wood grain patterns. Also, there's a soft grey dot to the left of the top of the lamp, 100px or so, that's entirely missing in the BPG. There are loads more examples...
Edit again: the color saturation of the rug is pretty washed-out as well.
Your issue if anything will be older browsers. Is there a way that it can detect browser side if something has failed?
I write this, because I am building such an application and for now it has many PNGs ... and yes, using a format like BPG would be fine, because I use the PNGs only because of transparency ... but when redisplay is done via a Java Script, I doubt that I could have the same speed. Loading is not so much a limiting factor, since after some time, all relevant PNGs are already in the browser cache.
Can anybody say something to this topic?
Of course, it would be great to have this integrated into the mayor browsers soon ...
BPG looks good upon cursory inspection. It seems to be more efficient than WebP and supports 42-bit color. It also has .png's features of transparency and lossless compression although I didn't see anything mentioned about animation to replace .gif.
Bonus: since it's based on h.265 hardware support will come naturally and should be just a software update for devices that already have HEVC capability.
As a bonus, you won't have to pay for a HEVC decoder license.
Assuming a fast C++ decoder instead,(possibly GPU accelerated if the decoding algorithm is well suited for it) and not using JS but what would be the rendering times?
PNG are 4x bigger in his experiments, but interlaced PNG makes it more pleasant to users since it can be rendered progressively, can BPG benefit from such a thing?
edit: Interlacing is also used in JPEG, isn't it ?
It's a tradeoff, as a user, it's obvisouly a win situation when we have a low bandwidth, and as a server it's obviously a win.
A C++ decoder with assembly optimizations could easily run four times as fast as the Javascript version. Unfortunately distributing it would not be possible due to patents.
Yes, and contrary to PNG it actually makes files smaller.
The problem with human judgement that it's very imprecise. You're unlikely to notice difference between JPEG at Q=90 and Q=95, but you can't say it doesn't matter, because that can cause 40% difference in file size. OTOH objective metrics can easily spot that.
"Looks the same to me" leaves a lot of room for error and you could be unfairly telling one format to save much more detail than the other. And almost by definition these are the details you're least likely to be able to see.
There's also a pitfall of choosing image that looks subjectively "nicer" rather than closer to the original. Codecs that are better (e.g. faithfully preserve noise) may be judged as worse than another codec that's an accidental Instagram filter.
There are two really hopeful things about this new project: (1) by leveraging HEVC, we get cheap (energy efficient) and fast decode on future mobile devices and (2) Since he is demonstrating pretty quick decode in JavaScript now, it clearly isn't a CPU pig like JPEG-2000.
I don't necessarily think JPEG is bad, or that it's even Tumblr's fault that I first thought to share photos there, but if any service/software started using BPG I think I would excitedly try it out.
[e.g. http://www.huddug.com/ vs https://www.flickr.com/photos/127341162@N03/15762469070/]
[0] http://people.mozilla.org/~josh/lossy_compressed_image_study...
Regarding the image itself, it's not even a good test image. There are far better images out there that test the robustness of image compression, but those test images haven't been ran though every image processing algorithm since the 1973. Should we change default test images? Yes, but Lena should still be used as well. The historical data it provides is invaluable.
This sounds a lot like Redskins argument.
> The source code for various compression algorithms may have been lost, but the encoded Lena results for that compression algorithm may very well still exist.
We need to compare a new algorithm to an obsolete one where we don't even have the source code and this is beneficial... how?
By the way, the image is remastered in 2013 so none of this is relevant anymore: http://en.wikipedia.org/wiki/Lenna#Remastering
The problem with the Lenna imagery isn't political correctness, it's the fact that it's a crappy scan from a magazine that always had crappy photography to begin with.
The problem is that women in science cannot read a paper on image processing without being reminded that it's a boy's club.
I find this attitude far more patronizing than any conceivable choice of test imagery in a graphics research project.
Suggest reading this before posting anything else about the delicate sensibilities of "women in science": http://www.nytimes.com/2014/12/07/magazine/my-great-great-au...
Do you think any of those women would have spared a half-second's thought about this issue? Somehow, I don't think so. I think they were too busy doing science.
Not doing something you are permitted to do is somehow denying their right to permit? It's nice of her permitting the use, however her permission doesn't force us to use it. By the same logic, it would be perfectly okay use goatse image if the guy permitted it, right?
If the ability to represent the goatse image were a critical part of the evaluation process for a compression algorithm, then yes. However, we evolved to recognize and respond to subtle features in human faces, not human colons. So, no, goatse would not be an appropriate reference image.
Yeah, sure, from a historical perspective, the situation is not exactly symmetrical, and if it helps with normalizing the situation, maybe Lenna should be banished ... but then again, I would think that if the atmosphere is right otherwise, I doubt anyone would really be bothered by the use of mildly erotic pictures where there is consent from the person in the picture?
Having said that, all those demo photos do look good. I was wondering how we were going to see a demo in the browser without built-in support, but leave it to the man who put Linux in the browser to write a decoder in javascript. This is an encouraging project.
I find your comment a bit strange. I am an heterosexual male and I find this picture utterly uninteresting from a sexual point of view. To me, the appeal of using this pictures is sheer seventies nostalgia... I'm too young to have been alive in 1973 but I'm old enough to remember gawking in awe at the wall of the computer room adorned with output from the first desktop color printer I ever heard of or the first laser printer I ever saw. The example picture used was Lena. The picture reminds me of old computer rooms... I don't even know who the model is and I don't even find her pretty.
By all means use a better picture... But when a Hello World moment is required on a printer, this one is a very strong contender.
[1] https://en.wikipedia.org/wiki/Lena_S%C3%B6derberg
[2] http://dimka-jd.livejournal.com/3673381.html (NSFW)
All this is incredibly unimportant. You just made me waste 60 seconds of my life on a pointless thing and i want them back.
Dianne O'Leary, distinguished university professor emerita in UMD's CS department, objects to it: https://www.cs.umd.edu/users/oleary/faculty/node8.html
Sunny Bains, senior teaching fellow at UCL, also objects (see page 6): http://www.cs.cmu.edu/~chuck/lennapg/pcs_mirror/may_june01.p...
written by this woman: https://twitter.com/Love2Code
Maybe you can't generalize the opinions of two people to 50% of the human race?
Try a different strategy: offer a better alternative that makes it so practitioners not only don't notices the loss of Lena in common usage, but instead overwhelmingly favor alternatives. Create a better product.
No matter how you feel about the image itself, though, there is value in continuing to use it... people are familiar with it, to the point of it becoming almost cliché. This takes the focus off of the image and subject and puts it squarely on the image algorithm.
That's the exact privilege you get to enjoy as a hetero male. You get to ignore things like this when your female colleagues (if you're lucky enough to work with any) have to look at the image and be reminded that many people continue to view them as objects.
- If I post a picture of a cute kitten, does it mean I look at a cat as an object? That I will only under-appreciate all animals because I liked a photo of one? - If I post a picture of my mother or father, am I objectifying them? - What if I take a picture of a street performer who's doing some awesome thing and post it... am I reducing them to simply an object of attraction?
I just said it didn't affect me one way or another... that it is just an image. If someone thinks this image means I view a woman as an object, they are projecting THEIR OWN ISSUES onto me. That is the ONLY way that it could be offensive, in that they are choosing to be offended by something that 99% of the population think nothing about.
http://people.mozilla.org/~josh/lossy_compressed_image_study...
Create a site with all the different image formats out there with a larger test set.
Be willing to take matters into your own hands and change the norms and traditions in that field of study. The best way to accomplish that is by offering something better. I would say that a wiki with many test images for many algorithms is something better. If you do an good job, people will adopt your approach and tradition will change. Complaining on HN isn't going to change tradition.
Introducing new ideas usually is usually more successful long-term approach than "book burning" because you disagree with the content.
You are either subtly trolling, or have an incredible amount of cognitive dissonance going on here. You both objectify her by using those adjectives ("beautiful, young") AND THEN go on to state that use of a female model is sexist. Is use of a well-dressed male model sexist? If not, then your entire PREMISE is, in fact, sexist! Not to mention this photo is ENTIRELY asexual. Are you suggesting we avoid use of human models entirely to dodge sexism? Good luck with that.
If I were someone working on image compression techniques I would probably have seen many many algorithms and their output using that image so when I see a new algorithm and a new Lena, I might look at the results and think "Hey, this is similar to this other approach I am familiar with"
So many photos taken on any given day are photos of people, so it's simply not practical to eliminate a human subject from test images. If we're going to have an image of a human subject, that person is going to have to be somewhere on the gender spectrum. More data (images of two people) is preferable to no data (no images of people to avoid the risk of offending anyone)
In particular, the (appropriately-licensed) Kodak image set used in the Mozilla study includes multiple pictures of women, none of which are Playboy scans. The complaint is not that there's a picture of a woman, it is that _this_ particular picture keeps being used despite no particular scientific reason why it's optimal for comparing graphics formats.
Furthermore, why does the licensing matter? Near as I can tell every use of Lena, except for by a for-profit company, constitutes fair use. The image, every time I've seen it, has been used for non-profit educational work. It's never reproduced in its entirety. The use of the image for this image compression purposes has no impact on the original market for which the image was originally created. Does this not meet the requirements of fair use?
That all said, I agree that if their is a better images available for this purposes, those should be used as well, but that is an entirely separate issue from whether or not Lena should or should not be used. The happenstance provenance of the image is really the only controversial detail, and if we go back to the history of why it was used it was mere chance:
Alexander Sawchuk estimates that it was in June or July of
1973 when he, then an assistant professor of electrical
engineering at the University of Southern California Signal
and Image Processing Institute (SIPI), along with a graduate
student and the SIPI lab manager, was hurriedly searching the
lab for a good image to scan for a colleague's conference
paper. They got tired of their stock of usual test images,
dull stuff dating back to television standards work in the
early 1960s. They wanted something glossy to ensure good
output dynamic range, and they wanted a human face. Just
then, somebody happened to walk in with a recent issue of
Playboy.[0]
Put yourself back in 1973. Imagine all the different sources of high quality glossy images of a human face with high dynamic range you might have easy access to 41 years ago. I have a hard time thinking of content that would have been available at that time that would have rivaled Playboy. I have no qualms with people judging things from today in todays terms, but presentism [1] tends to rub me the wrong way. If you want to judge something, don't do so anachronistically.Anyways, I want to re-iterate my main point, which you did not address:
If I were someone working on image compression techniques I
would probably have seen many many algorithms and their output
using that image so when I see a new algorithm and a new Lena,
I might look at the results and think "Hey, this is similar to
this other approach I am familiar with"
There is value in consistency/continuity. Starting to use the image of Fabio Lanzoni like Deanna Needell and Rachel Ward did is a "lossless" approach of dealing with the controversial provenance of Lena.[0]: http://en.wikipedia.org/wiki/Lenna#History
[1]: http://en.wikipedia.org/wiki/Presentism_%28literary_and_hist...
So everyone, please respond: Now that there's an "attractive" man in use for image testing, do you feel repulsed or discouraged that they would sexualize/objectify a man like that?
Do you feel pushed away from this industry?
Personally, this exercise is helping me see the light of the "are we treating women as delicate flowers who can't handle it" viewpoint. That image of Fabio is not threatening to me. Anyone who tries to tell me it is threaten, I think is being overly sensitive.
I'm utterly comfortable with people expressing this level of sexuality in the academic/public area. It's more akin to a "schoolkid crush" than to strip tease.
Also, looking at the other comments, the fact that you happen to be fine with that image is neither here nor there. It certainly doesn't cancel out the fact that I'm not.
Disappointing, but unsurprising, to see HN defending the use of literal pornography in a professional setting. I thought we moved past the Ruby on Rails jerks defending porn in a professional setting as harmless fun.
Well, so much for that. Executing code in order to view an image is just begging to be exploited…
What's needed is a compression method that doesn't introduce artifacts on hard edges, as JPEG does, but is otherwise no worse at compression than JPEG. Then we wouldn't need to do some things in JPEG and others in PNG, and we'd be spared the pain of JPEG screenshots. Much better results on the Tecnick image set (which is mostly hard edges) would indicate one had been found. The results only indicate modest improvement in that area.
The improvement is far from marginal. In particular:
... I just tried to link you to a BPG image, and discovered that I can't.
Well, I'm going to ignore that little flaw for the moment, because that's just a browser feature. If BPG catches on, that's sure to change.
Anyway, the improvement is far from marginal: http://a.pomf.se/cdywsc.png
In particular, look around her face, eyes, and the background. The JPG is not just worse, but in fact very worse.
A more serious flaw is that it doesn't support animation. It doesn't need to be a video format. It just needs to be able to play a sequence of frames in succession. This is as easy as including a header that specifies how many frames are in the animation and the duration of each frame, followed by the image data itself. The fact that PNG doesn't have this has plagued the format since the internet became popular.
That may seem like "a video format," but it's not. Video decoders optimize for inter-frame compression, not intra-frame compression, so it's a different problem altogether. BPG doesn't need to do everything, but it should probably have basic animation.
Open these two images in a separate browser tab, then switch back and forth between them:
Those are the upper images of the test. Also try these, the lower images:
Again, JPG is not merely worse, but very worse. In fact, JPG makes it look like she's wearing a hat that's made of crosshatch material at the top, when in fact the top is composed of rings of fiber, not crosshatch.
JPEG 2000? JPEG XR? Wavelets tend to produce softness instead of ringing or noise.