Skip to content

Commit 1834259

Browse files
author
Grok Compression
committed
MCT: force all components to 32 bit path is at least one must use 32 bit
1 parent 1136b6e commit 1834259

3 files changed

Lines changed: 31 additions & 3 deletions

File tree

.vscode/launch.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -877,7 +877,7 @@
877877
"args": [
878878
//"${workspaceFolder}/build/bin/grk_decompress",
879879
"-i",
880-
"$HOME/temp/clusterfuzz-testcase-minimized-grk_decompress_fuzzer-6467774498275328",
880+
"$HOME/temp/clusterfuzz-testcase-minimized-grk_decompress_fuzzer-4717825607663616",
881881
"-d 0,0,1024,1024",
882882
"-o",
883883
"$HOME/temp/fuzz.pgx"

src/lib/core/point_transform/mct.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -718,7 +718,9 @@ void Mct::schedule_decompress_irrev(FlowComponent* flow, bool applyDcShift)
718718
{
719719
ScheduleInfo info(tile_, flow, image_->rows_per_task);
720720
genShift(applyDcShift ? 1 : 0, info.shiftInfo);
721-
if(tile_->comps_[0].is16BitDwt())
721+
// All 3 MCT components must agree on data type; use 16-bit only if all are 16-bit
722+
if(tile_->comps_[0].is16BitDwt() && tile_->comps_[1].is16BitDwt() &&
723+
tile_->comps_[2].is16BitDwt())
722724
HWY_DYNAMIC_DISPATCH(hwy_schedule_decompress_irrev16)(info);
723725
else
724726
HWY_DYNAMIC_DISPATCH(hwy_schedule_decompress_irrev)(info);
@@ -731,7 +733,9 @@ void Mct::schedule_decompress_rev(FlowComponent* flow, bool applyDcShift)
731733
{
732734
ScheduleInfo info(tile_, flow, image_->rows_per_task);
733735
genShift(applyDcShift ? 1 : 0, info.shiftInfo);
734-
if(tile_->comps_[0].is16BitDwt())
736+
// All 3 MCT components must agree on data type; use 16-bit only if all are 16-bit
737+
if(tile_->comps_[0].is16BitDwt() && tile_->comps_[1].is16BitDwt() &&
738+
tile_->comps_[2].is16BitDwt())
735739
HWY_DYNAMIC_DISPATCH(hwy_schedule_decompress_rev16)(info);
736740
else
737741
HWY_DYNAMIC_DISPATCH(hwy_schedule_decompress_rev)(info);

src/lib/core/tile_processor/TileProcessor.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -998,6 +998,30 @@ bool TileProcessor::createDecompressTileComponentWindows(void)
998998
GRK_INT_16)
999999
tileComp->setUse16BitDwt(true);
10001000
}
1001+
}
1002+
// MCT operates on all 3 components with the same data type;
1003+
// if any MCT component is not 16-bit, force all to 32-bit
1004+
if(needsMctDecompress() && tcp_->mct_ == 1 && tile_->numcomps_ >= 3)
1005+
{
1006+
bool all16 = true;
1007+
for(uint16_t compno = 0; compno < 3; ++compno)
1008+
{
1009+
if(!tile_->comps_[compno].is16BitDwt())
1010+
{
1011+
all16 = false;
1012+
break;
1013+
}
1014+
}
1015+
if(!all16)
1016+
{
1017+
for(uint16_t compno = 0; compno < 3; ++compno)
1018+
tile_->comps_[compno].setUse16BitDwt(false);
1019+
}
1020+
}
1021+
for(uint16_t compno = 0; compno < tile_->numcomps_; ++compno)
1022+
{
1023+
auto imageComp = headerImage_->comps + compno;
1024+
auto tileComp = tile_->comps_ + compno;
10011025
auto unreducedImageCompWindow =
10021026
unreducedImageWindow_.scaleDownCeil(imageComp->dx, imageComp->dy);
10031027
if(!tileComp->canCreateWindow(unreducedImageCompWindow))

0 commit comments

Comments
 (0)