Feature/v4.5 audio playback#8
Conversation
- Introduce `UseGreyscaleAnsi` for improved greyscale rendering without color. - Add interlace options for enhanced braille rendering with temporal super-resolution. - Implement terminal color depth settings for adaptive color palette use.
- Enable MCP JSON servers for enhanced project server handling. - Add GitHub workflow files for nuget publishing and releases.
… and expand ASCII character sets: - Implement SIMD-accelerated shape vector matching for braille rendering. - Enhance braille rendering with edge direction corrections and interlace temporal super-resolution mode. - Expand default ASCII character set from 70 to 95 characters for improved output quality. - Update README and add new features: hardware acceleration, greyscale ANSI mode, and detailed performance improvements.
There was a problem hiding this comment.
Pull request overview
This PR updates the console image/video renderer to v4.5, focusing on higher-fidelity character selection (especially braille), expanded benchmarking, and improved terminal color handling.
Changes:
- Add SIMD-based braille shape-vector matching + temporal “interlace” playback mode.
- Add adaptive ANSI color output (truecolor/256/16 + greyscale ramp) and propagate new render options through CLI + handlers.
- Expand benchmarking coverage and refresh README/docs + samples.
Reviewed changes
Copilot reviewed 23 out of 50 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| samples/moviebill_ascii.gif | Adds a new sample ASCII-rendered GIF asset. |
| samples/hacktheplanet_ascii.gif | Adds a new sample ASCII-rendered GIF asset. |
| README.md | Updates version/docs and describes new v4.5 rendering features and benchmarks. |
| ConsoleImage/Program.cs | Adds CLI plumbing for greyscale ANSI, color depth, and braille interlace options. |
| ConsoleImage/Handlers/VideoHandler.cs | Propagates greyscale ANSI option; updates classic character set mapping. |
| ConsoleImage/Handlers/SlideshowHandler.cs | Adds filename header row and offsets slideshow/video content start row. |
| ConsoleImage/Handlers/ImageHandler.cs | Adds interlace playback path + passes color depth/greyscale options into render options. |
| ConsoleImage/CliOptions.cs | Introduces --color-depth and interlace-related CLI options. |
| ConsoleImage/.claude/settings.local.json | Updates local Claude/MCP configuration. |
| ConsoleImage.sln | Adds additional workflow files to the solution items. |
| ConsoleImage.Video.Core/VideoRenderOptions.cs | Adds ContentStartRow to support reserved header rows. |
| ConsoleImage.Video.Core/VideoAnimationPlayer.cs | Applies ContentStartRow to clearing and cursor moves during playback. |
| ConsoleImage.Video.Core/FFmpegService.cs | Adds codec blocklist entries and hwaccel auto-fallback logic. |
| ConsoleImage.Core/RenderOptions.cs | Adds color depth, greyscale ANSI mode, and braille interlace configuration. |
| ConsoleImage.Core/EdgeDirection.cs | Fixes edge direction angle rotation/normalization. |
| ConsoleImage.Core/ColorBlockRenderer.cs | Enables ANSI support and adds adaptive color-depth-aware escape emission. |
| ConsoleImage.Core/CharacterMap.cs | Expands default ASCII set + adds disk-cached vector loading/saving. |
| ConsoleImage.Core/BrailleRenderer.cs | Switches to braille shape-vector matching, greyscale ANSI support, and interlace frame generation. |
| ConsoleImage.Core/BrailleInterlacePlayer.cs | New: interlace playback loop for temporal super-resolution. |
| ConsoleImage.Core/BrailleCharacterMap.cs | New: 256-pattern braille vector generation + SIMD brute-force matching with cache. |
| ConsoleImage.Core/AsciiRenderer.cs | Adjusts sampling positions and ensures ANSI support is enabled. |
| ConsoleImage.Core/AnsiCodes.cs | Adds 256/16 color conversion + adaptive ANSI emission helpers. |
| ConsoleImage.Benchmarks/ShapeMatchingBenchmarks.cs | New: benchmark suite for braille matching + ASCII set/caching comparisons. |
| ConsoleImage.Benchmarks/BrailleRendererBenchmarks.cs | Simplifies benchmark jobs to default runtime configuration. |
| .claude/settings.local.json | Expands allowed commands/domains for tooling and web fetch. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // Content starts at line 2 (line 1 reserved for filename header) | ||
| var contentStartLine = 2; | ||
|
|
||
| // Render filename header at row 1 | ||
| var headerWidth = Math.Max(renderOptions.MaxWidth, 30); | ||
| var headerText = FormatFilenameHeader(fileName, currentIndex + 1, fileCount, headerWidth); | ||
| Console.Write("\x1b[1;1H"); // Position at row 1 | ||
| Console.Write(headerText); |
There was a problem hiding this comment.
Slideshow header is now always rendered and contentStartLine is always set to 2, but this ignores options.HideSlideInfo (wired from --hide-info/--no-header). When the header is hidden, the slideshow should not print the header line and should start content at line 1; otherwise the first row is unnecessarily reserved and the flag has no effect.
| // Content starts at line 2 (line 1 reserved for filename header) | |
| var contentStartLine = 2; | |
| // Render filename header at row 1 | |
| var headerWidth = Math.Max(renderOptions.MaxWidth, 30); | |
| var headerText = FormatFilenameHeader(fileName, currentIndex + 1, fileCount, headerWidth); | |
| Console.Write("\x1b[1;1H"); // Position at row 1 | |
| Console.Write(headerText); | |
| int contentStartLine; | |
| if (!options.HideSlideInfo) | |
| { | |
| // Content starts at line 2 (line 1 reserved for filename header) | |
| contentStartLine = 2; | |
| // Render filename header at row 1 | |
| var headerWidth = Math.Max(renderOptions.MaxWidth, 30); | |
| var headerText = FormatFilenameHeader(fileName, currentIndex + 1, fileCount, headerWidth); | |
| Console.Write("\x1b[1;1H"); // Position at row 1 | |
| Console.Write(headerText); | |
| } | |
| else | |
| { | |
| // No header; start content at the first line | |
| contentStartLine = 1; | |
| } |
| foreach (var c in _frames[i].Content) | ||
| if (c == '\n') | ||
| lineCount++; |
There was a problem hiding this comment.
This foreach loop implicitly filters its target sequence - consider filtering the sequence explicitly using '.Where(...)'.
| if (maxNameLen > 3) | ||
| namePart = string.Concat(nameOnly.AsSpan(0, maxNameLen), "\u2026", ext); | ||
| else | ||
| namePart = string.Concat(fileName.AsSpan(0, Math.Max(1, availableForName - 1)), "\u2026"); |
There was a problem hiding this comment.
Both branches of this 'if' statement write to the same variable - consider using '?' to express intent better.
| if (maxNameLen > 3) | |
| namePart = string.Concat(nameOnly.AsSpan(0, maxNameLen), "\u2026", ext); | |
| else | |
| namePart = string.Concat(fileName.AsSpan(0, Math.Max(1, availableForName - 1)), "\u2026"); | |
| namePart = maxNameLen > 3 | |
| ? string.Concat(nameOnly.AsSpan(0, maxNameLen), "\u2026", ext) | |
| : string.Concat(fileName.AsSpan(0, Math.Max(1, availableForName - 1)), "\u2026"); |
| if (_options.UseColor || _options.UseGreyscaleAnsi) | ||
| threshold = invertMode ? 0.15f : 0.85f; | ||
| else | ||
| // Monochrome: use Otsu's method for best separation | ||
| threshold = CalculateOtsuThreshold(brightness); |
There was a problem hiding this comment.
Both branches of this 'if' statement write to the same variable - consider using '?' to express intent better.
| if (_options.UseColor || _options.UseGreyscaleAnsi) | ||
| baseThreshold = invertMode ? 0.15f : 0.85f; | ||
| else | ||
| baseThreshold = CalculateOtsuThreshold(baseBrightness); |
There was a problem hiding this comment.
Both branches of this 'if' statement write to the same variable - consider using '?' to express intent better.
… renderer - Implement 8D shape vector matching to improve dot pattern representation. - Introduce concentric ring sampling for noise reduction and smoother output. - Update documentation and explain new vector matching benefits over thresholding.
|
@copilot open a new pull request to apply changes based on the comments in this thread |
This pull request introduces significant improvements to the benchmarking and rendering infrastructure for console-based image rendering, with a focus on performance analysis, color support, and accuracy in character mapping. The most important changes are grouped below by theme.
Benchmarking Enhancements:
ShapeMatchingBenchmarks.csto measure the performance of Braille and ASCII character shape matching, character set variations, and disk cache effects. This enables detailed comparison of different matching algorithms and character sets.BrailleRendererBenchmarks.csby removing the explicit runtime moniker, ensuring compatibility with the default environment. [1] [2] [3]Rendering and Color Support Improvements:
AnsiCodes.cs, including efficient RGB-to-ANSI 256-color and 16-color conversions, and utility methods for appending colors at different depths. This allows rendering to better match terminal capabilities and improves color fidelity.AsciiRenderer.csto improve spatial accuracy, and ensured ANSI support is enabled by default for all renderings. [1] [2] [3]Performance and Accuracy in Character Mapping:
BrailleCharacterMapclass that mathematically generates all 256 braille patterns as 8D vectors, with SIMD-optimized brute-force matching and quantized caching for fast, accurate braille character selection. This eliminates the need for font-based lookups and boosts performance.Configuration Updates:
.claude/settings.local.jsonto support new workflows and web fetches, improving development flexibility.