Skip to content

Commit c6a5abe

Browse files
lu-zerobarrbrain
authored andcommitted
Split the first_pass_qi selection
1 parent eefc4e6 commit c6a5abe

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

src/rate.rs

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -739,6 +739,20 @@ impl RCState {
739739
}
740740
}
741741

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+
742756
// TODO: Separate quantizers for Cb and Cr.
743757
pub(crate) fn select_qi<T: Pixel>(
744758
&self, ctx: &ContextInner<T>, output_frameno: u64, fti: usize,
@@ -777,15 +791,7 @@ impl RCState {
777791
match self.twopass_state {
778792
// First pass of 2-pass mode: use a fixed base quantizer.
779793
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);
789795
}
790796
// Second pass of 2-pass mode: we know exactly how much of each frame
791797
// type there is in the current buffer window, and have estimates for

0 commit comments

Comments
 (0)