# 率失真优化

率失真优化（Rate–distortion optimization，RDO）是视频与图像编码中的一种编码器控制技术，它在码率约束下通过最小化重建失真来选择编码参数，采用拉格朗日代价 \( J = D + \lambda \cdot R \)。<sup>[1](https://www.frontiersin.org/journals/signal-processing/articles/10.3389/frsip.2023.1205104/full)</sup> 编码器不是对每个块采用碰巧最省比特的编码模式，而是用每个候选决策所耗费的比特和留下的误差两方面来衡量。RDO 核心的[拉格朗日乘子](https://www.edgepedia.org/zh/lagrange-multiplier)方法至今仍是现代视频编解码器的核心机制。<sup>[1](https://www.frontiersin.org/journals/signal-processing/articles/10.3389/frsip.2023.1205104/full)</sup>

| 关键事实 | 详情 |
|---|---|
| 决策单元 | 对 \( D + \lambda \cdot R \) 的逐块或逐子集独立最小化，应用于运动矢量、参考索引、帧内模式、宏块模式和变换系数级别<sup>[2](https://www.hhi.fraunhofer.de/en/departments/vca/research-groups/video-coding-technologies/research-topics/past-research-topics/rate-distortion-optimization-rdo-for-encoder-control.html)</sup> |
| 失真度量 | 原始样本与重建样本之间的 SAD（p = 1）和 SSD/SSE（p = 2）；基于 SSIM 的变体使用 \( J = (1 - \mathrm{SSIM}) + \lambda \cdot R \)<sup>[2](https://www.hhi.fraunhofer.de/en/departments/vca/research-groups/video-coding-technologies/research-topics/past-research-topics/rate-distortion-optimization-rdo-for-encoder-control.html)</sup><sup> • </sup><sup>[3](https://ece.uwaterloo.ca/~z70wang/publications/TCSVT_SSIM_RDO.pdf)</sup> |
| 典型 λ–QP 模型 | \( \lambda_{\mathrm{H.264(I)}} = 0.57 \cdot 2^{\frac{\mathrm{QP}-12}{3}} \)<sup>[4](https://ar5iv.labs.arxiv.org/html/2106.08141)</sup> |
| 使用 RDO 的标准 | H.262/MPEG-2 Video、H.263、MPEG-4 Visual、H.264/MPEG-4 AVC 和 HEVC<sup>[2](https://www.hhi.fraunhofer.de/en/departments/vca/research-groups/video-coding-technologies/research-topics/past-research-topics/rate-distortion-optimization-rdo-for-encoder-control.html)</sup> |
| 最坏情况搜索增长 | HEVC：每个 64×64 CTU 最多 341 个块；VVC：最多 721k 个块，约多 2000 倍<sup>[5](https://sigport.org/sites/default/files/docs/RD_Cost_Regression_Speed_Up_Technique_For_vvc_intra_block_Partitioning%20%284%29.pdf)</sup> |
| 量化变体 | VVC 中的网格编码量化在全帧内配置下比 RDOQ 节省 3.5%，在随机接入配置下节省 2.4%<sup>[6](https://ar5iv.labs.arxiv.org/html/2008.11420)</sup> |

## 工作原理

编码器的任务是选择语法元素，从而选择码流，使得输入序列与其重建之间的失真 \( D(s, s') \) 在平均码率、最大码率和编码延迟的约束下最小化。<sup>[2](https://www.hhi.fraunhofer.de/en/departments/vca/research-groups/video-coding-technologies/research-topics/past-research-topics/rate-distortion-optimization-rdo-for-encoder-control.html)</sup> 这个约束问题，即 \( \min D \) 满足 \( R \le R_C \)，被重新表述为 \( J = D + \lambda \cdot R \) 的无约束最小化，其中非负拉格朗日乘子 \( \lambda \) 控制码率与失真之间的权衡。<sup>[3](https://ece.uwaterloo.ca/~z70wang/publications/TCSVT_SSIM_RDO.pdf)</sup> 每个 \( \lambda \) 值在率失真曲线上选择一个工作点。<sup>[1](https://www.frontiersin.org/journals/signal-processing/articles/10.3389/frsip.2023.1205104/full)</sup>

该表述之所以实用，是因为它可以分解。当图像各子集的编码决策 \( p_i \) 相互独立且失真是可加的，全局问题就分解为对 \( D_{k,i}(p_i) + \lambda \cdot R_{k,i}(p_i) \) 的逐子集独立最小化。<sup>[2](https://www.hhi.fraunhofer.de/en/departments/vca/research-groups/video-coding-technologies/research-topics/past-research-topics/rate-distortion-optimization-rdo-for-encoder-control.html)</sup> 这正是 RDO 成为逐块、逐模式决策过程而非逐序列搜索的原因。

## 实现方式

编码器循环运行如下。首先，候选生成：受码率约束的[运动估计](https://www.edgepedia.org/zh/motion-estimation)在运动矢量上最小化 \( D + \lambda \cdot R \)，使用 SAD（p = 1）或 SSD（p = 2）失真，例如在 ±16 整数像素位置搜索并进行半像素精化。<sup>[7](https://web.stanford.edu/~bgirod/pdfs/ICIP2001.pdf)</sup> 其次，失真与码率测量：在 H.263 风格的宏块控制中，代价按模式在集合 {INTRA, SKIP, INTER, INTER+4V} 上计算，失真为重建宏块像素与原始宏块像素之间的 SSD，码率取自游程级别可变长编码。<sup>[7](https://web.stanford.edu/~bgirod/pdfs/ICIP2001.pdf)</sup> 在 HEVC 中，最佳模式通过比较 \( J = \mathrm{SSE} + \lambda \times \mathrm{Bits} \) 来决定。<sup>[8](https://www.sciencedirect.com/science/article/abs/pii/S0141938215000979)</sup>

拉格朗日优化应用于运动矢量确定、参考索引选择、帧内预测模式、宏块编码模式和变换系数级别。<sup>[2](https://www.hhi.fraunhofer.de/en/departments/vca/research-groups/video-coding-technologies/research-topics/past-research-topics/rate-distortion-optimization-rdo-for-encoder-control.html)</sup> 实际编码器对不同阶段使用不同的乘子：x265 风格的 RDO 使用 \( J_{\mathrm{SAD}} = D_{\mathrm{SAD}}(s,c) + \lambda_{\mathrm{MOTION}} \cdot R \)，而对于基于 SSE 的模式决策，乘子满足 \( \lambda_{\mathrm{MODE}} = (\lambda_{\mathrm{SAD}})^2 \)。<sup>[9](https://library.imaging.org/admin/apis/public/api/ist/website/downloadArticle/ei/33/10/art00013)</sup> 量化本身在 RDOQ 中优化，其代价为 \( \mathrm{RD\_cost} = D + \lambda \cdot B \)，分三个阶段运行：变换系数量化、系数组消除和最后一个非零系数的选择。<sup>[10](https://www.multimedia.edu.pl/publications/Rate-distortion-optimized-quantization-in-HEVC-performance-limitations.pdf)</sup>

对于 H.264/AVC，乘子为 \( \lambda_I = 0.57 \cdot 2^{\frac{\mathrm{QP}-12}{3}} \)、\( \lambda_P = 0.85 \cdot 2^{\frac{\mathrm{QP}-12}{3}} \)，以及 B 帧公式 \( \lambda_B = 0.68 \cdot \max(2, \min(4, (\mathrm{QP}-12)/6)) \cdot 2^{\frac{\mathrm{QP}-12}{3}} \)。<sup>[4](https://ar5iv.labs.arxiv.org/html/2106.08141)</sup> HEVC 使用修订模型，例如 \( \lambda_{\mathrm{HEVC(I)}} = (1 - \max(0, \min(0.5, 0.05 N_B))) \cdot 0.57 \cdot 2^{\frac{\mathrm{QP}-12}{3}} \)，其中 \( N_B \) 与分层 B 帧结构有关。<sup>[4](https://ar5iv.labs.arxiv.org/html/2106.08141)</sup> 当前编码器版本使用查找表从 QP 和帧级信息为每帧推导 \( \lambda_{\mathrm{MODE}} \)。<sup>[9](https://library.imaging.org/admin/apis/public/api/ist/website/downloadArticle/ei/33/10/art00013)</sup>

## 起源

拉格朗日乘子方法于 1998 年由 G.J. Sullivan 和 T. Wiegand 在《IEEE 信号处理杂志》的“视频压缩的率失真优化”一文中提倡用于视频压缩。<sup>[11](https://doi.org/10.1109/79.733497)</sup> 将率失真优化的模式选择应用于极低码率视频编码和新兴的 H.263 标准的更早应用，由 T. Wiegand 及其同事于 1996 年发表在《IEEE 视频技术电路与系统汇刊》上。<sup>[12](https://doi.org/10.1109/76.488825)</sup> 将 \( \lambda \) 作为量化参数 QP 函数的预测模型由 Sullivan 和 Wiegand 建立，并部署在 H.264/AVC 和 HEVC 参考编码器中，后来为 VP9 和 AV1 建立了类似模型。<sup>[1](https://www.frontiersin.org/journals/signal-processing/articles/10.3389/frsip.2023.1205104/full)</sup> 标准化模型起源于 2018 年之前约 20 年，基于熵约束高速率近似以及在有限测试素材上用 H.263 参考编码器进行的实验。<sup>[13](https://ieeexplore.ieee.org/document/8482327)</sup>

## 变体

量化是 RDO 最显著专门化的地方。“率失真优化量化（RDOQ）”这一名称是在 KTA 工作中提出的，此前该方法已被提议用于 JPEG 和 MPEG 以及 MPEG-4 AVC。<sup>[10](https://www.multimedia.edu.pl/publications/Rate-distortion-optimized-quantization-in-HEVC-performance-limitations.pdf)</sup> RDOQ 需要对多个候选进行穷举搜索，通过比较它们的率失真代价来确定最优量化级别，这导致 H.264/AVC 中相当高的复杂度；一种快速方案排除不太可能的候选并使用码率估计模型代替实际 CABAC 熵编码，平均减少 RDOQ 时间 60.5%，同时具有更优的 RD 性能。<sup>[14](https://link.springer.com/article/10.1007/s11760-013-0474-x)</sup>

VVC 采用网格编码量化（TCQ），也称为依赖量化，与 RDOQ 并存，最小化相同的拉格朗日代价 \( J = D + \lambda \cdot R \)。<sup>[6](https://ar5iv.labs.arxiv.org/html/2008.11420)</sup> 一种低复杂度 TCQ 方案在全帧内配置下降低编码复杂度 11%，在随机接入配置下降低 5%，代价仅为 0.11% 和 0.05% 的 BD 码率增加，并被 VVC 测试模型采纳。<sup>[6](https://ar5iv.labs.arxiv.org/html/2008.11420)</sup> 对于感知优化，基于 SSIM 的 RDO 用代价 \( J = (1 - \mathrm{SSIM}) + \lambda \cdot R \) 替代平方误差失真，对于 H.264/AVC 建议乘子为 \( \lambda = 0.85 \cdot 2^{\frac{\mathrm{QP}-12}{3}} \)。<sup>[3](https://ece.uwaterloo.ca/~z70wang/publications/TCSVT_SSIM_RDO.pdf)</sup> 对于 VVC，2025 年的一种方法在 RDO 代价中用基于 WPSNR 的加权 SSE 度量替代传统 SSE，\( \min_{p_k} w_k \cdot D_k^{\mathrm{SSE}}(p_k) + \lambda \cdot R_k(p_k) \)，并通过 QP 增量偏移在基础 QP 周围对每个块评估十三个 QP 值。<sup>[15](https://link.springer.com/article/10.1007/s11227-025-06954-z)</sup>

## 应用

R-D 优化的编码器控制已应用于 H.262/MPEG-2 Video、H.263、MPEG-4 Visual、H.264/MPEG-4 AVC 和 HEVC。<sup>[2](https://www.hhi.fraunhofer.de/en/departments/vca/research-groups/video-coding-technologies/research-topics/past-research-topics/rate-distortion-optimization-rdo-for-encoder-control.html)</sup> 当前编码标准包括 H.264/AVC、H.265/HEVC、H.266/VVC，以及自 2025 年底定稿以来的 AOMedia 的 AV2。这些标准的编码器通常使用率失真优化，但标准本身只规定码流和解码过程，不规定特定的编码器优化，因此 RDO 中使用的码率和失真度量取决于实现，而非固定为每像素比特数和 PSNR。<sup>[16](https://pmc.ncbi.nlm.nih.gov/articles/PMC12025864/)</sup>

该框架也在扩展到学习式压缩。率–失真–感知权衡定义 \( R(D,P) = \min_{P_{\hat{X}|X}} I(X;\hat{X}) \) 满足 \( E[\Delta(X,\hat{X})] \le D \) 和统计散度 \( \delta(P_X, P_{\hat{X}}) \le P \)；以额外感知损失训练的神经网络压缩器最小化 \( \min_{\theta} E[-\log p_{\hat{y}}(\hat{y})] + \lambda_1 E[\Delta(x,\hat{x})] + \lambda_2 \delta(P_x, P_{\hat{x}}) \)。<sup>[17](https://arxiv.org/html/2503.17558v1)</sup> 在神经视频编码中，学习式码率控制将问题表述为在一个 GoP 上 \( \min \sum_i R_i + \lambda_i \cdot D_i \) 满足 \( \sum_i R_i < R_c \)；一个 2025 年框架报告相对于领先基准平均码率降低 13.1%，平均码率误差 1.66%。<sup>[18](https://arxiv.org/html/2508.20709)</sup> 对于学习式图像压缩，RDONet 使用零遍 RDO，完全依赖估计掩码而不测试多种划分可能性。<sup>[19](https://archive.compression.cc/2022/static/publications/10.pdf)</sup> 在基于矢量量化的生成式图像压缩中，从潜在表示到离散索引上码率的映射不可微，因此恢复可微性是基于 VQ 的 RDO 的核心挑战。<sup>[20](https://openaccess.thecvf.com/content/CVPR2026/papers/Jiang_Differentiable_Vector_Quantization_for_Rate-Distortion_Optimization_of_Generative_Image_Compression_CVPR_2026_paper.pdf)</sup>

## 局限与替代方案

最坏情况搜索空间随划分自由度急剧增长。在 HEVC 帧内条带中，64×64 CTU 上的完全因果 RDO 最多测试 341 个块；在 VVC 中，使用多类型树划分，同一 CTU 最多测试 721k 个块。从 HEVC 到 VVC，最坏情况 RDO 需要测试约 2000 倍的块数，重建约 1000 倍的像素。<sup>[5](https://sigport.org/sites/default/files/docs/RD_Cost_Regression_Speed_Up_Technique_For_vvc_intra_block_Partitioning%20%284%29.pdf)</sup> 精确 RDOQ 计算比快速 HM 实现耗时 3 至 4 倍，后者以显著更低的复杂度提供约 1% 的性能下降。<sup>[10](https://www.multimedia.edu.pl/publications/Rate-distortion-optimized-quantization-in-HEVC-performance-limitations.pdf)</sup>

已记录的主要失效模式是度量失配和次优乘子。SAD 和 MSE 等失真度量因与感知质量相关性不佳而广受批评，这推动了基于 SSIM 的 RDO。<sup>[3](https://ece.uwaterloo.ca/~z70wang/publications/TCSVT_SSIM_RDO.pdf)</sup> 一项 2018 年对 H.264/AVC 和 HEVC 参考编码器的研究发现，原始乘子选择方法在 I 帧和 P 帧上达到最优率失真性能，但在 B 帧上失效；一种基于失真统计的方法在恒定 QP 下平均获得约 3% 的 BD 节省，在非零 QP 偏移下获得 0.5%。<sup>[13](https://ieeexplore.ieee.org/document/8482327)</sup> 实际编码器的 \( \lambda \) 估计也偏离最优拉格朗日乘子。<sup>[1](https://www.frontiersin.org/journals/signal-processing/articles/10.3389/frsip.2023.1205104/full)</sup> 在比较方面，TCQ 在 VTM-1.0 的全帧内和随机接入配置下比 RDOQ 分别节省 3.5% 和 2.4% 码率，<sup>[6](https://ar5iv.labs.arxiv.org/html/2008.11420)</sup> 而工具的限制使完整 RDO 与非 RDO 编码之间实际运行时间的直接量化比较变得复杂：RDO 关闭选项存在于 H.264/AVC 参考软件 JM18.0 中，但不存在于 HEVC 参考软件 HM5.0 中。<sup>[8](https://www.sciencedirect.com/science/article/abs/pii/S0141938215000979)</sup>

## References

1. [The disparity between optimal and practical Lagrangian multiplier estimation in video encoders (Frontiers in Signal Processing, 2023)](https://www.frontiersin.org/journals/signal-processing/articles/10.3389/frsip.2023.1205104/full)
2. [Rate-Distortion Optimization (RDO) for Encoder Control (Fraunhofer HHI)](https://www.hhi.fraunhofer.de/en/departments/vca/research-groups/video-coding-technologies/research-topics/past-research-topics/rate-distortion-optimization-rdo-for-encoder-control.html)
3. [SSIM-based rate-distortion optimization (IEEE TCSVT)](https://ece.uwaterloo.ca/~z70wang/publications/TCSVT_SSIM_RDO.pdf)
4. [An adaptive Lagrange multiplier determination method for rate-distortion optimisation in hybrid video codecs (arXiv 2106.08141)](https://ar5iv.labs.arxiv.org/html/2106.08141)
5. [RD-Cost Regression Speed Up Technique for VVC Intra Block Partitioning (IEEE SigPort)](https://sigport.org/sites/default/files/docs/RD_Cost_Regression_Speed_Up_Technique_For_vvc_intra_block_Partitioning%20%284%29.pdf)
6. [Low Complexity Trellis-Coded Quantization in Versatile Video Coding (arXiv 2008.11420)](https://ar5iv.labs.arxiv.org/html/2008.11420)
7. [Lagrange multiplier selection in hybrid video coder control (ICIP 2001)](https://web.stanford.edu/~bgirod/pdfs/ICIP2001.pdf)
8. [Simplified algorithms for rate-distortion optimization in high efficiency video coding (ScienceDirect)](https://www.sciencedirect.com/science/article/abs/pii/S0141938215000979)
9. [HEVC rate-distortion optimization with source modeling (Imaging Science & Technology)](https://library.imaging.org/admin/apis/public/api/ist/website/downloadArticle/ei/33/10/art00013)
10. [Rate-distortion optimized quantization in HEVC, performance limitations](https://www.multimedia.edu.pl/publications/Rate-distortion-optimized-quantization-in-HEVC-performance-limitations.pdf)
11. [G.J. Sullivan, T. Wiegand (1998). Rate-distortion optimization for video compression. IEEE Signal Processing Magazine.](https://doi.org/10.1109/79.733497)
12. [T. Wiegand and colleagues (1996). Rate-distortion optimized mode selection for very low bit rate video coding and the emerging H.263 standard. IEEE Transactions on Circuits and Systems for Video Technology.](https://doi.org/10.1109/76.488825)
13. [Lagrange multiplier determination for B frames in H.264/AVC and HEVC (IEEE)](https://ieeexplore.ieee.org/document/8482327)
14. [High-speed implementation of rate-distortion optimized quantization for H.264/AVC (Signal, Image and Video Processing)](https://link.springer.com/article/10.1007/s11760-013-0474-x)
15. [Perceptual QP optimization for VVC with dual hybrid neural networks (The Journal of Supercomputing, 2025)](https://link.springer.com/article/10.1007/s11227-025-06954-z)
16. [Rate–Distortion–Perception Trade-Off in Information Theory, Generative Models, and Intelligent Communications (PMC)](https://pmc.ncbi.nlm.nih.gov/articles/PMC12025864/)
17. [Optimal Neural Compressors for the Rate-Distortion-Perception Tradeoff (arXiv 2503.17558)](https://arxiv.org/html/2503.17558v1)
18. [Learned Rate Control for Frame-Level Adaptive Neural Video Compression via Dynamic Neural Network (arXiv 2508.20709)](https://arxiv.org/html/2508.20709)
19. [RDONet: Rate-Distortion Optimized Learned Image Compression with Variable Depth (DCC 2022)](https://archive.compression.cc/2022/static/publications/10.pdf)
20. [Differentiable Vector Quantization for Rate-Distortion Optimization of Generative Image Compression (CVPR 2026)](https://openaccess.thecvf.com/content/CVPR2026/papers/Jiang_Differentiable_Vector_Quantization_for_Rate-Distortion_Optimization_of_Generative_Image_Compression_CVPR_2026_paper.pdf)

---
*Initially written Sep 29, 2026 · Edited: Oct 15, 2026*

Topic: 技术与人造世界 › 计算技术与数字系统 › 人工智能与数据 › Algorithms and computational methods › Optimization and dynamic programming › Applied and graph-based optimization

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/rate-distortion-optimization

English original: https://www.edgepedia.org/rate-distortion-optimization
