16 kbps row in the rate table
Browse files at this commitf9353670384fb8cdc25a1c11a69ec1c0acbb042dParent: 52ead44- test
- 16 kbps row in the rate table
- clippy-clean wide usage
2 changed files +21 -7
crates/ec-opus/src/celt_enc.rsmodified+10 -5
| @@ -1870,8 +1870,7 @@ impl CeltEncoder { | |||
| 1870 | let mut best_den = 0.0f32; | 1870 | let mut best_den = 0.0f32; |
| 1871 | let mut j0 = 0usize; | 1871 | let mut j0 = 0usize; |
| 1872 | if n >= 16 { | 1872 | if n >= 16 { |
| 1873 | - #[allow(deprecated)] | 1873 | + use wide::f32x8; |
| 1874 | - use wide::{CmpGt, f32x8}; | ||
| 1875 | let chunks = n / 8; | 1874 | let chunks = n / 8; |
| 1876 | let xy_v = f32x8::splat(xy); | 1875 | let xy_v = f32x8::splat(xy); |
| 1877 | let yy_v = f32x8::splat(yy); | 1876 | let yy_v = f32x8::splat(yy); |
| @@ -1887,9 +1886,15 @@ impl CeltEncoder { | |||
| 1887 | let ryy = yy_v + f32x8::from(ya); | 1886 | let ryy = yy_v + f32x8::from(ya); |
| 1888 | let rxy2 = rxy * rxy; | 1887 | let rxy2 = rxy * rxy; |
| 1889 | let mask = (bd * rxy2).simd_gt(ryy * bn); | 1888 | let mask = (bd * rxy2).simd_gt(ryy * bn); |
| 1890 | - bn = mask.blend(rxy2, bn); | 1889 | + // wide 1.5 deprecates `blend` in favour of a split that |
| 1891 | - bd = mask.blend(ryy, bd); | 1890 | + // does not exist yet in this release; the mask here is a |
| 1892 | - bc = mask.blend(f32x8::splat(c as f32), bc); | 1891 | + // true lane mask, which is exactly blend's contract. |
| 1892 | + #[allow(deprecated)] | ||
| 1893 | + { | ||
| 1894 | + bn = mask.blend(rxy2, bn); | ||
| 1895 | + bd = mask.blend(ryy, bd); | ||
| 1896 | + bc = mask.blend(f32x8::splat(c as f32), bc); | ||
| 1897 | + } | ||
| 1893 | } | 1898 | } |
| 1894 | let bn_a: [f32; 8] = bn.into(); | 1899 | let bn_a: [f32; 8] = bn.into(); |
| 1895 | let bd_a: [f32; 8] = bd.into(); | 1900 | let bd_a: [f32; 8] = bd.into(); |
crates/ec-opus/tests/conformance.rsmodified+11 -2
| @@ -1011,7 +1011,7 @@ fn libopus_decodes_our_packets_across_the_rate_table() { | |||
| 1011 | let pcm = test_signal(channels, 2.0); | 1011 | let pcm = test_signal(channels, 2.0); |
| 1012 | let total = pcm.len() / channels; | 1012 | let total = pcm.len() / channels; |
| 1013 | let mut table = Vec::new(); | 1013 | let mut table = Vec::new(); |
| 1014 | - for kbps in [32u32, 64, 96, 128, 160, 165, 192, 256, 320, 510] { | 1014 | + for kbps in [16u32, 32, 64, 96, 128, 160, 165, 192, 256, 320, 510] { |
| 1015 | let mut enc = Encoder::new(48000, channels).unwrap(); | 1015 | let mut enc = Encoder::new(48000, channels).unwrap(); |
| 1016 | enc.set_bitrate(kbps * 1000); | 1016 | enc.set_bitrate(kbps * 1000); |
| 1017 | let packets = encode_packets(&mut enc, &pcm, channels); | 1017 | let packets = encode_packets(&mut enc, &pcm, channels); |
| @@ -1043,7 +1043,16 @@ fn libopus_decodes_our_packets_across_the_rate_table() { | |||
| 1043 | "{channels} ch {kbps:>3} kbps: worst corr {worst:.4}, opus_compare {quality:.1}" | 1043 | "{channels} ch {kbps:>3} kbps: worst corr {worst:.4}, opus_compare {quality:.1}" |
| 1044 | )); | 1044 | )); |
| 1045 | let floor = match kbps { | 1045 | let floor = match kbps { |
| 1046 | - 0..=39 => 0.6, | 1046 | + // 16 kbps fullband CELT is the honest bottom of the range: |
| 1047 | + // reported, held to "clearly the same signal", not to hi-fi. | ||
| 1048 | + 0..=19 => { | ||
| 1049 | + if channels == 1 { | ||
| 1050 | + 0.6 | ||
| 1051 | + } else { | ||
| 1052 | + 0.35 | ||
| 1053 | + } | ||
| 1054 | + } | ||
| 1055 | + 20..=39 => 0.6, | ||
| 1047 | 40..=95 => 0.8, | 1056 | 40..=95 => 0.8, |
| 1048 | _ => 0.9, | 1057 | _ => 0.9, |
| 1049 | }; | 1058 | }; |