Improved success for the linux build; OPJViewer shows all the COM contents
[openjpeg.git] / OPJViewer / source / wxjp2parser.cpp
index afacd394d4477e39e1f4191e4b067e07a17142e1..6e89390a1bae8615ff8eee357b6ecf7c28c00433 100644 (file)
@@ -60,6 +60,8 @@ typedef enum {
                        TRAK_BOX,\r
                        TKHD_BOX,\r
                        MDIA_BOX,\r
+                       MDHD_BOX,\r
+                       HDLR_BOX,\r
                        MINF_BOX,\r
                        VMHD_BOX,\r
                        STBL_BOX,\r
@@ -102,6 +104,8 @@ struct boxdef {
 #define TRAK_SIGN           "trak"\r
 #define TKHD_SIGN           "tkhd"\r
 #define MDIA_SIGN           "mdia"\r
+#define MDHD_SIGN           "mdhd"\r
+#define HDLR_SIGN           "hdlr"\r
 #define MINF_SIGN           "minf"\r
 #define VMHD_SIGN           "vmhd"\r
 #define STBL_SIGN           "stbl"\r
@@ -231,6 +235,22 @@ struct boxdef j22box[] =
 /* req */      {1, 1, 1},\r
 /* ins */      TRAK_BOX},\r
 \r
+/* sign */     {MDHD_SIGN,\r
+/* short */    "Media Header box",\r
+/* long */     "The media header declares overall information which is media-independent, and relevant to characteristics "\r
+                       "of the media in a track",\r
+/* sbox */     0,\r
+/* req */      {1, 1, 1},\r
+/* ins */      MDIA_BOX},\r
+\r
+/* sign */     {HDLR_SIGN,\r
+/* short */    "Handler Reference box",\r
+/* long */     "This box within a Media Box declares the process by which the media-data in the track may be presented, "\r
+                       "and thus, the nature of the media in a track",\r
+/* sbox */     0,\r
+/* req */      {1, 1, 1},\r
+/* ins */      MDIA_BOX},\r
+\r
 /* sign */     {MINF_SIGN,\r
 /* short */    "Media Information box",\r
 /* long */     "This box contains all the objects which declare characteristic information of the media in the track",\r
@@ -829,7 +849,114 @@ int OPJParseThread::box_handler_function(int boxtype, wxFile *fileid, wxFileOffs
                };\r
                break;\r
 \r
+               /* Media Header box */\r
+       case (MDHD_BOX): {\r
+                       unsigned long int version;\r
+                       unsigned short int language;\r
+                       fileid->Read(&version, sizeof(unsigned long int));\r
+                       version = BYTE_SWAP4(version);\r
+                       if (version == 0) {\r
+                               unsigned long int creation_time, modification_time, timescale, duration;\r
+                               fileid->Read(&creation_time, sizeof(unsigned long int));\r
+                               creation_time = BYTE_SWAP4(creation_time);\r
+                               fileid->Read(&modification_time, sizeof(unsigned long int));\r
+                               modification_time = BYTE_SWAP4(modification_time);\r
+                               fileid->Read(&timescale, sizeof(unsigned long int));\r
+                               timescale = BYTE_SWAP4(timescale);\r
+                               fileid->Read(&duration, sizeof(unsigned long int));\r
+                               duration = BYTE_SWAP4(duration);\r
+                               const long unix_time = creation_time - 2082844800L;\r
+                               wxTreeItemId currid = m_tree->AppendItem(parentid,\r
+                                       wxString::Format(wxT("Creation time: %u (%.24s)"), creation_time, ctime(&unix_time)),\r
+                                       m_tree->TreeCtrlIcon_File, m_tree->TreeCtrlIcon_File + 1,\r
+                                       new OPJMarkerData(wxT("INFO"))\r
+                                       );\r
+                               const long unix_time1 = modification_time - 2082844800L;\r
+                               currid = m_tree->AppendItem(parentid,\r
+                                       wxString::Format(wxT("Modification time: %u (%.24s)"), modification_time, ctime(&unix_time1)),\r
+                                       m_tree->TreeCtrlIcon_File, m_tree->TreeCtrlIcon_File + 1,\r
+                                       new OPJMarkerData(wxT("INFO"))\r
+                                       );\r
+                               currid = m_tree->AppendItem(parentid,\r
+                                       wxString::Format(wxT("Timescale: %u (%.6fs)"), timescale, 1.0 / (float) timescale),\r
+                                       m_tree->TreeCtrlIcon_File, m_tree->TreeCtrlIcon_File + 1,\r
+                                       new OPJMarkerData(wxT("INFO"))\r
+                                       );\r
+                               currid = m_tree->AppendItem(parentid,\r
+                                       wxString::Format(wxT("Duration: %u (%.3fs)"), duration, (float) duration / (float) timescale),\r
+                                       m_tree->TreeCtrlIcon_File, m_tree->TreeCtrlIcon_File + 1,\r
+                                       new OPJMarkerData(wxT("INFO"))\r
+                                       );\r
+                       } else {\r
+                               int8byte creation_time, modification_time, duration;\r
+                               unsigned long int timescale;\r
+                               fileid->Read(&creation_time, sizeof(int8byte));\r
+                               creation_time = BYTE_SWAP8(creation_time);\r
+                               fileid->Read(&modification_time, sizeof(int8byte));\r
+                               modification_time = BYTE_SWAP8(modification_time);\r
+                               fileid->Read(&timescale, sizeof(unsigned long int));\r
+                               timescale = BYTE_SWAP4(timescale);\r
+                               fileid->Read(&duration, sizeof(int8byte));\r
+                               duration = BYTE_SWAP8(duration);\r
+                               wxTreeItemId currid = m_tree->AppendItem(parentid,\r
+                                       wxString::Format(wxT("Creation time: %u"), creation_time),\r
+                                       m_tree->TreeCtrlIcon_File, m_tree->TreeCtrlIcon_File + 1,\r
+                                       new OPJMarkerData(wxT("INFO"))\r
+                                       );\r
+                               currid = m_tree->AppendItem(parentid,\r
+                                       wxString::Format(wxT("Modification time: %u"), modification_time),\r
+                                       m_tree->TreeCtrlIcon_File, m_tree->TreeCtrlIcon_File + 1,\r
+                                       new OPJMarkerData(wxT("INFO"))\r
+                                       );\r
+                               currid = m_tree->AppendItem(parentid,\r
+                                       wxString::Format(wxT("Timescale: %u"), timescale),\r
+                                       m_tree->TreeCtrlIcon_File, m_tree->TreeCtrlIcon_File + 1,\r
+                                       new OPJMarkerData(wxT("INFO"))\r
+                                       );\r
+                               currid = m_tree->AppendItem(parentid,\r
+                                       wxString::Format(wxT("Duration: %u"), duration),\r
+                                       m_tree->TreeCtrlIcon_File, m_tree->TreeCtrlIcon_File + 1,\r
+                                       new OPJMarkerData(wxT("INFO"))\r
+                                       );\r
+                       }\r
+                       fileid->Read(&language, sizeof(unsigned short int));\r
+\r
+                       wxTreeItemId currid = m_tree->AppendItem(parentid,\r
+                               wxString::Format(wxT("Language: %d (%c%c%c)"), language & 0xEFFF,\r
+                               0x60 + (char) ((language >> 10) & 0x001F), 0x60 + (char) ((language >> 5) & 0x001F), 0x60 + (char) ((language >> 0) & 0x001F)),\r
+                               m_tree->TreeCtrlIcon_File, m_tree->TreeCtrlIcon_File + 1,\r
+                               new OPJMarkerData(wxT("INFO"))\r
+                               );\r
+               };\r
+               break;\r
                \r
+               /* Media Handler box */\r
+       case (HDLR_BOX): {\r
+                       unsigned long int version, predefined, temp[3];\r
+                       char handler[4], name[256];\r
+                       int namelen = wxMin(256, (filelimit - filepoint - 24));\r
+                       fileid->Read(&version, sizeof(unsigned long int));\r
+                       version = BYTE_SWAP4(version);\r
+                       fileid->Read(&predefined, sizeof(unsigned long int));\r
+                       fileid->Read(handler, 4 * sizeof(char));\r
+                       fileid->Read(&temp, 3 * sizeof(unsigned long int));\r
+                       fileid->Read(name, namelen * sizeof(char));\r
+\r
+                       wxTreeItemId currid = m_tree->AppendItem(parentid,\r
+                               wxString::Format(wxT("Handler: %.4s"), handler),\r
+                               m_tree->TreeCtrlIcon_File, m_tree->TreeCtrlIcon_File + 1,\r
+                               new OPJMarkerData(wxT("INFO"))\r
+                               );\r
+                                        \r
+                       currid = m_tree->AppendItem(parentid,\r
+                               wxString::Format(wxT("Name: %.255s"), name),\r
+                               m_tree->TreeCtrlIcon_File, m_tree->TreeCtrlIcon_File + 1,\r
+                               new OPJMarkerData(wxT("INFO"))\r
+                               );\r
+                                                                        \r
+               }\r
+               break;\r
+\r
        /* not yet implemented */\r
        default:\r
                break;\r