Merge branch 'simplify/s9' into simplify/w2
Browse files at this commit7 changed files +18 -226
- crates/ec-h265/examples/hevc_gop.rs +0 -7
- crates/ec-h265/src/ctu.rs +10 -132
- crates/ec-h265/src/dec/cu_syntax.rs +5 -9
- crates/ec-h265/src/dec/cu_syntax/wpp.rs +1 -1
- crates/ec-h265/src/dec/picjob.rs +0 -1
- crates/ec-h265/src/enc_p.rs +1 -1
- crates/ec-h265/src/encoder.rs +1 -75
crates/ec-h265/examples/hevc_gop.rsmodified+0 -7
| @@ -93,13 +93,6 @@ fn run() -> Result<(), String> { | ||
| 93 | 93 | cfg.keep_recon = true; |
| 94 | 94 | // Optional trailing flags: `sh` turns sign data hiding on. |
| 95 | 95 | cfg.sign_hiding = args.iter().skip(9).any(|a| a == "sh"); |
| 96 | - // Sweep override of the P-mode decision lambda scale (experiments only). | |
| 97 | - if let Some(v) = std::env::var("EC_INTER_LAMBDA_SCALE") | |
| 98 | - .ok() | |
| 99 | - .and_then(|v| v.parse::<f64>().ok()) | |
| 100 | - { | |
| 101 | - cfg.inter_lambda_scale = v; | |
| 102 | - } | |
| 103 | 96 | // Experiments: worker threads and the P-picture wavefront (`0` or `off`). |
| 104 | 97 | if let Some(v) = std::env::var("EC_H265_THREADS") |
| 105 | 98 | .ok() |
crates/ec-h265/src/ctu.rsmodified+10 -132
| @@ -180,10 +180,6 @@ pub struct CtuEncoder<'a> { | ||
| 180 | 180 | strong_smoothing: bool, |
| 181 | 181 | /// How many of the 35 modes get a full rate-distortion trial. |
| 182 | 182 | candidates: usize, |
| 183 | - /// Whether the chroma mode is chosen by rate-distortion or always derived. | |
| 184 | - chroma_rd: bool, | |
| 185 | - /// Weight on chroma SSD in that decision, against luma's lambda. | |
| 186 | - chroma_rd_weight: f64, | |
| 187 | 183 | /// Whether an 8x8 coding unit may split into four 4x4 intra partitions. |
| 188 | 184 | intra_nxn: bool, |
| 189 | 185 | sign_hiding: bool, |
| @@ -196,9 +192,6 @@ pub struct CtuEncoder<'a> { | ||
| 196 | 192 | /// The skip decision for the 4x4 luma block currently in the scratch. |
| 197 | 193 | ts_luma: bool, |
| 198 | 194 | rqt: bool, |
| 199 | - /// Whether a 64x64 coding tree block may stay one coding unit rather than | |
| 200 | - /// always splitting to 32x32. | |
| 201 | - cu64: bool, | |
| 202 | 195 | /// The counting CABAC engine that search prices its trials with. |
| 203 | 196 | rdoq_enc: CabacEncoder, |
| 204 | 197 | /// `log2` of the smallest coding unit the search will produce. |
| @@ -232,15 +225,11 @@ impl<'a> CtuEncoder<'a> { | ||
| 232 | 225 | qp: i32, |
| 233 | 226 | strong_smoothing: bool, |
| 234 | 227 | candidates: usize, |
| 235 | - chroma_rd: bool, | |
| 236 | - chroma_rd_weight: f64, | |
| 237 | 228 | intra_nxn: bool, |
| 238 | 229 | sign_hiding: bool, |
| 239 | 230 | rdoq: bool, |
| 240 | - rdoq_estimate: bool, | |
| 241 | 231 | transform_skip: TransformSkip, |
| 242 | 232 | rqt: bool, |
| 243 | - cu64: bool, | |
| 244 | 233 | min_cb_log2: u32, |
| 245 | 234 | bit_depth: u32, |
| 246 | 235 | ) -> CtuEncoder<'a> { |
| @@ -265,8 +254,6 @@ impl<'a> CtuEncoder<'a> { | ||
| 265 | 254 | lambda_satd: lambda_for(qp_bd).sqrt(), |
| 266 | 255 | strong_smoothing, |
| 267 | 256 | candidates: candidates.clamp(1, 35), |
| 268 | - chroma_rd, | |
| 269 | - chroma_rd_weight, | |
| 270 | 257 | intra_nxn, |
| 271 | 258 | sign_hiding, |
| 272 | 259 | rdoq, |
| @@ -274,10 +261,9 @@ impl<'a> CtuEncoder<'a> { | ||
| 274 | 261 | ts_rd: transform_skip == TransformSkip::Rd, |
| 275 | 262 | ts_luma: false, |
| 276 | 263 | rqt, |
| 277 | - cu64, | |
| 278 | 264 | rdoq_enc: { |
| 279 | 265 | let mut enc = CabacEncoder::counter(Contexts::new(qp.clamp(0, 51))); |
| 280 | - enc.set_estimating(rdoq_estimate); | |
| 266 | + enc.set_estimating(true); | |
| 281 | 267 | enc |
| 282 | 268 | }, |
| 283 | 269 | min_cb_log2: min_cb_log2.clamp(MIN_CB_LOG2, 5), |
| @@ -439,16 +425,6 @@ impl<'a> CtuEncoder<'a> { | ||
| 439 | 425 | return self.lambda * (enc.bit_count() - before) as f64 |
| 440 | 426 | + self.code_cu(x, y, log2, depth, enc); |
| 441 | 427 | } |
| 442 | - if log2 > 5 && !self.cu64 { | |
| 443 | - // 64x64 coding units are not searched; the decision starts at 32x32. | |
| 444 | - let before = enc.bit_count(); | |
| 445 | - enc.encode_bin(split_ctx, 1); | |
| 446 | - let mut cost = self.lambda * (enc.bit_count() - before) as f64; | |
| 447 | - for (dx, dy) in [(0, 0), (half, 0), (0, half), (half, half)] { | |
| 448 | - cost += self.code_quadtree(x + dx, y + dy, log2 - 1, depth + 1, enc); | |
| 449 | - } | |
| 450 | - return cost; | |
| 451 | - } | |
| 452 | 428 | |
| 453 | 429 | let start = enc.snapshot(); |
| 454 | 430 | // The z-scan availability map has to go back with everything else: the |
| @@ -646,12 +622,8 @@ impl<'a> CtuEncoder<'a> { | ||
| 646 | 622 | |
| 647 | 623 | // The chroma mode belongs to the coding unit and derives from the |
| 648 | 624 | // first partition's luma mode (8.4.3). |
| 649 | - let (chroma_mode, chroma_idx) = if self.chroma_rd { | |
| 650 | - self.choose_chroma_mode(x, y, 8, MIN_CB_LOG2, modes[0], self.transform_skip, enc) | |
| 651 | - } else { | |
| 652 | - (modes[0], None) | |
| 653 | - }; | |
| 654 | - self.write_chroma_mode_syntax(enc, chroma_idx); | |
| 625 | + let chroma_mode = modes[0]; | |
| 626 | + self.write_chroma_mode_syntax(enc); | |
| 655 | 627 | let cb_cbf = self |
| 656 | 628 | .code_chroma(x, y, 8, chroma_mode, 1, self.transform_skip) |
| 657 | 629 | .1; |
| @@ -742,12 +714,8 @@ impl<'a> CtuEncoder<'a> { | ||
| 742 | 714 | // levels in the luma scratch. |
| 743 | 715 | let mode = self.choose_luma_mode(x, y, HALF, LOG2 - 1, &mpm, enc); |
| 744 | 716 | self.write_mode_syntax(enc, mode, &mpm); |
| 745 | - let (chroma_mode, chroma_idx) = if self.chroma_rd { | |
| 746 | - self.choose_chroma_mode(x, y, HALF, LOG2 - 1, mode, chroma_tskip, enc) | |
| 747 | - } else { | |
| 748 | - (mode, None) | |
| 749 | - }; | |
| 750 | - self.write_chroma_mode_syntax(enc, chroma_idx); | |
| 717 | + let chroma_mode = mode; | |
| 718 | + self.write_chroma_mode_syntax(enc); | |
| 751 | 719 | |
| 752 | 720 | let mut child_levels = [[0i32; 1024]; 4]; |
| 753 | 721 | let mut child_tskip = [self.transform_skip; 4]; |
| @@ -855,12 +823,8 @@ impl<'a> CtuEncoder<'a> { | ||
| 855 | 823 | let mpm = self.mpm_at(x, y); |
| 856 | 824 | let mode = self.choose_luma_mode(x, y, n, log2, &mpm, enc); |
| 857 | 825 | self.write_mode_syntax(enc, mode, &mpm); |
| 858 | - let (chroma_mode, chroma_idx) = if self.chroma_rd { | |
| 859 | - self.choose_chroma_mode(x, y, n, log2, mode, chroma_tskip, enc) | |
| 860 | - } else { | |
| 861 | - (mode, None) | |
| 862 | - }; | |
| 863 | - self.write_chroma_mode_syntax(enc, chroma_idx); | |
| 826 | + let chroma_mode = mode; | |
| 827 | + self.write_chroma_mode_syntax(enc); | |
| 864 | 828 | |
| 865 | 829 | // Luma was reconstructed by the mode search; chroma is coded now. |
| 866 | 830 | let luma_cbf = self.scratch.luma_levels[..n * n].iter().any(|&v| v != 0); |
| @@ -1811,95 +1775,9 @@ impl<'a> CtuEncoder<'a> { | ||
| 1811 | 1775 | |
| 1812 | 1776 | // ---- chroma mode decision -------------------------------------------- |
| 1813 | 1777 | |
| 1814 | - /// Write `intra_chroma_pred_mode`: the single bin 0 for the derived mode, | |
| 1815 | - /// or bin 1 and two bypass bits picking one of the four explicit modes. | |
| 1816 | - fn write_chroma_mode_syntax(&self, enc: &mut CabacEncoder, idx: Option<u32>) { | |
| 1817 | - match idx { | |
| 1818 | - None => enc.encode_bin(ctx::INTRA_CHROMA_PRED_MODE, 0), | |
| 1819 | - Some(i) => { | |
| 1820 | - enc.encode_bin(ctx::INTRA_CHROMA_PRED_MODE, 1); | |
| 1821 | - enc.encode_bypass_bits(i, 2); | |
| 1822 | - } | |
| 1823 | - } | |
| 1824 | - } | |
| 1825 | - | |
| 1826 | - /// Pick the chroma prediction mode by rate-distortion over the five the | |
| 1827 | - /// syntax allows: planar, vertical, horizontal and DC — each replaced by | |
| 1828 | - /// angular 34 when it collides with the luma mode — plus the derived mode, | |
| 1829 | - /// which is the luma mode itself and costs one bin instead of three. | |
| 1830 | - /// | |
| 1831 | - /// Returns the mode and the index to code, `None` meaning derived. Neither | |
| 1832 | - /// the winner's reconstruction nor its levels survive the trial: the caller | |
| 1833 | - /// codes the winner again for real. | |
| 1834 | - #[allow(clippy::too_many_arguments)] | |
| 1835 | - fn choose_chroma_mode( | |
| 1836 | - &mut self, | |
| 1837 | - x: usize, | |
| 1838 | - y: usize, | |
| 1839 | - n: usize, | |
| 1840 | - log2: u32, | |
| 1841 | - luma_mode: u8, | |
| 1842 | - chroma_tskip: bool, | |
| 1843 | - enc: &mut CabacEncoder, | |
| 1844 | - ) -> (u8, Option<u32>) { | |
| 1845 | - let mut explicit = [0u8, 26, 10, 1]; | |
| 1846 | - for mode in explicit.iter_mut() { | |
| 1847 | - if *mode == luma_mode { | |
| 1848 | - *mode = 34; | |
| 1849 | - } | |
| 1850 | - } | |
| 1851 | - let start = enc.snapshot(); | |
| 1852 | - enc.set_counting(true); | |
| 1853 | - let mut best = (f64::MAX, luma_mode, None); | |
| 1854 | - for (i, mode) in explicit | |
| 1855 | - .iter() | |
| 1856 | - .copied() | |
| 1857 | - .enumerate() | |
| 1858 | - .map(|(i, m)| (Some(i as u32), m)) | |
| 1859 | - .chain(std::iter::once((None, luma_mode))) | |
| 1860 | - { | |
| 1861 | - let bits_before = enc.bit_count(); | |
| 1862 | - self.write_chroma_mode_syntax(enc, i); | |
| 1863 | - let (cb_ssd, cb_cbf) = self.code_chroma(x, y, n, mode, 1, chroma_tskip); | |
| 1864 | - let (cr_ssd, cr_cbf) = self.code_chroma(x, y, n, mode, 2, chroma_tskip); | |
| 1865 | - enc.encode_bin(ctx::CBF_CHROMA, u32::from(cb_cbf)); | |
| 1866 | - enc.encode_bin(ctx::CBF_CHROMA, u32::from(cr_cbf)); | |
| 1867 | - let scan = intra::scan_index(mode, log2 - 1, false); | |
| 1868 | - if cb_cbf { | |
| 1869 | - let levels = std::mem::take(&mut self.scratch.cb_levels); | |
| 1870 | - encode_residual( | |
| 1871 | - enc, | |
| 1872 | - &levels[..n * n / 4], | |
| 1873 | - log2 - 1, | |
| 1874 | - 1, | |
| 1875 | - scan, | |
| 1876 | - self.sign_hiding, | |
| 1877 | - self.ts_flag(chroma_tskip), | |
| 1878 | - ); | |
| 1879 | - self.scratch.cb_levels = levels; | |
| 1880 | - } | |
| 1881 | - if cr_cbf { | |
| 1882 | - let levels = std::mem::take(&mut self.scratch.cr_levels); | |
| 1883 | - encode_residual( | |
| 1884 | - enc, | |
| 1885 | - &levels[..n * n / 4], | |
| 1886 | - log2 - 1, | |
| 1887 | - 2, | |
| 1888 | - scan, | |
| 1889 | - self.sign_hiding, | |
| 1890 | - self.ts_flag(chroma_tskip), | |
| 1891 | - ); | |
| 1892 | - self.scratch.cr_levels = levels; | |
| 1893 | - } | |
| 1894 | - let bits = enc.bit_count() - bits_before; | |
| 1895 | - enc.restore(&start); | |
| 1896 | - let cost = self.chroma_rd_weight * (cb_ssd + cr_ssd) + self.lambda * bits as f64; | |
| 1897 | - if cost < best.0 { | |
| 1898 | - best = (cost, mode, i); | |
| 1899 | - } | |
| 1900 | - } | |
| 1901 | - enc.set_counting(false); | |
| 1902 | - (best.1, best.2) | |
| 1778 | + /// Write `intra_chroma_pred_mode` for the derived mode: the single bin 0. | |
| 1779 | + fn write_chroma_mode_syntax(&self, enc: &mut CabacEncoder) { | |
| 1780 | + enc.encode_bin(ctx::INTRA_CHROMA_PRED_MODE, 0); | |
| 1903 | 1781 | } |
| 1904 | 1782 | |
| 1905 | 1783 | // ---- reference samples ----------------------------------------------- |
crates/ec-h265/src/dec/cu_syntax.rsmodified+5 -9
| @@ -184,7 +184,6 @@ pub fn parse_slice_into( | ||
| 184 | 184 | motion: &mut SliceMotion<'_>, |
| 185 | 185 | pic: &mut PicState, |
| 186 | 186 | refs: Option<&InterRefs>, |
| 187 | - sink: &mut dyn FnMut(&CodingUnit), | |
| 188 | 187 | rows: &mut dyn FnMut(&mut PicState, usize), |
| 189 | 188 | ) -> Result<SliceStats> { |
| 190 | 189 | let min_cb_log2 = sps.log2_min_cb_size_minus3 + 3; |
| @@ -310,7 +309,7 @@ pub fn parse_slice_into( | ||
| 310 | 309 | if header.sao_luma || header.sao_chroma { |
| 311 | 310 | p.sao(&mut dec, rs, rx, ry)?; |
| 312 | 311 | } |
| 313 | - p.coding_quadtree(&mut dec, x0, y0, ctb_log2, 0, sink)?; | |
| 312 | + p.coding_quadtree(&mut dec, x0, y0, ctb_log2, 0)?; | |
| 314 | 313 | // The row is complete with its last CTB. Single-tile pictures are in raster order. |
| 315 | 314 | if raster && rx + 1 == cols { |
| 316 | 315 | p.motion.row_done(p.pic, y0 + ctb_size); |
| @@ -574,8 +573,7 @@ impl Parser<'_, '_> { | ||
| 574 | 573 | y0: usize, |
| 575 | 574 | log2: u32, |
| 576 | 575 | depth: u32, |
| 577 | - sink: &mut dyn FnMut(&CodingUnit), | |
| 578 | - ) -> Result<()> { | |
| 576 | + ) -> Result<()> { | |
| 579 | 577 | let n = 1usize << log2; |
| 580 | 578 | let fits = x0 + n <= self.pic.width && y0 + n <= self.pic.height; |
| 581 | 579 | let split = if fits && log2 > self.min_cb_log2 { |
| @@ -604,12 +602,12 @@ impl Parser<'_, '_> { | ||
| 604 | 602 | let half = n / 2; |
| 605 | 603 | for (dx, dy) in [(0, 0), (half, 0), (0, half), (half, half)] { |
| 606 | 604 | if x0 + dx < self.pic.width && y0 + dy < self.pic.height { |
| 607 | - self.coding_quadtree(dec, x0 + dx, y0 + dy, log2 - 1, depth + 1, sink)?; | |
| 605 | + self.coding_quadtree(dec, x0 + dx, y0 + dy, log2 - 1, depth + 1)?; | |
| 608 | 606 | } |
| 609 | 607 | } |
| 610 | 608 | Ok(()) |
| 611 | 609 | } else { |
| 612 | - self.coding_unit(dec, x0, y0, log2, depth, sink) | |
| 610 | + self.coding_unit(dec, x0, y0, log2, depth) | |
| 613 | 611 | } |
| 614 | 612 | } |
| 615 | 613 | |
| @@ -631,8 +629,7 @@ impl Parser<'_, '_> { | ||
| 631 | 629 | y0: usize, |
| 632 | 630 | log2: u32, |
| 633 | 631 | depth: u32, |
| 634 | - sink: &mut dyn FnMut(&CodingUnit), | |
| 635 | - ) -> Result<()> { | |
| 632 | + ) -> Result<()> { | |
| 636 | 633 | let n = 1usize << log2; |
| 637 | 634 | self.stats.cus += 1; |
| 638 | 635 | let is_i = self.header.slice_type == SliceType::I; |
| @@ -771,7 +768,6 @@ impl Parser<'_, '_> { | ||
| 771 | 768 | self.pic.update_info(x0, y0, n, n, |b| b.qp = qp); |
| 772 | 769 | self.stats.pus += cu.pus.len(); |
| 773 | 770 | self.stats.residual_blocks += cu.residuals.len(); |
| 774 | - sink(&cu); | |
| 775 | 771 | Ok(()) |
| 776 | 772 | } |
| 777 | 773 |
crates/ec-h265/src/dec/cu_syntax/wpp.rsmodified+1 -1
| @@ -359,7 +359,7 @@ fn parse_row( | ||
| 359 | 359 | if sao { |
| 360 | 360 | p.sao(&mut dec, rs, x, ry)?; |
| 361 | 361 | } |
| 362 | - p.coding_quadtree(&mut dec, x0, y0, ctb_log2, 0, &mut |_| {})?; | |
| 362 | + p.coding_quadtree(&mut dec, x0, y0, ctb_log2, 0)?; | |
| 363 | 363 | // 9.3.2.2: the wavefront storage after the second CTB of a row. |
| 364 | 364 | let stored = (x == 1 && cols > 1).then(|| dec.contexts.clone()); |
| 365 | 365 | sync.leave(&*p.pic, &mut *p.motion, x, stored.as_ref())?; |
crates/ec-h265/src/dec/picjob.rsmodified+0 -1
| @@ -171,7 +171,6 @@ impl PicJob { | ||
| 171 | 171 | &mut source, |
| 172 | 172 | pic, |
| 173 | 173 | refs.as_ref(), |
| 174 | - &mut |_| {}, | |
| 175 | 174 | &mut rows, |
| 176 | 175 | )?; |
| 177 | 176 | } |
crates/ec-h265/src/enc_p.rsmodified+1 -1
| @@ -624,7 +624,7 @@ impl<'a> PCoder<'a> { | ||
| 624 | 624 | bd, |
| 625 | 625 | qpd, |
| 626 | 626 | qpc, |
| 627 | - lambda: lambda_for(qpd) * enc.cfg.inter_lambda_scale, | |
| 627 | + lambda: lambda_for(qpd), | |
| 628 | 628 | // The search measures SAD on 8-bit samples, so its lambda is the 8-bit one. |
| 629 | 629 | search_lambda: lambda_for(qp).sqrt(), |
| 630 | 630 | sign_hiding: enc.cfg.sign_hiding, |
crates/ec-h265/src/encoder.rsmodified+1 -75
| @@ -126,39 +126,6 @@ pub struct EncoderConfig { | ||
| 126 | 126 | /// knee is where the default sits. `EC_H265_RDO_CANDIDATES` in the gate |
| 127 | 127 | /// test re-runs the sweep. |
| 128 | 128 | pub rdo_candidates: usize, |
| 129 | - /// Whether the chroma prediction mode is chosen by rate-distortion over the | |
| 130 | - /// five modes the syntax allows, instead of always taking the derived mode. | |
| 131 | - /// | |
| 132 | - /// Off by default: measured against x265 on four real clips it is a wash, | |
| 133 | - /// and on screen capture it is a loss (BD-PSNR luma / all-plane, derived | |
| 134 | - /// mode -> search, `chroma_rd_weight: 1.0`): | |
| 135 | - /// | |
| 136 | - /// | clip | derived | search | | |
| 137 | - /// |------|---------|--------| | |
| 138 | - /// | 4K film | -0.685 / -0.703 | -0.757 / **-0.606** | | |
| 139 | - /// | 1138x640 web | -0.507 / -0.556 | -0.584 / **-0.505** | | |
| 140 | - /// | 1440p screen capture | **-2.465 / -2.360** | -2.617 / -2.460 | | |
| 141 | - /// | 1080p phone | -0.366 / **-0.387** | -0.477 / -0.384 | | |
| 142 | - /// | |
| 143 | - /// Luma falls on every clip because the extra chroma bits come out of the | |
| 144 | - /// same budget at a fixed QP; all-plane gains 0.10 dB and 0.05 dB on the two | |
| 145 | - /// camera clips, is flat on the third and loses 0.10 dB on the screen | |
| 146 | - /// capture, for 10-15% more encode time. The average is +0.01 dB all-plane, | |
| 147 | - /// which is not a default. [`EncoderConfig::chroma_rd_weight`] was swept at | |
| 148 | - /// 0.25/0.5/1.0/2.0 and did not change the shape of that table: the screen | |
| 149 | - /// capture loses at every weight, so the cause is not the lambda. | |
| 150 | - pub chroma_mode_search: bool, | |
| 151 | - /// Weight on chroma SSD in that decision, against the luma lambda. Swept | |
| 152 | - /// at 0.25/0.5/1.0/2.0 on three clips; 1.0 is the best of them everywhere | |
| 153 | - /// the search wins at all (4K film all-plane: -0.606 at 1.0 against -0.649 | |
| 154 | - /// at 0.25, -0.619 at 0.5, -0.657 at 2.0). | |
| 155 | - pub chroma_rd_weight: f64, | |
| 156 | - /// Smallest coding unit the search will produce, 8 or 16. Sixteen is a | |
| 157 | - /// *coarser* search that is not always faster: on real pictures the 8x8 | |
| 158 | - /// blocks pay for their search in residual bits (measured: -27% bits and | |
| 159 | - /// +1.5 dB at QP 22 on a 1080p camera frame, at the same wall time), which | |
| 160 | - /// is why 8 is the default. | |
| 161 | - pub min_cu_size: usize, | |
| 162 | 129 | /// Whether an 8x8 coding unit may split into four 4x4 intra partitions |
| 163 | 130 | /// (PART_NxN). On: measured at +2.14 dB BD-PSNR on a 2560x1440 screen |
| 164 | 131 | /// capture (-2.619 dB against x265 without it, -0.479 dB with) and |
| @@ -187,16 +154,6 @@ pub struct EncoderConfig { | ||
| 187 | 154 | /// coder's own price for the whole block, so dropping a level is priced |
| 188 | 155 | /// with the significance map and last position that follow from it. |
| 189 | 156 | pub rdoq: bool, |
| 190 | - /// Whether RDOQ's per-candidate bit cost comes from an estimated | |
| 191 | - /// per-context fractional-bit table (x265/HM `entropyBits`-style: the | |
| 192 | - /// entropy of the bin under its context's current probability state) | |
| 193 | - /// instead of replaying the exact adaptive-CABAC coder for every trial. | |
| 194 | - /// Changes output bytes (the estimate is not exact). On by default: | |
| 195 | - /// measured 1.6x faster on `ec-bench`'s h265 encode row and, on the | |
| 196 | - /// synthetic `bd_psnr_vs_x265` clip, a small BD-PSNR-YUV *gain* over the | |
| 197 | - /// exact-replay path (+7.948 vs +7.880 dB against x265) rather than a | |
| 198 | - /// loss. `false` restores exact per-trial CABAC replay for A/B. | |
| 199 | - pub rdoq_estimate: bool, | |
| 200 | 157 | /// Whether 4x4 TUs may skip the integer transform. |
| 201 | 158 | /// |
| 202 | 159 | /// `Rd` by default: the tool is the screen-content lever, and it wants a |
| @@ -227,19 +184,6 @@ pub struct EncoderConfig { | ||
| 227 | 184 | /// worth +0.010 dB BD-PSNR on film and +0.080 dB on screen capture, which |
| 228 | 185 | /// is where our gap against x265 is (see `lanes/h265-rqt-r1.report.md`). |
| 229 | 186 | pub rqt: bool, |
| 230 | - /// Whether a 64x64 coding tree block may stay one coding unit instead of | |
| 231 | - /// always splitting to 32x32. Only reachable with `ctb_size` 64. | |
| 232 | - /// | |
| 233 | - /// A 64x64 intra coding unit still predicts and transforms in four 32x32 | |
| 234 | - /// blocks -- 32x32 is HEVC's largest transform -- so what it buys is three | |
| 235 | - /// split flags and three mode signallings, and what it costs is one luma | |
| 236 | - /// direction for the whole 64x64. Measured in `lanes/h265-cu64-r1.report.md`. | |
| 237 | - /// | |
| 238 | - /// On by default: against x265 over the four-point ladder it is worth | |
| 239 | - /// +0.007 dB BD-PSNR on film and +0.098 dB on screen capture over always | |
| 240 | - /// splitting a 64x64 tree block, and the default `ctb_size` of 32 leaves | |
| 241 | - /// it unreachable anyway. | |
| 242 | - pub cu64: bool, | |
| 243 | 187 | /// What the samples mean, written into the VUI. |
| 244 | 188 | pub video_signal_type: Option<VideoSignalType>, |
| 245 | 189 | /// Sample aspect ratio. |
| @@ -279,14 +223,6 @@ pub struct EncoderConfig { | ||
| 279 | 223 | /// against off, the single continuous substream the sequential coder writes. |
| 280 | 224 | /// Off also makes P pictures single-threaded. |
| 281 | 225 | pub inter_wpp: bool, |
| 282 | - /// Scale on the lambda the P-picture mode decisions use, against | |
| 283 | - /// `lambda_for(qp)` (the intra lambda, in squared-error units per bit). The | |
| 284 | - /// motion search uses `sqrt(lambda_for(qp))` instead, because it costs SAD. | |
| 285 | - /// | |
| 286 | - /// Measured with `scripts/hevc-bdrate.sh` (ffmpeg PSNR, bframes=0 x265 | |
| 287 | - /// anchor, 352x288, QPs 22/27/32/37), BD-rate against x265: +21.9% at scale 1, | |
| 288 | - /// +23.4% at 1/4, +28.9% at 1/16. Scale 1 is the default. | |
| 289 | - pub inter_lambda_scale: f64, | |
| 290 | 226 | /// Whether a sequence with P pictures (`keyint > 1`) codes its IDR pictures with the |
| 291 | 227 | /// fast intra tool set: no RDOQ, one full-RD intra candidate, no NxN split, no transform |
| 292 | 228 | /// skip trial, no transform-tree split. An IDR is one picture in `keyint`, so what |
| @@ -330,16 +266,11 @@ impl EncoderConfig { | ||
| 330 | 266 | threads: default_threads(), |
| 331 | 267 | ctb_size: 32, |
| 332 | 268 | rdo_candidates: 5, |
| 333 | - chroma_mode_search: false, | |
| 334 | - chroma_rd_weight: 1.0, | |
| 335 | - min_cu_size: 8, | |
| 336 | 269 | intra_nxn: true, |
| 337 | 270 | sign_hiding: false, |
| 338 | 271 | rdoq: true, |
| 339 | - rdoq_estimate: true, | |
| 340 | 272 | transform_skip: TransformSkip::Rd, |
| 341 | 273 | rqt: true, |
| 342 | - cu64: true, | |
| 343 | 274 | video_signal_type: None, |
| 344 | 275 | sample_aspect_ratio: None, |
| 345 | 276 | timing: None, |
| @@ -351,7 +282,6 @@ impl EncoderConfig { | ||
| 351 | 282 | keep_recon: false, |
| 352 | 283 | keyint: 1, |
| 353 | 284 | inter_wpp: true, |
| 354 | - inter_lambda_scale: 1.0, | |
| 355 | 285 | gop_fast_idr: true, |
| 356 | 286 | bit_depth: 8, |
| 357 | 287 | speed: Preset::Default, |
| @@ -885,16 +815,12 @@ impl Encoder { | ||
| 885 | 815 | slice_qp, |
| 886 | 816 | true, |
| 887 | 817 | self.cfg.rdo_candidates, |
| 888 | - self.cfg.chroma_mode_search, | |
| 889 | - self.cfg.chroma_rd_weight, | |
| 890 | 818 | self.cfg.intra_nxn, |
| 891 | 819 | self.cfg.sign_hiding, |
| 892 | 820 | self.cfg.rdoq, |
| 893 | - self.cfg.rdoq_estimate, | |
| 894 | 821 | self.cfg.transform_skip, |
| 895 | 822 | self.cfg.rqt, |
| 896 | - self.cfg.cu64, | |
| 897 | - self.cfg.min_cu_size.max(8).trailing_zeros(), | |
| 823 | + 3, | |
| 898 | 824 | u32::from(self.cfg.bit_depth), |
| 899 | 825 | ); |
| 900 | 826 | for col in 0..cols { |