From 3fb3d19b52dc517b18c177e604d3e9ecf7fa607f Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Fri, 6 Aug 2010 03:11:08 +0000 Subject: [PATCH] * Reverting the CSJ2K Array.Copy -> Buffer.BlockCopy optimization for now since I didn't properly update the length parameter the first time around (LIBOMV-861) git-svn-id: http://libopenmetaverse.googlecode.com/svn/libopenmetaverse/trunk@3415 52acb1d6-8a22-11de-b505-999d5b087335 --- CSJ2K/Icc/Tags/ICCTextDescriptionType.cs | 2 +- CSJ2K/Icc/Tags/ICCTextType.cs | 2 +- CSJ2K/Util/SupportClass.cs | 4 +- CSJ2K/j2k/JJ2KExceptionHandler.cs | 6 +-- .../reader/FileBitstreamReaderAgent.cs | 2 +- .../j2k/codestream/writer/BitOutputBuffer.cs | 6 +-- CSJ2K/j2k/codestream/writer/PktEncoder.cs | 12 ++--- CSJ2K/j2k/codestream/writer/TagTreeEncoder.cs | 8 ++-- CSJ2K/j2k/entropy/decoder/ByteInputBuffer.cs | 8 ++-- CSJ2K/j2k/entropy/decoder/MQDecoder.cs | 2 +- CSJ2K/j2k/entropy/encoder/ByteOutputBuffer.cs | 4 +- .../j2k/entropy/encoder/CBlkRateDistStats.cs | 4 +- .../j2k/entropy/encoder/EBCOTRateAllocator.cs | 27 ++++++----- CSJ2K/j2k/entropy/encoder/LayersInfo.cs | 4 +- CSJ2K/j2k/entropy/encoder/MQCoder.cs | 2 +- CSJ2K/j2k/entropy/encoder/StdEntropyCoder.cs | 24 ---------- CSJ2K/j2k/image/DataBlkFloat.cs | 2 +- CSJ2K/j2k/image/DataBlkInt.cs | 2 +- .../image/forwcomptransf/ForwCompTransf.cs | 8 ++-- .../j2k/image/invcomptransf/InvCompTransf.cs | 8 ++-- CSJ2K/j2k/io/BufferedRandomAccessFile.cs | 2 +- CSJ2K/j2k/util/ArrayUtil.cs | 8 ++-- CSJ2K/j2k/util/FacilityManager.cs | 17 ++++++- CSJ2K/j2k/util/ISRandomAccessIO.cs | 11 ++--- CSJ2K/j2k/wavelet/synthesis/InvWTFull.cs | 48 ++++++++++--------- 25 files changed, 106 insertions(+), 117 deletions(-) diff --git a/CSJ2K/Icc/Tags/ICCTextDescriptionType.cs b/CSJ2K/Icc/Tags/ICCTextDescriptionType.cs index c29157a3..78543b12 100644 --- a/CSJ2K/Icc/Tags/ICCTextDescriptionType.cs +++ b/CSJ2K/Icc/Tags/ICCTextDescriptionType.cs @@ -56,7 +56,7 @@ namespace CSJ2K.Icc.Tags offset += ICCProfile.int_size; ascii = new byte[size - 1]; - Buffer.BlockCopy(data, offset, ascii, 0, size - 1); + Array.Copy(data, offset, ascii, 0, size - 1); } /// Return the string rep of this tag. diff --git a/CSJ2K/Icc/Tags/ICCTextType.cs b/CSJ2K/Icc/Tags/ICCTextType.cs index 9dcb8b8e..4fcb7142 100644 --- a/CSJ2K/Icc/Tags/ICCTextType.cs +++ b/CSJ2K/Icc/Tags/ICCTextType.cs @@ -50,7 +50,7 @@ namespace CSJ2K.Icc.Tags while (data[offset + size] != 0) ++size; ascii = new byte[size]; - Buffer.BlockCopy(data, offset, ascii, 0, size); + Array.Copy(data, offset, ascii, 0, size); } /// Return the string rep of this tag. diff --git a/CSJ2K/Util/SupportClass.cs b/CSJ2K/Util/SupportClass.cs index a199e0d9..611dc672 100644 --- a/CSJ2K/Util/SupportClass.cs +++ b/CSJ2K/Util/SupportClass.cs @@ -581,7 +581,7 @@ internal class SupportClass { if (count < readLimit) readLimit = count; - Buffer.BlockCopy(this.buffer, this.position, array, index, readLimit); + System.Array.Copy(this.buffer, this.position, array, index, readLimit); count -= readLimit; index += readLimit; this.position += readLimit; @@ -1510,7 +1510,7 @@ internal class SupportClass { if (count < readLimit) readLimit = count; - Buffer.BlockCopy(this.buffer, this.position, array, index, readLimit); + System.Array.Copy(this.buffer, this.position, array, index, readLimit); count -= readLimit; index += readLimit; this.position += readLimit; diff --git a/CSJ2K/j2k/JJ2KExceptionHandler.cs b/CSJ2K/j2k/JJ2KExceptionHandler.cs index 328a061b..9d12c4d4 100644 --- a/CSJ2K/j2k/JJ2KExceptionHandler.cs +++ b/CSJ2K/j2k/JJ2KExceptionHandler.cs @@ -82,13 +82,13 @@ namespace CSJ2K.j2k // including this method in the stack. //UPGRADE_ISSUE: Method 'java.lang.Throwable.fillInStackTrace' was not converted. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1000_javalangThrowablefillInStackTrace'" //e.fillInStackTrace(); - SupportClass.WriteStackTrace(e, Console.Error); + //SupportClass.WriteStackTrace(e, Console.Error); // Print an explicative message - //System.Console.Error.WriteLine("The Thread is being terminated bacause an " + "Exception (shown above)\n" + "has been thrown and no special action was " + "defined for this Thread."); + System.Console.Error.WriteLine("The Thread is being terminated bacause an " + "Exception (shown above)\n" + "has been thrown and no special action was " + "defined for this Thread."); // Stop the thread (do not use stop, since it's deprecated in // Java 1.2) //UPGRADE_NOTE: Exception 'java.lang.ThreadDeath' was converted to 'System.ApplicationException' which has different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1100'" - throw new System.ApplicationException(e.Message, e); + throw e; } } } \ No newline at end of file diff --git a/CSJ2K/j2k/codestream/reader/FileBitstreamReaderAgent.cs b/CSJ2K/j2k/codestream/reader/FileBitstreamReaderAgent.cs index 7fa04c2d..e992cad6 100644 --- a/CSJ2K/j2k/codestream/reader/FileBitstreamReaderAgent.cs +++ b/CSJ2K/j2k/codestream/reader/FileBitstreamReaderAgent.cs @@ -2366,7 +2366,7 @@ namespace CSJ2K.j2k.codestream.reader catch (System.IO.IOException e) { SupportClass.WriteStackTrace(e, Console.Error); - throw new System.ApplicationException("IO Error when reading tile " + x + " x " + y + ": " + e.Message, e); + throw new System.ApplicationException("IO Error when reading tile " + x + " x " + y); } } diff --git a/CSJ2K/j2k/codestream/writer/BitOutputBuffer.cs b/CSJ2K/j2k/codestream/writer/BitOutputBuffer.cs index c89d8472..7e67929b 100644 --- a/CSJ2K/j2k/codestream/writer/BitOutputBuffer.cs +++ b/CSJ2K/j2k/codestream/writer/BitOutputBuffer.cs @@ -183,7 +183,7 @@ namespace CSJ2K.j2k.codestream.writer // We are at end of 'buf' => extend it byte[] oldbuf = buf; buf = new byte[oldbuf.Length + SZ_INCR]; - System.Buffer.BlockCopy(oldbuf, 0, buf, 0, oldbuf.Length); + Array.Copy(oldbuf, 0, buf, 0, oldbuf.Length); } } } @@ -213,7 +213,7 @@ namespace CSJ2K.j2k.codestream.writer // Not enough place, extend it byte[] oldbuf = buf; buf = new byte[oldbuf.Length + SZ_INCR]; - System.Buffer.BlockCopy(oldbuf, 0, buf, 0, oldbuf.Length); + Array.Copy(oldbuf, 0, buf, 0, oldbuf.Length); // SZ_INCR is always 6 or more, so it is enough to hold all the // new bits plus the ones to come after } @@ -297,7 +297,7 @@ namespace CSJ2K.j2k.codestream.writer { data = new byte[(avbits == 8)?curbyte:curbyte + 1]; } - System.Buffer.BlockCopy(buf, 0, data, 0, (avbits == 8) ? curbyte : curbyte + 1); + Array.Copy(buf, 0, data, 0, (avbits == 8)?curbyte:curbyte + 1); return data; } diff --git a/CSJ2K/j2k/codestream/writer/PktEncoder.cs b/CSJ2K/j2k/codestream/writer/PktEncoder.cs index c41166b3..3861977e 100644 --- a/CSJ2K/j2k/codestream/writer/PktEncoder.cs +++ b/CSJ2K/j2k/codestream/writer/PktEncoder.cs @@ -1258,12 +1258,12 @@ namespace CSJ2K.j2k.codestream.writer if (cur_prevtIdxs[b] < 0) { cblen = cur_cbs[b].truncRates[cur_cbs[b].truncIdxs[cur_tIndx[b]]]; - Buffer.BlockCopy(cur_cbs[b].data, 0, lbbuf, lblen, cblen); + Array.Copy(cur_cbs[b].data, 0, lbbuf, lblen, cblen); } else { cblen = cur_cbs[b].truncRates[cur_cbs[b].truncIdxs[cur_tIndx[b]]] - cur_cbs[b].truncRates[cur_cbs[b].truncIdxs[cur_prevtIdxs[b]]]; - Buffer.BlockCopy(cur_cbs[b].data, cur_cbs[b].truncRates[cur_cbs[b].truncIdxs[cur_prevtIdxs[b]]], lbbuf, lblen, cblen); + Array.Copy(cur_cbs[b].data, cur_cbs[b].truncRates[cur_cbs[b].truncIdxs[cur_prevtIdxs[b]]], lbbuf, lblen, cblen); } lblen += cblen; @@ -1368,9 +1368,9 @@ namespace CSJ2K.j2k.codestream.writer for (int s = minsbi; s < maxsbi; s++) { // Save 'lblock' - Buffer.BlockCopy(lblock_t_c[r][s], 0, bak_lblock_t_c[r][s], 0, lblock_t_c[r][s].Length); + Array.Copy(lblock_t_c[r][s], 0, bak_lblock_t_c[r][s], 0, lblock_t_c[r][s].Length); // Save 'prevtIdxs' - Buffer.BlockCopy(prevtIdxs_t_c_r[s], 0, bak_prevtIdxs_t_c_r[s], 0, prevtIdxs_t_c_r[s].Length); + Array.Copy(prevtIdxs_t_c_r[s], 0, bak_prevtIdxs_t_c_r[s], 0, prevtIdxs_t_c_r[s].Length); } // End loop on subbands // Loop on precincts @@ -1447,9 +1447,9 @@ namespace CSJ2K.j2k.codestream.writer for (int s = minsbi; s < maxsbi; s++) { // Restore 'lblock' - Buffer.BlockCopy(bak_lblock_t_c[r][s], 0, lblock_t_c[r][s], 0, lblock_t_c[r][s].Length); + Array.Copy(bak_lblock_t_c[r][s], 0, lblock_t_c[r][s], 0, lblock_t_c[r][s].Length); // Restore 'prevtIdxs' - Buffer.BlockCopy(bak_prevtIdxs_t_c_r[s], 0, prevtIdxs_t_c_r[s], 0, prevtIdxs_t_c_r[s].Length); + Array.Copy(bak_prevtIdxs_t_c_r[s], 0, prevtIdxs_t_c_r[s], 0, prevtIdxs_t_c_r[s].Length); } // End loop on subbands // Loop on precincts diff --git a/CSJ2K/j2k/codestream/writer/TagTreeEncoder.cs b/CSJ2K/j2k/codestream/writer/TagTreeEncoder.cs index 4180028b..11acfdd4 100644 --- a/CSJ2K/j2k/codestream/writer/TagTreeEncoder.cs +++ b/CSJ2K/j2k/codestream/writer/TagTreeEncoder.cs @@ -515,8 +515,8 @@ namespace CSJ2K.j2k.codestream.writer // Copy the arrays for (k = treeV.Length - 1; k >= 0; k--) { - Buffer.BlockCopy(treeV[k], 0, treeVbak[k], 0, treeV[k].Length); - Buffer.BlockCopy(treeS[k], 0, treeSbak[k], 0, treeS[k].Length); + Array.Copy(treeV[k], 0, treeVbak[k], 0, treeV[k].Length); + Array.Copy(treeS[k], 0, treeSbak[k], 0, treeS[k].Length); } // Set saved state @@ -544,8 +544,8 @@ namespace CSJ2K.j2k.codestream.writer // Copy the arrays for (k = lvls - 1; k >= 0; k--) { - Buffer.BlockCopy(treeVbak[k], 0, treeV[k], 0, treeV[k].Length); - Buffer.BlockCopy(treeSbak[k], 0, treeS[k], 0, treeS[k].Length); + Array.Copy(treeVbak[k], 0, treeV[k], 0, treeV[k].Length); + Array.Copy(treeSbak[k], 0, treeS[k], 0, treeS[k].Length); } } diff --git a/CSJ2K/j2k/entropy/decoder/ByteInputBuffer.cs b/CSJ2K/j2k/entropy/decoder/ByteInputBuffer.cs index 7141639d..5f68fabd 100644 --- a/CSJ2K/j2k/entropy/decoder/ByteInputBuffer.cs +++ b/CSJ2K/j2k/entropy/decoder/ByteInputBuffer.cs @@ -196,7 +196,7 @@ namespace CSJ2K.j2k.entropy.decoder if (count + len <= buf.Length) { // Enough place in 'buf' - Buffer.BlockCopy(data, off, buf, count, len); + Array.Copy(data, off, buf, count, len); count += len; } else @@ -205,7 +205,7 @@ namespace CSJ2K.j2k.entropy.decoder { // Enough place in 'buf' if we move input data // Move buffer - Buffer.BlockCopy(buf, pos, buf, 0, count - pos); + Array.Copy(buf, pos, buf, 0, count - pos); } else { @@ -213,12 +213,12 @@ namespace CSJ2K.j2k.entropy.decoder byte[] oldbuf = buf; buf = new byte[count - pos + len]; // Copy buffer - Buffer.BlockCopy(oldbuf, count, buf, 0, count - pos); + Array.Copy(oldbuf, count, buf, 0, count - pos); } count -= pos; pos = 0; // Copy new data - Buffer.BlockCopy(data, off, buf, count, len); + Array.Copy(data, off, buf, count, len); count += len; } } diff --git a/CSJ2K/j2k/entropy/decoder/MQDecoder.cs b/CSJ2K/j2k/entropy/decoder/MQDecoder.cs index 9147cbbc..69d9001c 100644 --- a/CSJ2K/j2k/entropy/decoder/MQDecoder.cs +++ b/CSJ2K/j2k/entropy/decoder/MQDecoder.cs @@ -756,7 +756,7 @@ namespace CSJ2K.j2k.entropy.decoder /// public void resetCtxts() { - Buffer.BlockCopy(initStates, 0, I, 0, I.Length); + Array.Copy(initStates, 0, I, 0, I.Length); ArrayUtil.intArraySet(mPS, 0); } diff --git a/CSJ2K/j2k/entropy/encoder/ByteOutputBuffer.cs b/CSJ2K/j2k/entropy/encoder/ByteOutputBuffer.cs index 53cce5e0..1b5bc3cf 100644 --- a/CSJ2K/j2k/entropy/encoder/ByteOutputBuffer.cs +++ b/CSJ2K/j2k/entropy/encoder/ByteOutputBuffer.cs @@ -113,7 +113,7 @@ namespace CSJ2K.j2k.entropy.encoder // Resize buffer byte[] tmpbuf = buf; buf = new byte[buf.Length + BUF_INC]; - Buffer.BlockCopy(tmpbuf, 0, buf, 0, count); + Array.Copy(tmpbuf, 0, buf, 0, count); } buf[count++] = (byte) b; } @@ -137,7 +137,7 @@ namespace CSJ2K.j2k.entropy.encoder public virtual void toByteArray(int off, int len, byte[] outbuf, int outoff) { // Copy the data - Buffer.BlockCopy(buf, off, outbuf, outoff, len); + Array.Copy(buf, off, outbuf, outoff, len); } /// Returns the number of valid bytes in the output buffer (count class diff --git a/CSJ2K/j2k/entropy/encoder/CBlkRateDistStats.cs b/CSJ2K/j2k/entropy/encoder/CBlkRateDistStats.cs index fda0519c..09f9732b 100644 --- a/CSJ2K/j2k/entropy/encoder/CBlkRateDistStats.cs +++ b/CSJ2K/j2k/entropy/encoder/CBlkRateDistStats.cs @@ -334,13 +334,13 @@ ploop: ; if (termp != null) { isTermPass = new bool[n]; - Buffer.BlockCopy(termp, 0, isTermPass, 0, n); + Array.Copy(termp, 0, isTermPass, 0, n); } else { isTermPass = null; } - Buffer.BlockCopy(rates, 0, truncRates, 0, n); + Array.Copy(rates, 0, truncRates, 0, n); for (k = first_pnt, p = - 1, i = 0; k < n; k++) { if (rates[k] > 0) diff --git a/CSJ2K/j2k/entropy/encoder/EBCOTRateAllocator.cs b/CSJ2K/j2k/entropy/encoder/EBCOTRateAllocator.cs index 857b1a1a..e29cd506 100644 --- a/CSJ2K/j2k/entropy/encoder/EBCOTRateAllocator.cs +++ b/CSJ2K/j2k/entropy/encoder/EBCOTRateAllocator.cs @@ -732,6 +732,7 @@ namespace CSJ2K.j2k.entropy.encoder SubbandAn root, sb; int cblkToEncode = 0; int nEncCblk = 0; + ProgressWatch pw = FacilityManager.ProgressWatch; //Get all coded code-blocks Goto first tile src.setTile(0, 0); @@ -765,10 +766,10 @@ namespace CSJ2K.j2k.entropy.encoder } } } - //if (pw != null) - //{ - // pw.initProgressWatch(0, cblkToEncode, "Encoding tile " + t + "..."); - //} + if (pw != null) + { + pw.initProgressWatch(0, cblkToEncode, "Encoding tile " + t + "..."); + } for (c = 0; c < numComps; c++) { @@ -781,11 +782,11 @@ namespace CSJ2K.j2k.entropy.encoder stime = (System.DateTime.Now.Ticks - 621355968000000000) / 10000; #endif - //if (pw != null) - //{ - // nEncCblk++; - // pw.updateProgressWatch(nEncCblk, null); - //} + if (pw != null) + { + nEncCblk++; + pw.updateProgressWatch(nEncCblk, null); + } subb = ccb.sb; @@ -826,10 +827,10 @@ namespace CSJ2K.j2k.entropy.encoder } } - //if (pw != null) - //{ - // pw.terminateProgressWatch(); - //} + if (pw != null) + { + pw.terminateProgressWatch(); + } //Goto next tile if (t < numTiles - 1) diff --git a/CSJ2K/j2k/entropy/encoder/LayersInfo.cs b/CSJ2K/j2k/entropy/encoder/LayersInfo.cs index 58e5d371..b99e5ec7 100644 --- a/CSJ2K/j2k/entropy/encoder/LayersInfo.cs +++ b/CSJ2K/j2k/entropy/encoder/LayersInfo.cs @@ -236,8 +236,8 @@ namespace CSJ2K.j2k.entropy.encoder // both arrays always have same size optbrate = new float[optbrate.Length + SZ_INCR]; extralyrs = new int[extralyrs.Length + SZ_INCR]; - Buffer.BlockCopy(tbr, 0, optbrate, 0, nopt); - Buffer.BlockCopy(tel, 0, extralyrs, 0, nopt); + Array.Copy(tbr, 0, optbrate, 0, nopt); + Array.Copy(tel, 0, extralyrs, 0, nopt); } // Add new optimization point optbrate[nopt] = brate; diff --git a/CSJ2K/j2k/entropy/encoder/MQCoder.cs b/CSJ2K/j2k/entropy/encoder/MQCoder.cs index e3c7700c..520d87ce 100644 --- a/CSJ2K/j2k/entropy/encoder/MQCoder.cs +++ b/CSJ2K/j2k/entropy/encoder/MQCoder.cs @@ -1323,7 +1323,7 @@ namespace CSJ2K.j2k.entropy.encoder /// public void resetCtxts() { - Buffer.BlockCopy(initStates, 0, I, 0, I.Length); + Array.Copy(initStates, 0, I, 0, I.Length); ArrayUtil.intArraySet(mPS, 0); } diff --git a/CSJ2K/j2k/entropy/encoder/StdEntropyCoder.cs b/CSJ2K/j2k/entropy/encoder/StdEntropyCoder.cs index fc44ff87..f396aaf6 100644 --- a/CSJ2K/j2k/entropy/encoder/StdEntropyCoder.cs +++ b/CSJ2K/j2k/entropy/encoder/StdEntropyCoder.cs @@ -743,30 +743,6 @@ namespace CSJ2K.j2k.entropy.encoder Enclosing_Instance.completedComps[c].Add(this); } } - - /// Returns the wall time spent by this compressor for component 'c' - /// since the last call to this method (or the creation of this - /// compressor if not yet called). If DO_TIMING is false 0 is returned. - /// - /// - /// The wall time in milliseconds spent by this compressor - /// since the last call to this method. - /// - /// - //UPGRADE_NOTE: Synchronized keyword was removed from method 'getTiming'. Lock expression was added. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1027'" - internal virtual long getTiming(int c) - { -#if DO_TIMING - lock (this) - { - long t = time[c]; - time[c] = 0L; - return t; - } -#else - return 0L; -#endif - } } /// Instantiates a new entropy coder engine, with the specified source of diff --git a/CSJ2K/j2k/image/DataBlkFloat.cs b/CSJ2K/j2k/image/DataBlkFloat.cs index f762bf67..a3aed3cc 100644 --- a/CSJ2K/j2k/image/DataBlkFloat.cs +++ b/CSJ2K/j2k/image/DataBlkFloat.cs @@ -188,7 +188,7 @@ namespace CSJ2K.j2k.image this.scanw = this.w; this.data = new float[this.w * this.h]; for (int i = 0; i < this.h; i++) - Buffer.BlockCopy(src.data, i * src.scanw, this.data, i * this.scanw, this.w); + Array.Copy(src.data, i * src.scanw, this.data, i * this.scanw, this.w); } /// Returns a string of informations about the DataBlkInt. diff --git a/CSJ2K/j2k/image/DataBlkInt.cs b/CSJ2K/j2k/image/DataBlkInt.cs index 22a1f3c6..b785f2c7 100644 --- a/CSJ2K/j2k/image/DataBlkInt.cs +++ b/CSJ2K/j2k/image/DataBlkInt.cs @@ -189,7 +189,7 @@ namespace CSJ2K.j2k.image this.scanw = this.w; this.data_array = new int[this.w * this.h]; for (int i = 0; i < this.h; i++) - Buffer.BlockCopy(src.data_array, i * src.scanw, this.data_array, i * this.scanw, this.w); + Array.Copy(src.data_array, i * src.scanw, this.data_array, i * this.scanw, this.w); } /// Returns a string of informations about the DataBlkInt. diff --git a/CSJ2K/j2k/image/forwcomptransf/ForwCompTransf.cs b/CSJ2K/j2k/image/forwcomptransf/ForwCompTransf.cs index 89c73eb4..00af357f 100644 --- a/CSJ2K/j2k/image/forwcomptransf/ForwCompTransf.cs +++ b/CSJ2K/j2k/image/forwcomptransf/ForwCompTransf.cs @@ -246,14 +246,14 @@ namespace CSJ2K.j2k.image.forwcomptransf switch (ttype) { - case NONE: - Buffer.BlockCopy(ntdepth, 0, tdepth, 0, ntdepth.Length); + case NONE: + Array.Copy(ntdepth, 0, tdepth, 0, ntdepth.Length); break; case FORW_RCT: if (ntdepth.Length > 3) { - Buffer.BlockCopy(ntdepth, 3, tdepth, 3, ntdepth.Length - 3); + Array.Copy(ntdepth, 3, tdepth, 3, ntdepth.Length - 3); } // The formulas are: // tdepth[0] = ceil(log2(2^(ntdepth[0])+2^ntdepth[1]+ @@ -271,7 +271,7 @@ namespace CSJ2K.j2k.image.forwcomptransf case FORW_ICT: if (ntdepth.Length > 3) { - Buffer.BlockCopy(ntdepth, 3, tdepth, 3, ntdepth.Length - 3); + Array.Copy(ntdepth, 3, tdepth, 3, ntdepth.Length - 3); } // The MathUtil.log2(x) function calculates floor(log2(x)), so we // use 'MathUtil.log2(2*x-1)+1', which calculates ceil(log2(x)) diff --git a/CSJ2K/j2k/image/invcomptransf/InvCompTransf.cs b/CSJ2K/j2k/image/invcomptransf/InvCompTransf.cs index 489e250e..dd88510a 100644 --- a/CSJ2K/j2k/image/invcomptransf/InvCompTransf.cs +++ b/CSJ2K/j2k/image/invcomptransf/InvCompTransf.cs @@ -292,14 +292,14 @@ namespace CSJ2K.j2k.image.invcomptransf switch (ttype) { - case NONE: - Buffer.BlockCopy(utdepth, 0, tdepth, 0, utdepth.Length); + case NONE: + Array.Copy(utdepth, 0, tdepth, 0, utdepth.Length); break; case INV_RCT: if (utdepth.Length > 3) { - Buffer.BlockCopy(utdepth, 3, tdepth, 3, utdepth.Length - 3); + Array.Copy(utdepth, 3, tdepth, 3, utdepth.Length - 3); } // The formulas are: // tdepth[0] = ceil(log2(2^(utdepth[0])+2^utdepth[1]+ @@ -317,7 +317,7 @@ namespace CSJ2K.j2k.image.invcomptransf case INV_ICT: if (utdepth.Length > 3) { - Buffer.BlockCopy(utdepth, 3, tdepth, 3, utdepth.Length - 3); + Array.Copy(utdepth, 3, tdepth, 3, utdepth.Length - 3); } // The MathUtil.log2(x) function calculates floor(log2(x)), so we // use 'MathUtil.log2(2*x-1)+1', which calculates ceil(log2(x)) diff --git a/CSJ2K/j2k/io/BufferedRandomAccessFile.cs b/CSJ2K/j2k/io/BufferedRandomAccessFile.cs index d9436c2a..b97d7150 100644 --- a/CSJ2K/j2k/io/BufferedRandomAccessFile.cs +++ b/CSJ2K/j2k/io/BufferedRandomAccessFile.cs @@ -475,7 +475,7 @@ namespace CSJ2K.j2k.io clen = maxByte - position; if (clen > len) clen = len; - Buffer.BlockCopy(byteBuffer, position, b, off, clen); + Array.Copy(byteBuffer, position, b, off, clen); position += clen; off += clen; len -= clen; diff --git a/CSJ2K/j2k/util/ArrayUtil.cs b/CSJ2K/j2k/util/ArrayUtil.cs index 01a16fdb..2bbe89ab 100644 --- a/CSJ2K/j2k/util/ArrayUtil.cs +++ b/CSJ2K/j2k/util/ArrayUtil.cs @@ -103,12 +103,12 @@ namespace CSJ2K.j2k.util for (; i <= len2; i <<= 1) { // Copy values doubling size each time - Buffer.BlockCopy(arr, 0, arr, i, i); + Array.Copy(arr, 0, arr, i, i); } if (i < len) { // Copy values to end - Buffer.BlockCopy(arr, 0, arr, i, len - i); + Array.Copy(arr, 0, arr, i, len - i); } } } @@ -155,12 +155,12 @@ namespace CSJ2K.j2k.util for (; i <= len2; i <<= 1) { // Copy values doubling size each time - Buffer.BlockCopy(arr, 0, arr, i, i); + Array.Copy(arr, 0, arr, i, i); } if (i < len) { // Copy values to end - Buffer.BlockCopy(arr, 0, arr, i, len - i); + Array.Copy(arr, 0, arr, i, len - i); } } } diff --git a/CSJ2K/j2k/util/FacilityManager.cs b/CSJ2K/j2k/util/FacilityManager.cs index 618c0197..661eeb5f 100644 --- a/CSJ2K/j2k/util/FacilityManager.cs +++ b/CSJ2K/j2k/util/FacilityManager.cs @@ -68,7 +68,22 @@ namespace CSJ2K.j2k.util /// /// public class FacilityManager - { + { + /// Returns the ProgressWatch instance registered with the current + /// thread (the thread that calls this method). If the current + /// thread has no registered ProgressWatch, then the default one is used. + /// + /// + public static ProgressWatch ProgressWatch + { + get + { + ProgressWatch pw = (ProgressWatch) watchProgList[SupportClass.ThreadClass.Current()]; + return (pw == null)?defWatchProg:pw; + } + + } + /// The loggers associated to different threads //UPGRADE_NOTE: Final was removed from the declaration of 'loggerList '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'" private static readonly System.Collections.Hashtable loggerList = System.Collections.Hashtable.Synchronized(new System.Collections.Hashtable()); diff --git a/CSJ2K/j2k/util/ISRandomAccessIO.cs b/CSJ2K/j2k/util/ISRandomAccessIO.cs index ebc9ebbc..a3b634ef 100644 --- a/CSJ2K/j2k/util/ISRandomAccessIO.cs +++ b/CSJ2K/j2k/util/ISRandomAccessIO.cs @@ -217,7 +217,7 @@ namespace CSJ2K.j2k.util { throw new System.IO.IOException("Out of memory to cache input data"); } - Buffer.BlockCopy(buf, 0, newbuf, 0, len); + Array.Copy(buf, 0, newbuf, 0, len); buf = newbuf; } @@ -321,11 +321,6 @@ namespace CSJ2K.j2k.util { throw new System.IO.EndOfStreamException(); } - - if (off < 0) - { - throw new System.IO.EndOfStreamException("Cannot seek to a negative position"); - } } pos = off; } @@ -415,7 +410,7 @@ namespace CSJ2K.j2k.util if (pos + n <= len) { // common, fast case - Buffer.BlockCopy(buf, pos, b, off, n); + Array.Copy(buf, pos, b, off, n); pos += n; return ; } @@ -428,7 +423,7 @@ namespace CSJ2K.j2k.util { throw new System.IO.EndOfStreamException(); } - Buffer.BlockCopy(buf, pos, b, off, n); + Array.Copy(buf, pos, b, off, n); pos += n; } diff --git a/CSJ2K/j2k/wavelet/synthesis/InvWTFull.cs b/CSJ2K/j2k/wavelet/synthesis/InvWTFull.cs index b2b72606..0e3ba9c3 100644 --- a/CSJ2K/j2k/wavelet/synthesis/InvWTFull.cs +++ b/CSJ2K/j2k/wavelet/synthesis/InvWTFull.cs @@ -79,7 +79,11 @@ namespace CSJ2K.j2k.wavelet.synthesis /// /// public class InvWTFull:InverseWT - { + { + + /// Reference to the ProgressWatch instance if any + private ProgressWatch pw = null; + /// The total number of code-blocks to decode private int cblkToDecode = 0; @@ -124,6 +128,7 @@ namespace CSJ2K.j2k.wavelet.synthesis int nc = src.NumComps; reconstructedComps = new DataBlk[nc]; ndl = new int[nc]; + pw = FacilityManager.ProgressWatch; } /// Returns the reversibility of the current subband. It computes @@ -293,10 +298,10 @@ namespace CSJ2K.j2k.wavelet.synthesis } //Reconstruct source image waveletTreeReconstruction(reconstructedComps[c], src.getSynSubbandTree(tIdx, c), c); - //if (pw != null && c == src.NumComps - 1) - //{ - // pw.terminateProgressWatch(); - //} + if (pw != null && c == src.NumComps - 1) + { + pw.terminateProgressWatch(); + } } if (blk.DataType != dtype) @@ -555,12 +560,12 @@ namespace CSJ2K.j2k.wavelet.synthesis if (!sb.isNode) { int i, m, n; - Array src_dataArray, dst_dataArray; + System.Object src_data, dst_data; Coord ncblks; - + if (sb.w == 0 || sb.h == 0) { - return; // If empty subband do nothing + return ; // If empty subband do nothing } // Get all code-blocks in subband @@ -572,27 +577,24 @@ namespace CSJ2K.j2k.wavelet.synthesis { subbData = new DataBlkFloat(); } - ncblks = sb.numCb; - dst_dataArray = (Array)img.Data; - + dst_data = img.Data; for (m = 0; m < ncblks.y; m++) { for (n = 0; n < ncblks.x; n++) { subbData = src.getInternCodeBlock(c, m, n, sb, subbData); - src_dataArray = (Array)subbData.Data; - - //if (pw != null) - //{ - // nDecCblk++; - // pw.updateProgressWatch(nDecCblk, null); - //} + src_data = subbData.Data; + if (pw != null) + { + nDecCblk++; + pw.updateProgressWatch(nDecCblk, null); + } // Copy the data line by line for (i = subbData.h - 1; i >= 0; i--) { // CONVERSION PROBLEM - Buffer.BlockCopy(src_dataArray, subbData.offset + i * subbData.scanw, dst_dataArray, (subbData.uly + i) * img.w + subbData.ulx, subbData.w); + Array.Copy((System.Array)src_data, subbData.offset + i * subbData.scanw, (System.Array)dst_data, (subbData.uly + i) * img.w + subbData.ulx, subbData.w); } } } @@ -699,10 +701,10 @@ namespace CSJ2K.j2k.wavelet.synthesis } // Loop on components nDecCblk = 0; - //if (pw != null) - //{ - // pw.initProgressWatch(0, cblkToDecode, "Decoding tile " + tIdx + "..."); - //} + if (pw != null) + { + pw.initProgressWatch(0, cblkToDecode, "Decoding tile " + tIdx + "..."); + } } /// Advances to the next tile, in standard scan-line order (by rows then