diff options
Diffstat (limited to 'src')
| -rwxr-xr-x | src/JP2K.cpp | 35 | ||||
| -rwxr-xr-x | src/JP2K.h | 31 | ||||
| -rwxr-xr-x | src/j2c-test.cpp | 33 |
3 files changed, 82 insertions, 17 deletions
diff --git a/src/JP2K.cpp b/src/JP2K.cpp index b16a696..058aaa1 100755 --- a/src/JP2K.cpp +++ b/src/JP2K.cpp @@ -146,6 +146,41 @@ ASDCP::JP2K::Accessor::SIZ::Dump(FILE* stream) // void +ASDCP::JP2K::Accessor::COD::Dump(FILE* stream) +{ + if ( stream == 0 ) + stream = stderr; + + fprintf(stream, "COD: \n"); + const char* prog_order_str = "RESERVED"; + const char* transformations_str = prog_order_str; + + switch ( ProgOrder() ) + { + case 0: prog_order_str = "LRCP"; break; + case 1: prog_order_str = "RLCP"; break; + case 2: prog_order_str = "RPCL"; break; + case 3: prog_order_str = "PCRL"; break; + case 4: prog_order_str = "CPRL"; break; + } + + switch ( Transformation() ) + { + case 0: transformations_str = "9/7"; break; + case 1: transformations_str = "5/3"; break; + } + + fprintf(stream, " ProgOrder: %s\n", prog_order_str); + fprintf(stream, " Layers: %hu\n", Layers()); + fprintf(stream, " DecompLevels: %hu\n", DecompLevels()); + fprintf(stream, " CodeBlockWidth: %d\n", 1 << CodeBlockWidth()); + fprintf(stream, "CodeBlockHeight: %d\n", 1 << CodeBlockHeight()); + fprintf(stream, " CodeBlockStyle: %d\n", CodeBlockStyle()); + fprintf(stream, " Transformation: %s\n", transformations_str); +} + +// +void ASDCP::JP2K::Accessor::COM::Dump(FILE* stream) { if ( stream == 0 ) @@ -127,6 +127,37 @@ namespace JP2K void Dump(FILE* stream = 0); }; + const int SGcodOFST = 1; + const int SPcodOFST = 5; + + // coding style + class COD + { + const byte_t* m_MarkerData; + + KM_NO_COPY_CONSTRUCT(COD); + COD(); + + public: + COD(const Marker& M) + { + assert(M.m_Type == MRK_COD); + m_MarkerData = M.m_Data; + } + + ~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); + }; + // a comment class COM { diff --git a/src/j2c-test.cpp b/src/j2c-test.cpp index 2221ff0..9f57c99 100755 --- a/src/j2c-test.cpp +++ b/src/j2c-test.cpp @@ -189,25 +189,24 @@ main(int argc, const char** argv) hexdump(MyMarker.m_Data - 2, MyMarker.m_DataSize + 2, stdout); } - switch ( MyMarker.m_Type ) + if ( MyMarker.m_Type == MRK_SOD ) { - case MRK_SOD: p = end_p; - break; - - case MRK_SIZ: - { - Accessor::SIZ SIZ_(MyMarker); - SIZ_.Dump(stdout); - } - break; - - case MRK_COM: - { - Accessor::COM COM_(MyMarker); - COM_.Dump(stdout); - } - break; + } + else if ( MyMarker.m_Type == MRK_SIZ ) + { + Accessor::SIZ SIZ_(MyMarker); + SIZ_.Dump(stdout); + } + else if ( MyMarker.m_Type == MRK_COD ) + { + Accessor::COD COD_(MyMarker); + COD_.Dump(stdout); + } + else if ( MyMarker.m_Type == MRK_COM ) + { + Accessor::COM COM_(MyMarker); + COM_.Dump(stdout); } } } |
