refactor(bin): dedupe av_err_to_string + receive_first_frame + drain_encoder via shared src/bin/common/mod.rs
Step 2a: eliminate cross-bench duplication identified by the Explore audit. Changes: - src/avhw/util.rs: av_err_to_string promoted pub(crate) -> pub (the only change to src/avhw/ in this whole refactor plan). - src/avhw/mod.rs: re-export av_err_to_string; #[allow(unused_imports)] silences rustc's per-bin unused-import false positive (the pub use is consumed by the bench bins, not by the main bin). - src/bin/common/mod.rs (new): shared receive_first_frame + drain_encoder. These were byte-identical between the two bench binaries modulo a type-path alias (ff::codec::encoder::video::Video vs ff::encoder::video::Video) and SAFETY-comment line wrapping. Both binaries now wire it via #[path = "common/mod.rs"] mod common;. - src/bin/vaapi_import_bench.rs: 1039 -> 947 LOC (av_err_to_string, receive_first_frame, drain_encoder all removed; 3 call sites updated). - src/bin/sw_encode_bench.rs: 614 -> 545 LOC (receive_first_frame, drain_encoder removed; 3 call sites updated). - use ffmpeg_next::packet::Mut moved to common/mod.rs (was needed only for pkt.as_mut_ptr() inside drain_encoder). Verification (all green): - cargo build --bins / cargo build --release - cargo test (79 lib + 3 integration = 82 pass, 1 ignored — unchanged) - cargo clippy --all-targets -- -D warnings - cargo fmt --check - Test counts unchanged from baseline
This commit is contained in:
@@ -63,6 +63,8 @@ pub use types::{
|
||||
BitrateCommand, CpuNv12Frame, EncodeOutcome, EncodeStages, EncodedH264Frame, ResolutionChange,
|
||||
SwEncodeTiming,
|
||||
};
|
||||
#[allow(unused_imports)]
|
||||
pub use util::av_err_to_string;
|
||||
pub(crate) use util::ff_err;
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
use ffmpeg_next::ffi;
|
||||
|
||||
/// Convert an FFmpeg error code to a human-readable string.
|
||||
pub(crate) fn av_err_to_string(err: i32) -> String {
|
||||
pub fn av_err_to_string(err: i32) -> String {
|
||||
let mut buf = vec![0u8; 128];
|
||||
// SAFETY: buf points to 128 writable bytes and lives for the duration of
|
||||
// av_strerror.
|
||||
|
||||
Reference in New Issue
Block a user