Skip to content

Instantly share code, notes, and snippets.

@dwbuiten
Last active May 20, 2019 19:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dwbuiten/1994c0a305c17b81b667fe99e95284db to your computer and use it in GitHub Desktop.
Save dwbuiten/1994c0a305c17b81b667fe99e95284db to your computer and use it in GitHub Desktop.
diff --git a/src/rate.rs b/src/rate.rs
--- a/src/rate.rs
+++ b/src/rate.rs
@@ -503,30 +503,15 @@ impl RCState {
// All of these initial scale/exp values are from Theora, and have not yet
// been adapted to AV1, so they're certainly wrong.
// The B-frame values especially are simply copies of the P-frame values.
- let i_exp: u8;
- let i_log_scale: i64;
- if ibpp < 1 {
- i_exp = 59;
- i_log_scale = blog64(1997) - q57(QSCALE);
- } else if ibpp < 2 {
- i_exp = 55;
- i_log_scale = blog64(1604) - q57(QSCALE);
- } else {
- i_exp = 48;
- i_log_scale = blog64(834) - q57(QSCALE);
- }
- let p_exp: u8;
- let p_log_scale: i64;
- if ibpp < 4 {
- p_exp = 100;
- p_log_scale = blog64(2249) - q57(QSCALE);
- } else if ibpp < 8 {
- p_exp = 95;
- p_log_scale = blog64(1751) - q57(QSCALE);
- } else {
- p_exp = 73;
- p_log_scale = blog64(1260) - q57(QSCALE);
- }
+ let i_exp = 62 as u8;
+ let i_log_scale = blog64(394) - q57(QSCALE);
+ let p_exp = 95 as u8;
+ let p_log_scale = blog64(1205) - q57(QSCALE);
+ let b0_exp = 93 as u8;
+ let b0_log_scale = blog64(546) - q57(QSCALE);
+ let b1_exp = 89 as u8;
+ let b1_log_scale = blog64(195) - q57(QSCALE);
+
// TODO: Add support for "golden" P frames.
RCState {
target_bitrate,
@@ -543,13 +528,13 @@ impl RCState {
reservoir_fullness: reservoir_target,
reservoir_target,
reservoir_max,
- log_scale: [i_log_scale, p_log_scale, p_log_scale, p_log_scale],
- exp: [i_exp, p_exp, p_exp, p_exp],
+ log_scale: [i_log_scale, p_log_scale, b0_log_scale, b1_log_scale],
+ exp: [i_exp, p_exp, b0_exp, b1_exp],
scalefilter: [
IIRBessel2::new(4, q57_to_q24(i_log_scale)),
IIRBessel2::new(INTER_DELAY_TARGET_MIN, q57_to_q24(p_log_scale)),
- IIRBessel2::new(INTER_DELAY_TARGET_MIN, q57_to_q24(p_log_scale)),
- IIRBessel2::new(INTER_DELAY_TARGET_MIN, q57_to_q24(p_log_scale))
+ IIRBessel2::new(INTER_DELAY_TARGET_MIN, q57_to_q24(b0_log_scale)),
+ IIRBessel2::new(INTER_DELAY_TARGET_MIN, q57_to_q24(b1_log_scale))
],
// TODO VFR
nframes: [0; FRAME_NSUBTYPES],
@@ -599,6 +584,11 @@ impl RCState {
let mut nframes: [i32; FRAME_NSUBTYPES] = [0; FRAME_NSUBTYPES];
let reservoir_frames = ctx.guess_frame_subtypes(&mut nframes,
self.reservoir_frame_delay);
+ nframes[0] = 1;
+ nframes[1] = 34;
+ nframes[2] = 68;
+ nframes[3] = 137;
+ println!("I {} P {} B0 {} B1 {}", nframes[0], nframes[1], nframes[2], nframes[3]);
// TODO: Scale for VFR.
// If we've been missing our target, add a penalty term.
let rate_bias =
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment