@@ -739,6 +739,20 @@ impl RCState {
739
739
}
740
740
}
741
741
742
+ pub ( crate ) fn select_first_pass_qi (
743
+ & self , bit_depth : usize , fti : usize ,
744
+ ) -> QuantizerParameters {
745
+ // Adjust the quantizer for the frame type, result is Q57:
746
+ let log_q = ( ( self . pass1_log_base_q + ( 1i64 << 11 ) ) >> 12 )
747
+ * ( MQP_Q12 [ fti] as i64 )
748
+ + DQP_Q57 [ fti] ;
749
+ QuantizerParameters :: new_from_log_q (
750
+ self . pass1_log_base_q ,
751
+ log_q,
752
+ bit_depth,
753
+ )
754
+ }
755
+
742
756
// TODO: Separate quantizers for Cb and Cr.
743
757
pub ( crate ) fn select_qi < T : Pixel > (
744
758
& self , ctx : & ContextInner < T > , output_frameno : u64 , fti : usize ,
@@ -777,15 +791,7 @@ impl RCState {
777
791
match self . twopass_state {
778
792
// First pass of 2-pass mode: use a fixed base quantizer.
779
793
PASS_1 => {
780
- // Adjust the quantizer for the frame type, result is Q57:
781
- let log_q = ( ( self . pass1_log_base_q + ( 1i64 << 11 ) ) >> 12 )
782
- * ( MQP_Q12 [ fti] as i64 )
783
- + DQP_Q57 [ fti] ;
784
- return QuantizerParameters :: new_from_log_q (
785
- self . pass1_log_base_q ,
786
- log_q,
787
- ctx. config . bit_depth ,
788
- ) ;
794
+ return self . select_first_pass_qi ( ctx. config . bit_depth , fti) ;
789
795
}
790
796
// Second pass of 2-pass mode: we know exactly how much of each frame
791
797
// type there is in the current buffer window, and have estimates for
0 commit comments