Skip to content

Commit

Permalink
tile cache strategy: treat strategies as flags
Browse files Browse the repository at this point in the history
  • Loading branch information
Grok Compression committed Dec 28, 2024
1 parent fea3a46 commit 33fc914
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 16 deletions.
6 changes: 3 additions & 3 deletions src/lib/core/cache/TileCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ TileCacheEntry::~TileCacheEntry()
{
delete processor;
}
TileCache::TileCache(GRK_TILE_CACHE_STRATEGY strategy) : tileComposite(nullptr), strategy_(strategy)
TileCache::TileCache(uint32_t strategy) : tileComposite(nullptr), strategy_(strategy)
{
tileComposite = new GrkImage();
}
Expand Down Expand Up @@ -63,11 +63,11 @@ TileCacheEntry* TileCache::get(uint16_t tile_index)

return nullptr;
}
void TileCache::setStrategy(GRK_TILE_CACHE_STRATEGY strategy)
void TileCache::setStrategy(uint32_t strategy)
{
strategy_ = strategy;
}
GRK_TILE_CACHE_STRATEGY TileCache::getStrategy(void)
uint32_t TileCache::getStrategy(void)
{
return strategy_;
}
Expand Down
8 changes: 4 additions & 4 deletions src/lib/core/cache/TileCache.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ struct TileCacheEntry
class TileCache
{
public:
TileCache(GRK_TILE_CACHE_STRATEGY strategy);
TileCache(uint32_t strategy);
TileCache(void);
virtual ~TileCache();

bool empty(void);
void setStrategy(GRK_TILE_CACHE_STRATEGY strategy);
GRK_TILE_CACHE_STRATEGY getStrategy(void);
void setStrategy(uint32_t strategy);
uint32_t getStrategy(void);
TileCacheEntry* put(uint16_t tile_index, TileProcessor* processor);
TileCacheEntry* get(uint16_t tile_index);
GrkImage* getComposite(void);
Expand All @@ -52,7 +52,7 @@ class TileCache
// each component is sub-sampled and resolution-reduced
GrkImage* tileComposite;
std::map<uint32_t, TileCacheEntry*> cache_;
GRK_TILE_CACHE_STRATEGY strategy_;
uint32_t strategy_;
};

} // namespace grk
16 changes: 9 additions & 7 deletions src/lib/core/grok.h
Original file line number Diff line number Diff line change
Expand Up @@ -580,12 +580,14 @@ typedef struct _grk_stream_params
/**
* @brief Grok tile cache strategy
*/
typedef enum _GRK_TILE_CACHE_STRATEGY
{
GRK_TILE_CACHE_NONE, /* no tile caching */
GRK_TILE_CACHE_IMAGE, /* cache final tile image */
GRK_TILE_CACHE_ALL /* cache everything */
} GRK_TILE_CACHE_STRATEGY;
/* no tile caching */
#define GRK_TILE_CACHE_NONE 0
/* cache final tile image */
#define GRK_TILE_CACHE_IMAGE 1
/* cache each code block output */
#define GRK_TILE_CACHE_BLOCK 2
/* cache everything */
#define GRK_TILE_CACHE_ALL 4

/**
* @struct grk_decompress_core_params
Expand All @@ -608,7 +610,7 @@ typedef struct _grk_decompress_core_params
used, all the quality layers are decompressed
*/
uint16_t layers_to_decompress; /* layers to decompress */
GRK_TILE_CACHE_STRATEGY tile_cache_strategy; /* tile cache strategy */
uint32_t tile_cache_strategy; /* tile cache strategy */

uint32_t random_access_flags; /* random access flags */

Expand Down
2 changes: 1 addition & 1 deletion src/lib/core/tile/TileProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ GrkImage* TileProcessor::getImage(void)
{
return image_;
}
void TileProcessor::release(GRK_TILE_CACHE_STRATEGY strategy)
void TileProcessor::release(uint32_t strategy)
{
// delete image in absence of tile cache strategy
if(strategy == GRK_TILE_CACHE_NONE)
Expand Down
2 changes: 1 addition & 1 deletion src/lib/core/tile/TileProcessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ struct TileProcessor
bool cacheTilePartPackets(CodeStreamDecompress* codeStream);
void generateImage(GrkImage* src_image, Tile* src_tile);
GrkImage* getImage(void);
void release(GRK_TILE_CACHE_STRATEGY strategy);
void release(uint32_t strategy);
void setCorruptPacket(void);
PacketTracker* getPacketTracker(void);
grk_rect32 getUnreducedTileWindow(void);
Expand Down

0 comments on commit 33fc914

Please sign in to comment.