4 ms·
I once wrote a JPEG 'recompressor' that could throw away some of the DCT coefficients, so you could dynamically adjust the size of images when streaming them to
by joosters 5y ago
I once wrote a JPEG 'recompressor' that could throw away some of the DCT coefficients, so you could dynamically adjust the size of images when streaming them to a web browser with limited bandwidth - just like the slider in this demo.
It was clunky and unreliable (estimating bandwidth quickly is hard!) but I really liked the way that the JPEG format allows you to increase the compression of a file without having to fully decompress and then recompress the image. You literally can just throw away some bits from the file here and there. I wonder if that is possible with other lossy data formats (video or audio)?
- KMag 5y agoI seem to remember that "bit peeling" was designed into Ogg Vorbis audio from early on, such that the data stream could be encoded in order of decreasing audio perceptibility such that data frames could be truncated at certain points and you'd get a good lower-bitrate stream. However, I've never read of a Vorbis encoder that actually encoded that way.
- sp332 5y agoIt was a valiant effort, but ultimately abandoned.
- pornel 5y agoI think it's unique to JPEG due to its simplicity. JPEG encodes blocks independently, which makes manipulation of block data easy (also enables progressive rendering). All later DCT-based formats try to get more compression by predicting future blocks from previous ones, which makes all blocks potentially interdependent, and distortions from such quick recompression could be amplified exponentially.
- jart 5y agoSo you're the reason Cache-Control:no-transform exists. Bravo.