57 int32_t INITIAL_STRIPT;
59 if (pHuffmanDecoder->DecodeAValue(SBHUFFDT, &INITIAL_STRIPT) != 0)
62 FX_SAFE_INT32 STRIPT = INITIAL_STRIPT;
65 FX_SAFE_INT32 FIRSTS = 0;
66 uint32_t NINSTANCES = 0;
69 if (pHuffmanDecoder->DecodeAValue(SBHUFFDT, &INITIAL_DT) != 0)
72 FX_SAFE_INT32 DT = INITIAL_DT;
76 FX_SAFE_INT32 CURS = 0;
80 if (pHuffmanDecoder->DecodeAValue(SBHUFFFS, &DFS) != 0)
88 int32_t nVal = pHuffmanDecoder->DecodeAValue(SBHUFFDS, &IDS);
101 while (
static_cast<uint32_t>(1 << nTmp) <
SBSTRIPS)
109 FX_SAFE_INT32 SAFE_TI = STRIPT + CURT;
110 if (!SAFE_TI.IsValid())
113 int32_t TI = SAFE_TI.ValueOrDie();
114 FX_SAFE_INT32 nSafeVal = 0;
123 if (!nSafeVal.IsValid())
128 const int32_t nVal = nSafeVal.ValueOrDie();
130 if (nBits == SBSYMCODES[IDI].codelen && nVal == SBSYMCODES[IDI].code)
140 MaybeOwned<CJBig2_Image> IBI;
149 if ((pHuffmanDecoder->DecodeAValue(SBHUFFRDW, &RDWI) != 0) ||
150 (pHuffmanDecoder->DecodeAValue(SBHUFFRDH, &RDHI) != 0) ||
151 (pHuffmanDecoder->DecodeAValue(SBHUFFRDX, &RDXI) != 0) ||
152 (pHuffmanDecoder->DecodeAValue(SBHUFFRDY, &RDYI) != 0) ||
153 (pHuffmanDecoder->DecodeAValue(SBHUFFRSIZE, &HUFFRSIZE) != 0)) {
162 absl::optional<uint32_t> WOI = CheckTRDDimension(IBOI->width(), RDWI);
163 absl::optional<uint32_t> HOI = CheckTRDDimension(IBOI->height(), RDHI);
164 if (!WOI.has_value() || !HOI.has_value())
167 absl::optional<int32_t> GRREFERENCEDX =
168 CheckTRDReferenceDimension(RDWI, 2, RDXI);
169 absl::optional<int32_t> GRREFERENCEDY =
170 CheckTRDReferenceDimension(RDHI, 2, RDYI);
171 if (!GRREFERENCEDX.has_value() || !GRREFERENCEDY.has_value())
175 pGRRD->GRW = WOI.value();
176 pGRRD->GRH = HOI.value();
178 pGRRD->GRREFERENCE = IBOI;
179 pGRRD->GRREFERENCEDX = GRREFERENCEDX.value();
180 pGRRD->GRREFERENCEDY = GRREFERENCEDY.value();
181 pGRRD->TPGRON =
false;
182 pGRRD->GRAT[0] =
SBRAT[0];
183 pGRRD->GRAT[1] =
SBRAT[1];
184 pGRRD->GRAT[2] =
SBRAT[2];
185 pGRRD->GRAT[3] =
SBRAT[3];
188 IBI = pGRRD->Decode(pArithDecoder.get(), grContext);
194 if (
static_cast<uint32_t>(HUFFRSIZE) != (pStream
->getOffset() - nTmp))
200 uint32_t WI = IBI->width();
201 uint32_t HI = IBI->height();
212 int32_t SI = CURS.ValueOrDie();
213 ComposeData compose = GetComposeData(SI, TI, WI, HI);
214 IBI.Get()->ComposeTo(SBREG.get(), compose.x, compose.y,
SBCOMBOP);
215 if (compose.increment)
216 CURS += compose.increment;
231 MaybeOwned<CJBig2_ArithIntDecoder> pIADT;
236 int32_t INITIAL_STRIPT;
237 if (!pIADT->Decode(pArithDecoder, &INITIAL_STRIPT))
240 MaybeOwned<CJBig2_ArithIntDecoder> pIAFS;
241 MaybeOwned<CJBig2_ArithIntDecoder> pIADS;
242 MaybeOwned<CJBig2_ArithIntDecoder> pIAIT;
243 MaybeOwned<CJBig2_ArithIntDecoder> pIARI;
244 MaybeOwned<CJBig2_ArithIntDecoder> pIARDW;
245 MaybeOwned<CJBig2_ArithIntDecoder> pIARDH;
246 MaybeOwned<CJBig2_ArithIntDecoder> pIARDX;
247 MaybeOwned<CJBig2_ArithIntDecoder> pIARDY;
248 MaybeOwned<CJBig2_ArithIaidDecoder> pIAID;
254 pIARDW = pIDS->IARDW;
255 pIARDH = pIDS->IARDH;
256 pIARDX = pIDS->IARDX;
257 pIARDY = pIDS->IARDY;
273 FX_SAFE_INT32 STRIPT = INITIAL_STRIPT;
276 FX_SAFE_INT32 FIRSTS = 0;
277 uint32_t NINSTANCES = 0;
279 FX_SAFE_INT32 CURS = 0;
281 if (!pIADT->Decode(pArithDecoder, &INITIAL_DT))
284 FX_SAFE_INT32 DT = INITIAL_DT;
291 pIAFS->Decode(pArithDecoder, &DFS);
297 if (!pIADS->Decode(pArithDecoder, &IDS))
308 pIAIT->Decode(pArithDecoder, &CURT);
310 FX_SAFE_INT32 SAFE_TI = STRIPT + CURT;
311 if (!SAFE_TI.IsValid())
314 int32_t TI = SAFE_TI.ValueOrDie();
316 pIAID->Decode(pArithDecoder, &IDI);
324 pIARI->Decode(pArithDecoder, &RI);
326 MaybeOwned<CJBig2_Image> pIBI;
334 pIARDW->Decode(pArithDecoder, &RDWI);
335 pIARDH->Decode(pArithDecoder, &RDHI);
336 pIARDX->Decode(pArithDecoder, &RDXI);
337 pIARDY->Decode(pArithDecoder, &RDYI);
342 absl::optional<uint32_t> WOI = CheckTRDDimension(IBOI->width(), RDWI);
343 absl::optional<uint32_t> HOI = CheckTRDDimension(IBOI->height(), RDHI);
344 if (!WOI.has_value() || !HOI.has_value())
347 absl::optional<int32_t> GRREFERENCEDX =
348 CheckTRDReferenceDimension(RDWI, 1, RDXI);
349 absl::optional<int32_t> GRREFERENCEDY =
350 CheckTRDReferenceDimension(RDHI, 1, RDYI);
351 if (!GRREFERENCEDX.has_value() || !GRREFERENCEDY.has_value())
355 pGRRD->GRW = WOI.value();
356 pGRRD->GRH = HOI.value();
358 pGRRD->GRREFERENCE = IBOI;
359 pGRRD->GRREFERENCEDX = GRREFERENCEDX.value();
360 pGRRD->GRREFERENCEDY = GRREFERENCEDY.value();
361 pGRRD->TPGRON =
false;
362 pGRRD->GRAT[0] =
SBRAT[0];
363 pGRRD->GRAT[1] =
SBRAT[1];
364 pGRRD->GRAT[2] =
SBRAT[2];
365 pGRRD->GRAT[3] =
SBRAT[3];
366 pIBI = pGRRD->Decode(pArithDecoder, grContext);
371 uint32_t WI = pIBI->width();
372 uint32_t HI = pIBI->height();
383 int32_t SI = CURS.ValueOrDie();
384 ComposeData compose = GetComposeData(SI, TI, WI, HI);
385 pIBI.Get()->ComposeTo(SBREG.get(), compose.x, compose.y,
SBCOMBOP);
386 if (compose.increment)
387 CURS += compose.increment;