| 636 | } |
| 637 | |
| 638 | static void DumpCDEFBox(CPLXMLNode *psBox, GDALJP2Box &oBox, |
| 639 | DumpContext *psDumpContext) |
| 640 | { |
| 641 | GIntBig nBoxDataLength = oBox.GetDataLength(); |
| 642 | GByte *pabyBoxData = oBox.ReadBoxData(); |
| 643 | if (pabyBoxData) |
| 644 | { |
| 645 | CPLXMLNode *psDecodedContent = |
| 646 | CPLCreateXMLNode(psBox, CXT_Element, "DecodedContent"); |
| 647 | GIntBig nRemainingLength = nBoxDataLength; |
| 648 | GByte *pabyIter = pabyBoxData; |
| 649 | GUInt16 nChannels = 0; |
| 650 | CPLXMLNode *psLastChild = nullptr; |
| 651 | if (nRemainingLength >= 2) |
| 652 | { |
| 653 | GUInt16 nVal; |
| 654 | memcpy(&nVal, pabyIter, 2); |
| 655 | nChannels = nVal; |
| 656 | CPL_MSBPTR16(&nVal); |
| 657 | AddField(psDecodedContent, psLastChild, psDumpContext, "N", nVal); |
| 658 | pabyIter += 2; |
| 659 | nRemainingLength -= 2; |
| 660 | } |
| 661 | for (int i = 0; i < nChannels; i++) |
| 662 | { |
| 663 | if (nRemainingLength >= 2) |
| 664 | { |
| 665 | GUInt16 nVal; |
| 666 | memcpy(&nVal, pabyIter, 2); |
| 667 | CPL_MSBPTR16(&nVal); |
| 668 | AddField(psDecodedContent, psLastChild, psDumpContext, |
| 669 | CPLSPrintf("Cn%d", i), nVal); |
| 670 | pabyIter += 2; |
| 671 | nRemainingLength -= 2; |
| 672 | } |
| 673 | if (nRemainingLength >= 2) |
| 674 | { |
| 675 | GUInt16 nVal; |
| 676 | memcpy(&nVal, pabyIter, 2); |
| 677 | CPL_MSBPTR16(&nVal); |
| 678 | AddField(psDecodedContent, psLastChild, psDumpContext, |
| 679 | CPLSPrintf("Typ%d", i), nVal, |
| 680 | (nVal == 0) ? "Colour channel" |
| 681 | : (nVal == 1) ? "Opacity channel" |
| 682 | : (nVal == 2) ? "Premultiplied opacity" |
| 683 | : (nVal == 65535) ? "Not specified" |
| 684 | : nullptr); |
| 685 | pabyIter += 2; |
| 686 | nRemainingLength -= 2; |
| 687 | } |
| 688 | if (nRemainingLength >= 2) |
| 689 | { |
| 690 | GUInt16 nVal; |
| 691 | memcpy(&nVal, pabyIter, 2); |
| 692 | CPL_MSBPTR16(&nVal); |
| 693 | AddField(psDecodedContent, psLastChild, psDumpContext, |
| 694 | CPLSPrintf("Asoc%d", i), nVal, |
| 695 | (nVal == 0) ? "Associated to the whole image" |
no test coverage detected