yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
yaze::gfx::BppFormatManager Class Reference

Comprehensive BPP format management system for SNES ROM hacking. More...

#include <bpp_format_manager.h>

Public Member Functions

void Initialize ()
 Initialize the BPP format manager.
 
const BppFormatInfoGetFormatInfo (BppFormat format) const
 Get BPP format information.
 
std::vector< BppFormatGetAvailableFormats () const
 Get all available BPP formats.
 
std::vector< uint8_t > ConvertFormat (const std::vector< uint8_t > &data, BppFormat from_format, BppFormat to_format, int width, int height)
 Convert bitmap data between BPP formats.
 
GraphicsSheetAnalysis AnalyzeGraphicsSheet (const std::vector< uint8_t > &sheet_data, int sheet_id, const SnesPalette &palette)
 Analyze graphics sheet to determine original and current BPP formats.
 
BppFormat DetectFormat (const std::vector< uint8_t > &data, int width, int height)
 Detect BPP format from bitmap data.
 
SnesPalette OptimizePaletteForFormat (const SnesPalette &palette, BppFormat target_format, const std::vector< int > &used_colors)
 Optimize palette for specific BPP format.
 
std::unordered_map< std::string, int > GetConversionStats () const
 Get conversion statistics.
 
void ClearCache ()
 Clear conversion cache.
 
std::pair< size_t, size_t > GetMemoryStats () const
 Get memory usage statistics.
 

Static Public Member Functions

static BppFormatManagerGet ()
 

Private Member Functions

 BppFormatManager ()=default
 
 ~BppFormatManager ()=default
 
void InitializeFormatInfo ()
 
std::string GenerateCacheKey (const std::vector< uint8_t > &data, BppFormat from_format, BppFormat to_format, int width, int height)
 
BppFormat AnalyzeColorDepth (const std::vector< uint8_t > &data, int width, int height)
 
std::vector< uint8_t > Convert2BppTo8Bpp (const std::vector< uint8_t > &data, int width, int height)
 
std::vector< uint8_t > Convert3BppTo8Bpp (const std::vector< uint8_t > &data, int width, int height)
 
std::vector< uint8_t > Convert4BppTo8Bpp (const std::vector< uint8_t > &data, int width, int height)
 
std::vector< uint8_t > Convert8BppTo2Bpp (const std::vector< uint8_t > &data, int width, int height)
 
std::vector< uint8_t > Convert8BppTo3Bpp (const std::vector< uint8_t > &data, int width, int height)
 
std::vector< uint8_t > Convert8BppTo4Bpp (const std::vector< uint8_t > &data, int width, int height)
 
int CountUsedColors (const std::vector< uint8_t > &data, int max_colors)
 
float CalculateCompressionRatio (const std::vector< uint8_t > &original, const std::vector< uint8_t > &compressed)
 
std::vector< int > AnalyzeTileUsagePattern (const std::vector< uint8_t > &data, int width, int height, int tile_size)
 

Private Attributes

std::unordered_map< BppFormat, BppFormatInfoformat_info_
 
std::unordered_map< std::string, std::vector< uint8_t > > conversion_cache_
 
std::unordered_map< int, GraphicsSheetAnalysisanalysis_cache_
 
std::unordered_map< std::string, int > conversion_stats_
 
size_t cache_memory_usage_
 
size_t max_cache_size_
 

Detailed Description

Comprehensive BPP format management system for SNES ROM hacking.

The BppFormatManager provides advanced BPP format handling, conversion, and analysis capabilities specifically designed for Link to the Past ROM hacking workflows.

Key Features:

  • Multi-format BPP support (2BPP, 3BPP, 4BPP, 8BPP)
  • Intelligent format detection and analysis
  • High-performance format conversion with caching
  • Graphics sheet analysis and conversion history tracking
  • Palette depth analysis and optimization
  • Memory-efficient conversion algorithms

Performance Optimizations:

  • Cached conversion results to avoid redundant processing
  • SIMD-optimized conversion algorithms where possible
  • Lazy evaluation for expensive analysis operations
  • Memory pool integration for efficient temporary allocations

ROM Hacking Specific:

  • SNES-specific BPP format handling
  • Graphics sheet format analysis and conversion tracking
  • Palette optimization based on actual color usage
  • Integration with existing YAZE graphics pipeline

Definition at line 97 of file bpp_format_manager.h.

Constructor & Destructor Documentation

◆ BppFormatManager()

yaze::gfx::BppFormatManager::BppFormatManager ( )
privatedefault

◆ ~BppFormatManager()

yaze::gfx::BppFormatManager::~BppFormatManager ( )
privatedefault

Member Function Documentation

◆ Get()

◆ Initialize()

void yaze::gfx::BppFormatManager::Initialize ( )

Initialize the BPP format manager.

Definition at line 19 of file bpp_format_manager.cc.

References cache_memory_usage_, InitializeFormatInfo(), and max_cache_size_.

Here is the call graph for this function:

◆ GetFormatInfo()

◆ GetAvailableFormats()

std::vector< BppFormat > yaze::gfx::BppFormatManager::GetAvailableFormats ( ) const

◆ ConvertFormat()

std::vector< uint8_t > yaze::gfx::BppFormatManager::ConvertFormat ( const std::vector< uint8_t > &  data,
BppFormat  from_format,
BppFormat  to_format,
int  width,
int  height 
)

◆ AnalyzeGraphicsSheet()

◆ DetectFormat()

BppFormat yaze::gfx::BppFormatManager::DetectFormat ( const std::vector< uint8_t > &  data,
int  width,
int  height 
)

◆ OptimizePaletteForFormat()

SnesPalette yaze::gfx::BppFormatManager::OptimizePaletteForFormat ( const SnesPalette palette,
BppFormat  target_format,
const std::vector< int > &  used_colors 
)

Optimize palette for specific BPP format.

Parameters
paletteSource palette
target_formatTarget BPP format
used_colorsVector of actually used color indices
Returns
Optimized palette

Definition at line 198 of file bpp_format_manager.cc.

References yaze::gfx::SnesPalette::AddColor(), GetFormatInfo(), and yaze::gfx::SnesPalette::size().

Referenced by yaze::gfx::GraphicsOptimizer::ApplyOptimizations().

Here is the call graph for this function:

◆ GetConversionStats()

std::unordered_map< std::string, int > yaze::gfx::BppFormatManager::GetConversionStats ( ) const

Get conversion statistics.

Returns
Map of conversion operation statistics

Definition at line 227 of file bpp_format_manager.cc.

References conversion_stats_.

◆ ClearCache()

void yaze::gfx::BppFormatManager::ClearCache ( )

Clear conversion cache.

Definition at line 231 of file bpp_format_manager.cc.

References analysis_cache_, cache_memory_usage_, yaze::gfx::SnesPalette::clear(), conversion_cache_, and conversion_stats_.

Here is the call graph for this function:

◆ GetMemoryStats()

std::pair< size_t, size_t > yaze::gfx::BppFormatManager::GetMemoryStats ( ) const

Get memory usage statistics.

Returns
Memory usage information

Definition at line 238 of file bpp_format_manager.cc.

References cache_memory_usage_, and max_cache_size_.

◆ InitializeFormatInfo()

void yaze::gfx::BppFormatManager::InitializeFormatInfo ( )
private

◆ GenerateCacheKey()

std::string yaze::gfx::BppFormatManager::GenerateCacheKey ( const std::vector< uint8_t > &  data,
BppFormat  from_format,
BppFormat  to_format,
int  width,
int  height 
)
private

Definition at line 244 of file bpp_format_manager.cc.

Referenced by ConvertFormat().

◆ AnalyzeColorDepth()

BppFormat yaze::gfx::BppFormatManager::AnalyzeColorDepth ( const std::vector< uint8_t > &  data,
int  width,
int  height 
)
private

Definition at line 261 of file bpp_format_manager.cc.

References yaze::gfx::kBpp2, yaze::gfx::kBpp3, yaze::gfx::kBpp4, and yaze::gfx::kBpp8.

Referenced by DetectFormat().

◆ Convert2BppTo8Bpp()

std::vector< uint8_t > yaze::gfx::BppFormatManager::Convert2BppTo8Bpp ( const std::vector< uint8_t > &  data,
int  width,
int  height 
)
private

Definition at line 285 of file bpp_format_manager.cc.

Referenced by ConvertFormat().

◆ Convert3BppTo8Bpp()

std::vector< uint8_t > yaze::gfx::BppFormatManager::Convert3BppTo8Bpp ( const std::vector< uint8_t > &  data,
int  width,
int  height 
)
private

Definition at line 305 of file bpp_format_manager.cc.

References Convert4BppTo8Bpp().

Referenced by ConvertFormat().

Here is the call graph for this function:

◆ Convert4BppTo8Bpp()

std::vector< uint8_t > yaze::gfx::BppFormatManager::Convert4BppTo8Bpp ( const std::vector< uint8_t > &  data,
int  width,
int  height 
)
private

Definition at line 310 of file bpp_format_manager.cc.

Referenced by Convert3BppTo8Bpp(), and ConvertFormat().

◆ Convert8BppTo2Bpp()

std::vector< uint8_t > yaze::gfx::BppFormatManager::Convert8BppTo2Bpp ( const std::vector< uint8_t > &  data,
int  width,
int  height 
)
private

Definition at line 333 of file bpp_format_manager.cc.

Referenced by ConvertFormat().

◆ Convert8BppTo3Bpp()

std::vector< uint8_t > yaze::gfx::BppFormatManager::Convert8BppTo3Bpp ( const std::vector< uint8_t > &  data,
int  width,
int  height 
)
private

Definition at line 353 of file bpp_format_manager.cc.

References Convert8BppTo4Bpp().

Referenced by ConvertFormat().

Here is the call graph for this function:

◆ Convert8BppTo4Bpp()

std::vector< uint8_t > yaze::gfx::BppFormatManager::Convert8BppTo4Bpp ( const std::vector< uint8_t > &  data,
int  width,
int  height 
)
private

Definition at line 360 of file bpp_format_manager.cc.

Referenced by Convert8BppTo3Bpp(), and ConvertFormat().

◆ CountUsedColors()

int yaze::gfx::BppFormatManager::CountUsedColors ( const std::vector< uint8_t > &  data,
int  max_colors 
)
private

Definition at line 376 of file bpp_format_manager.cc.

Referenced by AnalyzeGraphicsSheet().

◆ CalculateCompressionRatio()

float yaze::gfx::BppFormatManager::CalculateCompressionRatio ( const std::vector< uint8_t > &  original,
const std::vector< uint8_t > &  compressed 
)
private

Definition at line 393 of file bpp_format_manager.cc.

◆ AnalyzeTileUsagePattern()

std::vector< int > yaze::gfx::BppFormatManager::AnalyzeTileUsagePattern ( const std::vector< uint8_t > &  data,
int  width,
int  height,
int  tile_size 
)
private

Definition at line 399 of file bpp_format_manager.cc.

Referenced by AnalyzeGraphicsSheet().

Member Data Documentation

◆ format_info_

std::unordered_map<BppFormat, BppFormatInfo> yaze::gfx::BppFormatManager::format_info_
private

Definition at line 185 of file bpp_format_manager.h.

Referenced by GetFormatInfo(), and InitializeFormatInfo().

◆ conversion_cache_

std::unordered_map<std::string, std::vector<uint8_t> > yaze::gfx::BppFormatManager::conversion_cache_
private

Definition at line 188 of file bpp_format_manager.h.

Referenced by ClearCache(), and ConvertFormat().

◆ analysis_cache_

std::unordered_map<int, GraphicsSheetAnalysis> yaze::gfx::BppFormatManager::analysis_cache_
private

Definition at line 191 of file bpp_format_manager.h.

Referenced by AnalyzeGraphicsSheet(), and ClearCache().

◆ conversion_stats_

std::unordered_map<std::string, int> yaze::gfx::BppFormatManager::conversion_stats_
private

Definition at line 194 of file bpp_format_manager.h.

Referenced by ClearCache(), ConvertFormat(), and GetConversionStats().

◆ cache_memory_usage_

size_t yaze::gfx::BppFormatManager::cache_memory_usage_
private

Definition at line 197 of file bpp_format_manager.h.

Referenced by ClearCache(), ConvertFormat(), GetMemoryStats(), and Initialize().

◆ max_cache_size_

size_t yaze::gfx::BppFormatManager::max_cache_size_
private

Definition at line 198 of file bpp_format_manager.h.

Referenced by ConvertFormat(), GetMemoryStats(), and Initialize().


The documentation for this class was generated from the following files: