From 95d760a1735517347355ff875549d85ebbc72eb7 Mon Sep 17 00:00:00 2001 From: Giuseppe Baruffa Date: Mon, 5 Nov 2007 13:05:07 +0000 Subject: [PATCH] Fixed a bug which prevented JPWL from working on multi-tiled images; added some more fields in the interface info structures (keep a list of markers, save start packet number for each tile) --- ChangeLog | 3 + OPJViewer/Makefile | 8 +- OPJViewer/OPJViewer.dsp | 4 + OPJViewer/source/OPJDialogs.cpp | 1082 +++++++++++++++++++++++++++ OPJViewer/source/OPJViewer.cpp | 1213 +++++-------------------------- OPJViewer/source/OPJViewer.h | 35 +- OPJViewer/source/build.h | 2 +- OPJViewer/source/imagj2k.cpp | 209 +++++- OPJViewer/source/imagj2k.h | 18 + codec/image_to_j2k.c | 13 +- jpwl/LibOpenJPEG_JPWL.dsp | 4 + jpwl/Makefile | 51 +- jpwl/jpwl.c | 62 +- jpwl/jpwl.h | 2 + jpwl/jpwl_lib.c | 36 +- libopenjpeg/j2k.c | 44 +- libopenjpeg/openjpeg.c | 1 + libopenjpeg/openjpeg.h | 4 + mj2/wrap_j2k_in_mj2.c | 2 +- 19 files changed, 1695 insertions(+), 1098 deletions(-) create mode 100644 OPJViewer/source/OPJDialogs.cpp diff --git a/ChangeLog b/ChangeLog index a16e2d3c..85af2acf 100644 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,9 @@ What's New for OpenJPEG ! : changed + : added +November 5, 2007 +*+ [GB] Fixed a bug which prevented JPWL from working on multi-tiled images; added some more fields in the interface info structures (keep a list of markers, save start packet number for each tile) + October 23, 2007 * [GB] Improved success for the linux build; OPJViewer shows all the COM contents diff --git a/OPJViewer/Makefile b/OPJViewer/Makefile index c626b062..75f57230 100644 --- a/OPJViewer/Makefile +++ b/OPJViewer/Makefile @@ -13,18 +13,18 @@ MODULES = $(OPJV_SRCS:.cpp=.o) all: opjviewer lib .cpp.o: - $(CC) $(CFLAGS) -c $< -o $@ + $(CC) $(CFLAGS) -c $< -o $@ lib: - cd ../jpwl; make + cd ../jpwl; make opjviewer: $(OPJV_SRCS) lib $(CC) $(CFLAGS) -I .. $(OPJV_SRCS) -o OPJViewer -L ../jpwl -lopenjpeg_JPWL -lm -lstdc++ -ltiff $(shell wx-config-2.8 --libs) clean: - rm -f OPJViewer *.o *.a - cd ../libopenjpeg; rm -f *.o + rm -f OPJViewer *.o *.a + cd ../libopenjpeg; rm -f *.o diff --git a/OPJViewer/OPJViewer.dsp b/OPJViewer/OPJViewer.dsp index 99b640e5..d9521f4c 100644 --- a/OPJViewer/OPJViewer.dsp +++ b/OPJViewer/OPJViewer.dsp @@ -111,6 +111,10 @@ SOURCE=.\source\imagmj2.cpp # End Source File # Begin Source File +SOURCE=.\source\OPJDialogs.cpp +# End Source File +# Begin Source File + SOURCE=.\source\OPJViewer.cpp # End Source File # Begin Source File diff --git a/OPJViewer/source/OPJDialogs.cpp b/OPJViewer/source/OPJDialogs.cpp new file mode 100644 index 00000000..063cec8b --- /dev/null +++ b/OPJViewer/source/OPJDialogs.cpp @@ -0,0 +1,1082 @@ +/* + * Copyright (c) 2007, Digital Signal Processing Laboratory, Universita'  degli studi di Perugia (UPG), Italy + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ +#include "OPJViewer.h" + +// ---------------------------------------------------------------------------- +// OPJDecoderDialog +// ---------------------------------------------------------------------------- + +IMPLEMENT_CLASS(OPJDecoderDialog, wxPropertySheetDialog) + +BEGIN_EVENT_TABLE(OPJDecoderDialog, wxPropertySheetDialog) +#ifdef USE_JPWL + EVT_CHECKBOX(OPJDECO_ENABLEDECO, OPJDecoderDialog::OnEnableDeco) + EVT_CHECKBOX(OPJDECO_ENABLEJPWL, OPJDecoderDialog::OnEnableJPWL) +#endif // USE_JPWL +END_EVENT_TABLE() + +OPJDecoderDialog::OPJDecoderDialog(wxWindow* win, int dialogType) +{ + SetExtraStyle(wxDIALOG_EX_CONTEXTHELP|wxWS_EX_VALIDATE_RECURSIVELY); + + Create(win, wxID_ANY, wxT("Decoder settings"), + wxDefaultPosition, wxDefaultSize, + wxDEFAULT_DIALOG_STYLE| (int) wxPlatform::IfNot(wxOS_WINDOWS_CE, wxRESIZE_BORDER) + ); + + CreateButtons(wxOK | wxCANCEL | (int)wxPlatform::IfNot(wxOS_WINDOWS_CE, wxHELP)); + + m_settingsNotebook = GetBookCtrl(); + + wxPanel* mainSettings = CreateMainSettingsPage(m_settingsNotebook); + wxPanel* jpeg2000Settings = CreatePart1SettingsPage(m_settingsNotebook); + if (!wxGetApp().m_enabledeco) + jpeg2000Settings->Enable(false); + wxPanel* mjpeg2000Settings = CreatePart3SettingsPage(m_settingsNotebook); + if (!wxGetApp().m_enabledeco) + mjpeg2000Settings->Enable(false); +#ifdef USE_JPWL + wxPanel* jpwlSettings = CreatePart11SettingsPage(m_settingsNotebook); + if (!wxGetApp().m_enabledeco) + jpwlSettings->Enable(false); +#endif // USE_JPWL + + m_settingsNotebook->AddPage(mainSettings, wxT("Display"), false); + m_settingsNotebook->AddPage(jpeg2000Settings, wxT("JPEG 2000"), false); + m_settingsNotebook->AddPage(mjpeg2000Settings, wxT("MJPEG 2000"), false); +#ifdef USE_JPWL + m_settingsNotebook->AddPage(jpwlSettings, wxT("JPWL"), false); +#endif // USE_JPWL + + LayoutDialog(); +} + +OPJDecoderDialog::~OPJDecoderDialog() +{ +} + +wxPanel* OPJDecoderDialog::CreateMainSettingsPage(wxWindow* parent) +{ + wxPanel* panel = new wxPanel(parent, wxID_ANY); + + // top sizer + wxBoxSizer *topSizer = new wxBoxSizer(wxVERTICAL); + + // sub top sizer + wxBoxSizer *subtopSizer = new wxBoxSizer(wxVERTICAL); + + // add decoding enabling check box + subtopSizer->Add( + m_enabledecoCheck = new wxCheckBox(panel, OPJDECO_ENABLEDECO, wxT("Enable decoding"), wxDefaultPosition, wxDefaultSize), + 0, wxGROW | wxALL, 5); + m_enabledecoCheck->SetValue(wxGetApp().m_enabledeco); + + // add parsing enabling check box + subtopSizer->Add( + m_enableparseCheck = new wxCheckBox(panel, OPJDECO_ENABLEPARSE, wxT("Enable parsing"), wxDefaultPosition, wxDefaultSize), + 0, wxGROW | wxALL, 5); + m_enableparseCheck->SetValue(wxGetApp().m_enableparse); + + // resize settings, column + wxString choices[] = {wxT("Don't resize"), wxT("Low quality"), wxT("High quality")}; + m_resizeBox = new wxRadioBox(panel, OPJDECO_RESMETHOD, + wxT("Resize method"), + wxDefaultPosition, wxDefaultSize, + WXSIZEOF(choices), + choices, + 1, + wxRA_SPECIFY_ROWS); + m_resizeBox->SetSelection(wxGetApp().m_resizemethod + 1); + + subtopSizer->Add(m_resizeBox, 0, wxGROW | wxALL, 5); + + topSizer->Add(subtopSizer, 1, wxGROW | wxALIGN_CENTRE | wxALL, 5); + + // assign top and fit it + panel->SetSizer(topSizer); + topSizer->Fit(panel); + + return panel; +} + +wxPanel* OPJDecoderDialog::CreatePart3SettingsPage(wxWindow* parent) +{ + wxPanel* panel = new wxPanel(parent, wxID_ANY); + + // top sizer + wxBoxSizer *topSizer = new wxBoxSizer(wxVERTICAL); + + // add some space + //topSizer->AddSpacer(5); + + // sub top sizer + wxBoxSizer *subtopSizer = new wxBoxSizer(wxVERTICAL); + + // frame settings, column + wxStaticBox* frameBox = new wxStaticBox(panel, wxID_ANY, wxT("Frame")); + wxBoxSizer* frameSizer = new wxStaticBoxSizer(frameBox, wxVERTICAL); + + // selected frame number, row + wxBoxSizer* framenumSizer = new wxBoxSizer(wxHORIZONTAL); + + // add some text + framenumSizer->Add(new wxStaticText(panel, wxID_ANY, wxT("&Displayed frame:")), + 0, wxALL | wxALIGN_CENTER_VERTICAL, 5); + + // add some horizontal space + framenumSizer->Add(5, 5, 1, wxALL, 0); + + // add the value control + framenumSizer->Add( + m_framenumCtrl = new wxSpinCtrl(panel, OPJDECO_FRAMENUM, + wxString::Format(wxT("%d"), wxGetApp().m_framenum), + wxDefaultPosition, wxSize(80, wxDefaultCoord), + wxSP_ARROW_KEYS, + 1, 100000, wxGetApp().m_framenum), + 0, wxALL | wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL, 5); + + frameSizer->Add(framenumSizer, 0, wxGROW | wxALL, 5); + + subtopSizer->Add(frameSizer, 0, wxGROW | wxALL, 5); + + topSizer->Add(subtopSizer, 1, wxGROW | wxALIGN_CENTRE | wxALL, 5); + + // assign top and fit it + panel->SetSizer(topSizer); + topSizer->Fit(panel); + + return panel; +} + +wxPanel* OPJDecoderDialog::CreatePart1SettingsPage(wxWindow* parent) +{ + wxPanel* panel = new wxPanel(parent, wxID_ANY); + + // top sizer + wxBoxSizer *topSizer = new wxBoxSizer(wxVERTICAL); + + // add some space + //topSizer->AddSpacer(5); + + // sub top sizer + wxBoxSizer *subtopSizer = new wxBoxSizer(wxVERTICAL); + + // resolutions settings, column + wxStaticBox* resolutionBox = new wxStaticBox(panel, wxID_ANY, wxT("Resolutions")); + wxBoxSizer* resolutionSizer = new wxStaticBoxSizer(resolutionBox, wxVERTICAL); + + // reduce factor sizer, row + wxBoxSizer* reduceSizer = new wxBoxSizer(wxHORIZONTAL); + + // add some text + reduceSizer->Add(new wxStaticText(panel, wxID_ANY, wxT("&Reduce factor:")), + 0, wxALL | wxALIGN_CENTER_VERTICAL, 5); + + // add some horizontal space + reduceSizer->Add(5, 5, 1, wxALL, 0); + + // add the value control + reduceSizer->Add( + m_reduceCtrl = new wxSpinCtrl(panel, OPJDECO_REDUCEFACTOR, + wxString::Format(wxT("%d"), wxGetApp().m_reducefactor), + wxDefaultPosition, wxSize(80, wxDefaultCoord), + wxSP_ARROW_KEYS, + 0, 10000, wxGetApp().m_reducefactor), + 0, wxALL | wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL, 5); + + resolutionSizer->Add(reduceSizer, 0, wxGROW | wxALL, 5); + + subtopSizer->Add(resolutionSizer, 0, wxGROW | wxALL, 5); + + // quality layer settings, column + wxStaticBox* layerBox = new wxStaticBox(panel, wxID_ANY, wxT("Layers")); + wxBoxSizer* layerSizer = new wxStaticBoxSizer(layerBox, wxVERTICAL); + + // quality layers sizer, row + wxBoxSizer* qualitySizer = new wxBoxSizer(wxHORIZONTAL); + + // add some text + qualitySizer->Add(new wxStaticText(panel, wxID_ANY, wxT("&Quality layers:")), + 0, wxALL | wxALIGN_CENTER_VERTICAL, 5); + + // add some horizontal space + qualitySizer->Add(5, 5, 1, wxALL, 0); + + // add the value control + qualitySizer->Add( + m_layerCtrl = new wxSpinCtrl(panel, OPJDECO_QUALITYLAYERS, + wxString::Format(wxT("%d"), wxGetApp().m_qualitylayers), + wxDefaultPosition, wxSize(80, wxDefaultCoord), + wxSP_ARROW_KEYS, + 0, 100000, wxGetApp().m_qualitylayers), + 0, wxALL | wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL, 5); + + layerSizer->Add(qualitySizer, 0, wxGROW | wxALL, 5); + + subtopSizer->Add(layerSizer, 0, wxGROW | wxALL, 5); + + // component settings, column + wxStaticBox* compoBox = new wxStaticBox(panel, wxID_ANY, wxT("Components")); + wxBoxSizer* compoSizer = new wxStaticBoxSizer(compoBox, wxVERTICAL); + + // quality layers sizer, row + wxBoxSizer* numcompsSizer = new wxBoxSizer(wxHORIZONTAL); + + // add some text + numcompsSizer->Add(new wxStaticText(panel, wxID_ANY, wxT("&Component displayed:")), + 0, wxALL | wxALIGN_CENTER_VERTICAL, 5); + + // add some horizontal space + numcompsSizer->Add(5, 5, 1, wxALL, 0); + + // add the value control + numcompsSizer->Add( + m_numcompsCtrl = new wxSpinCtrl(panel, OPJDECO_NUMCOMPS, + wxString::Format(wxT("%d"), wxGetApp().m_components), + wxDefaultPosition, wxSize(80, wxDefaultCoord), + wxSP_ARROW_KEYS, + 0, 100000, wxGetApp().m_components), + 0, wxALL | wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL, 5); + m_numcompsCtrl->Enable(true); + + compoSizer->Add(numcompsSizer, 0, wxGROW | wxALL, 5); + + subtopSizer->Add(compoSizer, 0, wxGROW | wxALL, 5); + + topSizer->Add(subtopSizer, 1, wxGROW | wxALIGN_CENTRE | wxALL, 5); + + // assign top and fit it + panel->SetSizer(topSizer); + topSizer->Fit(panel); + + return panel; +} + +#ifdef USE_JPWL +wxPanel* OPJDecoderDialog::CreatePart11SettingsPage(wxWindow* parent) +{ + wxPanel* panel = new wxPanel(parent, wxID_ANY); + + // top sizer + wxBoxSizer *topSizer = new wxBoxSizer(wxVERTICAL); + + // add some space + //topSizer->AddSpacer(5); + + // sub top sizer + wxBoxSizer *subtopSizer = new wxBoxSizer(wxVERTICAL); + + // add JPWL enabling check box + subtopSizer->Add( + m_enablejpwlCheck = new wxCheckBox(panel, OPJDECO_ENABLEJPWL, wxT("Enable JPWL"), wxDefaultPosition, wxDefaultSize), + 0, wxGROW | wxALL, 5); + m_enablejpwlCheck->SetValue(wxGetApp().m_enablejpwl); + + // component settings, column + wxStaticBox* compoBox = new wxStaticBox(panel, wxID_ANY, wxT("Components")); + wxBoxSizer* compoSizer = new wxStaticBoxSizer(compoBox, wxVERTICAL); + + // expected components sizer, row + wxBoxSizer* expcompsSizer = new wxBoxSizer(wxHORIZONTAL); + + // add some text + expcompsSizer->Add(new wxStaticText(panel, wxID_ANY, wxT("&Expected comps.:")), + 0, wxALL | wxALIGN_CENTER_VERTICAL, 5); + + // add some horizontal space + expcompsSizer->Add(5, 5, 1, wxALL, 0); + + // add the value control + expcompsSizer->Add( + m_expcompsCtrl = new wxSpinCtrl(panel, OPJDECO_EXPCOMPS, + wxString::Format(wxT("%d"), wxGetApp().m_expcomps), + wxDefaultPosition, wxSize(80, wxDefaultCoord), + wxSP_ARROW_KEYS, + 1, 100000, wxGetApp().m_expcomps), + 0, wxALL | wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL, 5); + m_expcompsCtrl->Enable(wxGetApp().m_enablejpwl); + + compoSizer->Add(expcompsSizer, 0, wxGROW | wxALL, 5); + + subtopSizer->Add(compoSizer, 0, wxGROW | wxALL, 5); + + // tiles settings, column + wxStaticBox* tileBox = new wxStaticBox(panel, wxID_ANY, wxT("Tiles")); + wxBoxSizer* tileSizer = new wxStaticBoxSizer(tileBox, wxVERTICAL); + + // maximum tiles sizer, row + wxBoxSizer* maxtileSizer = new wxBoxSizer(wxHORIZONTAL); + + // add some text + maxtileSizer->Add(new wxStaticText(panel, wxID_ANY, wxT("&Max. no. of tiles:")), + 0, wxALL | wxALIGN_CENTER_VERTICAL, 5); + + // add some horizontal space + maxtileSizer->Add(5, 5, 1, wxALL, 0); + + // add the value control + maxtileSizer->Add( + m_maxtilesCtrl = new wxSpinCtrl(panel, OPJDECO_MAXTILES, + wxString::Format(wxT("%d"), wxGetApp().m_maxtiles), + wxDefaultPosition, wxSize(80, wxDefaultCoord), + wxSP_ARROW_KEYS, + 1, 100000, wxGetApp().m_maxtiles), + 0, wxALL | wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL, 5); + m_maxtilesCtrl->Enable(wxGetApp().m_enablejpwl); + + tileSizer->Add(maxtileSizer, 0, wxGROW | wxALL, 5); + + subtopSizer->Add(tileSizer, 0, wxGROW | wxALL, 5); + + topSizer->Add(subtopSizer, 1, wxGROW | wxALIGN_CENTRE | wxALL, 5); + + // assign top and fit it + panel->SetSizer(topSizer); + topSizer->Fit(panel); + + return panel; +} + +void OPJDecoderDialog::OnEnableDeco(wxCommandEvent& event) +{ + size_t pp; + + if (event.IsChecked()) { + wxLogMessage(wxT("Decoding enabled")); + m_resizeBox->Enable(true); + // enable all tabs except ourselves + for (pp = 0; pp < m_settingsNotebook->GetPageCount(); pp++) { + if (m_settingsNotebook->GetPageText(pp) != wxT("Display")) + m_settingsNotebook->GetPage(pp)->Enable(true); + } + } else { + wxLogMessage(wxT("Decoding disabled")); + m_resizeBox->Enable(false); + // disable all tabs except ourselves + for (pp = 0; pp < m_settingsNotebook->GetPageCount(); pp++) { + if (m_settingsNotebook->GetPageText(pp) != wxT("Display")) + m_settingsNotebook->GetPage(pp)->Enable(false); + } + } + +} + +void OPJDecoderDialog::OnEnableJPWL(wxCommandEvent& event) +{ + if (event.IsChecked()) { + wxLogMessage(wxT("JPWL enabled")); + m_expcompsCtrl->Enable(true); + m_maxtilesCtrl->Enable(true); + } else { + wxLogMessage(wxT("JPWL disabled")); + m_expcompsCtrl->Enable(false); + m_maxtilesCtrl->Enable(false); + } + +} + +#endif // USE_JPWL + +bool OPJDnDFile::OnDropFiles(wxCoord, wxCoord, const wxArrayString& filenames) +{ + /*size_t nFiles = filenames.GetCount(); + wxString str; + str.Printf( _T("%d files dropped\n"), (int)nFiles); + for ( size_t n = 0; n < nFiles; n++ ) { + str << filenames[n] << wxT("\n"); + } + wxLogMessage(str);*/ + m_pOwner->OpenFiles(filenames, filenames); + + return true; +} + + + + + +// ---------------------------------------------------------------------------- +// OPJEncoderDialog +// ---------------------------------------------------------------------------- + +IMPLEMENT_CLASS(OPJEncoderDialog, wxPropertySheetDialog) + +BEGIN_EVENT_TABLE(OPJEncoderDialog, wxPropertySheetDialog) +#ifdef USE_JPWL + EVT_CHECKBOX(OPJENCO_ENABLEJPWL, OPJEncoderDialog::OnEnableJPWL) + EVT_CHECKBOX(OPJENCO_ENABLECOMM, OPJEncoderDialog::OnEnableComm) + EVT_CHECKBOX(OPJENCO_ENABLEINDEX, OPJEncoderDialog::OnEnableIdx) + EVT_RADIOBUTTON(OPJENCO_RATERADIO, OPJEncoderDialog::OnRadioQualityRate) + EVT_RADIOBUTTON(OPJENCO_QUALITYRADIO, OPJEncoderDialog::OnRadioQualityRate) +#endif // USE_JPWL +END_EVENT_TABLE() + +OPJEncoderDialog::OPJEncoderDialog(wxWindow* win, int dialogType) +{ + SetExtraStyle(wxDIALOG_EX_CONTEXTHELP|wxWS_EX_VALIDATE_RECURSIVELY); + + Create(win, wxID_ANY, wxT("Encoder settings"), + wxDefaultPosition, wxDefaultSize, + wxDEFAULT_DIALOG_STYLE| (int) wxPlatform::IfNot(wxOS_WINDOWS_CE, wxRESIZE_BORDER) + ); + + CreateButtons(wxOK | wxCANCEL | (int)wxPlatform::IfNot(wxOS_WINDOWS_CE, wxHELP)); + + m_settingsNotebook = GetBookCtrl(); + + wxPanel* jpeg2000_1Settings = CreatePart1_1SettingsPage(m_settingsNotebook); + wxPanel* jpeg2000_2Settings = CreatePart1_2SettingsPage(m_settingsNotebook); + wxPanel* mainSettings = CreateMainSettingsPage(m_settingsNotebook); +#ifdef USE_JPWL + wxPanel* jpwlSettings = CreatePart11SettingsPage(m_settingsNotebook); +#endif // USE_JPWL + + m_settingsNotebook->AddPage(jpeg2000_1Settings, wxT("JPEG 2000 - 1"), false); + m_settingsNotebook->AddPage(jpeg2000_2Settings, wxT("JPEG 2000 - 2"), false); + m_settingsNotebook->AddPage(mainSettings, wxT("General"), false); +#ifdef USE_JPWL + m_settingsNotebook->AddPage(jpwlSettings, wxT("JPWL"), false); +#endif // USE_JPWL + + LayoutDialog(); +} + +OPJEncoderDialog::~OPJEncoderDialog() +{ +} + +wxPanel* OPJEncoderDialog::CreateMainSettingsPage(wxWindow* parent) +{ + wxPanel* panel = new wxPanel(parent, wxID_ANY); + + // top sizer + wxBoxSizer *topSizer = new wxBoxSizer(wxVERTICAL); + + // sub top sizer + wxBoxSizer *subtopSizer = new wxBoxSizer(wxVERTICAL); + + topSizer->Add(subtopSizer, 1, wxGROW | wxALIGN_CENTRE | wxALL, 5); + + // assign top and fit it + panel->SetSizer(topSizer); + topSizer->Fit(panel); + + return panel; +} + +#ifdef USE_JPWL +wxPanel* OPJEncoderDialog::CreatePart11SettingsPage(wxWindow* parent) +{ + wxPanel* panel = new wxPanel(parent, wxID_ANY); + + // top sizer + wxBoxSizer *topSizer = new wxBoxSizer(wxVERTICAL); + + // sub top sizer + wxBoxSizer *subtopSizer = new wxBoxSizer(wxVERTICAL); + + topSizer->Add(subtopSizer, 1, wxGROW | wxALIGN_CENTRE | wxALL, 5); + + // assign top and fit it + panel->SetSizer(topSizer); + topSizer->Fit(panel); + + return panel; +} +#endif // USE_JPWL + +wxPanel* OPJEncoderDialog::CreatePart1_1SettingsPage(wxWindow* parent) +{ + wxPanel* panel = new wxPanel(parent, wxID_ANY); + + // top sizer + wxBoxSizer *topSizer = new wxBoxSizer(wxVERTICAL); + + // add some space + //topSizer->AddSpacer(5); + + // sub top sizer + wxFlexGridSizer *subtopSizer = new wxFlexGridSizer(2, 3, 3); + + // image settings, column + wxStaticBox* imageBox = new wxStaticBox(panel, wxID_ANY, wxT("Image")); + wxBoxSizer* imageSizer = new wxStaticBoxSizer(imageBox, wxVERTICAL); + + // subsampling factor sizer, row + wxBoxSizer* subsSizer = new wxBoxSizer(wxHORIZONTAL); + + // add some text + subsSizer->Add(new wxStaticText(panel, wxID_ANY, wxT("&Subsampling:")), + 0, wxALL | wxALIGN_CENTER_VERTICAL, 3); + + // add some horizontal space + subsSizer->Add(3, 3, 1, wxALL, 0); + + // add the value control + subsSizer->Add( + m_subsamplingCtrl = new wxTextCtrl(panel, OPJENCO_SUBSAMPLING, + wxGetApp().m_subsampling, + wxDefaultPosition, wxSize(80, wxDefaultCoord), + wxTE_LEFT), + 0, wxALL | wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL, 3); + + imageSizer->Add(subsSizer, 0, wxGROW | wxALL, 3); + + // origin sizer, row + wxBoxSizer* imorigSizer = new wxBoxSizer(wxHORIZONTAL); + + // add some text + imorigSizer->Add(new wxStaticText(panel, wxID_ANY, wxT("&Origin:")), + 0, wxALL | wxALIGN_CENTER_VERTICAL, 3); + + // add some horizontal space + imorigSizer->Add(3, 3, 1, wxALL, 0); + + // add the value control + imorigSizer->Add( + m_originCtrl = new wxTextCtrl(panel, OPJENCO_IMORIG, + wxGetApp().m_origin, + wxDefaultPosition, wxSize(80, wxDefaultCoord), + wxTE_LEFT), + 0, wxALL | wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL, 3); + + imageSizer->Add(imorigSizer, 0, wxGROW | wxALL, 3); + + subtopSizer->Add(imageSizer, 0, wxGROW | wxALL, 3); + + // layer settings, column + wxStaticBox* layerBox = new wxStaticBox(panel, wxID_ANY, wxT("Layers/compression")); + wxBoxSizer* layerSizer = new wxStaticBoxSizer(layerBox, wxVERTICAL); + + // rate factor sizer, row + wxBoxSizer* rateSizer = new wxBoxSizer(wxHORIZONTAL); + + // add some text + /*rateSizer->Add(new wxStaticText(panel, wxID_ANY, wxT("&Rate values:")), + 0, wxALL | wxALIGN_CENTER_VERTICAL, 3);*/ + + // add the radio button + rateSizer->Add( + m_rateRadio = new wxRadioButton(panel, OPJENCO_RATERADIO, wxT("&Rate values"), + wxDefaultPosition, wxDefaultSize, + wxRB_GROUP), + 0, wxALL | wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL + ); + m_rateRadio->SetValue(!(wxGetApp().m_enablequality)); + + // add some horizontal space + rateSizer->Add(3, 3, 1, wxALL, 0); + + // add the value control + rateSizer->Add( + m_rateCtrl = new wxTextCtrl(panel, OPJENCO_RATEFACTOR, + wxGetApp().m_rates, + wxDefaultPosition, wxSize(100, wxDefaultCoord), + wxTE_LEFT), + 0, wxALL | wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL, 3); + if (wxGetApp().m_enablequality == true) + m_rateCtrl->Enable(false); + + layerSizer->Add(rateSizer, 0, wxGROW | wxALL, 3); + + // quality factor sizer, row + wxBoxSizer* qualitySizer = new wxBoxSizer(wxHORIZONTAL); + + // add some text + /*qualitySizer->Add(new wxStaticText(panel, wxID_ANY, wxT("&Quality values:")), + 0, wxALL | wxALIGN_CENTER_VERTICAL, 3);*/ + + // add the radio button + qualitySizer->Add( + m_qualityRadio = new wxRadioButton(panel, OPJENCO_QUALITYRADIO, wxT("&Quality values"), + wxDefaultPosition, wxDefaultSize), + 0, wxALL | wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL + ); + m_qualityRadio->SetValue(wxGetApp().m_enablequality); + + // add some horizontal space + qualitySizer->Add(3, 3, 1, wxALL, 0); + + // add the value control + qualitySizer->Add( + m_qualityCtrl = new wxTextCtrl(panel, OPJENCO_QUALITYFACTOR, + wxGetApp().m_quality, + wxDefaultPosition, wxSize(100, wxDefaultCoord), + wxTE_LEFT), + 0, wxALL | wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL, 3); + if (wxGetApp().m_enablequality == false) + m_qualityCtrl->Enable(false); + + layerSizer->Add(qualitySizer, 0, wxGROW | wxALL, 3); + + subtopSizer->Add(layerSizer, 0, wxGROW | wxALL, 3); + + // wavelet settings, column + wxStaticBox* transformBox = new wxStaticBox(panel, wxID_ANY, wxT("Transforms")); + wxBoxSizer* transformSizer = new wxStaticBoxSizer(transformBox, wxVERTICAL); + + // multiple component check box + transformSizer->Add( + m_mctCheck = new wxCheckBox(panel, OPJENCO_ENABLEMCT, wxT("Multiple component"), + wxDefaultPosition, wxDefaultSize), + 0, wxGROW | wxALL, 3); + m_mctCheck->SetValue(wxGetApp().m_multicomp); + + // irreversible wavelet check box + transformSizer->Add( + m_irrevCheck = new wxCheckBox(panel, OPJENCO_ENABLEIRREV, wxT("Irreversible wavelet"), + wxDefaultPosition, wxDefaultSize), + 0, wxGROW | wxALL, 3); + m_irrevCheck->SetValue(wxGetApp().m_irreversible); + + // resolution number sizer, row + wxBoxSizer* resnumSizer = new wxBoxSizer(wxHORIZONTAL); + + // add some text + resnumSizer->Add(new wxStaticText(panel, wxID_ANY, wxT("&Resolutions:")), + 0, wxALL | wxALIGN_CENTER_VERTICAL, 3); + + // add some horizontal space + resnumSizer->Add(3, 3, 1, wxALL, 0); + + // add the value control + resnumSizer->Add( + m_resolutionsCtrl = new wxSpinCtrl(panel, OPJENCO_RESNUMBER, + wxString::Format(wxT("%d"), wxGetApp().m_resolutions), + wxDefaultPosition, wxSize(80, wxDefaultCoord), + wxSP_ARROW_KEYS, + 0, 256, 6), + 0, wxALL | wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL, 3); + + transformSizer->Add(resnumSizer, 0, wxGROW | wxALL, 3); + + subtopSizer->Add(transformSizer, 0, wxGROW | wxALL, 3); + + // codestream settings, column + wxStaticBox* codestreamBox = new wxStaticBox(panel, wxID_ANY, wxT("Codestream")); + wxBoxSizer* codestreamSizer = new wxStaticBoxSizer(codestreamBox, wxVERTICAL); + + // codeblock sizer, row + wxBoxSizer* codeblockSizer = new wxBoxSizer(wxHORIZONTAL); + + // add some text + codeblockSizer->Add(new wxStaticText(panel, wxID_ANY, wxT("&Codeblocks size:")), + 0, wxALL | wxALIGN_CENTER_VERTICAL, 3); + + // add some horizontal space + codeblockSizer->Add(3, 3, 1, wxALL, 0); + + // add the value control + codeblockSizer->Add( + m_cbsizeCtrl = new wxTextCtrl(panel, OPJENCO_CODEBLOCKSIZE, + wxGetApp().m_cbsize, + wxDefaultPosition, wxSize(100, wxDefaultCoord), + wxTE_LEFT), + 0, wxALL | wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL, 3); + + codestreamSizer->Add(codeblockSizer, 0, wxGROW | wxALL, 3); + + // precinct sizer, row + wxBoxSizer* precinctSizer = new wxBoxSizer(wxHORIZONTAL); + + // add some text + precinctSizer->Add(new wxStaticText(panel, wxID_ANY, wxT("&Precincts size:")), + 0, wxALL | wxALIGN_CENTER_VERTICAL, 3); + + // add some horizontal space + precinctSizer->Add(3, 3, 1, wxALL, 0); + + // add the value control + precinctSizer->Add( + m_prsizeCtrl = new wxTextCtrl(panel, OPJENCO_PRECINCTSIZE, + wxGetApp().m_prsize, + wxDefaultPosition, wxSize(100, wxDefaultCoord), + wxTE_LEFT), + 0, wxALL | wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL, 3); + + codestreamSizer->Add(precinctSizer, 0, wxGROW | wxALL, 3); + + subtopSizer->Add(codestreamSizer, 0, wxGROW | wxALL, 3); + + // tile settings, column + wxStaticBox* tileBox = new wxStaticBox(panel, wxID_ANY, wxT("Tiles")); + wxBoxSizer* tileSizer = new wxStaticBoxSizer(tileBox, wxVERTICAL); + + // tile size sizer, row + wxBoxSizer* tilesizeSizer = new wxBoxSizer(wxHORIZONTAL); + + // add some text + tilesizeSizer->Add(new wxStaticText(panel, wxID_ANY, wxT("&Size:")), + 0, wxALL | wxALIGN_CENTER_VERTICAL, 3); + + // add some horizontal space + tilesizeSizer->Add(3, 3, 1, wxALL, 0); + + // add the value control + tilesizeSizer->Add( + m_tsizeCtrl = new wxTextCtrl(panel, OPJENCO_TILESIZE, + wxGetApp().m_tsize, + wxDefaultPosition, wxSize(80, wxDefaultCoord), + wxTE_LEFT), + 0, wxALL | wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL, 3); + + tileSizer->Add(tilesizeSizer, 0, wxGROW | wxALL, 3); + + // tile origin sizer, row + wxBoxSizer* tilorigSizer = new wxBoxSizer(wxHORIZONTAL); + + // add some text + tilorigSizer->Add(new wxStaticText(panel, wxID_ANY, wxT("&Origin:")), + 0, wxALL | wxALIGN_CENTER_VERTICAL, 3); + + // add some horizontal space + tilorigSizer->Add(3, 3, 1, wxALL, 0); + + // add the value control + tilorigSizer->Add( + m_toriginCtrl = new wxTextCtrl(panel, OPJENCO_TILORIG, + wxGetApp().m_torigin, + wxDefaultPosition, wxSize(80, wxDefaultCoord), + wxTE_LEFT), + 0, wxALL | wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL, 3); + + tileSizer->Add(tilorigSizer, 0, wxGROW | wxALL, 3); + + subtopSizer->Add(tileSizer, 0, wxGROW | wxALL, 3); + + // progression and profile settings, column + wxString choices[] = {wxT("LRCP"), wxT("RLCP"), wxT("RPCL"), wxT("PCRL"), wxT("CPRL"), + wxT("DCI2K24"), wxT("DCI2K48"), wxT("DCI4K")}; + progressionBox = new wxRadioBox(panel, OPJENCO_PROGRESSION, + wxT("Progression order/profile"), + wxDefaultPosition, wxDefaultSize, + WXSIZEOF(choices), + choices, + 3, + wxRA_SPECIFY_COLS); + progressionBox->SetSelection(wxGetApp().m_progression); + + subtopSizer->Add(progressionBox, 0, wxGROW | wxALL, 3); + + topSizer->Add(subtopSizer, 1, wxGROW | wxALIGN_CENTRE | wxALL, 5); + + // assign top and fit it + panel->SetSizer(topSizer); + topSizer->Fit(panel); + + return panel; +} + +wxPanel* OPJEncoderDialog::CreatePart1_2SettingsPage(wxWindow* parent) +{ + wxPanel* panel = new wxPanel(parent, wxID_ANY); + + // top sizer + wxBoxSizer *topSizer = new wxBoxSizer(wxVERTICAL); + + // add some space + //topSizer->AddSpacer(5); + + // sub top sizer + wxFlexGridSizer *subtopSizer = new wxFlexGridSizer(2, 3, 3); + + // resilience settings, column + wxStaticBox* resilBox = new wxStaticBox(panel, wxID_ANY, wxT("Error resilience")); + wxBoxSizer* resilSizer = new wxStaticBoxSizer(resilBox, wxVERTICAL); + + // resil2 sizer, row + wxBoxSizer* resil2Sizer = new wxBoxSizer(wxHORIZONTAL); + + // SOP check box + resil2Sizer->Add( + m_sopCheck = new wxCheckBox(panel, OPJENCO_ENABLESOP, wxT("SOP"), + wxDefaultPosition, wxDefaultSize), + 0, wxGROW | wxALL, 3); + m_sopCheck->SetValue(wxGetApp().m_enablesop); + + // EPH check box + resil2Sizer->Add( + m_ephCheck = new wxCheckBox(panel, OPJENCO_ENABLEEPH, wxT("EPH"), + wxDefaultPosition, wxDefaultSize), + 0, wxGROW | wxALL, 3); + m_ephCheck->SetValue(wxGetApp().m_enableeph); + + resilSizer->Add(resil2Sizer, 0, wxGROW | wxALL, 3); + + // separation + resilSizer->Add(new wxStaticLine(panel, wxID_ANY), 0, wxEXPAND | wxLEFT | wxRIGHT, 3); + + // resil3 sizer, row + wxFlexGridSizer* resil3Sizer = new wxFlexGridSizer(3, 3, 3); + + // BYPASS check box + resil3Sizer->Add( + m_enablebypassCheck = new wxCheckBox(panel, OPJENCO_ENABLEBYPASS, wxT("BYPASS"), + wxDefaultPosition, wxDefaultSize), + 0, wxGROW | wxALL, 3); + m_enablebypassCheck->SetValue(wxGetApp().m_enablebypass); + + // RESET check box + resil3Sizer->Add( + m_enableresetCheck = new wxCheckBox(panel, OPJENCO_ENABLERESET, wxT("RESET"), + wxDefaultPosition, wxDefaultSize), + 0, wxGROW | wxALL, 3); + m_enableresetCheck->SetValue(wxGetApp().m_enablereset); + + // RESTART check box + resil3Sizer->Add( + m_enablerestartCheck = new wxCheckBox(panel, OPJENCO_ENABLERESTART, wxT("RESTART"), + wxDefaultPosition, wxDefaultSize), + 0, wxGROW | wxALL, 3); + m_enablerestartCheck->SetValue(wxGetApp().m_enablerestart); + + // VSC check box + resil3Sizer->Add( + m_enablevscCheck = new wxCheckBox(panel, OPJENCO_ENABLEVSC, wxT("VSC"), + wxDefaultPosition, wxDefaultSize), + 0, wxGROW | wxALL, 3); + m_enablevscCheck->SetValue(wxGetApp().m_enablevsc); + + // ERTERM check box + resil3Sizer->Add( + m_enableertermCheck = new wxCheckBox(panel, OPJENCO_ENABLEERTERM, wxT("ERTERM"), + wxDefaultPosition, wxDefaultSize), + 0, wxGROW | wxALL, 3); + m_enableertermCheck->SetValue(wxGetApp().m_enableerterm); + + // SEGMARK check box + resil3Sizer->Add( + m_enablesegmarkCheck = new wxCheckBox(panel, OPJENCO_ENABLESEGMARK, wxT("SEGMARK"), + wxDefaultPosition, wxDefaultSize), + 0, wxGROW | wxALL, 3); + m_enablesegmarkCheck->SetValue(wxGetApp().m_enablesegmark); + + resilSizer->Add(resil3Sizer, 0, wxGROW | wxALL, 3); + + subtopSizer->Add(resilSizer, 0, wxGROW | wxALL, 3); + + // ROI settings, column + wxStaticBox* roiBox = new wxStaticBox(panel, wxID_ANY, wxT("Region Of Interest")); + wxBoxSizer* roiSizer = new wxStaticBoxSizer(roiBox, wxVERTICAL); + + // component number sizer, row + wxBoxSizer* roicompSizer = new wxBoxSizer(wxHORIZONTAL); + + // add some text + roicompSizer->Add(new wxStaticText(panel, wxID_ANY, wxT("&Component:")), + 0, wxALL | wxALIGN_CENTER_VERTICAL, 3); + + // add some horizontal space + roicompSizer->Add(3, 3, 1, wxALL, 0); + + // add the value control + roicompSizer->Add( + /*m_layerCtrl =*/ new wxSpinCtrl(panel, OPJENCO_ROICOMP, + wxT("0"), + wxDefaultPosition, wxSize(80, wxDefaultCoord), + wxSP_ARROW_KEYS, + 0, 256, 0), + 0, wxALL | wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL, 3); + + roiSizer->Add(roicompSizer, 0, wxGROW | wxALL, 3); + + // upshift sizer, row + wxBoxSizer* roishiftSizer = new wxBoxSizer(wxHORIZONTAL); + + // add some text + roishiftSizer->Add(new wxStaticText(panel, wxID_ANY, wxT("&Upshift:")), + 0, wxALL | wxALIGN_CENTER_VERTICAL, 3); + + // add some horizontal space + roishiftSizer->Add(3, 3, 1, wxALL, 0); + + // add the value control + roishiftSizer->Add( + /*m_layerCtrl =*/ new wxSpinCtrl(panel, OPJENCO_ROISHIFT, + wxT("0"), + wxDefaultPosition, wxSize(80, wxDefaultCoord), + wxSP_ARROW_KEYS, + 0, 37, 0), + 0, wxALL | wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL, 3); + + roiSizer->Add(roishiftSizer, 0, wxGROW | wxALL, 3); + + subtopSizer->Add(roiSizer, 0, wxGROW | wxALL, 3); + + // Index file settings, column + wxStaticBox* indexBox = new wxStaticBox(panel, wxID_ANY, wxT("Indexing")); + wxBoxSizer* indexSizer = new wxStaticBoxSizer(indexBox, wxVERTICAL); + + // indexing check box + indexSizer->Add( + m_enableidxCheck = new wxCheckBox(panel, OPJENCO_ENABLEINDEX, wxT("Enabled"), + wxDefaultPosition, wxDefaultSize), + 0, wxGROW | wxALL, 3); + m_enableidxCheck->SetValue(wxGetApp().m_enableidx); + + // index file sizer, row + wxBoxSizer* indexnameSizer = new wxBoxSizer(wxHORIZONTAL); + + // add some text + indexnameSizer->Add(new wxStaticText(panel, wxID_ANY, wxT("&File name:")), + 0, wxALL | wxALIGN_CENTER_VERTICAL, 3); + + // add some horizontal space + indexnameSizer->Add(3, 3, 1, wxALL, 0); + + // add the value control + indexnameSizer->Add( + m_indexCtrl = new wxTextCtrl(panel, OPJENCO_INDEXNAME, + wxGetApp().m_index, + wxDefaultPosition, wxSize(120, wxDefaultCoord), + wxTE_LEFT), + 0, wxALL | wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL, 3); + m_indexCtrl->Enable(wxGetApp().m_enableidx); + + indexSizer->Add(indexnameSizer, 0, wxGROW | wxALL, 3); + + subtopSizer->Add(indexSizer, 0, wxGROW | wxALL, 3); + + // Comment settings, column + wxStaticBox* commentBox = new wxStaticBox(panel, wxID_ANY, wxT("Comment")); + wxBoxSizer* commentSizer = new wxStaticBoxSizer(commentBox, wxVERTICAL); + + // commenting check box + commentSizer->Add( + m_enablecommCheck = new wxCheckBox(panel, OPJENCO_ENABLECOMM, wxT("Enabled (empty to reset)"), + wxDefaultPosition, wxDefaultSize), + 0, wxGROW | wxALL, 3); + m_enablecommCheck->SetValue(wxGetApp().m_enablecomm); + + // add some horizontal space + commentSizer->Add(3, 3, 1, wxALL, 0); + + // add the value control + commentSizer->Add( + m_commentCtrl = new wxTextCtrl(panel, OPJENCO_COMMENTTEXT, + wxGetApp().m_comment, + wxDefaultPosition, wxSize(wxDefaultCoord, 60), + wxTE_LEFT | wxTE_MULTILINE), + 0, wxGROW | wxALL | wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL, 3); + m_commentCtrl->Enable(wxGetApp().m_enablecomm); + + subtopSizer->Add(commentSizer, 0, wxGROW | wxALL, 3); + + // POC settings, column + wxStaticBox* pocBox = new wxStaticBox(panel, wxID_ANY, wxT("POC")); + wxBoxSizer* pocSizer = new wxStaticBoxSizer(pocBox, wxVERTICAL); + + // POC check box + pocSizer->Add( + m_enablepocCheck = new wxCheckBox(panel, OPJENCO_ENABLEPOC, wxT("Enabled"), + wxDefaultPosition, wxDefaultSize), + 0, wxGROW | wxALL, 3); + m_enablepocCheck->SetValue(/*wxGetApp().m_enableidx*/true); + + // POC sizer, row + wxBoxSizer* pocspecSizer = new wxBoxSizer(wxHORIZONTAL); + + // add some text + pocspecSizer->Add(new wxStaticText(panel, wxID_ANY, wxT("&Changes:")), + 0, wxALL | wxALIGN_CENTER_VERTICAL, 3); + + // add some horizontal space + pocspecSizer->Add(3, 3, 1, wxALL, 0); + + // add the value control + pocspecSizer->Add( + m_pocCtrl = new wxTextCtrl(panel, OPJENCO_POCSPEC, + /*wxGetApp().m_index*/wxT("RRRR"), + wxDefaultPosition, wxSize(120, wxDefaultCoord), + wxTE_LEFT), + 0, wxALL | wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL, 3); + m_pocCtrl->Enable(/*wxGetApp().m_enableidx*/true); + + pocSizer->Add(pocspecSizer, 0, wxGROW | wxALL, 3); + + subtopSizer->Add(pocSizer, 0, wxGROW | wxALL, 3); + + topSizer->Add(subtopSizer, 1, wxGROW | wxALIGN_CENTRE | wxALL, 5); + + // assign top and fit it + panel->SetSizer(topSizer); + topSizer->Fit(panel); + + return panel; +} + +void OPJEncoderDialog::OnEnableComm(wxCommandEvent& event) +{ + if (event.IsChecked()) { + wxLogMessage(wxT("Comment enabled")); + m_commentCtrl->Enable(true); + } else { + wxLogMessage(wxT("Comment disabled")); + m_commentCtrl->Enable(false); + } + +} + +void OPJEncoderDialog::OnEnableIdx(wxCommandEvent& event) +{ + if (event.IsChecked()) { + wxLogMessage(wxT("Index enabled")); + m_indexCtrl->Enable(true); + } else { + wxLogMessage(wxT("Index disabled")); + m_indexCtrl->Enable(false); + } + +} + +void OPJEncoderDialog::OnRadioQualityRate(wxCommandEvent& event) +{ + if (event.GetId() == OPJENCO_QUALITYRADIO) { + wxLogMessage(wxT("Quality selected")); + m_rateCtrl->Enable(false); + m_qualityCtrl->Enable(true); + } else { + wxLogMessage(wxT("Rate selected")); + m_rateCtrl->Enable(true); + m_qualityCtrl->Enable(false); + } +} + +#ifdef USE_JPWL +void OPJEncoderDialog::OnEnableJPWL(wxCommandEvent& event) +{ + /*if (event.IsChecked()) { + wxLogMessage(wxT("JPWL enabled")); + m_expcompsCtrl->Enable(true); + m_maxtilesCtrl->Enable(true); + } else { + wxLogMessage(wxT("JPWL disabled")); + m_expcompsCtrl->Enable(false); + m_maxtilesCtrl->Enable(false); + }*/ + +} +#endif // USE_JPWL diff --git a/OPJViewer/source/OPJViewer.cpp b/OPJViewer/source/OPJViewer.cpp index 8783386c..61668e41 100644 --- a/OPJViewer/source/OPJViewer.cpp +++ b/OPJViewer/source/OPJViewer.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, Digital Signal Processing Laboratory, Università degli studi di Perugia (UPG), Italy + * Copyright (c) 2007, Digital Signal Processing Laboratory, Universita' degli studi di Perugia (UPG), Italy * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -214,10 +214,10 @@ bool OPJViewerApp::OnInit(void) OPJconfig->Read(wxT("enabledeco"), &m_enabledeco, (bool) true); OPJconfig->Read(wxT("enableparse"), &m_enableparse, (bool) true); OPJconfig->Read(wxT("resizemethod"), &m_resizemethod, (long) 0); - OPJconfig->Read(wxT("reducefactor"), &m_reducefactor, (long) 0); - OPJconfig->Read(wxT("qualitylayers"), &m_qualitylayers, (long) 0); - OPJconfig->Read(wxT("components"), &m_components, (long) 0); - OPJconfig->Read(wxT("framenum"), &m_framenum, (long) 0); + OPJconfig->Read(wxT("xxxreducefactor"), &m_reducefactor, (long) 0); + OPJconfig->Read(wxT("xxxqualitylayers"), &m_qualitylayers, (long) 0); + OPJconfig->Read(wxT("xxxcomponents"), &m_components, (long) 0); + OPJconfig->Read(wxT("xxxframenum"), &m_framenum, (long) 0); #ifdef USE_JPWL OPJconfig->Read(wxT("enablejpwl"), &m_enablejpwl, (bool) true); OPJconfig->Read(wxT("expcomps"), &m_expcomps, (long) JPWL_EXPECTED_COMPONENTS); @@ -241,14 +241,23 @@ bool OPJViewerApp::OnInit(void) OPJconfig->Read(wxT("origin"), &m_origin, (wxString) wxT("0,0")); OPJconfig->Read(wxT("rates"), &m_rates, (wxString) wxT("20,10,5")); OPJconfig->Read(wxT("quality"), &m_quality, (wxString) wxT("30,35,40")); + OPJconfig->Read(wxT("enablequality"), &m_enablequality, (bool) false); + OPJconfig->Read(wxT("multicomp"), &m_multicomp, (bool) false); OPJconfig->Read(wxT("irreversible"), &m_irreversible, (bool) false); OPJconfig->Read(wxT("resolutions"), &m_resolutions, (int) 6); + OPJconfig->Read(wxT("progression"), &m_progression, (int) 0); OPJconfig->Read(wxT("cbsize"), &m_cbsize, (wxString) wxT("32,32")); OPJconfig->Read(wxT("prsize"), &m_prsize, (wxString) wxT("[128,128],[128,128]")); OPJconfig->Read(wxT("tsize"), &m_tsize, (wxString) wxT("")); OPJconfig->Read(wxT("torigin"), &m_torigin, (wxString) wxT("0,0")); OPJconfig->Read(wxT("enablesop"), &m_enablesop, (bool) false); OPJconfig->Read(wxT("enableeph"), &m_enableeph, (bool) false); + OPJconfig->Read(wxT("enablebypass"), &m_enablebypass, (bool) false); + OPJconfig->Read(wxT("enablereset"), &m_enablereset, (bool) false); + OPJconfig->Read(wxT("enablerestart"), &m_enablerestart, (bool) false); + OPJconfig->Read(wxT("enablevsc"), &m_enablevsc, (bool) false); + OPJconfig->Read(wxT("enableerterm"), &m_enableerterm, (bool) false); + OPJconfig->Read(wxT("enablesegmark"), &m_enablesegmark, (bool) false); OPJconfig->Read(wxT("enablecomm"), &m_enablecomm, (bool) true); OPJconfig->Read(wxT("comment"), &m_comment, (wxString) wxT("")); OPJconfig->Read(wxT("enableidx"), &m_enableidx, (bool) false); @@ -281,14 +290,23 @@ bool OPJViewerApp::OnInit(void) m_origin = wxT("0,0"); m_rates = wxT("20,10,5"); m_quality = wxT("30,35,40"); + m_enablequality = false; + m_multicomp = false; m_irreversible = false; m_resolutions = 6; + m_progression = 0; m_cbsize= wxT("32,32"); m_prsize= wxT("[128,128],[128,128]"); m_tsize = wxT(""); m_torigin = wxT("0,0"); m_enablesop = false; m_enableeph = false; + m_enablebypass = false; + m_enablereset = false; + m_enablerestart = false; + m_enablevsc = false; + m_enableerterm = false; + m_enablesegmark = false; m_enableidx = false; m_index = wxT("index.txt"); m_enablecomm = true; @@ -369,14 +387,23 @@ int OPJViewerApp::OnExit() OPJconfig->Write(wxT("origin"), m_origin); OPJconfig->Write(wxT("rates"), m_rates); OPJconfig->Write(wxT("quality"), m_quality); + OPJconfig->Write(wxT("enablequality"), m_enablequality); + OPJconfig->Write(wxT("multicomp"), m_multicomp); OPJconfig->Write(wxT("irreversible"), m_irreversible); OPJconfig->Write(wxT("resolutions"), m_resolutions); + OPJconfig->Write(wxT("progression"), m_progression); OPJconfig->Write(wxT("cbsize"), m_cbsize); OPJconfig->Write(wxT("prsize"), m_prsize); OPJconfig->Write(wxT("tiles"), m_tsize); OPJconfig->Write(wxT("torigin"), m_torigin); OPJconfig->Write(wxT("enablesop"), m_enablesop); OPJconfig->Write(wxT("enableeph"), m_enableeph); + OPJconfig->Write(wxT("enablebypass"), m_enablebypass); + OPJconfig->Write(wxT("enablereset"), m_enablereset); + OPJconfig->Write(wxT("enablerestart"), m_enablerestart); + OPJconfig->Write(wxT("enablevsc"), m_enablevsc); + OPJconfig->Write(wxT("enableerterm"), m_enableerterm); + OPJconfig->Write(wxT("enablesegmark"), m_enablesegmark); OPJconfig->Write(wxT("enableidx"), m_enableidx); OPJconfig->Write(wxT("index"), m_index); OPJconfig->Write(wxT("enablecomm"), m_enablecomm); @@ -415,6 +442,15 @@ BEGIN_EVENT_TABLE(OPJFrame, wxMDIParentFrame) EVT_MENU(OPJFRAME_VIEWPREVFRAME, OPJFrame::OnPrevFrame) EVT_MENU(OPJFRAME_VIEWHOMEFRAME, OPJFrame::OnHomeFrame) EVT_MENU(OPJFRAME_VIEWNEXTFRAME, OPJFrame::OnNextFrame) + EVT_MENU(OPJFRAME_VIEWLESSLAYERS, OPJFrame::OnLessLayers) + EVT_MENU(OPJFRAME_VIEWALLLAYERS, OPJFrame::OnAllLayers) + EVT_MENU(OPJFRAME_VIEWMORELAYERS, OPJFrame::OnMoreLayers) + EVT_MENU(OPJFRAME_VIEWLESSRES, OPJFrame::OnLessRes) + EVT_MENU(OPJFRAME_VIEWFULLRES, OPJFrame::OnFullRes) + EVT_MENU(OPJFRAME_VIEWMORERES, OPJFrame::OnMoreRes) + EVT_MENU(OPJFRAME_VIEWPREVCOMP, OPJFrame::OnPrevComp) + EVT_MENU(OPJFRAME_VIEWALLCOMPS, OPJFrame::OnAllComps) + EVT_MENU(OPJFRAME_VIEWNEXTCOMP, OPJFrame::OnNextComp) EVT_MENU(OPJFRAME_FILETOGGLEB, OPJFrame::OnToggleBrowser) EVT_MENU(OPJFRAME_FILETOGGLEP, OPJFrame::OnTogglePeeker) EVT_MENU(OPJFRAME_FILETOGGLET, OPJFrame::OnToggleToolbar) @@ -486,6 +522,39 @@ OPJFrame::OPJFrame(wxWindow *parent, const wxWindowID id, const wxString& title, view_menu->Append(OPJFRAME_VIEWNEXTFRAME, wxT("&Next frame\tRight")); view_menu->SetHelpString(OPJFRAME_VIEWNEXTFRAME, wxT("View next frame")); + view_menu->AppendSeparator(); + + view_menu->Append(OPJFRAME_VIEWLESSLAYERS, wxT("&Less layers\t-")); + view_menu->SetHelpString(OPJFRAME_VIEWLESSLAYERS, wxT("Remove a layer")); + + view_menu->Append(OPJFRAME_VIEWALLLAYERS, wxT("&All layers\t0")); + view_menu->SetHelpString(OPJFRAME_VIEWALLLAYERS, wxT("Show all layers")); + + view_menu->Append(OPJFRAME_VIEWMORELAYERS, wxT("&More layers\t+")); + view_menu->SetHelpString(OPJFRAME_VIEWMORELAYERS, wxT("Add a layer")); + + view_menu->AppendSeparator(); + + view_menu->Append(OPJFRAME_VIEWLESSRES, wxT("&Less resolution\t<")); + view_menu->SetHelpString(OPJFRAME_VIEWLESSRES, wxT("Reduce the resolution")); + + view_menu->Append(OPJFRAME_VIEWFULLRES, wxT("&Full resolution\tf")); + view_menu->SetHelpString(OPJFRAME_VIEWFULLRES, wxT("Full resolution")); + + view_menu->Append(OPJFRAME_VIEWMORERES, wxT("&More resolution\t>")); + view_menu->SetHelpString(OPJFRAME_VIEWMORERES, wxT("Increase the resolution")); + + view_menu->AppendSeparator(); + + view_menu->Append(OPJFRAME_VIEWPREVCOMP, wxT("&Prev component\tDown")); + view_menu->SetHelpString(OPJFRAME_VIEWPREVCOMP, wxT("View previous component")); + + view_menu->Append(OPJFRAME_VIEWALLCOMPS, wxT("&All components\ta")); + view_menu->SetHelpString(OPJFRAME_VIEWALLCOMPS, wxT("View all components")); + + view_menu->Append(OPJFRAME_VIEWNEXTCOMP, wxT("&Next component\tUp")); + view_menu->SetHelpString(OPJFRAME_VIEWNEXTCOMP, wxT("View next component")); + // settings menu and its items wxMenu *sets_menu = new wxMenu; @@ -539,6 +608,18 @@ OPJFrame::OPJFrame(wxWindow *parent, const wxWindowID id, const wxString& title, wxDefaultSize); wxBitmap bmpNextframe = wxArtProvider::GetBitmap(wxART_GO_FORWARD, wxART_TOOLBAR, wxDefaultSize); + wxBitmap bmpLesslayers = bmpPrevframe; + wxBitmap bmpAlllayers = wxArtProvider::GetBitmap(wxART_GO_TO_PARENT, wxART_TOOLBAR, + wxDefaultSize); + wxBitmap bmpMorelayers = bmpNextframe; + wxBitmap bmpLessres = bmpPrevframe; + wxBitmap bmpFullres = wxArtProvider::GetBitmap(wxART_GO_TO_PARENT, wxART_TOOLBAR, + wxDefaultSize); + wxBitmap bmpMoreres = bmpNextframe; + wxBitmap bmpPrevcomp = bmpPrevframe; + wxBitmap bmpAllcomps = wxArtProvider::GetBitmap(wxART_GO_TO_PARENT, wxART_TOOLBAR, + wxDefaultSize); + wxBitmap bmpNextcomp = bmpNextframe; tool_bar->AddTool(OPJFRAME_FILEOPEN, bmpOpen, wxT("Open")); tool_bar->AddTool(OPJFRAME_FILESAVEAS, bmpSaveAs, wxT("Save as ")); @@ -554,6 +635,18 @@ OPJFrame::OPJFrame(wxWindow *parent, const wxWindowID id, const wxString& title, tool_bar->AddTool(OPJFRAME_VIEWPREVFRAME, bmpPrevframe, wxT("Previous frame")); tool_bar->AddTool(OPJFRAME_VIEWHOMEFRAME, bmpHomeframe, wxT("Starting frame")); tool_bar->AddTool(OPJFRAME_VIEWNEXTFRAME, bmpNextframe, wxT("Next frame")); + tool_bar->AddSeparator(); + tool_bar->AddTool(OPJFRAME_VIEWLESSLAYERS, bmpLesslayers, wxT("Remove a layer")); + tool_bar->AddTool(OPJFRAME_VIEWALLLAYERS, bmpAlllayers, wxT("Show all layers")); + tool_bar->AddTool(OPJFRAME_VIEWMORELAYERS, bmpMorelayers, wxT("Add a layer")); + tool_bar->AddSeparator(); + tool_bar->AddTool(OPJFRAME_VIEWLESSRES, bmpLessres, wxT("Reduce the resolution")); + tool_bar->AddTool(OPJFRAME_VIEWFULLRES, bmpFullres, wxT("Full resolution")); + tool_bar->AddTool(OPJFRAME_VIEWMORERES, bmpMoreres, wxT("Increase the resolution")); + tool_bar->AddSeparator(); + tool_bar->AddTool(OPJFRAME_VIEWPREVCOMP, bmpPrevcomp, wxT("Previous component")); + tool_bar->AddTool(OPJFRAME_VIEWALLCOMPS, bmpAllcomps, wxT("All components")); + tool_bar->AddTool(OPJFRAME_VIEWNEXTCOMP, bmpNextcomp, wxT("Next component")); tool_bar->Realize(); // associate the toolbar with the frame @@ -702,14 +795,23 @@ void OPJFrame::OnSetsEnco(wxCommandEvent& event) wxGetApp().m_origin = dialog.m_originCtrl->GetValue(); wxGetApp().m_rates = dialog.m_rateCtrl->GetValue(); wxGetApp().m_quality = dialog.m_qualityCtrl->GetValue(); + wxGetApp().m_enablequality = dialog.m_qualityRadio->GetValue(); + wxGetApp().m_multicomp = dialog.m_mctCheck->GetValue(); wxGetApp().m_irreversible = dialog.m_irrevCheck->GetValue(); wxGetApp().m_resolutions = dialog.m_resolutionsCtrl->GetValue(); wxGetApp().m_cbsize = dialog.m_cbsizeCtrl->GetValue(); wxGetApp().m_prsize = dialog.m_prsizeCtrl->GetValue(); wxGetApp().m_tsize = dialog.m_tsizeCtrl->GetValue(); wxGetApp().m_torigin = dialog.m_toriginCtrl->GetValue(); + wxGetApp().m_progression = dialog.progressionBox->GetSelection(); wxGetApp().m_enablesop = dialog.m_sopCheck->GetValue(); wxGetApp().m_enableeph = dialog.m_ephCheck->GetValue(); + wxGetApp().m_enablebypass = dialog.m_enablebypassCheck->GetValue(); + wxGetApp().m_enablereset = dialog.m_enableresetCheck->GetValue(); + wxGetApp().m_enablerestart = dialog.m_enablerestartCheck->GetValue(); + wxGetApp().m_enablevsc = dialog.m_enablevscCheck->GetValue(); + wxGetApp().m_enableerterm = dialog.m_enableertermCheck->GetValue(); + wxGetApp().m_enablesegmark = dialog.m_enablesegmarkCheck->GetValue(); wxGetApp().m_enableidx = dialog.m_enableidxCheck->GetValue(); wxGetApp().m_index = dialog.m_indexCtrl->GetValue(); wxGetApp().m_enablecomm = dialog.m_enablecommCheck->GetValue(); @@ -850,7 +952,6 @@ void OPJFrame::OnPrevFrame(wxCommandEvent& event) if (--wxGetApp().m_framenum < 0) wxGetApp().m_framenum = 0; - //wxLogMessage(wxT("================Go prev, dude!=======================")); wxCommandEvent e; OnReload(e); } @@ -859,8 +960,6 @@ void OPJFrame::OnHomeFrame(wxCommandEvent& event) { wxGetApp().m_framenum = 0; - //wxLogMessage(wxT("================Go home, dude!=======================")); - wxCommandEvent e; OnReload(e); } @@ -869,7 +968,81 @@ void OPJFrame::OnNextFrame(wxCommandEvent& event) { ++wxGetApp().m_framenum; - //wxLogMessage(wxT("================Go next, dude!=======================")); + wxCommandEvent e; + OnReload(e); +} + +void OPJFrame::OnLessLayers(wxCommandEvent& event) +{ + if (--wxGetApp().m_qualitylayers < 1) + wxGetApp().m_qualitylayers = 1; + + wxCommandEvent e; + OnReload(e); +} + +void OPJFrame::OnAllLayers(wxCommandEvent& event) +{ + wxGetApp().m_qualitylayers = 0; + + wxCommandEvent e; + OnReload(e); +} + +void OPJFrame::OnMoreLayers(wxCommandEvent& event) +{ + ++wxGetApp().m_qualitylayers; + + wxCommandEvent e; + OnReload(e); +} + +void OPJFrame::OnLessRes(wxCommandEvent& event) +{ + ++wxGetApp().m_reducefactor; + + wxCommandEvent e; + OnReload(e); +} + +void OPJFrame::OnFullRes(wxCommandEvent& event) +{ + wxGetApp().m_reducefactor = 0; + + wxCommandEvent e; + OnReload(e); +} + +void OPJFrame::OnMoreRes(wxCommandEvent& event) +{ + if (--wxGetApp().m_reducefactor < 0) + wxGetApp().m_reducefactor = 0; + + wxCommandEvent e; + OnReload(e); +} + +void OPJFrame::OnPrevComp(wxCommandEvent& event) +{ + if (--wxGetApp().m_components < 1) + wxGetApp().m_components = 1; + + wxCommandEvent e; + OnReload(e); +} + +void OPJFrame::OnAllComps(wxCommandEvent& event) +{ + wxGetApp().m_components = 0; + + wxCommandEvent e; + OnReload(e); +} + +void OPJFrame::OnNextComp(wxCommandEvent& event) +{ + ++wxGetApp().m_components; + wxCommandEvent e; OnReload(e); } @@ -1860,7 +2033,7 @@ void OPJMarkerTree::OnSelChanged(wxTreeEvent& event) (buffer[pre_pos] == 0x0D) || (buffer[pre_pos] == 0x0B)) buffer[pre_pos] = ' '; - text << wxString::Format(wxT("%c."), wxChar(buffer[pre_pos])); + text << wxString::FromAscii((char) buffer[pre_pos]) << wxT("."); } else text << wxT(" "); pre_pos++; @@ -2321,14 +2494,23 @@ void *OPJEncoThread::Entry() j2kkkhandler->m_origin = wxGetApp().m_origin; j2kkkhandler->m_rates = wxGetApp().m_rates; j2kkkhandler->m_quality = wxGetApp().m_quality; + j2kkkhandler->m_enablequality = wxGetApp().m_enablequality; + j2kkkhandler->m_multicomp = wxGetApp().m_multicomp; j2kkkhandler->m_irreversible = wxGetApp().m_irreversible; j2kkkhandler->m_resolutions = wxGetApp().m_resolutions; + j2kkkhandler->m_progression = wxGetApp().m_progression; j2kkkhandler->m_cbsize = wxGetApp().m_cbsize; j2kkkhandler->m_prsize = wxGetApp().m_prsize; j2kkkhandler->m_tsize = wxGetApp().m_tsize; j2kkkhandler->m_torigin = wxGetApp().m_torigin; j2kkkhandler->m_enablesop = wxGetApp().m_enablesop; j2kkkhandler->m_enableeph = wxGetApp().m_enableeph; + j2kkkhandler->m_enablebypass = wxGetApp().m_enablebypass; + j2kkkhandler->m_enablerestart = wxGetApp().m_enablerestart; + j2kkkhandler->m_enablereset = wxGetApp().m_enablereset; + j2kkkhandler->m_enablesegmark = wxGetApp().m_enablesegmark; + j2kkkhandler->m_enableerterm = wxGetApp().m_enableerterm; + j2kkkhandler->m_enablevsc = wxGetApp().m_enablevsc; j2kkkhandler->m_enableidx = wxGetApp().m_enableidx; j2kkkhandler->m_index = m_canvas->m_savename.GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR) + wxGetApp().m_index; j2kkkhandler->m_enablecomm = wxGetApp().m_enablecomm; @@ -2586,1014 +2768,3 @@ void *OPJParseThread::Entry() -// ---------------------------------------------------------------------------- -// OPJDecoderDialog -// ---------------------------------------------------------------------------- - -IMPLEMENT_CLASS(OPJDecoderDialog, wxPropertySheetDialog) - -BEGIN_EVENT_TABLE(OPJDecoderDialog, wxPropertySheetDialog) -#ifdef USE_JPWL - EVT_CHECKBOX(OPJDECO_ENABLEDECO, OPJDecoderDialog::OnEnableDeco) - EVT_CHECKBOX(OPJDECO_ENABLEJPWL, OPJDecoderDialog::OnEnableJPWL) -#endif // USE_JPWL -END_EVENT_TABLE() - -OPJDecoderDialog::OPJDecoderDialog(wxWindow* win, int dialogType) -{ - SetExtraStyle(wxDIALOG_EX_CONTEXTHELP|wxWS_EX_VALIDATE_RECURSIVELY); - - Create(win, wxID_ANY, wxT("Decoder settings"), - wxDefaultPosition, wxDefaultSize, - wxDEFAULT_DIALOG_STYLE| (int) wxPlatform::IfNot(wxOS_WINDOWS_CE, wxRESIZE_BORDER) - ); - - CreateButtons(wxOK | wxCANCEL | (int)wxPlatform::IfNot(wxOS_WINDOWS_CE, wxHELP)); - - m_settingsNotebook = GetBookCtrl(); - - wxPanel* mainSettings = CreateMainSettingsPage(m_settingsNotebook); - wxPanel* jpeg2000Settings = CreatePart1SettingsPage(m_settingsNotebook); - if (!wxGetApp().m_enabledeco) - jpeg2000Settings->Enable(false); - wxPanel* mjpeg2000Settings = CreatePart3SettingsPage(m_settingsNotebook); - if (!wxGetApp().m_enabledeco) - mjpeg2000Settings->Enable(false); -#ifdef USE_JPWL - wxPanel* jpwlSettings = CreatePart11SettingsPage(m_settingsNotebook); - if (!wxGetApp().m_enabledeco) - jpwlSettings->Enable(false); -#endif // USE_JPWL - - m_settingsNotebook->AddPage(mainSettings, wxT("Display"), false); - m_settingsNotebook->AddPage(jpeg2000Settings, wxT("JPEG 2000"), false); - m_settingsNotebook->AddPage(mjpeg2000Settings, wxT("MJPEG 2000"), false); -#ifdef USE_JPWL - m_settingsNotebook->AddPage(jpwlSettings, wxT("JPWL"), false); -#endif // USE_JPWL - - LayoutDialog(); -} - -OPJDecoderDialog::~OPJDecoderDialog() -{ -} - -wxPanel* OPJDecoderDialog::CreateMainSettingsPage(wxWindow* parent) -{ - wxPanel* panel = new wxPanel(parent, wxID_ANY); - - // top sizer - wxBoxSizer *topSizer = new wxBoxSizer(wxVERTICAL); - - // sub top sizer - wxBoxSizer *subtopSizer = new wxBoxSizer(wxVERTICAL); - - // add decoding enabling check box - subtopSizer->Add( - m_enabledecoCheck = new wxCheckBox(panel, OPJDECO_ENABLEDECO, wxT("Enable decoding"), wxDefaultPosition, wxDefaultSize), - 0, wxGROW | wxALL, 5); - m_enabledecoCheck->SetValue(wxGetApp().m_enabledeco); - - // add parsing enabling check box - subtopSizer->Add( - m_enableparseCheck = new wxCheckBox(panel, OPJDECO_ENABLEPARSE, wxT("Enable parsing"), wxDefaultPosition, wxDefaultSize), - 0, wxGROW | wxALL, 5); - m_enableparseCheck->SetValue(wxGetApp().m_enableparse); - - // resize settings, column - wxString choices[] = {wxT("Don't resize"), wxT("Low quality"), wxT("High quality")}; - m_resizeBox = new wxRadioBox(panel, OPJDECO_RESMETHOD, - wxT("Resize method"), - wxDefaultPosition, wxDefaultSize, - WXSIZEOF(choices), - choices, - 1, - wxRA_SPECIFY_ROWS); - m_resizeBox->SetSelection(wxGetApp().m_resizemethod + 1); - - subtopSizer->Add(m_resizeBox, 0, wxGROW | wxALL, 5); - - topSizer->Add(subtopSizer, 1, wxGROW | wxALIGN_CENTRE | wxALL, 5); - - // assign top and fit it - panel->SetSizer(topSizer); - topSizer->Fit(panel); - - return panel; -} - -wxPanel* OPJDecoderDialog::CreatePart3SettingsPage(wxWindow* parent) -{ - wxPanel* panel = new wxPanel(parent, wxID_ANY); - - // top sizer - wxBoxSizer *topSizer = new wxBoxSizer(wxVERTICAL); - - // add some space - //topSizer->AddSpacer(5); - - // sub top sizer - wxBoxSizer *subtopSizer = new wxBoxSizer(wxVERTICAL); - - // frame settings, column - wxStaticBox* frameBox = new wxStaticBox(panel, wxID_ANY, wxT("Frame")); - wxBoxSizer* frameSizer = new wxStaticBoxSizer(frameBox, wxVERTICAL); - - // selected frame number, row - wxBoxSizer* framenumSizer = new wxBoxSizer(wxHORIZONTAL); - - // add some text - framenumSizer->Add(new wxStaticText(panel, wxID_ANY, wxT("&Displayed frame:")), - 0, wxALL | wxALIGN_CENTER_VERTICAL, 5); - - // add some horizontal space - framenumSizer->Add(5, 5, 1, wxALL, 0); - - // add the value control - framenumSizer->Add( - m_framenumCtrl = new wxSpinCtrl(panel, OPJDECO_FRAMENUM, - wxString::Format(wxT("%d"), wxGetApp().m_framenum), - wxDefaultPosition, wxSize(80, wxDefaultCoord), - wxSP_ARROW_KEYS, - 1, 100000, wxGetApp().m_framenum), - 0, wxALL | wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL, 5); - - frameSizer->Add(framenumSizer, 0, wxGROW | wxALL, 5); - - subtopSizer->Add(frameSizer, 0, wxGROW | wxALL, 5); - - topSizer->Add(subtopSizer, 1, wxGROW | wxALIGN_CENTRE | wxALL, 5); - - // assign top and fit it - panel->SetSizer(topSizer); - topSizer->Fit(panel); - - return panel; -} - -wxPanel* OPJDecoderDialog::CreatePart1SettingsPage(wxWindow* parent) -{ - wxPanel* panel = new wxPanel(parent, wxID_ANY); - - // top sizer - wxBoxSizer *topSizer = new wxBoxSizer(wxVERTICAL); - - // add some space - //topSizer->AddSpacer(5); - - // sub top sizer - wxBoxSizer *subtopSizer = new wxBoxSizer(wxVERTICAL); - - // resolutions settings, column - wxStaticBox* resolutionBox = new wxStaticBox(panel, wxID_ANY, wxT("Resolutions")); - wxBoxSizer* resolutionSizer = new wxStaticBoxSizer(resolutionBox, wxVERTICAL); - - // reduce factor sizer, row - wxBoxSizer* reduceSizer = new wxBoxSizer(wxHORIZONTAL); - - // add some text - reduceSizer->Add(new wxStaticText(panel, wxID_ANY, wxT("&Reduce factor:")), - 0, wxALL | wxALIGN_CENTER_VERTICAL, 5); - - // add some horizontal space - reduceSizer->Add(5, 5, 1, wxALL, 0); - - // add the value control - reduceSizer->Add( - m_reduceCtrl = new wxSpinCtrl(panel, OPJDECO_REDUCEFACTOR, - wxString::Format(wxT("%d"), wxGetApp().m_reducefactor), - wxDefaultPosition, wxSize(80, wxDefaultCoord), - wxSP_ARROW_KEYS, - 0, 10000, wxGetApp().m_reducefactor), - 0, wxALL | wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL, 5); - - resolutionSizer->Add(reduceSizer, 0, wxGROW | wxALL, 5); - - subtopSizer->Add(resolutionSizer, 0, wxGROW | wxALL, 5); - - // quality layer settings, column - wxStaticBox* layerBox = new wxStaticBox(panel, wxID_ANY, wxT("Layers")); - wxBoxSizer* layerSizer = new wxStaticBoxSizer(layerBox, wxVERTICAL); - - // quality layers sizer, row - wxBoxSizer* qualitySizer = new wxBoxSizer(wxHORIZONTAL); - - // add some text - qualitySizer->Add(new wxStaticText(panel, wxID_ANY, wxT("&Quality layers:")), - 0, wxALL | wxALIGN_CENTER_VERTICAL, 5); - - // add some horizontal space - qualitySizer->Add(5, 5, 1, wxALL, 0); - - // add the value control - qualitySizer->Add( - m_layerCtrl = new wxSpinCtrl(panel, OPJDECO_QUALITYLAYERS, - wxString::Format(wxT("%d"), wxGetApp().m_qualitylayers), - wxDefaultPosition, wxSize(80, wxDefaultCoord), - wxSP_ARROW_KEYS, - 0, 100000, wxGetApp().m_qualitylayers), - 0, wxALL | wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL, 5); - - layerSizer->Add(qualitySizer, 0, wxGROW | wxALL, 5); - - subtopSizer->Add(layerSizer, 0, wxGROW | wxALL, 5); - - // component settings, column - wxStaticBox* compoBox = new wxStaticBox(panel, wxID_ANY, wxT("Components")); - wxBoxSizer* compoSizer = new wxStaticBoxSizer(compoBox, wxVERTICAL); - - // quality layers sizer, row - wxBoxSizer* numcompsSizer = new wxBoxSizer(wxHORIZONTAL); - - // add some text - numcompsSizer->Add(new wxStaticText(panel, wxID_ANY, wxT("&Component displayed:")), - 0, wxALL | wxALIGN_CENTER_VERTICAL, 5); - - // add some horizontal space - numcompsSizer->Add(5, 5, 1, wxALL, 0); - - // add the value control - numcompsSizer->Add( - m_numcompsCtrl = new wxSpinCtrl(panel, OPJDECO_NUMCOMPS, - wxString::Format(wxT("%d"), wxGetApp().m_components), - wxDefaultPosition, wxSize(80, wxDefaultCoord), - wxSP_ARROW_KEYS, - 0, 100000, wxGetApp().m_components), - 0, wxALL | wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL, 5); - m_numcompsCtrl->Enable(true); - - compoSizer->Add(numcompsSizer, 0, wxGROW | wxALL, 5); - - subtopSizer->Add(compoSizer, 0, wxGROW | wxALL, 5); - - topSizer->Add(subtopSizer, 1, wxGROW | wxALIGN_CENTRE | wxALL, 5); - - // assign top and fit it - panel->SetSizer(topSizer); - topSizer->Fit(panel); - - return panel; -} - -#ifdef USE_JPWL -wxPanel* OPJDecoderDialog::CreatePart11SettingsPage(wxWindow* parent) -{ - wxPanel* panel = new wxPanel(parent, wxID_ANY); - - // top sizer - wxBoxSizer *topSizer = new wxBoxSizer(wxVERTICAL); - - // add some space - //topSizer->AddSpacer(5); - - // sub top sizer - wxBoxSizer *subtopSizer = new wxBoxSizer(wxVERTICAL); - - // add JPWL enabling check box - subtopSizer->Add( - m_enablejpwlCheck = new wxCheckBox(panel, OPJDECO_ENABLEJPWL, wxT("Enable JPWL"), wxDefaultPosition, wxDefaultSize), - 0, wxGROW | wxALL, 5); - m_enablejpwlCheck->SetValue(wxGetApp().m_enablejpwl); - - // component settings, column - wxStaticBox* compoBox = new wxStaticBox(panel, wxID_ANY, wxT("Components")); - wxBoxSizer* compoSizer = new wxStaticBoxSizer(compoBox, wxVERTICAL); - - // expected components sizer, row - wxBoxSizer* expcompsSizer = new wxBoxSizer(wxHORIZONTAL); - - // add some text - expcompsSizer->Add(new wxStaticText(panel, wxID_ANY, wxT("&Expected comps.:")), - 0, wxALL | wxALIGN_CENTER_VERTICAL, 5); - - // add some horizontal space - expcompsSizer->Add(5, 5, 1, wxALL, 0); - - // add the value control - expcompsSizer->Add( - m_expcompsCtrl = new wxSpinCtrl(panel, OPJDECO_EXPCOMPS, - wxString::Format(wxT("%d"), wxGetApp().m_expcomps), - wxDefaultPosition, wxSize(80, wxDefaultCoord), - wxSP_ARROW_KEYS, - 1, 100000, wxGetApp().m_expcomps), - 0, wxALL | wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL, 5); - m_expcompsCtrl->Enable(wxGetApp().m_enablejpwl); - - compoSizer->Add(expcompsSizer, 0, wxGROW | wxALL, 5); - - subtopSizer->Add(compoSizer, 0, wxGROW | wxALL, 5); - - // tiles settings, column - wxStaticBox* tileBox = new wxStaticBox(panel, wxID_ANY, wxT("Tiles")); - wxBoxSizer* tileSizer = new wxStaticBoxSizer(tileBox, wxVERTICAL); - - // maximum tiles sizer, row - wxBoxSizer* maxtileSizer = new wxBoxSizer(wxHORIZONTAL); - - // add some text - maxtileSizer->Add(new wxStaticText(panel, wxID_ANY, wxT("&Max. no. of tiles:")), - 0, wxALL | wxALIGN_CENTER_VERTICAL, 5); - - // add some horizontal space - maxtileSizer->Add(5, 5, 1, wxALL, 0); - - // add the value control - maxtileSizer->Add( - m_maxtilesCtrl = new wxSpinCtrl(panel, OPJDECO_MAXTILES, - wxString::Format(wxT("%d"), wxGetApp().m_maxtiles), - wxDefaultPosition, wxSize(80, wxDefaultCoord), - wxSP_ARROW_KEYS, - 1, 100000, wxGetApp().m_maxtiles), - 0, wxALL | wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL, 5); - m_maxtilesCtrl->Enable(wxGetApp().m_enablejpwl); - - tileSizer->Add(maxtileSizer, 0, wxGROW | wxALL, 5); - - subtopSizer->Add(tileSizer, 0, wxGROW | wxALL, 5); - - topSizer->Add(subtopSizer, 1, wxGROW | wxALIGN_CENTRE | wxALL, 5); - - // assign top and fit it - panel->SetSizer(topSizer); - topSizer->Fit(panel); - - return panel; -} - -void OPJDecoderDialog::OnEnableDeco(wxCommandEvent& event) -{ - size_t pp; - - if (event.IsChecked()) { - wxLogMessage(wxT("Decoding enabled")); - m_resizeBox->Enable(true); - // enable all tabs except ourselves - for (pp = 0; pp < m_settingsNotebook->GetPageCount(); pp++) { - if (m_settingsNotebook->GetPageText(pp) != wxT("Display")) - m_settingsNotebook->GetPage(pp)->Enable(true); - } - } else { - wxLogMessage(wxT("Decoding disabled")); - m_resizeBox->Enable(false); - // disable all tabs except ourselves - for (pp = 0; pp < m_settingsNotebook->GetPageCount(); pp++) { - if (m_settingsNotebook->GetPageText(pp) != wxT("Display")) - m_settingsNotebook->GetPage(pp)->Enable(false); - } - } - -} - -void OPJDecoderDialog::OnEnableJPWL(wxCommandEvent& event) -{ - if (event.IsChecked()) { - wxLogMessage(wxT("JPWL enabled")); - m_expcompsCtrl->Enable(true); - m_maxtilesCtrl->Enable(true); - } else { - wxLogMessage(wxT("JPWL disabled")); - m_expcompsCtrl->Enable(false); - m_maxtilesCtrl->Enable(false); - } - -} - -#endif // USE_JPWL - -bool OPJDnDFile::OnDropFiles(wxCoord, wxCoord, const wxArrayString& filenames) -{ - /*size_t nFiles = filenames.GetCount(); - wxString str; - str.Printf( _T("%d files dropped\n"), (int)nFiles); - for ( size_t n = 0; n < nFiles; n++ ) { - str << filenames[n] << wxT("\n"); - } - wxLogMessage(str);*/ - m_pOwner->OpenFiles(filenames, filenames); - - return true; -} - - - - - -// ---------------------------------------------------------------------------- -// OPJEncoderDialog -// ---------------------------------------------------------------------------- - -IMPLEMENT_CLASS(OPJEncoderDialog, wxPropertySheetDialog) - -BEGIN_EVENT_TABLE(OPJEncoderDialog, wxPropertySheetDialog) -#ifdef USE_JPWL - EVT_CHECKBOX(OPJENCO_ENABLEJPWL, OPJEncoderDialog::OnEnableJPWL) - EVT_CHECKBOX(OPJENCO_ENABLECOMM, OPJEncoderDialog::OnEnableComm) - EVT_CHECKBOX(OPJENCO_ENABLEINDEX, OPJEncoderDialog::OnEnableIdx) -#endif // USE_JPWL -END_EVENT_TABLE() - -OPJEncoderDialog::OPJEncoderDialog(wxWindow* win, int dialogType) -{ - SetExtraStyle(wxDIALOG_EX_CONTEXTHELP|wxWS_EX_VALIDATE_RECURSIVELY); - - Create(win, wxID_ANY, wxT("Encoder settings"), - wxDefaultPosition, wxDefaultSize, - wxDEFAULT_DIALOG_STYLE| (int) wxPlatform::IfNot(wxOS_WINDOWS_CE, wxRESIZE_BORDER) - ); - - CreateButtons(wxOK | wxCANCEL | (int)wxPlatform::IfNot(wxOS_WINDOWS_CE, wxHELP)); - - m_settingsNotebook = GetBookCtrl(); - - wxPanel* jpeg2000_1Settings = CreatePart1_1SettingsPage(m_settingsNotebook); - wxPanel* jpeg2000_2Settings = CreatePart1_2SettingsPage(m_settingsNotebook); - wxPanel* mainSettings = CreateMainSettingsPage(m_settingsNotebook); -#ifdef USE_JPWL - wxPanel* jpwlSettings = CreatePart11SettingsPage(m_settingsNotebook); -#endif // USE_JPWL - - m_settingsNotebook->AddPage(jpeg2000_1Settings, wxT("JPEG 2000 - 1"), false); - m_settingsNotebook->AddPage(jpeg2000_2Settings, wxT("JPEG 2000 - 2"), false); - m_settingsNotebook->AddPage(mainSettings, wxT("General"), false); -#ifdef USE_JPWL - m_settingsNotebook->AddPage(jpwlSettings, wxT("JPWL"), false); -#endif // USE_JPWL - - LayoutDialog(); -} - -OPJEncoderDialog::~OPJEncoderDialog() -{ -} - -wxPanel* OPJEncoderDialog::CreateMainSettingsPage(wxWindow* parent) -{ - wxPanel* panel = new wxPanel(parent, wxID_ANY); - - // top sizer - wxBoxSizer *topSizer = new wxBoxSizer(wxVERTICAL); - - // sub top sizer - wxBoxSizer *subtopSizer = new wxBoxSizer(wxVERTICAL); - - topSizer->Add(subtopSizer, 1, wxGROW | wxALIGN_CENTRE | wxALL, 5); - - // assign top and fit it - panel->SetSizer(topSizer); - topSizer->Fit(panel); - - return panel; -} - -#ifdef USE_JPWL -wxPanel* OPJEncoderDialog::CreatePart11SettingsPage(wxWindow* parent) -{ - wxPanel* panel = new wxPanel(parent, wxID_ANY); - - // top sizer - wxBoxSizer *topSizer = new wxBoxSizer(wxVERTICAL); - - // sub top sizer - wxBoxSizer *subtopSizer = new wxBoxSizer(wxVERTICAL); - - topSizer->Add(subtopSizer, 1, wxGROW | wxALIGN_CENTRE | wxALL, 5); - - // assign top and fit it - panel->SetSizer(topSizer); - topSizer->Fit(panel); - - return panel; -} -#endif // USE_JPWL - -wxPanel* OPJEncoderDialog::CreatePart1_1SettingsPage(wxWindow* parent) -{ - wxPanel* panel = new wxPanel(parent, wxID_ANY); - - // top sizer - wxBoxSizer *topSizer = new wxBoxSizer(wxVERTICAL); - - // add some space - //topSizer->AddSpacer(5); - - // sub top sizer - wxFlexGridSizer *subtopSizer = new wxFlexGridSizer(2, 3, 3); - - // image settings, column - wxStaticBox* imageBox = new wxStaticBox(panel, wxID_ANY, wxT("Image")); - wxBoxSizer* imageSizer = new wxStaticBoxSizer(imageBox, wxVERTICAL); - - // subsampling factor sizer, row - wxBoxSizer* subsSizer = new wxBoxSizer(wxHORIZONTAL); - - // add some text - subsSizer->Add(new wxStaticText(panel, wxID_ANY, wxT("&Subsampling:")), - 0, wxALL | wxALIGN_CENTER_VERTICAL, 3); - - // add some horizontal space - subsSizer->Add(3, 3, 1, wxALL, 0); - - // add the value control - subsSizer->Add( - m_subsamplingCtrl = new wxTextCtrl(panel, OPJENCO_SUBSAMPLING, - wxGetApp().m_subsampling, - wxDefaultPosition, wxSize(120, wxDefaultCoord), - wxTE_LEFT), - 0, wxALL | wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL, 3); - - imageSizer->Add(subsSizer, 0, wxGROW | wxALL, 3); - - // origin sizer, row - wxBoxSizer* imorigSizer = new wxBoxSizer(wxHORIZONTAL); - - // add some text - imorigSizer->Add(new wxStaticText(panel, wxID_ANY, wxT("&Origin:")), - 0, wxALL | wxALIGN_CENTER_VERTICAL, 3); - - // add some horizontal space - imorigSizer->Add(3, 3, 1, wxALL, 0); - - // add the value control - imorigSizer->Add( - m_originCtrl = new wxTextCtrl(panel, OPJENCO_IMORIG, - wxGetApp().m_origin, - wxDefaultPosition, wxSize(120, wxDefaultCoord), - wxTE_LEFT), - 0, wxALL | wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL, 3); - - imageSizer->Add(imorigSizer, 0, wxGROW | wxALL, 3); - - subtopSizer->Add(imageSizer, 0, wxGROW | wxALL, 3); - - // layer settings, column - wxStaticBox* layerBox = new wxStaticBox(panel, wxID_ANY, wxT("Layers/compression")); - wxBoxSizer* layerSizer = new wxStaticBoxSizer(layerBox, wxVERTICAL); - - // rate factor sizer, row - wxBoxSizer* rateSizer = new wxBoxSizer(wxHORIZONTAL); - - // add some text - rateSizer->Add(new wxStaticText(panel, wxID_ANY, wxT("&Rate values:")), - 0, wxALL | wxALIGN_CENTER_VERTICAL, 3); - - // add some horizontal space - rateSizer->Add(3, 3, 1, wxALL, 0); - - // add the value control - rateSizer->Add( - m_rateCtrl = new wxTextCtrl(panel, OPJENCO_RATEFACTOR, - wxGetApp().m_rates, - wxDefaultPosition, wxSize(120, wxDefaultCoord), - wxTE_LEFT), - 0, wxALL | wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL, 3); - - layerSizer->Add(rateSizer, 0, wxGROW | wxALL, 3); - - // quality factor sizer, row - wxBoxSizer* qualitySizer = new wxBoxSizer(wxHORIZONTAL); - - // add some text - qualitySizer->Add(new wxStaticText(panel, wxID_ANY, wxT("&Quality values:")), - 0, wxALL | wxALIGN_CENTER_VERTICAL, 3); - - // add some horizontal space - qualitySizer->Add(3, 3, 1, wxALL, 0); - - // add the value control - qualitySizer->Add( - m_qualityCtrl = new wxTextCtrl(panel, OPJENCO_QUALITYFACTOR, - wxGetApp().m_quality, - wxDefaultPosition, wxSize(120, wxDefaultCoord), - wxTE_LEFT), - 0, wxALL | wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL, 3); - - layerSizer->Add(qualitySizer, 0, wxGROW | wxALL, 3); - - subtopSizer->Add(layerSizer, 0, wxGROW | wxALL, 3); - - // wavelet settings, column - wxStaticBox* waveletBox = new wxStaticBox(panel, wxID_ANY, wxT("Wavelet transform")); - wxBoxSizer* waveletSizer = new wxStaticBoxSizer(waveletBox, wxVERTICAL); - - // irreversible check box - waveletSizer->Add( - m_irrevCheck = new wxCheckBox(panel, OPJENCO_ENABLEIRREV, wxT("Irreversible"), - wxDefaultPosition, wxDefaultSize), - 0, wxGROW | wxALL, 3); - m_irrevCheck->SetValue(wxGetApp().m_irreversible); - - // resolution number sizer, row - wxBoxSizer* resnumSizer = new wxBoxSizer(wxHORIZONTAL); - - // add some text - resnumSizer->Add(new wxStaticText(panel, wxID_ANY, wxT("&Resolutions:")), - 0, wxALL | wxALIGN_CENTER_VERTICAL, 3); - - // add some horizontal space - resnumSizer->Add(3, 3, 1, wxALL, 0); - - // add the value control - resnumSizer->Add( - m_resolutionsCtrl = new wxSpinCtrl(panel, OPJENCO_RESNUMBER, - wxString::Format(wxT("%d"), wxGetApp().m_resolutions), - wxDefaultPosition, wxSize(80, wxDefaultCoord), - wxSP_ARROW_KEYS, - 0, 256, 6), - 0, wxALL | wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL, 3); - - waveletSizer->Add(resnumSizer, 0, wxGROW | wxALL, 3); - - subtopSizer->Add(waveletSizer, 0, wxGROW | wxALL, 3); - - // codestream settings, column - wxStaticBox* codestreamBox = new wxStaticBox(panel, wxID_ANY, wxT("Codestream")); - wxBoxSizer* codestreamSizer = new wxStaticBoxSizer(codestreamBox, wxVERTICAL); - - // codeblock sizer, row - wxBoxSizer* codeblockSizer = new wxBoxSizer(wxHORIZONTAL); - - // add some text - codeblockSizer->Add(new wxStaticText(panel, wxID_ANY, wxT("&Codeblocks size:")), - 0, wxALL | wxALIGN_CENTER_VERTICAL, 3); - - // add some horizontal space - codeblockSizer->Add(3, 3, 1, wxALL, 0); - - // add the value control - codeblockSizer->Add( - m_cbsizeCtrl = new wxTextCtrl(panel, OPJENCO_CODEBLOCKSIZE, - wxGetApp().m_cbsize, - wxDefaultPosition, wxSize(120, wxDefaultCoord), - wxTE_LEFT), - 0, wxALL | wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL, 3); - - codestreamSizer->Add(codeblockSizer, 0, wxGROW | wxALL, 3); - - // precinct sizer, row - wxBoxSizer* precinctSizer = new wxBoxSizer(wxHORIZONTAL); - - // add some text - precinctSizer->Add(new wxStaticText(panel, wxID_ANY, wxT("&Precincts size:")), - 0, wxALL | wxALIGN_CENTER_VERTICAL, 3); - - // add some horizontal space - precinctSizer->Add(3, 3, 1, wxALL, 0); - - // add the value control - precinctSizer->Add( - m_prsizeCtrl = new wxTextCtrl(panel, OPJENCO_PRECINCTSIZE, - wxGetApp().m_prsize, - wxDefaultPosition, wxSize(120, wxDefaultCoord), - wxTE_LEFT), - 0, wxALL | wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL, 3); - - codestreamSizer->Add(precinctSizer, 0, wxGROW | wxALL, 3); - - subtopSizer->Add(codestreamSizer, 0, wxGROW | wxALL, 3); - - // tile settings, column - wxStaticBox* tileBox = new wxStaticBox(panel, wxID_ANY, wxT("Tiles")); - wxBoxSizer* tileSizer = new wxStaticBoxSizer(tileBox, wxVERTICAL); - - // tile size sizer, row - wxBoxSizer* tilesizeSizer = new wxBoxSizer(wxHORIZONTAL); - - // add some text - tilesizeSizer->Add(new wxStaticText(panel, wxID_ANY, wxT("&Size:")), - 0, wxALL | wxALIGN_CENTER_VERTICAL, 3); - - // add some horizontal space - tilesizeSizer->Add(3, 3, 1, wxALL, 0); - - // add the value control - tilesizeSizer->Add( - m_tsizeCtrl = new wxTextCtrl(panel, OPJENCO_TILESIZE, - wxGetApp().m_tsize, - wxDefaultPosition, wxSize(120, wxDefaultCoord), - wxTE_LEFT), - 0, wxALL | wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL, 3); - - tileSizer->Add(tilesizeSizer, 0, wxGROW | wxALL, 3); - - // tile origin sizer, row - wxBoxSizer* tilorigSizer = new wxBoxSizer(wxHORIZONTAL); - - // add some text - tilorigSizer->Add(new wxStaticText(panel, wxID_ANY, wxT("&Origin:")), - 0, wxALL | wxALIGN_CENTER_VERTICAL, 3); - - // add some horizontal space - tilorigSizer->Add(3, 3, 1, wxALL, 0); - - // add the value control - tilorigSizer->Add( - m_toriginCtrl = new wxTextCtrl(panel, OPJENCO_TILORIG, - wxGetApp().m_torigin, - wxDefaultPosition, wxSize(120, wxDefaultCoord), - wxTE_LEFT), - 0, wxALL | wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL, 3); - - tileSizer->Add(tilorigSizer, 0, wxGROW | wxALL, 3); - - subtopSizer->Add(tileSizer, 0, wxGROW | wxALL, 3); - - // progression and profile settings, column - wxString choices[] = {wxT("LRCP"), wxT("RLCP"), wxT("RPCL"), wxT("PCRL"), wxT("CPRL"), - wxT("DCI2K24"), wxT("DCI2K48"), wxT("DCI4K")}; - wxRadioBox *progressionBox = new wxRadioBox(panel, OPJENCO_PROGRESSION, - wxT("Progression order/profile"), - wxDefaultPosition, wxDefaultSize, - WXSIZEOF(choices), - choices, - 3, - wxRA_SPECIFY_COLS); - progressionBox->SetSelection(0); - - subtopSizer->Add(progressionBox, 0, wxGROW | wxALL, 3); - - topSizer->Add(subtopSizer, 1, wxGROW | wxALIGN_CENTRE | wxALL, 5); - - // assign top and fit it - panel->SetSizer(topSizer); - topSizer->Fit(panel); - - return panel; -} - -wxPanel* OPJEncoderDialog::CreatePart1_2SettingsPage(wxWindow* parent) -{ - wxPanel* panel = new wxPanel(parent, wxID_ANY); - - // top sizer - wxBoxSizer *topSizer = new wxBoxSizer(wxVERTICAL); - - // add some space - //topSizer->AddSpacer(5); - - // sub top sizer - wxFlexGridSizer *subtopSizer = new wxFlexGridSizer(2, 3, 3); - - // resilience settings, column - wxStaticBox* resilBox = new wxStaticBox(panel, wxID_ANY, wxT("Error resilience")); - wxBoxSizer* resilSizer = new wxStaticBoxSizer(resilBox, wxVERTICAL); - - // resil2 sizer, row - wxBoxSizer* resil2Sizer = new wxBoxSizer(wxHORIZONTAL); - - // SOP check box - resil2Sizer->Add( - m_sopCheck = new wxCheckBox(panel, OPJENCO_ENABLESOP, wxT("SOP"), - wxDefaultPosition, wxDefaultSize), - 0, wxGROW | wxALL, 3); - m_sopCheck->SetValue(wxGetApp().m_enablesop); - - // EPH check box - resil2Sizer->Add( - m_ephCheck = new wxCheckBox(panel, OPJENCO_ENABLEEPH, wxT("EPH"), - wxDefaultPosition, wxDefaultSize), - 0, wxGROW | wxALL, 3); - m_ephCheck->SetValue(wxGetApp().m_enableeph); - - resilSizer->Add(resil2Sizer, 0, wxGROW | wxALL, 3); - - // separation - resilSizer->Add(new wxStaticLine(panel, wxID_ANY), 0, wxEXPAND | wxLEFT | wxRIGHT, 3); - - // resil3 sizer, row - wxFlexGridSizer* resil3Sizer = new wxFlexGridSizer(3, 3, 3); - - // BYPASS check box - resil3Sizer->Add( - /*m_enabledecoCheck =*/ new wxCheckBox(panel, OPJENCO_ENABLEBYPASS, wxT("BYPASS"), - wxDefaultPosition, wxDefaultSize), - 0, wxGROW | wxALL, 3); - /*m_enabledecoCheck->SetValue(wxGetApp().m_enabledeco);*/ - - // RESET check box - resil3Sizer->Add( - /*m_enabledecoCheck =*/ new wxCheckBox(panel, OPJENCO_ENABLERESET, wxT("RESET"), - wxDefaultPosition, wxDefaultSize), - 0, wxGROW | wxALL, 3); - /*m_enabledecoCheck->SetValue(wxGetApp().m_enabledeco);*/ - - // RESTART check box - resil3Sizer->Add( - /*m_enabledecoCheck =*/ new wxCheckBox(panel, OPJENCO_ENABLERESTART, wxT("RESTART"), - wxDefaultPosition, wxDefaultSize), - 0, wxGROW | wxALL, 3); - /*m_enabledecoCheck->SetValue(wxGetApp().m_enabledeco);*/ - - // VSC check box - resil3Sizer->Add( - /*m_enabledecoCheck =*/ new wxCheckBox(panel, OPJENCO_ENABLEVSC, wxT("VSC"), - wxDefaultPosition, wxDefaultSize), - 0, wxGROW | wxALL, 3); - /*m_enabledecoCheck->SetValue(wxGetApp().m_enabledeco);*/ - - // ERTERM check box - resil3Sizer->Add( - /*m_enabledecoCheck =*/ new wxCheckBox(panel, OPJENCO_ENABLEERTERM, wxT("ERTERM"), - wxDefaultPosition, wxDefaultSize), - 0, wxGROW | wxALL, 3); - /*m_enabledecoCheck->SetValue(wxGetApp().m_enabledeco);*/ - - // SEGMARK check box - resil3Sizer->Add( - /*m_enabledecoCheck =*/ new wxCheckBox(panel, OPJENCO_ENABLESEGMARK, wxT("SEGMARK"), - wxDefaultPosition, wxDefaultSize), - 0, wxGROW | wxALL, 3); - /*m_enabledecoCheck->SetValue(wxGetApp().m_enabledeco);*/ - - resilSizer->Add(resil3Sizer, 0, wxGROW | wxALL, 3); - - subtopSizer->Add(resilSizer, 0, wxGROW | wxALL, 3); - - // ROI settings, column - wxStaticBox* roiBox = new wxStaticBox(panel, wxID_ANY, wxT("Region Of Interest")); - wxBoxSizer* roiSizer = new wxStaticBoxSizer(roiBox, wxVERTICAL); - - // component number sizer, row - wxBoxSizer* roicompSizer = new wxBoxSizer(wxHORIZONTAL); - - // add some text - roicompSizer->Add(new wxStaticText(panel, wxID_ANY, wxT("&Component:")), - 0, wxALL | wxALIGN_CENTER_VERTICAL, 3); - - // add some horizontal space - roicompSizer->Add(3, 3, 1, wxALL, 0); - - // add the value control - roicompSizer->Add( - /*m_layerCtrl =*/ new wxSpinCtrl(panel, OPJENCO_ROICOMP, - wxT("0"), - wxDefaultPosition, wxSize(80, wxDefaultCoord), - wxSP_ARROW_KEYS, - 0, 256, 0), - 0, wxALL | wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL, 3); - - roiSizer->Add(roicompSizer, 0, wxGROW | wxALL, 3); - - // upshift sizer, row - wxBoxSizer* roishiftSizer = new wxBoxSizer(wxHORIZONTAL); - - // add some text - roishiftSizer->Add(new wxStaticText(panel, wxID_ANY, wxT("&Upshift:")), - 0, wxALL | wxALIGN_CENTER_VERTICAL, 3); - - // add some horizontal space - roishiftSizer->Add(3, 3, 1, wxALL, 0); - - // add the value control - roishiftSizer->Add( - /*m_layerCtrl =*/ new wxSpinCtrl(panel, OPJENCO_ROISHIFT, - wxT("0"), - wxDefaultPosition, wxSize(80, wxDefaultCoord), - wxSP_ARROW_KEYS, - 0, 37, 0), - 0, wxALL | wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL, 3); - - roiSizer->Add(roishiftSizer, 0, wxGROW | wxALL, 3); - - subtopSizer->Add(roiSizer, 0, wxGROW | wxALL, 3); - - // Index file settings, column - wxStaticBox* indexBox = new wxStaticBox(panel, wxID_ANY, wxT("Indexing")); - wxBoxSizer* indexSizer = new wxStaticBoxSizer(indexBox, wxVERTICAL); - - // indexing check box - indexSizer->Add( - m_enableidxCheck = new wxCheckBox(panel, OPJENCO_ENABLEINDEX, wxT("Enabled"), - wxDefaultPosition, wxDefaultSize), - 0, wxGROW | wxALL, 3); - m_enableidxCheck->SetValue(wxGetApp().m_enableidx); - - // index file sizer, row - wxBoxSizer* indexnameSizer = new wxBoxSizer(wxHORIZONTAL); - - // add some text - indexnameSizer->Add(new wxStaticText(panel, wxID_ANY, wxT("&File name:")), - 0, wxALL | wxALIGN_CENTER_VERTICAL, 3); - - // add some horizontal space - indexnameSizer->Add(3, 3, 1, wxALL, 0); - - // add the value control - indexnameSizer->Add( - m_indexCtrl = new wxTextCtrl(panel, OPJENCO_INDEXNAME, - wxGetApp().m_index, - wxDefaultPosition, wxSize(120, wxDefaultCoord), - wxTE_LEFT), - 0, wxALL | wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL, 3); - m_indexCtrl->Enable(wxGetApp().m_enableidx); - - indexSizer->Add(indexnameSizer, 0, wxGROW | wxALL, 3); - - subtopSizer->Add(indexSizer, 0, wxGROW | wxALL, 3); - - // Comment settings, column - wxStaticBox* commentBox = new wxStaticBox(panel, wxID_ANY, wxT("Comment")); - wxBoxSizer* commentSizer = new wxStaticBoxSizer(commentBox, wxVERTICAL); - - // commenting check box - commentSizer->Add( - m_enablecommCheck = new wxCheckBox(panel, OPJENCO_ENABLECOMM, wxT("Enabled"), - wxDefaultPosition, wxDefaultSize), - 0, wxGROW | wxALL, 3); - m_enablecommCheck->SetValue(wxGetApp().m_enablecomm); - - // add some horizontal space - commentSizer->Add(3, 3, 1, wxALL, 0); - - // add the value control - commentSizer->Add( - m_commentCtrl = new wxTextCtrl(panel, OPJENCO_COMMENTTEXT, - wxGetApp().m_comment, - wxDefaultPosition, wxSize(wxDefaultCoord, 60), - wxTE_LEFT | wxTE_MULTILINE), - 0, wxGROW | wxALL | wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL, 3); - m_commentCtrl->Enable(wxGetApp().m_enablecomm); - - subtopSizer->Add(commentSizer, 0, wxGROW | wxALL, 3); - - // POC settings, column - wxStaticBox* pocBox = new wxStaticBox(panel, wxID_ANY, wxT("POC")); - wxBoxSizer* pocSizer = new wxStaticBoxSizer(pocBox, wxVERTICAL); - - // POC check box - pocSizer->Add( - m_enablepocCheck = new wxCheckBox(panel, OPJENCO_ENABLEPOC, wxT("Enabled"), - wxDefaultPosition, wxDefaultSize), - 0, wxGROW | wxALL, 3); - m_enablepocCheck->SetValue(/*wxGetApp().m_enableidx*/true); - - // POC sizer, row - wxBoxSizer* pocspecSizer = new wxBoxSizer(wxHORIZONTAL); - - // add some text - pocspecSizer->Add(new wxStaticText(panel, wxID_ANY, wxT("&Changes:")), - 0, wxALL | wxALIGN_CENTER_VERTICAL, 3); - - // add some horizontal space - pocspecSizer->Add(3, 3, 1, wxALL, 0); - - // add the value control - pocspecSizer->Add( - m_pocCtrl = new wxTextCtrl(panel, OPJENCO_POCSPEC, - /*wxGetApp().m_index*/wxT("RRRR"), - wxDefaultPosition, wxSize(120, wxDefaultCoord), - wxTE_LEFT), - 0, wxALL | wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL, 3); - m_pocCtrl->Enable(/*wxGetApp().m_enableidx*/true); - - pocSizer->Add(pocspecSizer, 0, wxGROW | wxALL, 3); - - subtopSizer->Add(pocSizer, 0, wxGROW | wxALL, 3); - - topSizer->Add(subtopSizer, 1, wxGROW | wxALIGN_CENTRE | wxALL, 5); - - // assign top and fit it - panel->SetSizer(topSizer); - topSizer->Fit(panel); - - return panel; -} - -void OPJEncoderDialog::OnEnableComm(wxCommandEvent& event) -{ - if (event.IsChecked()) { - wxLogMessage(wxT("Comment enabled")); - m_commentCtrl->Enable(true); - } else { - wxLogMessage(wxT("Comment disabled")); - m_commentCtrl->Enable(false); - } - -} - -void OPJEncoderDialog::OnEnableIdx(wxCommandEvent& event) -{ - if (event.IsChecked()) { - wxLogMessage(wxT("Index enabled")); - m_indexCtrl->Enable(true); - } else { - wxLogMessage(wxT("Index disabled")); - m_indexCtrl->Enable(false); - } -} - -#ifdef USE_JPWL -void OPJEncoderDialog::OnEnableJPWL(wxCommandEvent& event) -{ - /*if (event.IsChecked()) { - wxLogMessage(wxT("JPWL enabled")); - m_expcompsCtrl->Enable(true); - m_maxtilesCtrl->Enable(true); - } else { - wxLogMessage(wxT("JPWL disabled")); - m_expcompsCtrl->Enable(false); - m_maxtilesCtrl->Enable(false); - }*/ - -} -#endif // USE_JPWL diff --git a/OPJViewer/source/OPJViewer.h b/OPJViewer/source/OPJViewer.h index d861fac5..51b6badb 100644 --- a/OPJViewer/source/OPJViewer.h +++ b/OPJViewer/source/OPJViewer.h @@ -206,8 +206,11 @@ class OPJViewerApp: public wxApp // encoding engine parameters wxString m_subsampling, m_origin, m_rates, m_comment, m_index, m_quality; wxString m_cbsize, m_prsize, m_tsize, m_torigin; - bool m_enablecomm, m_enableidx, m_irreversible, m_enablesop, m_enableeph; - int m_resolutions; + bool m_enablecomm, m_enableidx, m_multicomp, m_irreversible, m_enablesop, m_enableeph; + bool m_enablebypass, m_enablereset, m_enablerestart, m_enablevsc, m_enableerterm; + bool m_enablesegmark; + bool m_enablequality; + int m_resolutions, m_progression; // some layout settings bool m_showtoolbar, m_showbrowser, m_showpeeker; @@ -404,6 +407,15 @@ class OPJFrame: public wxMDIParentFrame void OnPrevFrame(wxCommandEvent& event); void OnHomeFrame(wxCommandEvent& event); void OnNextFrame(wxCommandEvent& event); + void OnLessLayers(wxCommandEvent& event); + void OnAllLayers(wxCommandEvent& event); + void OnMoreLayers(wxCommandEvent& event); + void OnLessRes(wxCommandEvent& event); + void OnFullRes(wxCommandEvent& event); + void OnMoreRes(wxCommandEvent& event); + void OnPrevComp(wxCommandEvent& event); + void OnAllComps(wxCommandEvent& event); + void OnNextComp(wxCommandEvent& event); void OnSetsEnco(wxCommandEvent& event); void OnSetsDeco(wxCommandEvent& event); void OnSashDrag(wxSashEvent& event); @@ -475,6 +487,15 @@ enum { OPJFRAME_VIEWPREVFRAME, OPJFRAME_VIEWHOMEFRAME, OPJFRAME_VIEWNEXTFRAME, + OPJFRAME_VIEWLESSLAYERS, + OPJFRAME_VIEWALLLAYERS, + OPJFRAME_VIEWMORELAYERS, + OPJFRAME_VIEWLESSRES, + OPJFRAME_VIEWFULLRES, + OPJFRAME_VIEWMORERES, + OPJFRAME_VIEWPREVCOMP, + OPJFRAME_VIEWALLCOMPS, + OPJFRAME_VIEWNEXTCOMP, OPJFRAME_FILECLOSE, OPJFRAME_SETSENCO, OPJFRAME_SETSDECO, @@ -638,14 +659,19 @@ public: void OnEnableJPWL(wxCommandEvent& event); void OnEnableComm(wxCommandEvent& event); void OnEnableIdx(wxCommandEvent& event); + void OnRadioQualityRate(wxCommandEvent& event); wxPanel* CreatePart11SettingsPage(wxWindow* parent); /*wxCheckBox *m_enablejpwlCheck;*/ #endif // USE_JPWL wxTextCtrl *m_subsamplingCtrl, *m_originCtrl, *m_rateCtrl, *m_commentCtrl; + wxRadioButton *m_rateRadio, *m_qualityRadio; wxTextCtrl *m_indexCtrl, *m_qualityCtrl, *m_cbsizeCtrl, *m_prsizeCtrl, *m_pocCtrl; wxTextCtrl *m_tsizeCtrl, *m_toriginCtrl; - wxCheckBox *m_enablecommCheck, *m_enableidxCheck, *m_irrevCheck, *m_sopCheck, *m_ephCheck; + wxRadioBox *progressionBox; + wxCheckBox *m_enablecommCheck, *m_enableidxCheck, *m_mctCheck, *m_irrevCheck; + wxCheckBox *m_sopCheck, *m_ephCheck, *m_enablebypassCheck, *m_enableresetCheck, + *m_enablerestartCheck, *m_enablevscCheck, *m_enableertermCheck, *m_enablesegmarkCheck; wxCheckBox *m_enablepocCheck; wxSpinCtrl *m_resolutionsCtrl; @@ -654,7 +680,9 @@ protected: enum { OPJENCO_ENABLEJPWL = 100, OPJENCO_RATEFACTOR, + OPJENCO_RATERADIO, OPJENCO_QUALITYFACTOR, + OPJENCO_QUALITYRADIO, OPJENCO_RESNUMBER, OPJENCO_CODEBLOCKSIZE, OPJENCO_PRECINCTSIZE, @@ -674,6 +702,7 @@ protected: OPJENCO_ROISHIFT, OPJENCO_IMORIG, OPJENCO_TILORIG, + OPJENCO_ENABLEMCT, OPJENCO_ENABLEIRREV, OPJENCO_ENABLEINDEX, OPJENCO_INDEXNAME, diff --git a/OPJViewer/source/build.h b/OPJViewer/source/build.h index f23c5e96..654179bd 100644 --- a/OPJViewer/source/build.h +++ b/OPJViewer/source/build.h @@ -1 +1 @@ -wxT("242") +wxT("292") diff --git a/OPJViewer/source/imagj2k.cpp b/OPJViewer/source/imagj2k.cpp index 85b9acd5..143a1c0c 100644 --- a/OPJViewer/source/imagj2k.cpp +++ b/OPJViewer/source/imagj2k.cpp @@ -231,6 +231,11 @@ bool wxJ2KHandler::LoadFile(wxImage *image, wxInputStream& stream, bool verbose, } +#define CINEMA_24_CS 1302083 /* Codestream length for 24fps */ +#define CINEMA_48_CS 651041 /* Codestream length for 48fps */ +#define COMP_24_CS 1041666 /* Maximum size per color component for 2K & 4K @ 24fps */ +#define COMP_48_CS 520833 /* Maximum size per color component for 2K @ 48fps */ + // save the j2k codestream bool wxJ2KHandler::SaveFile( wxImage *wimage, wxOutputStream& stream, bool verbose ) { @@ -267,7 +272,7 @@ bool wxJ2KHandler::SaveFile( wxImage *wimage, wxOutputStream& stream, bool verbo } /* compression rates */ - if (m_rates != wxT("")) { + if ((m_rates != wxT("")) && (!m_enablequality)) { const char *s1 = m_rates.ToAscii(); wxLogMessage(wxT("rates %s"), s1); while (sscanf(s1, "%f", &(parameters.tcp_rates[parameters.tcp_numlayers])) == 1) { @@ -284,7 +289,7 @@ bool wxJ2KHandler::SaveFile( wxImage *wimage, wxOutputStream& stream, bool verbo } /* image quality, dB */ - if (m_rates == wxT("")) { + if ((m_quality != wxT("")) && (m_enablequality)) { const char *s2 = m_quality.ToAscii(); wxLogMessage(wxT("qualities %s"), s2); while (sscanf(s2, "%f", ¶meters.tcp_distoratio[parameters.tcp_numlayers]) == 1) { @@ -382,14 +387,103 @@ bool wxJ2KHandler::SaveFile( wxImage *wimage, wxOutputStream& stream, bool verbo if (m_enableeph) parameters.csty |= 0x04; + /* multiple component transform */ + if (m_multicomp) + parameters.tcp_mct = 1; + else + parameters.tcp_mct = 0; + /* mode switch */ + parameters.mode = (m_enablebypass ? 1 : 0) + (m_enablereset ? 2 : 0) + + (m_enablerestart ? 4 : 0) + (m_enablevsc ? 8 : 0) + + (m_enableerterm ? 16 : 0) + (m_enablesegmark ? 32 : 0); - /* compression settings */ - //parameters.tcp_numlayers = 1; - //parameters.tcp_rates[0] = 10.0; - //parameters.cp_disto_alloc = 1; - //parameters.irreversible = 1; - parameters.tcp_mct = 1; + /* progression order */ + switch (m_progression) { + + /* LRCP */ + case 0: + parameters.prog_order = LRCP; + break; + + /* RLCP */ + case 1: + parameters.prog_order = RLCP; + break; + + /* RPCL */ + case 2: + parameters.prog_order = RPCL; + break; + + /* PCRL */ + case 3: + parameters.prog_order = PCRL; + break; + + /* CPRL */ + case 4: + parameters.prog_order = CPRL; + break; + + /* DCI2K24 */ + case 5: + parameters.cp_cinema = CINEMA2K_24; + parameters.cp_rsiz = CINEMA2K; + break; + + /* DCI2K48 */ + case 6: + parameters.cp_cinema = CINEMA2K_48; + parameters.cp_rsiz = CINEMA2K; + break; + + /* DCI4K */ + case 7: + parameters.cp_cinema = CINEMA4K_24; + parameters.cp_rsiz = CINEMA4K; + break; + + default: + break; + } + + /* check cinema */ + if (parameters.cp_cinema) { + + /* set up */ + parameters.tile_size_on = false; + parameters.cp_tdx=1; + parameters.cp_tdy=1; + + /*Tile part*/ + parameters.tp_flag = 'C'; + parameters.tp_on = 1; + + /*Tile and Image shall be at (0,0)*/ + parameters.cp_tx0 = 0; + parameters.cp_ty0 = 0; + parameters.image_offset_x0 = 0; + parameters.image_offset_y0 = 0; + + /*Codeblock size= 32*32*/ + parameters.cblockw_init = 32; + parameters.cblockh_init = 32; + parameters.csty |= 0x01; + + /*The progression order shall be CPRL*/ + parameters.prog_order = CPRL; + + /* No ROI */ + parameters.roi_compno = -1; + + parameters.subsampling_dx = 1; + parameters.subsampling_dy = 1; + + /* 9-7 transform */ + parameters.irreversible = 1; + + } /* convert wx image into opj image */ cmptparm = (opj_image_cmptparm_t*) malloc(3 * sizeof(opj_image_cmptparm_t)); @@ -429,6 +523,103 @@ bool wxJ2KHandler::SaveFile( wxImage *wimage, wxOutputStream& stream, bool verbo oimage->comps[2].data[i] = *(value++); } + /* check cinema again */ + if (parameters.cp_cinema) { + int i; + float temp_rate; + opj_poc_t *POC = NULL; + + switch (parameters.cp_cinema) { + + case CINEMA2K_24: + case CINEMA2K_48: + if (parameters.numresolution > 6) { + parameters.numresolution = 6; + } + if (!((oimage->comps[0].w == 2048) | (oimage->comps[0].h == 1080))) { + wxLogWarning(wxT("Image coordinates %d x %d is not 2K compliant. JPEG Digital Cinema Profile-3 " + "(2K profile) compliance requires that at least one of coordinates match 2048 x 1080"), + oimage->comps[0].w, oimage->comps[0].h); + parameters.cp_rsiz = STD_RSIZ; + } + break; + + case CINEMA4K_24: + if (parameters.numresolution < 1) { + parameters.numresolution = 1; + } else if (parameters.numresolution > 7) { + parameters.numresolution = 7; + } + if (!((oimage->comps[0].w == 4096) | (oimage->comps[0].h == 2160))) { + wxLogWarning(wxT("Image coordinates %d x %d is not 4K compliant. JPEG Digital Cinema Profile-4" + "(4K profile) compliance requires that at least one of coordinates match 4096 x 2160"), + oimage->comps[0].w, oimage->comps[0].h); + parameters.cp_rsiz = STD_RSIZ; + } + parameters.POC[0].tile = 1; + parameters.POC[0].resno0 = 0; + parameters.POC[0].compno0 = 0; + parameters.POC[0].layno1 = 1; + parameters.POC[0].resno1 = parameters.numresolution - 1; + parameters.POC[0].compno1 = 3; + parameters.POC[0].prg1 = CPRL; + parameters.POC[1].tile = 1; + parameters.POC[1].resno0 = parameters.numresolution - 1; + parameters.POC[1].compno0 = 0; + parameters.POC[1].layno1 = 1; + parameters.POC[1].resno1 = parameters.numresolution; + parameters.POC[1].compno1 = 3; + parameters.POC[1].prg1 = CPRL; + parameters.numpocs = 2; + break; + } + + switch (parameters.cp_cinema) { + case CINEMA2K_24: + case CINEMA4K_24: + for (i = 0 ; i < parameters.tcp_numlayers; i++) { + temp_rate = 0; + if (parameters.tcp_rates[i] == 0) { + parameters.tcp_rates[0] = ((float) (oimage->numcomps * oimage->comps[0].w * oimage->comps[0].h * oimage->comps[0].prec)) / + (CINEMA_24_CS * 8 * oimage->comps[0].dx * oimage->comps[0].dy); + }else{ + temp_rate = ((float) (oimage->numcomps * oimage->comps[0].w * oimage->comps[0].h * oimage->comps[0].prec)) / + (parameters.tcp_rates[i] * 8 * oimage->comps[0].dx * oimage->comps[0].dy); + if (temp_rate > CINEMA_24_CS ) { + parameters.tcp_rates[i]= ((float) (oimage->numcomps * oimage->comps[0].w * oimage->comps[0].h * oimage->comps[0].prec)) / + (CINEMA_24_CS * 8 * oimage->comps[0].dx * oimage->comps[0].dy); + } else { + /* do nothing */ + } + } + } + parameters.max_comp_size = COMP_24_CS; + break; + + case CINEMA2K_48: + for (i = 0; i < parameters.tcp_numlayers; i++) { + temp_rate = 0 ; + if (parameters.tcp_rates[i] == 0) { + parameters.tcp_rates[0] = ((float) (oimage->numcomps * oimage->comps[0].w * oimage->comps[0].h * oimage->comps[0].prec)) / + (CINEMA_48_CS * 8 * oimage->comps[0].dx * oimage->comps[0].dy); + }else{ + temp_rate =((float) (oimage->numcomps * oimage->comps[0].w * oimage->comps[0].h * oimage->comps[0].prec)) / + (parameters.tcp_rates[i] * 8 * oimage->comps[0].dx * oimage->comps[0].dy); + if (temp_rate > CINEMA_48_CS ){ + parameters.tcp_rates[0]= ((float) (oimage->numcomps * oimage->comps[0].w * oimage->comps[0].h * oimage->comps[0].prec)) / + (CINEMA_48_CS * 8 * oimage->comps[0].dx * oimage->comps[0].dy); + }else{ + /* do nothing */ + } + } + } + parameters.max_comp_size = COMP_48_CS; + break; + } + + parameters.cp_disto_alloc = 1; + } + /* get a J2K compressor handle */ opj_cinfo_t* cinfo = opj_create_compress(CODEC_J2K); @@ -480,7 +671,7 @@ bool wxJ2KHandler::SaveFile( wxImage *wimage, wxOutputStream& stream, bool verbo /* Write the index to disk */ if (*indexfilename) { bSuccess = write_index_file(&cstr_info, indexfilename); - if (bSuccess) { + if (!bSuccess) { wxLogError(wxT("Failed to output index file")); } } diff --git a/OPJViewer/source/imagj2k.h b/OPJViewer/source/imagj2k.h index be1c9139..af70392e 100644 --- a/OPJViewer/source/imagj2k.h +++ b/OPJViewer/source/imagj2k.h @@ -82,8 +82,11 @@ public: m_origin = wxT("0,0"); m_rates = wxT("20,10,5"); m_quality = wxT("30,35,40"); + m_enablequality = false; + m_multicomp = false; m_irreversible = false; m_resolutions = 6; + m_progression = 0; m_cbsize = wxT("32,32"); m_prsize = wxT("[128,128],[128,128]"); m_tsize = wxT(""); @@ -92,6 +95,12 @@ public: m_resilience*/ m_enablesop = false; m_enableeph = false; + m_enablereset = false; + m_enablesegmark = false; + m_enablevsc = false; + m_enablerestart = false; + m_enableerterm = false; + m_enablebypass = false; /*m_roicompo m_roiup m_indexfname*/ @@ -127,8 +136,11 @@ public: wxString m_origin; wxString m_rates; wxString m_quality; + bool m_enablequality; + bool m_multicomp; bool m_irreversible; int m_resolutions; + int m_progression; wxString m_cbsize; wxString m_prsize; wxString m_tsize; @@ -137,6 +149,12 @@ public: m_resilience*/ bool m_enablesop; bool m_enableeph; + bool m_enablebypass; + bool m_enableerterm; + bool m_enablerestart; + bool m_enablereset; + bool m_enablesegmark; + bool m_enablevsc; /*m_roicompo m_roiup m_indexfname*/ diff --git a/codec/image_to_j2k.c b/codec/image_to_j2k.c index 470bd119..54ca14a1 100644 --- a/codec/image_to_j2k.c +++ b/codec/image_to_j2k.c @@ -639,10 +639,11 @@ int write_index_file(opj_codestream_info_t *cstr_info, char *index) { } fprintf(stream, "\nTILE %d DETAILS\n", tileno); - fprintf(stream, "part_nb tileno num_packs start_pos end_tph_pos end_pos\n"); + fprintf(stream, "part_nb tileno start_pack num_packs start_pos end_tph_pos end_pos\n"); for (tilepartno = 0; tilepartno < cstr_info->tile[tileno].num_tps; tilepartno++) - fprintf(stream, "%4d %9d %9d %9d %11d %9d\n", + fprintf(stream, "%4d %9d %9d %9d %9d %11d %9d\n", tilepartno, tileno, + cstr_info->tile[tileno].tp[tilepartno].tp_start_pack, cstr_info->tile[tileno].tp[tilepartno].tp_numpacks, cstr_info->tile[tileno].tp[tilepartno].tp_start_pos, cstr_info->tile[tileno].tp[tilepartno].tp_end_header, @@ -824,6 +825,14 @@ int write_index_file(opj_codestream_info_t *cstr_info, char *index) { fprintf(stream, "%8e\n", cstr_info->D_max); /* SE max */ fprintf(stream, "%.8e\n", total_disto); /* SE totale */ +/* UniPG>> */ + /* print the markers' list */ + fprintf(stream, "\nMARKER LIST\n"); + fprintf(stream, "%d\n", cstr_info->marknum); + fprintf(stream, "type\tstart_pos length\n"); + for (x = 0; x < cstr_info->marknum; x++) + fprintf(stream, "%X\t%9d %9d\n", cstr_info->marker[x].type, cstr_info->marker[x].pos, cstr_info->marker[x].len); +/* <marknum + 1) > cstr_info->maxmarknum) { + cstr_info->maxmarknum = 100 + (int) ((float) cstr_info->maxmarknum * 1.0F); + cstr_info->marker = opj_realloc(cstr_info->marker, cstr_info->maxmarknum); + } + + /* add the marker */ + cstr_info->marker[cstr_info->marknum].type = type; + cstr_info->marker[cstr_info->marknum].pos = pos; + cstr_info->marker[cstr_info->marknum].len = len; + cstr_info->marknum++; + +} void jpwl_prepare_marks(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image) { @@ -170,7 +191,7 @@ void jpwl_prepare_marks(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image) { jpwl_epc_ms_t *epc_mark; jpwl_esd_ms_t *esd_mark; - /* find SOC + SIZ length */ + /* find (SOC + SIZ) length */ /* I assume SIZ is always the first marker after SOC */ cio_seek(cio, soc_pos + 4); socsiz_len = (unsigned short int) cio_read(cio, 2) + 4; /* add the 2 marks length itself */ @@ -544,7 +565,8 @@ void jpwl_prepare_marks(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image) { startpack = 0; /* EPB MSs for UEP packet data protection in Tile Parts */ /****** for (packno = 0; packno < j2k->cstr_info->num; packno++) { */ - first_tp_pack = (tpno > 0) ? (first_tp_pack + j2k->cstr_info->tile[tileno].tp[tpno - 1].tp_numpacks) : 0; + /*first_tp_pack = (tpno > 0) ? (first_tp_pack + j2k->cstr_info->tile[tileno].tp[tpno - 1].tp_numpacks) : 0;*/ + first_tp_pack = j2k->cstr_info->tile[tileno].tp[tpno].tp_start_pack; last_tp_pack = first_tp_pack + j2k->cstr_info->tile[tileno].tp[tpno].tp_numpacks - 1; for (packno = 0; packno < j2k->cstr_info->tile[tileno].tp[tpno].tp_numpacks; packno++) { @@ -706,7 +728,7 @@ void jpwl_dump_marks(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image) { } /* allocate a new buffer of proper size */ - if (!(jpwl_buf = (unsigned char *) opj_malloc((size_t) new_size * sizeof (unsigned char)))) { + if (!(jpwl_buf = (unsigned char *) opj_malloc((size_t) (new_size + soc_pos) * sizeof(unsigned char)))) { opj_event_msg(j2k->cinfo, EVT_ERROR, "Could not allocate room for JPWL codestream buffer\n"); exit(1); }; @@ -736,15 +758,15 @@ void jpwl_dump_marks(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image) { switch (jwmarker[mm].id) { case J2K_MS_EPB: - jpwl_epb_write(jwmarker[mm].epbmark, jpwl_buf); + jpwl_epb_write(j2k, jwmarker[mm].epbmark, jpwl_buf); break; case J2K_MS_EPC: - jpwl_epc_write(jwmarker[mm].epcmark, jpwl_buf); + jpwl_epc_write(j2k, jwmarker[mm].epcmark, jpwl_buf); break; case J2K_MS_ESD: - jpwl_esd_write(jwmarker[mm].esdmark, jpwl_buf); + jpwl_esd_write(j2k, jwmarker[mm].esdmark, jpwl_buf); break; case J2K_MS_RED: @@ -755,6 +777,10 @@ void jpwl_dump_marks(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image) { break; }; + /* we update the markers struct */ + if (j2k->cstr_info) + j2k->cstr_info->marker[j2k->cstr_info->marknum - 1].pos = (jpwl_buf - orig_buf); + /* we set the marker dpos to the new position in the JPWL codestream */ jwmarker[mm].dpos = (double) (jpwl_buf - orig_buf); @@ -863,14 +889,13 @@ void jpwl_dump_marks(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image) { /* free original cio buffer and set it to the JPWL one */ opj_free(cio->buffer); - /*cio->cinfo;*/ /* no change */ - /*cio->openmode;*/ /* no change */ - /*cio->buffer = jpwl_buf - new_size - soc_pos;*/ + cio->cinfo = cio->cinfo; /* no change */ + cio->openmode = cio->openmode; /* no change */ cio->buffer = orig_buf; cio->length = new_size + soc_pos; - cio->start = jpwl_buf - new_size - soc_pos; - cio->end = jpwl_buf - 1; - cio->bp = jpwl_buf - new_size - soc_pos; + cio->start = cio->buffer; + cio->end = cio->buffer + cio->length; + cio->bp = cio->buffer; cio_seek(cio, soc_pos + new_size); } @@ -982,6 +1007,10 @@ void j2k_write_epc(opj_j2k_t *j2k) { cio_write(cio, Pcrc, 2); cio_seek(cio, Lepcp + Lepc); + + /* marker struct update */ + j2k_add_marker(j2k->cstr_info, J2K_MS_EPC, Lepcp - 2, Lepc + 2); + } void j2k_read_epb(opj_j2k_t *j2k) { @@ -1130,6 +1159,9 @@ void j2k_write_epb(opj_j2k_t *j2k) { cio_write(cio, Lepb, 2); /* Lepb */ cio_seek(cio, Lepbp + Lepb); + + /* marker struct update */ + j2k_add_marker(j2k->cstr_info, J2K_MS_EPB, Lepbp - 2, Lepb + 2); } void j2k_read_esd(opj_j2k_t *j2k) { diff --git a/jpwl/jpwl.h b/jpwl/jpwl.h index 65edce77..a58f2882 100644 --- a/jpwl/jpwl.h +++ b/jpwl/jpwl.h @@ -334,6 +334,8 @@ bool jpwl_esd_fill(opj_j2k_t *j2k, jpwl_esd_ms_t *esdmark, unsigned char *buf); bool jpwl_epb_fill(opj_j2k_t *j2k, jpwl_epb_ms_t *epbmark, unsigned char *buf, unsigned char *post_buf); +void j2k_add_marker(opj_codestream_info_t *cstr_info, unsigned short int type, int pos, int len); + /** corrects the data in the JPWL codestream @param j2k J2K compressor handle @return true if correction is performed correctly diff --git a/jpwl/jpwl_lib.c b/jpwl/jpwl_lib.c index 7839249c..5ee53603 100644 --- a/jpwl/jpwl_lib.c +++ b/jpwl/jpwl_lib.c @@ -295,7 +295,7 @@ jpwl_epb_ms_t *jpwl_epb_create(opj_j2k_t *j2k, bool latest, bool packed, int til return epb; } -void jpwl_epb_write(jpwl_epb_ms_t *epb, unsigned char *buf) { +void jpwl_epb_write(opj_j2k_t *j2k, jpwl_epb_ms_t *epb, unsigned char *buf) { /* Marker */ *(buf++) = (unsigned char) (J2K_MS_EPB >> 8); @@ -323,6 +323,10 @@ void jpwl_epb_write(jpwl_epb_ms_t *epb, unsigned char *buf) { /* Data */ /*memcpy(buf, epb->data, (size_t) epb->Lepb - 11);*/ memset(buf, 0, (size_t) epb->Lepb - 11); + + /* update markers struct */ + j2k_add_marker(j2k->cstr_info, J2K_MS_EPB, -1, epb->Lepb + 2); + }; @@ -1145,7 +1149,7 @@ bool jpwl_epb_correct(opj_j2k_t *j2k, unsigned char *buffer, int type, int pre_l return true; } -void jpwl_epc_write(jpwl_epc_ms_t *epc, unsigned char *buf) { +void jpwl_epc_write(opj_j2k_t *j2k, jpwl_epc_ms_t *epc, unsigned char *buf) { /* Marker */ *(buf++) = (unsigned char) (J2K_MS_EPC >> 8); @@ -1171,6 +1175,10 @@ void jpwl_epc_write(jpwl_epc_ms_t *epc, unsigned char *buf) { /* Data */ /*memcpy(buf, epc->data, (size_t) epc->Lepc - 9);*/ memset(buf, 0, (size_t) epc->Lepc - 9); + + /* update markers struct */ + j2k_add_marker(j2k->cstr_info, J2K_MS_EPC, -1, epc->Lepc + 2); + }; int jpwl_esds_add(opj_j2k_t *j2k, jpwl_marker_t *jwmarker, int *jwmarker_num, @@ -1561,7 +1569,7 @@ bool jpwl_esd_fill(opj_j2k_t *j2k, jpwl_esd_ms_t *esd, unsigned char *buf) { return true; } -void jpwl_esd_write(jpwl_esd_ms_t *esd, unsigned char *buf) { +void jpwl_esd_write(opj_j2k_t *j2k, jpwl_esd_ms_t *esd, unsigned char *buf) { /* Marker */ *(buf++) = (unsigned char) (J2K_MS_ESD >> 8); @@ -1586,6 +1594,10 @@ void jpwl_esd_write(jpwl_esd_ms_t *esd, unsigned char *buf) { else memset(buf, 0xAA, (size_t) esd->Lesd - 5); /*memcpy(buf, esd->data, (size_t) esd->Lesd - 5);*/ + + /* update markers struct */ + j2k_add_marker(j2k->cstr_info, J2K_MS_ESD, -1, esd->Lesd + 2); + } unsigned short int jpwl_double_to_pfp(double V, int bytes) { @@ -1703,10 +1715,10 @@ bool jpwl_update_info(opj_j2k_t *j2k, jpwl_marker_t *jwmarker, int jwmarker_num) /* end_pos: increment with markers before the end of this tile */ /* code is disabled, since according to JPWL no markers can be beyond TPH */ - /*addlen = 0; + addlen = 0; for (mm = 0; mm < jwmarker_num; mm++) if (jwmarker[mm].pos < (unsigned long int) info->tile[tileno].end_pos) - addlen += jwmarker[mm].len + 2;*/ + addlen += jwmarker[mm].len + 2; info->tile[tileno].end_pos += addlen; /* navigate through all the tile parts */ @@ -1740,11 +1752,19 @@ bool jpwl_update_info(opj_j2k_t *j2k, jpwl_marker_t *jwmarker, int jwmarker_num) /* start_pos: increment with markers before the packet */ /* disabled for the same reason as before */ + addlen = 0; + for (mm = 0; mm < jwmarker_num; mm++) + if (jwmarker[mm].pos <= (unsigned long int) info->tile[tileno].packet[packno].start_pos) + addlen += jwmarker[mm].len + 2; + info->tile[tileno].packet[packno].start_pos += addlen; + + /* end_ph_pos: increment with markers before the packet */ + /* disabled for the same reason as before */ /*addlen = 0; for (mm = 0; mm < jwmarker_num; mm++) - if (jwmarker[mm].pos < (unsigned long int) info->tile[tileno].packet[packno].start_pos) + if (jwmarker[mm].pos < (unsigned long int) info->tile[tileno].packet[packno].end_ph_pos) addlen += jwmarker[mm].len + 2;*/ - info->tile[tileno].packet[packno].start_pos += addlen; + info->tile[tileno].packet[packno].end_ph_pos += addlen; /* end_pos: increment if marker is before the end of packet */ /* disabled for the same reason as before */ @@ -1757,6 +1777,8 @@ bool jpwl_update_info(opj_j2k_t *j2k, jpwl_marker_t *jwmarker, int jwmarker_num) } } + /* reorder the markers list */ + return true; } diff --git a/libopenjpeg/j2k.c b/libopenjpeg/j2k.c index 114ee9ec..dfa8286c 100644 --- a/libopenjpeg/j2k.c +++ b/libopenjpeg/j2k.c @@ -434,6 +434,15 @@ int j2k_calculate_tp(opj_cp_t *cp,int img_numcomp,opj_image_t *image,opj_j2k_t * static void j2k_write_soc(opj_j2k_t *j2k) { opj_cio_t *cio = j2k->cio; cio_write(cio, J2K_MS_SOC, 2); + +/* UniPG>> */ +#ifdef USE_JPWL + + /* update markers struct */ + j2k_add_marker(j2k->cstr_info, J2K_MS_SOC, cio_tell(cio) - 2, 2); + +#endif /* USE_JPWL */ +/* <ppm_data); + opj_free(cp->ppm_data); opj_event_msg(j2k->cinfo, EVT_ERROR, "JPWL: giving up\n"); return; } @@ -1279,6 +1288,13 @@ static void j2k_write_sot(opj_j2k_t *j2k) { cio_seek(cio, lenp); cio_write(cio, len, 2); /* Lsot */ cio_seek(cio, lenp + len); + + /* UniPG>> */ +#ifdef USE_JPWL + /* update markers struct */ + j2k_add_marker(j2k->cstr_info, J2K_MS_SOT, j2k->sot_start, len + 2); +#endif /* USE_JPWL */ + /* <tile[j2k->curtileno].packet[cstr_info->packno - 1].end_pos < cio_tell(cio)) cstr_info->tile[j2k->curtileno].packet[cstr_info->packno].start_pos = cio_tell(cio); } + /* UniPG>> */ +#ifdef USE_JPWL + /* update markers struct */ + j2k_add_marker(j2k->cstr_info, J2K_MS_SOD, j2k->sod_start, 2); +#endif /* USE_JPWL */ + /* <cio; /* opj_event_msg(j2k->cinfo, "%.8x: EOC\n", cio_tell(cio) + j2k->pos_correction); */ cio_write(cio, J2K_MS_EOC, 2); + +/* UniPG>> */ +#ifdef USE_JPWL + /* update markers struct */ + j2k_add_marker(j2k->cstr_info, J2K_MS_EOC, cio_tell(cio) - 2, 2); +#endif /* USE_JPWL */ +/* <> */ - int acc_pack_num = 0; - /* <cio = cio; j2k->image = image; @@ -2309,6 +2334,9 @@ bool j2k_encode(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image, opj_codestre } cstr_info->D_max = 0.0; /* ADD Marcela */ cstr_info->main_head_start = cio_tell(cio); /* position of SOC */ + cstr_info->maxmarknum = 100; + cstr_info->marker = (opj_marker_info_t *) opj_malloc(cstr_info->maxmarknum * sizeof(opj_marker_info_t)); + cstr_info->marknum = 0; } /* << INDEX */ @@ -2359,6 +2387,10 @@ bool j2k_encode(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image, opj_codestre for (tileno = 0; tileno < cp->tw * cp->th; tileno++) { int pino; int tilepartno=0; + /* UniPG>> */ + int acc_pack_num = 0; + /* <tcps[tileno]; opj_event_msg(j2k->cinfo, EVT_INFO, "tile number %d / %d\n", tileno + 1, cp->tw * cp->th); @@ -2418,6 +2450,8 @@ bool j2k_encode(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image, opj_codestre if(cstr_info) { cstr_info->tile[j2k->curtileno].tp[j2k->cur_tp_num].tp_end_pos = cio_tell(cio) + j2k->pos_correction - 1; + cstr_info->tile[j2k->curtileno].tp[j2k->cur_tp_num].tp_start_pack = + acc_pack_num; cstr_info->tile[j2k->curtileno].tp[j2k->cur_tp_num].tp_numpacks = cstr_info->packno - acc_pack_num; acc_pack_num = cstr_info->packno; diff --git a/libopenjpeg/openjpeg.c b/libopenjpeg/openjpeg.c index 356d2ca9..96fa0ad5 100644 --- a/libopenjpeg/openjpeg.c +++ b/libopenjpeg/openjpeg.c @@ -324,5 +324,6 @@ void OPJ_CALLCONV opj_destroy_cstr_info(opj_codestream_info_t *cstr_info) { opj_free(tile_info->tp); } opj_free(cstr_info->tile); + opj_free(cstr_info->marker); } } diff --git a/libopenjpeg/openjpeg.h b/libopenjpeg/openjpeg.h index b58d39f9..015c2554 100644 --- a/libopenjpeg/openjpeg.h +++ b/libopenjpeg/openjpeg.h @@ -606,6 +606,8 @@ typedef struct opj_tp_info { int tp_end_header; /** end position of tile part */ int tp_end_pos; + /** start packet of tile part */ + int tp_start_pack; /** number of packets of tile part */ int tp_numpacks; } opj_tp_info_t; @@ -697,6 +699,8 @@ typedef struct opj_codestream_info { int marknum; /** list of markers */ opj_marker_info_t *marker; + /** actual size of markers array */ + int maxmarknum; /* <tk[0].sample[snum]; - sprintf(j2kfilename,"%s_%05d.j2k",argv[1],snum); + sprintf(j2kfilename,"%05d.j2k",/*argv[1],*/snum + 7111); j2kfile = fopen(j2kfilename, "rb"); if (!j2kfile) { if (snum==0) { // Could not open a single codestream