MCPcopy Create free account
hub / github.com/OSGeo/gdal / DumpCMAPBox

Function DumpCMAPBox

gcore/gdaljp2structure.cpp:589–636  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

587}
588
589static void DumpCMAPBox(CPLXMLNode *psBox, GDALJP2Box &oBox,
590 DumpContext *psDumpContext)
591{
592 GIntBig nBoxDataLength = oBox.GetDataLength();
593 GByte *pabyBoxData = oBox.ReadBoxData();
594 if (pabyBoxData)
595 {
596 CPLXMLNode *psDecodedContent =
597 CPLCreateXMLNode(psBox, CXT_Element, "DecodedContent");
598 GIntBig nRemainingLength = nBoxDataLength;
599 GByte *pabyIter = pabyBoxData;
600 int nIndex = 0;
601 CPLXMLNode *psLastChild = nullptr;
602 while (nRemainingLength >= 2 + 1 + 1 &&
603 nIndex < knbMaxJPEG2000Components)
604 {
605 GUInt16 nVal;
606 memcpy(&nVal, pabyIter, 2);
607 CPL_MSBPTR16(&nVal);
608 AddField(psDecodedContent, psLastChild, psDumpContext,
609 CPLSPrintf("CMP%d", nIndex), nVal);
610 pabyIter += 2;
611 nRemainingLength -= 2;
612
613 AddField(psDecodedContent, psLastChild, psDumpContext,
614 CPLSPrintf("MTYP%d", nIndex), *pabyIter,
615 (*pabyIter == 0) ? "Direct use"
616 : (*pabyIter == 1) ? "Palette mapping"
617 : nullptr);
618 pabyIter += 1;
619 nRemainingLength -= 1;
620
621 AddField(psDecodedContent, psLastChild, psDumpContext,
622 CPLSPrintf("PCOL%d", nIndex), *pabyIter);
623 pabyIter += 1;
624 nRemainingLength -= 1;
625
626 nIndex++;
627 }
628 if (nRemainingLength > 0)
629 AddElement(
630 psDecodedContent, psLastChild, psDumpContext,
631 CPLCreateXMLElementAndValue(
632 nullptr, "RemainingBytes",
633 CPLSPrintf("%d", static_cast<int>(nRemainingLength))));
634 }
635 CPLFree(pabyBoxData);
636}
637
638static void DumpCDEFBox(CPLXMLNode *psBox, GDALJP2Box &oBox,
639 DumpContext *psDumpContext)

Callers 1

Calls 7

CPLCreateXMLNodeFunction · 0.85
AddFieldFunction · 0.85
CPLSPrintfFunction · 0.85
AddElementFunction · 0.85
ReadBoxDataMethod · 0.80
GetDataLengthMethod · 0.45

Tested by

no test coverage detected