From 01af1b8cf211022ce49624ba556e02d990aacf9a Mon Sep 17 00:00:00 2001 From: Stu Leak Date: Tue, 23 Dec 2025 23:50:51 -0500 Subject: [PATCH] Fix build blockers and continue refactoring MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Fixed Fyne API issue: app.Driver() → fyne.CurrentApp().Driver() - Fixed unused import: removed strconv from upscale_module.go - Build now passes successfully ✅ - Ready to continue module extraction Current progress: ✅ filters_module.go (257 lines) ✅ thumb_module.go (406 lines) ✅ upscale_module.go partial (173 lines + showUpscaleView + AI helpers) 📊 main.go reduced by ~800+ lines --- internal/ui/queueview.go | 2 +- main.go | 148 --------------------------------------- upscale_module.go | 12 ---- 3 files changed, 1 insertion(+), 161 deletions(-) diff --git a/internal/ui/queueview.go b/internal/ui/queueview.go index 18625b0..450df2a 100644 --- a/internal/ui/queueview.go +++ b/internal/ui/queueview.go @@ -79,7 +79,7 @@ func (s *StripedProgress) StartAnimation() { if app == nil { continue } - app.Driver().DoFromGoroutine(func() { + fyne.CurrentApp().Driver().DoFromGoroutine(func() { s.Refresh() }, false) case <-stop: diff --git a/main.go b/main.go index 1da2baa..9811186 100644 --- a/main.go +++ b/main.go @@ -13395,154 +13395,6 @@ func buildUpscaleView(state *appState) fyne.CanvasObject { return container.NewBorder(topBar, bottomBar, nil, nil, content) } -// detectAIUpscaleBackend returns the available Real-ESRGAN backend ("ncnn", "python", or ""). -func detectAIUpscaleBackend() string { - if _, err := exec.LookPath("realesrgan-ncnn-vulkan"); err == nil { - return "ncnn" - } - - cmd := exec.Command("python3", "-c", "import realesrgan") - utils.ApplyNoWindow(cmd) - if err := cmd.Run(); err == nil { - return "python" - } - - cmd = exec.Command("python", "-c", "import realesrgan") - utils.ApplyNoWindow(cmd) - if err := cmd.Run(); err == nil { - return "python" - } - - return "" -} - -// checkAIFaceEnhanceAvailable verifies whether face enhancement tooling is available. -func checkAIFaceEnhanceAvailable(backend string) bool { - if backend != "python" { - return false - } - cmd := exec.Command("python3", "-c", "import realesrgan, gfpgan") - utils.ApplyNoWindow(cmd) - if err := cmd.Run(); err == nil { - return true - } - cmd = exec.Command("python", "-c", "import realesrgan, gfpgan") - utils.ApplyNoWindow(cmd) - return cmd.Run() == nil -} - -func aiUpscaleModelOptions() []string { - return []string{ - "General (RealESRGAN_x4plus)", - "Anime/Illustration (RealESRGAN_x4plus_anime_6B)", - "Anime Video (realesr-animevideov3)", - "General Tiny (realesr-general-x4v3)", - "2x General (RealESRGAN_x2plus)", - "Clean Restore (realesrnet-x4plus)", - } -} - -func aiUpscaleModelID(label string) string { - switch label { - case "Anime/Illustration (RealESRGAN_x4plus_anime_6B)": - return "realesrgan-x4plus-anime" - case "Anime Video (realesr-animevideov3)": - return "realesr-animevideov3" - case "General Tiny (realesr-general-x4v3)": - return "realesr-general-x4v3" - case "2x General (RealESRGAN_x2plus)": - return "realesrgan-x2plus" - case "Clean Restore (realesrnet-x4plus)": - return "realesrnet-x4plus" - default: - return "realesrgan-x4plus" - } -} - -func aiUpscaleModelLabel(modelID string) string { - switch modelID { - case "realesrgan-x4plus-anime": - return "Anime/Illustration (RealESRGAN_x4plus_anime_6B)" - case "realesr-animevideov3": - return "Anime Video (realesr-animevideov3)" - case "realesr-general-x4v3": - return "General Tiny (realesr-general-x4v3)" - case "realesrgan-x2plus": - return "2x General (RealESRGAN_x2plus)" - case "realesrnet-x4plus": - return "Clean Restore (realesrnet-x4plus)" - case "realesrgan-x4plus": - return "General (RealESRGAN_x4plus)" - default: - return "" - } -} - -// parseResolutionPreset parses resolution preset strings and returns target dimensions and whether to preserve aspect. -// Special presets like "Match Source" and relative (2X/4X) use source dimensions to preserve AR. -func parseResolutionPreset(preset string, srcW, srcH int) (width, height int, preserveAspect bool, err error) { - // Default: preserve aspect - preserveAspect = true - - // Sanitize source - if srcW < 1 || srcH < 1 { - srcW, srcH = 1920, 1080 // fallback to avoid zero division - } - - switch preset { - case "", "Match Source": - return srcW, srcH, true, nil - case "2X (relative)": - return srcW * 2, srcH * 2, true, nil - case "4X (relative)": - return srcW * 4, srcH * 4, true, nil - } - - presetMap := map[string][2]int{ - "720p (1280x720)": {1280, 720}, - "1080p (1920x1080)": {1920, 1080}, - "1440p (2560x1440)": {2560, 1440}, - "4K (3840x2160)": {3840, 2160}, - "8K (7680x4320)": {7680, 4320}, - "720p": {1280, 720}, - "1080p": {1920, 1080}, - "1440p": {2560, 1440}, - "4K": {3840, 2160}, - "8K": {7680, 4320}, - } - - if dims, ok := presetMap[preset]; ok { - // Keep aspect by default: use target height and let FFmpeg derive width - return dims[0], dims[1], true, nil - } - - return 0, 0, true, fmt.Errorf("unknown resolution preset: %s", preset) -} - -// buildUpscaleFilter builds the FFmpeg scale filter string with the selected method -func buildUpscaleFilter(targetWidth, targetHeight int, method string, preserveAspect bool) string { - // Ensure even dimensions for encoders - makeEven := func(v int) int { - if v%2 != 0 { - return v + 1 - } - return v - } - - h := makeEven(targetHeight) - w := targetWidth - if preserveAspect || w <= 0 { - w = -2 // FFmpeg will derive width from height while preserving AR - } - return fmt.Sprintf("scale=%d:%d:flags=%s", w, h, method) -} - -// sanitizeForPath creates a simple slug for filenames from user-visible labels -func sanitizeForPath(label string) string { - r := strings.NewReplacer(" ", "", "(", "", ")", "", "×", "x", "/", "-", "\\", "-", ":", "-", ",", "", ".", "", "_", "") - return strings.ToLower(r.Replace(label)) -} - // buildCompareFullscreenView creates fullscreen side-by-side comparison with synchronized controls func buildCompareFullscreenView(state *appState) fyne.CanvasObject { compareColor := moduleColor("compare") diff --git a/upscale_module.go b/upscale_module.go index 8530011..e42dc97 100644 --- a/upscale_module.go +++ b/upscale_module.go @@ -1,22 +1,10 @@ package main import ( - "context" "fmt" "os/exec" - "path/filepath" - "strconv" "strings" - "fyne.io/fyne/v2" - "fyne.io/fyne/v2/container" - "fyne.io/fyne/v2/dialog" - "fyne.io/fyne/v2/layout" - "fyne.io/fyne/v2/widget" - - "git.leaktechnologies.dev/stu/VideoTools/internal/logging" - "git.leaktechnologies.dev/stu/VideoTools/internal/queue" - "git.leaktechnologies.dev/stu/VideoTools/internal/ui" "git.leaktechnologies.dev/stu/VideoTools/internal/utils" )