Skip to content

Commit bd1d986

Browse files
vladimir-kazakovshssoichiro
authored andcommitted
1 parent 08acfcc commit bd1d986

File tree

5 files changed

+31
-31
lines changed

5 files changed

+31
-31
lines changed

.travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,4 @@ jobs:
4444
- cargo doc --verbose
4545
- rustup component add clippy
4646
- cargo clippy --version
47-
- cargo clippy -- -D warnings -A clippy::absurd_extreme_comparisons -A clippy::cast_lossless -A clippy::cast_ptr_alignment -A clippy::collapsible_if -A clippy::cyclomatic_complexity -A clippy::erasing_op -A clippy::get_unwrap -A clippy::identity_op -A clippy::if_same_then_else -A clippy::len_zero -A clippy::manual_memcpy -A clippy::needless_range_loop -A clippy::neg_multiply -A clippy::new_without_default -A clippy::new_without_default_derive -A clippy::precedence -A clippy::ptr_arg -A clippy::too_many_arguments -A clippy::trivially_copy_pass_by_ref -A clippy::type_complexity -A clippy::unreadable_literal -A clippy::unused_io_amount -A clippy::verbose_bit_mask --verbose
47+
- cargo clippy -- -D warnings -A clippy::absurd_extreme_comparisons -A clippy::cast_lossless -A clippy::cast_ptr_alignment -A clippy::collapsible_if -A clippy::cyclomatic_complexity -A clippy::erasing_op -A clippy::get_unwrap -A clippy::identity_op -A clippy::if_same_then_else -A clippy::len_zero -A clippy::manual_memcpy -A clippy::needless_range_loop -A clippy::neg_multiply -A clippy::new_without_default -A clippy::new_without_default_derive -A clippy::precedence -A clippy::ptr_arg -A clippy::too_many_arguments -A clippy::trivially_copy_pass_by_ref -A clippy::type_complexity -A clippy::unused_io_amount -A clippy::verbose_bit_mask --verbose

src/deblock.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -1345,21 +1345,21 @@ pub fn deblock_filter_optimize(
13451345
match fi.sequence.bit_depth {
13461346
8 =>
13471347
if fi.frame_type == FrameType::KEY {
1348-
q * 17563 - 421574 + (1 << 18 >> 1) >> 18
1348+
q * 17563 - 421_574 + (1 << 18 >> 1) >> 18
13491349
} else {
1350-
q * 6017 + 650707 + (1 << 18 >> 1) >> 18
1350+
q * 6017 + 650_707 + (1 << 18 >> 1) >> 18
13511351
},
13521352
10 =>
13531353
if fi.frame_type == FrameType::KEY {
1354-
(q * 20723 + 4060632 + (1 << 20 >> 1) >> 20) - 4
1354+
(q * 20723 + 4_060_632 + (1 << 20 >> 1) >> 20) - 4
13551355
} else {
1356-
q * 20723 + 4060632 + (1 << 20 >> 1) >> 20
1356+
q * 20723 + 4_060_632 + (1 << 20 >> 1) >> 20
13571357
},
13581358
12 =>
13591359
if fi.frame_type == FrameType::KEY {
1360-
(q * 20723 + 16242526 + (1 << 22 >> 1) >> 22) - 4
1360+
(q * 20723 + 16_242_526 + (1 << 22 >> 1) >> 22) - 4
13611361
} else {
1362-
q * 20723 + 16242526 + (1 << 22 >> 1) >> 22
1362+
q * 20723 + 16_242_526 + (1 << 22 >> 1) >> 22
13631363
},
13641364
_ => {
13651365
assert!(false);

src/metrics.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ pub fn calculate_frame_psnr(original: &Frame, compressed: &Frame, bit_depth: usi
2525
/// version.
2626
fn calculate_plane_psnr(original: &Plane, compressed: &Plane, bit_depth: usize) -> f64 {
2727
let mse = calculate_plane_mse(original, compressed);
28-
if mse <= 0.0000000001 {
28+
if mse <= 0.000_000_000_1 {
2929
return 100.0;
3030
}
3131
let max = ((1 << bit_depth) - 1) as f64;
@@ -39,4 +39,4 @@ fn calculate_plane_mse(original: &Plane, compressed: &Plane) -> f64 {
3939
.map(|(a, b)| (a as i32 - b as i32).abs() as u64)
4040
.map(|err| err * err)
4141
.sum::<u64>() as f64 / (original.cfg.width * original.cfg.height) as f64
42-
}
42+
}

src/quantize.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ fn divu_gen(d: u32) -> (u32, u32, u32) {
111111
let nbits = (mem::size_of_val(&d) as u64) * 8;
112112
let m = nbits - d.leading_zeros() as u64 - 1;
113113
if (d & (d - 1)) == 0 {
114-
(0xFFFFFFFF, 0xFFFFFFFF, m as u32)
114+
(0xFFFF_FFFF, 0xFFFF_FFFF, m as u32)
115115
} else {
116116
let d = d as u64;
117117
let t = (1u64 << (m + nbits)) / d;

src/rate.rs

+21-21
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,13 @@ const MQP_Q12: &[i32; FRAME_NSUBTYPES] = &[
4747
(1.0 * (1 << 12) as f64) as i32
4848
];
4949

50-
// The ratio 33810170.0/86043287.0 was derived by approximating the median of a
51-
// change of 15 quantizer steps in the quantizer tables.
50+
// The ratio 33_810_170.0 / 86_043_287.0 was derived by approximating the median
51+
// of a change of 15 quantizer steps in the quantizer tables.
5252
const DQP_Q57: &[i64; FRAME_NSUBTYPES] = &[
53-
(-(33810170.0 / 86043287.0) * (1i64 << 57) as f64) as i64,
53+
(-(33_810_170.0 / 86_043_287.0) * (1i64 << 57) as f64) as i64,
5454
(0.0 * (1i64 << 57) as f64) as i64,
55-
((33810170.0 / 86043287.0) * (1i64 << 57) as f64) as i64,
56-
(2.0 * (33810170.0 / 86043287.0) * (1i64 << 57) as f64) as i64
55+
((33_810_170.0 / 86_043_287.0) * (1i64 << 57) as f64) as i64,
56+
(2.0 * (33_810_170.0 / 86_043_287.0) * (1i64 << 57) as f64) as i64
5757
];
5858

5959
// Integer binary logarithm of a 64-bit value.
@@ -75,17 +75,17 @@ const fn q57(v: i32) -> i64 {
7575

7676
#[rustfmt::skip]
7777
const ATANH_LOG2: &[i64; 32] = &[
78-
0x32B803473F7AD0F4, 0x2F2A71BD4E25E916, 0x2E68B244BB93BA06,
79-
0x2E39FB9198CE62E4, 0x2E2E683F68565C8F, 0x2E2B850BE2077FC1,
80-
0x2E2ACC58FE7B78DB, 0x2E2A9E2DE52FD5F2, 0x2E2A92A338D53EEC,
81-
0x2E2A8FC08F5E19B6, 0x2E2A8F07E51A485E, 0x2E2A8ED9BA8AF388,
82-
0x2E2A8ECE2FE7384A, 0x2E2A8ECB4D3E4B1A, 0x2E2A8ECA94940FE8,
83-
0x2E2A8ECA6669811D, 0x2E2A8ECA5ADEDD6A, 0x2E2A8ECA57FC347E,
84-
0x2E2A8ECA57438A43, 0x2E2A8ECA57155FB4, 0x2E2A8ECA5709D510,
85-
0x2E2A8ECA5706F267, 0x2E2A8ECA570639BD, 0x2E2A8ECA57060B92,
86-
0x2E2A8ECA57060008, 0x2E2A8ECA5705FD25, 0x2E2A8ECA5705FC6C,
87-
0x2E2A8ECA5705FC3E, 0x2E2A8ECA5705FC33, 0x2E2A8ECA5705FC30,
88-
0x2E2A8ECA5705FC2F, 0x2E2A8ECA5705FC2F
78+
0x32B8_0347_3F7A_D0F4, 0x2F2A_71BD_4E25_E916, 0x2E68_B244_BB93_BA06,
79+
0x2E39_FB91_98CE_62E4, 0x2E2E_683F_6856_5C8F, 0x2E2B_850B_E207_7FC1,
80+
0x2E2A_CC58_FE7B_78DB, 0x2E2A_9E2D_E52F_D5F2, 0x2E2A_92A3_38D5_3EEC,
81+
0x2E2A_8FC0_8F5E_19B6, 0x2E2A_8F07_E51A_485E, 0x2E2A_8ED9_BA8A_F388,
82+
0x2E2A_8ECE_2FE7_384A, 0x2E2A_8ECB_4D3E_4B1A, 0x2E2A_8ECA_9494_0FE8,
83+
0x2E2A_8ECA_6669_811D, 0x2E2A_8ECA_5ADE_DD6A, 0x2E2A_8ECA_57FC_347E,
84+
0x2E2A_8ECA_5743_8A43, 0x2E2A_8ECA_5715_5FB4, 0x2E2A_8ECA_5709_D510,
85+
0x2E2A_8ECA_5706_F267, 0x2E2A_8ECA_5706_39BD, 0x2E2A_8ECA_5706_0B92,
86+
0x2E2A_8ECA_5706_0008, 0x2E2A_8ECA_5705_FD25, 0x2E2A_8ECA_5705_FC6C,
87+
0x2E2A_8ECA_5705_FC3E, 0x2E2A_8ECA_5705_FC33, 0x2E2A_8ECA_5705_FC30,
88+
0x2E2A_8ECA_5705_FC2F, 0x2E2A_8ECA_5705_FC2F
8989
];
9090

9191
// Computes the binary exponential of logq57.
@@ -98,7 +98,7 @@ fn bexp64(logq57: i64) -> i64 {
9898
return 0;
9999
}
100100
if ipart >= 63 {
101-
return 0x7FFFFFFFFFFFFFFF;
101+
return 0x7FFF_FFFF_FFFF_FFFF;
102102
}
103103
// z is the fractional part of the log in Q62 format.
104104
// We need 1 bit of headroom since the magnitude can get larger than 1
@@ -116,7 +116,7 @@ fn bexp64(logq57: i64) -> i64 {
116116
// \lim_{n->\infty} 2^{61}/\product_{i=1}^n \sqrt{1-2^{-2i}}
117117
// but in order to guarantee convergence we have to repeat iterations 4,
118118
// 13 (=3*4+1), and 40 (=3*13+1, etc.), so it winds up somewhat larger.
119-
w = 0x26A3D0E401DD846D;
119+
w = 0x26A3_D0E4_01DD_846D;
120120
let mut i: i64 = 0;
121121
loop {
122122
let mask = -((z < 0) as i64);
@@ -470,7 +470,7 @@ impl RCState {
470470
// Let's not get carried away.
471471
// TODO: Support constraints imposed by levels.
472472
let bits_per_frame = clamp(
473-
(target_bitrate as i64)*framerate_den/framerate_num, 32, 0x400000000000
473+
(target_bitrate as i64)*framerate_den/framerate_num, 32, 0x4000_0000_0000
474474
);
475475
let reservoir_max = bits_per_frame*(reservoir_frame_delay as i64);
476476
// Start with a buffer fullness and fullness target of 50%.
@@ -636,8 +636,8 @@ impl RCState {
636636
if let Some(prev_log_base_q) = maybe_prev_log_base_q {
637637
log_base_q = clamp(
638638
log_base_q,
639-
prev_log_base_q - 0xA4D3C25E68DC58,
640-
prev_log_base_q + 0xA4D3C25E68DC58
639+
prev_log_base_q - 0xA4_D3C2_5E68_DC58,
640+
prev_log_base_q + 0xA4_D3C2_5E68_DC58
641641
);
642642
}
643643
// Modulate base quantizer by frame type.

0 commit comments

Comments
 (0)