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 BppFormatInfo & | GetFormatInfo (BppFormat format) const |
Get BPP format information. | |
std::vector< BppFormat > | GetAvailableFormats () 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 BppFormatManager & | Get () |
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, BppFormatInfo > | format_info_ |
std::unordered_map< std::string, std::vector< uint8_t > > | conversion_cache_ |
std::unordered_map< int, GraphicsSheetAnalysis > | analysis_cache_ |
std::unordered_map< std::string, int > | conversion_stats_ |
size_t | cache_memory_usage_ |
size_t | max_cache_size_ |
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:
Performance Optimizations:
ROM Hacking Specific:
Definition at line 97 of file bpp_format_manager.h.
|
privatedefault |
|
privatedefault |
|
static |
Definition at line 14 of file bpp_format_manager.cc.
Referenced by yaze::gfx::AtlasRenderer::AddBitmap(), yaze::gfx::AtlasRenderer::AddBitmapWithBppOptimization(), yaze::gfx::GraphicsOptimizer::AnalyzeSheet(), yaze::gfx::GraphicsOptimizer::ApplyOptimizations(), yaze::gfx::GraphicsOptimizer::CalculateMemorySavings(), yaze::gui::BppComparisonTool::CalculateMetrics(), yaze::gfx::BppConversionScope::Convert(), yaze::gui::Canvas::ConvertBitmapFormat(), yaze::gui::BppComparisonTool::GenerateComparisons(), yaze::gfx::GraphicsOptimizer::GenerateOptimizationReason(), yaze::gui::Canvas::GetCurrentBppFormat(), yaze::gui::BppFormatUI::GetFormatDescription(), yaze::gui::BppFormatUI::RenderAnalysisPanel(), yaze::gui::BppComparisonTool::RenderComparisonGrid(), yaze::gui::BppFormatUI::RenderConversionPreview(), yaze::gui::BppConversionDialog::RenderFormatSelector(), yaze::gui::BppFormatUI::RenderFormatSelector(), yaze::gui::BppComparisonTool::RenderMetrics(), yaze::gui::BppFormatUI::RenderSheetAnalysis(), and yaze::gui::BppConversionDialog::UpdatePreview().
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_.
const BppFormatInfo & yaze::gfx::BppFormatManager::GetFormatInfo | ( | BppFormat | format | ) | const |
Get BPP format information.
format | BPP format to get info for |
Definition at line 47 of file bpp_format_manager.cc.
References format_info_.
Referenced by AnalyzeGraphicsSheet(), yaze::gfx::GraphicsOptimizer::AnalyzeSheet(), yaze::gfx::GraphicsOptimizer::CalculateMemorySavings(), yaze::gui::BppComparisonTool::CalculateMetrics(), yaze::gfx::GraphicsOptimizer::GenerateOptimizationReason(), yaze::gui::BppFormatUI::GetFormatDescription(), OptimizePaletteForFormat(), yaze::gui::BppFormatUI::RenderAnalysisPanel(), yaze::gui::BppComparisonTool::RenderComparisonGrid(), yaze::gui::BppFormatUI::RenderConversionPreview(), yaze::gui::BppConversionDialog::RenderFormatSelector(), yaze::gui::BppFormatUI::RenderFormatSelector(), and yaze::gui::BppComparisonTool::RenderMetrics().
std::vector< BppFormat > yaze::gfx::BppFormatManager::GetAvailableFormats | ( | ) | const |
Get all available BPP formats.
Definition at line 55 of file bpp_format_manager.cc.
References yaze::gfx::kBpp2, yaze::gfx::kBpp3, yaze::gfx::kBpp4, and yaze::gfx::kBpp8.
Referenced by yaze::gui::BppComparisonTool::GenerateComparisons(), yaze::gui::BppFormatUI::RenderAnalysisPanel(), yaze::gui::BppComparisonTool::RenderComparisonGrid(), and yaze::gui::BppComparisonTool::RenderMetrics().
std::vector< uint8_t > yaze::gfx::BppFormatManager::ConvertFormat | ( | const std::vector< uint8_t > & | data, |
BppFormat | from_format, | ||
BppFormat | to_format, | ||
int | width, | ||
int | height | ||
) |
Convert bitmap data between BPP formats.
data | Source bitmap data |
from_format | Source BPP format |
to_format | Target BPP format |
width | Bitmap width |
height | Bitmap height |
Definition at line 59 of file bpp_format_manager.cc.
References cache_memory_usage_, conversion_cache_, conversion_stats_, Convert2BppTo8Bpp(), Convert3BppTo8Bpp(), Convert4BppTo8Bpp(), Convert8BppTo2Bpp(), Convert8BppTo3Bpp(), Convert8BppTo4Bpp(), GenerateCacheKey(), yaze::gfx::kBpp2, yaze::gfx::kBpp3, yaze::gfx::kBpp4, yaze::gfx::kBpp8, and max_cache_size_.
Referenced by yaze::gfx::AtlasRenderer::AddBitmapWithBppOptimization(), yaze::gfx::GraphicsOptimizer::ApplyOptimizations(), yaze::gfx::BppConversionScope::Convert(), yaze::gui::Canvas::ConvertBitmapFormat(), yaze::gui::BppComparisonTool::GenerateComparisons(), yaze::gui::BppFormatUI::RenderConversionPreview(), and yaze::gui::BppConversionDialog::UpdatePreview().
GraphicsSheetAnalysis yaze::gfx::BppFormatManager::AnalyzeGraphicsSheet | ( | const std::vector< uint8_t > & | sheet_data, |
int | sheet_id, | ||
const SnesPalette & | palette | ||
) |
Analyze graphics sheet to determine original and current BPP formats.
sheet_data | Graphics sheet data |
sheet_id | Sheet identifier |
palette | Palette data for analysis |
Definition at line 129 of file bpp_format_manager.cc.
References analysis_cache_, AnalyzeTileUsagePattern(), yaze::gfx::GraphicsSheetAnalysis::compression_ratio, yaze::gfx::GraphicsSheetAnalysis::conversion_history, CountUsedColors(), yaze::gfx::GraphicsSheetAnalysis::current_format, yaze::gfx::GraphicsSheetAnalysis::current_size, DetectFormat(), GetFormatInfo(), yaze::gfx::kBpp2, yaze::gfx::kBpp3, yaze::gfx::kBpp4, yaze::gfx::kBpp8, yaze::gfx::BppFormatInfo::name, yaze::gfx::GraphicsSheetAnalysis::original_format, yaze::gfx::GraphicsSheetAnalysis::original_size, yaze::gfx::GraphicsSheetAnalysis::palette_entries_used, yaze::gfx::GraphicsSheetAnalysis::sheet_id, yaze::gfx::SnesPalette::size(), yaze::gfx::GraphicsSheetAnalysis::tile_usage_pattern, and yaze::gfx::GraphicsSheetAnalysis::was_converted.
Referenced by yaze::gui::BppFormatUI::RenderSheetAnalysis().
BppFormat yaze::gfx::BppFormatManager::DetectFormat | ( | const std::vector< uint8_t > & | data, |
int | width, | ||
int | height | ||
) |
Detect BPP format from bitmap data.
Definition at line 189 of file bpp_format_manager.cc.
References AnalyzeColorDepth(), and yaze::gfx::kBpp8.
Referenced by yaze::gfx::AtlasRenderer::AddBitmap(), yaze::gfx::AtlasRenderer::AddBitmapWithBppOptimization(), AnalyzeGraphicsSheet(), yaze::gfx::GraphicsOptimizer::AnalyzeSheet(), yaze::gui::BppComparisonTool::GenerateComparisons(), yaze::gui::Canvas::GetCurrentBppFormat(), yaze::gui::BppFormatUI::RenderAnalysisPanel(), yaze::gui::BppFormatUI::RenderConversionPreview(), yaze::gui::BppFormatUI::RenderFormatSelector(), and yaze::gui::BppConversionDialog::UpdatePreview().
SnesPalette yaze::gfx::BppFormatManager::OptimizePaletteForFormat | ( | const SnesPalette & | palette, |
BppFormat | target_format, | ||
const std::vector< int > & | used_colors | ||
) |
Optimize palette for specific BPP format.
palette | Source palette |
target_format | Target BPP format |
used_colors | Vector of actually used color indices |
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().
std::unordered_map< std::string, int > yaze::gfx::BppFormatManager::GetConversionStats | ( | ) | const |
Get conversion statistics.
Definition at line 227 of file bpp_format_manager.cc.
References conversion_stats_.
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_.
std::pair< size_t, size_t > yaze::gfx::BppFormatManager::GetMemoryStats | ( | ) | const |
Get memory usage statistics.
Definition at line 238 of file bpp_format_manager.cc.
References cache_memory_usage_, and max_cache_size_.
|
private |
Definition at line 25 of file bpp_format_manager.cc.
References format_info_, yaze::gfx::kBpp2, yaze::gfx::kBpp3, yaze::gfx::kBpp4, and yaze::gfx::kBpp8.
Referenced by Initialize().
|
private |
Definition at line 244 of file bpp_format_manager.cc.
Referenced by ConvertFormat().
|
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().
|
private |
Definition at line 285 of file bpp_format_manager.cc.
Referenced by ConvertFormat().
|
private |
Definition at line 305 of file bpp_format_manager.cc.
References Convert4BppTo8Bpp().
Referenced by ConvertFormat().
|
private |
Definition at line 310 of file bpp_format_manager.cc.
Referenced by Convert3BppTo8Bpp(), and ConvertFormat().
|
private |
Definition at line 333 of file bpp_format_manager.cc.
Referenced by ConvertFormat().
|
private |
Definition at line 353 of file bpp_format_manager.cc.
References Convert8BppTo4Bpp().
Referenced by ConvertFormat().
|
private |
Definition at line 360 of file bpp_format_manager.cc.
Referenced by Convert8BppTo3Bpp(), and ConvertFormat().
|
private |
Definition at line 376 of file bpp_format_manager.cc.
Referenced by AnalyzeGraphicsSheet().
|
private |
Definition at line 393 of file bpp_format_manager.cc.
|
private |
Definition at line 399 of file bpp_format_manager.cc.
Referenced by AnalyzeGraphicsSheet().
|
private |
Definition at line 185 of file bpp_format_manager.h.
Referenced by GetFormatInfo(), and InitializeFormatInfo().
|
private |
Definition at line 188 of file bpp_format_manager.h.
Referenced by ClearCache(), and ConvertFormat().
|
private |
Definition at line 191 of file bpp_format_manager.h.
Referenced by AnalyzeGraphicsSheet(), and ClearCache().
|
private |
Definition at line 194 of file bpp_format_manager.h.
Referenced by ClearCache(), ConvertFormat(), and GetConversionStats().
|
private |
Definition at line 197 of file bpp_format_manager.h.
Referenced by ClearCache(), ConvertFormat(), GetMemoryStats(), and Initialize().
|
private |
Definition at line 198 of file bpp_format_manager.h.
Referenced by ConvertFormat(), GetMemoryStats(), and Initialize().