Skip to content

Commit a79ee33

Browse files
author
Grok Compression
committed
MCT: add component dimension sanity check
1 parent 242de5d commit a79ee33

File tree

1 file changed

+25
-6
lines changed
  • src/lib/core/point_transform

1 file changed

+25
-6
lines changed

src/lib/core/point_transform/mct.cpp

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,14 +94,24 @@ namespace HWY_NAMESPACE
9494
public:
9595
void transform(ScheduleInfo info)
9696
{
97+
auto w0 = info.tile->comps_[0].getWindow()->getResWindowBufferHighestSimple();
98+
auto w1 = info.tile->comps_[1].getWindow()->getResWindowBufferHighestSimple();
99+
auto w2 = info.tile->comps_[2].getWindow()->getResWindowBufferHighestSimple();
100+
101+
if(w0.stride_ != w1.stride_ || w1.stride_ != w2.stride_)
102+
{
103+
grklog.warn("MCT components have differing dimensions - skipping MCT transform");
104+
return;
105+
}
106+
97107
auto highestResBufferStride =
98108
info.tile->comps_[info.compno].getWindow()->getResWindowBufferHighestStride();
99109
auto index = (uint64_t)info.yBegin * highestResBufferStride;
100110
auto chunkSize = (uint64_t)(info.yEnd - info.yBegin) * highestResBufferStride;
101111
const std::vector<ShiftInfo>& shiftInfo = info.shiftInfo;
102-
auto chan0 = info.tile->comps_[0].getWindow()->getResWindowBufferHighestSimple().buf_;
103-
auto chan1 = info.tile->comps_[1].getWindow()->getResWindowBufferHighestSimple().buf_;
104-
auto chan2 = info.tile->comps_[2].getWindow()->getResWindowBufferHighestSimple().buf_;
112+
auto chan0 = w0.buf_;
113+
auto chan1 = w1.buf_;
114+
auto chan2 = w2.buf_;
105115
int32_t shift[3] = {shiftInfo[0]._shift, shiftInfo[1]._shift, shiftInfo[2]._shift};
106116
int32_t _min[3] = {shiftInfo[0]._min, shiftInfo[1]._min, shiftInfo[2]._min};
107117
int32_t _max[3] = {shiftInfo[0]._max, shiftInfo[1]._max, shiftInfo[2]._max};
@@ -141,14 +151,23 @@ namespace HWY_NAMESPACE
141151
public:
142152
void transform(ScheduleInfo info)
143153
{
154+
auto w0 = info.tile->comps_[0].getWindow()->getResWindowBufferHighestSimpleF();
155+
auto w1 = info.tile->comps_[1].getWindow()->getResWindowBufferHighestSimpleF();
156+
auto w2 = info.tile->comps_[2].getWindow()->getResWindowBufferHighestSimpleF();
157+
158+
if(w0.stride_ != w1.stride_ || w1.stride_ != w2.stride_)
159+
{
160+
grklog.warn("MCT components have differing dimensions - skipping MCT transform");
161+
return;
162+
}
144163
auto highestResBufferStride =
145164
info.tile->comps_[info.compno].getWindow()->getResWindowBufferHighestStride();
146165
auto index = (uint64_t)info.yBegin * highestResBufferStride;
147166
auto chunkSize = (uint64_t)(info.yEnd - info.yBegin) * highestResBufferStride;
148167
const std::vector<ShiftInfo>& shiftInfo = info.shiftInfo;
149-
auto chan0 = info.tile->comps_[0].getWindow()->getResWindowBufferHighestSimpleF().buf_;
150-
auto chan1 = info.tile->comps_[1].getWindow()->getResWindowBufferHighestSimpleF().buf_;
151-
auto chan2 = info.tile->comps_[2].getWindow()->getResWindowBufferHighestSimpleF().buf_;
168+
auto chan0 = w0.buf_;
169+
auto chan1 = w1.buf_;
170+
auto chan2 = w2.buf_;
152171

153172
auto c0 = (int32_t*)chan0;
154173
auto c1 = (int32_t*)chan1;

0 commit comments

Comments
 (0)