@@ -226,7 +226,10 @@ impl Decoder {
226226 }
227227
228228 for plane_name in [ ColorPlane :: Cb , ColorPlane :: Cr ] {
229- let chroma_qp = get_chroma_qp ( qp as i32 , slice. pps . chroma_qp_index_offset , 0 ) . try_into ( ) . unwrap ( ) ;
229+ let chroma_qp =
230+ get_chroma_qp ( qp as i32 , slice. pps . chroma_qp_index_offset , 0 )
231+ . try_into ( )
232+ . unwrap ( ) ;
230233 info ! ( "QP: {qp} chroma qp: {chroma_qp}" ) ;
231234 let chroma_plane = & mut frame. planes [ plane_name as usize ] ;
232235 let residuals = if let Some ( residual) = imb. residual . as_ref ( ) {
@@ -348,7 +351,6 @@ pub fn get_chroma_qp(luma_qp: i32, chroma_qp_offset: i32, qp_bd_offset_c: i32) -
348351 qp_c + qp_bd_offset_c
349352}
350353
351-
352354// Section 8.3.1.1 Derivation process for Intra4x4PredMode
353355pub fn render_luma_4x4_intra_prediction (
354356 slice : & Slice ,
@@ -657,6 +659,7 @@ pub fn render_chroma_intra_prediction(
657659 let loc = Point { x : loc. x >> chroma_shift. width , y : loc. y >> chroma_shift. width } ;
658660 let mb_width = MB_WIDTH >> chroma_shift. width ;
659661 let mb_height = MB_HEIGHT >> chroma_shift. height ;
662+ let offset = point_to_plain_offset ( loc) ;
660663
661664 #[ inline]
662665 fn sum ( slice : & [ u8 ] ) -> u32 {
@@ -670,14 +673,13 @@ pub fn render_chroma_intra_prediction(
670673 let y = loc. y as usize ;
671674 let mut src_row = [ 0 ; 16 ] ;
672675 src_row[ 0 ..mb_width] . copy_from_slice ( & target. row ( y as isize - 1 ) [ x..( x + mb_width) ] ) ;
673- let mut target_slice = target. mut_slice ( point_to_plain_offset ( loc ) ) ;
676+ let mut target_slice = target. mut_slice ( offset ) ;
674677 for row in target_slice. rows_iter_mut ( ) . take ( mb_height) {
675678 row[ 0 ..mb_width] . copy_from_slice ( & src_row[ 0 ..mb_width] ) ;
676679 }
677680 }
678681 Intra_Chroma_Pred_Mode :: Horizontal => {
679682 // Section 8.3.4.2 Specification of Intra_Chroma_Horizontal prediction mode
680- let offset = point_to_plain_offset ( loc) ;
681683 let mut target_slice = target. mut_slice ( PlaneOffset { x : offset. x - 1 , ..offset } ) ;
682684 for row in target_slice. rows_iter_mut ( ) . take ( mb_height) {
683685 let src = row[ 0 ] ;
@@ -686,7 +688,6 @@ pub fn render_chroma_intra_prediction(
686688 }
687689 Intra_Chroma_Pred_Mode :: DC => {
688690 // Section 8.3.4.1 Specification of Intra_Chroma_DC prediction mode
689- let offset = point_to_plain_offset ( loc) ;
690691
691692 // Calculate the sum of all the values at the top of the current block
692693 let mut top_left = None ;
@@ -711,9 +712,10 @@ pub fn render_chroma_intra_prediction(
711712 }
712713
713714 for blk_idx in 0 ..4 {
714- const DEFAULT_VALUE : u32 = 1 << 7 ; // = 1 << ( BitDepthC − 1 )
715+ const DEFAULT_VALUE : u32 = 1 << 7 ; // = 1 << ( BitDepthC − 1 )
715716 let result = match blk_idx {
716- 0 => { // If ( xO, yO ) is equal to ( 0, 0 ) or xO and yO are greater than 0
717+ 0 => {
718+ // If ( xO, yO ) is equal to ( 0, 0 ) or xO and yO are greater than 0
717719 if let ( Some ( left) , Some ( top) ) = ( left_top, top_left) {
718720 ( left + top + 4 ) >> 3
719721 } else if let Some ( s) = top_left {
@@ -724,7 +726,8 @@ pub fn render_chroma_intra_prediction(
724726 DEFAULT_VALUE
725727 }
726728 }
727- 1 => { // If xO is greater than 0 and yO is equal to 0
729+ 1 => {
730+ // If xO is greater than 0 and yO is equal to 0
728731 if let Some ( s) = top_right {
729732 ( s + 2 ) >> 2
730733 } else if let Some ( s) = left_top {
@@ -733,7 +736,8 @@ pub fn render_chroma_intra_prediction(
733736 DEFAULT_VALUE
734737 }
735738 }
736- 2 => { // If xO is equal to 0 and yO is greater than 0
739+ 2 => {
740+ // If xO is equal to 0 and yO is greater than 0
737741 if let Some ( s) = left_bottom {
738742 ( s + 2 ) >> 2
739743 } else if let Some ( s) = top_left {
@@ -742,8 +746,8 @@ pub fn render_chroma_intra_prediction(
742746 DEFAULT_VALUE
743747 }
744748 }
745- 3 => { // If xO is equal to 0 and yO is greater than 0
746- if let ( Some ( left) , Some ( top) ) = ( left_bottom, top_right) {
749+ 3 => {
750+ if let ( Some ( left) , Some ( top) ) = ( left_bottom, top_right) {
747751 ( left + top + 4 ) >> 3
748752 } else if let Some ( s) = top_right {
749753 ( s + 2 ) >> 2
@@ -753,7 +757,7 @@ pub fn render_chroma_intra_prediction(
753757 DEFAULT_VALUE
754758 }
755759 }
756- _ => unreachable ! ( )
760+ _ => unreachable ! ( ) ,
757761 } ;
758762
759763 let mut blk_loc = get_4x4chroma_block_location ( blk_idx) ;
@@ -768,10 +772,7 @@ pub fn render_chroma_intra_prediction(
768772 Intra_Chroma_Pred_Mode :: Plane => {
769773 // Section 8.3.4.4 Specification of Intra_Chroma_Plane prediction mode
770774 // yCF = 0 and xCF = 0
771- let mut offset = point_to_plain_offset ( loc) ;
772- offset. x -= 1 ;
773- offset. y -= 1 ;
774- let target_slice = target. slice ( offset) ;
775+ let target_slice = target. slice ( PlaneOffset { x : offset. x - 1 , y : offset. y - 1 } ) ;
775776 let mut h = 0 ;
776777 let mut top_row = [ 0u8 ; 9 ] ;
777778 top_row. copy_from_slice ( & target_slice[ 0 ] [ 0 ..9 ] ) ;
@@ -793,7 +794,6 @@ pub fn render_chroma_intra_prediction(
793794 let b = ( 34 * h + 32 ) >> 6 ;
794795 let c = ( 34 * v + 32 ) >> 6 ;
795796
796- let offset = point_to_plain_offset ( loc) ;
797797 let mut target_slice = target. mut_slice ( offset) ;
798798 for ( y, row) in target_slice. rows_iter_mut ( ) . take ( mb_height) . enumerate ( ) {
799799 for ( x, pixel) in row. iter_mut ( ) . take ( mb_width) . enumerate ( ) {
0 commit comments