Report chroma per plane, and stop dropping the first x264 param
Browse files at this commit8adad232839ba07c43c488e228fb3d9816981be5Parent: 49e08f5- test
- report chroma per plane, and stop dropping the first x264 param
1 changed file +39 -1
crates/ec-h264/tests/encode.rsmodified+39 -1
| @@ -980,7 +980,13 @@ fn x264_encode_qp(sources: &[Planes], w: usize, h: usize, qp: i32, gop: u32) -> | ||
| 980 | 980 | &format!( |
| 981 | 981 | "scenecut=0:aq-mode=0:psy=0:8x8dct=0:ipratio=1.0:pbratio=1.0:qcomp=1.0:chroma-qp-offset=0{}", |
| 982 | 982 | match std::env::var("EC_H264_X264_PARAMS") { |
| 983 | - Ok(extra) if !extra.trim().is_empty() => format!(":{}", extra.trim()), | |
| 983 | + // The value may or may not carry its own leading colon; | |
| 984 | + // both spell the same thing. Passing it through would not: | |
| 985 | + // ffmpeg drops the token after an empty one, so "::subme=1" | |
| 986 | + // silently encodes at the preset's subme and the sweep | |
| 987 | + // reads as "the feature does nothing". | |
| 988 | + Ok(extra) if !extra.trim().trim_matches(':').is_empty() => | |
| 989 | + format!(":{}", extra.trim().trim_matches(':')), | |
| 984 | 990 | _ => String::new(), |
| 985 | 991 | } |
| 986 | 992 | ), |
| @@ -1088,6 +1094,23 @@ fn bd_psnr_vs_x264() { | ||
| 1088 | 1094 | .zip(&decoded) |
| 1089 | 1095 | .map(|(s, d)| psnr_yuv(s, d)) |
| 1090 | 1096 | .sum(); |
| 1097 | + let (sum_u, sum_v) = ( | |
| 1098 | + sources | |
| 1099 | + .iter() | |
| 1100 | + .zip(&decoded) | |
| 1101 | + .map(|(s, d)| psnr(&s.1, &d.1)) | |
| 1102 | + .sum::<f64>(), | |
| 1103 | + sources | |
| 1104 | + .iter() | |
| 1105 | + .zip(&decoded) | |
| 1106 | + .map(|(s, d)| psnr(&s.2, &d.2)) | |
| 1107 | + .sum::<f64>(), | |
| 1108 | + ); | |
| 1109 | + eprintln!( | |
| 1110 | + " ours qp {qp}: u {:.2} dB v {:.2} dB", | |
| 1111 | + sum_u / sources.len() as f64, | |
| 1112 | + sum_v / sources.len() as f64 | |
| 1113 | + ); | |
| 1091 | 1114 | let (decoded_psnr, recon_psnr) = |
| 1092 | 1115 | (sum / sources.len() as f64, sum_recon / sources.len() as f64); |
| 1093 | 1116 | assert!( |
| @@ -1122,6 +1145,21 @@ fn bd_psnr_vs_x264() { | ||
| 1122 | 1145 | .map(|(s, d)| psnr_yuv(s, d)) |
| 1123 | 1146 | .sum(); |
| 1124 | 1147 | let n = sources.len() as f64; |
| 1148 | + eprintln!( | |
| 1149 | + " x264 qp {qp}: u {:.2} dB v {:.2} dB", | |
| 1150 | + sources | |
| 1151 | + .iter() | |
| 1152 | + .zip(&decoded) | |
| 1153 | + .map(|(s, d)| psnr(&s.1, &d.1)) | |
| 1154 | + .sum::<f64>() | |
| 1155 | + / n, | |
| 1156 | + sources | |
| 1157 | + .iter() | |
| 1158 | + .zip(&decoded) | |
| 1159 | + .map(|(s, d)| psnr(&s.2, &d.2)) | |
| 1160 | + .sum::<f64>() | |
| 1161 | + / n | |
| 1162 | + ); | |
| 1125 | 1163 | ((stream.len() * 8) as f64, sum / n, sum_yuv / n) |
| 1126 | 1164 | }; |
| 1127 | 1165 |