summaryrefslogtreecommitdiff
path: root/OPJViewer/source
diff options
context:
space:
mode:
authorGiuseppe Baruffa <gbaruffa@users.noreply.github.com>2007-09-07 23:16:31 +0000
committerGiuseppe Baruffa <gbaruffa@users.noreply.github.com>2007-09-07 23:16:31 +0000
commitd70a0415b910cc5a3550fea1d777ded84d4cdfa0 (patch)
tree9d73e44534b437db7144bff8b64653bc42a07302 /OPJViewer/source
parent3816e0edf40b766ab78cdbf3ba5634b684630d0f (diff)
Adapted the JPWL and OPJViewer code to new interface; fixed a samll bug in JPWL which created large EPBs even when null protection was specified
Diffstat (limited to 'OPJViewer/source')
-rw-r--r--OPJViewer/source/OPJViewer.cpp104
-rw-r--r--OPJViewer/source/OPJViewer.h12
-rw-r--r--OPJViewer/source/build.h2
-rw-r--r--OPJViewer/source/imagj2k.cpp140
-rw-r--r--OPJViewer/source/imagjp2.cpp3
-rw-r--r--OPJViewer/source/imagmj2.cpp3
6 files changed, 175 insertions, 89 deletions
diff --git a/OPJViewer/source/OPJViewer.cpp b/OPJViewer/source/OPJViewer.cpp
index 8253f90b..66d47c5d 100644
--- a/OPJViewer/source/OPJViewer.cpp
+++ b/OPJViewer/source/OPJViewer.cpp
@@ -2995,11 +2995,19 @@ OPJEncoderDialog::OPJEncoderDialog(wxWindow* win, int dialogType)
m_settingsNotebook = GetBookCtrl();
- wxPanel* jpeg2000Settings = CreatePart1SettingsPage(m_settingsNotebook);
+ 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(jpeg2000Settings, wxT("JPEG 2000"), false);
+ 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();
}
@@ -3027,7 +3035,28 @@ wxPanel* OPJEncoderDialog::CreateMainSettingsPage(wxWindow* parent)
return panel;
}
-wxPanel* OPJEncoderDialog::CreatePart1SettingsPage(wxWindow* parent)
+#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);
@@ -3038,7 +3067,7 @@ wxPanel* OPJEncoderDialog::CreatePart1SettingsPage(wxWindow* parent)
//topSizer->AddSpacer(5);
// sub top sizer
- wxFlexGridSizer *subtopSizer = new wxFlexGridSizer(4, 3, 3);
+ wxFlexGridSizer *subtopSizer = new wxFlexGridSizer(2, 3, 3);
// image settings, column
wxStaticBox* imageBox = new wxStaticBox(panel, wxID_ANY, wxT("Image"));
@@ -3258,19 +3287,42 @@ wxPanel* OPJEncoderDialog::CreatePart1SettingsPage(wxWindow* parent)
subtopSizer->Add(tileSizer, 0, wxGROW | wxALL, 3);
- // progression settings, column
- wxString choices[] = {wxT("LRCP"), wxT("RLCP"), wxT("RPCL"), wxT("PCRL"), wxT("CPRL")};
+ // 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"),
+ wxT("Progression order/profile"),
wxDefaultPosition, wxDefaultSize,
WXSIZEOF(choices),
choices,
- 4,
+ 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);
@@ -3394,7 +3446,7 @@ wxPanel* OPJEncoderDialog::CreatePart1SettingsPage(wxWindow* parent)
subtopSizer->Add(roiSizer, 0, wxGROW | wxALL, 3);
- // ROI settings, column
+ // Index file settings, column
wxStaticBox* indexBox = new wxStaticBox(panel, wxID_ANY, wxT("Indexing"));
wxBoxSizer* indexSizer = new wxStaticBoxSizer(indexBox, wxVERTICAL);
@@ -3453,6 +3505,40 @@ wxPanel* OPJEncoderDialog::CreatePart1SettingsPage(wxWindow* parent)
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
diff --git a/OPJViewer/source/OPJViewer.h b/OPJViewer/source/OPJViewer.h
index 0c29af4d..db28837e 100644
--- a/OPJViewer/source/OPJViewer.h
+++ b/OPJViewer/source/OPJViewer.h
@@ -631,20 +631,22 @@ public:
wxBookCtrlBase* m_settingsNotebook;
wxPanel* CreateMainSettingsPage(wxWindow* parent);
- wxPanel* CreatePart1SettingsPage(wxWindow* parent);
+ wxPanel* CreatePart1_1SettingsPage(wxWindow* parent);
+ wxPanel* CreatePart1_2SettingsPage(wxWindow* parent);
/* wxPanel* CreatePart3SettingsPage(wxWindow* parent);*/
#ifdef USE_JPWL
void OnEnableJPWL(wxCommandEvent& event);
void OnEnableComm(wxCommandEvent& event);
void OnEnableIdx(wxCommandEvent& event);
-/* wxPanel* CreatePart11SettingsPage(wxWindow* parent);
- wxCheckBox *m_enablejpwlCheck;*/
+ wxPanel* CreatePart11SettingsPage(wxWindow* parent);
+ /*wxCheckBox *m_enablejpwlCheck;*/
#endif // USE_JPWL
wxTextCtrl *m_subsamplingCtrl, *m_originCtrl, *m_rateCtrl, *m_commentCtrl;
- wxTextCtrl *m_indexCtrl, *m_qualityCtrl, *m_cbsizeCtrl, *m_prsizeCtrl;
+ 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;
+ wxCheckBox *m_enablepocCheck;
wxSpinCtrl *m_resolutionsCtrl;
protected:
@@ -667,6 +669,7 @@ protected:
OPJENCO_ENABLEVSC,
OPJENCO_ENABLEERTERM,
OPJENCO_ENABLESEGMARK,
+ OPJENCO_ENABLEPOC,
OPJENCO_ROICOMP,
OPJENCO_ROISHIFT,
OPJENCO_IMORIG,
@@ -674,6 +677,7 @@ protected:
OPJENCO_ENABLEIRREV,
OPJENCO_ENABLEINDEX,
OPJENCO_INDEXNAME,
+ OPJENCO_POCSPEC,
OPJENCO_ENABLECOMM,
OPJENCO_COMMENTTEXT
};
diff --git a/OPJViewer/source/build.h b/OPJViewer/source/build.h
index 176e98c1..4d7baa6b 100644
--- a/OPJViewer/source/build.h
+++ b/OPJViewer/source/build.h
@@ -1 +1 @@
-wxT("207")
+wxT("219")
diff --git a/OPJViewer/source/imagj2k.cpp b/OPJViewer/source/imagj2k.cpp
index 64c051ff..9ce142df 100644
--- a/OPJViewer/source/imagj2k.cpp
+++ b/OPJViewer/source/imagj2k.cpp
@@ -131,6 +131,7 @@ bool wxJ2KHandler::LoadFile(wxImage *image, wxInputStream& stream, bool verbose,
unsigned char *src = NULL;
unsigned char *ptr;
int file_length;
+ opj_codestream_info_t cstr_info; /* Codestream information structure */
// destroy the image
image->Destroy();
@@ -188,7 +189,7 @@ bool wxJ2KHandler::LoadFile(wxImage *image, wxInputStream& stream, bool verbose,
cio = opj_cio_open((opj_common_ptr)dinfo, src, file_length);
/* decode the stream and fill the image structure */
- opjimage = opj_decode(dinfo, cio);
+ opjimage = opj_decode(dinfo, cio, &cstr_info);
if (!opjimage) {
#ifndef __WXGTK__
wxMutexGuiEnter();
@@ -242,6 +243,7 @@ bool wxJ2KHandler::SaveFile( wxImage *wimage, wxOutputStream& stream, bool verbo
int codestream_length;
bool bSuccess;
int i;
+ char indexfilename[OPJ_PATH_LEN] = ""; /* index file name */
/*
configure the event callbacks (not required)
@@ -316,11 +318,8 @@ bool wxJ2KHandler::SaveFile( wxImage *wimage, wxOutputStream& stream, bool verbo
/* indexing file */
if (m_enableidx) {
- strncpy(parameters.index, m_index.c_str(), m_index.Len());
- wxLogMessage("index file is %s", parameters.index);
- parameters.index_on = 1;
- } else {
- parameters.index_on = 0;
+ strncpy(indexfilename, m_index.c_str(), OPJ_PATH_LEN);
+ wxLogMessage("index file is %s", indexfilename);
}
/* if no rate entered, lossless by default */
@@ -479,8 +478,8 @@ bool wxJ2KHandler::SaveFile( wxImage *wimage, wxOutputStream& stream, bool verbo
opj_cio_close(cio);
/* Write the index to disk */
- if (parameters.index_on) {
- bSuccess = write_index_file(&cstr_info, parameters.index);
+ if (*indexfilename) {
+ bSuccess = write_index_file(&cstr_info, indexfilename);
if (bSuccess) {
wxLogError(wxT("Failed to output index file"));
}
@@ -536,67 +535,72 @@ Create an index and write it to a file
bool wxJ2KHandler::write_index_file(opj_codestream_info_t *cstr_info, char *index) {
int tileno, compno, layno, resno, precno, pack_nb, x, y;
FILE *stream = NULL;
- double total_disto = 0;
+ int tilepartno;
if (!cstr_info)
- return false;
+ return 1;
stream = fopen(index, "w");
if (!stream) {
- wxLogError(wxT("failed to open index file [%s] for writing"), index);
- return false;
+ fprintf(stderr, "failed to open index file [%s] for writing\n", index);
+ return 1;
}
fprintf(stream, "%d %d\n", cstr_info->image_w, cstr_info->image_h);
fprintf(stream, "%d\n", cstr_info->prog);
fprintf(stream, "%d %d\n", cstr_info->tile_x, cstr_info->tile_y);
fprintf(stream, "%d %d\n", cstr_info->tw, cstr_info->th);
- fprintf(stream, "%d\n", cstr_info->comp);
- fprintf(stream, "%d\n", cstr_info->layer);
- fprintf(stream, "%d\n", cstr_info->decomposition);
+ fprintf(stream, "%d\n", cstr_info->numcomps);
+ fprintf(stream, "%d\n", cstr_info->numlayers);
+ fprintf(stream, "%d\n", cstr_info->numdecompos);
- for (resno = cstr_info->decomposition; resno >= 0; resno--) {
+ for (resno = cstr_info->numdecompos; resno >= 0; resno--) {
fprintf(stream, "[%d,%d] ",
(1 << cstr_info->tile[0].pdx[resno]), (1 << cstr_info->tile[0].pdx[resno])); /* based on tile 0 */
}
fprintf(stream, "\n");
+ fprintf(stream, "%d\n", cstr_info->main_head_start);
fprintf(stream, "%d\n", cstr_info->main_head_end);
fprintf(stream, "%d\n", cstr_info->codestream_size);
fprintf(stream, "\nINFO ON TILES\n");
- fprintf(stream, "tileno start_pos end_hd end_tile disto nbpix disto/nbpix\n");
+ fprintf(stream, "tileno start_pos end_hd end_tile nbparts\n");
for (tileno = 0; tileno < cstr_info->tw * cstr_info->th; tileno++) {
- fprintf(stream, "%4d %9d %9d %9d %9e %9d %9e\n",
- cstr_info->tile[tileno].num_tile,
+ fprintf(stream, "%4d %9d %9d %9d %9d\n",
+ cstr_info->tile[tileno].tileno,
cstr_info->tile[tileno].start_pos,
cstr_info->tile[tileno].end_header,
cstr_info->tile[tileno].end_pos,
- cstr_info->tile[tileno].distotile, cstr_info->tile[tileno].nbpix,
- cstr_info->tile[tileno].distotile / cstr_info->tile[tileno].nbpix);
+ cstr_info->tile[tileno].num_tps);
}
for (tileno = 0; tileno < cstr_info->tw * cstr_info->th; tileno++) {
int start_pos, end_ph_pos, end_pos;
- double disto = 0;
pack_nb = 0;
- fprintf(stream, "\nTILE %d DETAILS\n", tileno);
+ fprintf(stream, "\nTILE %d DETAILS\n", tileno);
+ fprintf(stream, "part_nb tileno 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",
+ tilepartno, tileno,
+ 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,
+ cstr_info->tile[tileno].tp[tilepartno].tp_end_pos
+ );
if (cstr_info->prog == LRCP) { /* LRCP */
+ fprintf(stream, "LRCP\npack_nb tileno layno resno compno precno start_pos end_ph_pos end_pos\n");
- fprintf(stream, "LRCP\npack_nb tileno layno resno compno precno start_pos end_ph_pos end_pos disto\n");
-
- for (layno = 0; layno < cstr_info->layer; layno++) {
- for (resno = 0; resno < cstr_info->decomposition + 1; resno++) {
- for (compno = 0; compno < cstr_info->comp; compno++) {
+ for (layno = 0; layno < cstr_info->numlayers; layno++) {
+ for (resno = 0; resno < cstr_info->numdecompos + 1; resno++) {
+ for (compno = 0; compno < cstr_info->numcomps; compno++) {
int prec_max = cstr_info->tile[tileno].pw[resno] * cstr_info->tile[tileno].ph[resno];
for (precno = 0; precno < prec_max; precno++) {
start_pos = cstr_info->tile[tileno].packet[pack_nb].start_pos;
end_ph_pos = cstr_info->tile[tileno].packet[pack_nb].end_ph_pos;
end_pos = cstr_info->tile[tileno].packet[pack_nb].end_pos;
- disto = cstr_info->tile[tileno].packet[pack_nb].disto;
- fprintf(stream, "%4d %6d %7d %5d %6d %6d %6d %6d %7d %8e\n",
- pack_nb, tileno, layno, resno, compno, precno, start_pos, end_ph_pos, end_pos, disto);
- total_disto += disto;
+ fprintf(stream, "%4d %6d %7d %5d %6d %6d %6d %6d %7d\n",
+ pack_nb, tileno, layno, resno, compno, precno, start_pos, end_ph_pos, end_pos);
pack_nb++;
}
}
@@ -605,20 +609,18 @@ bool wxJ2KHandler::write_index_file(opj_codestream_info_t *cstr_info, char *inde
} /* LRCP */
else if (cstr_info->prog == RLCP) { /* RLCP */
- fprintf(stream, "RLCP\npack_nb tileno resno layno compno precno start_pos end_ph_pos end_pos disto\n");
+ fprintf(stream, "RLCP\npack_nb tileno resno layno compno precno start_pos end_ph_pos end_pos\n");
- for (resno = 0; resno < cstr_info->decomposition + 1; resno++) {
- for (layno = 0; layno < cstr_info->layer; layno++) {
- for (compno = 0; compno < cstr_info->comp; compno++) {
+ for (resno = 0; resno < cstr_info->numdecompos + 1; resno++) {
+ for (layno = 0; layno < cstr_info->numlayers; layno++) {
+ for (compno = 0; compno < cstr_info->numcomps; compno++) {
int prec_max = cstr_info->tile[tileno].pw[resno] * cstr_info->tile[tileno].ph[resno];
for (precno = 0; precno < prec_max; precno++) {
start_pos = cstr_info->tile[tileno].packet[pack_nb].start_pos;
end_ph_pos = cstr_info->tile[tileno].packet[pack_nb].end_ph_pos;
end_pos = cstr_info->tile[tileno].packet[pack_nb].end_pos;
- disto = cstr_info->tile[tileno].packet[pack_nb].disto;
- fprintf(stream, "%4d %6d %5d %7d %6d %6d %9d %9d %7d %8e\n",
- pack_nb, tileno, resno, layno, compno, precno, start_pos, end_ph_pos, end_pos, disto);
- total_disto += disto;
+ fprintf(stream, "%4d %6d %5d %7d %6d %6d %9d %9d %7d\n",
+ pack_nb, tileno, resno, layno, compno, precno, start_pos, end_ph_pos, end_pos);
pack_nb++;
}
}
@@ -627,34 +629,32 @@ bool wxJ2KHandler::write_index_file(opj_codestream_info_t *cstr_info, char *inde
} /* RLCP */
else if (cstr_info->prog == RPCL) { /* RPCL */
- fprintf(stream, "RPCL\npack_nb tileno resno precno compno layno start_pos end_ph_pos end_pos disto\n");
+ fprintf(stream, "RPCL\npack_nb tileno resno precno compno layno start_pos end_ph_pos end_pos\n");
- for (resno = 0; resno < cstr_info->decomposition + 1; resno++) {
+ for (resno = 0; resno < cstr_info->numdecompos + 1; resno++) {
/* I suppose components have same XRsiz, YRsiz */
int x0 = cstr_info->tile_Ox + tileno - (int)floor((float)tileno/(float)cstr_info->tw ) * cstr_info->tw * cstr_info->tile_x;
int y0 = cstr_info->tile_Ox + (int)floor( (float)tileno/(float)cstr_info->tw ) * cstr_info->tile_y;
int x1 = x0 + cstr_info->tile_x;
int y1 = y0 + cstr_info->tile_y;
- for (compno = 0; compno < cstr_info->comp; compno++) {
+ for (compno = 0; compno < cstr_info->numcomps; compno++) {
int prec_max = cstr_info->tile[tileno].pw[resno] * cstr_info->tile[tileno].ph[resno];
for (precno = 0; precno < prec_max; precno++) {
int pcnx = cstr_info->tile[tileno].pw[resno];
- int pcx = (int) pow( 2, cstr_info->tile[tileno].pdx[resno] + cstr_info->decomposition - resno );
- int pcy = (int) pow( 2, cstr_info->tile[tileno].pdy[resno] + cstr_info->decomposition - resno );
+ int pcx = (int) pow( 2, cstr_info->tile[tileno].pdx[resno] + cstr_info->numdecompos - resno );
+ int pcy = (int) pow( 2, cstr_info->tile[tileno].pdy[resno] + cstr_info->numdecompos - resno );
int precno_x = precno - (int) floor( (float)precno/(float)pcnx ) * pcnx;
int precno_y = (int) floor( (float)precno/(float)pcnx );
for(y = y0; y < y1; y++) {
if (precno_y*pcy == y ) {
for (x = x0; x < x1; x++) {
if (precno_x*pcx == x ) {
- for (layno = 0; layno < cstr_info->layer; layno++) {
+ for (layno = 0; layno < cstr_info->numlayers; layno++) {
start_pos = cstr_info->tile[tileno].packet[pack_nb].start_pos;
end_ph_pos = cstr_info->tile[tileno].packet[pack_nb].end_ph_pos;
end_pos = cstr_info->tile[tileno].packet[pack_nb].end_pos;
- disto = cstr_info->tile[tileno].packet[pack_nb].disto;
- fprintf(stream, "%4d %6d %5d %6d %6d %7d %9d %9d %7d %8e\n",
- pack_nb, tileno, resno, precno, compno, layno, start_pos, end_ph_pos, end_pos, disto);
- total_disto += disto;
+ fprintf(stream, "%4d %6d %5d %6d %6d %7d %9d %9d %7d\n",
+ pack_nb, tileno, resno, precno, compno, layno, start_pos, end_ph_pos, end_pos);
pack_nb++;
}
}
@@ -672,29 +672,27 @@ bool wxJ2KHandler::write_index_file(opj_codestream_info_t *cstr_info, char *inde
int x1 = x0 + cstr_info->tile_x;
int y1 = y0 + cstr_info->tile_y;
- fprintf(stream, "PCRL\npack_nb tileno precno compno resno layno start_pos end_ph_pos end_pos disto\n");
+ fprintf(stream, "PCRL\npack_nb tileno precno compno resno layno start_pos end_ph_pos end_pos\n");
- for (compno = 0; compno < cstr_info->comp; compno++) {
- for (resno = 0; resno < cstr_info->decomposition + 1; resno++) {
+ for (compno = 0; compno < cstr_info->numcomps; compno++) {
+ for (resno = 0; resno < cstr_info->numdecompos + 1; resno++) {
int prec_max = cstr_info->tile[tileno].pw[resno] * cstr_info->tile[tileno].ph[resno];
for (precno = 0; precno < prec_max; precno++) {
int pcnx = cstr_info->tile[tileno].pw[resno];
- int pcx = (int) pow( 2, cstr_info->tile[tileno].pdx[resno] + cstr_info->decomposition - resno );
- int pcy = (int) pow( 2, cstr_info->tile[tileno].pdy[resno] + cstr_info->decomposition - resno );
+ int pcx = (int) pow( 2, cstr_info->tile[tileno].pdx[resno] + cstr_info->numdecompos - resno );
+ int pcy = (int) pow( 2, cstr_info->tile[tileno].pdy[resno] + cstr_info->numdecompos - resno );
int precno_x = precno - (int) floor( (float)precno/(float)pcnx ) * pcnx;
int precno_y = (int) floor( (float)precno/(float)pcnx );
for(y = y0; y < y1; y++) {
if (precno_y*pcy == y ) {
for (x = x0; x < x1; x++) {
if (precno_x*pcx == x ) {
- for (layno = 0; layno < cstr_info->layer; layno++) {
+ for (layno = 0; layno < cstr_info->numlayers; layno++) {
start_pos = cstr_info->tile[tileno].packet[pack_nb].start_pos;
end_ph_pos = cstr_info->tile[tileno].packet[pack_nb].end_ph_pos;
end_pos = cstr_info->tile[tileno].packet[pack_nb].end_pos;
- disto = cstr_info->tile[tileno].packet[pack_nb].disto;
- fprintf(stream, "%4d %6d %6d %6d %5d %7d %9d %9d %7d %8e\n",
- pack_nb, tileno, precno, compno, resno, layno, start_pos, end_ph_pos, end_pos, disto);
- total_disto += disto;
+ fprintf(stream, "%4d %6d %6d %6d %5d %7d %9d %9d %7d\n",
+ pack_nb, tileno, precno, compno, resno, layno, start_pos, end_ph_pos, end_pos);
pack_nb++;
}
}
@@ -707,35 +705,33 @@ bool wxJ2KHandler::write_index_file(opj_codestream_info_t *cstr_info, char *inde
} /* PCRL */
else { /* CPRL */
- fprintf(stream, "CPRL\npack_nb tileno compno precno resno layno start_pos end_ph_pos end_pos disto\n");
+ fprintf(stream, "CPRL\npack_nb tileno compno precno resno layno start_pos end_ph_pos end_pos\n");
- for (compno = 0; compno < cstr_info->comp; compno++) {
+ for (compno = 0; compno < cstr_info->numcomps; compno++) {
/* I suppose components have same XRsiz, YRsiz */
int x0 = cstr_info->tile_Ox + tileno - (int)floor( (float)tileno/(float)cstr_info->tw ) * cstr_info->tw * cstr_info->tile_x;
int y0 = cstr_info->tile_Ox + (int)floor( (float)tileno/(float)cstr_info->tw ) * cstr_info->tile_y;
int x1 = x0 + cstr_info->tile_x;
int y1 = y0 + cstr_info->tile_y;
- for (resno = 0; resno < cstr_info->decomposition + 1; resno++) {
+ for (resno = 0; resno < cstr_info->numdecompos + 1; resno++) {
int prec_max = cstr_info->tile[tileno].pw[resno] * cstr_info->tile[tileno].ph[resno];
for (precno = 0; precno < prec_max; precno++) {
int pcnx = cstr_info->tile[tileno].pw[resno];
- int pcx = (int) pow( 2, cstr_info->tile[tileno].pdx[resno] + cstr_info->decomposition - resno );
- int pcy = (int) pow( 2, cstr_info->tile[tileno].pdy[resno] + cstr_info->decomposition - resno );
+ int pcx = (int) pow( 2, cstr_info->tile[tileno].pdx[resno] + cstr_info->numdecompos - resno );
+ int pcy = (int) pow( 2, cstr_info->tile[tileno].pdy[resno] + cstr_info->numdecompos - resno );
int precno_x = precno - (int) floor( (float)precno/(float)pcnx ) * pcnx;
int precno_y = (int) floor( (float)precno/(float)pcnx );
for(y = y0; y < y1; y++) {
if (precno_y*pcy == y ) {
for (x = x0; x < x1; x++) {
if (precno_x*pcx == x ) {
- for (layno = 0; layno < cstr_info->layer; layno++) {
+ for (layno = 0; layno < cstr_info->numlayers; layno++) {
start_pos = cstr_info->tile[tileno].packet[pack_nb].start_pos;
end_ph_pos = cstr_info->tile[tileno].packet[pack_nb].end_ph_pos;
end_pos = cstr_info->tile[tileno].packet[pack_nb].end_pos;
- disto = cstr_info->tile[tileno].packet[pack_nb].disto;
- fprintf(stream, "%4d %6d %6d %6d %5d %7d %9d %9d %7d %8e\n",
- pack_nb, tileno, compno, precno, resno, layno, start_pos, end_ph_pos, end_pos, disto);
- total_disto += disto;
+ fprintf(stream, "%4d %6d %6d %6d %5d %7d %9d %9d %7d\n",
+ pack_nb, tileno, compno, precno, resno, layno, start_pos, end_ph_pos, end_pos);
pack_nb++;
}
}
@@ -748,11 +744,9 @@ bool wxJ2KHandler::write_index_file(opj_codestream_info_t *cstr_info, char *inde
} /* CPRL */
} /* tileno */
- fprintf(stream, "%8e\n", cstr_info->D_max); /* SE max */
- fprintf(stream, "%.8e\n", total_disto); /* SE totale */
fclose(stream);
- wxLogError(wxT("Generated index file %s"), index);
+ fprintf(stderr,"Generated index file %s\n", index);
return true;
}
diff --git a/OPJViewer/source/imagjp2.cpp b/OPJViewer/source/imagjp2.cpp
index 70be1555..7328e807 100644
--- a/OPJViewer/source/imagjp2.cpp
+++ b/OPJViewer/source/imagjp2.cpp
@@ -135,6 +135,7 @@ bool wxJP2Handler::LoadFile(wxImage *image, wxInputStream& stream, bool verbose,
unsigned char *src = NULL;
unsigned char *ptr;
int file_length;
+ opj_codestream_info_t cstr_info; /* Codestream information structure */
// destroy the image
image->Destroy();
@@ -193,7 +194,7 @@ bool wxJP2Handler::LoadFile(wxImage *image, wxInputStream& stream, bool verbose,
cio = opj_cio_open((opj_common_ptr)dinfo, src, file_length);
/* decode the stream and fill the image structure */
- opjimage = opj_decode(dinfo, cio);
+ opjimage = opj_decode(dinfo, cio, &cstr_info);
if (!opjimage) {
#ifndef __WXGTK__
wxMutexGuiEnter();
diff --git a/OPJViewer/source/imagmj2.cpp b/OPJViewer/source/imagmj2.cpp
index 1cd7244f..e2862916 100644
--- a/OPJViewer/source/imagmj2.cpp
+++ b/OPJViewer/source/imagmj2.cpp
@@ -618,6 +618,7 @@ bool wxMJ2Handler::LoadFile(wxImage *image, wxInputStream& stream, bool verbose,
unsigned char *ptr;
int file_length, jp2c_point, jp2h_point;
unsigned long int jp2hboxlen, jp2cboxlen;
+ opj_codestream_info_t cstr_info; /* Codestream information structure */
// destroy the image
image->Destroy();
@@ -699,7 +700,7 @@ bool wxMJ2Handler::LoadFile(wxImage *image, wxInputStream& stream, bool verbose,
cio = opj_cio_open((opj_common_ptr)dinfo, src, my_jPheadSIZE + jp2hboxlen + jp2cboxlen);
/* decode the stream and fill the image structure */
- opjimage = opj_decode(dinfo, cio);
+ opjimage = opj_decode(dinfo, cio, &cstr_info);
if (!opjimage) {
wxMutexGuiEnter();
wxLogError(wxT("MJ2: failed to decode image!"));