How AVIF Compression Works
A technical deep dive into the next-generation AVIF image format and its advanced compression technology.
Quick Summary
- AVIF is based on the AV1 video codec, bringing video compression efficiency to still images
- Delivers 50% better compression than JPEG and 20% better than WebP at equivalent quality
- Supports HDR, wide color gamut, and 12-bit color depth
- Uses advanced techniques: inter/intra-frame prediction, transform coding, and modern entropy coding
AVIF Format Overview
AVIF (AV1 Image File Format) is a next-generation image format developed by the Alliance for Open Media. It leverages the sophisticated AV1 video codec to achieve unprecedented compression efficiency for still images. AVIF represents the most significant advancement in image compression in over a decade.
The AV1 Codec Foundation
AVIF inherits its compression power from AV1, a royalty-free video codec designed to replace H.264 and VP9. Key innovations include:
- Block-Based Encoding: Variable block sizes from 4×4 to 128×128 pixels for adaptive compression
- Advanced Prediction: 71 intra-prediction modes for highly accurate spatial prediction
- Transform Coding: DCT, ADST, and identity transforms optimized for different content types
- Context-Adaptive Entropy Coding: Sophisticated probability modeling for efficient bit allocation
AVIF Compression Pipeline
1. Color Space Conversion
AVIF supports multiple color spaces including:
- sRGB: Standard color space for web
- Display P3: Wide color gamut for modern displays
- Rec. 2020: Ultra-wide gamut for HDR content
- BT.2100 PQ/HLG: HDR transfer functions
Images are typically converted to YUV color space (luma + chroma) for compression. AVIF supports:
- 4:4:4: No chroma subsampling (highest quality)
- 4:2:2: Horizontal chroma subsampling
- 4:2:0: Horizontal and vertical subsampling (best compression)
- 4:0:0: Grayscale (no chroma)
2. Block Partitioning
The encoder divides the image into superblocks (64×64 or 128×128) and recursively partitions them using:
- PARTITION_NONE: No subdivision
- PARTITION_HORZ/VERT: Horizontal or vertical split
- PARTITION_SPLIT: Quad-tree split into 4 equal parts
- Complex partitions: T-shaped, H-shaped, and asymmetric splits
3. Intra-Prediction
For still images, AVIF uses only intra-frame prediction (predicting from already-encoded pixels). AV1 provides 71 directional and non-directional prediction modes:
- DC Prediction: Average of neighboring pixels
- Smooth Prediction: Gradient-based extrapolation
- Directional Modes: 56 angles from -135° to +135°
- Paeth Prediction: Intelligent selection of left, top, or diagonal neighbor
- CFL (Chroma from Luma): Predicts chroma channels from luma
4. Transform Coding
Residuals (difference between predicted and actual pixels) are transformed using:
- DCT (Discrete Cosine Transform): Standard for natural images
- ADST (Asymmetric Discrete Sine Transform): Better for edges
- Identity Transform: No transform (for very detailed areas)
- Hybrid Transforms: Different transforms for horizontal and vertical
Transform sizes range from 4×4 to 64×64, adaptively chosen per block.
5. Quantization
Transform coefficients are quantized to reduce precision and achieve compression. AVIF uses:
- Quantization Parameter (QP): Range 0-63, where lower = higher quality
- Adaptive Quantization: Different QP per block based on visual importance
- Quantization Matrices: Custom weighting for different frequencies
6. Entropy Coding
Quantized coefficients and prediction modes are entropy coded using:
- Context-Dependent Arithmetic Coding: Probability model adapts based on neighboring symbols
- Symbol Grouping: Efficient coding of coefficient magnitudes and signs
- Coefficient Ordering: Zig-zag scan optimized for zeros
AVIF vs Other Formats: Compression Comparison
| Feature | AVIF | WebP | JPEG | PNG |
|---|---|---|---|---|
| Compression Efficiency | Best (50% better than JPEG) | Very Good (25-35% better than JPEG) | Good (baseline) | Poor for photos |
| Encoding Speed | Slow (10-100x slower than JPEG) | Medium (2-5x slower) | Fast (baseline) | Medium |
| Decoding Speed | Slow (2-5x slower than JPEG) | Medium (similar to JPEG) | Fast | Fast |
| HDR Support | ✓ Yes (10/12-bit) | ✗ No | ✗ No | Limited (16-bit) |
| Animation | ✓ Yes (efficient) | ✓ Yes | ✗ No | ✓ (APNG) |
| Browser Support | 90%+ (Chrome, Firefox, Safari 16+) | 97%+ | 100% | 100% |
AVIF Optimization Strategies
Quality Settings
AVIF quality is controlled by QP or CRF (Constant Rate Factor) values:
- CRF 0-15: Near-lossless, large file sizes
- CRF 16-23: High quality, excellent compression (recommended for photos)
- CRF 24-32: Good quality, aggressive compression
- CRF 33-51: Lower quality, maximum compression
- CRF 63: Lossless mode
Speed vs Quality Tradeoff
AVIF encoders offer speed presets (0-10):
- Speed 0-2: Slowest, best quality (~10-100x slower than JPEG)
- Speed 3-5: Balanced (~5-10x slower)
- Speed 6-8: Fast, slightly lower quality (~2-5x slower)
- Speed 9-10: Fastest, noticeably lower quality
Chroma Subsampling Choice
- 4:4:4: Use for graphics, logos, screenshots (no quality loss in chroma)
- 4:2:0: Use for photographs (human eye less sensitive to chroma detail)
Real-World File Size Comparison
Example: 4000×3000px photograph at high quality:
- Original: 36 MB uncompressed
- PNG (optimized): 12 MB (67% reduction)
- JPEG (quality 85): 1.8 MB (95% reduction)
- WebP (quality 85): 1.2 MB (97% reduction)
- AVIF (CRF 20): 0.8 MB (98% reduction) ⭐
AVIF provides 55% smaller files than JPEG at the same perceptual quality.
When to Use AVIF
AVIF is ideal for:
- Modern web applications targeting current browsers
- Applications requiring the absolute smallest file sizes
- HDR and wide color gamut content
- High-resolution images (8K, 10K) where file size matters most
- Situations where encoding time is not critical (batch processing, CDN transcoding)
Browser Support & Fallbacks
AVIF Support (as of 2024):
- Chrome/Edge: Since version 85 (2020)
- Firefox: Since version 93 (2021)
- Safari: Since version 16 (2022)
- Opera: Since version 71 (2020)
- iOS Safari: Since iOS 16 (2022)
Always provide fallbacks using the <picture> element:
<picture>
<!-- AVIF for best compression -->
<source srcset="image.avif" type="image/avif">
<!-- WebP fallback -->
<source srcset="image.webp" type="image/webp">
<!-- JPEG fallback -->
<img src="image.jpg" alt="Description">
</picture>Future of AVIF
AVIF continues to evolve with:
- Hardware Acceleration: Native decode support in modern GPUs and mobile processors
- Faster Encoders: Optimized implementations reducing encoding time by 10-50×
- Wider Adoption: CDNs and image optimization services adding AVIF support
- Enhanced Features: Film grain synthesis, depth maps, and advanced metadata
Ready to Compress AVIF Images?
Use our free online AVIF compressor to reduce file sizes by up to 90% while maintaining excellent visual quality. Supports batch processing with no registration required.
Compress AVIF Images Now →