Skip to content

Feature/v4.5 audio playback#8

Merged
scottgal merged 4 commits into
masterfrom
feature/v4.5-audio-playback
Feb 1, 2026
Merged

Feature/v4.5 audio playback#8
scottgal merged 4 commits into
masterfrom
feature/v4.5-audio-playback

Conversation

@scottgal
Copy link
Copy Markdown
Owner

@scottgal scottgal commented Feb 1, 2026

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:

  • Added a comprehensive new benchmark suite in ShapeMatchingBenchmarks.cs to 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.
  • Simplified all existing benchmark jobs in BrailleRendererBenchmarks.cs by removing the explicit runtime moniker, ensuring compatibility with the default environment. [1] [2] [3]

Rendering and Color Support Improvements:

  • Introduced adaptive ANSI color support in 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.
  • Adjusted sampling positions for ASCII rendering in AsciiRenderer.cs to improve spatial accuracy, and ensured ANSI support is enabled by default for all renderings. [1] [2] [3]

Performance and Accuracy in Character Mapping:

  • Added a new BrailleCharacterMap class 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:

  • Expanded the set of allowed commands and domains in .claude/settings.local.json to support new workflows and web fetches, improving development flexibility.

- 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.
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +387 to +394
// 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);
Copy link

Copilot AI Feb 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
// 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;
}

Copilot uses AI. Check for mistakes.
Comment on lines +192 to +194
foreach (var c in _frames[i].Content)
if (c == '\n')
lineCount++;
Copy link

Copilot AI Feb 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This foreach loop implicitly filters its target sequence - consider filtering the sequence explicitly using '.Where(...)'.

Copilot uses AI. Check for mistakes.
Comment on lines +1082 to +1085
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");
Copy link

Copilot AI Feb 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both branches of this 'if' statement write to the same variable - consider using '?' to express intent better.

Suggested change
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");

Copilot uses AI. Check for mistakes.
Comment on lines +551 to 554
if (_options.UseColor || _options.UseGreyscaleAnsi)
threshold = invertMode ? 0.15f : 0.85f;
else
// Monochrome: use Otsu's method for best separation
threshold = CalculateOtsuThreshold(brightness);
Copy link

Copilot AI Feb 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both branches of this 'if' statement write to the same variable - consider using '?' to express intent better.

Copilot uses AI. Check for mistakes.
Comment on lines +587 to +590
if (_options.UseColor || _options.UseGreyscaleAnsi)
baseThreshold = invertMode ? 0.15f : 0.85f;
else
baseThreshold = CalculateOtsuThreshold(baseBrightness);
Copy link

Copilot AI Feb 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both branches of this 'if' statement write to the same variable - consider using '?' to express intent better.

Copilot uses AI. Check for mistakes.
… 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.
@scottgal
Copy link
Copy Markdown
Owner Author

scottgal commented Feb 1, 2026

@copilot open a new pull request to apply changes based on the comments in this thread

Copy link
Copy Markdown

Copilot AI commented Feb 1, 2026

@scottgal I've opened a new pull request, #9, to work on those changes. Once the pull request is ready, I'll request review from you.

@scottgal scottgal merged commit c70bea4 into master Feb 1, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants