Files
mixvideo-v2/cargos/tvai/src/core/models.rs
imeepos e4dbb57b68 feat: 完成 tvai 库基础架构搭建 (阶段一)
项目初始化完成
- 创建 cargos/tvai 项目结构
- 配置 Cargo.toml 依赖和工作空间
- 实现基础错误类型 TvaiError

 FFmpeg 管理模块
- 实现 FfmpegManager 结构体
- FFmpeg 路径检测和验证 (系统 vs Topaz)
- 基础命令执行框架
- 支持 Windows/Linux/macOS 平台

 核心处理引擎框架
- TvaiProcessor 主结构体
- TvaiConfig 配置管理和 Builder 模式
- 临时文件管理和自动清理
- GPU 检测和配置

 模型和参数定义
- 16种超分辨率模型枚举 (Iris3, Nyx3, Thf4 等)
- 4种插值模型枚举 (Apo8, Chr2 等)
- 质量预设和编码设置
- 完整的参数结构体和验证

 模块结构完整
- video/ 视频处理模块框架
- image/ 图片处理模块框架
- config/ 配置管理模块
- utils/ 工具函数模块

 系统检测功能
- Topaz Video AI 安装检测
- GPU 支持检测
- FFmpeg 可用性检测

 文档和示例
- 完整的 README 文档
- 基础使用示例
- API 文档注释

 测试结果
-  编译通过 (cargo check)
-  示例运行成功
-  检测到 Topaz Video AI 安装
-  所有模块结构就绪

下一步: 开始阶段二 - 核心处理引擎实现
2025-08-11 15:12:44 +08:00

173 lines
5.9 KiB
Rust

//! AI model definitions and parameter types
use serde::{Deserialize, Serialize};
/// Upscaling AI models available in Topaz Video AI
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub enum UpscaleModel {
/// Iris v3 - Best general purpose model
Iris3,
/// Iris v2 - Balanced quality and speed
Iris2,
/// Artemis HQ v12 - High quality model
Ahq12,
/// Artemis LQ v13 - Optimized for low quality input
Alq13,
/// Artemis LQ Small v2 - Fast processing
Alqs2,
/// Artemis MQ v13 - Medium quality balance
Amq13,
/// Artemis MQ Small v2 - Fast medium quality
Amqs2,
/// Gaia HQ v5 - Game/CG content
Ghq5,
/// Nyx v3 - Portrait optimization
Nyx3,
/// Proteus v4 - Problem footage repair
Prob4,
/// Theia Fidelity v4 - Old content restoration
Thf4,
/// Theia Detail v3 - Detail enhancement
Thd3,
/// Theia Magic v2 - Magic enhancement (forces 1x scale)
Thm2,
/// Rhea v1 - Realism enhancement
Rhea1,
/// Rhea XL v1 - Extra large resolution
Rxl1,
/// Artemis Anti-Alias v9 - Anti-aliasing
Aaa9,
}
impl UpscaleModel {
/// Get the model identifier string for FFmpeg
pub fn as_str(&self) -> &'static str {
match self {
Self::Iris3 => "iris-3",
Self::Iris2 => "iris-2",
Self::Ahq12 => "ahq-12",
Self::Alq13 => "alq-13",
Self::Alqs2 => "alqs-2",
Self::Amq13 => "amq-13",
Self::Amqs2 => "amqs-2",
Self::Ghq5 => "ghq-5",
Self::Nyx3 => "nyx-3",
Self::Prob4 => "prob-4",
Self::Thf4 => "thf-4",
Self::Thd3 => "thd-3",
Self::Thm2 => "thm-2",
Self::Rhea1 => "rhea-1",
Self::Rxl1 => "rxl-1",
Self::Aaa9 => "aaa-9",
}
}
/// Check if this model forces a specific scale factor
pub fn forces_scale(&self) -> Option<f32> {
match self {
Self::Thm2 => Some(1.0), // Theia Magic forces 1x scale
_ => None,
}
}
/// Get recommended use case for this model
pub fn description(&self) -> &'static str {
match self {
Self::Iris3 => "Best general purpose model for most content",
Self::Iris2 => "Balanced quality and processing speed",
Self::Ahq12 => "High quality upscaling for premium content",
Self::Alq13 => "Optimized for low quality input footage",
Self::Alqs2 => "Fast processing for low quality content",
Self::Amq13 => "Medium quality balance for general use",
Self::Amqs2 => "Fast medium quality processing",
Self::Ghq5 => "Specialized for game footage and CG content",
Self::Nyx3 => "Optimized for portrait and face content",
Self::Prob4 => "Repair and restoration of problem footage",
Self::Thf4 => "Restoration of old films and vintage content",
Self::Thd3 => "Enhanced detail preservation",
Self::Thm2 => "Magic enhancement with artifact removal",
Self::Rhea1 => "Realism enhancement for natural content",
Self::Rxl1 => "Extra large resolution upscaling",
Self::Aaa9 => "Anti-aliasing and edge smoothing",
}
}
}
/// Frame interpolation models available in Topaz Video AI
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub enum InterpolationModel {
/// Apollo v8 - High quality interpolation
Apo8,
/// Apollo Fast v1 - Fast interpolation
Apf1,
/// Chronos v2 - Animation content
Chr2,
/// Chronos Fast v3 - Fast animation interpolation
Chf3,
}
impl InterpolationModel {
/// Get the model identifier string for FFmpeg
pub fn as_str(&self) -> &'static str {
match self {
Self::Apo8 => "apo-8",
Self::Apf1 => "apf-1",
Self::Chr2 => "chr-2",
Self::Chf3 => "chf-3",
}
}
/// Get recommended use case for this model
pub fn description(&self) -> &'static str {
match self {
Self::Apo8 => "High quality interpolation for most content",
Self::Apf1 => "Fast interpolation with good quality",
Self::Chr2 => "Specialized for animation and cartoon content",
Self::Chf3 => "Fast interpolation for animation content",
}
}
}
/// Quality presets for processing
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub enum QualityPreset {
/// Fast processing with acceptable quality
Fast,
/// Balanced quality and speed
Balanced,
/// High quality processing
HighQuality,
/// Maximum quality (slowest)
Maximum,
}
impl QualityPreset {
/// Get encoding settings for this preset
pub fn get_encoding_settings(&self, use_gpu: bool) -> (&'static str, &'static str) {
match (self, use_gpu) {
(Self::Fast, true) => ("hevc_nvenc", "fast"),
(Self::Fast, false) => ("libx264", "ultrafast"),
(Self::Balanced, true) => ("hevc_nvenc", "medium"),
(Self::Balanced, false) => ("libx264", "medium"),
(Self::HighQuality, true) => ("hevc_nvenc", "slow"),
(Self::HighQuality, false) => ("libx264", "slow"),
(Self::Maximum, true) => ("hevc_nvenc", "slow"),
(Self::Maximum, false) => ("libx264", "veryslow"),
}
}
/// Get quality value for this preset
pub fn get_quality_value(&self, use_gpu: bool) -> &'static str {
match (self, use_gpu) {
(Self::Fast, true) => "25",
(Self::Fast, false) => "23",
(Self::Balanced, true) => "20",
(Self::Balanced, false) => "20",
(Self::HighQuality, true) => "17",
(Self::HighQuality, false) => "17",
(Self::Maximum, true) => "15",
(Self::Maximum, false) => "15",
}
}
}