refactor: 升级依赖版本并优化构建系统

- 升级核心依赖 (axum 0.8, tower-http 0.6, alsa 0.11 等)
- 简化交叉编译配置,切换至 Debian 11 提高兼容性
- 新增 Debian 包打包支持 (debuerreotype 模板)
- 移除独立的 mjpeg 解码器,简化视频模块
- 静态链接 libx264/libx265/libopus 到二进制
This commit is contained in:
mofeng-git
2026-01-10 10:59:00 +08:00
parent 3fa91772f0
commit e670f1ffd1
46 changed files with 893 additions and 1156 deletions

View File

@@ -58,8 +58,6 @@ pub enum YuvError {
BufferTooSmall,
/// libyuv function returned an error code
ConversionFailed(i32),
/// MJPEG data is invalid or corrupt
InvalidMjpeg,
}
impl fmt::Display for YuvError {
@@ -68,7 +66,6 @@ impl fmt::Display for YuvError {
YuvError::InvalidDimensions => write!(f, "Invalid dimensions (must be even)"),
YuvError::BufferTooSmall => write!(f, "Buffer too small"),
YuvError::ConversionFailed(code) => write!(f, "Conversion failed with code {}", code),
YuvError::InvalidMjpeg => write!(f, "Invalid MJPEG data"),
}
}
}
@@ -915,129 +912,6 @@ pub fn bgr24_to_nv12(src: &[u8], dst: &mut [u8], width: i32, height: i32) -> Res
i420_to_nv12(&i420_buffer, dst, width, height)
}
// ============================================================================
// MJPEG decoding
// ============================================================================
/// Decode MJPEG to I420
///
/// # Arguments
/// * `src` - Source MJPEG data
/// * `dst` - Destination I420 buffer
/// * `width` - Expected frame width
/// * `height` - Expected frame height
///
/// # Note
/// This function requires libyuv to be compiled with JPEG support
pub fn mjpeg_to_i420(src: &[u8], dst: &mut [u8], width: i32, height: i32) -> Result<()> {
if width % 2 != 0 || height % 2 != 0 {
return Err(YuvError::InvalidDimensions);
}
let w = width as usize;
let h = height as usize;
let y_size = w * h;
let uv_size = (w / 2) * (h / 2);
if dst.len() < i420_size(w, h) {
return Err(YuvError::BufferTooSmall);
}
if src.len() < 2 || src[0] != 0xFF || src[1] != 0xD8 {
return Err(YuvError::InvalidMjpeg);
}
call_yuv!(MJPGToI420(
src.as_ptr(),
usize_to_size_t(src.len()),
dst.as_mut_ptr(),
width,
dst[y_size..].as_mut_ptr(),
width / 2,
dst[y_size + uv_size..].as_mut_ptr(),
width / 2,
width,
height,
width,
height,
))
}
/// Decode MJPEG to NV12 (optimal for VAAPI)
pub fn mjpeg_to_nv12(src: &[u8], dst: &mut [u8], width: i32, height: i32) -> Result<()> {
if width % 2 != 0 || height % 2 != 0 {
return Err(YuvError::InvalidDimensions);
}
let w = width as usize;
let h = height as usize;
let y_size = w * h;
if dst.len() < nv12_size(w, h) {
return Err(YuvError::BufferTooSmall);
}
if src.len() < 2 || src[0] != 0xFF || src[1] != 0xD8 {
return Err(YuvError::InvalidMjpeg);
}
call_yuv!(MJPGToNV12(
src.as_ptr(),
usize_to_size_t(src.len()),
dst.as_mut_ptr(),
width,
dst[y_size..].as_mut_ptr(),
width,
width,
height,
width,
height,
))
}
/// Decode MJPEG to BGRA
pub fn mjpeg_to_bgra(src: &[u8], dst: &mut [u8], width: i32, height: i32) -> Result<()> {
let w = width as usize;
let h = height as usize;
if dst.len() < argb_size(w, h) {
return Err(YuvError::BufferTooSmall);
}
if src.len() < 2 || src[0] != 0xFF || src[1] != 0xD8 {
return Err(YuvError::InvalidMjpeg);
}
call_yuv!(MJPGToARGB(
src.as_ptr(),
usize_to_size_t(src.len()),
dst.as_mut_ptr(),
width * 4,
width,
height,
width,
height,
))
}
/// Get MJPEG frame dimensions without decoding
pub fn mjpeg_size(src: &[u8]) -> Result<(i32, i32)> {
if src.len() < 2 || src[0] != 0xFF || src[1] != 0xD8 {
return Err(YuvError::InvalidMjpeg);
}
let mut width: i32 = 0;
let mut height: i32 = 0;
let ret = unsafe { MJPGSize(src.as_ptr(), usize_to_size_t(src.len()), &mut width, &mut height) };
if ret != 0 || width <= 0 || height <= 0 {
return Err(YuvError::InvalidMjpeg);
}
Ok((width, height))
}
// ============================================================================
// Scaling
// ============================================================================
@@ -1199,18 +1073,6 @@ impl Converter {
Ok(&self.nv12_buffer)
}
/// Decode MJPEG to NV12, returns reference to internal buffer
pub fn mjpeg_to_nv12(&mut self, src: &[u8]) -> Result<&[u8]> {
mjpeg_to_nv12(src, &mut self.nv12_buffer, self.width, self.height)?;
Ok(&self.nv12_buffer)
}
/// Decode MJPEG to I420, returns reference to internal buffer
pub fn mjpeg_to_i420(&mut self, src: &[u8]) -> Result<&[u8]> {
mjpeg_to_i420(src, &mut self.i420_buffer, self.width, self.height)?;
Ok(&self.i420_buffer)
}
/// Convert I420 to NV12, returns reference to internal buffer
pub fn i420_to_nv12(&mut self, src: &[u8]) -> Result<&[u8]> {
i420_to_nv12(src, &mut self.nv12_buffer, self.width, self.height)?;