/*
-Copyright (c) 2005-2009, John Hurst
+Copyright (c) 2005-2014, John Hurst
All rights reserved.
Redistribution and use in source and binary forms, with or without
MRK_SOT = 0xff90, // Start of tile-part
MRK_SOD = 0xff93, // Start of data
MRK_EOC = 0xffd9, // End of codestream
+ MRK_CAP = 0xff50, // Extended capabilities
MRK_SIZ = 0xff51, // Image and tile size
MRK_COD = 0xff52, // Coding style default
MRK_COC = 0xff53, // Coding style component
+ MRK_PRF = 0xff56, // Profile
+ MRK_CPF = 0xff59, // Corresponding profile
MRK_RGN = 0xff5e, // Region of interest
MRK_QCD = 0xff5c, // Quantization default
MRK_QCC = 0xff5d, // Quantization component
~SIZ() {}
- inline ui16_t Rsize() { return KM_i16_BE(*(ui16_t*)m_MarkerData); }
- inline ui32_t Xsize() { return KM_i32_BE(*(ui32_t*)(m_MarkerData + 2)); }
- inline ui32_t Ysize() { return KM_i32_BE(*(ui32_t*)(m_MarkerData + 6)); }
- inline ui32_t XOsize() { return KM_i32_BE(*(ui32_t*)(m_MarkerData + 10)); }
- inline ui32_t YOsize() { return KM_i32_BE(*(ui32_t*)(m_MarkerData + 14)); }
- inline ui32_t XTsize() { return KM_i32_BE(*(ui32_t*)(m_MarkerData + 18)); }
- inline ui32_t YTsize() { return KM_i32_BE(*(ui32_t*)(m_MarkerData + 22)); }
- inline ui32_t XTOsize() { return KM_i32_BE(*(ui32_t*)(m_MarkerData + 26)); }
- inline ui32_t YTOsize() { return KM_i32_BE(*(ui32_t*)(m_MarkerData + 30)); }
- inline ui16_t Csize() { return KM_i16_BE(*(ui16_t*)(m_MarkerData + 34)); }
- void ReadComponent(ui32_t index, ImageComponent_t& IC);
- void Dump(FILE* stream = 0);
+ inline ui16_t Rsize() const { return KM_i16_BE(*(ui16_t*)m_MarkerData); }
+ inline ui32_t Xsize() const { return KM_i32_BE(*(ui32_t*)(m_MarkerData + 2)); }
+ inline ui32_t Ysize() const { return KM_i32_BE(*(ui32_t*)(m_MarkerData + 6)); }
+ inline ui32_t XOsize() const { return KM_i32_BE(*(ui32_t*)(m_MarkerData + 10)); }
+ inline ui32_t YOsize() const { return KM_i32_BE(*(ui32_t*)(m_MarkerData + 14)); }
+ inline ui32_t XTsize() const { return KM_i32_BE(*(ui32_t*)(m_MarkerData + 18)); }
+ inline ui32_t YTsize() const { return KM_i32_BE(*(ui32_t*)(m_MarkerData + 22)); }
+ inline ui32_t XTOsize() const { return KM_i32_BE(*(ui32_t*)(m_MarkerData + 26)); }
+ inline ui32_t YTOsize() const { return KM_i32_BE(*(ui32_t*)(m_MarkerData + 30)); }
+ inline ui16_t Csize() const { return KM_i16_BE(*(ui16_t*)(m_MarkerData + 34)); }
+ void ReadComponent(const ui32_t index, ImageComponent_t& IC) const;
+ void Dump(FILE* stream = 0) const;
};
const int SGcodOFST = 1;
~COD() {}
- inline ui8_t ProgOrder() { return *(m_MarkerData + SGcodOFST ); }
- inline ui16_t Layers() { return KM_i16_BE(*(ui16_t*)(m_MarkerData + SGcodOFST + 1));}
- inline ui8_t DecompLevels() { return *(m_MarkerData + SPcodOFST); }
- inline ui8_t CodeBlockWidth() { return *(m_MarkerData + SPcodOFST + 1) + 2; }
- inline ui8_t CodeBlockHeight() { return *(m_MarkerData + SPcodOFST + 2) + 2; }
- inline ui8_t CodeBlockStyle() { return *(m_MarkerData + SPcodOFST + 3); }
- inline ui8_t Transformation() { return *(m_MarkerData + SPcodOFST + 4); }
-
- void Dump(FILE* stream = 0);
+ inline ui8_t ProgOrder() const { return *(m_MarkerData + SGcodOFST ); }
+ inline ui16_t Layers() const { return KM_i16_BE(*(ui16_t*)(m_MarkerData + SGcodOFST + 1));}
+ inline ui8_t DecompLevels() const { return *(m_MarkerData + SPcodOFST); }
+ inline ui8_t CodeBlockWidth() const { return *(m_MarkerData + SPcodOFST + 1) + 2; }
+ inline ui8_t CodeBlockHeight() const { return *(m_MarkerData + SPcodOFST + 2) + 2; }
+ inline ui8_t CodeBlockStyle() const { return *(m_MarkerData + SPcodOFST + 3); }
+ inline ui8_t Transformation() const { return *(m_MarkerData + SPcodOFST + 4); }
+
+ void Dump(FILE* stream = 0) const;
+ };
+
+ const int SqcdOFST = 1;
+ const int SPqcdOFST = 2;
+
+ enum QuantizationType_t
+ {
+ QT_NONE,
+ QT_DERIVED,
+ QT_EXP
+ };
+
+ const char* GetQuantizationTypeString(const QuantizationType_t m);
+
+ // Quantization default
+ class QCD
+ {
+ const byte_t* m_MarkerData;
+ ui32_t m_DataSize;
+
+ KM_NO_COPY_CONSTRUCT(QCD);
+ QCD();
+
+ public:
+ QCD(const Marker& M)
+ {
+ assert(M.m_Type == MRK_QCD);
+ m_MarkerData = M.m_Data + 2;
+ m_DataSize = M.m_DataSize - 2;
+ }
+
+ ~QCD() {}
+ inline QuantizationType_t QuantizationType() const { return static_cast<QuantizationType_t>(*(m_MarkerData + SqcdOFST) & 0x03); }
+ inline ui8_t GuardBits() const { return (*(m_MarkerData + SqcdOFST) & 0xe0) >> 5; }
+ void Dump(FILE* stream = 0) const;
};
// a comment
~COM() {}
- inline bool IsText() { return m_IsText; }
- inline const byte_t* CommentData() { return m_MarkerData; }
- inline ui32_t CommentSize() { return m_DataSize; }
- void Dump(FILE* stream = 0);
+ inline bool IsText() const { return m_IsText; }
+ inline const byte_t* CommentData() const { return m_MarkerData; }
+ inline ui32_t CommentSize() const { return m_DataSize; }
+ void Dump(FILE* stream = 0) const;
};
+
+ // Corresponding Profile
+ class CPF {
+
+ const ui16_t* m_Data;
+ ui16_t m_N;
+
+ KM_NO_COPY_CONSTRUCT(CPF);
+ CPF();
+
+ public:
+ CPF(const Marker& M) {
+ assert(M.m_Type == MRK_CPF);
+
+ m_Data = (ui16_t*) M.m_Data;
+ m_N = M.m_DataSize >> 1;
+ }
+
+ ~CPF() {}
+
+ inline ui16_t N() const { return m_N; }
+
+ inline ui16_t pcpf(ui16_t i) const { return KM_i16_BE(m_Data[2 * (i - 1)]); }
+
+ void Dump(FILE* stream = 0) const;
+ };
+
+ // Profile
+ class PRF {
+
+ const ui16_t* m_Data;
+ ui16_t m_N;
+
+ KM_NO_COPY_CONSTRUCT(PRF);
+ PRF();
+
+ public:
+ PRF(const Marker& M) {
+ assert(M.m_Type == MRK_PRF);
+
+ m_Data = (ui16_t*) M.m_Data;
+ m_N = M.m_DataSize >> 1;
+ }
+
+ ~PRF() {}
+
+ inline ui16_t N() const { return m_N; }
+
+ inline ui16_t pprf(ui16_t i) const { return KM_i16_BE(m_Data[2 * (i - 1)]); }
+
+ void Dump(FILE* stream = 0) const;
+ };
+
+ // Extended capabilities
+ class CAP {
+
+ const ui16_t* m_Data;
+
+ ui32_t m_Pcap;
+
+ i8_t m_N;
+
+ KM_NO_COPY_CONSTRUCT(CAP);
+ CAP();
+
+ public:
+ CAP(const Marker& M) {
+ assert(M.m_Type == MRK_CAP);
+
+ m_Data = (ui16_t *) (M.m_Data + 4);
+ m_Pcap = KM_i32_BE(*(ui32_t*)(M.m_Data));
+ m_N = (M.m_DataSize - 4) >> 1;
+ }
+
+ ~CAP() {}
+
+ inline ui32_t pcap() const { return m_Pcap; }
+
+ inline i8_t N() const { return m_N; }
+
+ inline ui16_t ccap(ui16_t i) const { return KM_i16_BE(m_Data[2 * (i - 1)]); }
+
+ void Dump(FILE* stream = 0) const;
+ };
} // namespace Accessor
} // namespace JP2K
} // namespace ASDCP