Skip to main content

Module encode

Module encode 

Source
Expand description

Encodes animated thumbnails.

A picture that carries a frame sequence can answer a request for an animated thumbnail with the frames themselves rather than one of them. The three containers MSC2705 names each hold a sequence differently, so each has its own decoder here, and all of them produce a GIF, which is the one animated format this build can encode.

The caps that bound the work live here rather than at either call site, so a source reaches no decoder before what it would cost is known.

Re-exportsΒ§

use std::cmp::min; πŸ”’
use std::io::Cursor; πŸ”’
use std::panic::AssertUnwindSafe; πŸ”’
use std::panic::catch_unwind; πŸ”’
use std::result::Result as StdResult; πŸ”’
use bytes::Bytes; πŸ”’
use image::AnimationDecoder; πŸ”’
use image::DynamicImage; πŸ”’
use image::Frame; πŸ”’
use image::Frames; πŸ”’
use image::ImageDecoder; πŸ”’
use image::ImageFormat; πŸ”’
use image::Limits; πŸ”’
use image::codecs::gif::GifDecoder; πŸ”’
use image::codecs::gif::GifEncoder; πŸ”’
use image::codecs::gif::Repeat; πŸ”’
use image::codecs::png::PngDecoder; πŸ”’
use image::codecs::webp::WebPDecoder; πŸ”’
use ruma::Mxc; πŸ”’
use tokio::sync::OwnedSemaphorePermit; πŸ”’
use tuwunel_core::Err; πŸ”’
use tuwunel_core::Error; πŸ”’
use tuwunel_core::Result; πŸ”’
use tuwunel_core::defer; πŸ”’
use tuwunel_core::err; πŸ”’
use tuwunel_core::implement; πŸ”’
use super::super::Media; πŸ”’
use super::Dim; πŸ”’
use super::animate::GIF; πŸ”’
use super::generate::BYTES_PER_PIXEL; πŸ”’
use super::generate::reader; πŸ”’
use super::generate::thumbnail_generate; πŸ”’

StructsΒ§

Output πŸ”’

ConstantsΒ§

ANIMATED_NAME πŸ”’
GIF_SPEED πŸ”’
Quantization effort the GIF encoder spends per frame.

FunctionsΒ§

canvas_pixels πŸ”’
Pixels one composited frame of this source occupies.
decoder_limits πŸ”’
Creates decoder limits from the configured pixel budget.
encode_frames πŸ”’
Encode a picture’s frames as a GIF scaled to these dimensions.
encode_sequence πŸ”’
Encodes a bounded frame sequence into one GIF buffer.
gif_frames πŸ”’
Builds a bounded GIF frame iterator.
png_frames πŸ”’
Builds a bounded APNG frame iterator.
source_frames πŸ”’
The frame sequence a picture carries, and what one frame of it costs.
webp_frames πŸ”’
Builds a bounded WebP frame iterator.