Skip to content

Commit

Permalink
api: remove trailing underscore from some struct members - now consis…
Browse files Browse the repository at this point in the history
…tent
  • Loading branch information
Grok Compression committed Nov 22, 2024
1 parent 5c76eb7 commit 0add64c
Show file tree
Hide file tree
Showing 14 changed files with 128 additions and 130 deletions.
40 changes: 20 additions & 20 deletions src/lib/codec/image_format/BMPFormat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,11 +173,11 @@ bool BMPFormat::encodeHeader(void)
*header_ptr++ = 0;
}
}
destBuff.data_ = header_;
destBuff.offset_ = off_;
destBuff.pooled_ = false;
destBuff.len_ = header_plus_lut;
if(write(destBuff) != destBuff.len_)
destBuff.data = header_;
destBuff.offset = off_;
destBuff.pooled = false;
destBuff.len = header_plus_lut;
if(write(destBuff) != destBuff.len)
goto cleanup;
off_ += header_plus_lut;
ret = true;
Expand Down Expand Up @@ -234,7 +234,7 @@ bool BMPFormat::encodePixels()
// zero out padding at end of line
if(pad_dest)
{
uint8_t* ptr = destBuff.data_ + w_dest - pad_dest;
uint8_t* ptr = destBuff.data + w_dest - pad_dest;
for(uint32_t m = 0; m < image_->rows_per_strip; ++m)
{
memset(ptr, 0, pad_dest);
Expand Down Expand Up @@ -263,24 +263,24 @@ bool BMPFormat::encodePixels()
}
if(decompress_num_comps == 1)
{
destBuff.data_[destInd++] = rc[0];
destBuff.data[destInd++] = rc[0];
}
else
{
destBuff.data_[destInd++] = rc[2];
destBuff.data_[destInd++] = rc[1];
destBuff.data_[destInd++] = rc[0];
destBuff.data[destInd++] = rc[2];
destBuff.data[destInd++] = rc[1];
destBuff.data[destInd++] = rc[0];
if(decompress_num_comps == 4)
destBuff.data_[destInd++] = rc[3];
destBuff.data[destInd++] = rc[3];
}
}
destInd += pad_dest;
srcIndex_ -= stride_src;
}
destBuff.offset_ = off_;
destBuff.pooled_ = true;
destBuff.len_ = destInd;
if(write(destBuff) != destBuff.len_)
destBuff.offset = off_;
destBuff.pooled = true;
destBuff.len = destInd;
if(write(destBuff) != destBuff.len)
goto cleanup;
destBuff = pool.get(packedLen);
// pooled buffer may not have been zero-padded
Expand Down Expand Up @@ -310,11 +310,11 @@ bool BMPFormat::encodeFinish(void)
if(image_->meta && image_->meta->color.icc_profile_buf)
{
GrkIOBuf destBuff;
destBuff.data_ = image_->meta->color.icc_profile_buf;
destBuff.offset_ = off_;
destBuff.pooled_ = false;
destBuff.len_ = image_->meta->color.icc_profile_len;
if(write(destBuff) != destBuff.len_)
destBuff.data = image_->meta->color.icc_profile_buf;
destBuff.offset = off_;
destBuff.pooled = false;
destBuff.len = image_->meta->color.icc_profile_len;
if(write(destBuff) != destBuff.len)
return false;
off_ += image_->meta->color.icc_profile_len;
}
Expand Down
10 changes: 5 additions & 5 deletions src/lib/codec/image_format/BufferPool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ GrkIOBuf BufferPool::get(size_t len)
{
for(auto iter = pool.begin(); iter != pool.end(); ++iter)
{
if(iter->second.alloc_len_ >= len)
if(iter->second.alloc_len >= len)
{
auto b = iter->second;
b.len_ = len;
b.len = len;
pool.erase(iter);
// printf("Buffer pool get %p\n", b.data);
return b;
Expand All @@ -28,7 +28,7 @@ GrkIOBuf BufferPool::get(size_t len)
}
void BufferPool::put(GrkIOBuf b)
{
assert(b.data_);
assert(pool.find(b.data_) == pool.end());
pool[b.data_] = b;
assert(b.data);
assert(pool.find(b.data) == pool.end());
pool[b.data] = b;
}
8 changes: 4 additions & 4 deletions src/lib/codec/image_format/FileStreamIO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,11 @@ uint64_t FileStreamIO::write(uint8_t* buf, [[maybe_unused]] uint64_t offset, siz
}
uint64_t FileStreamIO::write(GrkIOBuf buffer)
{
auto actual = fwrite(buffer.data_, 1, buffer.len_, fileHandle_);
if(actual < buffer.len_)
spdlog::error("wrote fewer bytes {} than expected number of bytes {}.", actual, buffer.len_);
auto actual = fwrite(buffer.data, 1, buffer.len, fileHandle_);
if(actual < buffer.len)
spdlog::error("wrote fewer bytes {} than expected number of bytes {}.", actual, buffer.len);

return buffer.len_;
return buffer.len;
}
bool FileStreamIO::read(uint8_t* buf, size_t len)
{
Expand Down
36 changes: 18 additions & 18 deletions src/lib/codec/image_format/IFileIO.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,41 +28,41 @@ struct GrkIOBuf : public grk_io_buf
GrkIOBuf() : GrkIOBuf(nullptr, 0, 0, 0, false) {}
GrkIOBuf(uint8_t* data, size_t offset, size_t dataLen, size_t allocLen, bool pooled)
{
data_ = data;
offset_ = offset;
len_ = dataLen;
alloc_len_ = allocLen;
pooled_ = pooled;
this->data = data;
this->offset = offset;
this->len = dataLen;
this->alloc_len = allocLen;
this->pooled = pooled;
}
explicit GrkIOBuf(const grk_io_buf rhs)
{
data_ = rhs.data_;
offset_ = rhs.offset_;
len_ = rhs.len_;
alloc_len_ = rhs.alloc_len_;
pooled_ = rhs.pooled_;
data = rhs.data;
offset = rhs.offset;
len = rhs.len;
alloc_len = rhs.alloc_len;
pooled = rhs.pooled;
}
bool alloc(size_t len)
{
dealloc();
data_ = (uint8_t*)grk_bin::grk_aligned_malloc(len);
if(data_)
data = (uint8_t*)grk_bin::grk_aligned_malloc(len);
if(data)
{
// printf("Allocated %p\n", data);
len_ = len;
alloc_len_ = len;
this->len = len;
alloc_len = len;
}

return data_ != nullptr;
return data != nullptr;
}
void dealloc()
{
if(data_)
if(data)
{
grk_bin::grk_aligned_free(data_);
grk_bin::grk_aligned_free(data);
// printf("Deallocated %p\n", data);
}
data_ = nullptr;
data = nullptr;
}
};

Expand Down
10 changes: 5 additions & 5 deletions src/lib/codec/image_format/ImageFormat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ ImageFormat::ImageFormat()
encodeState(IMAGE_FORMAT_UNENCODED)
{
grk_io_init init;
init.max_pooled_requests_ = 0;
init.max_pooled_requests = 0;
registerGrkReclaimCallback(init, grkReclaimCallback, &pool);
}
ImageFormat::~ImageFormat()
Expand All @@ -48,8 +48,8 @@ void ImageFormat::registerGrkReclaimCallback(grk_io_init io_init, grk_io_callbac
void* user_data)
{
serializer.registerGrkReclaimCallback(io_init, reclaim_callback, user_data);
if(io_init.max_pooled_requests_)
serializer.setMaxPooledRequests(io_init.max_pooled_requests_);
if(io_init.max_pooled_requests)
serializer.setMaxPooledRequests(io_init.max_pooled_requests);
}
void ImageFormat::ioReclaimBuffer(uint32_t threadId, grk_io_buf buffer)
{
Expand Down Expand Up @@ -129,7 +129,7 @@ void ImageFormat::applicationOrchestratedReclaim([[maybe_unused]] GrkIOBuf buf)
*/
bool ImageFormat::encodePixelsCoreWrite(grk_io_buf pixels)
{
return (serializer.write(pixels.data_, pixels.len_) == pixels.len_);
return (serializer.write(pixels.data, pixels.len) == pixels.len);
}
bool ImageFormat::encodeFinish(void)
{
Expand All @@ -153,7 +153,7 @@ uint64_t ImageFormat::write(GrkIOBuf buffer)
{
auto rc = fileIO_->write(buffer);
#ifndef GROK_HAVE_URING
if(buffer.pooled_)
if(buffer.pooled)
pool.put(buffer);
#endif

Expand Down
10 changes: 5 additions & 5 deletions src/lib/codec/image_format/PNMFormat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,13 +209,13 @@ bool PNMFormat::encodeRows([[maybe_unused]] uint32_t rows)
{
uint32_t stripRows = (std::min)(image_->rows_per_strip, height - h);
packedBuf = pool.get(image_->packed_row_bytes * stripRows);
iter->interleave((int32_t**)planes, decompress_num_comps, packedBuf.data_,
iter->interleave((int32_t**)planes, decompress_num_comps, packedBuf.data,
image_->decompress_width, image_->comps[0].stride,
image_->packed_row_bytes, stripRows, adjust);
packedBuf.pooled_ = true;
packedBuf.offset_ = serializer.getOffset();
packedBuf.len_ = image_->packed_row_bytes * stripRows;
packedBuf.index_ = serializer.getNumPooledRequests();
packedBuf.pooled = true;
packedBuf.offset = serializer.getOffset();
packedBuf.len = image_->packed_row_bytes * stripRows;
packedBuf.index = serializer.getNumPooledRequests();
if(!encodePixelsCore(0, packedBuf))
{
delete iter;
Expand Down
33 changes: 16 additions & 17 deletions src/lib/codec/image_format/TIFFFormat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ void TIFFFormat::registerGrkReclaimCallback(grk_io_init io_init, grk_io_callback
{
grkReclaimCallback_ = reclaim_callback;
grkReclaimUserData_ = user_data;
if(io_init.max_pooled_requests_)
serializer.setMaxPooledRequests(io_init.max_pooled_requests_);
if(io_init.max_pooled_requests)
serializer.setMaxPooledRequests(io_init.max_pooled_requests);
}
bool TIFFFormat::encodeInit(grk_image* image, const std::string& filename,
uint32_t compression_level, uint32_t concurrency)
Expand Down Expand Up @@ -409,21 +409,21 @@ bool TIFFFormat::encodePixels()
uint64_t packedLengthEncoded =
(uint64_t)TIFFVStripSize(tif_, (uint32_t)image_->rows_per_strip);
packedBuf = pool.get(packedLengthEncoded);
auto bufPtr = (int8_t*)packedBuf.data_;
auto bufPtr = (int8_t*)packedBuf.data;
uint32_t bytesToWrite = 0;
uint32_t rowsWritten = 0;
for(; h < rowsWritten + height; h += chroma_subsample_y)
{
uint32_t rowsSoFar = h - rowsWritten;
if(bytesToWrite > 0 && rowsSoFar > 0 && (rowsSoFar % image_->rows_per_strip == 0))
{
packedBuf.len_ = bytesToWrite;
packedBuf.offset_ = serializer.getOffset();
packedBuf.index_ = serializer.getNumPooledRequests();
packedBuf.len = bytesToWrite;
packedBuf.offset = serializer.getOffset();
packedBuf.index = serializer.getNumPooledRequests();
if(!encodePixelsCore(0, packedBuf))
goto cleanup;
packedBuf = pool.get(packedLengthEncoded);
bufPtr = (int8_t*)(packedBuf.data_);
bufPtr = (int8_t*)(packedBuf.data);
bytesToWrite = 0;
}
size_t xposLuma = 0;
Expand Down Expand Up @@ -463,9 +463,9 @@ bool TIFFFormat::encodePixels()
if(h != rowsWritten)
rowsWritten += h - chroma_subsample_y - rowsWritten;
// cleanup
packedBuf.len_ = bytesToWrite;
packedBuf.offset_ = serializer.getOffset();
packedBuf.index_ = serializer.getNumPooledRequests();
packedBuf.len = bytesToWrite;
packedBuf.offset = serializer.getOffset();
packedBuf.index = serializer.getNumPooledRequests();
if(bytesToWrite && !encodePixelsCore(0, packedBuf))
goto cleanup;
}
Expand All @@ -478,12 +478,12 @@ bool TIFFFormat::encodePixels()
{
uint32_t stripRows = (std::min)(image_->rows_per_strip, height - h);
packedBuf = pool.get(image_->packed_row_bytes * stripRows);
iter->interleave((int32_t**)planes, numcomps, packedBuf.data_, image_->decompress_width,
iter->interleave((int32_t**)planes, numcomps, packedBuf.data, image_->decompress_width,
image_->comps[0].stride, image_->packed_row_bytes, stripRows, 0);
packedBuf.pooled_ = true;
packedBuf.offset_ = serializer.getOffset();
packedBuf.len_ = image_->packed_row_bytes * stripRows;
packedBuf.index_ = serializer.getNumPooledRequests();
packedBuf.pooled = true;
packedBuf.offset = serializer.getOffset();
packedBuf.len = image_->packed_row_bytes * stripRows;
packedBuf.index = serializer.getNumPooledRequests();
if(!encodePixelsCore(0, packedBuf))
{
delete iter;
Expand All @@ -503,8 +503,7 @@ bool TIFFFormat::encodePixels()
*/
bool TIFFFormat::encodePixelsCoreWrite(grk_io_buf pixels)
{
tmsize_t written =
TIFFWriteEncodedStrip(tif_, pixels.index_, pixels.data_, (tmsize_t)pixels.len_);
tmsize_t written = TIFFWriteEncodedStrip(tif_, pixels.index, pixels.data, (tmsize_t)pixels.len);
return written != -1;
}
bool TIFFFormat::encodeFinish(void)
Expand Down
2 changes: 1 addition & 1 deletion src/lib/codec/jp2/GrkCompress.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1188,7 +1188,7 @@ GrkRC GrkCompress::parseCommandLine(int argc, char* argv[], CompressInitParams*
inputFolder->set_out_format = false;
parameters->raw_cp.width = 0;
if(applyICCOpt->count() > 0)
parameters->apply_icc_ = true;
parameters->apply_icc = true;
if(pltOpt->count() > 0)
parameters->write_plt = true;
if(tlmOpt->count() > 0)
Expand Down
22 changes: 11 additions & 11 deletions src/lib/codec/jp2/GrkDecompress.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -638,18 +638,18 @@ GrkRC GrkDecompress::parseCommandLine(int argc, char* argv[], DecompressInitPara
CLI11_PARSE_CUSTOM(cmd, argc, argv);

if(verboseOpt->count() > 0)
parameters->verbose_ = true;
parameters->verbose = true;
else
spdlog::set_level(spdlog::level::level_enum::err);
grk_set_msg_handlers({parameters->verbose_ ? infoCallback : nullptr, nullptr,
parameters->verbose_ ? warningCallback : nullptr, nullptr, errorCallback,
grk_set_msg_handlers({parameters->verbose ? infoCallback : nullptr, nullptr,
parameters->verbose ? warningCallback : nullptr, nullptr, errorCallback,
nullptr});
bool useStdio =
inputFileOpt->count() > 0 && outForOpt->count() > 0 && outputFileOpt->count() == 0;
// disable verbose mode so we don't write info or warnings to stdout
if(useStdio)
parameters->verbose_ = false;
if(!parameters->verbose_)
parameters->verbose = false;
if(!parameters->verbose)
spdlog::set_level(spdlog::level::level_enum::err);

if(logfileOpt->count() > 0)
Expand Down Expand Up @@ -826,9 +826,9 @@ GrkRC GrkDecompress::parseCommandLine(int argc, char* argv[], DecompressInitPara
parameters->core.reduce = (uint8_t)reduce;
}
if(layerOpt->count() > 0)
parameters->core.layers_to_decompress_ = layer;
parameters->core.layers_to_decompress = layer;
if(randomAccessOpt->count() > 0)
parameters->core.random_access_flags_ = randomAccess;
parameters->core.random_access_flags = randomAccess;
parameters->single_tile_decompress = tileOpt->count() > 0;
if(tileOpt->count() > 0)
parameters->tile_index = (uint16_t)tile;
Expand Down Expand Up @@ -980,20 +980,20 @@ GrkRC GrkDecompress::pluginMain(int argc, char* argv[], DecompressInitParams* in
if(parseReturn != GrkRCSuccess)
return parseReturn;
#ifdef GROK_HAVE_LIBTIFF
tiffSetErrorAndWarningHandlers(initParams->parameters.verbose_);
tiffSetErrorAndWarningHandlers(initParams->parameters.verbose);
#endif
#ifdef GROK_HAVE_LIBPNG
pngSetVerboseFlag(initParams->parameters.verbose_);
pngSetVerboseFlag(initParams->parameters.verbose);
#endif
initParams->initialized = true;
// loads plugin but does not actually create codec
grk_initialize(initParams->pluginPath, initParams->parameters.num_threads,
initParams->parameters.verbose_);
initParams->parameters.verbose);

// create codec
grk_plugin_init_info initInfo;
initInfo.device_id = initParams->parameters.device_id;
initInfo.verbose = initParams->parameters.verbose_;
initInfo.verbose = initParams->parameters.verbose;
if(!grk_plugin_init(initInfo))
goto cleanup;
initParams->parameters.user_data = this;
Expand Down
2 changes: 1 addition & 1 deletion src/lib/core/codestream/CodeStreamCompress.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ bool CodeStreamCompress::init(grk_cparameters* parameters, GrkImage* image)
return false;
}
}
if(parameters->apply_icc_)
if(parameters->apply_icc)
image->applyICC();

// create private sanitized copy of image
Expand Down
Loading

0 comments on commit 0add64c

Please sign in to comment.