@@ -1485,7 +1485,7 @@ pub fn encode_block_post_cdef<T: Pixel>(
1485
1485
skip : bool , cfl : CFLParams , tx_size : TxSize , tx_type : TxType ,
1486
1486
mode_context : usize , mv_stack : & [ CandidateMV ] , rdo_type : RDOType ,
1487
1487
need_recon_pixel : bool , record_stats : bool ,
1488
- ) -> i64 {
1488
+ ) -> ( bool , i64 ) {
1489
1489
let is_inter = !luma_mode. is_intra ( ) ;
1490
1490
if is_inter {
1491
1491
assert ! ( luma_mode == chroma_mode) ;
@@ -1758,13 +1758,14 @@ pub fn write_tx_blocks<T: Pixel>(
1758
1758
chroma_mode : PredictionMode , tile_bo : TileBlockOffset , bsize : BlockSize ,
1759
1759
tx_size : TxSize , tx_type : TxType , skip : bool , cfl : CFLParams ,
1760
1760
luma_only : bool , rdo_type : RDOType , need_recon_pixel : bool ,
1761
- ) -> i64 {
1761
+ ) -> ( bool , i64 ) {
1762
1762
let bw = bsize. width_mi ( ) / tx_size. width_mi ( ) ;
1763
1763
let bh = bsize. height_mi ( ) / tx_size. height_mi ( ) ;
1764
1764
let qidx = get_qidx ( fi, ts, cw, tile_bo) ;
1765
1765
1766
1766
let PlaneConfig { xdec, ydec, .. } = ts. input . planes [ 1 ] . cfg ;
1767
1767
let mut ac: AlignedArray < [ i16 ; 32 * 32 ] > = AlignedArray :: uninitialized ( ) ;
1768
+ let mut partition_has_coeff: bool = false ;
1768
1769
let mut tx_dist: i64 = 0 ;
1769
1770
let do_chroma = has_chroma ( tile_bo, bsize, xdec, ydec) ;
1770
1771
@@ -1785,7 +1786,7 @@ pub fn write_tx_blocks<T: Pixel>(
1785
1786
} ) ;
1786
1787
1787
1788
let po = tx_bo. plane_offset ( & ts. input . planes [ 0 ] . cfg ) ;
1788
- let ( _ , dist) = encode_tx_block (
1789
+ let ( has_coeff , dist) = encode_tx_block (
1789
1790
fi,
1790
1791
ts,
1791
1792
cw,
@@ -1806,6 +1807,7 @@ pub fn write_tx_blocks<T: Pixel>(
1806
1807
rdo_type,
1807
1808
need_recon_pixel,
1808
1809
) ;
1810
+ partition_has_coeff |= has_coeff;
1809
1811
assert ! (
1810
1812
!fi. use_tx_domain_distortion || need_recon_pixel || skip || dist >= 0
1811
1813
) ;
@@ -1814,7 +1816,7 @@ pub fn write_tx_blocks<T: Pixel>(
1814
1816
}
1815
1817
1816
1818
if luma_only {
1817
- return tx_dist;
1819
+ return ( partition_has_coeff , tx_dist) ;
1818
1820
} ;
1819
1821
1820
1822
let uv_tx_size = bsize. largest_chroma_tx_size ( xdec, ydec) ;
@@ -1870,7 +1872,7 @@ pub fn write_tx_blocks<T: Pixel>(
1870
1872
let mut po = tile_bo. plane_offset ( & ts. input . planes [ p] . cfg ) ;
1871
1873
po. x += ( bx * uv_tx_size. width ( ) ) as isize ;
1872
1874
po. y += ( by * uv_tx_size. height ( ) ) as isize ;
1873
- let ( _ , dist) = encode_tx_block (
1875
+ let ( has_coeff , dist) = encode_tx_block (
1874
1876
fi,
1875
1877
ts,
1876
1878
cw,
@@ -1891,6 +1893,7 @@ pub fn write_tx_blocks<T: Pixel>(
1891
1893
rdo_type,
1892
1894
need_recon_pixel,
1893
1895
) ;
1896
+ partition_has_coeff |= has_coeff;
1894
1897
assert ! (
1895
1898
!fi. use_tx_domain_distortion
1896
1899
|| need_recon_pixel
@@ -1903,7 +1906,7 @@ pub fn write_tx_blocks<T: Pixel>(
1903
1906
}
1904
1907
}
1905
1908
1906
- tx_dist
1909
+ ( partition_has_coeff , tx_dist)
1907
1910
}
1908
1911
1909
1912
// FIXME: For now, assume tx_mode is LARGEST_TX, so var-tx is not implemented yet,
@@ -1914,14 +1917,18 @@ pub fn write_tx_tree<T: Pixel>(
1914
1917
tile_bo : TileBlockOffset , bsize : BlockSize , tx_size : TxSize ,
1915
1918
tx_type : TxType , skip : bool , luma_only : bool , rdo_type : RDOType ,
1916
1919
need_recon_pixel : bool ,
1917
- ) -> i64 {
1920
+ ) -> ( bool , i64 ) {
1921
+ if skip {
1922
+ return ( false , -1 ) ;
1923
+ }
1918
1924
let bw = bsize. width_mi ( ) / tx_size. width_mi ( ) ;
1919
1925
let bh = bsize. height_mi ( ) / tx_size. height_mi ( ) ;
1920
1926
let qidx = get_qidx ( fi, ts, cw, tile_bo) ;
1921
1927
1922
1928
let PlaneConfig { xdec, ydec, .. } = ts. input . planes [ 1 ] . cfg ;
1923
1929
let ac = & [ 0i16 ; 0 ] ;
1924
1930
let mut tx_dist: i64 = 0 ;
1931
+ let mut partition_has_coeff: bool = false ;
1925
1932
1926
1933
ts. qc . update (
1927
1934
qidx,
@@ -1954,13 +1961,14 @@ pub fn write_tx_tree<T: Pixel>(
1954
1961
rdo_type,
1955
1962
need_recon_pixel,
1956
1963
) ;
1964
+ partition_has_coeff |= has_coeff;
1957
1965
assert ! (
1958
1966
!fi. use_tx_domain_distortion || need_recon_pixel || skip || dist >= 0
1959
1967
) ;
1960
1968
tx_dist += dist;
1961
1969
1962
1970
if luma_only {
1963
- return tx_dist;
1971
+ return ( partition_has_coeff , tx_dist) ;
1964
1972
} ;
1965
1973
1966
1974
let uv_tx_size = bsize. largest_chroma_tx_size ( xdec, ydec) ;
@@ -2008,7 +2016,7 @@ pub fn write_tx_tree<T: Pixel>(
2008
2016
let mut po = tile_bo. plane_offset ( & ts. input . planes [ p] . cfg ) ;
2009
2017
po. x += ( bx * uv_tx_size. width ( ) ) as isize ;
2010
2018
po. y += ( by * uv_tx_size. height ( ) ) as isize ;
2011
- let ( _ , dist) = encode_tx_block (
2019
+ let ( has_coeff , dist) = encode_tx_block (
2012
2020
fi,
2013
2021
ts,
2014
2022
cw,
@@ -2029,6 +2037,7 @@ pub fn write_tx_tree<T: Pixel>(
2029
2037
rdo_type,
2030
2038
need_recon_pixel,
2031
2039
) ;
2040
+ partition_has_coeff |= has_coeff;
2032
2041
assert ! (
2033
2042
!fi. use_tx_domain_distortion
2034
2043
|| need_recon_pixel
@@ -2041,7 +2050,7 @@ pub fn write_tx_tree<T: Pixel>(
2041
2050
}
2042
2051
}
2043
2052
2044
- tx_dist
2053
+ ( partition_has_coeff , tx_dist)
2045
2054
}
2046
2055
2047
2056
pub fn encode_block_with_modes < T : Pixel > (
@@ -2055,7 +2064,7 @@ pub fn encode_block_with_modes<T: Pixel>(
2055
2064
let cfl = mode_decision. pred_cfl_params ;
2056
2065
let ref_frames = mode_decision. ref_frames ;
2057
2066
let mvs = mode_decision. mvs ;
2058
- let skip = mode_decision. skip ;
2067
+ let mut skip = mode_decision. skip ;
2059
2068
let mut cdef_coded = cw. bc . cdef_coded ;
2060
2069
let ( tx_size, tx_type) = ( mode_decision. tx_size , mode_decision. tx_type ) ;
2061
2070
@@ -2075,6 +2084,9 @@ pub fn encode_block_with_modes<T: Pixel>(
2075
2084
let mode_context =
2076
2085
cw. find_mvrefs ( tile_bo, ref_frames, & mut mv_stack, bsize, fi, is_compound) ;
2077
2086
2087
+ if !mode_decision. skip && !mode_decision. has_coeff {
2088
+ skip = true ;
2089
+ }
2078
2090
cdef_coded = encode_block_pre_cdef (
2079
2091
& fi. sequence ,
2080
2092
ts,
0 commit comments