diff --git a/.gitattributes b/.gitattributes
index d0f0d3df..ded6cb71 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -1,17 +1,9 @@
# These files are text eol=lf and should be normalized (convert crlf => lf)
-*.cs text eol=lf diff=csharp
-*.xaml text eol=lf
-*.csproj text eol=lf
-*.sln text eol=lf
-*.tt text eol=lf
-*.ps1 text eol=lf
-*.cmd text eol=lf
-*.msbuild text eol=lf
-*.md text eol=lf
-
+* text=auto eol=lf
+*.{cmd,[cC][mM][dD]} text eol=crlf
+*.{bat,[bB][aA][tT]} text eol=crlf
# Images should be treated as binary
# (binary is a macro for -text eol=lf -diff)
*.png binary
*.jepg binary
-
*.sdf binary
diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml
new file mode 100644
index 00000000..fff48955
--- /dev/null
+++ b/.github/workflows/dotnet.yml
@@ -0,0 +1,27 @@
+name: dotnet
+
+on:
+ push:
+ branches: [ develop ]
+ pull_request:
+ branches: [ develop ]
+
+jobs:
+ build:
+
+ runs-on: ubuntu-latest
+
+ steps:
+ - uses: actions/checkout@v4
+ with:
+ fetch-depth: 0 # Required for Nerdbank.GitVersioning
+ - name: Setup .NET
+ uses: actions/setup-dotnet@v4
+ with:
+ dotnet-version: '8.0.x'
+ - name: Restore dependencies
+ run: dotnet restore
+ - name: Build
+ run: dotnet build --no-restore
+ - name: Test
+ run: dotnet test --no-build --verbosity normal --filter "Category!=Network&Category!=Benchmark"
diff --git a/.github/workflows/publish-nuget.yml b/.github/workflows/publish-nuget.yml
new file mode 100644
index 00000000..16969201
--- /dev/null
+++ b/.github/workflows/publish-nuget.yml
@@ -0,0 +1,63 @@
+name: Publish NuGet Packages
+
+on:
+ push:
+ tags:
+ - 'v*'
+
+jobs:
+ publish:
+ runs-on: ubuntu-latest
+
+ permissions:
+ packages: write
+ contents: read
+
+ steps:
+ - name: Checkout (full history for Nerdbank.GitVersioning)
+ uses: actions/checkout@v4
+ with:
+ fetch-depth: 0
+
+ - name: Setup .NET
+ uses: actions/setup-dotnet@v4
+ with:
+ dotnet-version: '8.0.x'
+
+ - name: Add GitHub Packages source
+ run: |
+ dotnet nuget add source \
+ "https://nuget.pkg.github.com/OpenSim-NGC/index.json" \
+ --name "github" \
+ --username "${{ github.actor }}" \
+ --password "${{ secrets.GITHUB_TOKEN }}" \
+ --store-password-in-clear-text
+
+ - name: Restore dependencies
+ run: dotnet restore OpenMetaverse.sln
+
+ - name: Build (Release)
+ run: dotnet build OpenMetaverse.sln -c Release --no-restore
+
+ - name: Pack library projects
+ run: |
+ mkdir -p ./nupkgs
+ for proj in \
+ OpenMetaverse.Types/OpenMetaverse.Types.csproj \
+ OpenMetaverse.StructuredData/OpenMetaverse.StructuredData.csproj \
+ OpenMetaverse/OpenMetaverse.csproj \
+ OpenMetaverse.Rendering.Simple/OpenMetaverse.Rendering.Simple.csproj \
+ OpenMetaverse.Rendering.Meshmerizer/OpenMetaverse.Rendering.Meshmerizer.csproj; do
+ dotnet pack "$proj" \
+ -c Release \
+ --no-build \
+ --include-symbols \
+ -o ./nupkgs
+ done
+
+ - name: Publish packages to GitHub Packages
+ run: |
+ dotnet nuget push "./nupkgs/*.nupkg" \
+ --api-key "${{ secrets.GITHUB_TOKEN }}" \
+ --source "github" \
+ --skip-duplicate
diff --git a/.gitignore b/.gitignore
index 9a7f6e27..52a02ba9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,9 +3,12 @@ compile.bat
*.userprefs
*.suo
*.cache
-
+*.csproj.lscache
.vs/
[Oo]bj/
[Bb]in/
+[Bb]uild/
PublishProfiles/
-
+build_log.txt
+build_output.txt
+build_status.txt
\ No newline at end of file
diff --git a/bin/Be.Windows.Forms.HexBox.dll b/AppData/Be.Windows.Forms.HexBox.dll
similarity index 100%
rename from bin/Be.Windows.Forms.HexBox.dll
rename to AppData/Be.Windows.Forms.HexBox.dll
diff --git a/bin/GlacialList.dll b/AppData/GlacialList.dll
similarity index 100%
rename from bin/GlacialList.dll
rename to AppData/GlacialList.dll
diff --git a/bin/GridImageUpload.exe.config b/AppData/GridImageUpload.exe.config
similarity index 100%
rename from bin/GridImageUpload.exe.config
rename to AppData/GridImageUpload.exe.config
diff --git a/AppData/ICSharpCode.SharpZipLib.dll b/AppData/ICSharpCode.SharpZipLib.dll
new file mode 100755
index 00000000..3b268b7c
Binary files /dev/null and b/AppData/ICSharpCode.SharpZipLib.dll differ
diff --git a/bin/OpenMetaverse.Rendering.Linden.dll b/AppData/OpenMetaverse.Rendering.Linden.dll
similarity index 100%
rename from bin/OpenMetaverse.Rendering.Linden.dll
rename to AppData/OpenMetaverse.Rendering.Linden.dll
diff --git a/AppData/OpenMetaverse.dll.config b/AppData/OpenMetaverse.dll.config
new file mode 100755
index 00000000..20b1df5e
--- /dev/null
+++ b/AppData/OpenMetaverse.dll.config
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
diff --git a/bin/SmartThreadPool.dll b/AppData/SmartThreadPool.dll
similarity index 100%
rename from bin/SmartThreadPool.dll
rename to AppData/SmartThreadPool.dll
diff --git a/bin/Tao.OpenGl.dll b/AppData/Tao.OpenGl.dll
similarity index 100%
rename from bin/Tao.OpenGl.dll
rename to AppData/Tao.OpenGl.dll
diff --git a/bin/Tao.OpenGl.dll.config b/AppData/Tao.OpenGl.dll.config
similarity index 100%
rename from bin/Tao.OpenGl.dll.config
rename to AppData/Tao.OpenGl.dll.config
diff --git a/bin/Tao.Platform.Windows.dll b/AppData/Tao.Platform.Windows.dll
similarity index 100%
rename from bin/Tao.Platform.Windows.dll
rename to AppData/Tao.Platform.Windows.dll
diff --git a/bin/WinGridProxy.exe.config b/AppData/WinGridProxy.exe.config
similarity index 100%
rename from bin/WinGridProxy.exe.config
rename to AppData/WinGridProxy.exe.config
diff --git a/AppData/XMLRPC.dll b/AppData/XMLRPC.dll
new file mode 100755
index 00000000..e6fe0eb3
Binary files /dev/null and b/AppData/XMLRPC.dll differ
diff --git a/bin/openmetaverse_data/avatar_lad.xml b/AppData/openmetaverse_data/avatar_lad.xml
similarity index 69%
rename from bin/openmetaverse_data/avatar_lad.xml
rename to AppData/openmetaverse_data/avatar_lad.xml
index 5d6b10c0..0c3fa9d4 100644
--- a/bin/openmetaverse_data/avatar_lad.xml
+++ b/AppData/openmetaverse_data/avatar_lad.xml
@@ -1,6 +1,6 @@
+ version="2.0" wearable_definition_version="22">
@@ -21,6 +22,7 @@
pie_slice="2"
name="Skull"
joint="mHead"
+ location="ATTACH_HEAD"
position="0 0 0.15"
rotation="0 0 90"
visible_in_first_person="false" />
@@ -28,9 +30,10 @@
@@ -38,18 +41,21 @@
@@ -78,9 +87,10 @@
@@ -91,6 +101,7 @@
pie_slice="7"
name="Spine"
joint="mChest"
+ location="ATTACH_BACK"
position="-0.15 0 -0.1"
rotation="0 -90 90"
visible_in_first_person="true" />
@@ -101,6 +112,7 @@
pie_slice="6"
name="Pelvis"
joint="mPelvis"
+ location="ATTACH_PELVIS"
position="0 0 -0.15"
rotation="0 0 0"
visible_in_first_person="true" />
@@ -111,6 +123,7 @@
pie_slice="6"
name="Mouth"
joint="mHead"
+ location="ATTACH_MOUTH"
position="0.12 0 0.001"
rotation="0 0 0"
visible_in_first_person="false"/>
@@ -121,6 +134,7 @@
pie_slice="7"
name="Chin"
joint="mHead"
+ location="ATTACH_CHIN"
position="0.12 0 -0.04"
rotation="0 0 0"
visible_in_first_person="false" />
@@ -131,6 +145,7 @@
pie_slice="4"
name="Left Ear"
joint="mHead"
+ location="ATTACH_LEAR"
position="0.015 0.08 0.017"
rotation="0 0 0"
visible_in_first_person="false" />
@@ -141,6 +156,7 @@
pie_slice="0"
name="Right Ear"
joint="mHead"
+ location="ATTACH_REAR"
position="0.015 -0.08 0.017"
rotation="0 0 0"
visible_in_first_person="false" />
@@ -151,6 +167,7 @@
pie_slice="3"
name="Left Eyeball"
joint="mEyeLeft"
+ location="ATTACH_LEYE"
position="0 0 0"
rotation="0 0 0"
visible_in_first_person="false"/>
@@ -161,6 +178,7 @@
pie_slice="1"
name="Right Eyeball"
joint="mEyeRight"
+ location="ATTACH_REYE"
position="0 0 0"
rotation="0 0 0"
visible_in_first_person="false" />
@@ -171,6 +189,7 @@
pie_slice="5"
name="Nose"
joint="mHead"
+ location="ATTACH_NOSE"
position="0.1 0 0.05"
rotation="0 0 0"
visible_in_first_person="false"/>
@@ -178,9 +197,10 @@
@@ -188,9 +208,10 @@
@@ -198,9 +219,10 @@
@@ -208,9 +230,10 @@
@@ -218,9 +241,10 @@
@@ -228,9 +252,10 @@
@@ -238,9 +263,10 @@
@@ -248,9 +274,10 @@
@@ -258,9 +285,10 @@
@@ -268,9 +296,10 @@
@@ -281,6 +310,7 @@
pie_slice="5"
name="Stomach"
joint="mPelvis"
+ location="ATTACH_BELLY"
position="0.092 0.0 0.088"
rotation="0 0 0"
visible_in_first_person="true" />
@@ -291,6 +321,7 @@
pie_slice="3"
name="Left Pec"
joint="mTorso"
+ location="ATTACH_LEFT_PEC"
position="0.104 0.082 0.247"
rotation="0 0 0"
visible_in_first_person="true" />
@@ -301,15 +332,17 @@
pie_slice="1"
name="Right Pec"
joint="mTorso"
+ location="ATTACH_RIGHT_PEC"
position="0.104 -0.082 0.247"
rotation="0 0 0"
visible_in_first_person="true" />
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ name="mSpine3"
+ scale="0 0 .05" />
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -514,8 +771,12 @@
scale="0 0 0.05" />
+ name="mSpine3"
+ scale="0 0 0.05" />
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -586,10 +937,26 @@
name="mTorso"
scale="0.1 0.1 0" />
+
+
+
+
+
+
+
+
@@ -605,6 +972,37 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -643,6 +1041,17 @@
+
+
+
+
+
@@ -650,7 +1059,7 @@
id="37"
group="0"
name="Hip Width"
- label="Hip Width"
+ label="Hip Width"
wearable="shape"
edit_group="shape_legs"
edit_group_order="3"
@@ -665,6 +1074,14 @@
name="mPelvis"
scale="0 0.1 0" />
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -693,7 +1129,19 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -732,6 +1196,26 @@
+
+
+
+
+
+
+
+
+
+
@@ -755,10 +1239,82 @@
name="mEyeRight"
scale="0 0 0"
offset="0 -.009 0" />
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -801,9 +1507,10 @@
name="mEyeRight"
scale="0 0 0"
offset=".016 0 0" />
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -831,7 +1612,7 @@
id="655"
group="1"
name="Head Size"
- label="Head Size"
+ label="Head Size"
wearable="shape"
edit_group="shape_head"
label_min="Small Head"
@@ -840,6 +1621,36 @@
value_min="-.25"
value_max=".10">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
+
+ name="mFaceEyeAltLeft"
+ scale="1 1 1"
+ offset="0 0 -0.001" />
-
-
-
-
-
+ name="mFaceEyeAltRight"
+ scale="1 1 1"
+ offset="0 0 -0.001" />
+
+ name="mFaceForeheadLeft"
+ scale="1 1 1"
+ offset="0 0 0" />
-
-
+ name="mFaceForeheadCenter"
+ scale="1 1 1"
+ offset="0 0 0" />
-
-
-
-
-
-
-
-
-
-
+ name="mFaceEyebrowInnerLeft"
+ scale="1 1 1"
+ offset="0 0 0" />
+ name="mFaceEyebrowOuterRight"
+ scale="1 1 1"
+ offset="0 0 0" />
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ id="197"
+ group="1"
+ wearable="shoes"
+ name="Shoe_Heels"
+ edit_group="shoes"
+ label_min="No Heels"
+ label_max="High Heels"
+ value_min="0"
+ value_max="1">
+ name="mFootRight"
+ scale="0 0 0"
+ offset="0 0 -.08" />
+ name="mFootLeft"
+ scale="0 0 0"
+ offset="0 0 -.08" />
+ name="mHindLimb4Left"
+ scale="0 0 0"
+ offset="0 0 -.08" />
+ name="mHindLimb4Right"
+ scale="0 0 0"
+ offset="0 0 -.08" />
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ edit_group_order="10"
+ label_min="Small Hands"
+ label_max="Large Hands"
+ value_min="-.3"
+ value_max=".3"
+ camera_elevation=".1"
+ camera_distance="1.4"
+ camera_angle="0">
+ name="mWristRight"
+ scale="1 1 1"
+ offset="0 0 0" />
+ name="mWristLeft"
+ scale="1 1 1"
+ offset="0 0 0" />
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+ scale="1 1 0"
+ offset="0 0 0" />
-
-
-
-
-
-
-
-
-
-
-
-
+ value_max="1">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+ camera_distance="2.5">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+ value_default=".6"
+ camera_distance="1.5">
+
+
+
+
+
+
+
+
+
-
+ value_default="0"
+ camera_elevation=".3"
+ camera_distance=".8"
+ camera_angle="15">
+
+
+
-
+
-
+ value_default="0"
+ camera_distance="2.5">
+
+
+
+
+
+
+
+
+
+
+
-
+ id="30004"
+ group="1"
+ name="Broad_Nostrils"
+ value_min="-.5"
+ value_max="1">
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+ id="30517"
+ group="1"
+ name="Wide_Nose"
+ value_min="-.5"
+ value_max="1">
+
+
+
+
+
-
-
+ id="30656"
+ group="1"
+ name="Crooked_Nose"
+ value_min="-2"
+ value_max="2">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+ name="Lip Width"
+ value_min="-0.9"
+ value_max="1.3"
+ value_default="0">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+ name="Tall_Lips"
+ value_min="-1"
+ value_max="2">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+ value_max="0.7">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+ value_max="1">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+ value_max="1.5">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+ value_max="1.5">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+ value_max="1.4">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+ value_max="1.4">
+
+
+
-
-
-
+
+
+
+
+
-
-
-
+
+
+
+
+
-
-
-
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
+
+
+
+
+
+
-
+ value_max="2">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+ value_max="2">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+ name="Big_Ears"
+ value_min="-1"
+ value_max="2">
+
+
+
+
-
+
-
+ name="Ears_Out"
+ value_min="-.5"
+ value_max="1.5">
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
+ id="30185"
+ group="1"
+ name="Deep_Chin"
+ value_min="-1"
+ value_max="1">
+
+
+
+
-
-
+
+
+
+
-
+
-
+ name="Jaw_Angle"
+ value_min="-1.2"
+ value_max="2"
+ value_default="0">
+
+
+
-
+
+
-
-
+ name="Jaw_Jut"
+ value_min="-2"
+ value_max="2">
+
-
-
-
+
+
+
+
+
+
-
+ name="Bulbous_Nose_Tip"
+ value_min="-1"
+ value_max="1.5">
+
+
+
+
-
+
-
+ name="Weak_Chin"
+ value_min="-.5"
+ value_max=".5">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
+
-
-
+
-
-
-
+
-
-
-
+
+
+
-
-
-
+
+
+
-
-
-
+
-
-
+
-
+
-
-
+ name="Eyelid_Corner_Up"
+ value_min="-1.3"
+ value_max="1.2">
+
+
-
-
+
+
-
+
-
-
+ name="Eyelid_Inner_Corner_Up"
+ value_min="-1.3"
+ value_max="1.2">
+
+
+
+
+
+
-
+ name="Puffy_Lower_Lids"
+ value_min="-.3"
+ value_max="2.5">
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
+
+
+
+
+
+
+
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
-
-
+
-
-
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
-
-
+
+
-
-
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
+ value_max="2">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+ id="30011"
+ group="1"
+ name="Noble_Nose_Bridge"
+ value_min="-.5"
+ value_max="1.5">
+
+
+
+
+
+
+
-
+ id="30758"
+ group="1"
+ name="Lower_Bridge_Nose"
+ value_min="-1.5"
+ value_max="1.5">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+ value_default="0.5">
+
-
-
-
+
+
+
+
+
+
-
+ id="30010"
+ group="1"
+ name="Sunken_Cheeks"
+ value_min="-1.5"
+ value_max="3">
+
+
+
+
+
+
-
-
+ id="30017"
+ group="1"
+ name="Square_Jaw"
+ value_min="-0.5"
+ value_max="1">
+
-
-
-
+
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+ value_max="2.5">
+
-
-
-
+
+
+
+
+
+
-
+ id="30021"
+ group="1"
+ name="Upper_Eyelid_Fold"
+ value_min="-0.2"
+ value_max="1.3">
+
+
+
+
+
+
+
-
-
+ value_max="1.5">
+
-
-
+
+
+
+
+
-
-
+ value_max="1">
+
-
-
-
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+ value_default="0">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+ value_default="0.5">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+ id="30031"
+ group="1"
+ name="Arced_Eyebrows"
+ value_min="0"
+ value_max="2"
+ value_default=".5">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+ id="30757"
+ group="1"
+ name="Lower_Eyebrows"
+ value_min="-4"
+ value_max="2"
+ value_default="-1">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ camera_distance=".5"
+ camera_angle="20">
+ camera_distance=".5"
+ camera_angle="20">
+ camera_distance=".5"
+ camera_angle="90">
+ camera_distance=".5"
+ camera_angle="90">
+ camera_distance=".7"
+ camera_angle="90">
+ camera_distance=".5"
+ camera_angle="20">
+ name="Hair_Part_Middle"
+ label="Middle Part"
+ wearable="hair"
+ edit_group="hair_style"
+ edit_group_order="17"
+ label_min="No Part"
+ label_max="Part"
+ value_min="0"
+ value_max="2"
+ camera_elevation=".1"
+ camera_distance=".5"
+ camera_angle="0">
+ name="Hair_Part_Right"
+ label="Right Part"
+ wearable="hair"
+ edit_group="hair_style"
+ edit_group_order="18"
+ label_min="No Part"
+ label_max="Part"
+ value_min="0"
+ value_max="2"
+ camera_elevation=".1"
+ camera_distance=".5"
+ camera_angle="0">
+ value_max="2"
+ camera_elevation=".1"
+ camera_distance=".5"
+ camera_angle="0">
+ camera_distance=".5"
+ camera_angle="20">
+ value_max="1"
+ camera_elevation=".1"
+ camera_distance=".5"
+ camera_angle="20">
+ clothing_morph="true"
+ name="Bangs_Front_Down"
+ label="Front Bangs Down"
+ wearable="hair"
+ edit_group="hair_style"
+ label_min="Bangs"
+ label_max="Bangs Down"
+ value_min="0"
+ value_max="5"
+ camera_elevation=".1"
+ camera_distance=".5"
+ camera_angle="20">
+ name="Bangs_Sides_Up"
+ label="Side Bangs Up"
+ wearable="hair"
+ edit_group="hair_style"
+ label_min="Side Bangs"
+ label_max="Side Bangs Up"
+ value_min="0"
+ value_max="1"
+ camera_elevation=".1"
+ camera_distance=".5"
+ camera_angle="20">
-
+ value_max="2"
+ camera_elevation=".1"
+ camera_distance=".5"
+ camera_angle="20">
-
+ edit_group="hair_style"
+ label_min="Back Bangs"
+ label_max="Back Bangs Up"
+ value_min="0"
+ value_max="1"
+ camera_elevation=".1"
+ camera_distance=".5"
+ camera_angle="150">
-
-
-
-
-
-
-
-
+ camera_distance=".5"
+ camera_angle="150">
-
-
-
+
@@ -2589,12 +4802,14 @@
+ name="Hair_Back_Down"
+ label="Back Hair Down"
+ clothing_morph="true"
+ wearable="hair"
+ edit_group="hair_style"
+ label_min="Back Hair"
+ label_max="Back Hair Down"
+ value_min="0"
+ value_max="3"
+ camera_elevation=".1"
+ camera_distance=".5"
+ camera_angle="150">
+ value_max="1"
+ camera_elevation=".1"
+ camera_distance=".5"
+ camera_angle="150">
+ wearable="hair"
+ clothing_morph="true"
+ edit_group="hair_style"
+ edit_group_order="14.5"
+ label_min="Smooth Hair"
+ label_max="Rumpled Hair"
+ value_min="0"
+ value_max="1"
+ camera_elevation=".1"
+ camera_distance=".5"
+ camera_angle="20">
-
+ camera_elevation=".1"
+ camera_distance=".5"
+ camera_angle="90">
+
+ value_max="1"
+ camera_elevation=".1"
+ camera_distance=".5"
+ camera_angle="90">
+ value_max="1"
+ camera_elevation=".1"
+ camera_distance=".5"
+ camera_angle="0">
+ id="191"
+ group="1"
+ name="Hair_Tilt_Left"
+ label="Hair Tilted Left"
+ wearable="hair"
+ edit_group="hair_style"
+ label_min="Hair"
+ label_max="Tilt Left"
+ value_min="0"
+ value_max="1"
+ camera_elevation=".1"
+ camera_distance=".5"
+ camera_angle="0">
+ id="192"
+ group="0"
+ name="Bangs_Part_Middle"
+ label="Part Bangs"
+ wearable="hair"
+ edit_group="hair_style"
+ edit_group_order="20"
+ label_min="No Part"
+ label_max="Part Bangs"
+ value_min="0"
+ value_max="1"
+ camera_elevation=".1"
+ camera_distance=".5"
+ camera_angle="0">
-
+ id="640"
+ group="1"
+ name="Hair_Egg_Head"
+ wearable="hair"
+ edit_group="hair_style"
+ cross_wearable="true"
+ value_min="-1.3"
+ value_max="1">
+ id="641"
+ group="1"
+ name="Hair_Squash_Stretch_Head"
+ wearable="hair"
+ edit_group="hair_style"
+ cross_wearable="true"
+ value_min="-.5"
+ value_max="1">
+ value_max="1">
+ value_max="1">
+ value_max="1">
+ value_max="1">
+ value_max="2">
-
-
-
+ value_max="1">
+
+ value_default="-0.3"
+ camera_elevation=".1"
+ camera_distance=".5"
+ camera_angle="100">
+ camera_distance=".5"
+ camera_angle="30">
-
-
-
-
-
-
-
-
+ camera_angle="160">
+ id="755"
+ group="0"
+ name="Hair_Taper_Front"
+ wearable="hair"
+ edit_group="hair_style"
+ edit_group_order="13"
+ label="Taper Front"
+ label_min="Wide Front"
+ label_max="Narrow Front"
+ value_min="-1.5"
+ value_max="1.5"
+ value_default="0.05"
+ camera_elevation=".1"
+ camera_distance=".5"
+ camera_angle="20">
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ name="Big_Brow"
+ value_min="-.3"
+ value_max="2">
+ name="Nose_Big_Out"
+ value_min="-0.8"
+ value_max="2.5">
+ name="Bulbous_Nose"
+ value_min="-.5"
+ value_max="1.5">
-
+
+ name="Crooked_Nose"
+ value_min="-2"
+ value_max="2">
-
+
+ name="Tall_Lips"
+ value_min="-1"
+ value_max="2">
-
+
+ name="Mouth_Height"
+ value_min="-2"
+ value_max="2">
-
+
-
-
+ name="Lip_Cleft_Deep"
+ value_min="-.5"
+ value_max="1.2">
+
+
-
+ name="Wide_Lip_Cleft"
+ value_min="-.8"
+ value_max="1.5">
+
-
+
+ name="Shift_Mouth"
+ value_min="-2"
+ value_max="2"
+ value_default="0">
-
+
-
+ name="Big_Ears"
+ value_min="-1"
+ value_max="2">
+
-
+
-
+ name="Ears_Out"
+ value_min="-.5"
+ value_max="1.5">
+
-
-
-
+
+ name="Pointy_Ears"
+ value_min="-.4"
+ value_max="3">
-
+
-
-
+
+ name="Jaw_Jut"
+ value_min="-2"
+ value_max="2">
-
+
+ name="Wide_Eyes"
+ value_min="-1.5"
+ value_max="2">
-
-
+
+ name="Eyelid_Corner_Up"
+ value_min="-1.3"
+ value_max="1.2">
-
+
+ name="Puffy_Lower_Lids"
+ value_min="-.3"
+ value_max="2.5">
+ name="Low_Septum_Nose"
+ value_min="-1"
+ value_max="1.5"
+ value_default="0.5">
+ id="5"
+ group="0"
+ name="Cleft_Chin"
+ label="Chin Cleft"
+ wearable="shape"
+ edit_group="shape_chin"
+ edit_group_order="6"
+ label_min="Round"
+ label_max="Cleft"
+ value_min="-.1"
+ value_max="1"
+ camera_elevation="0"
+ camera_distance=".28"
+ camera_angle="-20">
+ name="Weak_Chin"
+ value_min="-.5"
+ value_max=".5">
+ name="Double_Chin"
+ value_min="-.5"
+ value_max="1.5">
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+ name="Sunken_Cheeks"
+ value_min="-1.5"
+ value_max="3">
+ name="Noble_Nose_Bridge"
+ value_min="-.5"
+ value_max="1.5">
+ id="20758"
+ group="1"
+ name="Lower_Bridge_Nose"
+ value_min="-1.5"
+ value_max="1.5">
+ camera_distance=".4"
+ camera_angle="0">
+ edit_group="shape_chin"
+ edit_group_order="7"
+ label_min="Round"
+ label_max="Cleft"
+ value_min="0"
+ value_max="1.5"
+ camera_elevation="0"
+ camera_distance=".28"
+ camera_angle="-20">
+ name="High_Cheek_Bones"
+ value_min="-.5"
+ value_max="1">
+
+ camera_distance=".3">
+ name="Square_Jaw"
+ value_min="-.5"
+ value_max="1">
+ id="20018"
+ group="1"
+ name="Puffy_Upper_Cheeks"
+ value_min="-1.5"
+ value_max="2.5">
+ id="20019"
+ group="1"
+ name="Upturned_Nose_Tip"
+ value_min="-1.5"
+ value_max="1">
-
-
+
+ id="20021"
+ group="1"
+ name="Upper_Eyelid_Fold"
+ value_min="-0.2"
+ value_max="1.3">
+ edit_group="shape_ears"
+ edit_group_order="3"
+ label_min="Unattached"
+ label_max="Attached"
+ value_min="0"
+ value_max="1"
+ camera_elevation=".1"
+ camera_distance=".3"
+ camera_angle="45">
+ name="Baggy_Eyes"
+ value_min="-.5"
+ value_max="1.5">
-
+ value_max=".7">
+ name="Wide_Nose_Bridge"
+ value_min="-1.3"
+ value_max="1.2">
+ value_max="2">
+ name="Wide_Upper_Lip"
+ wearable="shape"
+ edit_group="driven"
+ value_min="-.7"
+ value_max="1.3">
+ name="Wide_Lower_Lip"
+ wearable="shape"
+ edit_group="driven"
+ value_min="-.7"
+ value_max="1.3">
+
+
+ name="Lower_Eyebrows"
+ label="Eyebrow Height"
+ show_simple="true"
+ wearable="hair"
+ edit_group="hair_eyebrows"
+ edit_group_order="2.5"
+ label_min="Higher"
+ label_max="Lower"
+ value_min="-2"
+ value_max="2">
+ name="Egg_Head"
+ label="Egg Head"
+ wearable="shape"
+ edit_group="shape_head"
+ label_min="Chin Heavy"
+ label_max="Forehead Heavy"
+ value_min="-1.3"
+ value_max="1"
+ camera_elevation=".1"
+ camera_distance=".5"
+ camera_angle="20">
-
+ name="Squash_Stretch_Head"
+ label="Squash/Stretch Head"
+ wearable="shape"
+ edit_group="shape_head"
+ label_min="Squash Head"
+ label_max="Stretch Head"
+ value_min="-.5"
+ value_max="1"
+ camera_elevation=".1"
+ camera_distance=".5"
+ camera_angle="20">
+
+
+
+ value_max=".7"
+ camera_elevation=".1"
+ camera_distance=".5"
+ camera_angle="20">
+ value_max="1"
+ camera_elevation=".1"
+ camera_distance=".5"
+ camera_angle="20">
+ name="Eye_Spread"
+ wearable="shape"
+ edit_group="shape_eyes"
+ label_min="Eyes Together"
+ label_max="Eyes Spread"
+ value_min="-2"
+ value_max="2">
+ value_max="2">
-
+ value_max="1"
+ camera_elevation=".3">
+
+ id="20880"
+ group="1"
+ name="Eyelid_Inner_Corner_Up"
+ value_min="-1.3"
+ value_max="1.2">
-
-
+
+ value_max="1.4"
+ camera_distance=".3"
+ camera_elevation=".04">
-
+ value_max="1.2"
+ camera_distance=".3"
+ camera_elevation=".04">
+ value_max="1.5"
+ camera_distance=".3"
+ camera_elevation=".04">
-
-
-
-
-
-
-
+ value_max="1.5"
+ camera_distance=".3"
+ camera_elevation=".04">
+
+ label="Shear Face"
+ edit_group="shape_head"
+ label_min="Shear Left"
+ label_max="Shear Right"
+ value_min="-2"
+ value_max="2"
+ value_default="0"
+ camera_distance=".5"
+ camera_elevation=".04">
-
+ value_default="0"
+ camera_distance=".5"
+ camera_elevation=".04">
+
+
+
+ id="664"
+ group="0"
+ name="Pop_Eye"
+ wearable="shape"
+ label="Eye Pop"
+ edit_group="shape_eyes"
+ edit_group_order="8"
+ label_min="Pop Right Eye"
+ label_max="Pop Left Eye"
+ value_min="-1.3"
+ value_max="1.3"
+ value_default="0"
+ camera_elevation=".1"
+ camera_distance=".35">
+
+
+
+
-
-
-
-
-
-
-
-
+ label="Eye Size"
+ edit_group="shape_eyes"
+ label_min="Beady Eyes"
+ label_max="Anime Eyes"
+ show_simple="true"
+ value_min="-2"
+ value_max="2"
+ value_default="0">
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
+ value_max="1">
+
-
-
-
-
-
-
-
-
-
-
+ value_max="1">
+
-
-
-
-
-
-
-
-
-
-
-
-
+ value_max="1">
+
-
-
-
-
+ value_max="1">
+ value_max="1">
-
-
-
+ name="Express_Shrug_Emote"
+ value_min="0"
+ value_max="1">
+
+ id="306"
+ group="1"
+ name="Express_Kiss"
+ value_min="0"
+ value_max="1">
-
+
+ id="307"
+ group="1"
+ name="Express_Bored_Emote"
+ value_min="0"
+ value_max="1">
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
+
+
+ value_min="0"
+ value_max="1">
+ name="Old"
+ value_min="0"
+ value_max="1">
+
+ name="Surprised_Eyebrows"
+ value_min="0"
+ value_max="1">
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ reference="avatar_head.llm">
+ reference="avatar_head.llm">
+ reference="avatar_head.llm">
+ reference="avatar_head.llm">
-
-
+ label="Shear Face"
+ edit_group="shape_head"
+ label_min="Shear Left"
+ label_max="Shear Right"
+ value_min="-2"
+ value_max="2"
+ value_default="0"
+ camera_distance=".5"
+ camera_elevation=".04">
-
-
-
-
+ label="Shear Face"
+ edit_group="shape_head"
+ label_min="Flat Head"
+ label_max="Long Head"
+ value_min="-1"
+ value_max="1"
+ value_default="0"
+ camera_distance=".5"
+ camera_elevation=".04">
+
-
-
-
+ label="Eye Pop"
+ edit_group="shape_eyes"
+ edit_group_order="8"
+ label_min="Pop Right Eye"
+ label_max="Pop Left Eye"
+ value_min="-2"
+ value_max="2"
+ value_default="0"
+ camera_distance=".5"
+ camera_elevation=".04"
+ camera_angle="-20">
+
-
-
-
-
-
-
+ edit_group="shape_head"
+ label_min="Chin Heavy"
+ label_max="Forehead Heavy"
+ value_min="-1.3"
+ value_max="1"
+ camera_elevation=".1"
+ camera_distance=".5"
+ camera_angle="20">
+
-
-
-
-
-
-
+ edit_group="shape_head"
+ label_min="Squash Head"
+ label_max="Stretch Head"
+ value_min="-.5"
+ value_max="1"
+ camera_elevation=".1"
+ camera_distance=".5"
+ camera_angle="20">
+
+
+
+
+
-
-
-
-
-
-
+ label="Eyelash Length"
+ edit_group="shape_eyes"
+ edit_group_order="7"
+ label_min="Short"
+ label_max="Long"
+ value_min="-.3"
+ value_max="1.5"
+ camera_elevation=".1"
+ camera_distance=".30"
+ camera_angle="-20">
+
+ name="Head_Eyes_Big"
+ wearable="shape"
+ label="Eye Size"
+ edit_group="shape_eyes"
+ label_min="Beady Eyes"
+ label_max="Anime Eyes"
+ value_min="-2"
+ value_max="2"
+ show_simple="true"
+ value_default="0">
+ name="Bug_Eyed_Head"
+ wearable="shape"
+ label="Eye Depth"
+ edit_group="shape_eyes"
+ edit_group_order="4.5"
+ label_min="Sunken Eyes"
+ label_max="Bug Eyes"
+ value_min="-2"
+ value_max="2"
+ value_default="0">
+ shared="1"
+ id="20021"
+ group="1"
+ name="Upper_Eyelid_Fold"
+ value_min="-0.2"
+ value_max="1.3">
+ name="Wide_Eyes"
+ value_min="-1.5"
+ value_max="2">
+ name="Eyelid_Corner_Up"
+ value_min="-1.3"
+ value_max="1.2">
+
+
+
+
+
+ value_max="1">
+ value_max="1">
+ value_max="1">
-
-
-
-
+ shared="1"
+ id="304"
+ group="1"
+ name="Express_Embarrassed_Emote"
+ value_min="0"
+ value_max="1">
+
+ value_max="1">
+ value_max="1">
+ value_max="1">
+ value_max="1">
-
-
-
-
-
-
-
+
-
-
-
-
+ name="Express_Afraid_Emote"
+ value_min="0"
+ value_max="1">
+
+ shared="1"
+ id="312"
+ group="1"
+ name="Express_Cry_Emote"
+ value_min="0"
+ value_max="1">
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+ name="Express_Toothsmile"
+ value_min="0"
+ value_max="1">
-
-
-
-
-
-
-
+ name="Express_Smile"
+ value_min="0"
+ value_max="1">
+
+ name="Old"
+ value_min="0"
+ value_max="1">
-
-
-
-
+
+ name="Blink_Left"
+ value_min="0"
+ value_max="1">
+ name="Blink_Right"
+ value_min="0"
+ value_max="1">
+
-
+ type="upperBodyMesh"
+ lod="0"
+ file_name="avatar_upper_body.llm"
+ min_pixel_width="320">
+
-
+ edit_group="driven"
+ value_min="0"
+ value_max="1">
+
+
+
+
-
-
-
-
-
-
-
+ value_max="1"
+ camera_elevation=".1"
+ camera_distance="1"
+ camera_angle="15">
+
+
+
+
-
+ value_max="1"
+ camera_elevation="0"
+ camera_distance=".28">
+
+
+
+
-
+ value_max="1"
+ camera_elevation="0"
+ camera_distance=".28">
+
+
+
+
-
+ value_max="1.4"
+ camera_elevation=".3"
+ camera_distance="1.2">
+
+
+
+
+
+
+
+
-
-
-
-
-
+ value_max="1.4"
+ camera_elevation=".3"
+ camera_distance="1.2">
+
+
+
+
+
+
+
+
-
+ value_max="1.3"
+ camera_elevation=".3"
+ camera_distance="1.2">
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
+ value_max="1.3"
+ camera_elevation=".3"
+ camera_distance="1.2">
+
+
+
+
+
+
+
+
+
+
+
-
+ camera_elevation=".3">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+ id="840"
+ group="0"
+ name="Shirtsleeve_flair"
+ label="Sleeve Looseness"
+ show_simple="true"
+ wearable="shirt"
+ edit_group="shirt"
+ edit_group_order="6"
+ clothing_morph="true"
+ label_min="Tight Sleeves"
+ label_max="Loose Sleeves"
+ value_min="0"
+ value_max="1.5"
+ camera_distance="1.8"
+ camera_angle="30"
+ camera_elevation="-.3">
-
-
+ value_max="2">
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+ sex="female"
+ name="Breast_Female_Cleavage"
+ label="Breast Cleavage"
+ wearable="shape"
+ edit_group="shape_torso"
+ edit_group_order="8"
+ label_min="Separate"
+ label_max="Join"
+ value_default="0"
+ value_min="-.3"
+ value_max="1.3"
+ camera_elevation=".3"
+ camera_distance=".8">
+
+
+
+
-
+
-
-
-
+ sex="male"
+ name="Chest_Male_No_Pecs"
+ label="Pectorals"
+ wearable="shape"
+ edit_group="shape_torso"
+ edit_group_order="5"
+ label_min="Big Pectorals"
+ label_max="Sunken Chest"
+ value_default="0"
+ value_min="-0.5"
+ value_max="1.1"
+ camera_elevation=".3"
+ camera_distance="1.2">
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+ value_max="1">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+ value_max="1">
+
+
-
-
+
+
-
-
+ value_max="1">
+
+
-
-
+
+
-
-
+ value_max="1">
+
+
-
+
+
+
-
+
+
+
-
+
+
+
-
+
+
+
-
+
+
+
-
+
+
+
-
-
+
+
-
-
-
-
-
-
-
-
-
-
-
-
+ value_max="1">
+
+
-
-
+
+
+
+
+
+
+
-
-
+
+
+
+
+
+
-
-
+
+
+
+
+
-
-
+
+
+
+
+
+
-
-
+
-
-
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
+
+
+
+
-
-
-
-
+
+
+
+
-
-
-
-
-
+ value_max="1">
+
+
+
+
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
-
-
-
+
+
+
+
+
+
+
+
-
-
+
+
+
+
+
+
+
+
-
-
-
+
+
+
-
-
+
+
+
-
+
+
+
-
-
-
-
+
+
+
-
-
-
+
+
+
-
-
-
+
+
+
-
-
+
+
+
-
-
-
-
-
-
-
-
+
+
+
-
-
+
+
+
+
+
+
+
+
+
-
-
-
+
+
+
+
+
+
-
-
-
-
-
-
+
+
+
-
-
-
+
+
+
+
+
+
+
+
+
-
-
-
-
+
+
+
+
-
-
+
-
-
-
+
+
+
-
-
-
-
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
-
-
+
+
+
+
+
+
-
-
-
+
+
+
+
+
-
-
-
+
-
-
-
-
+
-
-
-
-
+
+
-
+
+
-
+
+
-
+
+
-
+
+
+
+
+
+
+
-
+
+
+
+
-
+
+
+
+
+
-
+
+
+
+
-
+
+
+
+
+
+
-
-
-
+
+
+
+
-
-
-
-
+
+
+
+
+
-
-
-
-
-
+
+
+
+
-
-
-
-
+
+
+
+
-
-
-
+
+
+
-
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
-
-
-
+
+
+
-
-
-
-
+
+
+
-
-
-
-
+
+
+
-
+
+
+
-
+
+
+
-
+
+
+
-
+
+
+
-
+
+
+
+
-
+
+
+
+
-
+
-
+
+
-
+
+
-
+
+
-
+
+
-
-
-
-
-
-
-
+
+
+
+
+
-
+
-
+
-
+
+
+
-
+
+
+
+
+
-
+
+
+
-
+
-
+
-
+
-
-
-
+
-
-
-
+
-
-
-
+
-
-
-
-
+
+
+
+
-
-
-
-
+
+
+
+
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
+
+
-
+
+
+
-
+
+
+
-
+
+
+
-
+
+
+
-
+
+
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ color="0, 0, 0, 255" />
+ color="255, 0, 0, 255" />
-
+ value_default="1">
+
+ color="0, 0, 0, 255" />
+ color="0, 255, 0, 255" />
-
+ value_default="1">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ name="head bump definition"
+ render_pass="bump">
+
+
+
+
+ value_max="1">
+ domain="0" />
+
+
+
+
+
+
+
+
+
+
+
+
+ value_max="1">
+ color="0, 0, 0, 0" />
-
+ color="0, 0, 0, 128" />
+
+
+
-
-
+
+
-
-
-
+
+
+color="255, 255, 255, 0" />
+
-
+ color="255, 255, 255, 64" />
+
+
+
+
+
-
+
+
+ color="198, 71, 71, 0" />
-
+ color="198, 71, 71, 255" />
+
+
+
-
+
+
+
+
+
+ color="220, 115, 115, 0" />
-
+
+ name="wrinkles_shading"
+ render_pass="bump"
+ fixed_color="0,0,0,100">
+
+
+
+
+
+
+
+
+
+
+
+
+ tga_file="eyebrows_alpha.tga"
+ domain="0.1" />
-
-
-
-
-
-
-
-
-
-
-
-
+ color="255,255,255,0" />
+ color="255,255,255,255" />
-
-
-
-
-
-
-
-
-
+ value_max="1"
+ value_default="0.5">
-
-
-
-
+ color="255,255,255,0" />
+ color="255,255,255,255" />
-
-
-
-
-
-
-
-
-
-
+ name="lipstick">
+ value_default=".25"
+ camera_distance=".25">
+ color="245,161,177,200" />
-
-
+ color="216,37,67,200" />
-
-
+ color="178,48,76,200" />
-
-
+ color="68,0,11,200" />
-
-
+ color="252,207,184,200" />
-
-
+ color="241,136,106,200" />
-
+
+
-
+
-
-
-
-
-
-
+
+
+
+ value_max=".9"
+ value_default="0.0"
+ camera_distance=".25">
+ tga_file="lipstick_alpha.tga"
+ skip_if_zero="true"
+ domain="0.05" />
-
-
-
-
-
-
-
-
-
-
+ name="lipgloss"
+ fixed_color="255,255,255,190">
-
-
-
-
-
+ value_max="1"
+ camera_distance=".25">
+
-
+ name="blush">
+
+
+
+ value_max="1"
+ value_default=".5"
+ camera_distance=".3"
+ camera_elevation=".07"
+ camera_angle="20">
+ color="253,162,193,200" />
-
-
-
+ color="247,131,152,200" />
-
-
-
+
-
-
-
-
-
+
-
-
+
-
-
+ color="195,128,122,200" />
+ color="148,103,100,200" />
+
+
-
+ value_default=".5"
+ camera_distance=".3"
+ camera_elevation=".07"
+ camera_angle="20">
+
+ color="255,255,255,0" />
+ color="255,255,255,255" />
+
+
+ camera_distance=".3"
+ camera_elevation=".14">
+ color="252,247,246,255" />
-
-
+ color="255,206,206,255" />
-
+
+
-
-
+
-
-
-
+
-
-
-
+
-
-
-
+
-
-
-
-
+
-
-
+
-
-
+ color="223,227,213,255" />
-
-
+ color="96,116,87,255" />
-
-
+ color="88,143,107,255" />
-
-
+ color="194,231,223,255" />
-
-
+ color="207,227,234,255" />
-
-
+ color="41,171,212,255" />
-
-
-
+
-
-
-
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+ value_default=".6"
+ camera_distance=".3"
+ camera_elevation=".14">
+
+
+
+
+
-
-
+ value_max=".7"
+ camera_distance=".3"
+ camera_elevation=".14">
+ domain="0.05" />
+
+
+ camera_distance=".3"
+ camera_elevation=".14">
+ color="252,247,246,255" />
+ color="255,206,206,255" />
+ color="233,135,149,255" />
+ color="220,168,192,255" />
+ color="228,203,232,255" />
+ color="255,234,195,255" />
+ color="230,157,101,255" />
+ color="255,147,86,255" />
-
-
-
+ color="228,110,89,255" />
-
-
+
-
-
-
+
-
-
-
-
+
-
-
+
-
-
+ color="194,231,223,255" />
-
-
+ color="207,227,234,255" />
-
-
+ color="41,171,212,255" />
+ color="180,137,130,255" />
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+ value_default=".7"
+ camera_distance=".3"
+ camera_elevation=".14">
+
+ color="255,255,255,0" />
+ color="255,255,255,255" />
+ value_default="0"
+ camera_distance=".3"
+ camera_elevation=".14">
+ tga_file="eyeshadow_inner_alpha.tga"
+ skip_if_zero="true"
+ domain="0.2" />
+
+
+ value_default="0.0"
+ camera_distance=".3"
+ camera_elevation=".14">
+ tga_file="eyeliner_alpha.tga"
+ skip_if_zero="true"
+ domain="0.1" />
-
-
-
-
+ camera_distance=".3"
+ camera_elevation=".14">
+ color="24,98,40,250" />
+
+ color="9,100,127,250" />
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ name="Sideburns bump"
+ value_min="0"
+ value_max="1">
+ domain="0.05" />
+ domain="0.1" />
+ domain="0.03" />
+
+
+
+
+
+
+
+
+ name="facialhair"
+ global_color="hair_color">
+
+ tga_file="head_hair.tga"
+ file_is_mask="false" />
+ value_max="1">
+ tga_file="facehair_sideburns_alpha.tga"
+ skip_if_zero="true"
+ domain="0.05" />
+ tga_file="facehair_soulpatch_alpha.tga"
+ skip_if_zero="true"
+ domain="0.1" />
+ tga_file="facehair_chincurtains_alpha.tga"
+ skip_if_zero="true"
+ domain="0.03" />
+
+
+
+
+
+
+
+
+ name="head_bodypaint">
-
+ local_texture="head_bodypaint" />
+
+
+
+
+
-
+ local_texture="head_alpha" />
+
+
+
+ value_default="1">
+ color="0, 0, 0, 255" />
+ color="255, 0, 0, 255" />
-
-
+ value_max="1"
+ value_default="1">
+
+
-
-
+
+
-
-
+ value_max="1"
+ value_default="1">
+
+
-
-
+
+
-
+
+ name="head_universal_tattoo">
-
+ local_texture="head_universal_tattoo" />
@@ -7626,11 +10109,11 @@ render_pass="bump">
@@ -7644,11 +10127,11 @@ render_pass="bump">
@@ -7661,260 +10144,324 @@ render_pass="bump">
-
-
-
+
-
-
-
+
+
+
+
+
+
+
+
+ value_max="1">
+ domain="0" />
+
+
+
+
+
+
+
+
+
+
+
+
-
+ value_max="1">
+
+
+
+
+
+ name="highlight">
+ tga_file="upperbody_highlights_alpha.tga"
+ file_is_mask="TRUE" />
-
+
+
+
+
+
+
+
+
+
+
+
+ tga_file="upperbodyfreckles_alpha.tga"
+ skip_if_zero="true"
+ domain="0.6" />
+
+
+
+
-
+ value_max="1"
+ value_default="1">
+
+
+
+
+
-
+ value_max="1"
+ value_default="1">
+
+
+
+
+
-
+ value_max="1"
+ value_default="1">
+
+
+
+
+
-
+
+ name="upper_universal_tattoo">
-
-
-
-
+ local_texture="upper_universal_tattoo" />
+ id="1232"
+ group="1"
+ edit_group="colorpicker_driven"
+ wearable="universal"
+ name="tattoo_upper_universal_red"
+ value_min="0"
+ value_max="1"
+ value_default="1">
+ color="0, 0, 0, 255" />
+ color="255, 0, 0, 255" />
-
+ value_max="1"
+ value_default="1">
+
+
+
+
+
-
+ value_max="1"
+ value_default="1">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ value_max="1"
+ value_default=".8">
+ value_max="1"
+ value_default=".8">
+ domain="0.05" />
+ value_max="1"
+ value_default=".8">
+ domain="0.05" />
+ name="upper_undershirt">
+ local_texture="upper_undershirt" />
@@ -7928,11 +10475,11 @@ render_pass="bump">
@@ -7946,11 +10493,11 @@ render_pass="bump">
@@ -7964,320 +10511,185 @@ render_pass="bump">
+ wearable="undershirt"
+ edit_group="driven"
+ name="Sleeve Length"
+ value_min=".01"
+ value_max="1"
+ value_default=".4">
+ value_max="1"
+ value_default=".8">
+ value_max="1"
+ value_default=".8">
+ value_default=".8">
+ domain="0.05" />
+
+
+ value_default="0.0"
+ camera_distance="1.6"
+ camera_elevation="-.4"
+ camera_angle="70">
+ tga_file="nailpolish_alpha.tga"
+ skip_if_zero="true"
+ domain="0.1" />
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+ value_max="1"
+ camera_distance="1.6"
+ camera_elevation="-.4"
+ camera_angle="70">
-
-
-
-
-
-
-
-
+ color="255,187,200,255" />
-
-
+ color="194,102,127,255" />
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+ color="227,34,99,255" />
-
-
+ color="168,41,60,255" />
-
-
+ color="97,28,59,255" />
-
-
+ color="234,115,93,255" />
-
-
+ color="142,58,47,255" />
-
-
+ color="114,30,46,255" />
+ color="14,14,14,255" />
-
+ value_default=".8">
+ value_default="1">
+ tga_file="gloves_fingers_alpha.tga"
+ multiply_blend="true"
+ domain="0.01" />
+ name="upper_gloves">
+ local_texture="upper_gloves" />
@@ -8291,11 +10703,11 @@ render_pass="bump">
@@ -8309,11 +10721,11 @@ render_pass="bump">
@@ -8327,168 +10739,282 @@ render_pass="bump">
+ value_default=".8">
+ value_default="1">
+ tga_file="gloves_fingers_alpha.tga"
+ multiply_blend="true"
+ domain="0.01" />
+ name="upper_clothes_shadow">
+ local_texture="upper_shirt" />
-
-
-
+ value_default="0">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ name="upper_shirt base bump"
+ render_pass="bump"
+ fixed_color="128,128,128,255">
+ local_texture="upper_shirt"
+ local_texture_alpha_only="true" />
-
-
+ value_max="0.85">
+
+
-
-
+
+
-
-
+ value_max="1">
+
+
-
-
+
+
+
+
+
+
+
+
+ value_default="0">
+ color="255, 255, 255, 0" />
+ color="255, 255, 255, 255" />
+ value_max="0.85">
-
-
-
+
+
+
+ value_max="1">
+ multiply_blend="true"
+ tga_file="shirt_collar_alpha.tga"
+ domain="0.05" />
+
+
+
+
+ name="upper_clothes">
+ local_texture="upper_shirt" />
@@ -8502,11 +11028,11 @@ render_pass="bump">
@@ -8520,11 +11046,11 @@ render_pass="bump">
@@ -8538,127 +11064,166 @@ render_pass="bump">
+ value_max="0.85"
+ value_default=".7">
-
-
-
-
-
-
-
-
-
+ value_default=".8">
+
+ name="Collar Front Height Cloth"
+ value_min="0"
+ value_max="1"
+ value_default=".8">
+ multiply_blend="true"
+ tga_file="shirt_collar_alpha.tga"
+ domain="0.05" />
+ name="Collar Back Height Cloth"
+ value_min="0"
+ value_max="1"
+ value_default=".8">
+ multiply_blend="true"
+ tga_file="shirt_collar_back_alpha.tga"
+ domain="0.05" />
+
+
+
+
+
+
+
+
+
+
+
+
+ tga_file="bump_shirt_wrinkles.tga" />
+
+ id="875"
+ group="1"
+ wearable="jacket"
+ name="jacket upper Wrinkles"
+ value_min="0"
+ value_max="1"
+ value_default="0">
@@ -8669,43 +11234,89 @@ render_pass="bump">
+
+
+
+
+
+
+
+
+
+
+
+
+ name="upper_jacket">
+ local_texture="upper_jacket" />
@@ -8719,11 +11330,11 @@ render_pass="bump">
@@ -8737,15 +11348,15 @@ render_pass="bump">
-
+ id="833"
+ group="1"
+ edit_group="colorpicker_driven"
+ wearable="jacket"
+ name="upper_jacket_blue"
+ value_min="0"
+ value_max="1"
+ value_default="1">
+
@@ -8755,140 +11366,222 @@ render_pass="bump">
+
+
+
+
+ value_max="1">
+ value_max="1">
+ multiply_blend="true"
+ tga_file="shirt_collar_back_alpha.tga"
+ domain="0.05" />
-
-
-
-
+ value_max="1"
+ value_default=".8"
+ camera_distance="1.2"
+ camera_angle="30"
+ camera_elevation=".2">
+ value_max="1"
+ value_default=".8"
+ camera_distance="1.2"
+ camera_angle="30"
+ camera_elevation=".2">
+
+
+
+
+
+
+
+
+
+
+ tga_file="bump_lowerbody_base.tga"
+ file_is_mask="FALSE" />
+
+
+
+
+
+
-
+ tga_file="body_skingrain.tga" />
+
+
+
+
+ value_max="1">
+ color="0, 0, 0, 0" />
+ color="0, 0, 0, 128" />
+
+
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ tga_file="bodyfreckles_alpha.tga"
+ skip_if_zero="true"
+ domain="0.6" />
+ name="lower_tattoo">
+ local_texture="lower_tattoo" />
@@ -8902,11 +11595,11 @@ render_pass="bump">
@@ -8920,11 +11613,11 @@ render_pass="bump">
@@ -8937,101 +11630,114 @@ render_pass="bump">
+
+
+
-
-
-
-
+
+
+
+
+
+
+
+
-
+ value_default="1">
+
+
+
+
+
-
-
-
-
+
+
+
-
+
+
+
-
-
-
-
-
+ name="lower_underpants bump"
+ render_pass="bump"
+ fixed_color="128,128,128,255">
-
+ local_texture="lower_underpants"
+ local_texture_alpha_only="true" />
-
-
-
+
+
+
-
+
+
+
+
-
-
+ name="lower_underpants">
+ local_texture="lower_underpants" />
@@ -9045,11 +11751,11 @@ render_pass="bump">
@@ -9063,11 +11769,11 @@ render_pass="bump">
@@ -9079,123 +11785,2167 @@ render_pass="bump">
color="0, 0, 255, 255" />
-
-
+ value_default=".3"
+ camera_distance="1.2"
+ camera_angle="30"
+ camera_elevation="-.3">
+ tga_file="pants_length_alpha.tga"
+ domain="0.01" />
+ value_default=".8">
+ tga_file="pants_waist_alpha.tga"
+ domain="0.05" />
+
+
+
+
+ value_default="0.35">
+ tga_file="shoe_height_alpha.tga"
+ domain="0.01" />
+
+
+
+
-
-
+ value_default="1">
+
+
+
+
+
+
+ value_default="1">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ tga_file="shoe_height_alpha.tga"
+ domain="0.01" />
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
max1="1"
max2="1"
min2="1" />
+
+
+
+
@@ -9631,8 +14395,8 @@ render_pass="bump">
edit_group="shape_mouth"
edit_group_order="3.2"
name="Lip Ratio"
- label="Lip Ratio"
- show_simple="true"
+ label="Lip Ratio"
+ show_simple="true"
label_min="More Upper Lip"
label_max="More Lower Lip"
value_min="0"
@@ -9655,6 +14419,21 @@ render_pass="bump">
max1="1"
max2="1"
min2="1" />
+
+
+
+
+
@@ -9680,6 +14459,10 @@ render_pass="bump">
+
+
+
@@ -9890,6 +14673,10 @@ render_pass="bump">
max1="1"
max2="1"
min2="1" />
+
+
+
@@ -10362,6 +15149,21 @@ render_pass="bump">
max1="1"
max2="1"
min2="1" />
+
+
+
+
+
@@ -10388,6 +15190,14 @@ render_pass="bump">
+
+
+
@@ -10414,6 +15224,10 @@ render_pass="bump">
+
+
+
@@ -10444,7 +15258,7 @@ render_pass="bump">
min2=".5" />
min1=".5"
max1="1"
max2="1"
+ min2="1" />
+
+
+
+
+
+
+
+
+
+
+
+
@@ -10636,7 +15483,7 @@ render_pass="bump">
edit_group="shape_head"
edit_group_order="1"
name="Head Size"
- label="Head Size"
+ label="Head Size"
label_min="Small Head"
label_max="Big Head"
show_simple="true"
@@ -10670,16 +15517,17 @@ render_pass="bump">
edit_group="shape_eyes"
edit_group_order="1"
name="Eye Size"
- label="Eye Size"
+ label="Eye Size"
label_min="Beady Eyes"
label_max="Anime Eyes"
value_min="0"
value_max="1"
value_default=".5"
- show_simple="true"
+ show_simple="true"
camera_elevation=".1"
camera_distance=".35">
+
@@ -10697,6 +15545,10 @@ render_pass="bump">
+
+
+
@@ -10967,19 +15819,44 @@ render_pass="bump">
min2=".3" />
+ id="151"
+ min1=".3"
+ max1="1"
+ max2="1"
+ min2="1" />
+
+
+
+
+
+
+
+
-
-
+
+
+
+
+
@@ -11580,6 +16461,8 @@ render_pass="bump">
+
@@ -11603,6 +16486,8 @@ render_pass="bump">
+
@@ -11625,13 +16510,15 @@ render_pass="bump">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/AppData/openmetaverse_data/avatar_skeleton.xml b/AppData/openmetaverse_data/avatar_skeleton.xml
new file mode 100644
index 00000000..2241a125
--- /dev/null
+++ b/AppData/openmetaverse_data/avatar_skeleton.xml
@@ -0,0 +1,232 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/bin/openmetaverse_data/blush_alpha.tga b/AppData/openmetaverse_data/blush_alpha.tga
similarity index 100%
rename from bin/openmetaverse_data/blush_alpha.tga
rename to AppData/openmetaverse_data/blush_alpha.tga
diff --git a/bin/openmetaverse_data/body_skingrain.tga b/AppData/openmetaverse_data/body_skingrain.tga
similarity index 100%
rename from bin/openmetaverse_data/body_skingrain.tga
rename to AppData/openmetaverse_data/body_skingrain.tga
diff --git a/bin/openmetaverse_data/bodyfreckles_alpha.tga b/AppData/openmetaverse_data/bodyfreckles_alpha.tga
similarity index 100%
rename from bin/openmetaverse_data/bodyfreckles_alpha.tga
rename to AppData/openmetaverse_data/bodyfreckles_alpha.tga
diff --git a/bin/openmetaverse_data/bump_face_wrinkles.tga b/AppData/openmetaverse_data/bump_face_wrinkles.tga
similarity index 100%
rename from bin/openmetaverse_data/bump_face_wrinkles.tga
rename to AppData/openmetaverse_data/bump_face_wrinkles.tga
diff --git a/bin/openmetaverse_data/bump_head_base.tga b/AppData/openmetaverse_data/bump_head_base.tga
similarity index 100%
rename from bin/openmetaverse_data/bump_head_base.tga
rename to AppData/openmetaverse_data/bump_head_base.tga
diff --git a/bin/openmetaverse_data/bump_lowerbody_base.tga b/AppData/openmetaverse_data/bump_lowerbody_base.tga
similarity index 100%
rename from bin/openmetaverse_data/bump_lowerbody_base.tga
rename to AppData/openmetaverse_data/bump_lowerbody_base.tga
diff --git a/bin/openmetaverse_data/bump_pants_wrinkles.tga b/AppData/openmetaverse_data/bump_pants_wrinkles.tga
similarity index 100%
rename from bin/openmetaverse_data/bump_pants_wrinkles.tga
rename to AppData/openmetaverse_data/bump_pants_wrinkles.tga
diff --git a/bin/openmetaverse_data/bump_shirt_wrinkles.tga b/AppData/openmetaverse_data/bump_shirt_wrinkles.tga
similarity index 100%
rename from bin/openmetaverse_data/bump_shirt_wrinkles.tga
rename to AppData/openmetaverse_data/bump_shirt_wrinkles.tga
diff --git a/bin/openmetaverse_data/bump_upperbody_base.tga b/AppData/openmetaverse_data/bump_upperbody_base.tga
similarity index 100%
rename from bin/openmetaverse_data/bump_upperbody_base.tga
rename to AppData/openmetaverse_data/bump_upperbody_base.tga
diff --git a/bin/openmetaverse_data/eyebrows_alpha.tga b/AppData/openmetaverse_data/eyebrows_alpha.tga
similarity index 100%
rename from bin/openmetaverse_data/eyebrows_alpha.tga
rename to AppData/openmetaverse_data/eyebrows_alpha.tga
diff --git a/bin/openmetaverse_data/eyeliner_alpha.tga b/AppData/openmetaverse_data/eyeliner_alpha.tga
similarity index 100%
rename from bin/openmetaverse_data/eyeliner_alpha.tga
rename to AppData/openmetaverse_data/eyeliner_alpha.tga
diff --git a/bin/openmetaverse_data/eyeshadow_inner_alpha.tga b/AppData/openmetaverse_data/eyeshadow_inner_alpha.tga
similarity index 100%
rename from bin/openmetaverse_data/eyeshadow_inner_alpha.tga
rename to AppData/openmetaverse_data/eyeshadow_inner_alpha.tga
diff --git a/bin/openmetaverse_data/eyeshadow_outer_alpha.tga b/AppData/openmetaverse_data/eyeshadow_outer_alpha.tga
similarity index 100%
rename from bin/openmetaverse_data/eyeshadow_outer_alpha.tga
rename to AppData/openmetaverse_data/eyeshadow_outer_alpha.tga
diff --git a/bin/openmetaverse_data/eyewhite.tga b/AppData/openmetaverse_data/eyewhite.tga
similarity index 100%
rename from bin/openmetaverse_data/eyewhite.tga
rename to AppData/openmetaverse_data/eyewhite.tga
diff --git a/bin/openmetaverse_data/facehair_chincurtains_alpha.tga b/AppData/openmetaverse_data/facehair_chincurtains_alpha.tga
similarity index 100%
rename from bin/openmetaverse_data/facehair_chincurtains_alpha.tga
rename to AppData/openmetaverse_data/facehair_chincurtains_alpha.tga
diff --git a/bin/openmetaverse_data/facehair_moustache_alpha.tga b/AppData/openmetaverse_data/facehair_moustache_alpha.tga
similarity index 100%
rename from bin/openmetaverse_data/facehair_moustache_alpha.tga
rename to AppData/openmetaverse_data/facehair_moustache_alpha.tga
diff --git a/bin/openmetaverse_data/facehair_sideburns_alpha.tga b/AppData/openmetaverse_data/facehair_sideburns_alpha.tga
similarity index 100%
rename from bin/openmetaverse_data/facehair_sideburns_alpha.tga
rename to AppData/openmetaverse_data/facehair_sideburns_alpha.tga
diff --git a/bin/openmetaverse_data/facehair_soulpatch_alpha.tga b/AppData/openmetaverse_data/facehair_soulpatch_alpha.tga
similarity index 100%
rename from bin/openmetaverse_data/facehair_soulpatch_alpha.tga
rename to AppData/openmetaverse_data/facehair_soulpatch_alpha.tga
diff --git a/bin/openmetaverse_data/freckles_alpha.tga b/AppData/openmetaverse_data/freckles_alpha.tga
similarity index 100%
rename from bin/openmetaverse_data/freckles_alpha.tga
rename to AppData/openmetaverse_data/freckles_alpha.tga
diff --git a/bin/openmetaverse_data/glove_length_alpha.tga b/AppData/openmetaverse_data/glove_length_alpha.tga
similarity index 100%
rename from bin/openmetaverse_data/glove_length_alpha.tga
rename to AppData/openmetaverse_data/glove_length_alpha.tga
diff --git a/bin/openmetaverse_data/gloves_fingers_alpha.tga b/AppData/openmetaverse_data/gloves_fingers_alpha.tga
similarity index 100%
rename from bin/openmetaverse_data/gloves_fingers_alpha.tga
rename to AppData/openmetaverse_data/gloves_fingers_alpha.tga
diff --git a/bin/openmetaverse_data/head_alpha.tga b/AppData/openmetaverse_data/head_alpha.tga
similarity index 100%
rename from bin/openmetaverse_data/head_alpha.tga
rename to AppData/openmetaverse_data/head_alpha.tga
diff --git a/bin/openmetaverse_data/head_color.tga b/AppData/openmetaverse_data/head_color.tga
similarity index 100%
rename from bin/openmetaverse_data/head_color.tga
rename to AppData/openmetaverse_data/head_color.tga
diff --git a/bin/openmetaverse_data/head_hair.tga b/AppData/openmetaverse_data/head_hair.tga
similarity index 100%
rename from bin/openmetaverse_data/head_hair.tga
rename to AppData/openmetaverse_data/head_hair.tga
diff --git a/bin/openmetaverse_data/head_highlights_alpha.tga b/AppData/openmetaverse_data/head_highlights_alpha.tga
similarity index 100%
rename from bin/openmetaverse_data/head_highlights_alpha.tga
rename to AppData/openmetaverse_data/head_highlights_alpha.tga
diff --git a/bin/openmetaverse_data/head_shading_alpha.tga b/AppData/openmetaverse_data/head_shading_alpha.tga
similarity index 100%
rename from bin/openmetaverse_data/head_shading_alpha.tga
rename to AppData/openmetaverse_data/head_shading_alpha.tga
diff --git a/bin/openmetaverse_data/head_skingrain.tga b/AppData/openmetaverse_data/head_skingrain.tga
similarity index 100%
rename from bin/openmetaverse_data/head_skingrain.tga
rename to AppData/openmetaverse_data/head_skingrain.tga
diff --git a/bin/openmetaverse_data/jacket_length_lower_alpha.tga b/AppData/openmetaverse_data/jacket_length_lower_alpha.tga
similarity index 100%
rename from bin/openmetaverse_data/jacket_length_lower_alpha.tga
rename to AppData/openmetaverse_data/jacket_length_lower_alpha.tga
diff --git a/bin/openmetaverse_data/jacket_length_upper_alpha.tga b/AppData/openmetaverse_data/jacket_length_upper_alpha.tga
similarity index 100%
rename from bin/openmetaverse_data/jacket_length_upper_alpha.tga
rename to AppData/openmetaverse_data/jacket_length_upper_alpha.tga
diff --git a/bin/openmetaverse_data/jacket_open_lower_alpha.tga b/AppData/openmetaverse_data/jacket_open_lower_alpha.tga
similarity index 100%
rename from bin/openmetaverse_data/jacket_open_lower_alpha.tga
rename to AppData/openmetaverse_data/jacket_open_lower_alpha.tga
diff --git a/bin/openmetaverse_data/jacket_open_upper_alpha.tga b/AppData/openmetaverse_data/jacket_open_upper_alpha.tga
similarity index 100%
rename from bin/openmetaverse_data/jacket_open_upper_alpha.tga
rename to AppData/openmetaverse_data/jacket_open_upper_alpha.tga
diff --git a/bin/openmetaverse_data/lipgloss_alpha.tga b/AppData/openmetaverse_data/lipgloss_alpha.tga
similarity index 100%
rename from bin/openmetaverse_data/lipgloss_alpha.tga
rename to AppData/openmetaverse_data/lipgloss_alpha.tga
diff --git a/bin/openmetaverse_data/lips_mask.tga b/AppData/openmetaverse_data/lips_mask.tga
similarity index 100%
rename from bin/openmetaverse_data/lips_mask.tga
rename to AppData/openmetaverse_data/lips_mask.tga
diff --git a/bin/openmetaverse_data/lipstick_alpha.tga b/AppData/openmetaverse_data/lipstick_alpha.tga
similarity index 100%
rename from bin/openmetaverse_data/lipstick_alpha.tga
rename to AppData/openmetaverse_data/lipstick_alpha.tga
diff --git a/bin/openmetaverse_data/lowerbody_color.tga b/AppData/openmetaverse_data/lowerbody_color.tga
similarity index 100%
rename from bin/openmetaverse_data/lowerbody_color.tga
rename to AppData/openmetaverse_data/lowerbody_color.tga
diff --git a/bin/openmetaverse_data/lowerbody_highlights_alpha.tga b/AppData/openmetaverse_data/lowerbody_highlights_alpha.tga
similarity index 100%
rename from bin/openmetaverse_data/lowerbody_highlights_alpha.tga
rename to AppData/openmetaverse_data/lowerbody_highlights_alpha.tga
diff --git a/bin/openmetaverse_data/lowerbody_shading_alpha.tga b/AppData/openmetaverse_data/lowerbody_shading_alpha.tga
similarity index 100%
rename from bin/openmetaverse_data/lowerbody_shading_alpha.tga
rename to AppData/openmetaverse_data/lowerbody_shading_alpha.tga
diff --git a/bin/openmetaverse_data/nailpolish_alpha.tga b/AppData/openmetaverse_data/nailpolish_alpha.tga
similarity index 100%
rename from bin/openmetaverse_data/nailpolish_alpha.tga
rename to AppData/openmetaverse_data/nailpolish_alpha.tga
diff --git a/bin/openmetaverse_data/pants_length_alpha.tga b/AppData/openmetaverse_data/pants_length_alpha.tga
similarity index 100%
rename from bin/openmetaverse_data/pants_length_alpha.tga
rename to AppData/openmetaverse_data/pants_length_alpha.tga
diff --git a/bin/openmetaverse_data/pants_waist_alpha.tga b/AppData/openmetaverse_data/pants_waist_alpha.tga
similarity index 100%
rename from bin/openmetaverse_data/pants_waist_alpha.tga
rename to AppData/openmetaverse_data/pants_waist_alpha.tga
diff --git a/bin/openmetaverse_data/rosyface_alpha.tga b/AppData/openmetaverse_data/rosyface_alpha.tga
similarity index 100%
rename from bin/openmetaverse_data/rosyface_alpha.tga
rename to AppData/openmetaverse_data/rosyface_alpha.tga
diff --git a/bin/openmetaverse_data/rouge_alpha.tga b/AppData/openmetaverse_data/rouge_alpha.tga
similarity index 100%
rename from bin/openmetaverse_data/rouge_alpha.tga
rename to AppData/openmetaverse_data/rouge_alpha.tga
diff --git a/bin/openmetaverse_data/shirt_bottom_alpha.tga b/AppData/openmetaverse_data/shirt_bottom_alpha.tga
similarity index 100%
rename from bin/openmetaverse_data/shirt_bottom_alpha.tga
rename to AppData/openmetaverse_data/shirt_bottom_alpha.tga
diff --git a/bin/openmetaverse_data/shirt_collar_alpha.tga b/AppData/openmetaverse_data/shirt_collar_alpha.tga
similarity index 100%
rename from bin/openmetaverse_data/shirt_collar_alpha.tga
rename to AppData/openmetaverse_data/shirt_collar_alpha.tga
diff --git a/bin/openmetaverse_data/shirt_collar_back_alpha.tga b/AppData/openmetaverse_data/shirt_collar_back_alpha.tga
similarity index 100%
rename from bin/openmetaverse_data/shirt_collar_back_alpha.tga
rename to AppData/openmetaverse_data/shirt_collar_back_alpha.tga
diff --git a/bin/openmetaverse_data/shirt_sleeve_alpha.tga b/AppData/openmetaverse_data/shirt_sleeve_alpha.tga
similarity index 100%
rename from bin/openmetaverse_data/shirt_sleeve_alpha.tga
rename to AppData/openmetaverse_data/shirt_sleeve_alpha.tga
diff --git a/bin/openmetaverse_data/shoe_height_alpha.tga b/AppData/openmetaverse_data/shoe_height_alpha.tga
similarity index 100%
rename from bin/openmetaverse_data/shoe_height_alpha.tga
rename to AppData/openmetaverse_data/shoe_height_alpha.tga
diff --git a/bin/openmetaverse_data/skirt_length_alpha.tga b/AppData/openmetaverse_data/skirt_length_alpha.tga
similarity index 100%
rename from bin/openmetaverse_data/skirt_length_alpha.tga
rename to AppData/openmetaverse_data/skirt_length_alpha.tga
diff --git a/bin/openmetaverse_data/skirt_slit_back_alpha.tga b/AppData/openmetaverse_data/skirt_slit_back_alpha.tga
similarity index 100%
rename from bin/openmetaverse_data/skirt_slit_back_alpha.tga
rename to AppData/openmetaverse_data/skirt_slit_back_alpha.tga
diff --git a/bin/openmetaverse_data/skirt_slit_front_alpha.tga b/AppData/openmetaverse_data/skirt_slit_front_alpha.tga
similarity index 100%
rename from bin/openmetaverse_data/skirt_slit_front_alpha.tga
rename to AppData/openmetaverse_data/skirt_slit_front_alpha.tga
diff --git a/bin/openmetaverse_data/skirt_slit_left_alpha.tga b/AppData/openmetaverse_data/skirt_slit_left_alpha.tga
similarity index 100%
rename from bin/openmetaverse_data/skirt_slit_left_alpha.tga
rename to AppData/openmetaverse_data/skirt_slit_left_alpha.tga
diff --git a/bin/openmetaverse_data/skirt_slit_right_alpha.tga b/AppData/openmetaverse_data/skirt_slit_right_alpha.tga
similarity index 100%
rename from bin/openmetaverse_data/skirt_slit_right_alpha.tga
rename to AppData/openmetaverse_data/skirt_slit_right_alpha.tga
diff --git a/bin/openmetaverse_data/underpants_trial_female.tga b/AppData/openmetaverse_data/underpants_trial_female.tga
similarity index 100%
rename from bin/openmetaverse_data/underpants_trial_female.tga
rename to AppData/openmetaverse_data/underpants_trial_female.tga
diff --git a/bin/openmetaverse_data/underpants_trial_male.tga b/AppData/openmetaverse_data/underpants_trial_male.tga
similarity index 100%
rename from bin/openmetaverse_data/underpants_trial_male.tga
rename to AppData/openmetaverse_data/underpants_trial_male.tga
diff --git a/bin/openmetaverse_data/undershirt_trial_female.tga b/AppData/openmetaverse_data/undershirt_trial_female.tga
similarity index 100%
rename from bin/openmetaverse_data/undershirt_trial_female.tga
rename to AppData/openmetaverse_data/undershirt_trial_female.tga
diff --git a/bin/openmetaverse_data/upperbody_color.tga b/AppData/openmetaverse_data/upperbody_color.tga
similarity index 100%
rename from bin/openmetaverse_data/upperbody_color.tga
rename to AppData/openmetaverse_data/upperbody_color.tga
diff --git a/bin/openmetaverse_data/upperbody_highlights_alpha.tga b/AppData/openmetaverse_data/upperbody_highlights_alpha.tga
similarity index 100%
rename from bin/openmetaverse_data/upperbody_highlights_alpha.tga
rename to AppData/openmetaverse_data/upperbody_highlights_alpha.tga
diff --git a/bin/openmetaverse_data/upperbody_shading_alpha.tga b/AppData/openmetaverse_data/upperbody_shading_alpha.tga
similarity index 100%
rename from bin/openmetaverse_data/upperbody_shading_alpha.tga
rename to AppData/openmetaverse_data/upperbody_shading_alpha.tga
diff --git a/bin/openmetaverse_data/upperbodyfreckles_alpha.tga b/AppData/openmetaverse_data/upperbodyfreckles_alpha.tga
similarity index 100%
rename from bin/openmetaverse_data/upperbodyfreckles_alpha.tga
rename to AppData/openmetaverse_data/upperbodyfreckles_alpha.tga
diff --git a/CSJ2K/CSJ2K.csproj b/CSJ2K/CSJ2K.csproj
deleted file mode 100644
index ee641e1f..00000000
--- a/CSJ2K/CSJ2K.csproj
+++ /dev/null
@@ -1,16 +0,0 @@
-
-
- Local
- net48
- CSJ2K
- CSJ2K
- JPEG2000 decoding library
- True
- 1591,1574,0419,0618
-
- true
-
-
-
-
-
\ No newline at end of file
diff --git a/CSJ2K/Color/ChannelDefinitionMapper.cs b/CSJ2K/Color/ChannelDefinitionMapper.cs
deleted file mode 100644
index 17f39081..00000000
--- a/CSJ2K/Color/ChannelDefinitionMapper.cs
+++ /dev/null
@@ -1,218 +0,0 @@
-/// **************************************************************************
-///
-/// $Id: ChannelDefinitionMapper.java,v 1.2 2002/08/08 14:06:53 grosbois Exp $
-///
-/// Copyright Eastman Kodak Company, 343 State Street, Rochester, NY 14650
-/// $Date $
-/// ***************************************************************************
-///
-using CSJ2K.j2k.image;
-namespace CSJ2K.Color
-{
-
- /// This class is responsible for the mapping between
- /// requested components and image channels.
- ///
- ///
- ///
- ///
- /// 1.0
- ///
- /// Bruce A. Kern
- ///
- public class ChannelDefinitionMapper : ColorSpaceMapper
- {
- /// Factory method for creating instances of this class.
- /// -- source of image data
- ///
- /// -- provides colorspace info
- ///
- /// ChannelDefinitionMapper instance
- ///
- ///
- ///
- public static new BlkImgDataSrc createInstance(BlkImgDataSrc src, ColorSpace csMap)
- {
-
- return new ChannelDefinitionMapper(src, csMap);
- }
-
- /// Ctor which creates an ICCProfile for the image and initializes
- /// all data objects (input, working, and output).
- ///
- ///
- /// -- Source of image data
- ///
- /// -- provides colorspace info
- ///
- protected internal ChannelDefinitionMapper(BlkImgDataSrc src, ColorSpace csMap) : base(src, csMap)
- {
- /* end ChannelDefinitionMapper ctor */
- }
-
-
- /// Returns, in the blk argument, a block of image data containing the
- /// specifed rectangular area, in the specified component. The data is
- /// returned, as a copy of the internal data, therefore the returned data
- /// can be modified "in place".
- ///
- /// The rectangular area to return is specified by the 'ulx', 'uly', 'w'
- /// and 'h' members of the 'blk' argument, relative to the current
- /// tile. These members are not modified by this method. The 'offset' of
- /// the returned data is 0, and the 'scanw' is the same as the block's
- /// width. See the 'DataBlk' class.
- ///
- ///
If the data array in 'blk' is 'null', then a new one is created. If
- /// the data array is not 'null' then it is reused, and it must be large
- /// enough to contain the block's data. Otherwise an 'ArrayStoreException'
- /// or an 'IndexOutOfBoundsException' is thrown by the Java system.
- ///
- ///
The returned data has its 'progressive' attribute set to that of the
- /// input data.
- ///
- ///
- /// Its coordinates and dimensions specify the area to
- /// return. If it contains a non-null data array, then it must have the
- /// correct dimensions. If it contains a null data array a new one is
- /// created. The fields in this object are modified to return the data.
- ///
- ///
- /// The index of the component from which to get the data. Only 0
- /// and 3 are valid.
- ///
- ///
- /// The requested DataBlk
- ///
- ///
- ///
- ///
- ///
- public override DataBlk getCompData(DataBlk out_Renamed, int c)
- {
- return src.getCompData(out_Renamed, csMap.getChannelDefinition(c));
- }
-
- /// Returns, in the blk argument, a block of image data containing the
- /// specifed rectangular area, in the specified component. The data is
- /// returned, as a copy of the internal data, therefore the returned data
- /// can be modified "in place".
- ///
- /// The rectangular area to return is specified by the 'ulx', 'uly', 'w'
- /// and 'h' members of the 'blk' argument, relative to the current
- /// tile. These members are not modified by this method. The 'offset' of
- /// the returned data is 0, and the 'scanw' is the same as the block's
- /// width. See the 'DataBlk' class.
- ///
- ///
This method, in general, is less efficient than the
- /// 'getInternCompData()' method since, in general, it copies the
- /// data. However if the array of returned data is to be modified by the
- /// caller then this method is preferable.
- ///
- ///
If the data array in 'blk' is 'null', then a new one is created. If
- /// the data array is not 'null' then it is reused, and it must be large
- /// enough to contain the block's data. Otherwise an 'ArrayStoreException'
- /// or an 'IndexOutOfBoundsException' is thrown by the Java system.
- ///
- ///
The returned data may have its 'progressive' attribute set. In this
- /// case the returned data is only an approximation of the "final" data.
- ///
- ///
- /// Its coordinates and dimensions specify the area to return,
- /// relative to the current tile. If it contains a non-null data array,
- /// then it must be large enough. If it contains a null data array a new
- /// one is created. Some fields in this object are modified to return the
- /// data.
- ///
- ///
- /// The index of the component from which to get the data.
- ///
- ///
- ///
- ///
- ///
- public override DataBlk getInternCompData(DataBlk out_Renamed, int c)
- {
- return src.getInternCompData(out_Renamed, csMap.getChannelDefinition(c));
- }
-
- /// Returns the number of bits, referred to as the "range bits",
- /// corresponding to the nominal range of the data in the specified
- /// component. If this number is b then for unsigned data the
- /// nominal range is between 0 and 2^b-1, and for signed data it is between
- /// -2^(b-1) and 2^(b-1)-1. For floating point data this value is not
- /// applicable.
- ///
- ///
- /// The index of the component.
- ///
- ///
- /// The number of bits corresponding to the nominal range of the
- /// data. Fro floating-point data this value is not applicable and the
- /// return value is undefined.
- ///
- public override int getFixedPoint(int c)
- {
- return src.getFixedPoint(csMap.getChannelDefinition(c));
- }
-
- public override int getNomRangeBits(int c)
- {
- return src.getNomRangeBits(csMap.getChannelDefinition(c));
- }
-
- public override int getCompImgHeight(int c)
- {
- return src.getCompImgHeight(csMap.getChannelDefinition(c));
- }
-
- public override int getCompImgWidth(int c)
- {
- return src.getCompImgWidth(csMap.getChannelDefinition(c));
- }
-
- public override int getCompSubsX(int c)
- {
- return src.getCompSubsX(csMap.getChannelDefinition(c));
- }
-
- public override int getCompSubsY(int c)
- {
- return src.getCompSubsY(csMap.getChannelDefinition(c));
- }
-
- public override int getCompULX(int c)
- {
- return src.getCompULX(csMap.getChannelDefinition(c));
- }
-
- public override int getCompULY(int c)
- {
- return src.getCompULY(csMap.getChannelDefinition(c));
- }
-
- public override int getTileCompHeight(int t, int c)
- {
- return src.getTileCompHeight(t, csMap.getChannelDefinition(c));
- }
-
- public override int getTileCompWidth(int t, int c)
- {
- return src.getTileCompWidth(t, csMap.getChannelDefinition(c));
- }
-
- public override System.String ToString()
- {
- int i;
- System.Text.StringBuilder rep = new System.Text.StringBuilder("[ChannelDefinitionMapper nchannels= ").Append(ncomps);
-
- for (i = 0; i < ncomps; ++i)
- {
- rep.Append(eol).Append(" component[").Append(i).Append("] mapped to channel[").Append(csMap.getChannelDefinition(i)).Append("]");
- }
-
- return rep.Append("]").ToString();
- }
-
- /* end class ChannelDefinitionMapper */
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/Color/ColorSpace.cs b/CSJ2K/Color/ColorSpace.cs
deleted file mode 100644
index d3cbaeda..00000000
--- a/CSJ2K/Color/ColorSpace.cs
+++ /dev/null
@@ -1,409 +0,0 @@
-using ChannelDefinitionBox = CSJ2K.Color.Boxes.ChannelDefinitionBox;
-using ColorSpecificationBox = CSJ2K.Color.Boxes.ColorSpecificationBox;
-using ComponentMappingBox = CSJ2K.Color.Boxes.ComponentMappingBox;
-using HeaderDecoder = CSJ2K.j2k.codestream.reader.HeaderDecoder;
-using ImageHeaderBox = CSJ2K.Color.Boxes.ImageHeaderBox;
-using PaletteBox = CSJ2K.Color.Boxes.PaletteBox;
-/// **************************************************************************
-///
-/// $Id: ColorSpace.java,v 1.2 2002/07/25 16:31:11 grosbois Exp $
-///
-/// Copyright Eastman Kodak Company, 343 State Street, Rochester, NY 14650
-/// $Date $
-/// ***************************************************************************
-///
-using ParameterList = CSJ2K.j2k.util.ParameterList;
-using RandomAccessIO = CSJ2K.j2k.io.RandomAccessIO;
-namespace CSJ2K.Color
-{
-
- /// This class analyzes the image to provide colorspace
- /// information for the decoding chain. It does this by
- /// examining the box structure of the JP2 image.
- /// It also provides access to the parameter list information,
- /// which is stored as a public final field.
- ///
- ///
- ///
- ///
- /// 1.0
- ///
- /// Bruce A. Kern
- ///
- public class ColorSpace
- {
- /// Retrieve the ICC profile from the images as
- /// a byte array.
- ///
- /// the ICC Profile as a byte [].
- ///
- virtual public byte[] ICCProfile
- {
- get
- {
- return csbox.ICCProfile;
- }
-
- }
- /// Return the colorspace method (Profiled, enumerated, or palettized).
- virtual public MethodEnum Method
- {
- get
- {
- return csbox.Method;
- }
-
- }
- /// Return number of channels in the palette.
- virtual public PaletteBox PaletteBox
- {
- get
- {
- return pbox;
- }
-
- }
- /// Return number of channels in the palette.
- virtual public int PaletteChannels
- {
- get
- {
- return pbox == null ? 0 : pbox.NumColumns;
- }
-
- }
- /// Is palettized predicate.
- virtual public bool Palettized
- {
- get
- {
- return pbox != null;
- }
-
- }
- //UPGRADE_NOTE: Final was removed from the declaration of 'eol '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- public static readonly System.String eol = System.Environment.NewLine;
-
- // Renamed for convenience:
- internal const int GRAY = 0;
- internal const int RED = 1;
- internal const int GREEN = 2;
- internal const int BLUE = 3;
-
- /// Parameter Specs
- public ParameterList pl;
-
- /// Parameter Specs
- public HeaderDecoder hd;
-
- /* Image box structure as pertains to colorspacees. */
- private PaletteBox pbox = null;
- private ComponentMappingBox cmbox = null;
- private ColorSpecificationBox csbox = null;
- private ChannelDefinitionBox cdbox = null;
- private ImageHeaderBox ihbox = null;
-
- /// Input image
- private RandomAccessIO in_Renamed = null;
-
- /// Indent a String that contains newlines.
- public static System.String indent(System.String ident, System.Text.StringBuilder instr)
- {
- return indent(ident, instr.ToString());
- }
-
- /// Indent a String that contains newlines.
- public static System.String indent(System.String ident, System.String instr)
- {
- System.Text.StringBuilder tgt = new System.Text.StringBuilder(instr);
- char eolChar = eol[0];
- int i = tgt.Length;
- while (--i > 0)
- {
- if (tgt[i] == eolChar)
- tgt.Insert(i + 1, ident);
- }
- return ident + tgt.ToString();
- }
-
- /// public constructor which takes in the image, parameterlist and the
- /// image header decoder as args.
- ///
- /// input RandomAccess image file.
- ///
- /// provides information about the image header.
- ///
- /// provides parameters from the default and commandline lists.
- ///
- /// ColorSpaceException
- ///
- public ColorSpace(RandomAccessIO in_Renamed, HeaderDecoder hd, ParameterList pl)
- {
- this.pl = pl;
- this.in_Renamed = in_Renamed;
- this.hd = hd;
- getBoxes();
- }
-
- /// Retrieve the various boxes from the JP2 file.
- /// IOException
- ///
- protected internal void getBoxes()
- {
- //byte[] data;
- int type;
- long len = 0;
- int boxStart = 0;
- byte[] boxHeader = new byte[16];
- int i = 0;
-
- // Search the toplevel boxes for the header box
- while (true)
- {
- in_Renamed.seek(boxStart);
- in_Renamed.readFully(boxHeader, 0, 16);
- // CONVERSION PROBLEM?
-
- len = (long)CSJ2K.Icc.ICCProfile.getInt(boxHeader, 0);
- if (len == 1)
- len = CSJ2K.Icc.ICCProfile.getLong(boxHeader, 8); // Extended
- // length
- type = CSJ2K.Icc.ICCProfile.getInt(boxHeader, 4);
-
- // Verify the contents of the file so far.
- if (i == 0 && type != CSJ2K.j2k.fileformat.FileFormatBoxes.JP2_SIGNATURE_BOX)
- {
- throw new ColorSpaceException("first box in image not " + "signature");
- }
- else if (i == 1 && type != CSJ2K.j2k.fileformat.FileFormatBoxes.FILE_TYPE_BOX)
- {
- throw new ColorSpaceException("second box in image not file");
- }
- else if (type == CSJ2K.j2k.fileformat.FileFormatBoxes.CONTIGUOUS_CODESTREAM_BOX)
- {
- throw new ColorSpaceException("header box not found in image");
- }
- else if (type == CSJ2K.j2k.fileformat.FileFormatBoxes.JP2_HEADER_BOX)
- {
- break;
- }
-
- // Progress to the next box.
- ++i;
- boxStart = (int)(boxStart + len);
- }
-
- // boxStart indexes the start of the JP2_HEADER_BOX,
- // make headerBoxEnd index the end of the box.
- long headerBoxEnd = boxStart + len;
-
- if (len == 1)
- boxStart += 8; // Extended length header
-
- for (boxStart += 8; boxStart < headerBoxEnd; boxStart = (int)(boxStart + len))
- {
- in_Renamed.seek(boxStart);
- in_Renamed.readFully(boxHeader, 0, 16);
- len = (long)CSJ2K.Icc.ICCProfile.getInt(boxHeader, 0);
- if (len == 1)
- throw new ColorSpaceException("Extended length boxes " + "not supported");
- type = (int)CSJ2K.Icc.ICCProfile.getInt(boxHeader, 4);
-
- switch (type)
- {
-
- case CSJ2K.j2k.fileformat.FileFormatBoxes.IMAGE_HEADER_BOX:
- ihbox = new ImageHeaderBox(in_Renamed, boxStart);
- break;
-
- case CSJ2K.j2k.fileformat.FileFormatBoxes.COLOUR_SPECIFICATION_BOX:
- csbox = new ColorSpecificationBox(in_Renamed, boxStart);
- break;
-
- case CSJ2K.j2k.fileformat.FileFormatBoxes.CHANNEL_DEFINITION_BOX:
- cdbox = new ChannelDefinitionBox(in_Renamed, boxStart);
- break;
-
- case CSJ2K.j2k.fileformat.FileFormatBoxes.COMPONENT_MAPPING_BOX:
- cmbox = new ComponentMappingBox(in_Renamed, boxStart);
- break;
-
- case CSJ2K.j2k.fileformat.FileFormatBoxes.PALETTE_BOX:
- pbox = new PaletteBox(in_Renamed, boxStart);
- break;
-
- default:
- break;
-
- }
- }
-
- if (ihbox == null)
- throw new ColorSpaceException("image header box not found");
-
- if ((pbox == null && cmbox != null) || (pbox != null && cmbox == null))
- throw new ColorSpaceException("palette box and component " + "mapping box inconsistency");
- }
-
-
- /// Return the channel definition of the input component.
- public virtual int getChannelDefinition(int c)
- {
- if (cdbox == null)
- return c;
- else
- return cdbox.getCn(c + 1);
- }
-
- /// Return the colorspace (sYCC, sRGB, sGreyScale).
- public virtual CSEnum getColorSpace()
- {
- return csbox.ColorSpace;
- }
-
- /// Return bitdepth of the palette entries.
- public virtual int getPaletteChannelBits(int c)
- {
- return pbox == null ? 0 : (int)pbox.getBitDepth(c);
- }
-
- /// Return a palettized sample
- /// requested
- ///
- /// of entry
- ///
- /// palettized sample
- ///
- public virtual int getPalettizedSample(int channel, int index)
- {
- return pbox == null ? 0 : pbox.getEntry(channel, index);
- }
-
- /// Signed output predicate.
- public virtual bool isOutputSigned(int channel)
- {
- return (pbox != null) ? pbox.isSigned(channel) : hd.isOriginalSigned(channel);
- }
-
- /// Return a suitable String representation of the class instance.
- public override System.String ToString()
- {
- System.Text.StringBuilder rep = new System.Text.StringBuilder("[ColorSpace is ").Append(csbox.MethodString).Append(Palettized ? " and palettized " : " ").Append(Method == MethodEnum.ENUMERATED ? csbox.ColorSpaceString : "");
- if (ihbox != null)
- {
- rep.Append(eol).Append(indent(" ", ihbox.ToString()));
- }
- if (cdbox != null)
- {
- rep.Append(eol).Append(indent(" ", cdbox.ToString()));
- }
- if (csbox != null)
- {
- rep.Append(eol).Append(indent(" ", csbox.ToString()));
- }
- if (pbox != null)
- {
- rep.Append(eol).Append(indent(" ", pbox.ToString()));
- }
- if (cmbox != null)
- {
- rep.Append(eol).Append(indent(" ", cmbox.ToString()));
- }
- return rep.Append("]").ToString();
- }
-
- /// Are profiling diagnostics turned on
- /// yes or no
- ///
- public virtual bool debugging()
- {
- return pl.Get("colorspace_debug") != null && pl.Get("colorspace_debug").ToUpper().Equals("on".ToUpper());
- }
-
-
- public enum MethodEnum
- {
- ICC_PROFILED,
- ENUMERATED
- }
- public enum CSEnum
- {
- sRGB,
- GreyScale,
- sYCC,
- esRGB,
- Illegal,
- Unknown
- }
- /* Enumeration Class */
- /*
- /// method enumeration
- //UPGRADE_NOTE: Final was removed from the declaration of 'ICC_PROFILED '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- public const MethodEnum ICC_PROFILED = new MethodEnum("profiled");
- /// method enumeration
- //UPGRADE_NOTE: Final was removed from the declaration of 'ENUMERATED '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- public const MethodEnum ENUMERATED = new MethodEnum("enumerated");
-
- /// colorspace enumeration
- //UPGRADE_NOTE: Final was removed from the declaration of 'sRGB '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- public const CSEnum sRGB = new CSEnum("sRGB");
- /// colorspace enumeration
- //UPGRADE_NOTE: Final was removed from the declaration of 'GreyScale '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- public const CSEnum GreyScale = new CSEnum("GreyScale");
- /// colorspace enumeration
- //UPGRADE_NOTE: Final was removed from the declaration of 'sYCC '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- public const CSEnum sYCC = new CSEnum("sYCC");
- /// colorspace enumeration
- //UPGRADE_NOTE: Final was removed from the declaration of 'Illegal '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- public const CSEnum Illegal = new CSEnum("Illegal");
- /// colorspace enumeration
- //UPGRADE_NOTE: Final was removed from the declaration of 'Unknown '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- public const CSEnum Unknown = new CSEnum("Unknown");
-
- /// Typesafe enumeration class
- /// 1.0
- ///
- /// Bruce A Kern
- ///
- public class Enumeration
- {
- //UPGRADE_NOTE: Final was removed from the declaration of 'value '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- public System.String value_Renamed;
- public Enumeration(System.String value_Renamed)
- {
- this.value_Renamed = value_Renamed;
- }
- public override System.String ToString()
- {
- return value_Renamed;
- }
- }
-
-
- /// Method enumeration class
- /// 1.0
- ///
- /// Bruce A Kern
- ///
- public class MethodEnum:Enumeration
- {
- public MethodEnum(System.String value_Renamed):base(value_Renamed)
- {
- }
- }
-
- /// Colorspace enumeration class
- /// 1.0
- ///
- /// Bruce A Kern
- ///
- public class CSEnum:Enumeration
- {
- public CSEnum(System.String value_Renamed):base(value_Renamed)
- {
- }
- }
- */
- /* end class ColorSpace */
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/Color/ColorSpaceException.cs b/CSJ2K/Color/ColorSpaceException.cs
deleted file mode 100644
index 2f01779f..00000000
--- a/CSJ2K/Color/ColorSpaceException.cs
+++ /dev/null
@@ -1,43 +0,0 @@
-/// **************************************************************************
-///
-/// $Id: ColorSpaceException.java,v 1.1 2002/07/25 14:52:00 grosbois Exp $
-///
-/// Copyright Eastman Kodak Company, 343 State Street, Rochester, NY 14650
-/// $Date $
-/// ***************************************************************************
-///
-using System;
-namespace CSJ2K.Color
-{
-
- /// This exception is thrown when the content of an
- /// image contains an incorrect colorspace box
- ///
- ///
- ///
- ///
- /// 1.0
- ///
- /// Bruce A. Kern
- ///
-
- [Serializable]
- public class ColorSpaceException : System.Exception
- {
-
- /// Contruct with message
- /// returned by getMessage()
- ///
- public ColorSpaceException(System.String msg) : base(msg)
- {
- }
-
-
- /// Empty constructor
- public ColorSpaceException()
- {
- }
-
- /* end class ColorSpaceException */
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/Color/ColorSpaceMapper.cs b/CSJ2K/Color/ColorSpaceMapper.cs
deleted file mode 100644
index ed9f53b4..00000000
--- a/CSJ2K/Color/ColorSpaceMapper.cs
+++ /dev/null
@@ -1,451 +0,0 @@
-using CSJ2K.Icc;
-/// **************************************************************************
-///
-/// $Id: ColorSpaceMapper.java,v 1.2 2002/07/25 16:30:55 grosbois Exp $
-///
-/// Copyright Eastman Kodak Company, 343 State Street, Rochester, NY 14650
-/// $Date $
-/// ***************************************************************************
-///
-using CSJ2K.j2k.image;
-using CSJ2K.j2k.util;
-namespace CSJ2K.Color
-{
-
- /// This is the base class for all modules in the colorspace and icc
- /// profiling steps of the decoding chain. It is responsible for the
- /// allocation and iniitialization of all working storage. It provides
- /// several utilities which are of generic use in preparing DataBlks
- /// for use and provides default implementations for the getCompData
- /// and getInternCompData methods.
- ///
- ///
- ///
- ///
- /// 1.0
- ///
- /// Bruce A. Kern
- ///
- public abstract class ColorSpaceMapper : ImgDataAdapter, BlkImgDataSrc
- {
- private void InitBlock()
- {
- computed = new ComputedComponents(this);
- }
- /// Returns the parameters that are used in this class and implementing
- /// classes. It returns a 2D String array. Each of the 1D arrays is for a
- /// different option, and they have 3 elements. The first element is the
- /// option name, the second one is the synopsis and the third one is a long
- /// description of what the parameter is. The synopsis or description may
- /// be 'null', in which case it is assumed that there is no synopsis or
- /// description of the option, respectively. Null may be returned if no
- /// options are supported.
- ///
- ///
- /// the options name, their synopsis and their explanation, or null
- /// if no options are supported.
- ///
- ///
- public static System.String[][] ParameterInfo
- {
- get
- {
- return pinfo;
- }
-
- }
- /// Arrange for the input DataBlk to receive an
- /// appropriately sized and typed data buffer
- ///
- /// input DataBlk
- ///
- ///
- ///
- protected internal static DataBlk InternalBuffer
- {
- set
- {
- switch (value.DataType)
- {
-
-
- case DataBlk.TYPE_INT:
- if (value.Data == null || ((int[])value.Data).Length < value.w * value.h)
- value.Data = new int[value.w * value.h];
- break;
-
-
- case DataBlk.TYPE_FLOAT:
- if (value.Data == null || ((float[])value.Data).Length < value.w * value.h)
- {
- value.Data = new float[value.w * value.h];
- }
- break;
-
-
- default:
- throw new System.ArgumentException("Invalid output datablock" + " type");
-
- }
- }
-
- }
-
- /// The prefix for ICC Profiler options
- public const char OPT_PREFIX = 'I';
-
- /// Platform dependant end of line String.
- //UPGRADE_NOTE: Final was removed from the declaration of 'eol '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- protected internal static readonly System.String eol = System.Environment.NewLine;
-
- // Temporary data buffers needed during profiling.
- protected internal DataBlkInt[] inInt; // Integer input data.
- protected internal DataBlkFloat[] inFloat; // Floating point input data.
- protected internal DataBlkInt[] workInt; // Input data shifted to zero-offset
- protected internal DataBlkFloat[] workFloat; // Input data shifted to zero-offset.
- protected internal int[][] dataInt; // Points to input data.
- protected internal float[][] dataFloat; // Points to input data.
- protected internal float[][] workDataFloat; // References working data pixels.
- protected internal int[][] workDataInt; // References working data pixels.
-
-
- /* input data parameters by component */
- protected internal int[] shiftValueArray = null;
- protected internal int[] maxValueArray = null;
- protected internal int[] fixedPtBitsArray = null;
-
- /// The list of parameters that are accepted for ICC profiling.
- //UPGRADE_NOTE: Final was removed from the declaration of 'pinfo'. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- private static readonly System.String[][] pinfo = new System.String[][] { new System.String[] { "IcolorSpacedebug", null, "Print debugging messages during colorspace mapping.", "off" } };
-
- /// Parameter Specs
- protected internal ParameterList pl = null;
-
- /// ColorSpace info
- protected internal ColorSpace csMap = null;
-
- /// Number of image components
- protected internal int ncomps = 0;
-
- /// The image source.
- protected internal BlkImgDataSrc src = null;
-
- /// The image source data per component.
- protected internal DataBlk[] srcBlk = null;
-
-
- //UPGRADE_NOTE: Field 'EnclosingInstance' was added to class 'ComputedComponents' to access its enclosing instance. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1019'"
- protected internal class ComputedComponents
- {
- private void InitBlock(ColorSpaceMapper enclosingInstance)
- {
- this.enclosingInstance = enclosingInstance;
- }
- private ColorSpaceMapper enclosingInstance;
- public ColorSpaceMapper Enclosing_Instance
- {
- get
- {
- return enclosingInstance;
- }
-
- }
- //private int tIdx = - 1;
- private int h = -1;
- private int w = -1;
- private int ulx = -1;
- private int uly = -1;
- private int offset = -1;
- private int scanw = -1;
-
- public ComputedComponents(ColorSpaceMapper enclosingInstance)
- {
- InitBlock(enclosingInstance);
- clear();
- }
-
- public ComputedComponents(ColorSpaceMapper enclosingInstance, DataBlk db)
- {
- InitBlock(enclosingInstance);
- set_Renamed(db);
- }
-
- public virtual void set_Renamed(DataBlk db)
- {
- h = db.h;
- w = db.w;
- ulx = db.ulx;
- uly = db.uly;
- offset = db.offset;
- scanw = db.scanw;
- }
-
- public virtual void clear()
- {
- h = w = ulx = uly = offset = scanw = -1;
- }
-
- public bool Equals(ComputedComponents cc)
- {
- return (h == cc.h && w == cc.w && ulx == cc.ulx && uly == cc.uly && offset == cc.offset && scanw == cc.scanw);
- }
-
- /* end class ComputedComponents */
- }
-
- //UPGRADE_NOTE: The initialization of 'computed' was moved to method 'InitBlock'. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1005'"
- protected internal ComputedComponents computed;
-
- /// Copy the DataBlk geometry from source to target
- /// DataBlk and assure that the target has an appropriate
- /// data buffer.
- ///
- /// has its geometry set.
- ///
- /// used to get the new geometric parameters.
- ///
- protected internal static void copyGeometry(DataBlk tgt, DataBlk src)
- {
- tgt.offset = 0;
- tgt.h = src.h;
- tgt.w = src.w;
- tgt.ulx = src.ulx;
- tgt.uly = src.uly;
- tgt.scanw = src.w;
-
- // Create data array if necessary
-
- InternalBuffer = tgt;
- }
-
-
- /// Factory method for creating instances of this class.
- /// -- source of image data
- ///
- /// -- provides colorspace info
- ///
- /// ColorSpaceMapper instance
- ///
- /// profile access exception
- ///
- public static BlkImgDataSrc createInstance(BlkImgDataSrc src, ColorSpace csMap)
- {
-
- // Check parameters
- csMap.pl.checkList(OPT_PREFIX, CSJ2K.j2k.util.ParameterList.toNameArray(pinfo));
-
- // Perform ICCProfiling or ColorSpace tranfsormation.
- if (csMap.Method == ColorSpace.MethodEnum.ICC_PROFILED)
- {
- return ICCProfiler.createInstance(src, csMap);
- }
- else
- {
- ColorSpace.CSEnum colorspace = csMap.getColorSpace();
-
- if (colorspace == ColorSpace.CSEnum.sRGB)
- {
- return EnumeratedColorSpaceMapper.createInstance(src, csMap);
- }
- else if (colorspace == ColorSpace.CSEnum.GreyScale)
- {
- return EnumeratedColorSpaceMapper.createInstance(src, csMap);
- }
- else if (colorspace == ColorSpace.CSEnum.sYCC)
- {
- return SYccColorSpaceMapper.createInstance(src, csMap);
- }
- if (colorspace == ColorSpace.CSEnum.esRGB)
- {
- return EsRgbColorSpaceMapper.createInstance(src, csMap);
- }
- else if (colorspace == ColorSpace.CSEnum.Unknown)
- {
- return null;
- }
- else
- {
- throw new ColorSpaceException("Bad color space specification in image");
- }
- }
- }
-
- /// Ctor which creates an ICCProfile for the image and initializes
- /// all data objects (input, working, and output).
- ///
- ///
- /// -- Source of image data
- ///
- /// -- provides colorspace info
- ///
- ///
- protected internal ColorSpaceMapper(BlkImgDataSrc src, ColorSpace csMap) : base(src)
- {
- InitBlock();
- this.src = src;
- this.csMap = csMap;
- initialize();
- /* end ColorSpaceMapper ctor */
- }
-
- /// General utility used by ctors
- private void initialize()
- {
-
- this.pl = csMap.pl;
- this.ncomps = src.NumComps;
-
- shiftValueArray = new int[ncomps];
- maxValueArray = new int[ncomps];
- fixedPtBitsArray = new int[ncomps];
-
- srcBlk = new DataBlk[ncomps];
- inInt = new DataBlkInt[ncomps];
- inFloat = new DataBlkFloat[ncomps];
- workInt = new DataBlkInt[ncomps];
- workFloat = new DataBlkFloat[ncomps];
- dataInt = new int[ncomps][];
- dataFloat = new float[ncomps][];
- workDataInt = new int[ncomps][];
- workDataFloat = new float[ncomps][];
- dataInt = new int[ncomps][];
- dataFloat = new float[ncomps][];
-
-
- /* For each component, get a reference to the pixel data and
- * set up working DataBlks for both integer and float output.
- */
- for (int i = 0; i < ncomps; ++i)
- {
-
- shiftValueArray[i] = 1 << (src.getNomRangeBits(i) - 1);
- maxValueArray[i] = (1 << src.getNomRangeBits(i)) - 1;
- fixedPtBitsArray[i] = src.getFixedPoint(i);
-
- inInt[i] = new DataBlkInt();
- inFloat[i] = new DataBlkFloat();
- workInt[i] = new DataBlkInt();
- workInt[i].progressive = inInt[i].progressive;
- workFloat[i] = new DataBlkFloat();
- workFloat[i].progressive = inFloat[i].progressive;
- }
- }
-
- /// Returns the number of bits, referred to as the "range bits",
- /// corresponding to the nominal range of the data in the specified
- /// component. If this number is b then for unsigned data the
- /// nominal range is between 0 and 2^b-1, and for signed data it is between
- /// -2^(b-1) and 2^(b-1)-1. For floating point data this value is not
- /// applicable.
- ///
- ///
- /// The index of the component.
- ///
- ///
- /// The number of bits corresponding to the nominal range of the
- /// data. Fro floating-point data this value is not applicable and the
- /// return value is undefined.
- ///
- public virtual int getFixedPoint(int c)
- {
- return src.getFixedPoint(c);
- }
-
- /// Returns, in the blk argument, a block of image data containing the
- /// specifed rectangular area, in the specified component. The data is
- /// returned, as a copy of the internal data, therefore the returned data
- /// can be modified "in place".
- ///
- /// The rectangular area to return is specified by the 'ulx', 'uly', 'w'
- /// and 'h' members of the 'blk' argument, relative to the current
- /// tile. These members are not modified by this method. The 'offset' of
- /// the returned data is 0, and the 'scanw' is the same as the block's
- /// width. See the 'DataBlk' class.
- ///
- ///
This method, in general, is less efficient than the
- /// 'getInternCompData()' method since, in general, it copies the
- /// data. However if the array of returned data is to be modified by the
- /// caller then this method is preferable.
- ///
- ///
If the data array in 'blk' is 'null', then a new one is created. If
- /// the data array is not 'null' then it is reused, and it must be large
- /// enough to contain the block's data. Otherwise an 'ArrayStoreException'
- /// or an 'IndexOutOfBoundsException' is thrown by the Java system.
- ///
- ///
The returned data may have its 'progressive' attribute set. In this
- /// case the returned data is only an approximation of the "final" data.
- ///
- ///
- /// Its coordinates and dimensions specify the area to return,
- /// relative to the current tile. If it contains a non-null data array,
- /// then it must be large enough. If it contains a null data array a new
- /// one is created. Some fields in this object are modified to return the
- /// data.
- ///
- ///
- /// The index of the component from which to get the data.
- ///
- ///
- ///
- ///
- ///
- public virtual DataBlk getCompData(DataBlk out_Renamed, int c)
- {
- return src.getCompData(out_Renamed, c);
- }
-
- /// Returns, in the blk argument, a block of image data containing the
- /// specifed rectangular area, in the specified component. The data is
- /// returned, as a reference to the internal data, if any, instead of as a
- /// copy, therefore the returned data should not be modified.
- ///
- /// The rectangular area to return is specified by the 'ulx', 'uly', 'w'
- /// and 'h' members of the 'blk' argument, relative to the current
- /// tile. These members are not modified by this method. The 'offset' and
- /// 'scanw' of the returned data can be arbitrary. See the 'DataBlk' class.
- ///
- ///
This method, in general, is more efficient than the 'getCompData()'
- /// method since it may not copy the data. However if the array of returned
- /// data is to be modified by the caller then the other method is probably
- /// preferable.
- ///
- ///
If possible, the data in the returned 'DataBlk' should be the
- /// internal data itself, instead of a copy, in order to increase the data
- /// transfer efficiency. However, this depends on the particular
- /// implementation (it may be more convenient to just return a copy of the
- /// data). This is the reason why the returned data should not be modified.
- ///
- ///
If the data array in blk is null, then a new one
- /// is created if necessary. The implementation of this interface may
- /// choose to return the same array or a new one, depending on what is more
- /// efficient. Therefore, the data array in blk prior to the
- /// method call should not be considered to contain the returned data, a
- /// new array may have been created. Instead, get the array from
- /// blk after the method has returned.
- ///
- ///
The returned data may have its 'progressive' attribute set. In this
- /// case the returned data is only an approximation of the "final" data.
- ///
- ///
- /// Its coordinates and dimensions specify the area to return,
- /// relative to the current tile. Some fields in this object are modified
- /// to return the data.
- ///
- ///
- /// The index of the component from which to get the data.
- ///
- ///
- /// The requested DataBlk
- ///
- ///
- ///
- ///
- ///
- public virtual DataBlk getInternCompData(DataBlk out_Renamed, int c)
- {
- return src.getInternCompData(out_Renamed, c);
- }
-
- /* end class ColorSpaceMapper */
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/Color/EnumeratedColorSpaceMapper.cs b/CSJ2K/Color/EnumeratedColorSpaceMapper.cs
deleted file mode 100644
index d9fd0943..00000000
--- a/CSJ2K/Color/EnumeratedColorSpaceMapper.cs
+++ /dev/null
@@ -1,185 +0,0 @@
-/// **************************************************************************
-///
-/// $Id: EnumeratedColorSpaceMapper.java,v 1.1 2002/07/25 14:52:01 grosbois Exp $
-///
-/// Copyright Eastman Kodak Company, 343 State Street, Rochester, NY 14650
-/// $Date $
-/// ***************************************************************************
-///
-using BlkImgDataSrc = CSJ2K.j2k.image.BlkImgDataSrc;
-using DataBlk = CSJ2K.j2k.image.DataBlk;
-namespace CSJ2K.Color
-{
-
- /// This class provides Enumerated ColorSpace API for the jj2000.j2k imaging chain
- /// by implementing the BlkImgDataSrc interface, in particular the getCompData
- /// and getInternCompData methods.
- ///
- ///
- ///
- ///
- /// 1.0
- ///
- /// Bruce A. Kern
- ///
- public class EnumeratedColorSpaceMapper : ColorSpaceMapper
- {
- /// Factory method for creating instances of this class.
- /// -- source of image data
- ///
- /// -- provides colorspace info
- ///
- /// EnumeratedColorSpaceMapper instance
- ///
- public static new BlkImgDataSrc createInstance(BlkImgDataSrc src, ColorSpace csMap)
- {
- return new EnumeratedColorSpaceMapper(src, csMap);
- }
-
- /// Ctor which creates an ICCProfile for the image and initializes
- /// all data objects (input, working, and output).
- ///
- ///
- /// -- Source of image data
- ///
- /// -- provides colorspace info
- ///
- protected internal EnumeratedColorSpaceMapper(BlkImgDataSrc src, ColorSpace csMap) : base(src, csMap)
- {
- /* end EnumeratedColorSpaceMapper ctor */
- }
-
-
- /// Returns, in the blk argument, a block of image data containing the
- /// specifed rectangular area, in the specified component. The data is
- /// returned, as a copy of the internal data, therefore the returned data
- /// can be modified "in place".
- ///
- /// The rectangular area to return is specified by the 'ulx', 'uly', 'w'
- /// and 'h' members of the 'blk' argument, relative to the current
- /// tile. These members are not modified by this method. The 'offset' of
- /// the returned data is 0, and the 'scanw' is the same as the block's
- /// width. See the 'DataBlk' class.
- ///
- ///
If the data array in 'blk' is 'null', then a new one is created. If
- /// the data array is not 'null' then it is reused, and it must be large
- /// enough to contain the block's data. Otherwise an 'ArrayStoreException'
- /// or an 'IndexOutOfBoundsException' is thrown by the Java system.
- ///
- ///
The returned data has its 'progressive' attribute set to that of the
- /// input data.
- ///
- ///
- /// Its coordinates and dimensions specify the area to
- /// return. If it contains a non-null data array, then it must have the
- /// correct dimensions. If it contains a null data array a new one is
- /// created. The fields in this object are modified to return the data.
- ///
- ///
- /// The index of the component from which to get the data. Only 0
- /// and 3 are valid.
- ///
- ///
- /// The requested DataBlk
- ///
- ///
- ///
- ///
- ///
- public override DataBlk getCompData(DataBlk out_Renamed, int c)
- {
- return src.getCompData(out_Renamed, c);
- }
-
- /// Returns, in the blk argument, a block of image data containing the
- /// specifed rectangular area, in the specified component. The data is
- /// returned, as a reference to the internal data, if any, instead of as a
- /// copy, therefore the returned data should not be modified.
- ///
- /// The rectangular area to return is specified by the 'ulx', 'uly', 'w'
- /// and 'h' members of the 'blk' argument, relative to the current
- /// tile. These members are not modified by this method. The 'offset' and
- /// 'scanw' of the returned data can be arbitrary. See the 'DataBlk' class.
- ///
- ///
This method, in general, is more efficient than the 'getCompData()'
- /// method since it may not copy the data. However if the array of returned
- /// data is to be modified by the caller then the other method is probably
- /// preferable.
- ///
- ///
If possible, the data in the returned 'DataBlk' should be the
- /// internal data itself, instead of a copy, in order to increase the data
- /// transfer efficiency. However, this depends on the particular
- /// implementation (it may be more convenient to just return a copy of the
- /// data). This is the reason why the returned data should not be modified.
- ///
- ///
If the data array in blk is null, then a new one
- /// is created if necessary. The implementation of this interface may
- /// choose to return the same array or a new one, depending on what is more
- /// efficient. Therefore, the data array in blk prior to the
- /// method call should not be considered to contain the returned data, a
- /// new array may have been created. Instead, get the array from
- /// blk after the method has returned.
- ///
- ///
The returned data may have its 'progressive' attribute set. In this
- /// case the returned data is only an approximation of the "final" data.
- ///
- ///
- /// Its coordinates and dimensions specify the area to return,
- /// relative to the current tile. Some fields in this object are modified
- /// to return the data.
- ///
- ///
- /// The index of the component from which to get the data.
- ///
- ///
- /// The requested DataBlk
- ///
- ///
- ///
- ///
- ///
- public override DataBlk getInternCompData(DataBlk out_Renamed, int c)
- {
- return src.getInternCompData(out_Renamed, c);
- }
-
-
-
- public override System.String ToString()
- {
- int i;
- System.Text.StringBuilder rep_nComps = new System.Text.StringBuilder("ncomps= ").Append(System.Convert.ToString(ncomps));
-
- System.Text.StringBuilder rep_fixedValue = new System.Text.StringBuilder("fixedPointBits= (");
- System.Text.StringBuilder rep_shiftValue = new System.Text.StringBuilder("shiftValue= (");
- System.Text.StringBuilder rep_maxValue = new System.Text.StringBuilder("maxValue= (");
-
- for (i = 0; i < ncomps; ++i)
- {
- if (i != 0)
- {
- rep_shiftValue.Append(", ");
- rep_maxValue.Append(", ");
- rep_fixedValue.Append(", ");
- }
- rep_shiftValue.Append(System.Convert.ToString(shiftValueArray[i]));
- rep_maxValue.Append(System.Convert.ToString(maxValueArray[i]));
- rep_fixedValue.Append(System.Convert.ToString(fixedPtBitsArray[i]));
- }
-
- rep_shiftValue.Append(")");
- rep_maxValue.Append(")");
- rep_fixedValue.Append(")");
-
- System.Text.StringBuilder rep = new System.Text.StringBuilder("[EnumeratedColorSpaceMapper ");
- rep.Append(rep_nComps);
- rep.Append(eol).Append(" ").Append(rep_shiftValue);
- rep.Append(eol).Append(" ").Append(rep_maxValue);
- rep.Append(eol).Append(" ").Append(rep_fixedValue);
-
- return rep.Append("]").ToString();
- }
-
- /* end class EnumeratedColorSpaceMapper */
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/Color/EsRgbColorSpaceMapper.cs b/CSJ2K/Color/EsRgbColorSpaceMapper.cs
deleted file mode 100644
index ffb2809a..00000000
--- a/CSJ2K/Color/EsRgbColorSpaceMapper.cs
+++ /dev/null
@@ -1,210 +0,0 @@
-/// **************************************************************************
-///
-/// $Id: SYccColorSpaceMapper.java,v 1.1 2002/07/25 14:52:01 grosbois Exp $
-///
-/// Copyright Eastman Kodak Company, 343 State Street, Rochester, NY 14650
-/// $Date $
-/// ***************************************************************************
-///
-using System;
-using BlkImgDataSrc = CSJ2K.j2k.image.BlkImgDataSrc;
-using DataBlk = CSJ2K.j2k.image.DataBlk;
-using DataBlkFloat = CSJ2K.j2k.image.DataBlkFloat;
-using DataBlkInt = CSJ2K.j2k.image.DataBlkInt;
-using FacilityManager = CSJ2K.j2k.util.FacilityManager;
-namespace CSJ2K.Color
-{
-
-
- /// This decodes maps which are defined in the e-sRGB
- /// colorspace into the sRGB colorspace.
- ///
- ///
- ///
- ///
- /// 1.0
- ///
- /// Jason S. Clary
- ///
- public class EsRgbColorSpaceMapper : ColorSpaceMapper
- {
-
- /// Factory method for creating instances of this class.
- /// -- source of image data
- ///
- /// -- provides colorspace info
- ///
- /// SYccColorSpaceMapper instance
- ///
- public static new BlkImgDataSrc createInstance(BlkImgDataSrc src, ColorSpace csMap)
- {
- return new EsRgbColorSpaceMapper(src, csMap);
- }
-
- /// Ctor which creates an ICCProfile for the image and initializes
- /// all data objects (input, working, and output).
- ///
- ///
- /// -- Source of image data
- ///
- /// -- provides colorspace info
- ///
- protected internal EsRgbColorSpaceMapper(BlkImgDataSrc src, ColorSpace csMap) : base(src, csMap)
- {
- initialize();
- }
-
- /// General utility used by ctors
- private void initialize()
- {
-
- if (ncomps != 1 && ncomps != 3)
- {
- System.String msg = "EsRgbColorSpaceMapper: e-sRGB transformation _not_ applied to " + ncomps + " component image";
- FacilityManager.getMsgLogger().printmsg(CSJ2K.j2k.util.MsgLogger_Fields.ERROR, msg);
- throw new ColorSpaceException(msg);
- }
- }
-
-
- ///
- /// Returns, in the blk argument, a block of image data containing the
- /// specifed rectangular area, in the specified component. The data is
- /// returned, as a copy of the internal data, therefore the returned data
- /// can be modified "in place".
- ///
- /// The rectangular area to return is specified by the 'ulx', 'uly', 'w'
- /// and 'h' members of the 'blk' argument, relative to the current
- /// tile. These members are not modified by this method. The 'offset' of
- /// the returned data is 0, and the 'scanw' is the same as the block's
- /// width. See the 'DataBlk' class.
- ///
- /// If the data array in 'blk' is 'null', then a new one is created. If
- /// the data array is not 'null' then it is reused, and it must be large
- /// enough to contain the block's data. Otherwise an 'ArrayStoreException'
- /// or an 'IndexOutOfBoundsException' is thrown by the Java system.
- ///
- /// The returned data has its 'progressive' attribute set to that of the
- /// input data.
- ///
- ///
- /// Its coordinates and dimensions specify the area to
- /// return. If it contains a non-null data array, then it must have the
- /// correct dimensions. If it contains a null data array a new one is
- /// created. The fields in this object are modified to return the data.
- ///
- ///
- /// The index of the component from which to get the data. Only 0
- /// and 3 are valid.
- ///
- ///
- /// The requested DataBlk
- ///
- ///
- ///
- ///
- public override DataBlk getCompData(DataBlk outblk, int c)
- {
-
- int type = outblk.DataType;
- double colors = Math.Pow(2, src.getNomRangeBits(c));
- double bitoff = colors * 0.375D;
- if (type == DataBlk.TYPE_INT)
- {
- DataBlkInt intblk = (DataBlkInt)src.getInternCompData(outblk, c);
-
- for (int i = 0; i < intblk.data_array.Length; i++)
- {
- int tmp = intblk.data_array[i];
-
- tmp += (int)(colors / 2);
- tmp -= (int)bitoff;
- tmp *= 2;
- tmp -= (int)(colors / 2);
-
- intblk.data_array[i] = tmp;
- }
- outblk = intblk;
- }
- else if (type == DataBlk.TYPE_FLOAT)
- {
- FacilityManager.getMsgLogger().printmsg(CSJ2K.j2k.util.MsgLogger_Fields.WARNING, "Unsupported e-sRGB DataType (float)");
-
- DataBlkFloat fltblk = (DataBlkFloat)src.getInternCompData(outblk, c);
- outblk = fltblk;
- }
- return outblk;
- }
-
- /// Returns, in the blk argument, a block of image data containing the
- /// specifed rectangular area, in the specified component. The data is
- /// returned, as a reference to the internal data, if any, instead of as a
- /// copy, therefore the returned data should not be modified.
- ///
- /// The rectangular area to return is specified by the 'ulx', 'uly', 'w'
- /// and 'h' members of the 'blk' argument, relative to the current
- /// tile. These members are not modified by this method. The 'offset' and
- /// 'scanw' of the returned data can be arbitrary. See the 'DataBlk' class.
- ///
- ///
This method, in general, is more efficient than the 'getCompData()'
- /// method since it may not copy the data. However if the array of returned
- /// data is to be modified by the caller then the other method is probably
- /// preferable.
- ///
- ///
If possible, the data in the returned 'DataBlk' should be the
- /// internal data itself, instead of a copy, in order to increase the data
- /// transfer efficiency. However, this depends on the particular
- /// implementation (it may be more convenient to just return a copy of the
- /// data). This is the reason why the returned data should not be modified.
- ///
- ///
If the data array in blk is null, then a new one
- /// is created if necessary. The implementation of this interface may
- /// choose to return the same array or a new one, depending on what is more
- /// efficient. Therefore, the data array in blk prior to the
- /// method call should not be considered to contain the returned data, a
- /// new array may have been created. Instead, get the array from
- /// blk after the method has returned.
- ///
- ///
The returned data may have its 'progressive' attribute set. In this
- /// case the returned data is only an approximation of the "final" data.
- ///
- ///
- /// Its coordinates and dimensions specify the area to return,
- /// relative to the current tile. Some fields in this object are modified
- /// to return the data.
- ///
- ///
- /// The index of the component from which to get the data.
- ///
- ///
- /// The requested DataBlk
- ///
- ///
- ///
- ///
- public override DataBlk getInternCompData(DataBlk out_Renamed, int c)
- {
- return getCompData(out_Renamed, c);
- }
-
- /// Return a suitable String representation of the class instance.
- public override System.String ToString()
- {
- int i;
-
- System.Text.StringBuilder rep_nComps = new System.Text.StringBuilder("ncomps= ").Append(System.Convert.ToString(ncomps));
- System.Text.StringBuilder rep_comps = new System.Text.StringBuilder();
-
- for (i = 0; i < ncomps; ++i)
- {
- rep_comps.Append(" ").Append("component[").Append(System.Convert.ToString(i)).Append("] height, width = (").Append(src.getCompImgHeight(i)).Append(", ").Append(src.getCompImgWidth(i)).Append(")").Append(eol);
- }
-
- System.Text.StringBuilder rep = new System.Text.StringBuilder("[EsRGBColorSpaceMapper ");
- rep.Append(rep_nComps).Append(eol);
- rep.Append(rep_comps).Append(" ");
-
- return rep.Append("]").ToString();
- }
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/Color/PalettizedColorSpaceMapper.cs b/CSJ2K/Color/PalettizedColorSpaceMapper.cs
deleted file mode 100644
index 5a9eca11..00000000
--- a/CSJ2K/Color/PalettizedColorSpaceMapper.cs
+++ /dev/null
@@ -1,471 +0,0 @@
-using CSJ2K.Color.Boxes;
-/// **************************************************************************
-///
-/// $Id: PalettizedColorSpaceMapper.java,v 1.2 2002/08/08 14:07:16 grosbois Exp $
-///
-/// Copyright Eastman Kodak Company, 343 State Street, Rochester, NY 14650
-/// $Date $
-/// ***************************************************************************
-///
-using CSJ2K.j2k.image;
-using CSJ2K.j2k.util;
-namespace CSJ2K.Color
-{
-
- /// This class provides decoding of images with palettized colorspaces.
- /// Here each sample in the input is treated as an index into a color
- /// palette of triplet sRGB output values.
- ///
- ///
- ///
- ///
- /// 1.0
- ///
- /// Bruce A. Kern
- ///
- public class PalettizedColorSpaceMapper : ColorSpaceMapper
- {
- /// Returns the number of components in the image.
- ///
- ///
- /// The number of components in the image.
- ///
- override public int NumComps
- {
- get
- {
- return pbox == null ? src.NumComps : pbox.NumColumns;
- }
-
- }
- internal int[] outShiftValueArray;
- internal int srcChannel = 0;
-
- /// Access to the palette box information.
- private PaletteBox pbox;
-
- /// Factory method for creating instances of this class.
- /// -- source of image data
- ///
- /// -- provides colorspace info
- ///
- /// PalettizedColorSpaceMapper instance
- ///
- public static new BlkImgDataSrc createInstance(BlkImgDataSrc src, ColorSpace csMap)
- {
- return new PalettizedColorSpaceMapper(src, csMap);
- }
-
- /// Ctor which creates an ICCProfile for the image and initializes
- /// all data objects (input, working, and output).
- ///
- ///
- /// -- Source of image data
- ///
- /// -- provides colorspace info
- ///
- protected internal PalettizedColorSpaceMapper(BlkImgDataSrc src, ColorSpace csMap) : base(src, csMap)
- {
- pbox = csMap.PaletteBox;
- initialize();
- }
-
- /// General utility used by ctors
- private void initialize()
- {
- if (ncomps != 1 && ncomps != 3)
- throw new ColorSpaceException("wrong number of components (" + ncomps + ") for palettized image");
-
- int outComps = NumComps;
- outShiftValueArray = new int[outComps];
-
- for (int i = 0; i < outComps; i++)
- {
- outShiftValueArray[i] = 1 << (getNomRangeBits(i) - 1);
- }
- }
-
-
- /// Returns, in the blk argument, a block of image data containing the
- /// specifed rectangular area, in the specified component. The data is
- /// returned, as a copy of the internal data, therefore the returned data
- /// can be modified "in place".
- ///
- /// The rectangular area to return is specified by the 'ulx', 'uly', 'w'
- /// and 'h' members of the 'blk' argument, relative to the current
- /// tile. These members are not modified by this method. The 'offset' of
- /// the returned data is 0, and the 'scanw' is the same as the block's
- /// width. See the 'DataBlk' class.
- ///
- ///
If the data array in 'blk' is 'null', then a new one is created. If
- /// the data array is not 'null' then it is reused, and it must be large
- /// enough to contain the block's data. Otherwise an 'ArrayStoreException'
- /// or an 'IndexOutOfBoundsException' is thrown by the Java system.
- ///
- ///
The returned data has its 'progressive' attribute set to that of the
- /// input data.
- ///
- ///
- /// Its coordinates and dimensions specify the area to
- /// return. If it contains a non-null data array, then it must have the
- /// correct dimensions. If it contains a null data array a new one is
- /// created. The fields in this object are modified to return the data.
- ///
- ///
- /// The index of the component from which to get the data. Only 0
- /// and 3 are valid.
- ///
- ///
- /// The requested DataBlk
- ///
- ///
- ///
- ///
- ///
- public override DataBlk getCompData(DataBlk out_Renamed, int c)
- {
-
- if (pbox == null)
- return src.getCompData(out_Renamed, c);
-
- if (ncomps != 1)
- {
- System.String msg = "PalettizedColorSpaceMapper: color palette " + "_not_ applied, incorrect number (" + System.Convert.ToString(ncomps) + ") of components";
- FacilityManager.getMsgLogger().printmsg(CSJ2K.j2k.util.MsgLogger_Fields.WARNING, msg);
- return src.getCompData(out_Renamed, c);
- }
-
- // Initialize general input and output indexes
- int leftedgeOut = -1; // offset to the start of the output scanline
- int rightedgeOut = -1; // offset to the end of the output
- // scanline + 1
- int leftedgeIn = -1; // offset to the start of the input scanline
- int rightedgeIn = -1; // offset to the end of the input
- // scanline + 1
- int kOut = -1;
- int kIn = -1;
-
- // Assure a properly sized data buffer for output.
- InternalBuffer = out_Renamed;
-
- switch (out_Renamed.DataType)
- {
-
- // Int and Float data only
- case DataBlk.TYPE_INT:
-
- copyGeometry(inInt[0], out_Renamed);
-
- // Request data from the source.
- inInt[0] = (DataBlkInt)src.getInternCompData(inInt[0], 0);
- dataInt[0] = (int[])inInt[0].Data;
- int[] outdataInt = ((DataBlkInt)out_Renamed).DataInt;
-
- // The nitty-gritty.
-
- for (int row = 0; row < out_Renamed.h; ++row)
- {
- leftedgeIn = inInt[0].offset + row * inInt[0].scanw;
- rightedgeIn = leftedgeIn + inInt[0].w;
- leftedgeOut = out_Renamed.offset + row * out_Renamed.scanw;
- rightedgeOut = leftedgeOut + out_Renamed.w;
-
- for (kOut = leftedgeOut, kIn = leftedgeIn; kIn < rightedgeIn; ++kIn, ++kOut)
- {
- outdataInt[kOut] = pbox.getEntry(c, dataInt[0][kIn] + shiftValueArray[0]) - outShiftValueArray[c];
- }
- }
- out_Renamed.progressive = inInt[0].progressive;
- break;
-
-
- case DataBlk.TYPE_FLOAT:
-
- copyGeometry(inFloat[0], out_Renamed);
-
- // Request data from the source.
- inFloat[0] = (DataBlkFloat)src.getInternCompData(inFloat[0], 0);
- dataFloat[0] = (float[])inFloat[0].Data;
- float[] outdataFloat = ((DataBlkFloat)out_Renamed).DataFloat;
-
- // The nitty-gritty.
-
- for (int row = 0; row < out_Renamed.h; ++row)
- {
- leftedgeIn = inFloat[0].offset + row * inFloat[0].scanw;
- rightedgeIn = leftedgeIn + inFloat[0].w;
- leftedgeOut = out_Renamed.offset + row * out_Renamed.scanw;
- rightedgeOut = leftedgeOut + out_Renamed.w;
-
- for (kOut = leftedgeOut, kIn = leftedgeIn; kIn < rightedgeIn; ++kIn, ++kOut)
- {
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- outdataFloat[kOut] = pbox.getEntry(c, (int)dataFloat[0][kIn] + shiftValueArray[0]) - outShiftValueArray[c];
- }
- }
- out_Renamed.progressive = inFloat[0].progressive;
- break;
-
-
- case DataBlk.TYPE_SHORT:
- case DataBlk.TYPE_BYTE:
- default:
- // Unsupported output type.
- throw new System.ArgumentException("invalid source datablock" + " type");
- }
-
- // Initialize the output block geometry and set the profiled
- // data into the output block.
- out_Renamed.offset = 0;
- out_Renamed.scanw = out_Renamed.w;
- return out_Renamed;
- }
-
-
- /// Return a suitable String representation of the class instance, e.g.
- ///
- /// [PalettizedColorSpaceMapper
- /// ncomps= 3, scomp= 1, nentries= 1024
- /// column=0, 7 bit signed entry
- /// column=1, 7 bit unsigned entry
- /// column=2, 7 bit signed entry]
- ///
- ///
- ///
- public override System.String ToString()
- {
-
- int c;
- System.Text.StringBuilder rep = new System.Text.StringBuilder("[PalettizedColorSpaceMapper ");
- System.Text.StringBuilder body = new System.Text.StringBuilder(" " + eol);
-
- if (pbox != null)
- {
- body.Append("ncomps= ").Append(NumComps).Append(", scomp= ").Append(srcChannel);
- for (c = 0; c < NumComps; ++c)
- {
- body.Append(eol).Append("column= ").Append(c).Append(", ").Append(pbox.getBitDepth(c)).Append(" bit ").Append(pbox.isSigned(c) ? "signed entry" : "unsigned entry");
- }
- }
- else
- {
- body.Append("image does not contain a palette box");
- }
-
- rep.Append(ColorSpace.indent(" ", body));
- return rep.Append("]").ToString();
- }
-
-
- /// Returns, in the blk argument, a block of image data containing the
- /// specifed rectangular area, in the specified component. The data is
- /// returned, as a reference to the internal data, if any, instead of as a
- /// copy, therefore the returned data should not be modified.
- ///
- /// The rectangular area to return is specified by the 'ulx', 'uly', 'w'
- /// and 'h' members of the 'blk' argument, relative to the current
- /// tile. These members are not modified by this method. The 'offset' and
- /// 'scanw' of the returned data can be arbitrary. See the 'DataBlk' class.
- ///
- ///
This method, in general, is more efficient than the 'getCompData()'
- /// method since it may not copy the data. However if the array of returned
- /// data is to be modified by the caller then the other method is probably
- /// preferable.
- ///
- ///
If possible, the data in the returned 'DataBlk' should be the
- /// internal data itself, instead of a copy, in order to increase the data
- /// transfer efficiency. However, this depends on the particular
- /// implementation (it may be more convenient to just return a copy of the
- /// data). This is the reason why the returned data should not be modified.
- ///
- ///
If the data array in blk is null, then a new one
- /// is created if necessary. The implementation of this interface may
- /// choose to return the same array or a new one, depending on what is more
- /// efficient. Therefore, the data array in blk prior to the
- /// method call should not be considered to contain the returned data, a
- /// new array may have been created. Instead, get the array from
- /// blk after the method has returned.
- ///
- ///
The returned data may have its 'progressive' attribute set. In this
- /// case the returned data is only an approximation of the "final" data.
- ///
- ///
- /// Its coordinates and dimensions specify the area to return,
- /// relative to the current tile. Some fields in this object are modified
- /// to return the data.
- ///
- ///
- /// The index of the component from which to get the data.
- ///
- ///
- /// The requested DataBlk
- ///
- ///
- ///
- ///
- public override DataBlk getInternCompData(DataBlk out_Renamed, int c)
- {
- return getCompData(out_Renamed, c);
- }
-
- /// Returns the number of bits, referred to as the "range bits",
- /// corresponding to the nominal range of the image data in the specified
- /// component. If this number is n then for unsigned data the
- /// nominal range is between 0 and 2^b-1, and for signed data it is between
- /// -2^(b-1) and 2^(b-1)-1. In the case of transformed data which is not in
- /// the image domain (e.g., wavelet coefficients), this method returns the
- /// "range bits" of the image data that generated the coefficients.
- ///
- ///
- /// The index of the component.
- ///
- ///
- /// The number of bits corresponding to the nominal range of the
- /// image data (in the image domain).
- ///
- public override int getNomRangeBits(int c)
- {
- return pbox == null ? src.getNomRangeBits(c) : pbox.getBitDepth(c);
- }
-
-
- /// Returns the component subsampling factor in the horizontal direction,
- /// for the specified component. This is, approximately, the ratio of
- /// dimensions between the reference grid and the component itself, see the
- /// 'ImgData' interface desription for details.
- ///
- ///
- /// The index of the component (between 0 and N-1)
- ///
- ///
- /// The horizontal subsampling factor of component 'c'
- ///
- ///
- ///
- ///
- ///
- public override int getCompSubsX(int c)
- {
- return imgdatasrc.getCompSubsX(srcChannel);
- }
-
- /// Returns the component subsampling factor in the vertical direction, for
- /// the specified component. This is, approximately, the ratio of
- /// dimensions between the reference grid and the component itself, see the
- /// 'ImgData' interface desription for details.
- ///
- ///
- /// The index of the component (between 0 and N-1)
- ///
- ///
- /// The vertical subsampling factor of component 'c'
- ///
- ///
- ///
- ///
- ///
- public override int getCompSubsY(int c)
- {
- return imgdatasrc.getCompSubsY(srcChannel);
- }
-
- /// Returns the width in pixels of the specified tile-component
- ///
- ///
- /// Tile index
- ///
- ///
- /// The index of the component, from 0 to N-1.
- ///
- ///
- /// The width in pixels of component c in tilet.
- ///
- ///
- public override int getTileCompWidth(int t, int c)
- {
- return imgdatasrc.getTileCompWidth(t, srcChannel);
- }
-
- /// Returns the height in pixels of the specified tile-component.
- ///
- ///
- /// The tile index.
- ///
- ///
- /// The index of the component, from 0 to N-1.
- ///
- ///
- /// The height in pixels of component c in tile
- /// t.
- ///
- ///
- public override int getTileCompHeight(int t, int c)
- {
- return imgdatasrc.getTileCompHeight(t, srcChannel);
- }
-
- /// Returns the width in pixels of the specified component in the overall
- /// image.
- ///
- ///
- /// The index of the component, from 0 to N-1.
- ///
- ///
- /// The width in pixels of component c in the overall
- /// image.
- ///
- ///
- public override int getCompImgWidth(int c)
- {
- return imgdatasrc.getCompImgWidth(srcChannel);
- }
-
-
- /// Returns the number of bits, referred to as the "range bits",
- /// corresponding to the nominal range of the image data in the specified
- /// component. If this number is n then for unsigned data the
- /// nominal range is between 0 and 2^b-1, and for signed data it is between
- /// -2^(b-1) and 2^(b-1)-1. In the case of transformed data which is not in
- /// the image domain (e.g., wavelet coefficients), this method returns the
- /// "range bits" of the image data that generated the coefficients.
- ///
- ///
- /// The index of the component.
- ///
- ///
- /// The number of bits corresponding to the nominal range of the
- /// image data (in the image domain).
- ///
- ///
- public override int getCompImgHeight(int c)
- {
- return imgdatasrc.getCompImgHeight(srcChannel);
- }
-
- /// Returns the horizontal coordinate of the upper-left corner of the
- /// specified component in the current tile.
- ///
- ///
- /// The index of the component.
- ///
- ///
- public override int getCompULX(int c)
- {
- return imgdatasrc.getCompULX(srcChannel);
- }
-
- /// Returns the vertical coordinate of the upper-left corner of the
- /// specified component in the current tile.
- ///
- ///
- /// The index of the component.
- ///
- ///
- public override int getCompULY(int c)
- {
- return imgdatasrc.getCompULY(srcChannel);
- }
-
- /* end class PalettizedColorSpaceMapper */
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/Color/Resampler.cs b/CSJ2K/Color/Resampler.cs
deleted file mode 100644
index 2c0acf6f..00000000
--- a/CSJ2K/Color/Resampler.cs
+++ /dev/null
@@ -1,431 +0,0 @@
-/// **************************************************************************
-///
-/// $Id: Resampler.java,v 1.2 2002/08/08 14:07:31 grosbois Exp $
-///
-/// Copyright Eastman Kodak Company, 343 State Street, Rochester, NY 14650
-/// $Date $
-/// ***************************************************************************
-///
-using CSJ2K.j2k.image;
-namespace CSJ2K.Color
-{
-
- /// This class resamples the components of an image so that
- /// all have the same number of samples. The current implementation
- /// only handles the case of 2:1 upsampling.
- ///
- ///
- ///
- ///
- /// 1.0
- ///
- /// Bruce A. Kern
- ///
- public class Resampler : ColorSpaceMapper
- {
- //UPGRADE_NOTE: Final was removed from the declaration of 'minCompSubsX '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- private int minCompSubsX;
- //UPGRADE_NOTE: Final was removed from the declaration of 'minCompSubsY '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- private int minCompSubsY;
- //UPGRADE_NOTE: Final was removed from the declaration of 'maxCompSubsX '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- private int maxCompSubsX;
- //UPGRADE_NOTE: Final was removed from the declaration of 'maxCompSubsY '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- private int maxCompSubsY;
-
- //UPGRADE_NOTE: Final was removed from the declaration of 'wspan '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- //UPGRADE_NOTE: Final was removed from the declaration of 'hspan '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- internal int wspan = 0;
- internal int hspan = 0;
-
- /// Factory method for creating instances of this class.
- /// -- source of image data
- ///
- /// -- provides colorspace info
- ///
- /// Resampler instance
- ///
- public static new BlkImgDataSrc createInstance(BlkImgDataSrc src, ColorSpace csMap)
- {
- return new Resampler(src, csMap);
- }
-
- /// Ctor resamples a BlkImgDataSrc so that all components
- /// have the same number of samples.
- ///
- /// Note the present implementation does only two to one
- /// respampling in either direction (row, column).
- ///
- ///
- /// -- Source of image data
- ///
- /// -- provides colorspace info
- ///
- protected internal Resampler(BlkImgDataSrc src, ColorSpace csMap) : base(src, csMap)
- {
-
- int c;
-
- // Calculate the minimum and maximum subsampling factor
- // across all channels.
-
- int minX = src.getCompSubsX(0);
- int minY = src.getCompSubsY(0);
- int maxX = minX;
- int maxY = minY;
-
- for (c = 1; c < ncomps; ++c)
- {
- minX = System.Math.Min(minX, src.getCompSubsX(c));
- minY = System.Math.Min(minY, src.getCompSubsY(c));
- maxX = System.Math.Max(maxX, src.getCompSubsX(c));
- maxY = System.Math.Max(maxY, src.getCompSubsY(c));
- }
-
- // Throw an exception for other than 2:1 sampling.
- if ((maxX != 1 && maxX != 2) || (maxY != 1 && maxY != 2))
- {
- throw new ColorSpaceException("Upsampling by other than 2:1 not" + " supported");
- }
-
- minCompSubsX = minX;
- minCompSubsY = minY;
- maxCompSubsX = maxX;
- maxCompSubsY = maxY;
-
- /* end Resampler ctor */
- }
-
- /// Return a DataBlk containing the requested component
- /// upsampled by the scale factor applied to the particular
- /// scaling direction
- ///
- /// Returns, in the blk argument, a block of image data containing the
- /// specifed rectangular area, in the specified component. The data is
- /// returned, as a copy of the internal data, therefore the returned data
- /// can be modified "in place".
- ///
- /// The rectangular area to return is specified by the 'ulx', 'uly', 'w'
- /// and 'h' members of the 'blk' argument, relative to the current
- /// tile. These members are not modified by this method. The 'offset' of
- /// the returned data is 0, and the 'scanw' is the same as the block's
- /// width. See the 'DataBlk' class.
- ///
- ///
If the data array in 'blk' is 'null', then a new one is created. If
- /// the data array is not 'null' then it is reused, and it must be large
- /// enough to contain the block's data. Otherwise an 'ArrayStoreException'
- /// or an 'IndexOutOfBoundsException' is thrown by the Java system.
- ///
- ///
The returned data has its 'progressive' attribute set to that of the
- /// input data.
- ///
- ///
- /// Its coordinates and dimensions specify the area to
- /// return. If it contains a non-null data array, then it must have the
- /// correct dimensions. If it contains a null data array a new one is
- /// created. The fields in this object are modified to return the data.
- ///
- ///
- /// The index of the component from which to get the data. Only 0
- /// and 3 are valid.
- ///
- ///
- /// The requested DataBlk
- ///
- ///
- ///
- ///
- public override DataBlk getInternCompData(DataBlk outblk, int c)
- {
-
- // If the scaling factor of this channel is 1 in both
- // directions, simply return the source DataBlk.
-
- if (src.getCompSubsX(c) == 1 && src.getCompSubsY(c) == 1)
- return src.getInternCompData(outblk, c);
-
- int wfactor = src.getCompSubsX(c);
- int hfactor = src.getCompSubsY(c);
- if ((wfactor != 2 && wfactor != 1) || (hfactor != 2 && hfactor != 1))
- throw new System.ArgumentException("Upsampling by other than 2:1" + " not supported");
-
- int leftedgeOut = -1; // offset to the start of the output scanline
- int rightedgeOut = -1; // offset to the end of the output
- // scanline + 1
- int leftedgeIn = -1; // offset to the start of the input scanline
- int rightedgeIn = -1; // offset to the end of the input scanline + 1
-
-
- int y0In, y1In, y0Out, y1Out;
- int x0In, x1In, x0Out, x1Out;
-
- y0Out = outblk.uly;
- y1Out = y0Out + outblk.h - 1;
-
- x0Out = outblk.ulx;
- x1Out = x0Out + outblk.w - 1;
-
- y0In = y0Out / hfactor;
- y1In = y1Out / hfactor;
-
- x0In = x0Out / wfactor;
- x1In = x1Out / wfactor;
-
-
- // Calculate the requested height and width, requesting an extra
- // row and or for upsampled channels.
- int reqW = x1In - x0In + 1;
- int reqH = y1In - y0In + 1;
-
- // Initialize general input and output indexes
- int kOut = -1;
- int kIn = -1;
- int yIn;
-
- switch (outblk.DataType)
- {
-
-
- case DataBlk.TYPE_INT:
-
- DataBlkInt inblkInt = new DataBlkInt(x0In, y0In, reqW, reqH);
- inblkInt = (DataBlkInt)src.getInternCompData(inblkInt, c);
- dataInt[c] = inblkInt.DataInt;
-
- // Reference the working array
- int[] outdataInt = (int[])outblk.Data;
-
- // Create data array if necessary
- if (outdataInt == null || outdataInt.Length != outblk.w * outblk.h)
- {
- outdataInt = new int[outblk.h * outblk.w];
- outblk.Data = outdataInt;
- }
-
- // The nitty-gritty.
-
- for (int yOut = y0Out; yOut <= y1Out; ++yOut)
- {
-
- yIn = yOut / hfactor;
-
-
- leftedgeIn = inblkInt.offset + (yIn - y0In) * inblkInt.scanw;
- rightedgeIn = leftedgeIn + inblkInt.w;
- leftedgeOut = outblk.offset + (yOut - y0Out) * outblk.scanw;
- rightedgeOut = leftedgeOut + outblk.w;
-
- kIn = leftedgeIn;
- kOut = leftedgeOut;
-
- if ((x0Out & 0x1) == 1)
- {
- // first is odd do the pixel once.
- outdataInt[kOut++] = dataInt[c][kIn++];
- }
-
- if ((x1Out & 0x1) == 0)
- {
- // last is even adjust loop bounds
- rightedgeOut--;
- }
-
- while (kOut < rightedgeOut)
- {
- outdataInt[kOut++] = dataInt[c][kIn];
- outdataInt[kOut++] = dataInt[c][kIn++];
- }
-
- if ((x1Out & 0x1) == 0)
- {
- // last is even do the pixel once.
- outdataInt[kOut++] = dataInt[c][kIn];
- }
- }
-
- outblk.progressive = inblkInt.progressive;
- break;
-
-
- case DataBlk.TYPE_FLOAT:
-
- DataBlkFloat inblkFloat = new DataBlkFloat(x0In, y0In, reqW, reqH);
- inblkFloat = (DataBlkFloat)src.getInternCompData(inblkFloat, c);
- dataFloat[c] = inblkFloat.DataFloat;
-
- // Reference the working array
- float[] outdataFloat = (float[])outblk.Data;
-
- // Create data array if necessary
- if (outdataFloat == null || outdataFloat.Length != outblk.w * outblk.h)
- {
- outdataFloat = new float[outblk.h * outblk.w];
- outblk.Data = outdataFloat;
- }
-
- // The nitty-gritty.
-
- for (int yOut = y0Out; yOut <= y1Out; ++yOut)
- {
-
- yIn = yOut / hfactor;
-
-
- leftedgeIn = inblkFloat.offset + (yIn - y0In) * inblkFloat.scanw;
- rightedgeIn = leftedgeIn + inblkFloat.w;
- leftedgeOut = outblk.offset + (yOut - y0Out) * outblk.scanw;
- rightedgeOut = leftedgeOut + outblk.w;
-
- kIn = leftedgeIn;
- kOut = leftedgeOut;
-
- if ((x0Out & 0x1) == 1)
- {
- // first is odd do the pixel once.
- outdataFloat[kOut++] = dataFloat[c][kIn++];
- }
-
- if ((x1Out & 0x1) == 0)
- {
- // last is even adjust loop bounds
- rightedgeOut--;
- }
-
- while (kOut < rightedgeOut)
- {
- outdataFloat[kOut++] = dataFloat[c][kIn];
- outdataFloat[kOut++] = dataFloat[c][kIn++];
- }
-
- if ((x1Out & 0x1) == 0)
- {
- // last is even do the pixel once.
- outdataFloat[kOut++] = dataFloat[c][kIn];
- }
- }
-
- outblk.progressive = inblkFloat.progressive;
- break;
-
-
- case DataBlk.TYPE_SHORT:
- case DataBlk.TYPE_BYTE:
- default:
- // Unsupported output type.
- throw new System.ArgumentException("invalid source datablock " + "type");
- }
-
- return outblk;
- }
-
-
- /// Return an appropriate String representation of this Resampler instance.
- public override System.String ToString()
- {
- System.Text.StringBuilder rep = new System.Text.StringBuilder("[Resampler: ncomps= " + ncomps);
- System.Text.StringBuilder body = new System.Text.StringBuilder(" ");
- for (int i = 0; i < ncomps; ++i)
- {
- body.Append(eol);
- body.Append("comp[");
- body.Append(i);
- body.Append("] xscale= ");
- body.Append(imgdatasrc.getCompSubsX(i));
- body.Append(", yscale= ");
- body.Append(imgdatasrc.getCompSubsY(i));
- }
-
- rep.Append(ColorSpace.indent(" ", body));
- return rep.Append("]").ToString();
- }
-
-
-
- /// Returns, in the blk argument, a block of image data containing the
- /// specifed rectangular area, in the specified component. The data is
- /// returned, as a copy of the internal data, therefore the returned data
- /// can be modified "in place".
- ///
- /// The rectangular area to return is specified by the 'ulx', 'uly', 'w'
- /// and 'h' members of the 'blk' argument, relative to the current
- /// tile. These members are not modified by this method. The 'offset' of
- /// the returned data is 0, and the 'scanw' is the same as the block's
- /// width. See the 'DataBlk' class.
- ///
- ///
If the data array in 'blk' is 'null', then a new one is created. If
- /// the data array is not 'null' then it is reused, and it must be large
- /// enough to contain the block's data. Otherwise an 'ArrayStoreException'
- /// or an 'IndexOutOfBoundsException' is thrown by the Java system.
- ///
- ///
The returned data has its 'progressive' attribute set to that of the
- /// input data.
- ///
- ///
- /// Its coordinates and dimensions specify the area to
- /// return. If it contains a non-null data array, then it must have the
- /// correct dimensions. If it contains a null data array a new one is
- /// created. The fields in this object are modified to return the data.
- ///
- ///
- /// The index of the component from which to get the data. Only 0
- /// and 3 are valid.
- ///
- ///
- /// The requested DataBlk
- ///
- ///
- ///
- ///
- ///
- public override DataBlk getCompData(DataBlk outblk, int c)
- {
- return getInternCompData(outblk, c);
- }
-
-
- /// Returns the height in pixels of the specified component in the
- /// overall image.
- ///
- public override int getCompImgHeight(int c)
- {
- return src.getCompImgHeight(c) * src.getCompSubsY(c);
- }
-
- /// Returns the width in pixels of the specified component in the
- /// overall image.
- ///
- public override int getCompImgWidth(int c)
- {
- return src.getCompImgWidth(c) * src.getCompSubsX(c);
- }
-
- /// Returns the component subsampling factor in the horizontal
- /// direction, for the specified component.
- ///
- public override int getCompSubsX(int c)
- {
- return 1;
- }
-
- /// Returns the component subsampling factor in the vertical
- /// direction, for the specified component.
- ///
- public override int getCompSubsY(int c)
- {
- return 1;
- }
-
- /// Returns the height in pixels of the specified tile-component.
- public override int getTileCompHeight(int t, int c)
- {
- return src.getTileCompHeight(t, c) * src.getCompSubsY(c);
- }
-
- /// Returns the width in pixels of the specified tile-component..
- public override int getTileCompWidth(int t, int c)
- {
- return src.getTileCompWidth(t, c) * src.getCompSubsX(c);
- }
-
- /* end class Resampler */
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/Color/SYccColorSpaceMapper.cs b/CSJ2K/Color/SYccColorSpaceMapper.cs
deleted file mode 100644
index b194a158..00000000
--- a/CSJ2K/Color/SYccColorSpaceMapper.cs
+++ /dev/null
@@ -1,344 +0,0 @@
-/// **************************************************************************
-///
-/// $Id: SYccColorSpaceMapper.java,v 1.1 2002/07/25 14:52:01 grosbois Exp $
-///
-/// Copyright Eastman Kodak Company, 343 State Street, Rochester, NY 14650
-/// $Date $
-/// ***************************************************************************
-///
-using BlkImgDataSrc = CSJ2K.j2k.image.BlkImgDataSrc;
-using DataBlk = CSJ2K.j2k.image.DataBlk;
-using DataBlkFloat = CSJ2K.j2k.image.DataBlkFloat;
-using DataBlkInt = CSJ2K.j2k.image.DataBlkInt;
-using FacilityManager = CSJ2K.j2k.util.FacilityManager;
-namespace CSJ2K.Color
-{
-
-
- /// This decodes maps which are defined in the sYCC
- /// colorspace into the sRGB colorspadce.
- ///
- ///
- ///
- ///
- /// 1.0
- ///
- /// Bruce A. Kern
- ///
- public class SYccColorSpaceMapper : ColorSpaceMapper
- {
- /// Matrix component for ycc transform.
- /* sYCC colorspace matrix */
-
- protected internal static float Matrix00 = 1;
- /// Matrix component for ycc transform.
- protected internal static float Matrix01 = 0;
- /// Matrix component for ycc transform.
- protected internal static float Matrix02 = (float)1.402;
- /// Matrix component for ycc transform.
- protected internal static float Matrix10 = 1;
- /// Matrix component for ycc transform.
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- protected internal static float Matrix11 = (float)(-0.34413);
- /// Matrix component for ycc transform.
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- protected internal static float Matrix12 = (float)(-0.71414);
- /// Matrix component for ycc transform.
- protected internal static float Matrix20 = 1;
- /// Matrix component for ycc transform.
- protected internal static float Matrix21 = (float)1.772;
- /// Matrix component for ycc transform.
- protected internal static float Matrix22 = 0;
-
-
- /// Factory method for creating instances of this class.
- /// -- source of image data
- ///
- /// -- provides colorspace info
- ///
- /// SYccColorSpaceMapper instance
- ///
- public static new BlkImgDataSrc createInstance(BlkImgDataSrc src, ColorSpace csMap)
- {
- return new SYccColorSpaceMapper(src, csMap);
- }
-
- /// Ctor which creates an ICCProfile for the image and initializes
- /// all data objects (input, working, and output).
- ///
- ///
- /// -- Source of image data
- ///
- /// -- provides colorspace info
- ///
- protected internal SYccColorSpaceMapper(BlkImgDataSrc src, ColorSpace csMap) : base(src, csMap)
- {
- initialize();
- /* end SYccColorSpaceMapper ctor */
- }
-
- /// General utility used by ctors
- private void initialize()
- {
-
- if (ncomps != 1 && ncomps != 3)
- {
- System.String msg = "SYccColorSpaceMapper: ycc transformation _not_ applied to " + ncomps + " component image";
- FacilityManager.getMsgLogger().printmsg(CSJ2K.j2k.util.MsgLogger_Fields.ERROR, msg);
- throw new ColorSpaceException(msg);
- }
- }
-
-
- /// Returns, in the blk argument, a block of image data containing the
- /// specifed rectangular area, in the specified component. The data is
- /// returned, as a copy of the internal data, therefore the returned data
- /// can be modified "in place".
- ///
- /// The rectangular area to return is specified by the 'ulx', 'uly', 'w'
- /// and 'h' members of the 'blk' argument, relative to the current
- /// tile. These members are not modified by this method. The 'offset' of
- /// the returned data is 0, and the 'scanw' is the same as the block's
- /// width. See the 'DataBlk' class.
- ///
- ///
If the data array in 'blk' is 'null', then a new one is created. If
- /// the data array is not 'null' then it is reused, and it must be large
- /// enough to contain the block's data. Otherwise an 'ArrayStoreException'
- /// or an 'IndexOutOfBoundsException' is thrown by the Java system.
- ///
- ///
The returned data has its 'progressive' attribute set to that of the
- /// input data.
- ///
- ///
- /// Its coordinates and dimensions specify the area to
- /// return. If it contains a non-null data array, then it must have the
- /// correct dimensions. If it contains a null data array a new one is
- /// created. The fields in this object are modified to return the data.
- ///
- ///
- /// The index of the component from which to get the data. Only 0
- /// and 3 are valid.
- ///
- ///
- /// The requested DataBlk
- ///
- ///
- ///
- ///
- public override DataBlk getCompData(DataBlk outblk, int c)
- {
-
- int type = outblk.DataType;
-
- int i; // j removed
-
- // Calculate all components:
- for (i = 0; i < ncomps; ++i)
- {
-
- // Set up the working DataBlk geometry.
- copyGeometry(workInt[i], outblk);
- copyGeometry(workFloat[i], outblk);
- copyGeometry(inInt[i], outblk);
- copyGeometry(inFloat[i], outblk);
-
- // Request data from the source.
- inInt[i] = (DataBlkInt)src.getInternCompData(inInt[i], i);
- }
-
- if (type == DataBlk.TYPE_INT)
- {
- if (ncomps == 1)
- workInt[c] = inInt[c];
- else
- workInt = mult(inInt);
- outblk.progressive = inInt[c].progressive;
- outblk.Data = workInt[c].Data;
- }
-
- if (type == DataBlk.TYPE_FLOAT)
- {
- if (ncomps == 1)
- workFloat[c] = inFloat[c];
- else
- workFloat = mult(inFloat);
- outblk.progressive = inFloat[c].progressive;
- outblk.Data = workFloat[c].Data;
- }
-
-
- // Initialize the output block geometry and set the profiled
- // data into the output block.
- outblk.offset = 0;
- outblk.scanw = outblk.w;
-
- return outblk;
- }
-
- /// Returns, in the blk argument, a block of image data containing the
- /// specifed rectangular area, in the specified component. The data is
- /// returned, as a reference to the internal data, if any, instead of as a
- /// copy, therefore the returned data should not be modified.
- ///
- /// The rectangular area to return is specified by the 'ulx', 'uly', 'w'
- /// and 'h' members of the 'blk' argument, relative to the current
- /// tile. These members are not modified by this method. The 'offset' and
- /// 'scanw' of the returned data can be arbitrary. See the 'DataBlk' class.
- ///
- ///
This method, in general, is more efficient than the 'getCompData()'
- /// method since it may not copy the data. However if the array of returned
- /// data is to be modified by the caller then the other method is probably
- /// preferable.
- ///
- ///
If possible, the data in the returned 'DataBlk' should be the
- /// internal data itself, instead of a copy, in order to increase the data
- /// transfer efficiency. However, this depends on the particular
- /// implementation (it may be more convenient to just return a copy of the
- /// data). This is the reason why the returned data should not be modified.
- ///
- ///
If the data array in blk is null, then a new one
- /// is created if necessary. The implementation of this interface may
- /// choose to return the same array or a new one, depending on what is more
- /// efficient. Therefore, the data array in blk prior to the
- /// method call should not be considered to contain the returned data, a
- /// new array may have been created. Instead, get the array from
- /// blk after the method has returned.
- ///
- ///
The returned data may have its 'progressive' attribute set. In this
- /// case the returned data is only an approximation of the "final" data.
- ///
- ///
- /// Its coordinates and dimensions specify the area to return,
- /// relative to the current tile. Some fields in this object are modified
- /// to return the data.
- ///
- ///
- /// The index of the component from which to get the data.
- ///
- ///
- /// The requested DataBlk
- ///
- ///
- ///
- ///
- public override DataBlk getInternCompData(DataBlk out_Renamed, int c)
- {
- return getCompData(out_Renamed, c);
- }
-
-
- /// Output a DataBlkFloat array where each sample in each component
- /// is the product of the YCC matrix * the vector of samples across
- /// the input components.
- ///
- /// input DataBlkFloat array
- ///
- /// output DataBlkFloat array
- ///
- private static DataBlkFloat[] mult(DataBlkFloat[] inblk)
- {
-
- if (inblk.Length != 3)
- throw new System.ArgumentException("bad input array size");
-
- int i, j;
- int length = inblk[0].h * inblk[0].w;
- DataBlkFloat[] outblk = new DataBlkFloat[3];
- float[][] out_Renamed = new float[3][];
- float[][] in_Renamed = new float[3][];
-
- for (i = 0; i < 3; ++i)
- {
- in_Renamed[i] = inblk[i].DataFloat;
- outblk[i] = new DataBlkFloat();
- copyGeometry(outblk[i], inblk[i]);
- outblk[i].offset = inblk[i].offset;
- out_Renamed[i] = new float[length];
- outblk[i].Data = out_Renamed[i];
- }
-
- for (j = 0; j < length; ++j)
- {
- out_Renamed[0][j] = (Matrix00 * in_Renamed[0][inblk[0].offset + j] + Matrix01 * in_Renamed[1][inblk[1].offset + j] + Matrix02 * in_Renamed[2][inblk[2].offset + j]);
-
- out_Renamed[1][j] = (Matrix10 * in_Renamed[0][inblk[0].offset + j] + Matrix11 * in_Renamed[1][inblk[1].offset + j] + Matrix12 * in_Renamed[2][inblk[2].offset + j]);
-
- out_Renamed[2][j] = (Matrix20 * in_Renamed[0][inblk[0].offset + j] + Matrix21 * in_Renamed[1][inblk[1].offset + j] + Matrix22 * in_Renamed[2][inblk[2].offset + j]);
- }
-
- return outblk;
- }
-
-
-
- /// Output a DataBlkInt array where each sample in each component
- /// is the product of the YCC matrix * the vector of samples across
- /// the input components.
- ///
- /// input DataBlkInt array
- ///
- /// output DataBlkInt array
- ///
- private static DataBlkInt[] mult(DataBlkInt[] inblk)
- {
-
- if (inblk.Length != 3)
- throw new System.ArgumentException("bad input array size");
-
-
- int i, j;
- int length = inblk[0].h * inblk[0].w;
- DataBlkInt[] outblk = new DataBlkInt[3];
- int[][] out_Renamed = new int[3][];
- int[][] in_Renamed = new int[3][];
-
- for (i = 0; i < 3; ++i)
- {
- in_Renamed[i] = inblk[i].DataInt;
- outblk[i] = new DataBlkInt();
- copyGeometry(outblk[i], inblk[i]);
- outblk[i].offset = inblk[i].offset;
- out_Renamed[i] = new int[length];
- outblk[i].Data = out_Renamed[i];
- }
-
- for (j = 0; j < length; ++j)
- {
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- out_Renamed[0][j] = (int)(Matrix00 * in_Renamed[0][inblk[0].offset + j] + Matrix01 * in_Renamed[1][inblk[1].offset + j] + Matrix02 * in_Renamed[2][inblk[2].offset + j]);
-
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- out_Renamed[1][j] = (int)(Matrix10 * in_Renamed[0][inblk[0].offset + j] + Matrix11 * in_Renamed[1][inblk[1].offset + j] + Matrix12 * in_Renamed[2][inblk[2].offset + j]);
-
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- out_Renamed[2][j] = (int)(Matrix20 * in_Renamed[0][inblk[0].offset + j] + Matrix21 * in_Renamed[1][inblk[1].offset + j] + Matrix22 * in_Renamed[2][inblk[2].offset + j]);
- }
-
- return outblk;
- }
-
-
- /// Return a suitable String representation of the class instance.
- public override System.String ToString()
- {
- int i;
-
- System.Text.StringBuilder rep_nComps = new System.Text.StringBuilder("ncomps= ").Append(System.Convert.ToString(ncomps));
- System.Text.StringBuilder rep_comps = new System.Text.StringBuilder();
-
- for (i = 0; i < ncomps; ++i)
- {
- rep_comps.Append(" ").Append("component[").Append(System.Convert.ToString(i)).Append("] height, width = (").Append(src.getCompImgHeight(i)).Append(", ").Append(src.getCompImgWidth(i)).Append(")").Append(eol);
- }
-
- System.Text.StringBuilder rep = new System.Text.StringBuilder("[SYccColorSpaceMapper ");
- rep.Append(rep_nComps).Append(eol);
- rep.Append(rep_comps).Append(" ");
-
- return rep.Append("]").ToString();
- }
-
-
- /* end class SYccColorSpaceMapper */
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/Color/boxes/ChannelDefinitionBox.cs b/CSJ2K/Color/boxes/ChannelDefinitionBox.cs
deleted file mode 100644
index edb51b12..00000000
--- a/CSJ2K/Color/boxes/ChannelDefinitionBox.cs
+++ /dev/null
@@ -1,165 +0,0 @@
-/// **************************************************************************
-///
-/// $Id: ChannelDefinitionBox.java,v 1.1 2002/07/25 14:50:46 grosbois Exp $
-///
-/// Copyright Eastman Kodak Company, 343 State Street, Rochester, NY 14650
-/// $Date $
-/// ***************************************************************************
-///
-using ICCProfile = CSJ2K.Icc.ICCProfile;
-using RandomAccessIO = CSJ2K.j2k.io.RandomAccessIO;
-namespace CSJ2K.Color.Boxes
-{
-
- /// This class maps the components in the codestream
- /// to channels in the image. It models the Component
- /// Mapping box in the JP2 header.
- ///
- ///
- /// 1.0
- ///
- /// Bruce A. Kern
- ///
- public sealed class ChannelDefinitionBox : JP2Box
- {
- public int NDefs
- {
- /* Return the number of channel definitions. */
-
- get
- {
- return ndefs;
- }
-
- }
-
- private int ndefs;
- private System.Collections.Hashtable definitions = System.Collections.Hashtable.Synchronized(new System.Collections.Hashtable());
-
- /// Construct a ChannelDefinitionBox from an input image.
- /// RandomAccessIO jp2 image
- ///
- /// offset to the start of the box in the image
- ///
- /// ColorSpaceException
- ///
- public ChannelDefinitionBox(RandomAccessIO in_Renamed, int boxStart) : base(in_Renamed, boxStart)
- {
- readBox();
- }
-
- /// Analyze the box content.
- private void readBox()
- {
-
- byte[] bfr = new byte[8];
-
- in_Renamed.seek(dataStart);
- in_Renamed.readFully(bfr, 0, 2);
- ndefs = ICCProfile.getShort(bfr, 0) & 0x0000ffff;
-
- int offset = dataStart + 2;
- in_Renamed.seek(offset);
- for (int i = 0; i < ndefs; ++i)
- {
- in_Renamed.readFully(bfr, 0, 6);
- int channel = ICCProfile.getShort(bfr, 0);
- int[] channel_def = new int[3];
- channel_def[0] = getCn(bfr);
- channel_def[1] = getTyp(bfr);
- channel_def[2] = getAsoc(bfr);
- definitions[(System.Int32)channel_def[0]] = channel_def;
- }
- }
-
- /* Return the channel association. */
- public int getCn(int asoc)
- {
- System.Collections.IEnumerator keys = definitions.Keys.GetEnumerator();
- //UPGRADE_TODO: Method 'java.util.Enumeration.hasMoreElements' was converted to 'System.Collections.IEnumerator.MoveNext' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilEnumerationhasMoreElements'"
- while (keys.MoveNext())
- {
- //UPGRADE_TODO: Method 'java.util.Enumeration.nextElement' was converted to 'System.Collections.IEnumerator.Current' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilEnumerationnextElement'"
- int[] bfr = (int[])definitions[keys.Current];
- if (asoc == getAsoc(bfr))
- return getCn(bfr);
- }
- return asoc;
- }
-
- /* Return the channel type. */
- public int getTyp(int channel)
- {
- int[] bfr = (int[])definitions[(System.Int32)channel];
- return getTyp(bfr);
- }
-
- /* Return the associated channel of the association. */
- public int getAsoc(int channel)
- {
- int[] bfr = (int[])definitions[(System.Int32)channel];
- return getAsoc(bfr);
- }
-
-
- /// Return a suitable String representation of the class instance.
- public override System.String ToString()
- {
- System.Text.StringBuilder rep = new System.Text.StringBuilder("[ChannelDefinitionBox ").Append(eol).Append(" ");
- rep.Append("ndefs= ").Append(System.Convert.ToString(ndefs));
-
- System.Collections.IEnumerator keys = definitions.Keys.GetEnumerator();
- //UPGRADE_TODO: Method 'java.util.Enumeration.hasMoreElements' was converted to 'System.Collections.IEnumerator.MoveNext' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilEnumerationhasMoreElements'"
- while (keys.MoveNext())
- {
- //UPGRADE_TODO: Method 'java.util.Enumeration.nextElement' was converted to 'System.Collections.IEnumerator.Current' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilEnumerationnextElement'"
- int[] bfr = (int[])definitions[keys.Current];
- rep.Append(eol).Append(" ").Append("Cn= ").Append(System.Convert.ToString(getCn(bfr))).Append(", ").Append("Typ= ").Append(System.Convert.ToString(getTyp(bfr))).Append(", ").Append("Asoc= ").Append(System.Convert.ToString(getAsoc(bfr)));
- }
-
- rep.Append("]");
- return rep.ToString();
- }
-
- /// Return the channel from the record.
- private int getCn(byte[] bfr)
- {
- return ICCProfile.getShort(bfr, 0);
- }
-
- /// Return the channel type from the record.
- private int getTyp(byte[] bfr)
- {
- return ICCProfile.getShort(bfr, 2);
- }
-
- /// Return the associated channel from the record.
- private int getAsoc(byte[] bfr)
- {
- return ICCProfile.getShort(bfr, 4);
- }
-
- private int getCn(int[] bfr)
- {
- return bfr[0];
- }
-
- private int getTyp(int[] bfr)
- {
- return bfr[1];
- }
-
- private int getAsoc(int[] bfr)
- {
- return bfr[2];
- }
-
- /* end class ChannelDefinitionBox */
- static ChannelDefinitionBox()
- {
- {
- type = 0x63646566;
- }
- }
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/Color/boxes/ColorSpecificationBox.cs b/CSJ2K/Color/boxes/ColorSpecificationBox.cs
deleted file mode 100644
index 647e23f2..00000000
--- a/CSJ2K/Color/boxes/ColorSpecificationBox.cs
+++ /dev/null
@@ -1,217 +0,0 @@
-using CSJ2K.j2k.io;
-/// **************************************************************************
-///
-/// $Id: ColorSpecificationBox.java,v 1.3 2002/08/08 14:07:53 grosbois Exp $
-///
-/// Copyright Eastman Kodak Company, 343 State Street, Rochester, NY 14650
-/// $Date $
-/// ***************************************************************************
-///
-using CSJ2K.j2k.util;
-namespace CSJ2K.Color.Boxes
-{
-
- /// This class models the Color Specification Box in a JP2 image.
- ///
- ///
- /// 1.0
- ///
- /// Bruce A. Kern
- ///
- public sealed class ColorSpecificationBox : JP2Box
- {
-
- public ColorSpace.MethodEnum Method
- {
- // Return an enumeration for the colorspace method.
-
- get
- {
- return method;
- }
-
- }
- public ColorSpace.CSEnum ColorSpace
- {
- // Return an enumeration for the colorspace.
-
- get
- {
- return colorSpace;
- }
-
- }
-
- public System.String ColorSpaceString
- {
- // Return a String representation of the colorspace.
-
- get
- {
- return colorSpace.ToString();
- }
-
- }
- public System.String MethodString
- {
- // Return a String representation of the colorspace method.
-
- get
- {
- return method.ToString();
- }
-
- }
-
- public byte[] ICCProfile
- {
- /* Retrieve the ICC Profile from the image as a byte []. */
-
- get
- {
- return iccProfile;
- }
-
- }
-
- private ColorSpace.MethodEnum method;
- private ColorSpace.CSEnum colorSpace;
- private byte[] iccProfile = null;
-
- /// Construct a ColorSpecificationBox from an input image.
- /// RandomAccessIO jp2 image
- ///
- /// offset to the start of the box in the image
- ///
- /// ColorSpaceException
- ///
- ///
- public ColorSpecificationBox(RandomAccessIO in_Renamed, int boxStart) : base(in_Renamed, boxStart)
- {
- readBox();
- }
-
- /// Analyze the box content.
- private void readBox()
- {
- byte[] boxHeader = new byte[256];
- in_Renamed.seek(dataStart);
- in_Renamed.readFully(boxHeader, 0, 11);
- switch (boxHeader[0])
- {
-
- case 1:
- method = CSJ2K.Color.ColorSpace.MethodEnum.ENUMERATED;
- int cs = CSJ2K.Icc.ICCProfile.getInt(boxHeader, 3);
- switch (cs)
- {
- case 16:
- colorSpace = CSJ2K.Color.ColorSpace.CSEnum.sRGB;
- break; // from switch (cs)...
-
- case 17:
- colorSpace = CSJ2K.Color.ColorSpace.CSEnum.GreyScale;
- break; // from switch (cs)...
-
- case 18:
- colorSpace = CSJ2K.Color.ColorSpace.CSEnum.sYCC;
- break; // from switch (cs)...
- case 20:
- colorSpace = CSJ2K.Color.ColorSpace.CSEnum.esRGB;
- break;
-
- #region Known but unsupported colorspaces
- case 3:
- FacilityManager.getMsgLogger().printmsg(CSJ2K.j2k.util.MsgLogger_Fields.WARNING, "Unsupported enumerated colorspace YCbCr(2) in color specification box");
- colorSpace = CSJ2K.Color.ColorSpace.CSEnum.Unknown;
- break;
- case 4:
- FacilityManager.getMsgLogger().printmsg(CSJ2K.j2k.util.MsgLogger_Fields.WARNING, "Unsupported enumerated colorspace YCbCr(3) in color specification box");
- colorSpace = CSJ2K.Color.ColorSpace.CSEnum.Unknown;
- break;
- case 9:
- FacilityManager.getMsgLogger().printmsg(CSJ2K.j2k.util.MsgLogger_Fields.WARNING, "Unsupported enumerated colorspace PhotoYCC in color specification box");
- colorSpace = CSJ2K.Color.ColorSpace.CSEnum.Unknown;
- break;
- case 11:
- FacilityManager.getMsgLogger().printmsg(CSJ2K.j2k.util.MsgLogger_Fields.WARNING, "Unsupported enumerated colorspace CMY in color specification box");
- colorSpace = CSJ2K.Color.ColorSpace.CSEnum.Unknown;
- break;
- case 12:
- FacilityManager.getMsgLogger().printmsg(CSJ2K.j2k.util.MsgLogger_Fields.WARNING, "Unsupported enumerated colorspace CMYK in color specification box");
- colorSpace = CSJ2K.Color.ColorSpace.CSEnum.Unknown;
- break;
- case 13:
- FacilityManager.getMsgLogger().printmsg(CSJ2K.j2k.util.MsgLogger_Fields.WARNING, "Unsupported enumerated colorspace YCCK in color specification box");
- colorSpace = CSJ2K.Color.ColorSpace.CSEnum.Unknown;
- break;
- case 14:
- FacilityManager.getMsgLogger().printmsg(CSJ2K.j2k.util.MsgLogger_Fields.WARNING, "Unsupported enumerated colorspace CIELab in color specification box");
- colorSpace = CSJ2K.Color.ColorSpace.CSEnum.Unknown;
- break;
- case 15:
- FacilityManager.getMsgLogger().printmsg(CSJ2K.j2k.util.MsgLogger_Fields.WARNING, "Unsupported enumerated colorspace Bi-Level(2) in color specification box");
- colorSpace = CSJ2K.Color.ColorSpace.CSEnum.Unknown;
- break;
- case 19:
- FacilityManager.getMsgLogger().printmsg(CSJ2K.j2k.util.MsgLogger_Fields.WARNING, "Unsupported enumerated colorspace CIEJab in color specification box");
- colorSpace = CSJ2K.Color.ColorSpace.CSEnum.Unknown;
- break;
- case 21:
- FacilityManager.getMsgLogger().printmsg(CSJ2K.j2k.util.MsgLogger_Fields.WARNING, "Unsupported enumerated colorspace ROMM-RGB in color specification box");
- colorSpace = CSJ2K.Color.ColorSpace.CSEnum.Unknown;
- break;
- case 22:
- FacilityManager.getMsgLogger().printmsg(CSJ2K.j2k.util.MsgLogger_Fields.WARNING, "Unsupported enumerated colorspace YPbPr(1125/60) in color specification box");
- colorSpace = CSJ2K.Color.ColorSpace.CSEnum.Unknown;
- break;
- case 23:
- FacilityManager.getMsgLogger().printmsg(CSJ2K.j2k.util.MsgLogger_Fields.WARNING, "Unsupported enumerated colorspace YPbPr(1250/50) in color specification box");
- colorSpace = CSJ2K.Color.ColorSpace.CSEnum.Unknown;
- break;
- case 24:
- FacilityManager.getMsgLogger().printmsg(CSJ2K.j2k.util.MsgLogger_Fields.WARNING, "Unsupported enumerated colorspace e-sYCC in color specification box");
- colorSpace = CSJ2K.Color.ColorSpace.CSEnum.Unknown;
- break;
- #endregion
-
- default:
- FacilityManager.getMsgLogger().printmsg(CSJ2K.j2k.util.MsgLogger_Fields.WARNING, "Unknown enumerated colorspace (" + cs + ") in color specification box");
- colorSpace = CSJ2K.Color.ColorSpace.CSEnum.Unknown;
- break;
-
- }
- break; // from switch (boxHeader[0])...
-
- case 2:
- method = CSJ2K.Color.ColorSpace.MethodEnum.ICC_PROFILED;
- int size = CSJ2K.Icc.ICCProfile.getInt(boxHeader, 3);
- iccProfile = new byte[size];
- in_Renamed.seek(dataStart + 3);
- in_Renamed.readFully(iccProfile, 0, size);
- break; // from switch (boxHeader[0])...
-
- default:
- throw new ColorSpaceException("Bad specification method (" + boxHeader[0] + ") in " + this);
-
- }
- }
-
- /// Return a suitable String representation of the class instance.
- public override System.String ToString()
- {
- System.Text.StringBuilder rep = new System.Text.StringBuilder("[ColorSpecificationBox ");
- rep.Append("method= ").Append(System.Convert.ToString(method)).Append(", ");
- rep.Append("colorspace= ").Append(System.Convert.ToString(colorSpace)).Append("]");
- return rep.ToString();
- }
-
- /* end class ColorSpecificationBox */
- static ColorSpecificationBox()
- {
- {
- type = 0x636f6c72;
- }
- }
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/Color/boxes/ComponentMappingBox.cs b/CSJ2K/Color/boxes/ComponentMappingBox.cs
deleted file mode 100644
index 560d76bb..00000000
--- a/CSJ2K/Color/boxes/ComponentMappingBox.cs
+++ /dev/null
@@ -1,127 +0,0 @@
-/// **************************************************************************
-///
-/// $Id: ComponentMappingBox.java,v 1.1 2002/07/25 14:50:46 grosbois Exp $
-///
-/// Copyright Eastman Kodak Company, 343 State Street, Rochester, NY 14650
-/// $Date $
-/// ***************************************************************************
-///
-using ICCProfile = CSJ2K.Icc.ICCProfile;
-using RandomAccessIO = CSJ2K.j2k.io.RandomAccessIO;
-namespace CSJ2K.Color.Boxes
-{
-
- /// This class maps the components in the codestream
- /// to channels in the image. It models the Component
- /// Mapping box in the JP2 header.
- ///
- ///
- /// 1.0
- ///
- /// Bruce A. Kern
- ///
- public sealed class ComponentMappingBox : JP2Box
- {
- public int NChannels
- {
- /* Return the number of mapped channels. */
-
- get
- {
- return nChannels;
- }
-
- }
-
- private int nChannels;
- private System.Collections.ArrayList map = System.Collections.ArrayList.Synchronized(new System.Collections.ArrayList(10));
-
- /// Construct a ComponentMappingBox from an input image.
- /// RandomAccessIO jp2 image
- ///
- /// offset to the start of the box in the image
- ///
- /// ColorSpaceException
- ///
- public ComponentMappingBox(RandomAccessIO in_Renamed, int boxStart) : base(in_Renamed, boxStart)
- {
- readBox();
- }
-
- /// Analyze the box content.
- internal void readBox()
- {
- nChannels = (boxEnd - dataStart) / 4;
- in_Renamed.seek(dataStart);
- for (int offset = dataStart; offset < boxEnd; offset += 4)
- {
- byte[] mapping = new byte[4];
- in_Renamed.readFully(mapping, 0, 4);
- map.Add(mapping);
- }
- }
-
- /* Return the component mapped to the channel. */
- public int getCMP(int channel)
- {
- byte[] mapping = (byte[])map[channel];
- return ICCProfile.getShort(mapping, 0) & 0x0000ffff;
- }
-
- /// Return the channel type.
- public short getMTYP(int channel)
- {
- byte[] mapping = (byte[])map[channel];
- return (short)(mapping[2] & 0x00ff);
- }
-
- /// Return the palette index for the channel.
- public short getPCOL(int channel)
- {
- byte[] mapping = (byte[])map[channel];
- return (short)(mapping[3] & 0x000ff);
- }
-
- /// Return a suitable String representation of the class instance.
- public override System.String ToString()
- {
- System.Text.StringBuilder rep = new System.Text.StringBuilder("[ComponentMappingBox ").Append(" ");
- rep.Append("nChannels= ").Append(System.Convert.ToString(nChannels));
- System.Collections.IEnumerator Enum = map.GetEnumerator();
- //UPGRADE_TODO: Method 'java.util.Enumeration.hasMoreElements' was converted to 'System.Collections.IEnumerator.MoveNext' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilEnumerationhasMoreElements'"
- while (Enum.MoveNext())
- {
- //UPGRADE_TODO: Method 'java.util.Enumeration.nextElement' was converted to 'System.Collections.IEnumerator.Current' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilEnumerationnextElement'"
- byte[] bfr = (byte[])Enum.Current;
- rep.Append(eol).Append(" ").Append("CMP= ").Append(System.Convert.ToString(getCMP(bfr))).Append(", ");
- rep.Append("MTYP= ").Append(System.Convert.ToString(getMTYP(bfr))).Append(", ");
- rep.Append("PCOL= ").Append(System.Convert.ToString(getPCOL(bfr)));
- }
- rep.Append("]");
- return rep.ToString();
- }
-
- private int getCMP(byte[] mapping)
- {
- return ICCProfile.getShort(mapping, 0) & 0x0000ffff;
- }
-
- private short getMTYP(byte[] mapping)
- {
- return (short)(mapping[2] & 0x00ff);
- }
-
- private short getPCOL(byte[] mapping)
- {
- return (short)(mapping[3] & 0x000ff);
- }
-
- /* end class ComponentMappingBox */
- static ComponentMappingBox()
- {
- {
- type = 0x636d6170;
- }
- }
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/Color/boxes/ImageHeaderBox.cs b/CSJ2K/Color/boxes/ImageHeaderBox.cs
deleted file mode 100644
index f79d41f4..00000000
--- a/CSJ2K/Color/boxes/ImageHeaderBox.cs
+++ /dev/null
@@ -1,88 +0,0 @@
-using ICCProfile = CSJ2K.Icc.ICCProfile;
-/// **************************************************************************
-///
-/// $Id: ImageHeaderBox.java,v 1.1 2002/07/25 14:50:47 grosbois Exp $
-///
-/// Copyright Eastman Kodak Company, 343 State Street, Rochester, NY 14650
-/// $Date $
-/// ***************************************************************************
-///
-using RandomAccessIO = CSJ2K.j2k.io.RandomAccessIO;
-namespace CSJ2K.Color.Boxes
-{
-
- /// This class models the Image Header box contained in a JP2
- /// image. It is a stub class here since for colormapping the
- /// knowlege of the existance of the box in the image is sufficient.
- ///
- ///
- /// 1.0
- ///
- /// Bruce A. Kern
- ///
- public sealed class ImageHeaderBox : JP2Box
- {
-
- internal long height;
- internal long width;
- internal int nc;
- internal short bpc;
- internal short c;
- internal bool unk;
- internal bool ipr;
-
-
- /// Construct an ImageHeaderBox from an input image.
- /// RandomAccessIO jp2 image
- ///
- /// offset to the start of the box in the image
- ///
- /// ColorSpaceException
- ///
- public ImageHeaderBox(RandomAccessIO in_Renamed, int boxStart) : base(in_Renamed, boxStart)
- {
- readBox();
- }
-
- /// Return a suitable String representation of the class instance.
- public override System.String ToString()
- {
- System.Text.StringBuilder rep = new System.Text.StringBuilder("[ImageHeaderBox ").Append(eol).Append(" ");
- rep.Append("height= ").Append(System.Convert.ToString(height)).Append(", ");
- rep.Append("width= ").Append(System.Convert.ToString(width)).Append(eol).Append(" ");
-
- rep.Append("nc= ").Append(System.Convert.ToString(nc)).Append(", ");
- rep.Append("bpc= ").Append(System.Convert.ToString(bpc)).Append(", ");
- rep.Append("c= ").Append(System.Convert.ToString(c)).Append(eol).Append(" ");
-
- rep.Append("image colorspace is ").Append(new System.Text.StringBuilder(unk == true ? "known" : "unknown").ToString());
- rep.Append(", the image ").Append(new System.Text.StringBuilder(ipr == true ? "contains " : "does not contain ").ToString()).Append("intellectual property").Append("]");
-
- return rep.ToString();
- }
-
- /// Analyze the box content.
- internal void readBox()
- {
- byte[] bfr = new byte[14];
- in_Renamed.seek(dataStart);
- in_Renamed.readFully(bfr, 0, 14);
-
- height = ICCProfile.getInt(bfr, 0);
- width = ICCProfile.getInt(bfr, 4);
- nc = ICCProfile.getShort(bfr, 8);
- bpc = (short)(bfr[10] & 0x00ff);
- c = (short)(bfr[11] & 0x00ff);
- unk = bfr[12] == 0 ? true : false;
- ipr = bfr[13] == 1 ? true : false;
- }
-
- /* end class ImageHeaderBox */
- static ImageHeaderBox()
- {
- {
- type = 69686472;
- }
- }
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/Color/boxes/JP2Box.cs b/CSJ2K/Color/boxes/JP2Box.cs
deleted file mode 100644
index 719300ef..00000000
--- a/CSJ2K/Color/boxes/JP2Box.cs
+++ /dev/null
@@ -1,138 +0,0 @@
-/// **************************************************************************
-///
-/// $Id: JP2Box.java,v 1.1 2002/07/25 14:50:47 grosbois Exp $
-///
-/// Copyright Eastman Kodak Company, 343 State Street, Rochester, NY 14650
-/// $Date $
-/// ***************************************************************************
-///
-using System;
-using ICCProfile = CSJ2K.Icc.ICCProfile;
-using RandomAccessIO = CSJ2K.j2k.io.RandomAccessIO;
-namespace CSJ2K.Color.Boxes
-{
-
- /// The abstract super class modeling the aspects of
- /// a JP2 box common to all such boxes.
- ///
- ///
- /// 1.0
- ///
- /// Bruce A. Kern
- ///
- public abstract class JP2Box
- {
- /// Platform dependant line terminator
- //UPGRADE_NOTE: Final was removed from the declaration of 'eol '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- public static readonly System.String eol = System.Environment.NewLine;
- /// Box type
- public static int type;
-
- /// Return a String representation of the Box type.
- public static System.String getTypeString(int t)
- {
- return BoxType.get_Renamed(t);
- }
-
- /// Length of the box.
- public int length;
- /// input file
- protected internal RandomAccessIO in_Renamed;
- /// offset to start of box
- protected internal int boxStart;
- /// offset to end of box
- protected internal int boxEnd;
- /// offset to start of data in box
- protected internal int dataStart;
-
- public JP2Box()
- {
- try
- {
- throw new ColorSpaceException("JP2Box empty ctor called!!");
- }
- catch (ColorSpaceException e)
- {
- SupportClass.WriteStackTrace(e, Console.Error); throw e;
- }
- }
-
- /// Construct a JP2Box from an input image.
- /// RandomAccessIO jp2 image
- ///
- /// offset to the start of the box in the image
- ///
- /// ColorSpaceException
- ///
- public JP2Box(RandomAccessIO in_Renamed, int boxStart)
- {
- byte[] boxHeader = new byte[16];
-
- this.in_Renamed = in_Renamed;
- this.boxStart = boxStart;
-
- this.in_Renamed.seek(this.boxStart);
- this.in_Renamed.readFully(boxHeader, 0, 8);
-
- this.dataStart = boxStart + 8;
- this.length = ICCProfile.getInt(boxHeader, 0);
- this.boxEnd = boxStart + length;
- if (length == 1)
- throw new ColorSpaceException("extended length boxes not supported");
- }
-
-
- /// Return the box type as a String.
- public virtual System.String getTypeString()
- {
- return BoxType.get_Renamed(JP2Box.type);
- }
-
-
- /// JP2 Box structure analysis help
- [Serializable]
- protected internal class BoxType : System.Collections.Hashtable
- {
-
- private static System.Collections.Hashtable map = System.Collections.Hashtable.Synchronized(new System.Collections.Hashtable());
-
- private static void put(int type, System.String desc)
- {
- map[(System.Int32)type] = desc;
- }
-
- public static System.String get_Renamed(int type)
- {
- return (System.String)map[(System.Int32)type];
- }
-
- /* end class BoxType */
- static BoxType()
- {
- {
- put(CSJ2K.j2k.fileformat.FileFormatBoxes.BITS_PER_COMPONENT_BOX, "BITS_PER_COMPONENT_BOX");
- put(CSJ2K.j2k.fileformat.FileFormatBoxes.CAPTURE_RESOLUTION_BOX, "CAPTURE_RESOLUTION_BOX");
- put(CSJ2K.j2k.fileformat.FileFormatBoxes.CHANNEL_DEFINITION_BOX, "CHANNEL_DEFINITION_BOX");
- put(CSJ2K.j2k.fileformat.FileFormatBoxes.COLOUR_SPECIFICATION_BOX, "COLOUR_SPECIFICATION_BOX");
- put(CSJ2K.j2k.fileformat.FileFormatBoxes.COMPONENT_MAPPING_BOX, "COMPONENT_MAPPING_BOX");
- put(CSJ2K.j2k.fileformat.FileFormatBoxes.CONTIGUOUS_CODESTREAM_BOX, "CONTIGUOUS_CODESTREAM_BOX");
- put(CSJ2K.j2k.fileformat.FileFormatBoxes.DEFAULT_DISPLAY_RESOLUTION_BOX, "DEFAULT_DISPLAY_RESOLUTION_BOX");
- put(CSJ2K.j2k.fileformat.FileFormatBoxes.FILE_TYPE_BOX, "FILE_TYPE_BOX");
- put(CSJ2K.j2k.fileformat.FileFormatBoxes.IMAGE_HEADER_BOX, "IMAGE_HEADER_BOX");
- put(CSJ2K.j2k.fileformat.FileFormatBoxes.INTELLECTUAL_PROPERTY_BOX, "INTELLECTUAL_PROPERTY_BOX");
- put(CSJ2K.j2k.fileformat.FileFormatBoxes.JP2_HEADER_BOX, "JP2_HEADER_BOX");
- put(CSJ2K.j2k.fileformat.FileFormatBoxes.JP2_SIGNATURE_BOX, "JP2_SIGNATURE_BOX");
- put(CSJ2K.j2k.fileformat.FileFormatBoxes.PALETTE_BOX, "PALETTE_BOX");
- put(CSJ2K.j2k.fileformat.FileFormatBoxes.RESOLUTION_BOX, "RESOLUTION_BOX");
- put(CSJ2K.j2k.fileformat.FileFormatBoxes.URL_BOX, "URL_BOX");
- put(CSJ2K.j2k.fileformat.FileFormatBoxes.UUID_BOX, "UUID_BOX");
- put(CSJ2K.j2k.fileformat.FileFormatBoxes.UUID_INFO_BOX, "UUID_INFO_BOX");
- put(CSJ2K.j2k.fileformat.FileFormatBoxes.UUID_LIST_BOX, "UUID_LIST_BOX");
- put(CSJ2K.j2k.fileformat.FileFormatBoxes.XML_BOX, "XML_BOX");
- }
- }
- }
-
- /* end class JP2Box */
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/Color/boxes/PaletteBox.cs b/CSJ2K/Color/boxes/PaletteBox.cs
deleted file mode 100644
index e7005f8f..00000000
--- a/CSJ2K/Color/boxes/PaletteBox.cs
+++ /dev/null
@@ -1,189 +0,0 @@
-/// **************************************************************************
-///
-/// $Id: PaletteBox.java,v 1.1 2002/07/25 14:50:47 grosbois Exp $
-///
-/// Copyright Eastman Kodak Company, 343 State Street, Rochester, NY 14650
-/// $Date $
-/// ***************************************************************************
-///
-using ICCProfile = CSJ2K.Icc.ICCProfile;
-using RandomAccessIO = CSJ2K.j2k.io.RandomAccessIO;
-namespace CSJ2K.Color.Boxes
-{
-
- /// This class models the palette box contained in a JP2
- /// image.
- ///
- ///
- /// 1.0
- ///
- /// Bruce A. Kern
- ///
- public sealed class PaletteBox : JP2Box
- {
- /// Return the number of palette entries.
- public int NumEntries
- {
- get
- {
- return nentries;
- }
-
- }
- /// Return the number of palette columns.
- public int NumColumns
- {
- get
- {
- return ncolumns;
- }
-
- }
-
- private int nentries;
- private int ncolumns;
- private short[] bitdepth;
- private int[][] entries;
-
- /// Construct a PaletteBox from an input image.
- /// RandomAccessIO jp2 image
- ///
- /// offset to the start of the box in the image
- ///
- /// ColorSpaceException
- ///
- public PaletteBox(RandomAccessIO in_Renamed, int boxStart) : base(in_Renamed, boxStart)
- {
- readBox();
- }
-
- /// Analyze the box content.
- internal void readBox()
- {
- byte[] bfr = new byte[4];
- int i, j, b, m;
- //int entry;
-
- // Read the number of palette entries and columns per entry.
- in_Renamed.seek((int)dataStart);
- in_Renamed.readFully(bfr, 0, 3);
- nentries = ICCProfile.getShort(bfr, 0) & 0x0000ffff;
- ncolumns = bfr[2] & 0x0000ffff;
-
- // Read the bitdepths for each column
- bitdepth = new short[ncolumns];
- bfr = new byte[ncolumns];
- in_Renamed.readFully(bfr, 0, ncolumns);
- for (i = 0; i < ncolumns; ++i)
- {
- bitdepth[i] = (short)(bfr[i] & 0x00fff);
- }
-
- entries = new int[nentries * ncolumns][];
-
- bfr = new byte[2];
- for (i = 0; i < nentries; ++i)
- {
- entries[i] = new int[ncolumns];
-
- for (j = 0; j < ncolumns; ++j)
- {
-
- int bd = getBitDepth(j);
- bool signed = isSigned(j);
-
- switch (getEntrySize(j))
- {
-
- case 1: // 8 bit entries
- in_Renamed.readFully(bfr, 0, 1);
- b = bfr[0];
- break;
-
-
- case 2: // 16 bits
- in_Renamed.readFully(bfr, 0, 2);
- b = ICCProfile.getShort(bfr, 0);
- break;
-
-
- default:
- throw new ColorSpaceException("palettes greater than 16 bits deep not supported");
-
- }
-
- if (signed)
- {
- // Do sign extension if high bit is set.
- if ((b & (1 << (bd - 1))) == 0)
- {
- // high bit not set.
- m = (1 << bd) - 1;
- entries[i][j] = m & b;
- }
- else
- {
- // high bit set.
- // CONVERSION PROBLEM?
- m = unchecked((int)(0xffffffff << bd));
- entries[i][j] = m | b;
- }
- }
- else
- {
- // Clear all high bits.
- m = (1 << bd) - 1;
- entries[i][j] = m & b;
- }
- }
- }
- }
-
- /// Are entries signed predicate.
- public bool isSigned(int column)
- {
- return (bitdepth[column] & 0x80) == 1;
- }
-
- /// Are entries unsigned predicate.
- public bool isUnSigned(int column)
- {
- return !isSigned(column);
- }
-
- /// Return the bitdepth of palette entries.
- public short getBitDepth(int column)
- {
- return (short)((bitdepth[column] & 0x7f) + 1);
- }
-
- /// Return an entry for a given index and column.
- public int getEntry(int column, int entry)
- {
- return entries[entry][column];
- }
-
- /// Return a suitable String representation of the class instance.
- public override System.String ToString()
- {
- System.Text.StringBuilder rep = new System.Text.StringBuilder("[PaletteBox ").Append("nentries= ").Append(System.Convert.ToString(nentries)).Append(", ncolumns= ").Append(System.Convert.ToString(ncolumns)).Append(", bitdepth per column= (");
- for (int i = 0; i < ncolumns; ++i)
- rep.Append(getBitDepth(i)).Append(isSigned(i) ? "S" : "U").Append(i < ncolumns - 1 ? ", " : "");
- return rep.Append(")]").ToString();
- }
-
- private int getEntrySize(int column)
- {
- int bd = getBitDepth(column);
- return bd / 8 + (bd % 8) == 0 ? 0 : 1;
- }
-
- /* end class PaletteBox */
- static PaletteBox()
- {
- {
- type = 0x70636c72;
- }
- }
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/Icc/ICCMatrixBasedInputProfile.cs b/CSJ2K/Icc/ICCMatrixBasedInputProfile.cs
deleted file mode 100644
index fd32bbeb..00000000
--- a/CSJ2K/Icc/ICCMatrixBasedInputProfile.cs
+++ /dev/null
@@ -1,56 +0,0 @@
-/// **************************************************************************
-///
-/// $Id: ICCMatrixBasedInputProfile.java,v 1.1 2002/07/25 14:56:54 grosbois Exp $
-///
-/// Copyright Eastman Kodak Company, 343 State Street, Rochester, NY 14650
-/// $Date $
-/// ***************************************************************************
-///
-using ColorSpace = CSJ2K.Color.ColorSpace;
-using ColorSpaceException = CSJ2K.Color.ColorSpaceException;
-namespace CSJ2K.Icc
-{
-
- /// This class enables an application to construct an 3 component ICCProfile
- ///
- ///
- /// 1.0
- ///
- /// Bruce A. Kern
- ///
-
- public class ICCMatrixBasedInputProfile : ICCProfile
- {
-
- /// Factory method to create ICCMatrixBasedInputProfile based on a
- /// suppled profile file.
- ///
- /// contains a disk based ICCProfile.
- ///
- /// the ICCMatrixBasedInputProfile
- ///
- ///
- ///
- ///
- ///
- public static ICCMatrixBasedInputProfile createInstance(ColorSpace csm)
- {
- return new ICCMatrixBasedInputProfile(csm);
- }
-
- /// Construct an ICCMatrixBasedInputProfile based on a
- /// suppled profile file.
- ///
- /// contains a disk based ICCProfile.
- ///
- ///
- ///
- ///
- ///
- protected internal ICCMatrixBasedInputProfile(ColorSpace csm) : base(csm)
- {
- }
-
- /* end class ICCMatrixBasedInputProfile */
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/Icc/ICCMonochromeInputProfile.cs b/CSJ2K/Icc/ICCMonochromeInputProfile.cs
deleted file mode 100644
index 0e6d40d6..00000000
--- a/CSJ2K/Icc/ICCMonochromeInputProfile.cs
+++ /dev/null
@@ -1,53 +0,0 @@
-/// **************************************************************************
-///
-/// $Id: ICCMonochromeInputProfile.java,v 1.1 2002/07/25 14:56:54 grosbois Exp $
-///
-/// Copyright Eastman Kodak Company, 343 State Street, Rochester, NY 14650
-/// $Date $
-/// ***************************************************************************
-///
-using ColorSpace = CSJ2K.Color.ColorSpace;
-using ColorSpaceException = CSJ2K.Color.ColorSpaceException;
-namespace CSJ2K.Icc
-{
-
- /// The monochrome ICCProfile.
- ///
- ///
- /// 1.0
- ///
- /// Bruce A. Kern
- ///
- public class ICCMonochromeInputProfile : ICCProfile
- {
-
- /// Return the ICCProfile embedded in the input image
- /// jp2 image with embedded profile
- ///
- /// ICCMonochromeInputProfile
- ///
- ///
- ///
- ///
- ///
- public static ICCMonochromeInputProfile createInstance(ColorSpace csm)
- {
- return new ICCMonochromeInputProfile(csm);
- }
-
- /// Construct a ICCMonochromeInputProfile corresponding to the profile file
- /// disk based ICCMonochromeInputProfile
- ///
- /// theICCMonochromeInputProfile
- ///
- ///
- ///
- ///
- ///
- protected internal ICCMonochromeInputProfile(ColorSpace csm) : base(csm)
- {
- }
-
- /* end class ICCMonochromeInputProfile */
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/Icc/ICCProfile.cs b/CSJ2K/Icc/ICCProfile.cs
deleted file mode 100644
index 14010b4c..00000000
--- a/CSJ2K/Icc/ICCProfile.cs
+++ /dev/null
@@ -1,973 +0,0 @@
-/// **************************************************************************
-///
-/// $Id: ICCProfile.java,v 1.1 2002/07/25 14:56:55 grosbois Exp $
-///
-/// Copyright Eastman Kodak Company, 343 State Street, Rochester, NY 14650
-/// $Date $
-/// ***************************************************************************
-///
-using System;
-using System.Text;
-using ColorSpace = CSJ2K.Color.ColorSpace;
-using FacilityManager = CSJ2K.j2k.util.FacilityManager;
-using ICCCurveType = CSJ2K.Icc.Tags.ICCCurveType;
-using ICCDateTime = CSJ2K.Icc.Types.ICCDateTime;
-using ICCProfileHeader = CSJ2K.Icc.Types.ICCProfileHeader;
-using ICCProfileVersion = CSJ2K.Icc.Types.ICCProfileVersion;
-using ICCTagTable = CSJ2K.Icc.Tags.ICCTagTable;
-using ICCXYZType = CSJ2K.Icc.Tags.ICCXYZType;
-using ParameterList = CSJ2K.j2k.util.ParameterList;
-using XYZNumber = CSJ2K.Icc.Types.XYZNumber;
-namespace CSJ2K.Icc
-{
-
- /// This class models the ICCProfile file. This file is a binary file which is divided
- /// into two parts, an ICCProfileHeader followed by an ICCTagTable. The header is a
- /// straightforward list of descriptive parameters such as profile size, version, date and various
- /// more esoteric parameters. The tag table is a structured list of more complexly aggragated data
- /// describing things such as ICC curves, copyright information, descriptive text blocks, etc.
- ///
- /// Classes exist to model the header and tag table and their various constituent parts the developer
- /// is refered to these for further information on the structure and contents of the header and tag table.
- ///
- ///
- ///
- ///
- ///
- ///
- /// 1.0
- ///
- /// Bruce A. Kern
- ///
-
- public abstract class ICCProfile
- {
- private int ProfileSize
- {
- get
- {
- return header.dwProfileSize;
- }
-
- set
- {
- header.dwProfileSize = value;
- }
-
- }
- private int CMMTypeSignature
- {
- get
- {
- return header.dwCMMTypeSignature;
- }
-
- set
- {
- header.dwCMMTypeSignature = value;
- }
-
- }
- private int ProfileClass
- {
- get
- {
- return header.dwProfileClass;
- }
-
- set
- {
- header.dwProfileClass = value;
- }
-
- }
- private int ColorSpaceType
- {
- get
- {
- return header.dwColorSpaceType;
- }
-
- set
- {
- header.dwColorSpaceType = value;
- }
-
- }
- private int PCSType
- {
- get
- {
- return header.dwPCSType;
- }
-
- set
- {
- header.dwPCSType = value;
- }
-
- }
- private int ProfileSignature
- {
- get
- {
- return header.dwProfileSignature;
- }
-
- set
- {
- header.dwProfileSignature = value;
- }
-
- }
- private int PlatformSignature
- {
- get
- {
- return header.dwPlatformSignature;
- }
-
- set
- {
- header.dwPlatformSignature = value;
- }
-
- }
- private int CMMFlags
- {
- get
- {
- return header.dwCMMFlags;
- }
-
- set
- {
- header.dwCMMFlags = value;
- }
-
- }
- private int DeviceManufacturer
- {
- get
- {
- return header.dwDeviceManufacturer;
- }
-
- set
- {
- header.dwDeviceManufacturer = value;
- }
-
- }
- private int DeviceModel
- {
- get
- {
- return header.dwDeviceModel;
- }
-
- set
- {
- header.dwDeviceModel = value;
- }
-
- }
- private int DeviceAttributes1
- {
- get
- {
- return header.dwDeviceAttributes1;
- }
-
- set
- {
- header.dwDeviceAttributes1 = value;
- }
-
- }
- private int DeviceAttributesReserved
- {
- get
- {
- return header.dwDeviceAttributesReserved;
- }
-
- set
- {
- header.dwDeviceAttributesReserved = value;
- }
-
- }
- private int RenderingIntent
- {
- get
- {
- return header.dwRenderingIntent;
- }
-
- set
- {
- header.dwRenderingIntent = value;
- }
-
- }
- private int CreatorSig
- {
- get
- {
- return header.dwCreatorSig;
- }
-
- set
- {
- header.dwCreatorSig = value;
- }
-
- }
- private ICCProfileVersion ProfileVersion
- {
- get
- {
- return header.profileVersion;
- }
-
- set
- {
- header.profileVersion = value;
- }
-
- }
- private XYZNumber PCSIlluminant
- {
- set
- {
- header.PCSIlluminant = value;
- }
-
- }
- private ICCDateTime DateTime
- {
- set
- {
- header.dateTime = value;
- }
-
- }
- /// Access the profile header
- /// ICCProfileHeader
- ///
- virtual public ICCProfileHeader Header
- {
- get
- {
- return header;
- }
-
- }
- /// Access the profile tag table
- /// ICCTagTable
- ///
- virtual public ICCTagTable TagTable
- {
- get
- {
- return tags;
- }
-
- }
-
- //UPGRADE_NOTE: Final was removed from the declaration of 'eol '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- private static readonly System.String eol = System.Environment.NewLine;
-
- /// Gray index.
- // Renamed for convenience:
- public const int GRAY = 0;
- /// RGB index.
- public const int RED = 0;
- /// RGB index.
- public const int GREEN = 1;
- /// RGB index.
- public const int BLUE = 2;
-
- /// Size of native type
- public const int boolean_size = 1;
- /// Size of native type
- public const int byte_size = 1;
- /// Size of native type
- public const int char_size = 2;
- /// Size of native type
- public const int short_size = 2;
- /// Size of native type
- public const int int_size = 4;
- /// Size of native type
- public const int float_size = 4;
- /// Size of native type
- public const int long_size = 8;
- /// Size of native type
- public const int double_size = 8;
-
- /* Bit twiddling constant for integral types. */
- public const int BITS_PER_BYTE = 8;
- /* Bit twiddling constant for integral types. */
- public const int BITS_PER_SHORT = 16;
- /* Bit twiddling constant for integral types. */
- public const int BITS_PER_INT = 32;
- /* Bit twiddling constant for integral types. */
- public const int BITS_PER_LONG = 64;
- /* Bit twiddling constant for integral types. */
- public const int BYTES_PER_SHORT = 2;
- /* Bit twiddling constant for integral types. */
- public const int BYTES_PER_INT = 4;
- /* Bit twiddling constant for integral types. */
- public const int BYTES_PER_LONG = 8;
-
- /* JP2 Box structure analysis help */
-
- [Serializable]
- private class BoxType : System.Collections.Hashtable
- {
-
- private static System.Collections.Hashtable map = System.Collections.Hashtable.Synchronized(new System.Collections.Hashtable());
-
- public static void put(int type, System.String desc)
- {
- map[(System.Int32)type] = desc;
- }
-
- public static System.String get_Renamed(int type)
- {
- return (System.String)map[(System.Int32)type];
- }
-
- public static System.String colorSpecMethod(int meth)
- {
- switch (meth)
- {
-
- case 2: return "Restricted ICC Profile";
-
- case 1: return "Enumerated Color Space";
-
- default: return "Undefined Color Spec Method";
-
- }
- }
- static BoxType()
- {
- {
- put(CSJ2K.j2k.fileformat.FileFormatBoxes.BITS_PER_COMPONENT_BOX, "BITS_PER_COMPONENT_BOX");
- put(CSJ2K.j2k.fileformat.FileFormatBoxes.CAPTURE_RESOLUTION_BOX, "CAPTURE_RESOLUTION_BOX");
- put(CSJ2K.j2k.fileformat.FileFormatBoxes.CHANNEL_DEFINITION_BOX, "CHANNEL_DEFINITION_BOX");
- put(CSJ2K.j2k.fileformat.FileFormatBoxes.COLOUR_SPECIFICATION_BOX, "COLOUR_SPECIFICATION_BOX");
- put(CSJ2K.j2k.fileformat.FileFormatBoxes.COMPONENT_MAPPING_BOX, "COMPONENT_MAPPING_BOX");
- put(CSJ2K.j2k.fileformat.FileFormatBoxes.CONTIGUOUS_CODESTREAM_BOX, "CONTIGUOUS_CODESTREAM_BOX");
- put(CSJ2K.j2k.fileformat.FileFormatBoxes.DEFAULT_DISPLAY_RESOLUTION_BOX, "DEFAULT_DISPLAY_RESOLUTION_BOX");
- put(CSJ2K.j2k.fileformat.FileFormatBoxes.FILE_TYPE_BOX, "FILE_TYPE_BOX");
- put(CSJ2K.j2k.fileformat.FileFormatBoxes.IMAGE_HEADER_BOX, "IMAGE_HEADER_BOX");
- put(CSJ2K.j2k.fileformat.FileFormatBoxes.INTELLECTUAL_PROPERTY_BOX, "INTELLECTUAL_PROPERTY_BOX");
- put(CSJ2K.j2k.fileformat.FileFormatBoxes.JP2_HEADER_BOX, "JP2_HEADER_BOX");
- put(CSJ2K.j2k.fileformat.FileFormatBoxes.JP2_SIGNATURE_BOX, "JP2_SIGNATURE_BOX");
- put(CSJ2K.j2k.fileformat.FileFormatBoxes.PALETTE_BOX, "PALETTE_BOX");
- put(CSJ2K.j2k.fileformat.FileFormatBoxes.RESOLUTION_BOX, "RESOLUTION_BOX");
- put(CSJ2K.j2k.fileformat.FileFormatBoxes.URL_BOX, "URL_BOX");
- put(CSJ2K.j2k.fileformat.FileFormatBoxes.UUID_BOX, "UUID_BOX");
- put(CSJ2K.j2k.fileformat.FileFormatBoxes.UUID_INFO_BOX, "UUID_INFO_BOX");
- put(CSJ2K.j2k.fileformat.FileFormatBoxes.UUID_LIST_BOX, "UUID_LIST_BOX");
- put(CSJ2K.j2k.fileformat.FileFormatBoxes.XML_BOX, "XML_BOX");
- }
- }
- }
-
-
- /// Creates an int from a 4 character String
- /// string representation of an integer
- ///
- /// the integer which is denoted by the input String.
- ///
- public static int getIntFromString(System.String fourChar)
- {
- byte[] bytes = SupportClass.ToByteArray(fourChar);
- return getInt(bytes, 0);
- }
- /// Create an XYZNumber from byte [] input
- /// array containing the XYZNumber representation
- ///
- /// start of the rep in the array
- ///
- /// the created XYZNumber
- ///
- public static XYZNumber getXYZNumber(byte[] data, int offset)
- {
- int x, y, z;
- x = ICCProfile.getInt(data, offset);
- y = ICCProfile.getInt(data, offset + int_size);
- z = ICCProfile.getInt(data, offset + 2 * int_size);
- return new XYZNumber(x, y, z);
- }
-
- /// Create an ICCProfileVersion from byte [] input
- /// array containing the ICCProfileVersion representation
- ///
- /// start of the rep in the array
- ///
- /// the created ICCProfileVersion
- ///
- public static ICCProfileVersion getICCProfileVersion(byte[] data, int offset)
- {
- byte major = data[offset];
- byte minor = data[offset + byte_size];
- byte resv1 = data[offset + 2 * byte_size];
- byte resv2 = data[offset + 3 * byte_size];
- return new ICCProfileVersion(major, minor, resv1, resv2);
- }
-
- /// Create an ICCDateTime from byte [] input
- /// array containing the ICCProfileVersion representation
- ///
- /// start of the rep in the array
- ///
- /// the created ICCProfileVersion
- ///
- public static ICCDateTime getICCDateTime(byte[] data, int offset)
- {
- short wYear = ICCProfile.getShort(data, offset); // Number of the actual year (i.e. 1994)
- short wMonth = ICCProfile.getShort(data, offset + ICCProfile.short_size); // Number of the month (1-12)
- short wDay = ICCProfile.getShort(data, offset + 2 * ICCProfile.short_size); // Number of the day
- short wHours = ICCProfile.getShort(data, offset + 3 * ICCProfile.short_size); // Number of hours (0-23)
- short wMinutes = ICCProfile.getShort(data, offset + 4 * ICCProfile.short_size); // Number of minutes (0-59)
- short wSeconds = ICCProfile.getShort(data, offset + 5 * ICCProfile.short_size); // Number of seconds (0-59)
- return new ICCDateTime(wYear, wMonth, wDay, wHours, wMinutes, wSeconds);
- }
-
-
- /// Create a String from a byte []. Optionally swap adjacent byte
- /// pairs. Intended to be used to create integer String representations
- /// allowing for endian translations.
- ///
- /// data array
- ///
- /// start of data in array
- ///
- /// length of data in array
- ///
- /// swap adjacent bytes?
- ///
- /// String rep of data
- ///
- public static System.String getString(byte[] bfr, int offset, int length, bool swap)
- {
-
- byte[] result = new byte[length];
- int incr = swap ? -1 : 1;
- int start = swap ? offset + length - 1 : offset;
- for (int i = 0, j = start; i < length; ++i)
- {
- result[i] = bfr[j];
- j += incr;
- }
- return new System.String(SupportClass.ToCharArray(result));
- }
-
- /// Create a short from a two byte [], with optional byte swapping.
- /// data array
- ///
- /// start of data in array
- ///
- /// swap bytes?
- ///
- /// native type from representation.
- ///
- public static short getShort(byte[] bfr, int off, bool swap)
- {
-
- int tmp0 = bfr[off] & 0xff; // Clear the sign extended bits in the int.
- int tmp1 = bfr[off + 1] & 0xff;
-
-
- return (short)(swap ? (tmp1 << BITS_PER_BYTE | tmp0) : (tmp0 << BITS_PER_BYTE | tmp1));
- }
-
- /// Create a short from a two byte [].
- /// data array
- ///
- /// start of data in array
- ///
- /// native type from representation.
- ///
- public static short getShort(byte[] bfr, int off)
- {
- int tmp0 = bfr[off] & 0xff; // Clear the sign extended bits in the int.
- int tmp1 = bfr[off + 1] & 0xff;
- return (short)(tmp0 << BITS_PER_BYTE | tmp1);
- }
-
- /// Separate bytes in an int into a byte array lsb to msb order.
- /// integer to separate
- ///
- /// byte [] containing separated int.
- ///
- public static byte[] setInt(int d)
- {
- return setInt(d, new byte[BYTES_PER_INT]);
- }
-
- /// Separate bytes in an int into a byte array lsb to msb order.
- /// Return the result in the provided array
- ///
- /// integer to separate
- ///
- /// return output here.
- ///
- /// reference to output.
- ///
- public static byte[] setInt(int d, byte[] b)
- {
- if (b == null)
- b = new byte[BYTES_PER_INT];
- for (int i = 0; i < BYTES_PER_INT; ++i)
- {
- b[i] = (byte)(d & 0x0ff);
- d = d >> BITS_PER_BYTE;
- }
- return b;
- }
-
- /// Separate bytes in a long into a byte array lsb to msb order.
- /// long to separate
- ///
- /// byte [] containing separated int.
- ///
- public static byte[] setLong(long d)
- {
- return setLong(d, new byte[BYTES_PER_INT]);
- }
-
- /// Separate bytes in a long into a byte array lsb to msb order.
- /// Return the result in the provided array
- ///
- /// long to separate
- ///
- /// return output here.
- ///
- /// reference to output.
- ///
- public static byte[] setLong(long d, byte[] b)
- {
- if (b == null)
- b = new byte[BYTES_PER_LONG];
- for (int i = 0; i < BYTES_PER_LONG; ++i)
- {
- b[i] = (byte)(d & 0x0ff);
- d = d >> BITS_PER_BYTE;
- }
- return b;
- }
-
-
- /// Create an int from a byte [4], with optional byte swapping.
- /// data array
- ///
- /// start of data in array
- ///
- /// swap bytes?
- ///
- /// native type from representation.
- ///
- public static int getInt(byte[] bfr, int off, bool swap)
- {
-
- int tmp0 = getShort(bfr, off, swap) & 0xffff; // Clear the sign extended bits in the int.
- int tmp1 = getShort(bfr, off + 2, swap) & 0xffff;
-
- return (int)(swap ? (tmp1 << BITS_PER_SHORT | tmp0) : (tmp0 << BITS_PER_SHORT | tmp1));
- }
-
- /// Create an int from a byte [4].
- /// data array
- ///
- /// start of data in array
- ///
- /// native type from representation.
- ///
- public static int getInt(byte[] bfr, int off)
- {
-
- int tmp0 = getShort(bfr, off) & 0xffff; // Clear the sign extended bits in the int.
- int tmp1 = getShort(bfr, off + 2) & 0xffff;
-
- return (int)(tmp0 << BITS_PER_SHORT | tmp1);
- }
-
- /// Create an long from a byte [8].
- /// data array
- ///
- /// start of data in array
- ///
- /// native type from representation.
- ///
- public static long getLong(byte[] bfr, int off)
- {
-
- long tmp0 = getInt(bfr, off) & unchecked((int)0xffffffff); // Clear the sign extended bits in the int.
- long tmp1 = getInt(bfr, off + 4) & unchecked((int)0xffffffff);
-
- return (long)(tmp0 << BITS_PER_INT | tmp1);
- }
-
-
- /// signature
- // Define the set of standard signature and type values
- // Because of the endian issues and byte swapping, the profile codes must
- // be stored in memory and be addressed by address. As such, only those
- // codes required for Restricted ICC use are defined here
-
- //UPGRADE_NOTE: Final was removed from the declaration of 'kdwProfileSignature '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- public static readonly int kdwProfileSignature;
- /// signature
- //UPGRADE_NOTE: Final was removed from the declaration of 'kdwProfileSigReverse '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- public static readonly int kdwProfileSigReverse;
- /// profile type
- //UPGRADE_NOTE: Final was removed from the declaration of 'kdwInputProfile '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- public static readonly int kdwInputProfile;
- /// tag type
- //UPGRADE_NOTE: Final was removed from the declaration of 'kdwDisplayProfile '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- public static readonly int kdwDisplayProfile;
- /// tag type
- //UPGRADE_NOTE: Final was removed from the declaration of 'kdwRGBData '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- public static readonly int kdwRGBData;
- /// tag type
- //UPGRADE_NOTE: Final was removed from the declaration of 'kdwGrayData '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- public static readonly int kdwGrayData;
- /// tag type
- //UPGRADE_NOTE: Final was removed from the declaration of 'kdwXYZData '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- public static readonly int kdwXYZData;
- /// input type
- public const int kMonochromeInput = 0;
- /// input type
- public const int kThreeCompInput = 1;
-
- /// tag signature
- //UPGRADE_NOTE: Final was removed from the declaration of 'kdwGrayTRCTag '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- public static readonly int kdwGrayTRCTag;
- /// tag signature
- //UPGRADE_NOTE: Final was removed from the declaration of 'kdwRedColorantTag '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- public static readonly int kdwRedColorantTag;
- /// tag signature
- //UPGRADE_NOTE: Final was removed from the declaration of 'kdwGreenColorantTag '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- public static readonly int kdwGreenColorantTag;
- /// tag signature
- //UPGRADE_NOTE: Final was removed from the declaration of 'kdwBlueColorantTag '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- public static readonly int kdwBlueColorantTag;
- /// tag signature
- //UPGRADE_NOTE: Final was removed from the declaration of 'kdwRedTRCTag '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- public static readonly int kdwRedTRCTag;
- /// tag signature
- //UPGRADE_NOTE: Final was removed from the declaration of 'kdwGreenTRCTag '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- public static readonly int kdwGreenTRCTag;
- /// tag signature
- //UPGRADE_NOTE: Final was removed from the declaration of 'kdwBlueTRCTag '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- public static readonly int kdwBlueTRCTag;
- /// tag signature
- //UPGRADE_NOTE: Final was removed from the declaration of 'kdwCopyrightTag '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- public static readonly int kdwCopyrightTag;
- /// tag signature
- //UPGRADE_NOTE: Final was removed from the declaration of 'kdwMediaWhiteTag '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- public static readonly int kdwMediaWhiteTag;
- /// tag signature
- //UPGRADE_NOTE: Final was removed from the declaration of 'kdwProfileDescTag '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- public static readonly int kdwProfileDescTag;
-
-
- private ICCProfileHeader header = null;
- private ICCTagTable tags = null;
- private byte[] profile = null;
-
- //private byte[] data = null;
- private ParameterList pl = null;
-
- private ICCProfile()
- {
- throw new ICCProfileException("illegal to invoke empty constructor");
- }
-
- /// ParameterList constructor
- /// provides colorspace information
- ///
- protected internal ICCProfile(ColorSpace csm)
- {
- this.pl = csm.pl;
- profile = csm.ICCProfile;
- initProfile(profile);
- }
-
- /// Read the header and tags into memory and verify
- /// that the correct type of profile is being used. for encoding.
- ///
- /// ICCProfile
- ///
- /// for bad signature and class and bad type
- ///
- private void initProfile(byte[] data)
- {
- header = new ICCProfileHeader(data);
- tags = ICCTagTable.createInstance(data);
-
-
- // Verify that the data pointed to by icc is indeed a valid profile
- // and that it is possibly of one of the Restricted ICC types. The simplest way to check
- // this is to verify that the profile signature is correct, that it is an input profile,
- // and that the PCS used is XYX.
-
- // However, a common error in profiles will be to create Monitor profiles rather
- // than input profiles. If this is the only error found, it's still useful to let this
- // go through with an error written to stderr.
-
- if (ProfileClass == kdwDisplayProfile)
- {
- System.String message = "NOTE!! Technically, this profile is a Display profile, not an" + " Input Profile, and thus is not a valid Restricted ICC profile." + " However, it is quite possible that this profile is usable as" + " a Restricted ICC profile, so this code will ignore this state" + " and proceed with processing.";
-
- FacilityManager.getMsgLogger().printmsg(CSJ2K.j2k.util.MsgLogger_Fields.WARNING, message);
- }
-
- if ((ProfileSignature != kdwProfileSignature) || ((ProfileClass != kdwInputProfile) && (ProfileClass != kdwDisplayProfile)) || (PCSType != kdwXYZData))
- {
- throw new ICCProfileInvalidException();
- }
- }
-
-
- /// Provide a suitable string representation for the class
- public override System.String ToString()
- {
- System.Text.StringBuilder rep = new System.Text.StringBuilder("[ICCProfile:");
- System.Text.StringBuilder body = new System.Text.StringBuilder();
- body.Append(eol).Append(header);
- body.Append(eol).Append(eol).Append(tags);
- rep.Append(ColorSpace.indent(" ", body));
- return rep.Append("]").ToString();
- }
-
-
- /// Create a two character hex representation of a byte
- /// byte to represent
- ///
- /// representation
- ///
- public static System.String toHexString(byte i)
- {
- System.String rep = (i >= 0 && i < 16 ? "0" : "") + System.Convert.ToString((int)i, 16);
- if (rep.Length > 2)
- rep = rep.Substring(rep.Length - 2);
- return rep;
- }
-
- /// Create a 4 character hex representation of a short
- /// short to represent
- ///
- /// representation
- ///
- public static System.String toHexString(short i)
- {
- System.String rep;
-
- if (i >= 0 && i < 0x10)
- rep = "000" + System.Convert.ToString((int)i, 16);
- else if (i >= 0 && i < 0x100)
- rep = "00" + System.Convert.ToString((int)i, 16);
- else if (i >= 0 && i < 0x1000)
- rep = "0" + System.Convert.ToString((int)i, 16);
- else
- rep = "" + System.Convert.ToString((int)i, 16);
-
- if (rep.Length > 4)
- rep = rep.Substring(rep.Length - 4);
- return rep;
- }
-
-
- /// Create a 8 character hex representation of a int
- /// int to represent
- ///
- /// representation
- ///
- public static System.String toHexString(int i)
- {
- System.String rep;
-
- if (i >= 0 && i < 0x10)
- rep = "0000000" + System.Convert.ToString((int)i, 16);
- else if (i >= 0 && i < 0x100)
- rep = "000000" + System.Convert.ToString((int)i, 16);
- else if (i >= 0 && i < 0x1000)
- rep = "00000" + System.Convert.ToString((int)i, 16);
- else if (i >= 0 && i < 0x10000)
- rep = "0000" + System.Convert.ToString((int)i, 16);
- else if (i >= 0 && i < 0x100000)
- rep = "000" + System.Convert.ToString((int)i, 16);
- else if (i >= 0 && i < 0x1000000)
- rep = "00" + System.Convert.ToString((int)i, 16);
- else if (i >= 0 && i < 0x10000000)
- rep = "0" + System.Convert.ToString((int)i, 16);
- else
- rep = "" + System.Convert.ToString((int)i, 16);
-
- if (rep.Length > 8)
- rep = rep.Substring(rep.Length - 8);
- return rep;
- }
-
- public static System.String ToString(byte[] data)
- {
-
- int i, row, col, rem, rows, cols;
-
- System.Text.StringBuilder rep = new System.Text.StringBuilder();
- System.Text.StringBuilder rep0 = null;
- System.Text.StringBuilder rep1 = null;
- System.Text.StringBuilder rep2 = null;
-
- cols = 16;
- rows = data.Length / cols;
- rem = data.Length % cols;
-
- byte[] lbytes = new byte[8];
- for (row = 0, i = 0; row < rows; ++row)
- {
- rep1 = new System.Text.StringBuilder();
- rep2 = new System.Text.StringBuilder();
-
- for (i = 0; i < 8; ++i)
- lbytes[i] = 0;
- byte[] tbytes = System.Text.ASCIIEncoding.ASCII.GetBytes(System.Convert.ToString(row * 16, 16));
- for (int t = 0, l = lbytes.Length - tbytes.Length; t < tbytes.Length; ++l, ++t)
- lbytes[l] = tbytes[t];
-
- rep0 = new System.Text.StringBuilder(new System.String(SupportClass.ToCharArray(lbytes)));
-
- for (col = 0; col < cols; ++col)
- {
- byte b = data[i++];
- rep1.Append(toHexString(b)).Append(i % 2 == 0 ? " " : "");
- if ((System.Char.IsLetter((char)b) || ((char)b).CompareTo('$') == 0 || ((char)b).CompareTo('_') == 0))
- rep2.Append((char)b);
- else
- rep2.Append(".");
- }
- rep.Append(rep0).Append(" : ").Append(rep1).Append(": ").Append(rep2).Append(eol);
- }
-
- rep1 = new System.Text.StringBuilder();
- rep2 = new System.Text.StringBuilder();
-
- for (i = 0; i < 8; ++i)
- lbytes[i] = 0;
- byte[] tbytes2 = System.Text.ASCIIEncoding.ASCII.GetBytes(System.Convert.ToString(row * 16, 16));
- for (int t = 0, l = lbytes.Length - tbytes2.Length; t < tbytes2.Length; ++l, ++t)
- lbytes[l] = tbytes2[t];
-
- rep0 = new System.Text.StringBuilder(System.Text.ASCIIEncoding.ASCII.GetString(lbytes));
-
- for (col = 0; col < rem; ++col)
- {
- byte b = data[i++];
- rep1.Append(toHexString(b)).Append(i % 2 == 0 ? " " : "");
- if ((System.Char.IsLetter((char)b) || ((char)b).CompareTo('$') == 0 || ((char)b).CompareTo('_') == 0))
- rep2.Append((char)b);
- else
- rep2.Append(".");
- }
- for (col = rem; col < 16; ++col)
- rep1.Append(" ").Append(col % 2 == 0 ? " " : "");
-
- rep.Append(rep0).Append(" : ").Append(rep1).Append(": ").Append(rep2).Append(eol);
-
- return rep.ToString();
- }
-
- /// Parse this ICCProfile into a RestrictedICCProfile
- /// which is appropriate to the data in this profile.
- /// Either a MonochromeInputRestrictedProfile or
- /// MatrixBasedRestrictedProfile is returned
- ///
- /// RestrictedICCProfile
- ///
- /// no curve data
- ///
- public virtual RestrictedICCProfile parse()
- {
-
- // The next step is to determine which Restricted ICC type is used by this profile.
- // Unfortunately, the only way to do this is to look through the tag table for
- // the tags required by the two types.
-
- // First look for the gray TRC tag. If the profile is indeed an input profile, and this
- // tag exists, then the profile is a Monochrome Input profile
-
- ICCCurveType grayTag = (ICCCurveType)tags[(System.Int32)kdwGrayTRCTag];
- if (grayTag != null)
- {
- return RestrictedICCProfile.createInstance(grayTag);
- }
-
- // If it wasn't a Monochrome Input profile, look for the Red Colorant tag. If that
- // tag is found and the profile is indeed an input profile, then this profile is
- // a Three-Component Matrix-Based Input profile
-
- ICCCurveType rTRCTag = (ICCCurveType)tags[(System.Int32)kdwRedTRCTag];
-
-
- if (rTRCTag != null)
- {
- ICCCurveType gTRCTag = (ICCCurveType)tags[(System.Int32)kdwGreenTRCTag];
- ICCCurveType bTRCTag = (ICCCurveType)tags[(System.Int32)kdwBlueTRCTag];
- ICCXYZType rColorantTag = (ICCXYZType)tags[(System.Int32)kdwRedColorantTag];
- ICCXYZType gColorantTag = (ICCXYZType)tags[(System.Int32)kdwGreenColorantTag];
- ICCXYZType bColorantTag = (ICCXYZType)tags[(System.Int32)kdwBlueColorantTag];
- return RestrictedICCProfile.createInstance(rTRCTag, gTRCTag, bTRCTag, rColorantTag, gColorantTag, bColorantTag);
- }
-
- throw new ICCProfileInvalidException("curve data not found in profile");
- }
-
- /// Output this ICCProfile to a RandomAccessFile
- /// output file
- ///
- //UPGRADE_TODO: Class 'java.io.RandomAccessFile' was converted to 'System.IO.FileStream' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaioRandomAccessFile'"
- public virtual void write(System.IO.FileStream os)
- {
- Header.write(os);
- TagTable.write(os);
- }
-
-
- /* end class ICCProfile */
- static ICCProfile()
- {
- kdwProfileSignature = GetTagInt("acsp");
- kdwProfileSigReverse = GetTagInt("psca");
- kdwInputProfile = GetTagInt("scnr");
- kdwDisplayProfile = GetTagInt("mntr");
- kdwRGBData = GetTagInt("RGB ");
- kdwGrayData = GetTagInt("GRAY");
- kdwXYZData = GetTagInt("XYZ ");
-
- kdwGrayTRCTag = GetTagInt("kTRC");
- kdwRedColorantTag = GetTagInt("rXYZ");
- kdwGreenColorantTag = GetTagInt("gXYZ");
- kdwBlueColorantTag = GetTagInt("bXYZ");
- kdwRedTRCTag = GetTagInt("rTRC");
- kdwGreenTRCTag = GetTagInt("gTRC");
- kdwBlueTRCTag = GetTagInt("bTRC");
- kdwCopyrightTag = GetTagInt("cprt");
- kdwMediaWhiteTag = GetTagInt("wtpt");
- kdwProfileDescTag = GetTagInt("desc");
- }
- static int GetTagInt(string tag)
- {
- byte[] tagBytes = ASCIIEncoding.ASCII.GetBytes(tag);
- Array.Reverse(tagBytes);
- return BitConverter.ToInt32(tagBytes, 0);
- }
-
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/Icc/ICCProfileException.cs b/CSJ2K/Icc/ICCProfileException.cs
deleted file mode 100644
index b02422fc..00000000
--- a/CSJ2K/Icc/ICCProfileException.cs
+++ /dev/null
@@ -1,40 +0,0 @@
-/// **************************************************************************
-///
-/// $Id: ICCProfileException.java,v 1.2 2002/08/08 14:08:13 grosbois Exp $
-///
-/// Copyright Eastman Kodak Company, 343 State Street, Rochester, NY 14650
-/// $Date $
-/// ***************************************************************************
-///
-using System;
-namespace CSJ2K.Icc
-{
-
- /// This exception is thrown when the content of a profile
- /// is incorrect.
- ///
- ///
- ///
- ///
- /// 1.0
- ///
- /// Bruce A. Kern
- ///
- [Serializable]
- public class ICCProfileException : System.Exception
- {
-
- /// Contruct with message
- /// returned by getMessage()
- ///
- public ICCProfileException(System.String msg) : base(msg)
- {
- }
-
-
- /// Empty constructor
- public ICCProfileException()
- {
- }
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/Icc/ICCProfileInvalidException.cs b/CSJ2K/Icc/ICCProfileInvalidException.cs
deleted file mode 100644
index 08fc0785..00000000
--- a/CSJ2K/Icc/ICCProfileInvalidException.cs
+++ /dev/null
@@ -1,43 +0,0 @@
-/// **************************************************************************
-///
-/// $Id: ICCProfileInvalidException.java,v 1.1 2002/07/25 14:56:55 grosbois Exp $
-///
-/// Copyright Eastman Kodak Company, 343 State Street, Rochester, NY 14650
-/// $Date $
-/// ***************************************************************************
-///
-using System;
-namespace CSJ2K.Icc
-{
-
- /// This exception is thrown when the content of an an icc profile
- /// is in someway incorrect.
- ///
- ///
- ///
- ///
- /// 1.0
- ///
- /// Bruce A. Kern
- ///
-
- [Serializable]
- public class ICCProfileInvalidException : ICCProfileException
- {
-
- /// Contruct with message
- /// returned by getMessage()
- ///
- internal ICCProfileInvalidException(System.String msg) : base(msg)
- {
- }
-
-
- /// Empty constructor
- internal ICCProfileInvalidException() : base("icc profile is invalid")
- {
- }
-
- /* end class ICCProfileInvalidException */
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/Icc/ICCProfileNotFoundException.cs b/CSJ2K/Icc/ICCProfileNotFoundException.cs
deleted file mode 100644
index 328ab26b..00000000
--- a/CSJ2K/Icc/ICCProfileNotFoundException.cs
+++ /dev/null
@@ -1,43 +0,0 @@
-/// **************************************************************************
-///
-/// $Id: ICCProfileNotFoundException.java,v 1.1 2002/07/25 14:56:55 grosbois Exp $
-///
-/// Copyright Eastman Kodak Company, 343 State Street, Rochester, NY 14650
-/// $Date $
-/// ***************************************************************************
-///
-using System;
-namespace CSJ2K.Icc
-{
-
- /// This exception is thrown when an image contains no icc profile.
- /// is incorrect.
- ///
- ///
- ///
- ///
- /// 1.0
- ///
- /// Bruce A. Kern
- ///
-
- [Serializable]
- public class ICCProfileNotFoundException : ICCProfileException
- {
-
- /// Contruct with message
- /// returned by getMessage()
- ///
- internal ICCProfileNotFoundException(System.String msg) : base(msg)
- {
- }
-
-
- /// Empty constructor
- internal ICCProfileNotFoundException() : base("no icc profile in image")
- {
- }
-
- /* end class ICCProfileNotFoundException */
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/Icc/ICCProfiler.cs b/CSJ2K/Icc/ICCProfiler.cs
deleted file mode 100644
index b095525a..00000000
--- a/CSJ2K/Icc/ICCProfiler.cs
+++ /dev/null
@@ -1,479 +0,0 @@
-using CSJ2K.Color;
-using CSJ2K.Icc.Lut;
-using CSJ2K.j2k.image;
-using CSJ2K.j2k.util;
-/// **************************************************************************
-///
-/// $Id: ICCProfiler.java,v 1.2 2002/08/08 14:08:27 grosbois Exp $
-///
-/// Copyright Eastman Kodak Company, 343 State Street, Rochester, NY 14650
-/// $Date $
-/// ***************************************************************************
-///
-using System;
-namespace CSJ2K.Icc
-{
-
- /// This class provides ICC Profiling API for the jj2000.j2k imaging chain
- /// by implementing the BlkImgDataSrc interface, in particular the getCompData
- /// and getInternCompData methods.
- ///
- ///
- ///
- ///
- /// 1.0
- ///
- /// Bruce A. Kern
- ///
- public class ICCProfiler : ColorSpaceMapper
- {
-
- /// The prefix for ICC Profiler options
- new public const char OPT_PREFIX = 'I';
-
- /// Platform dependant end of line String.
- //UPGRADE_NOTE: Final was removed from the declaration of 'eol '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- new protected internal static readonly System.String eol = System.Environment.NewLine;
-
- // Renamed for convenience:
- //UPGRADE_NOTE: Final was removed from the declaration of 'GRAY '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- //UPGRADE_NOTE: The initialization of 'GRAY' was moved to static method 'icc.ICCProfiler'. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1005'"
- private static readonly int GRAY;
- //UPGRADE_NOTE: Final was removed from the declaration of 'RED '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- //UPGRADE_NOTE: The initialization of 'RED' was moved to static method 'icc.ICCProfiler'. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1005'"
- private static readonly int RED;
- //UPGRADE_NOTE: Final was removed from the declaration of 'GREEN '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- //UPGRADE_NOTE: The initialization of 'GREEN' was moved to static method 'icc.ICCProfiler'. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1005'"
- private static readonly int GREEN;
- //UPGRADE_NOTE: Final was removed from the declaration of 'BLUE '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- //UPGRADE_NOTE: The initialization of 'BLUE' was moved to static method 'icc.ICCProfiler'. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1005'"
- private static readonly int BLUE;
-
- // ICCProfiles.
- internal RestrictedICCProfile ricc = null;
- internal ICCProfile icc = null;
-
- // Temporary variables needed during profiling.
- private DataBlkInt[] tempInt; // Holds the results of the transform.
- private DataBlkFloat[] tempFloat; // Holds the results of the transform.
-
- private System.Object xform = null;
-
- /// The image's ICC profile.
- private RestrictedICCProfile iccp = null;
-
- /// Factory method for creating instances of this class.
- /// -- source of image data
- ///
- /// -- provides colorspace info
- ///
- /// ICCProfiler instance
- ///
- /// profile access exception
- ///
- /// profile content exception
- ///
- public static new BlkImgDataSrc createInstance(BlkImgDataSrc src, CSJ2K.Color.ColorSpace csMap)
- {
- return new ICCProfiler(src, csMap);
- }
-
- /// Ctor which creates an ICCProfile for the image and initializes
- /// all data objects (input, working, output).
- ///
- ///
- /// -- Source of image data
- ///
- /// -- provides colorspace info
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- protected internal ICCProfiler(BlkImgDataSrc src, CSJ2K.Color.ColorSpace csMap) : base(src, csMap)
- {
- initialize();
-
- iccp = getICCProfile(csMap);
- if (ncomps == 1)
- {
- xform = new MonochromeTransformTosRGB(iccp, maxValueArray[0], shiftValueArray[0]);
- }
- else
- {
- xform = new MatrixBasedTransformTosRGB(iccp, maxValueArray, shiftValueArray);
- }
-
- /* end ICCProfiler ctor */
- }
-
- /// General utility used by ctors
- private void initialize()
- {
-
- tempInt = new DataBlkInt[ncomps];
- tempFloat = new DataBlkFloat[ncomps];
-
- /* For each component, get the maximum data value, a reference
- * to the pixel data and set up working and temporary DataBlks
- * for both integer and float output.
- */
- for (int i = 0; i < ncomps; ++i)
- {
- tempInt[i] = new DataBlkInt();
- tempFloat[i] = new DataBlkFloat();
- }
- }
-
- /// Get the ICCProfile information JP2 ColorSpace
- /// provides all necessary info about the colorspace
- ///
- /// ICCMatrixBasedInputProfile for 3 component input and
- /// ICCMonochromeInputProfile for a 1 component source. Returns
- /// null if exceptions were encountered.
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- private RestrictedICCProfile getICCProfile(CSJ2K.Color.ColorSpace csm)
- {
-
- switch (ncomps)
- {
-
- case 1:
- icc = ICCMonochromeInputProfile.createInstance(csm);
- ricc = icc.parse();
- if (ricc.Type != RestrictedICCProfile.kMonochromeInput)
- throw new System.ArgumentException("wrong ICCProfile type" + " for image");
- break;
-
- case 3:
- icc = ICCMatrixBasedInputProfile.createInstance(csm);
- ricc = icc.parse();
- if (ricc.Type != RestrictedICCProfile.kThreeCompInput)
- throw new System.ArgumentException("wrong ICCProfile type" + " for image");
- break;
-
- default:
- throw new System.ArgumentException("illegal number of " + "components (" + ncomps + ") in image");
-
- }
- return ricc;
- }
-
- /// Returns, in the blk argument, a block of image data containing the
- /// specifed rectangular area, in the specified component. The data is
- /// returned, as a copy of the internal data, therefore the returned data
- /// can be modified "in place".
- ///
- /// The rectangular area to return is specified by the 'ulx', 'uly', 'w'
- /// and 'h' members of the 'blk' argument, relative to the current
- /// tile. These members are not modified by this method. The 'offset' of
- /// the returned data is 0, and the 'scanw' is the same as the block's
- /// width. See the 'DataBlk' class.
- ///
- ///
If the data array in 'blk' is 'null', then a new one is created. If
- /// the data array is not 'null' then it is reused, and it must be large
- /// enough to contain the block's data. Otherwise an 'ArrayStoreException'
- /// or an 'IndexOutOfBoundsException' is thrown by the Java system.
- ///
- ///
The returned data has its 'progressive' attribute set to that of the
- /// input data.
- ///
- ///
- /// Its coordinates and dimensions specify the area to
- /// return. If it contains a non-null data array, then it must have the
- /// correct dimensions. If it contains a null data array a new one is
- /// created. The fields in this object are modified to return the data.
- ///
- ///
- /// The index of the component from which to get the data. Only 0
- /// and 3 are valid.
- ///
- ///
- /// The requested DataBlk
- ///
- ///
- ///
- ///
- ///
- public override DataBlk getCompData(DataBlk outblk, int c)
- {
-
- try
- {
- if (ncomps != 1 && ncomps != 3)
- {
- System.String msg = "ICCProfiler: icc profile _not_ applied to " + ncomps + " component image";
- FacilityManager.getMsgLogger().printmsg(CSJ2K.j2k.util.MsgLogger_Fields.WARNING, msg);
- return src.getCompData(outblk, c);
- }
-
- int type = outblk.DataType;
-
- int leftedgeOut = -1; // offset to the start of the output scanline
- int rightedgeOut = -1; // offset to the end of the output
- // scanline + 1
- int leftedgeIn = -1; // offset to the start of the input scanline
- int rightedgeIn = -1; // offset to the end of the input
- // scanline + 1
-
- // Calculate all components:
- for (int i = 0; i < ncomps; ++i)
- {
-
- int fixedPtBits = src.getFixedPoint(i);
- int shiftVal = shiftValueArray[i];
- int maxVal = maxValueArray[i];
-
- // Initialize general input and output indexes
- int kOut = -1;
- int kIn = -1;
-
- switch (type)
- {
-
- // Int and Float data only
- case DataBlk.TYPE_INT:
-
- // Set up the DataBlk geometry
- copyGeometry(workInt[i], outblk);
- copyGeometry(tempInt[i], outblk);
- copyGeometry(inInt[i], outblk);
- InternalBuffer = outblk;
-
- // Reference the output array
- workDataInt[i] = (int[])workInt[i].Data;
-
- // Request data from the source.
- inInt[i] = (DataBlkInt)src.getInternCompData(inInt[i], i);
- dataInt[i] = inInt[i].DataInt;
-
- // The nitty-gritty.
-
- for (int row = 0; row < outblk.h; ++row)
- {
- leftedgeIn = inInt[i].offset + row * inInt[i].scanw;
- rightedgeIn = leftedgeIn + inInt[i].w;
- leftedgeOut = outblk.offset + row * outblk.scanw;
- rightedgeOut = leftedgeOut + outblk.w;
-
- for (kOut = leftedgeOut, kIn = leftedgeIn; kIn < rightedgeIn; ++kIn, ++kOut)
- {
- int tmpInt = (dataInt[i][kIn] >> fixedPtBits) + shiftVal;
- workDataInt[i][kOut] = ((tmpInt < 0) ? 0 : ((tmpInt > maxVal) ? maxVal : tmpInt));
- }
- }
- break;
-
-
- case DataBlk.TYPE_FLOAT:
-
- // Set up the DataBlk geometry
- copyGeometry(workFloat[i], outblk);
- copyGeometry(tempFloat[i], outblk);
- copyGeometry(inFloat[i], outblk);
- InternalBuffer = outblk;
-
- // Reference the output array
- workDataFloat[i] = (float[])workFloat[i].Data;
-
- // Request data from the source.
- inFloat[i] = (DataBlkFloat)src.getInternCompData(inFloat[i], i);
- dataFloat[i] = inFloat[i].DataFloat;
-
- // The nitty-gritty.
-
- for (int row = 0; row < outblk.h; ++row)
- {
- leftedgeIn = inFloat[i].offset + row * inFloat[i].scanw;
- rightedgeIn = leftedgeIn + inFloat[i].w;
- leftedgeOut = outblk.offset + row * outblk.scanw;
- rightedgeOut = leftedgeOut + outblk.w;
-
- for (kOut = leftedgeOut, kIn = leftedgeIn; kIn < rightedgeIn; ++kIn, ++kOut)
- {
- float tmpFloat = dataFloat[i][kIn] / (1 << fixedPtBits) + shiftVal;
- workDataFloat[i][kOut] = ((tmpFloat < 0) ? 0 : ((tmpFloat > maxVal) ? maxVal : tmpFloat));
- }
- }
- break;
-
-
- case DataBlk.TYPE_SHORT:
- case DataBlk.TYPE_BYTE:
- default:
- // Unsupported output type.
- throw new System.ArgumentException("Invalid source " + "datablock type");
- }
- }
-
- switch (type)
- {
-
- // Int and Float data only
- case DataBlk.TYPE_INT:
-
- if (ncomps == 1)
- {
- ((MonochromeTransformTosRGB)xform).apply(workInt[c], tempInt[c]);
- }
- else
- {
- // ncomps == 3
- ((MatrixBasedTransformTosRGB)xform).apply(workInt, tempInt);
- }
-
- outblk.progressive = inInt[c].progressive;
- outblk.Data = tempInt[c].Data;
- break;
-
-
- case DataBlk.TYPE_FLOAT:
-
- if (ncomps == 1)
- {
- ((MonochromeTransformTosRGB)xform).apply(workFloat[c], tempFloat[c]);
- }
- else
- {
- // ncomps == 3
- ((MatrixBasedTransformTosRGB)xform).apply(workFloat, tempFloat);
- }
-
- outblk.progressive = inFloat[c].progressive;
- outblk.Data = tempFloat[c].Data;
- break;
-
-
- case DataBlk.TYPE_SHORT:
- case DataBlk.TYPE_BYTE:
- default:
- // Unsupported output type.
- throw new System.ArgumentException("invalid source datablock" + " type");
- }
-
- // Initialize the output block geometry and set the profiled
- // data into the output block.
- outblk.offset = 0;
- outblk.scanw = outblk.w;
- }
- catch (MatrixBasedTransformException e)
- {
- //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Throwable.getMessage' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'"
- FacilityManager.getMsgLogger().printmsg(CSJ2K.j2k.util.MsgLogger_Fields.ERROR, "matrix transform problem:\n" + e.Message);
- if (pl.getParameter("debug").Equals("on"))
- {
- SupportClass.WriteStackTrace(e, Console.Error);
- }
- else
- {
- FacilityManager.getMsgLogger().printmsg(CSJ2K.j2k.util.MsgLogger_Fields.ERROR, "Use '-debug' option for more details");
- }
- return null;
- }
- catch (MonochromeTransformException e)
- {
- //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Throwable.getMessage' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'"
- FacilityManager.getMsgLogger().printmsg(CSJ2K.j2k.util.MsgLogger_Fields.ERROR, "monochrome transform problem:\n" + e.Message);
- if (pl.getParameter("debug").Equals("on"))
- {
- SupportClass.WriteStackTrace(e, Console.Error);
- }
- else
- {
- FacilityManager.getMsgLogger().printmsg(CSJ2K.j2k.util.MsgLogger_Fields.ERROR, "Use '-debug' option for more details");
- }
- return null;
- }
-
- return outblk;
- }
-
- /// Returns, in the blk argument, a block of image data containing the
- /// specifed rectangular area, in the specified component. The data is
- /// returned, as a reference to the internal data, if any, instead of as a
- /// copy, therefore the returned data should not be modified.
- ///
- /// The rectangular area to return is specified by the 'ulx', 'uly', 'w'
- /// and 'h' members of the 'blk' argument, relative to the current
- /// tile. These members are not modified by this method. The 'offset' and
- /// 'scanw' of the returned data can be arbitrary. See the 'DataBlk' class.
- ///
- ///
This method, in general, is more efficient than the 'getCompData()'
- /// method since it may not copy the data. However if the array of returned
- /// data is to be modified by the caller then the other method is probably
- /// preferable.
- ///
- ///
If possible, the data in the returned 'DataBlk' should be the
- /// internal data itself, instead of a copy, in order to increase the data
- /// transfer efficiency. However, this depends on the particular
- /// implementation (it may be more convenient to just return a copy of the
- /// data). This is the reason why the returned data should not be modified.
- ///
- ///
If the data array in blk is null, then a new one
- /// is created if necessary. The implementation of this interface may
- /// choose to return the same array or a new one, depending on what is more
- /// efficient. Therefore, the data array in blk prior to the
- /// method call should not be considered to contain the returned data, a
- /// new array may have been created. Instead, get the array from
- /// blk after the method has returned.
- ///
- ///
The returned data may have its 'progressive' attribute set. In this
- /// case the returned data is only an approximation of the "final" data.
- ///
- ///
- /// Its coordinates and dimensions specify the area to return,
- /// relative to the current tile. Some fields in this object are modified
- /// to return the data.
- ///
- ///
- /// The index of the component from which to get the data.
- ///
- ///
- /// The requested DataBlk
- ///
- ///
- ///
- ///
- ///
- public override DataBlk getInternCompData(DataBlk out_Renamed, int c)
- {
- return getCompData(out_Renamed, c);
- }
-
- /// Return a suitable String representation of the class instance.
- public override System.String ToString()
- {
- System.Text.StringBuilder rep = new System.Text.StringBuilder("[ICCProfiler:");
- System.Text.StringBuilder body = new System.Text.StringBuilder();
- if (icc != null)
- {
- body.Append(eol).Append(CSJ2K.Color.ColorSpace.indent(" ", icc.ToString()));
- }
- if (xform != null)
- {
- //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Object.toString' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'"
- body.Append(eol).Append(CSJ2K.Color.ColorSpace.indent(" ", xform.ToString()));
- }
- rep.Append(CSJ2K.Color.ColorSpace.indent(" ", body));
- return rep.Append("]").ToString();
- }
-
- /* end class ICCProfiler */
- static ICCProfiler()
- {
- GRAY = RestrictedICCProfile.GRAY;
- RED = RestrictedICCProfile.RED;
- GREEN = RestrictedICCProfile.GREEN;
- BLUE = RestrictedICCProfile.BLUE;
- }
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/Icc/Lut/LookUpTable.cs b/CSJ2K/Icc/Lut/LookUpTable.cs
deleted file mode 100644
index 018990b0..00000000
--- a/CSJ2K/Icc/Lut/LookUpTable.cs
+++ /dev/null
@@ -1,47 +0,0 @@
-/// **************************************************************************
-///
-/// $Id: LookUpTable.java,v 1.1 2002/07/25 14:56:49 grosbois Exp $
-///
-/// Copyright Eastman Kodak Company, 343 State Street, Rochester, NY 14650
-/// $Date $
-/// ***************************************************************************
-///
-using ICCCurveType = CSJ2K.Icc.Tags.ICCCurveType;
-namespace CSJ2K.Icc.Lut
-{
-
-
- /// Toplevel class for a lut. All lookup tables must
- /// extend this class.
- ///
- ///
- /// 1.0
- ///
- /// Bruce A. Kern
- ///
- public abstract class LookUpTable
- {
-
- /// End of line string.
- //UPGRADE_NOTE: Final was removed from the declaration of 'eol '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- protected internal static readonly System.String eol = System.Environment.NewLine;
- /// The curve data
- protected internal ICCCurveType curve = null;
- /// Number of values in created lut
- protected internal int dwNumInput = 0;
-
-
- /// For subclass usage.
- /// The curve data
- ///
- /// Number of values in created lut
- ///
- protected internal LookUpTable(ICCCurveType curve, int dwNumInput)
- {
- this.curve = curve;
- this.dwNumInput = dwNumInput;
- }
-
- /* end class LookUpTable */
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/Icc/Lut/LookUpTable16.cs b/CSJ2K/Icc/Lut/LookUpTable16.cs
deleted file mode 100644
index b893fd3f..00000000
--- a/CSJ2K/Icc/Lut/LookUpTable16.cs
+++ /dev/null
@@ -1,122 +0,0 @@
-/// **************************************************************************
-///
-/// $Id: LookUpTable16.java,v 1.1 2002/07/25 14:56:47 grosbois Exp $
-///
-/// Copyright Eastman Kodak Company, 343 State Street, Rochester, NY 14650
-/// $Date $
-/// ***************************************************************************
-///
-using ICCCurveType = CSJ2K.Icc.Tags.ICCCurveType;
-namespace CSJ2K.Icc.Lut
-{
-
- /// Toplevel class for a short [] lut.
- ///
- ///
- /// 1.0
- ///
- /// Bruce A. Kern
- ///
- public abstract class LookUpTable16 : LookUpTable
- {
-
- /// Maximum output value of the LUT
- //UPGRADE_NOTE: Final was removed from the declaration of 'dwMaxOutput '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- protected internal int dwMaxOutput;
- /// The lut values.
- //UPGRADE_NOTE: Final was removed from the declaration of 'lut '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- protected internal short[] lut;
-
- /// Create an abbreviated string representation of a 16 bit lut.
- /// the lut as a String
- ///
- public override System.String ToString()
- {
- System.Text.StringBuilder rep = new System.Text.StringBuilder("[LookUpTable16 ");
- //int row, col;
- rep.Append("max= " + dwMaxOutput);
- rep.Append(", nentries= " + dwMaxOutput);
- return rep.Append("]").ToString();
- }
-
- /// Create a full string representation of a 16 bit lut.
- /// the lut as a String
- ///
- public virtual System.String toStringWholeLut()
- {
- System.Text.StringBuilder rep = new System.Text.StringBuilder("[LookUpTable16" + eol);
- int row, col;
-
- rep.Append("max output = " + dwMaxOutput + eol);
- for (row = 0; row < dwNumInput / 10; ++row)
- {
- rep.Append("lut[" + 10 * row + "] : ");
- for (col = 0; col < 10; ++col)
- {
- rep.Append(lut[10 * row + col]).Append(" ");
- }
- rep.Append(eol);
- }
- // Partial row.
- rep.Append("lut[" + 10 * row + "] : ");
- for (col = 0; col < dwNumInput % 10; ++col)
- rep.Append(lut[10 * row + col] + " ");
- rep.Append(eol + eol);
- return rep.ToString();
- }
-
- /// Factory method for getting a 16 bit lut from a given curve.
- /// the data
- ///
- /// the size of the lut
- ///
- /// max output value of the lut
- ///
- /// the lookup table
- ///
- public static LookUpTable16 createInstance(ICCCurveType curve, int dwNumInput, int dwMaxOutput)
- {
-
- if (curve.count == 1)
- return new LookUpTable16Gamma(curve, dwNumInput, dwMaxOutput);
- else
- return new LookUpTable16Interp(curve, dwNumInput, dwMaxOutput);
- }
-
- /// Construct an empty 16 bit lut
- /// the size of the lut t lut.
- ///
- /// max output value of the lut
- ///
- protected internal LookUpTable16(int dwNumInput, int dwMaxOutput) : base(null, dwNumInput)
- {
- lut = new short[dwNumInput];
- this.dwMaxOutput = dwMaxOutput;
- }
-
- /// Construct a 16 bit lut from a given curve.
- /// the data
- ///
- /// the size of the lut t lut.
- ///
- /// max output value of the lut
- ///
- protected internal LookUpTable16(ICCCurveType curve, int dwNumInput, int dwMaxOutput) : base(curve, dwNumInput)
- {
- this.dwMaxOutput = dwMaxOutput;
- lut = new short[dwNumInput];
- }
-
- /// lut accessor
- /// of the element
- ///
- /// the lut [index]
- ///
- public short elementAt(int index)
- {
- return lut[index];
- }
-
- /* end class LookUpTable16 */
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/Icc/Lut/LookUpTable16Gamma.cs b/CSJ2K/Icc/Lut/LookUpTable16Gamma.cs
deleted file mode 100644
index 91ed72c4..00000000
--- a/CSJ2K/Icc/Lut/LookUpTable16Gamma.cs
+++ /dev/null
@@ -1,42 +0,0 @@
-/// **************************************************************************
-///
-/// $Id: LookUpTable16Gamma.java,v 1.1 2002/07/25 14:56:46 grosbois Exp $
-///
-/// Copyright Eastman Kodak Company, 343 State Street, Rochester, NY 14650
-/// $Date $
-/// ***************************************************************************
-///
-using ICCCurveType = CSJ2K.Icc.Tags.ICCCurveType;
-namespace CSJ2K.Icc.Lut
-{
-
- /// A Gamma based 16 bit lut.
- ///
- ///
- ///
- ///
- /// 1.0
- ///
- /// Bruce A. Kern
- ///
- public class LookUpTable16Gamma : LookUpTable16
- {
-
- /* Construct the lut
- * @param curve data
- * @param dwNumInput size of lut
- * @param dwMaxOutput max value of lut
- */
- public LookUpTable16Gamma(ICCCurveType curve, int dwNumInput, int dwMaxOutput) : base(curve, dwNumInput, dwMaxOutput)
- {
- double dfE = ICCCurveType.CurveGammaToDouble(curve.entry(0)); // Gamma exponent for inverse transformation
- for (int i = 0; i < dwNumInput; i++)
- {
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- lut[i] = (short)System.Math.Floor(System.Math.Pow((double)i / (dwNumInput - 1), dfE) * dwMaxOutput + 0.5);
- }
- }
-
- /* end class LookUpTable16Gamma */
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/Icc/Lut/LookUpTable16Interp.cs b/CSJ2K/Icc/Lut/LookUpTable16Interp.cs
deleted file mode 100644
index 8dfb7d25..00000000
--- a/CSJ2K/Icc/Lut/LookUpTable16Interp.cs
+++ /dev/null
@@ -1,65 +0,0 @@
-/// **************************************************************************
-///
-/// $Id: LookUpTable16Interp.java,v 1.1 2002/07/25 14:56:46 grosbois Exp $
-///
-/// Copyright Eastman Kodak Company, 343 State Street, Rochester, NY 14650
-/// $Date $
-/// ***************************************************************************
-///
-using ICCCurveType = CSJ2K.Icc.Tags.ICCCurveType;
-namespace CSJ2K.Icc.Lut
-{
-
- /// An interpolated 16 bit lut
- ///
- ///
- /// 1.0
- ///
- /// Bruce A.Kern
- ///
- public class LookUpTable16Interp : LookUpTable16
- {
-
- /// Construct the lut from the curve data
- /// curve the data
- /// dwNumInput the lut size
- /// dwMaxOutput the lut max value
- public LookUpTable16Interp(ICCCurveType curve, int dwNumInput, int dwMaxOutput) : base(curve, dwNumInput, dwMaxOutput)
- {
-
- int dwLowIndex, dwHighIndex; // Indices of interpolation points
- double dfLowIndex, dfHighIndex; // FP indices of interpolation points
- double dfTargetIndex; // Target index into interpolation table
- double dfRatio; // Ratio of LUT input points to curve values
- double dfLow, dfHigh; // Interpolation values
- double dfOut; // Output LUT value
-
- dfRatio = (double)(curve.count - 1) / (double)(dwNumInput - 1);
-
- for (int i = 0; i < dwNumInput; i++)
- {
- dfTargetIndex = (double)i * dfRatio;
- dfLowIndex = System.Math.Floor(dfTargetIndex);
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- dwLowIndex = (int)dfLowIndex;
- dfHighIndex = System.Math.Ceiling(dfTargetIndex);
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- dwHighIndex = (int)dfHighIndex;
-
- if (dwLowIndex == dwHighIndex)
- dfOut = ICCCurveType.CurveToDouble(curve.entry(dwLowIndex));
- else
- {
- dfLow = ICCCurveType.CurveToDouble(curve.entry(dwLowIndex));
- dfHigh = ICCCurveType.CurveToDouble(curve.entry(dwHighIndex));
- dfOut = dfLow + (dfHigh - dfLow) * (dfTargetIndex - dfLowIndex);
- }
-
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- lut[i] = (short)System.Math.Floor(dfOut * dwMaxOutput + 0.5);
- }
- }
-
- /* end class LookUpTable16Interp */
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/Icc/Lut/LookUpTable16LinearSRGBtoSRGB.cs b/CSJ2K/Icc/Lut/LookUpTable16LinearSRGBtoSRGB.cs
deleted file mode 100644
index e4b67d10..00000000
--- a/CSJ2K/Icc/Lut/LookUpTable16LinearSRGBtoSRGB.cs
+++ /dev/null
@@ -1,79 +0,0 @@
-/// **************************************************************************
-///
-/// $Id: LookUpTable16LinearSRGBtoSRGB.java,v 1.1 2002/07/25 14:56:47 grosbois Exp $
-///
-/// Copyright Eastman Kodak Company, 343 State Street, Rochester, NY 14650
-/// $Date $
-/// ***************************************************************************
-///
-namespace CSJ2K.Icc.Lut
-{
-
- /// A Linear 16 bit SRGB to SRGB lut
- ///
- ///
- /// 1.0
- ///
- /// Bruce A. Kern
- ///
- public class LookUpTable16LinearSRGBtoSRGB : LookUpTable16
- {
-
- /// Factory method for creating the lut.
- /// size of shadow region
- ///
- /// shadow region parameter
- ///
- /// size of lut
- ///
- /// post shadow region parameter
- ///
- /// post shadow region parameter
- ///
- /// post shadow region parameter
- ///
- /// the lut
- ///
- public static LookUpTable16LinearSRGBtoSRGB createInstance(int wShadowCutoff, double dfShadowSlope, int ksRGBLinearMaxValue, double ksRGB8ScaleAfterExp, double ksRGBExponent, double ksRGB8ReduceAfterEx)
- {
- return new LookUpTable16LinearSRGBtoSRGB(wShadowCutoff, dfShadowSlope, ksRGBLinearMaxValue, ksRGB8ScaleAfterExp, ksRGBExponent, ksRGB8ReduceAfterEx);
- }
-
- /// Construct the lut
- /// size of shadow region
- ///
- /// shadow region parameter
- ///
- /// size of lut
- ///
- /// post shadow region parameter
- ///
- /// post shadow region parameter
- ///
- /// post shadow region parameter
- ///
- protected internal LookUpTable16LinearSRGBtoSRGB(int wShadowCutoff, double dfShadowSlope, int ksRGBLinearMaxValue, double ksRGB8ScaleAfterExp, double ksRGBExponent, double ksRGB8ReduceAfterExp) : base(ksRGBLinearMaxValue + 1, (short)0)
- {
-
- int i = -1;
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- double dfNormalize = 1.0 / (float)ksRGBLinearMaxValue;
-
- // Generate the final linear-sRGB to non-linear sRGB LUT
- for (i = 0; i <= wShadowCutoff; i++)
- {
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- lut[i] = (byte)System.Math.Floor(dfShadowSlope * (double)i + 0.5);
- }
-
- // Now calculate the rest
- for (; i <= ksRGBLinearMaxValue; i++)
- {
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- lut[i] = (byte)System.Math.Floor(ksRGB8ScaleAfterExp * System.Math.Pow((double)i * dfNormalize, ksRGBExponent) - ksRGB8ReduceAfterExp + 0.5);
- }
- }
-
- /* end class LookUpTable16LinearSRGBtoSRGB */
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/Icc/Lut/LookUpTable32.cs b/CSJ2K/Icc/Lut/LookUpTable32.cs
deleted file mode 100644
index c139871c..00000000
--- a/CSJ2K/Icc/Lut/LookUpTable32.cs
+++ /dev/null
@@ -1,121 +0,0 @@
-/// **************************************************************************
-///
-/// $Id: LookUpTable32.java,v 1.1 2002/07/25 14:56:47 grosbois Exp $
-///
-/// Copyright Eastman Kodak Company, 343 State Street, Rochester, NY 14650
-/// $Date $
-/// ***************************************************************************
-///
-using ICCCurveType = CSJ2K.Icc.Tags.ICCCurveType;
-namespace CSJ2K.Icc.Lut
-{
-
- /// Toplevel class for a int [] lut.
- ///
- ///
- /// 1.0
- ///
- /// Bruce A. Kern
- ///
- //UPGRADE_NOTE: The access modifier for this class or class field has been changed in order to prevent compilation errors due to the visibility level. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1296'"
- abstract public class LookUpTable32 : LookUpTable
- {
-
- /// Maximum output value of the LUT
- //UPGRADE_NOTE: Final was removed from the declaration of 'dwMaxOutput '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- protected internal int dwMaxOutput;
- /// the lut values.
- //UPGRADE_NOTE: Final was removed from the declaration of 'lut '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- public int[] lut;
-
- /// Create an abbreviated string representation of a 16 bit lut.
- /// the lut as a String
- ///
- public override System.String ToString()
- {
- System.Text.StringBuilder rep = new System.Text.StringBuilder("[LookUpTable32 ");
- //int row, col;
- rep.Append("max= " + dwMaxOutput);
- rep.Append(", nentries= " + dwNumInput);
- return rep.Append("]").ToString();
- }
-
- /// Create the string representation of a 32 bit lut.
- /// the lut as a String
- ///
- public virtual System.String toStringWholeLut()
- {
- System.Text.StringBuilder rep = new System.Text.StringBuilder("[LookUpTable32" + eol);
- int row, col;
- rep.Append("max output = " + dwMaxOutput + eol);
- for (row = 0; row < dwNumInput / 10; ++row)
- {
- rep.Append("lut[" + 10 * row + "] : ");
- for (col = 0; col < 10; ++col)
- {
- rep.Append(lut[10 * row + col] + " ");
- }
- rep.Append(eol);
- }
- // Partial row.
- rep.Append("lut[" + 10 * row + "] : ");
- for (col = 0; col < dwNumInput % 10; ++col)
- rep.Append(lut[10 * row + col] + " ");
- rep.Append(eol + eol);
- return rep.ToString();
- }
-
- /// Factory method for getting a 32 bit lut from a given curve.
- /// the data
- ///
- /// the size of the lut
- ///
- /// max output value of the lut
- ///
- /// the lookup table
- ///
- public static LookUpTable32 createInstance(ICCCurveType curve, int dwNumInput, int dwMaxOutput)
- {
- if (curve.count == 1)
- return new LookUpTable32Gamma(curve, dwNumInput, dwMaxOutput);
- else
- return new LookUpTable32Interp(curve, dwNumInput, dwMaxOutput);
- }
-
- /// Construct an empty 32 bit
- /// the size of the lut t lut.
- ///
- /// max output value of the lut
- ///
- protected internal LookUpTable32(int dwNumInput, int dwMaxOutput) : base(null, dwNumInput)
- {
- lut = new int[dwNumInput];
- this.dwMaxOutput = dwMaxOutput;
- }
-
- /// Construct a 16 bit lut from a given curve.
- /// the data
- ///
- /// the size of the lut t lut.
- ///
- /// max output value of the lut
- ///
- protected internal LookUpTable32(ICCCurveType curve, int dwNumInput, int dwMaxOutput) : base(curve, dwNumInput)
- {
- this.dwMaxOutput = dwMaxOutput;
- lut = new int[dwNumInput];
- }
-
- /// lut accessor
- /// of the element
- ///
- /// the lut [index]
- ///
- public int elementAt(int index)
- {
- return lut[index];
- }
-
- /* end class LookUpTable32 */
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/Icc/Lut/LookUpTable32Gamma.cs b/CSJ2K/Icc/Lut/LookUpTable32Gamma.cs
deleted file mode 100644
index 8ec3a6f3..00000000
--- a/CSJ2K/Icc/Lut/LookUpTable32Gamma.cs
+++ /dev/null
@@ -1,44 +0,0 @@
-/// **************************************************************************
-///
-/// $Id: LookUpTable32Gamma.java,v 1.1 2002/07/25 14:56:47 grosbois Exp $
-///
-/// Copyright Eastman Kodak Company, 343 State Street, Rochester, NY 14650
-/// $Date $
-/// ***************************************************************************
-///
-using ICCCurveType = CSJ2K.Icc.Tags.ICCCurveType;
-namespace CSJ2K.Icc.Lut
-{
-
- /// A Gamma based 32 bit lut.
- ///
- ///
- ///
- ///
- /// 1.0
- ///
- /// Bruce A. Kern
- ///
-
- public class LookUpTable32Gamma : LookUpTable32
- {
-
-
- /* Construct the lut
- * @param curve data
- * @param dwNumInput size of lut
- * @param dwMaxOutput max value of lut
- */
- public LookUpTable32Gamma(ICCCurveType curve, int dwNumInput, int dwMaxOutput) : base(curve, dwNumInput, dwMaxOutput)
- {
- double dfE = ICCCurveType.CurveGammaToDouble(curve.entry(0)); // Gamma exponent for inverse transformation
- for (int i = 0; i < dwNumInput; i++)
- {
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- lut[i] = (int)System.Math.Floor(System.Math.Pow((double)i / (dwNumInput - 1), dfE) * dwMaxOutput + 0.5);
- }
- }
-
- /* end class LookUpTable32Gamma */
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/Icc/Lut/LookUpTable32Interp.cs b/CSJ2K/Icc/Lut/LookUpTable32Interp.cs
deleted file mode 100644
index 5626e145..00000000
--- a/CSJ2K/Icc/Lut/LookUpTable32Interp.cs
+++ /dev/null
@@ -1,66 +0,0 @@
-/// **************************************************************************
-///
-/// $Id: LookUpTable32Interp.java,v 1.1 2002/07/25 14:56:47 grosbois Exp $
-///
-/// Copyright Eastman Kodak Company, 343 State Street, Rochester, NY 14650
-/// $Date $
-/// ***************************************************************************
-///
-using ICCCurveType = CSJ2K.Icc.Tags.ICCCurveType;
-namespace CSJ2K.Icc.Lut
-{
-
- /// An interpolated 32 bit lut
- ///
- ///
- /// 1.0
- ///
- /// Bruce A.Kern
- ///
-
- public class LookUpTable32Interp : LookUpTable32
- {
-
- /// Construct the lut from the curve data
- /// curve the data
- /// dwNumInput the lut size
- /// dwMaxOutput the lut max value
- public LookUpTable32Interp(ICCCurveType curve, int dwNumInput, int dwMaxOutput) : base(curve, dwNumInput, dwMaxOutput)
- {
-
- int dwLowIndex, dwHighIndex; // Indices of interpolation points
- double dfLowIndex, dfHighIndex; // FP indices of interpolation points
- double dfTargetIndex; // Target index into interpolation table
- double dfRatio; // Ratio of LUT input points to curve values
- double dfLow, dfHigh; // Interpolation values
- double dfOut; // Output LUT value
-
- dfRatio = (double)(curve.count - 1) / (double)(dwNumInput - 1);
-
- for (int i = 0; i < dwNumInput; i++)
- {
- dfTargetIndex = (double)i * dfRatio;
- dfLowIndex = System.Math.Floor(dfTargetIndex);
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- dwLowIndex = (int)dfLowIndex;
- dfHighIndex = System.Math.Ceiling(dfTargetIndex);
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- dwHighIndex = (int)dfHighIndex;
-
- if (dwLowIndex == dwHighIndex)
- dfOut = ICCCurveType.CurveToDouble(curve.entry(dwLowIndex));
- else
- {
- dfLow = ICCCurveType.CurveToDouble(curve.entry(dwLowIndex));
- dfHigh = ICCCurveType.CurveToDouble(curve.entry(dwHighIndex));
- dfOut = dfLow + (dfHigh - dfLow) * (dfTargetIndex - dfLowIndex);
- }
-
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- lut[i] = (int)System.Math.Floor(dfOut * dwMaxOutput + 0.5);
- }
- }
-
- /* end class LookUpTable32Interp */
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/Icc/Lut/LookUpTable32LinearSRGBtoSRGB.cs b/CSJ2K/Icc/Lut/LookUpTable32LinearSRGBtoSRGB.cs
deleted file mode 100644
index 09b1df6d..00000000
--- a/CSJ2K/Icc/Lut/LookUpTable32LinearSRGBtoSRGB.cs
+++ /dev/null
@@ -1,100 +0,0 @@
-/// **************************************************************************
-///
-/// $Id: LookUpTable32LinearSRGBtoSRGB.java,v 1.1 2002/07/25 14:56:47 grosbois Exp $
-///
-/// Copyright Eastman Kodak Company, 343 State Street, Rochester, NY 14650
-/// $Date $
-/// ***************************************************************************
-///
-namespace CSJ2K.Icc.Lut
-{
-
- /// A Linear 32 bit SRGB to SRGB lut
- ///
- ///
- /// 1.0
- ///
- /// Bruce A. Kern
- ///
- public class LookUpTable32LinearSRGBtoSRGB : LookUpTable32
- {
-
- /// Factory method for creating the lut.
- /// size of shadow region
- ///
- /// shadow region parameter
- ///
- /// size of lut
- ///
- /// post shadow region parameter
- ///
- /// post shadow region parameter
- ///
- /// post shadow region parameter
- ///
- /// the lut
- ///
- public static LookUpTable32LinearSRGBtoSRGB createInstance(int inMax, int outMax, double shadowCutoff, double shadowSlope, double scaleAfterExp, double exponent, double reduceAfterExp)
- {
- return new LookUpTable32LinearSRGBtoSRGB(inMax, outMax, shadowCutoff, shadowSlope, scaleAfterExp, exponent, reduceAfterExp);
- }
-
- /// Construct the lut
- /// size of shadow region
- ///
- /// shadow region parameter
- ///
- /// size of lut
- ///
- /// post shadow region parameter
- ///
- /// post shadow region parameter
- ///
- /// post shadow region parameter
- ///
- protected internal LookUpTable32LinearSRGBtoSRGB(int inMax, int outMax, double shadowCutoff, double shadowSlope, double scaleAfterExp, double exponent, double reduceAfterExp) : base(inMax + 1, outMax)
- {
-
- int i = -1;
- // Normalization factor for i.
- double normalize = 1.0 / (double)inMax;
-
- // Generate the final linear-sRGB to non-linear sRGB LUT
-
- // calculate where shadow portion of lut ends.
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- int cutOff = (int)System.Math.Floor(shadowCutoff * inMax);
-
- // Scale to account for output
- shadowSlope *= outMax;
-
- // Our output needs to be centered on zero so we shift it down.
- int shift = (outMax + 1) / 2;
-
- for (i = 0; i <= cutOff; i++)
- {
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- lut[i] = (int)(System.Math.Floor(shadowSlope * (i * normalize) + 0.5) - shift);
- }
-
- // Scale values for output.
- scaleAfterExp *= outMax;
- reduceAfterExp *= outMax;
-
- // Now calculate the rest
- for (; i <= inMax; i++)
- {
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- lut[i] = (int)(System.Math.Floor(scaleAfterExp * System.Math.Pow(i * normalize, exponent) - reduceAfterExp + 0.5) - shift);
- }
- }
-
- public override System.String ToString()
- {
- System.Text.StringBuilder rep = new System.Text.StringBuilder("[LookUpTable32LinearSRGBtoSRGB:");
- return rep.Append("]").ToString();
- }
-
- /* end class LookUpTable32LinearSRGBtoSRGB */
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/Icc/Lut/LookUpTable8.cs b/CSJ2K/Icc/Lut/LookUpTable8.cs
deleted file mode 100644
index 79773e70..00000000
--- a/CSJ2K/Icc/Lut/LookUpTable8.cs
+++ /dev/null
@@ -1,83 +0,0 @@
-/// **************************************************************************
-///
-/// $Id: LookUpTable8.java,v 1.1 2002/07/25 14:56:48 grosbois Exp $
-///
-/// Copyright Eastman Kodak Company, 343 State Street, Rochester, NY 14650
-/// $Date $
-/// ***************************************************************************
-///
-using ICCCurveType = CSJ2K.Icc.Tags.ICCCurveType;
-namespace CSJ2K.Icc.Lut
-{
-
- /// Toplevel class for a byte [] lut.
- ///
- ///
- /// 1.0
- ///
- /// Bruce A. Kern
- ///
- public abstract class LookUpTable8 : LookUpTable
- {
-
- /// Maximum output value of the LUT
- //UPGRADE_NOTE: Final was removed from the declaration of 'dwMaxOutput '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- protected internal byte dwMaxOutput;
- /// The lut values.
- // Maximum output value of the LUT
- //UPGRADE_NOTE: Final was removed from the declaration of 'lut '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- protected internal byte[] lut;
-
-
- /// Create an abbreviated string representation of a 16 bit lut.
- /// the lut as a String
- ///
- public override System.String ToString()
- {
- System.Text.StringBuilder rep = new System.Text.StringBuilder("[LookUpTable8 ");
- //int row, col;
- rep.Append("max= " + dwMaxOutput);
- rep.Append(", nentries= " + dwMaxOutput);
- return rep.Append("]").ToString();
- }
-
-
-
- public virtual System.String toStringWholeLut()
- {
- System.Text.StringBuilder rep = new System.Text.StringBuilder("LookUpTable8" + eol);
- rep.Append("maxOutput = " + dwMaxOutput + eol);
- for (int i = 0; i < dwNumInput; ++i)
- rep.Append("lut[" + i + "] = " + lut[i] + eol);
- return rep.Append("]").ToString();
- }
-
- protected internal LookUpTable8(int dwNumInput, byte dwMaxOutput) : base(null, dwNumInput)
- {
- lut = new byte[dwNumInput];
- this.dwMaxOutput = dwMaxOutput;
- }
-
-
- /// Create the string representation of a 16 bit lut.
- /// the lut as a String
- ///
- protected internal LookUpTable8(ICCCurveType curve, int dwNumInput, byte dwMaxOutput) : base(curve, dwNumInput)
- {
- this.dwMaxOutput = dwMaxOutput;
- lut = new byte[dwNumInput];
- }
-
- /// lut accessor
- /// of the element
- ///
- /// the lut [index]
- ///
- public byte elementAt(int index)
- {
- return lut[index];
- }
-
- /* end class LookUpTable8 */
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/Icc/Lut/LookUpTable8Gamma.cs b/CSJ2K/Icc/Lut/LookUpTable8Gamma.cs
deleted file mode 100644
index 9dd22264..00000000
--- a/CSJ2K/Icc/Lut/LookUpTable8Gamma.cs
+++ /dev/null
@@ -1,42 +0,0 @@
-/// **************************************************************************
-///
-/// $Id: LookUpTable8Gamma.java,v 1.1 2002/07/25 14:56:48 grosbois Exp $
-///
-/// Copyright Eastman Kodak Company, 343 State Street, Rochester, NY 14650
-/// $Date $
-/// ***************************************************************************
-///
-using ICCCurveType = CSJ2K.Icc.Tags.ICCCurveType;
-namespace CSJ2K.Icc.Lut
-{
-
- /// A Gamma based 16 bit lut.
- ///
- ///
- ///
- ///
- /// 1.0
- ///
- /// Bruce A. Kern
- ///
- public class LookUpTable8Gamma : LookUpTable8
- {
-
- /* Construct the lut
- * @param curve data
- * @param dwNumInput size of lut
- * @param dwMaxOutput max value of lut
- */
- public LookUpTable8Gamma(ICCCurveType curve, int dwNumInput, byte dwMaxOutput) : base(curve, dwNumInput, dwMaxOutput)
- {
- double dfE = ICCCurveType.CurveGammaToDouble(curve.entry(0)); // Gamma exponent for inverse transformation
- for (int i = 0; i < dwNumInput; i++)
- {
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- lut[i] = (byte)System.Math.Floor(System.Math.Pow((double)i / (dwNumInput - 1), dfE) * dwMaxOutput + 0.5);
- }
- }
-
- /* end class LookUpTable8Gamma */
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/Icc/Lut/LookUpTable8Interp.cs b/CSJ2K/Icc/Lut/LookUpTable8Interp.cs
deleted file mode 100644
index 98619ad3..00000000
--- a/CSJ2K/Icc/Lut/LookUpTable8Interp.cs
+++ /dev/null
@@ -1,66 +0,0 @@
-/// **************************************************************************
-///
-/// $Id: LookUpTable8Interp.java,v 1.1 2002/07/25 14:56:48 grosbois Exp $
-///
-/// Copyright Eastman Kodak Company, 343 State Street, Rochester, NY 14650
-/// $Date $
-/// ***************************************************************************
-///
-using ICCCurveType = CSJ2K.Icc.Tags.ICCCurveType;
-namespace CSJ2K.Icc.Lut
-{
-
-
- /// An interpolated 8 bit lut
- ///
- ///
- /// 1.0
- ///
- /// Bruce A.Kern
- ///
- public class LookUpTable8Interp : LookUpTable8
- {
-
- /// Construct the lut from the curve data
- /// curve the data
- /// dwNumInput the lut size
- /// dwMaxOutput the lut max value
- public LookUpTable8Interp(ICCCurveType curve, int dwNumInput, byte dwMaxOutput) : base(curve, dwNumInput, dwMaxOutput)
- {
-
- int dwLowIndex, dwHighIndex; // Indices of interpolation points
- double dfLowIndex, dfHighIndex; // FP indices of interpolation points
- double dfTargetIndex; // Target index into interpolation table
- double dfRatio; // Ratio of LUT input points to curve values
- double dfLow, dfHigh; // Interpolation values
- double dfOut; // Output LUT value
-
- dfRatio = (double)(curve.count - 1) / (double)(dwNumInput - 1);
-
- for (int i = 0; i < dwNumInput; i++)
- {
- dfTargetIndex = (double)i * dfRatio;
- dfLowIndex = System.Math.Floor(dfTargetIndex);
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- dwLowIndex = (int)dfLowIndex;
- dfHighIndex = System.Math.Ceiling(dfTargetIndex);
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- dwHighIndex = (int)dfHighIndex;
-
- if (dwLowIndex == dwHighIndex)
- dfOut = ICCCurveType.CurveToDouble(curve.entry(dwLowIndex));
- else
- {
- dfLow = ICCCurveType.CurveToDouble(curve.entry(dwLowIndex));
- dfHigh = ICCCurveType.CurveToDouble(curve.entry(dwHighIndex));
- dfOut = dfLow + (dfHigh - dfLow) * (dfTargetIndex - dfLowIndex);
- }
-
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- lut[i] = (byte)System.Math.Floor(dfOut * dwMaxOutput + 0.5);
- }
- }
-
- /* end class LookUpTable8Interp */
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/Icc/Lut/LookUpTableFP.cs b/CSJ2K/Icc/Lut/LookUpTableFP.cs
deleted file mode 100644
index 06fba55b..00000000
--- a/CSJ2K/Icc/Lut/LookUpTableFP.cs
+++ /dev/null
@@ -1,66 +0,0 @@
-/// **************************************************************************
-///
-/// $Id: LookUpTableFP.java,v 1.1 2002/07/25 14:56:49 grosbois Exp $
-///
-/// Copyright Eastman Kodak Company, 343 State Street, Rochester, NY 14650
-/// $Date $
-/// ***************************************************************************
-///
-using ICCCurveType = CSJ2K.Icc.Tags.ICCCurveType;
-namespace CSJ2K.Icc.Lut
-{
-
- /// Toplevel class for a float [] lut.
- ///
- ///
- /// 1.0
- ///
- /// Bruce A. Kern
- ///
- public abstract class LookUpTableFP : LookUpTable
- {
-
- /// The lut values.
- //UPGRADE_NOTE: Final was removed from the declaration of 'lut '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- public float[] lut;
-
- /// Factory method for getting a lut from a given curve.
- /// the data
- ///
- /// the size of the lut
- ///
- /// the lookup table
- ///
-
- public static LookUpTableFP createInstance(ICCCurveType curve, int dwNumInput)
- {
-
- if (curve.nEntries == 1)
- return new LookUpTableFPGamma(curve, dwNumInput);
- else
- return new LookUpTableFPInterp(curve, dwNumInput);
- }
-
- /// Construct an empty lut
- /// the size of the lut t lut.
- ///
- /// max output value of the lut
- ///
- protected internal LookUpTableFP(ICCCurveType curve, int dwNumInput) : base(curve, dwNumInput)
- {
- lut = new float[dwNumInput];
- }
-
- /// lut accessor
- /// of the element
- ///
- /// the lut [index]
- ///
- public float elementAt(int index)
- {
- return lut[index];
- }
-
- /* end class LookUpTableFP */
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/Icc/Lut/LookUpTableFPGamma.cs b/CSJ2K/Icc/Lut/LookUpTableFPGamma.cs
deleted file mode 100644
index 012b034f..00000000
--- a/CSJ2K/Icc/Lut/LookUpTableFPGamma.cs
+++ /dev/null
@@ -1,55 +0,0 @@
-/// **************************************************************************
-///
-/// $Id: LookUpTableFPGamma.java,v 1.1 2002/07/25 14:56:48 grosbois Exp $
-///
-/// Copyright Eastman Kodak Company, 343 State Street, Rochester, NY 14650
-/// $Date $
-/// ***************************************************************************
-///
-using ICCCurveType = CSJ2K.Icc.Tags.ICCCurveType;
-namespace CSJ2K.Icc.Lut
-{
-
- /// Class Description
- ///
- ///
- /// 1.0
- ///
- /// Bruce A. Kern
- ///
-
- public class LookUpTableFPGamma : LookUpTableFP
- {
-
- internal double dfE = -1;
- //UPGRADE_NOTE: Final was removed from the declaration of 'eol '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- new private static readonly System.String eol = System.Environment.NewLine;
-
- public LookUpTableFPGamma(ICCCurveType curve, int dwNumInput) : base(curve, dwNumInput)
- {
-
- // Gamma exponent for inverse transformation
- dfE = ICCCurveType.CurveGammaToDouble(curve.entry(0));
- for (int i = 0; i < dwNumInput; i++)
- {
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- lut[i] = (float)System.Math.Pow((double)i / (dwNumInput - 1), dfE);
- }
- }
-
- /// Create an abbreviated string representation of a 16 bit lut.
- /// the lut as a String
- ///
- public override System.String ToString()
- {
- System.Text.StringBuilder rep = new System.Text.StringBuilder("[LookUpTableGamma ");
- //int row, col;
- rep.Append("dfe= " + dfE);
- rep.Append(", nentries= " + lut.Length);
- return rep.Append("]").ToString();
- }
-
-
- /* end class LookUpTableFPGamma */
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/Icc/Lut/LookUpTableFPInterp.cs b/CSJ2K/Icc/Lut/LookUpTableFPInterp.cs
deleted file mode 100644
index c3c7f654..00000000
--- a/CSJ2K/Icc/Lut/LookUpTableFPInterp.cs
+++ /dev/null
@@ -1,72 +0,0 @@
-/// **************************************************************************
-///
-/// $Id: LookUpTableFPInterp.java,v 1.1 2002/07/25 14:56:48 grosbois Exp $
-///
-/// Copyright Eastman Kodak Company, 343 State Street, Rochester, NY 14650
-/// $Date $
-/// ***************************************************************************
-///
-using ICCCurveType = CSJ2K.Icc.Tags.ICCCurveType;
-namespace CSJ2K.Icc.Lut
-{
-
- /// An interpolated floating point lut
- ///
- ///
- /// 1.0
- ///
- /// Bruce A.Kern
- ///
- public class LookUpTableFPInterp : LookUpTableFP
- {
-
- /// Create an abbreviated string representation of a 16 bit lut.
- /// the lut as a String
- ///
- public override System.String ToString()
- {
- System.Text.StringBuilder rep = new System.Text.StringBuilder("[LookUpTable32 ").Append(" nentries= " + lut.Length);
- return rep.Append("]").ToString();
- }
-
- /// Construct the lut from the curve data
- /// curve the data
- /// dwNumInput the lut size
- public LookUpTableFPInterp(ICCCurveType curve, int dwNumInput) : base(curve, dwNumInput)
- {
-
- int dwLowIndex, dwHighIndex; // Indices of interpolation points
- double dfLowIndex, dfHighIndex; // FP indices of interpolation points
- double dfTargetIndex; // Target index into interpolation table
- double dfRatio; // Ratio of LUT input points to curve values
- double dfLow, dfHigh; // Interpolation values
-
- dfRatio = (double)(curve.nEntries - 1) / (double)(dwNumInput - 1);
-
- for (int i = 0; i < dwNumInput; i++)
- {
- dfTargetIndex = (double)i * dfRatio;
- dfLowIndex = System.Math.Floor(dfTargetIndex);
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- dwLowIndex = (int)dfLowIndex;
- dfHighIndex = System.Math.Ceiling(dfTargetIndex);
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- dwHighIndex = (int)dfHighIndex;
- if (dwLowIndex == dwHighIndex)
- {
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- lut[i] = (float)ICCCurveType.CurveToDouble(curve.entry(dwLowIndex));
- }
- else
- {
- dfLow = ICCCurveType.CurveToDouble(curve.entry(dwLowIndex));
- dfHigh = ICCCurveType.CurveToDouble(curve.entry(dwHighIndex));
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- lut[i] = (float)(dfLow + (dfHigh - dfLow) * (dfTargetIndex - dfLowIndex));
- }
- }
- }
-
- /* end class LookUpTableFPInterp */
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/Icc/Lut/MatrixBasedTransformException.cs b/CSJ2K/Icc/Lut/MatrixBasedTransformException.cs
deleted file mode 100644
index fd86fc4b..00000000
--- a/CSJ2K/Icc/Lut/MatrixBasedTransformException.cs
+++ /dev/null
@@ -1,42 +0,0 @@
-/// **************************************************************************
-///
-/// $Id: MatrixBasedTransformException.java,v 1.1 2002/07/25 14:56:49 grosbois Exp $
-///
-/// Copyright Eastman Kodak Company, 343 State Street, Rochester, NY 14650
-/// $Date $
-/// ***************************************************************************
-///
-using System;
-namespace CSJ2K.Icc.Lut
-{
-
- /// Thrown by MatrixBasedTransformTosRGB
- ///
- ///
- ///
- ///
- /// 1.0
- ///
- /// Bruce A. Kern
- ///
-
- [Serializable]
- public class MatrixBasedTransformException : System.Exception
- {
-
- /// Contruct with message
- /// returned by getMessage()
- ///
- internal MatrixBasedTransformException(System.String msg) : base(msg)
- {
- }
-
-
- /// Empty constructor
- internal MatrixBasedTransformException()
- {
- }
-
- /* end class MatrixBasedTransformException */
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/Icc/Lut/MatrixBasedTransformTosRGB.cs b/CSJ2K/Icc/Lut/MatrixBasedTransformTosRGB.cs
deleted file mode 100644
index d3c78704..00000000
--- a/CSJ2K/Icc/Lut/MatrixBasedTransformTosRGB.cs
+++ /dev/null
@@ -1,472 +0,0 @@
-/// **************************************************************************
-///
-/// $Id: MatrixBasedTransformTosRGB.java,v 1.1 2002/07/25 14:56:49 grosbois Exp $
-///
-/// Copyright Eastman Kodak Company, 343 State Street, Rochester, NY 14650
-/// $Date $
-/// ***************************************************************************
-///
-using ColorSpace = CSJ2K.Color.ColorSpace;
-using DataBlkFloat = CSJ2K.j2k.image.DataBlkFloat;
-using DataBlkInt = CSJ2K.j2k.image.DataBlkInt;
-using ICCXYZType = CSJ2K.Icc.Tags.ICCXYZType;
-namespace CSJ2K.Icc.Lut
-{
-
- /// Transform for applying ICCProfiling to an input DataBlk
- ///
- ///
- ///
- ///
- ///
- ///
- /// 1.0
- ///
- /// Bruce A. Kern
- ///
- public class MatrixBasedTransformTosRGB
- {
-
- //UPGRADE_NOTE: Final was removed from the declaration of 'eol '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- private static readonly System.String eol = System.Environment.NewLine;
-
- // Start of contant definitions:
-
- //UPGRADE_NOTE: Final was removed from the declaration of 'RED '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- //UPGRADE_NOTE: The initialization of 'RED' was moved to static method 'icc.lut.MatrixBasedTransformTosRGB'. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1005'"
- //UPGRADE_NOTE: Final was removed from the declaration of 'GREEN '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- //UPGRADE_NOTE: The initialization of 'GREEN' was moved to static method 'icc.lut.MatrixBasedTransformTosRGB'. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1005'"
- //UPGRADE_NOTE: Final was removed from the declaration of 'BLUE '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- //UPGRADE_NOTE: The initialization of 'BLUE' was moved to static method 'icc.lut.MatrixBasedTransformTosRGB'. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1005'"
- private static readonly int RED;
- private static readonly int GREEN;
- private static readonly int BLUE;
-
- private const double SRGB00 = 3.1337;
- private const double SRGB01 = -1.6173;
- private const double SRGB02 = -0.4907;
- private const double SRGB10 = -0.9785;
- private const double SRGB11 = 1.9162;
- private const double SRGB12 = 0.0334;
- private const double SRGB20 = 0.0720;
- private const double SRGB21 = -0.2290;
- private const double SRGB22 = 1.4056;
-
- // Define constants representing the indices into the matrix array
- private const int M00 = 0;
- private const int M01 = 1;
- private const int M02 = 2;
- private const int M10 = 3;
- private const int M11 = 4;
- private const int M12 = 5;
- private const int M20 = 6;
- private const int M21 = 7;
- private const int M22 = 8;
-
- private const double ksRGBExponent = (1.0 / 2.4);
- private const double ksRGBScaleAfterExp = 1.055;
- private const double ksRGBReduceAfterExp = 0.055;
- private const double ksRGBShadowCutoff = 0.0031308;
- private const double ksRGBShadowSlope = 12.92;
-
- // End of contant definitions:
-
- //UPGRADE_NOTE: Final was removed from the declaration of 'matrix '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- private double[] matrix; // Matrix coefficients
-
- private LookUpTableFP[] fLut = new LookUpTableFP[3];
- private LookUpTable32LinearSRGBtoSRGB lut; // Linear sRGB to sRGB LUT
-
- //UPGRADE_NOTE: Final was removed from the declaration of 'dwMaxValue '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- private int[] dwMaxValue;
- //UPGRADE_NOTE: Final was removed from the declaration of 'dwShiftValue '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- private int[] dwShiftValue;
-
- //private int dwMaxCols = 0; // Maximum number of columns that can be processed
- //private int dwMaxRows = 0; // Maximum number of rows that can be processed
-
- private float[][] fBuf = null; // Intermediate output of the first LUT operation.
-
- /// String representation of class
- /// suitable representation for class
- ///
- public override System.String ToString()
- {
- int i, j;
-
- System.Text.StringBuilder rep = new System.Text.StringBuilder("[MatrixBasedTransformTosRGB: ");
-
- System.Text.StringBuilder body = new System.Text.StringBuilder(" ");
- body.Append(eol).Append("ksRGBExponent= ").Append(System.Convert.ToString(ksRGBExponent));
- body.Append(eol).Append("ksRGBScaleAfterExp= ").Append(System.Convert.ToString(ksRGBScaleAfterExp));
- body.Append(eol).Append("ksRGBReduceAfterExp= ").Append(System.Convert.ToString(ksRGBReduceAfterExp));
-
-
- body.Append(eol).Append("dwMaxValues= ").Append(System.Convert.ToString(dwMaxValue[0])).Append(", ").Append(System.Convert.ToString(dwMaxValue[1])).Append(", ").Append(System.Convert.ToString(dwMaxValue[2]));
-
- body.Append(eol).Append("dwShiftValues= ").Append(System.Convert.ToString(dwShiftValue[0])).Append(", ").Append(System.Convert.ToString(dwShiftValue[1])).Append(", ").Append(System.Convert.ToString(dwShiftValue[2]));
-
- //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Object.toString' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'"
- body.Append(eol).Append(eol).Append("fLut= ").Append(eol).Append(ColorSpace.indent(" ", "fLut[RED]= " + fLut[0].ToString())).Append(eol).Append(ColorSpace.indent(" ", "fLut[GRN]= " + fLut[1].ToString())).Append(eol).Append(ColorSpace.indent(" ", "fLut[BLU]= " + fLut[2].ToString()));
-
- // Print the matrix
- body.Append(eol).Append(eol).Append("[matrix ");
- for (i = 0; i < 3; ++i)
- {
- body.Append(eol).Append(" ");
- for (j = 0; j < 3; ++j)
- {
- body.Append(matrix[3 * i + j] + " ");
- }
- }
- body.Append("]");
-
-
- // Print the LinearSRGBtoSRGB lut.
- body.Append(eol).Append(eol).Append(lut.ToString());
-
- rep.Append(ColorSpace.indent(" ", body)).Append("]");
- return rep.Append("]").ToString();
- }
-
-
- /// Construct a 3 component transform based on an input RestricedICCProfile
- /// This transform will pass the input throught a floating point lut (LookUpTableFP),
- /// apply a matrix to the output and finally pass the intermediate buffer through
- /// a 8-bit lut (LookUpTable8). This operation will be designated (LFP*M*L8) * Data
- /// The operators (LFP*M*L8) are constructed here. Although the data for
- /// only one component is returned, the transformation must be done for all
- /// components, because the matrix application involves a linear combination of
- /// component input to produce the output.
- ///
- /// input profile
- ///
- /// clipping value for output.
- ///
- /// number of columns to transform
- ///
- /// number of rows to transform
- ///
- public MatrixBasedTransformTosRGB(RestrictedICCProfile ricc, int[] dwMaxValue, int[] dwShiftValue)
- {
-
- // Assure the proper type profile for this xform.
- if (ricc.Type != RestrictedICCProfile.kThreeCompInput)
- throw new System.ArgumentException("MatrixBasedTransformTosRGB: wrong type ICCProfile supplied");
-
- int c; // component index.
- this.dwMaxValue = dwMaxValue;
- this.dwShiftValue = dwShiftValue;
-
- // Create the LUTFP from the input profile.
- for (c = 0; c < 3; ++c)
- {
- fLut[c] = LookUpTableFP.createInstance(ricc.trc[c], dwMaxValue[c] + 1);
- }
-
- // Create the Input linear to PCS matrix
- matrix = createMatrix(ricc, dwMaxValue); // Create and matrix from the ICC profile.
-
- // Create the final LUT32
- lut = LookUpTable32LinearSRGBtoSRGB.createInstance(dwMaxValue[0], dwMaxValue[0], ksRGBShadowCutoff, ksRGBShadowSlope, ksRGBScaleAfterExp, ksRGBExponent, ksRGBReduceAfterExp);
- }
-
-
- private double[] createMatrix(RestrictedICCProfile ricc, int[] maxValues)
- {
-
- // Coefficients from the input linear to PCS matrix
- double dfPCS00 = ICCXYZType.XYZToDouble(ricc.colorant[RED].x);
- double dfPCS01 = ICCXYZType.XYZToDouble(ricc.colorant[GREEN].x);
- double dfPCS02 = ICCXYZType.XYZToDouble(ricc.colorant[BLUE].x);
- double dfPCS10 = ICCXYZType.XYZToDouble(ricc.colorant[RED].y);
- double dfPCS11 = ICCXYZType.XYZToDouble(ricc.colorant[GREEN].y);
- double dfPCS12 = ICCXYZType.XYZToDouble(ricc.colorant[BLUE].y);
- double dfPCS20 = ICCXYZType.XYZToDouble(ricc.colorant[RED].z);
- double dfPCS21 = ICCXYZType.XYZToDouble(ricc.colorant[GREEN].z);
- double dfPCS22 = ICCXYZType.XYZToDouble(ricc.colorant[BLUE].z);
-
- double[] matrix = new double[9];
- matrix[M00] = maxValues[0] * (SRGB00 * dfPCS00 + SRGB01 * dfPCS10 + SRGB02 * dfPCS20);
- matrix[M01] = maxValues[0] * (SRGB00 * dfPCS01 + SRGB01 * dfPCS11 + SRGB02 * dfPCS21);
- matrix[M02] = maxValues[0] * (SRGB00 * dfPCS02 + SRGB01 * dfPCS12 + SRGB02 * dfPCS22);
- matrix[M10] = maxValues[1] * (SRGB10 * dfPCS00 + SRGB11 * dfPCS10 + SRGB12 * dfPCS20);
- matrix[M11] = maxValues[1] * (SRGB10 * dfPCS01 + SRGB11 * dfPCS11 + SRGB12 * dfPCS21);
- matrix[M12] = maxValues[1] * (SRGB10 * dfPCS02 + SRGB11 * dfPCS12 + SRGB12 * dfPCS22);
- matrix[M20] = maxValues[2] * (SRGB20 * dfPCS00 + SRGB21 * dfPCS10 + SRGB22 * dfPCS20);
- matrix[M21] = maxValues[2] * (SRGB20 * dfPCS01 + SRGB21 * dfPCS11 + SRGB22 * dfPCS21);
- matrix[M22] = maxValues[2] * (SRGB20 * dfPCS02 + SRGB21 * dfPCS12 + SRGB22 * dfPCS22);
-
- return matrix;
- }
-
-
- /// Performs the transform. Pass the input throught the LookUpTableFP, apply the
- /// matrix to the output and finally pass the intermediate buffer through the
- /// LookUpTable8. This operation is designated (LFP*M*L8) * Data are already
- /// constructed. Although the data for only one component is returned, the
- /// transformation must be done for all components, because the matrix application
- /// involves a linear combination of component input to produce the output.
- ///
- /// number of columns in the input
- ///
- /// number of rows in the input
- ///
- /// input data block
- ///
- /// output data block
- ///
- ///
- ///
- public virtual void apply(DataBlkInt[] inb, DataBlkInt[] outb)
- {
- int[][] in_Renamed = new int[3][], out_Renamed = new int[3][]; // data references.
-
- int nrows = inb[0].h, ncols = inb[0].w;
-
- if ((fBuf == null) || (fBuf[0].Length < ncols * nrows))
- {
- float[][] tmpArray = new float[3][];
- for (int i = 0; i < 3; i++)
- {
- tmpArray[i] = new float[ncols * nrows];
- }
- fBuf = tmpArray;
- }
-
- // for each component (rgb)
- for (int c = 0; c < 3; ++c)
- {
-
- // Reference the input and output samples.
- in_Renamed[c] = (int[])inb[c].Data;
- out_Renamed[c] = (int[])outb[c].Data;
-
- // Assure a properly sized output buffer.
- if (out_Renamed[c] == null || out_Renamed[c].Length < in_Renamed[c].Length)
- {
- out_Renamed[c] = new int[in_Renamed[c].Length];
- outb[c].Data = out_Renamed[c];
- }
-
- // The first thing to do is to process the input into a standard form
- // and through the first input LUT, producing floating point output values
- standardizeMatrixLineThroughLut(inb[c], fBuf[c], dwMaxValue[c], fLut[c]);
- }
-
- // For each row and column
- float[] ra = fBuf[RED];
- float[] ga = fBuf[GREEN];
- float[] ba = fBuf[BLUE];
-
- int[] ro = out_Renamed[RED];
- int[] go = out_Renamed[GREEN];
- int[] bo = out_Renamed[BLUE];
- int[] lut32 = lut.lut;
-
- double r, g, b;
- int val, index = 0;
- for (int y = 0; y < inb[0].h; ++y)
- {
- int end = index + inb[0].w;
- while (index < end)
- {
- // Calculate the rgb pixel indices for this row / column
- r = ra[index];
- g = ga[index];
- b = ba[index];
-
- // Apply the matrix to the intermediate floating point data in order to index the
- // final LUT.
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- val = (int)(matrix[M00] * r + matrix[M01] * g + matrix[M02] * b + 0.5);
- // Clip the calculated value if necessary..
- if (val < 0)
- ro[index] = lut32[0];
- else if (val >= lut32.Length)
- ro[index] = lut32[lut32.Length - 1];
- else
- ro[index] = lut32[val];
-
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- val = (int)(matrix[M10] * r + matrix[M11] * g + matrix[M12] * b + 0.5);
- // Clip the calculated value if necessary..
- if (val < 0)
- go[index] = lut32[0];
- else if (val >= lut32.Length)
- go[index] = lut32[lut32.Length - 1];
- else
- go[index] = lut32[val];
-
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- val = (int)(matrix[M20] * r + matrix[M21] * g + matrix[M22] * b + 0.5);
- // Clip the calculated value if necessary..
- if (val < 0)
- bo[index] = lut32[0];
- else if (val >= lut32.Length)
- bo[index] = lut32[lut32.Length - 1];
- else
- bo[index] = lut32[val];
-
- index++;
- }
- }
- }
-
- /// Performs the transform. Pass the input throught the LookUpTableFP, apply the
- /// matrix to the output and finally pass the intermediate buffer through the
- /// LookUpTable8. This operation is designated (LFP*M*L8) * Data are already
- /// constructed. Although the data for only one component is returned, the
- /// transformation must be done for all components, because the matrix application
- /// involves a linear combination of component input to produce the output.
- ///
- /// number of columns in the input
- ///
- /// number of rows in the input
- ///
- /// input data block
- ///
- /// output data block
- ///
- ///
- ///
- public virtual void apply(DataBlkFloat[] inb, DataBlkFloat[] outb)
- {
-
- float[][] in_Renamed = new float[3][], out_Renamed = new float[3][]; // data references.
-
- int nrows = inb[0].h, ncols = inb[0].w;
-
- if ((fBuf == null) || (fBuf[0].Length < ncols * nrows))
- {
- float[][] tmpArray = new float[3][];
- for (int i = 0; i < 3; i++)
- {
- tmpArray[i] = new float[ncols * nrows];
- }
- fBuf = tmpArray;
- }
-
- // for each component (rgb)
- for (int c = 0; c < 3; ++c)
- {
-
- // Reference the input and output pixels.
- in_Renamed[c] = (float[])inb[c].Data;
- out_Renamed[c] = (float[])outb[c].Data;
-
- // Assure a properly sized output buffer.
- if (out_Renamed[c] == null || out_Renamed[c].Length < in_Renamed[c].Length)
- {
- out_Renamed[c] = new float[in_Renamed[c].Length];
- outb[c].Data = out_Renamed[c];
- }
-
- // The first thing to do is to process the input into a standard form
- // and through the first input LUT, producing floating point output values
- standardizeMatrixLineThroughLut(inb[c], fBuf[c], dwMaxValue[c], fLut[c]);
- }
-
- int[] lut32 = lut.lut;
-
- // For each row and column
- int index = 0, val;
- for (int y = 0; y < inb[0].h; ++y)
- {
- int end = index + inb[0].w;
- while (index < end)
- {
- // Calculate the rgb pixel indices for this row / column
-
- // Apply the matrix to the intermediate floating point data inorder to index the
- // final LUT.
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- val = (int)(matrix[M00] * fBuf[RED][index] + matrix[M01] * fBuf[GREEN][index] + matrix[M02] * fBuf[BLUE][index] + 0.5);
- // Clip the calculated value if necessary..
- if (val < 0)
- out_Renamed[0][index] = lut32[0];
- else if (val >= lut32.Length)
- out_Renamed[0][index] = lut32[lut32.Length - 1];
- else
- out_Renamed[0][index] = lut32[val];
-
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- val = (int)(matrix[M10] * fBuf[RED][index] + matrix[M11] * fBuf[GREEN][index] + matrix[M12] * fBuf[BLUE][index] + 0.5);
- // Clip the calculated value if necessary..
- if (val < 0)
- out_Renamed[1][index] = lut32[0];
- else if (val >= lut32.Length)
- out_Renamed[1][index] = lut32[lut32.Length - 1];
- else
- out_Renamed[1][index] = lut32[val];
-
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- val = (int)(matrix[M20] * fBuf[RED][index] + matrix[M21] * fBuf[GREEN][index] + matrix[M22] * fBuf[BLUE][index] + 0.5);
- // Clip the calculated value if necessary..
- if (val < 0)
- out_Renamed[2][index] = lut32[0];
- else if (val >= lut32.Length)
- out_Renamed[2][index] = lut32[lut32.Length - 1];
- else
- out_Renamed[2][index] = lut32[val];
-
- index++;
- }
- }
- }
-
- private static void standardizeMatrixLineThroughLut(DataBlkInt inb, float[] out_Renamed, int dwInputMaxValue, LookUpTableFP lut)
- {
- int wTemp, j = 0;
- int[] in_Renamed = (int[])inb.Data; // input pixel reference
- float[] lutFP = lut.lut;
- for (int y = inb.uly; y < inb.uly + inb.h; ++y)
- {
- for (int x = inb.ulx; x < inb.ulx + inb.w; ++x)
- {
- int i = inb.offset + (y - inb.uly) * inb.scanw + (x - inb.ulx); // pixel index.
- if (in_Renamed[i] > dwInputMaxValue)
- wTemp = dwInputMaxValue;
- else if (in_Renamed[i] < 0)
- wTemp = 0;
- else
- wTemp = in_Renamed[i];
- out_Renamed[j++] = lutFP[wTemp];
- }
- }
- }
-
-
- private static void standardizeMatrixLineThroughLut(DataBlkFloat inb, float[] out_Renamed, float dwInputMaxValue, LookUpTableFP lut)
- {
- int j = 0;
- float wTemp;
- float[] in_Renamed = (float[])inb.Data; // input pixel reference
- float[] lutFP = lut.lut;
-
- for (int y = inb.uly; y < inb.uly + inb.h; ++y)
- {
- for (int x = inb.ulx; x < inb.ulx + inb.w; ++x)
- {
- int i = inb.offset + (y - inb.uly) * inb.scanw + (x - inb.ulx); // pixel index.
- if (in_Renamed[i] > dwInputMaxValue)
- wTemp = dwInputMaxValue;
- else if (in_Renamed[i] < 0)
- wTemp = 0;
- else
- wTemp = in_Renamed[i];
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- out_Renamed[j++] = lutFP[(int)wTemp];
- }
- }
- }
-
- /* end class MatrixBasedTransformTosRGB */
- static MatrixBasedTransformTosRGB()
- {
- RED = ICCProfile.RED;
- GREEN = ICCProfile.GREEN;
- BLUE = ICCProfile.BLUE;
- }
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/Icc/Lut/MonochromeTransformException.cs b/CSJ2K/Icc/Lut/MonochromeTransformException.cs
deleted file mode 100644
index 87493283..00000000
--- a/CSJ2K/Icc/Lut/MonochromeTransformException.cs
+++ /dev/null
@@ -1,41 +0,0 @@
-/// **************************************************************************
-///
-/// $Id: MonochromeTransformException.java,v 1.1 2002/07/25 14:56:49 grosbois Exp $
-///
-/// Copyright Eastman Kodak Company, 343 State Street, Rochester, NY 14650
-/// $Date $
-/// ***************************************************************************
-///
-using System;
-namespace CSJ2K.Icc.Lut
-{
-
- /// Exception thrown by MonochromeTransformTosRGB.
- ///
- ///
- ///
- ///
- /// 1.0
- ///
- /// Bruce A. Kern
- ///
-
- [Serializable]
- public class MonochromeTransformException : System.Exception
- {
-
- /// Contruct with message
- /// returned by getMessage()
- ///
- internal MonochromeTransformException(System.String msg) : base(msg)
- {
- }
-
- /// Empty constructor
- internal MonochromeTransformException()
- {
- }
-
- /* end class MonochromeTransformException */
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/Icc/Lut/MonochromeTransformTosRGB.cs b/CSJ2K/Icc/Lut/MonochromeTransformTosRGB.cs
deleted file mode 100644
index 5e3f16fa..00000000
--- a/CSJ2K/Icc/Lut/MonochromeTransformTosRGB.cs
+++ /dev/null
@@ -1,210 +0,0 @@
-/// **************************************************************************
-///
-/// $Id: MonochromeTransformTosRGB.java,v 1.1 2002/07/25 14:56:50 grosbois Exp $
-///
-/// Copyright Eastman Kodak Company, 343 State Street, Rochester, NY 14650
-/// $Date $
-/// ***************************************************************************
-///
-using ColorSpace = CSJ2K.Color.ColorSpace;
-using DataBlkFloat = CSJ2K.j2k.image.DataBlkFloat;
-using DataBlkInt = CSJ2K.j2k.image.DataBlkInt;
-namespace CSJ2K.Icc.Lut
-{
-
- ///
- /// This class constructs a LookUpTableFP from a RestrictedICCProfile.
- /// The values in this table are used to calculate a second lookup table (simply a short []).
- /// table. When this transform is applied to an input DataBlk, an output data block is
- /// constructed by using the input samples as indices into the lookup table, whose values
- /// are used to populate the output DataBlk.
- ///
- ///
- ///
- ///
- ///
- ///
- /// 1.0
- ///
- /// Bruce A. Kern
- ///
-
- public class MonochromeTransformTosRGB
- {
-
- //UPGRADE_NOTE: Final was removed from the declaration of 'eol '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- private static readonly System.String eol = System.Environment.NewLine;
-
- /// Transform parameter.
- public const double ksRGBShadowCutoff = 0.0031308;
- /// Transform parameter.
- public const double ksRGBShadowSlope = 12.92;
- /// Transform parameter.
- //UPGRADE_NOTE: Final was removed from the declaration of 'ksRGB8ShadowSlope '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- public static readonly double ksRGB8ShadowSlope = (255 * ksRGBShadowSlope);
- /// Transform parameter.
- public const double ksRGBExponent = (1.0 / 2.4);
- /// Transform parameter.
- public const double ksRGB8ScaleAfterExp = 269.025;
- /// Transform parameter.
- public const double ksRGB8ReduceAfterExp = 14.025;
-
- private short[] lut = null;
- private int dwInputMaxValue = 0;
- private LookUpTableFP fLut = null;
-
-
- /// String representation of class
- /// suitable representation for class
- ///
- public override System.String ToString()
- {
- System.Text.StringBuilder rep = new System.Text.StringBuilder("[MonochromeTransformTosRGB ");
- System.Text.StringBuilder body = new System.Text.StringBuilder(" ");
-
- // Print the parameters:
- body.Append(eol).Append("ksRGBShadowSlope= ").Append(System.Convert.ToString(ksRGBShadowSlope));
- body.Append(eol).Append("ksRGBShadowCutoff= ").Append(System.Convert.ToString(ksRGBShadowCutoff));
- body.Append(eol).Append("ksRGBShadowSlope= ").Append(System.Convert.ToString(ksRGBShadowSlope));
- body.Append(eol).Append("ksRGB8ShadowSlope= ").Append(System.Convert.ToString(ksRGB8ShadowSlope));
- body.Append(eol).Append("ksRGBExponent= ").Append(System.Convert.ToString(ksRGBExponent));
- body.Append(eol).Append("ksRGB8ScaleAfterExp= ").Append(System.Convert.ToString(ksRGB8ScaleAfterExp));
- body.Append(eol).Append("ksRGB8ReduceAfterExp= ").Append(System.Convert.ToString((ksRGB8ReduceAfterExp)));
- body.Append(eol).Append("dwInputMaxValue= ").Append(System.Convert.ToString(dwInputMaxValue));
-
- // Print the LinearSRGBtoSRGB lut.
- body.Append(eol).Append("[lut = [short[" + lut.Length + "]]]");
-
- // Print the FP luts.
- //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Object.toString' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'"
- body.Append(eol).Append("fLut= " + fLut.ToString());
-
- rep.Append(ColorSpace.indent(" ", body));
- return rep.Append("]").ToString();
- }
-
- /// Construct the lut from the RestrictedICCProfile.
- ///
- ///
- /// input RestrictedICCProfile
- ///
- /// size of the output lut.
- ///
- /// value used to shift samples to positive
- ///
- public MonochromeTransformTosRGB(RestrictedICCProfile ricc, int dwInputMaxValue, int dwInputShiftValue)
- {
-
- if (ricc.Type != RestrictedICCProfile.kMonochromeInput)
- throw new System.ArgumentException("MonochromeTransformTosRGB: wrong type ICCProfile supplied");
-
- this.dwInputMaxValue = dwInputMaxValue;
- lut = new short[dwInputMaxValue + 1];
- fLut = LookUpTableFP.createInstance(ricc.trc[ICCProfile.GRAY], dwInputMaxValue + 1);
-
- // First calculate the value for the shadow region
- int i;
- for (i = 0; ((i <= dwInputMaxValue) && (fLut.lut[i] <= ksRGBShadowCutoff)); i++)
- {
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- lut[i] = (short)(System.Math.Floor(ksRGB8ShadowSlope * (double)fLut.lut[i] + 0.5) - dwInputShiftValue);
- }
-
- // Now calculate the rest
- for (; i <= dwInputMaxValue; i++)
- {
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- lut[i] = (short)(System.Math.Floor(ksRGB8ScaleAfterExp * System.Math.Pow((double)fLut.lut[i], ksRGBExponent) - ksRGB8ReduceAfterExp + 0.5) - dwInputShiftValue);
- }
- }
-
- /// Populate the output block by looking up the values in the lut, using the input
- /// as lut indices.
- ///
- /// input samples
- ///
- /// output samples.
- ///
- ///
- ///
- public virtual void apply(DataBlkInt inb, DataBlkInt outb)
- {
-
- int i, j, o; // x, y removed
-
- int[] in_Renamed = (int[])inb.Data;
- int[] out_Renamed = (int[])outb.Data;
-
- if (out_Renamed == null || out_Renamed.Length < in_Renamed.Length)
- {
- out_Renamed = new int[in_Renamed.Length];
- outb.Data = out_Renamed;
- }
-
- outb.uly = inb.uly;
- outb.ulx = inb.ulx;
- outb.h = inb.h;
- outb.w = inb.w;
- outb.offset = inb.offset;
- outb.scanw = inb.scanw;
-
- o = inb.offset;
- for (i = 0; i < inb.h * inb.w; ++i)
- {
- j = in_Renamed[i];
- if (j < 0)
- j = 0;
- else if (j > dwInputMaxValue)
- j = dwInputMaxValue;
- out_Renamed[i] = lut[j];
- }
- }
-
- /// Populate the output block by looking up the values in the lut, using the input
- /// as lut indices.
- ///
- /// input samples
- ///
- /// output samples.
- ///
- ///
- ///
- public virtual void apply(DataBlkFloat inb, DataBlkFloat outb)
- {
-
- int i, j, o; // x, y removed
-
- float[] in_Renamed = (float[])inb.Data;
- float[] out_Renamed = (float[])outb.Data;
-
-
- if (out_Renamed == null || out_Renamed.Length < in_Renamed.Length)
- {
- out_Renamed = new float[in_Renamed.Length];
- outb.Data = out_Renamed;
-
- outb.uly = inb.uly;
- outb.ulx = inb.ulx;
- outb.h = inb.h;
- outb.w = inb.w;
- outb.offset = inb.offset;
- outb.scanw = inb.scanw;
- }
-
- o = inb.offset;
- for (i = 0; i < inb.h * inb.w; ++i)
- {
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- j = (int)in_Renamed[i];
- if (j < 0)
- j = 0;
- else if (j > dwInputMaxValue)
- j = dwInputMaxValue;
- out_Renamed[i] = lut[j];
- }
- }
-
-
- /* end class MonochromeTransformTosRGB */
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/Icc/MatrixBasedRestrictedProfile.cs b/CSJ2K/Icc/MatrixBasedRestrictedProfile.cs
deleted file mode 100644
index 8b16bdc7..00000000
--- a/CSJ2K/Icc/MatrixBasedRestrictedProfile.cs
+++ /dev/null
@@ -1,91 +0,0 @@
-/// **************************************************************************
-///
-/// $Id: MatrixBasedRestrictedProfile.java,v 1.1 2002/07/25 14:56:56 grosbois Exp $
-///
-/// Copyright Eastman Kodak Company, 343 State Street, Rochester, NY 14650
-/// $Date $
-/// ***************************************************************************
-///
-using ICCCurveType = CSJ2K.Icc.Tags.ICCCurveType;
-using ICCXYZType = CSJ2K.Icc.Tags.ICCXYZType;
-namespace CSJ2K.Icc
-{
-
- /// This class is a 3 component RestrictedICCProfile
- ///
- ///
- /// 1.0
- ///
- /// Bruce A Kern
- ///
- public class MatrixBasedRestrictedProfile : RestrictedICCProfile
- {
- /// Get the type of RestrictedICCProfile for this object
- /// kThreeCompInput
- ///
- override public int Type
- {
- get
- {
- return kThreeCompInput;
- }
-
- }
-
- /// Factory method which returns a 3 component RestrictedICCProfile
- /// Red TRC curve
- ///
- /// Green TRC curve
- ///
- /// Blue TRC curve
- ///
- /// Red colorant
- ///
- /// Green colorant
- ///
- /// Blue colorant
- ///
- /// the RestrictedICCProfile
- ///
- public static new RestrictedICCProfile createInstance(ICCCurveType rcurve, ICCCurveType gcurve, ICCCurveType bcurve, ICCXYZType rcolorant, ICCXYZType gcolorant, ICCXYZType bcolorant)
- {
- return new MatrixBasedRestrictedProfile(rcurve, gcurve, bcurve, rcolorant, gcolorant, bcolorant);
- }
-
- /// Construct a 3 component RestrictedICCProfile
- /// Red TRC curve
- ///
- /// Green TRC curve
- ///
- /// Blue TRC curve
- ///
- /// Red colorant
- ///
- /// Green colorant
- ///
- /// Blue colorant
- ///
- protected internal MatrixBasedRestrictedProfile(ICCCurveType rcurve, ICCCurveType gcurve, ICCCurveType bcurve, ICCXYZType rcolorant, ICCXYZType gcolorant, ICCXYZType bcolorant) : base(rcurve, gcurve, bcurve, rcolorant, gcolorant, bcolorant)
- {
- }
-
- /// String representation of a MatrixBasedRestrictedProfile
- ///
- public override System.String ToString()
- {
- System.Text.StringBuilder rep = new System.Text.StringBuilder("[Matrix-Based Input Restricted ICC profile").Append(eol);
-
- rep.Append("trc[RED]:").Append(eol).Append(trc[RED]).Append(eol);
- rep.Append("trc[RED]:").Append(eol).Append(trc[GREEN]).Append(eol);
- rep.Append("trc[RED]:").Append(eol).Append(trc[BLUE]).Append(eol);
-
- rep.Append("Red colorant: ").Append(colorant[RED]).Append(eol);
- rep.Append("Red colorant: ").Append(colorant[GREEN]).Append(eol);
- rep.Append("Red colorant: ").Append(colorant[BLUE]).Append(eol);
-
- return rep.Append("]").ToString();
- }
-
- /* end class MatrixBasedRestrictedProfile */
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/Icc/MonochromeInputRestrictedProfile.cs b/CSJ2K/Icc/MonochromeInputRestrictedProfile.cs
deleted file mode 100644
index fd071e29..00000000
--- a/CSJ2K/Icc/MonochromeInputRestrictedProfile.cs
+++ /dev/null
@@ -1,64 +0,0 @@
-/// **************************************************************************
-///
-/// $Id: MonochromeInputRestrictedProfile.java,v 1.1 2002/07/25 14:56:56 grosbois Exp $
-///
-/// Copyright Eastman Kodak Company, 343 State Street, Rochester, NY 14650
-/// $Date $
-/// ***************************************************************************
-///
-using ICCCurveType = CSJ2K.Icc.Tags.ICCCurveType;
-namespace CSJ2K.Icc
-{
-
- /// This class is a 1 component RestrictedICCProfile
- ///
- ///
- /// 1.0
- ///
- /// Bruce A Kern
- ///
- public class MonochromeInputRestrictedProfile : RestrictedICCProfile
- {
- /// Get the type of RestrictedICCProfile for this object
- /// kMonochromeInput
- ///
- override public int Type
- {
- get
- {
- return kMonochromeInput;
- }
-
- }
-
- /// Factory method which returns a 1 component RestrictedICCProfile
- /// Gray TRC curve
- ///
- /// the RestrictedICCProfile
- ///
- public static new RestrictedICCProfile createInstance(ICCCurveType c)
- {
- return new MonochromeInputRestrictedProfile(c);
- }
-
- /// Construct a 1 component RestrictedICCProfile
- /// Gray TRC curve
- ///
- private MonochromeInputRestrictedProfile(ICCCurveType c) : base(c)
- {
- }
-
- /// String representation of a MonochromeInputRestrictedProfile
- ///
- public override System.String ToString()
- {
- System.Text.StringBuilder rep = new System.Text.StringBuilder("Monochrome Input Restricted ICC profile" + eol);
-
- rep.Append("trc[GRAY]:" + eol).Append(trc[GRAY]).Append(eol);
-
- return rep.ToString();
- }
-
- /* end class MonochromeInputRestrictedProfile */
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/Icc/RestrictedICCProfile.cs b/CSJ2K/Icc/RestrictedICCProfile.cs
deleted file mode 100644
index d5c20193..00000000
--- a/CSJ2K/Icc/RestrictedICCProfile.cs
+++ /dev/null
@@ -1,141 +0,0 @@
-/// **************************************************************************
-///
-/// $Id: RestrictedICCProfile.java,v 1.1 2002/07/25 14:56:56 grosbois Exp $
-///
-/// Copyright Eastman Kodak Company, 343 State Street, Rochester, NY 14650
-/// $Date $
-/// ***************************************************************************
-///
-using ICCCurveType = CSJ2K.Icc.Tags.ICCCurveType;
-using ICCXYZType = CSJ2K.Icc.Tags.ICCXYZType;
-namespace CSJ2K.Icc
-{
-
- /// This profile is constructed by parsing an ICCProfile and
- /// is the profile actually applied to the image.
- ///
- ///
- ///
- ///
- /// 1.0
- ///
- /// Bruce A. Kern
- ///
- public abstract class RestrictedICCProfile
- {
- /// Returns the appropriate input type enum.
- public abstract int Type { get; }
-
- //UPGRADE_NOTE: Final was removed from the declaration of 'eol '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- protected internal static readonly System.String eol = System.Environment.NewLine;
-
- /// Factory method for creating a RestrictedICCProfile from
- /// 3 component curve and colorant data.
- ///
- /// red curve
- ///
- /// green curve
- ///
- /// blue curve
- ///
- /// red colorant
- ///
- /// green colorant
- ///
- /// blue colorant
- ///
- /// MatrixBasedRestrictedProfile
- ///
- public static RestrictedICCProfile createInstance(ICCCurveType rcurve, ICCCurveType gcurve, ICCCurveType bcurve, ICCXYZType rcolorant, ICCXYZType gcolorant, ICCXYZType bcolorant)
- {
-
- return MatrixBasedRestrictedProfile.createInstance(rcurve, gcurve, bcurve, rcolorant, gcolorant, bcolorant);
- }
-
- /// Factory method for creating a RestrictedICCProfile from
- /// gray curve data.
- ///
- /// gray curve
- ///
- /// MonochromeInputRestrictedProfile
- ///
- public static RestrictedICCProfile createInstance(ICCCurveType gcurve)
- {
- return MonochromeInputRestrictedProfile.createInstance(gcurve);
- }
-
- /// Component index
- //UPGRADE_NOTE: Final was removed from the declaration of 'GRAY '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- //UPGRADE_NOTE: The initialization of 'GRAY' was moved to static method 'icc.RestrictedICCProfile'. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1005'"
- protected internal static readonly int GRAY;
- /// Component index
- //UPGRADE_NOTE: Final was removed from the declaration of 'RED '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- //UPGRADE_NOTE: The initialization of 'RED' was moved to static method 'icc.RestrictedICCProfile'. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1005'"
- protected internal static readonly int RED;
- /// Component index
- //UPGRADE_NOTE: Final was removed from the declaration of 'GREEN '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- //UPGRADE_NOTE: The initialization of 'GREEN' was moved to static method 'icc.RestrictedICCProfile'. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1005'"
- protected internal static readonly int GREEN;
- /// Component index
- //UPGRADE_NOTE: Final was removed from the declaration of 'BLUE '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- //UPGRADE_NOTE: The initialization of 'BLUE' was moved to static method 'icc.RestrictedICCProfile'. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1005'"
- protected internal static readonly int BLUE;
- /// input type enumerator
- public const int kMonochromeInput = 0;
- /// input type enumerator
- public const int kThreeCompInput = 1;
-
- /// Curve data
- public ICCCurveType[] trc;
- /// Colorant data
- public ICCXYZType[] colorant;
-
- /// Construct the common state of all gray RestrictedICCProfiles
- /// curve data
- ///
- protected internal RestrictedICCProfile(ICCCurveType gcurve)
- {
- trc = new ICCCurveType[1];
- colorant = null;
- trc[GRAY] = gcurve;
- }
-
- /// Construct the common state of all 3 component RestrictedICCProfiles
- ///
- ///
- /// red curve
- ///
- /// green curve
- ///
- /// blue curve
- ///
- /// red colorant
- ///
- /// green colorant
- ///
- /// blue colorant
- ///
- protected internal RestrictedICCProfile(ICCCurveType rcurve, ICCCurveType gcurve, ICCCurveType bcurve, ICCXYZType rcolorant, ICCXYZType gcolorant, ICCXYZType bcolorant)
- {
- trc = new ICCCurveType[3];
- colorant = new ICCXYZType[3];
-
- trc[RED] = rcurve;
- trc[GREEN] = gcurve;
- trc[BLUE] = bcurve;
-
- colorant[RED] = rcolorant;
- colorant[GREEN] = gcolorant;
- colorant[BLUE] = bcolorant;
- }
-
- /* end class RestrictedICCProfile */
- static RestrictedICCProfile()
- {
- GRAY = ICCProfile.GRAY;
- RED = ICCProfile.RED;
- GREEN = ICCProfile.GREEN;
- BLUE = ICCProfile.BLUE;
- }
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/Icc/Tags/ICCCurveType.cs b/CSJ2K/Icc/Tags/ICCCurveType.cs
deleted file mode 100644
index 9e8aab6e..00000000
--- a/CSJ2K/Icc/Tags/ICCCurveType.cs
+++ /dev/null
@@ -1,92 +0,0 @@
-/// **************************************************************************
-///
-/// $Id: ICCCurveType.java,v 1.1 2002/07/25 14:56:36 grosbois Exp $
-///
-/// Copyright Eastman Kodak Company, 343 State Street, Rochester, NY 14650
-/// $Date $
-/// ***************************************************************************
-///
-namespace CSJ2K.Icc.Tags
-{
-
- /// The ICCCurve tag
- ///
- ///
- /// 1.0
- ///
- /// Bruce A. Kern
- ///
- public class ICCCurveType : ICCTag
- {
-
- //UPGRADE_NOTE: Final was removed from the declaration of 'eol '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- private static readonly System.String eol = System.Environment.NewLine;
- /// Tag fields
- //UPGRADE_NOTE: Final was removed from the declaration of 'type '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- new public int type;
- /// Tag fields
- //UPGRADE_NOTE: Final was removed from the declaration of 'reserved '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- public int reserved;
- /// Tag fields
- //UPGRADE_NOTE: Final was removed from the declaration of 'nEntries '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- public int nEntries;
- /// Tag fields
- //UPGRADE_NOTE: Final was removed from the declaration of 'entry '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- public int[] entry_Renamed_Field;
-
- /// Return the string rep of this tag.
- public override System.String ToString()
- {
- System.Text.StringBuilder rep = new System.Text.StringBuilder("[").Append(base.ToString()).Append(" nentries = ").Append(System.Convert.ToString(nEntries)).Append(", length = " + System.Convert.ToString(entry_Renamed_Field.Length) + " ... ");
- return rep.Append("]").ToString();
- }
-
- /// Normalization utility
- public static double CurveToDouble(int entry)
- {
- return (double)entry / 65535.0;
- }
-
- /// Normalization utility
- public static short DoubleToCurve(double entry)
- {
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- return (short)System.Math.Floor(entry * 65535.0 + 0.5);
- }
-
- /// Normalization utility
- public static double CurveGammaToDouble(int entry)
- {
- return (double)entry / 256.0;
- }
-
-
- /// Construct this tag from its constituant parts
- /// tag id
- ///
- /// array of bytes
- ///
- /// to data in the data array
- ///
- /// of data in the data array
- ///
- protected internal ICCCurveType(int signature, byte[] data, int offset, int length) : base(signature, data, offset, offset + 2 * ICCProfile.int_size)
- {
- type = ICCProfile.getInt(data, offset);
- reserved = ICCProfile.getInt(data, offset + ICCProfile.int_size);
- nEntries = ICCProfile.getInt(data, offset + 2 * ICCProfile.int_size);
- entry_Renamed_Field = new int[nEntries];
- for (int i = 0; i < nEntries; ++i)
- entry_Renamed_Field[i] = ICCProfile.getShort(data, offset + 3 * ICCProfile.int_size + i * ICCProfile.short_size) & 0xFFFF;
- }
-
-
- /// Accessor for curve entry at index.
- public int entry(int i)
- {
- return entry_Renamed_Field[i];
- }
-
- /* end class ICCCurveType */
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/Icc/Tags/ICCCurveTypeReverse.cs b/CSJ2K/Icc/Tags/ICCCurveTypeReverse.cs
deleted file mode 100644
index d39d6b1c..00000000
--- a/CSJ2K/Icc/Tags/ICCCurveTypeReverse.cs
+++ /dev/null
@@ -1,96 +0,0 @@
-/// **************************************************************************
-///
-/// $Id: ICCCurveTypeReverse.java,v 1.1 2002/07/25 14:56:36 grosbois Exp $
-///
-/// Copyright Eastman Kodak Company, 343 State Street, Rochester, NY 14650
-/// $Date $
-/// ***************************************************************************
-///
-namespace CSJ2K.Icc.Tags
-{
-
- /// The ICCCurveReverse tag
- ///
- ///
- /// 1.0
- ///
- /// Bruce A. Kern
- ///
- public class ICCCurveTypeReverse : ICCTag
- {
-
- //UPGRADE_NOTE: Final was removed from the declaration of 'eol '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- private static readonly System.String eol = System.Environment.NewLine;
- /// Tag fields
- //UPGRADE_NOTE: Final was removed from the declaration of 'type '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- new public int type;
- /// Tag fields
- //UPGRADE_NOTE: Final was removed from the declaration of 'reserved '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- public int reserved;
- /// Tag fields
- //UPGRADE_NOTE: Final was removed from the declaration of 'nEntries '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- public int nEntries;
- /// Tag fields
- //UPGRADE_NOTE: Final was removed from the declaration of 'entry '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- public int[] entry_Renamed_Field;
-
-
- /// Return the string rep of this tag.
- public override System.String ToString()
- {
- System.Text.StringBuilder rep = new System.Text.StringBuilder("[").Append(base.ToString()).Append(eol);
- rep.Append("num entries = " + System.Convert.ToString(nEntries) + eol);
- rep.Append("data length = " + System.Convert.ToString(entry_Renamed_Field.Length) + eol);
- for (int i = 0; i < nEntries; ++i)
- rep.Append(ICCProfile.toHexString(entry_Renamed_Field[i]) + eol);
- return rep.Append("]").ToString();
- }
-
- /// Normalization utility
- public static double CurveToDouble(int entry)
- {
- return ICCCurveType.CurveToDouble(entry);
- }
-
- /// Normalization utility
- public static short DoubleToCurve(int entry)
- {
- return ICCCurveType.DoubleToCurve(entry);
- }
-
- /// Normalization utility
- public static double CurveGammaToDouble(int entry)
- {
- return ICCCurveType.CurveGammaToDouble(entry);
- }
-
-
- /// Construct this tag from its constituant parts
- /// tag id
- ///
- /// array of bytes
- ///
- /// to data in the data array
- ///
- /// of data in the data array
- ///
- protected internal ICCCurveTypeReverse(int signature, byte[] data, int offset, int length) : base(signature, data, offset, offset + 2 * ICCProfile.int_size)
- {
- type = ICCProfile.getInt(data, offset);
- reserved = ICCProfile.getInt(data, offset + ICCProfile.int_size);
- nEntries = ICCProfile.getInt(data, offset + 2 * ICCProfile.int_size);
- entry_Renamed_Field = new int[nEntries];
- for (int i = 0; i < nEntries; ++i)
- // Reverse the storage order.
- entry_Renamed_Field[nEntries - 1 + i] = ICCProfile.getShort(data, offset + 3 * ICCProfile.int_size + i * ICCProfile.short_size) & 0xFFFF;
- }
-
- /// Accessor for curve entry at index.
- public int entry(int i)
- {
- return entry_Renamed_Field[i];
- }
-
- /* end class ICCCurveTypeReverse */
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/Icc/Tags/ICCDataType.cs b/CSJ2K/Icc/Tags/ICCDataType.cs
deleted file mode 100644
index 68dc0bb3..00000000
--- a/CSJ2K/Icc/Tags/ICCDataType.cs
+++ /dev/null
@@ -1,24 +0,0 @@
-namespace CSJ2K.Icc.Tags
-{
- public class ICCDataType : ICCTag
- {
- new public int type;
- public int reserved;
- public int dataFlag;
- //byte[] Data;
-
- /// Construct this tag from its constituant parts
- /// tag id
- /// array of bytes
- /// to data in the data array
- /// of data in the data array
- protected internal ICCDataType(int signature, byte[] data, int offset, int length)
- : base(signature, data, offset, offset + 2 * ICCProfile.int_size)
- {
- type = ICCProfile.getInt(data, offset);
- reserved = ICCProfile.getInt(data, offset + ICCProfile.int_size);
- dataFlag = ICCProfile.getInt(data, offset + ICCProfile.int_size);
- //Data = ICCProfile.getString(data, offset + ICCProfile.int_size, length, true);
- }
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/Icc/Tags/ICCMeasurementType.cs b/CSJ2K/Icc/Tags/ICCMeasurementType.cs
deleted file mode 100644
index d2317173..00000000
--- a/CSJ2K/Icc/Tags/ICCMeasurementType.cs
+++ /dev/null
@@ -1,32 +0,0 @@
-using CSJ2K.Icc.Types;
-
-namespace CSJ2K.Icc.Tags
-{
- public class ICCMeasurementType : ICCTag
- {
- new public int type;
- public int reserved;
- public int observer;
- public XYZNumber backing;
- public int geometry;
- public int flare;
- public int illuminant;
-
- /// Construct this tag from its constituant parts
- /// tag id
- /// array of bytes
- /// to data in the data array
- /// of data in the data array
- protected internal ICCMeasurementType(int signature, byte[] data, int offset, int length)
- : base(signature, data, offset, offset + 2 * ICCProfile.int_size)
- {
- type = ICCProfile.getInt(data, offset);
- reserved = ICCProfile.getInt(data, offset + ICCProfile.int_size);
- observer = ICCProfile.getInt(data, offset + ICCProfile.int_size);
- backing = ICCProfile.getXYZNumber(data, offset + ICCProfile.int_size);
- geometry = ICCProfile.getInt(data, offset + (ICCProfile.int_size * 3));
- flare = ICCProfile.getInt(data, offset + ICCProfile.int_size);
- illuminant = ICCProfile.getInt(data, offset + ICCProfile.int_size);
- }
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/Icc/Tags/ICCSignatureType.cs b/CSJ2K/Icc/Tags/ICCSignatureType.cs
deleted file mode 100644
index 180f0e7f..00000000
--- a/CSJ2K/Icc/Tags/ICCSignatureType.cs
+++ /dev/null
@@ -1,22 +0,0 @@
-namespace CSJ2K.Icc.Tags
-{
- public class ICCSignatureType : ICCTag
- {
- new public int type;
- public int reserved;
- new public int signature;
-
- /// Construct this tag from its constituant parts
- /// tag id
- /// array of bytes
- /// to data in the data array
- /// of data in the data array
- protected internal ICCSignatureType(int signature, byte[] data, int offset, int length)
- : base(signature, data, offset, offset + 2 * ICCProfile.int_size)
- {
- type = ICCProfile.getInt(data, offset);
- reserved = ICCProfile.getInt(data, offset + ICCProfile.int_size);
- signature = ICCProfile.getInt(data, offset + ICCProfile.int_size);
- }
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/Icc/Tags/ICCTag.cs b/CSJ2K/Icc/Tags/ICCTag.cs
deleted file mode 100644
index 2cb55e17..00000000
--- a/CSJ2K/Icc/Tags/ICCTag.cs
+++ /dev/null
@@ -1,276 +0,0 @@
-/// **************************************************************************
-///
-/// $Id: ICCTag.java,v 1.1 2002/07/25 14:56:37 grosbois Exp $
-///
-/// Copyright Eastman Kodak Company, 343 State Street, Rochester, NY 14650
-/// $Date $
-/// ***************************************************************************
-///
-using System;
-using System.Text;
-namespace CSJ2K.Icc.Tags
-{
-
- /// An ICC profile contains a 128-byte header followed by a variable
- /// number of tags contained in a tag table. Each tag is a structured
- /// block of ints. The tags share a common format on disk starting with
- /// a signature, an offset to the tag data, and a length of the tag data.
- /// The tag data itself is found at the given offset in the file and
- /// consists of a tag type int, followed by a reserved int, followed by
- /// a data block, the structure of which is unique to the tag type.
- ///
- /// This class is the abstract super class of all tags. It models that
- /// part of the structure which is common among tags of all types.
- /// It also contains the definitions of the various tag types.
- ///
- ///
- ///
- ///
- ///
- /// 1.0
- ///
- /// Bruce A. Kern
- ///
- public abstract class ICCTag
- {
-
- // Tag Signature Strings
- private const System.String sdwCprtSignature = "cprt";
- private const System.String sdwDescSignature = "desc";
- private const System.String sdwWtPtSignature = "wtpt";
- private const System.String sdwBkPtSignature = "bkpt";
- private const System.String sdwRXYZSignature = "rXYZ";
- private const System.String sdwGXYZSignature = "gXYZ";
- private const System.String sdwBXYZSignature = "bXYZ";
- private const System.String sdwKXYZSignature = "kXYZ";
- private const System.String sdwRTRCSignature = "rTRC";
- private const System.String sdwGTRCSignature = "gTRC";
- private const System.String sdwBTRCSignature = "bTRC";
- private const System.String sdwKTRCSignature = "kTRC";
- private const System.String sdwDmndSignature = "dmnd";
- private const System.String sdwDmddSignature = "dmdd";
-
- // Tag Signatures
- private static readonly int kdwCprtSignature;
- private static readonly int kdwDescSignature;
- private static readonly int kdwWtPtSignature;
- private static readonly int kdwBkPtSignature;
- private static readonly int kdwRXYZSignature;
- private static readonly int kdwGXYZSignature;
- private static readonly int kdwBXYZSignature;
- private static readonly int kdwKXYZSignature;
- private static readonly int kdwRTRCSignature;
- private static readonly int kdwGTRCSignature;
- private static readonly int kdwBTRCSignature;
- private static readonly int kdwKTRCSignature;
- private static readonly int kdwDmndSignature;
- private static readonly int kdwDmddSignature;
-
- // Tag Type Strings
- private const string sdwTextDescType = "desc";
- private const string sdwTextType = "text";
- private const string sdwCurveType = "curv";
- private const string sdwCurveTypeReverse = "vruc";
- private const string sdwXYZType = "XYZ ";
- private const string sdwXYZTypeReverse = " ZYX";
- private const string sdwMeasurementType = "meas";
- private const string sdwSignatureType = "sig ";
- private const string sdwViewType = "view";
- private const string sdwDataType = "data";
-
- // Tag Types
- private static readonly int kdwTextDescType;
- private static readonly int kdwTextType;
- private static readonly int kdwCurveType;
- private static readonly int kdwCurveTypeReverse;
- private static readonly int kdwXYZType;
- private static readonly int kdwXYZTypeReverse;
- private static readonly int kdwMeasurementType;
- private static readonly int kdwSignatureType;
- private static readonly int kdwViewType;
- private static readonly int kdwDataType;
-
- /// Tag id
- public int signature;
- /// Tag type
- // Tag signature
- public int type;
- /// Tag data
- public byte[] data;
- /// offset to tag data in the array
- // Tag type
- public int offset;
- /// size of the tag data in the array
- public int count;
-
- /// Create a string representation of the tag type
- /// input
- ///
- /// String representation of the type
- ///
- public static System.String typeString(int type)
- {
- if (type == kdwTextDescType)
- return sdwTextDescType;
- else if (type == kdwTextType)
- return sdwTextDescType;
- else if (type == kdwCurveType)
- return sdwCurveType;
- else if (type == kdwCurveTypeReverse)
- return sdwCurveTypeReverse;
- else if (type == kdwXYZType)
- return sdwXYZType;
- else if (type == kdwXYZTypeReverse)
- return sdwXYZTypeReverse;
- else if (type == kdwMeasurementType)
- return sdwMeasurementType;
- else if (type == kdwSignatureType)
- return sdwSignatureType;
- else if (type == kdwViewType)
- return sdwViewType;
- else if (type == kdwDataType)
- return sdwDataType;
- else
- return "bad tag type";
- }
-
-
- /// Create a string representation of the signature
- /// input
- ///
- /// String representation of the signature
- ///
- public static System.String signatureString(int signature)
- {
-
- if (signature == kdwCprtSignature)
- return sdwCprtSignature;
- else if (signature == kdwDescSignature)
- return sdwDescSignature;
- else if (signature == kdwWtPtSignature)
- return sdwWtPtSignature;
- else if (signature == kdwBkPtSignature)
- return sdwBkPtSignature;
- else if (signature == kdwRXYZSignature)
- return sdwRXYZSignature;
- else if (signature == kdwGXYZSignature)
- return sdwGXYZSignature;
- else if (signature == kdwBXYZSignature)
- return sdwBXYZSignature;
- else if (signature == kdwRTRCSignature)
- return sdwRTRCSignature;
- else if (signature == kdwGTRCSignature)
- return sdwGTRCSignature;
- else if (signature == kdwBTRCSignature)
- return sdwBTRCSignature;
- else if (signature == kdwKTRCSignature)
- return sdwKTRCSignature;
- else if (signature == kdwDmndSignature)
- return sdwDmndSignature;
- else if (signature == kdwDmddSignature)
- return sdwDmddSignature;
- else
- return "bad tag signature";
- }
-
-
- /// Factory method for creating a tag of a specific type.
- /// tag to create
- ///
- /// byte array containg embedded tag data
- ///
- /// to tag data in the array
- ///
- /// size of tag data in bytes
- ///
- /// specified ICCTag
- ///
- public static ICCTag createInstance(int signature, byte[] data, int offset, int count)
- {
-
- int type = ICCProfile.getInt(data, offset);
-
- if (type == kdwTextDescType)
- return new ICCTextDescriptionType(signature, data, offset, count);
- else if (type == kdwTextType)
- return new ICCTextType(signature, data, offset, count);
- else if (type == kdwXYZType)
- return new ICCXYZType(signature, data, offset, count);
- else if (type == kdwXYZTypeReverse)
- return new ICCXYZTypeReverse(signature, data, offset, count);
- else if (type == kdwCurveType)
- return new ICCCurveType(signature, data, offset, count);
- else if (type == kdwCurveTypeReverse)
- return new ICCCurveTypeReverse(signature, data, offset, count);
- else if (type == kdwMeasurementType)
- return new ICCMeasurementType(signature, data, offset, count);
- else if (type == kdwSignatureType)
- return new ICCSignatureType(signature, data, offset, count);
- else if (type == kdwViewType)
- return new ICCViewType(signature, data, offset, count);
- else if (type == kdwDataType)
- return new ICCDataType(signature, data, offset, count);
- else
- throw new System.ArgumentException("bad tag type: " + System.Text.ASCIIEncoding.ASCII.GetString(BitConverter.GetBytes(type)) + "(" + type + ")");
- }
-
-
- /// Ued by subclass initialization to store the state common to all tags
- /// tag being created
- ///
- /// byte array containg embedded tag data
- ///
- /// to tag data in the array
- ///
- /// size of tag data in bytes
- ///
- protected internal ICCTag(int signature, byte[] data, int offset, int count)
- {
- this.signature = signature;
- this.data = data;
- this.offset = offset;
- this.count = count;
- this.type = ICCProfile.getInt(data, offset);
- }
-
- public override System.String ToString()
- {
- return signatureString(signature) + ":" + typeString(type);
- }
-
- /* end class ICCTag */
- static ICCTag()
- {
- kdwCprtSignature = GetTagInt(sdwCprtSignature);
- kdwDescSignature = GetTagInt(sdwDescSignature);
- kdwWtPtSignature = GetTagInt(sdwWtPtSignature);
- kdwBkPtSignature = GetTagInt(sdwBkPtSignature);
- kdwRXYZSignature = GetTagInt(sdwRXYZSignature);
- kdwGXYZSignature = GetTagInt(sdwGXYZSignature);
- kdwBXYZSignature = GetTagInt(sdwBXYZSignature);
- kdwKXYZSignature = GetTagInt(sdwKXYZSignature);
- kdwRTRCSignature = GetTagInt(sdwRTRCSignature);
- kdwGTRCSignature = GetTagInt(sdwGTRCSignature);
- kdwBTRCSignature = GetTagInt(sdwBTRCSignature);
- kdwKTRCSignature = GetTagInt(sdwKTRCSignature);
- kdwDmndSignature = GetTagInt(sdwDmndSignature);
- kdwDmddSignature = GetTagInt(sdwDmddSignature);
- kdwTextDescType = GetTagInt(sdwTextDescType);
- kdwTextType = GetTagInt(sdwTextType);
- kdwCurveType = GetTagInt(sdwCurveType);
- kdwCurveTypeReverse = GetTagInt(sdwCurveTypeReverse);
- kdwXYZType = GetTagInt(sdwXYZType);
- kdwXYZTypeReverse = GetTagInt(sdwXYZTypeReverse);
- kdwMeasurementType = GetTagInt(sdwMeasurementType);
- kdwSignatureType = GetTagInt(sdwSignatureType);
- kdwViewType = GetTagInt(sdwViewType);
- kdwDataType = GetTagInt(sdwDataType);
- }
- static int GetTagInt(string tag)
- {
- byte[] tagBytes = ASCIIEncoding.ASCII.GetBytes(tag);
- Array.Reverse(tagBytes);
- return BitConverter.ToInt32(tagBytes, 0);
- }
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/Icc/Tags/ICCTagTable.cs b/CSJ2K/Icc/Tags/ICCTagTable.cs
deleted file mode 100644
index c0102c48..00000000
--- a/CSJ2K/Icc/Tags/ICCTagTable.cs
+++ /dev/null
@@ -1,200 +0,0 @@
-/// **************************************************************************
-///
-/// $Id: ICCTagTable.java,v 1.1 2002/07/25 14:56:37 grosbois Exp $
-///
-/// Copyright Eastman Kodak Company, 343 State Street, Rochester, NY 14650
-/// $Date $
-/// ***************************************************************************
-///
-using System;
-using ColorSpace = CSJ2K.Color.ColorSpace;
-using ICCProfileHeader = CSJ2K.Icc.Types.ICCProfileHeader;
-namespace CSJ2K.Icc.Tags
-{
-
- /// This class models an ICCTagTable as a HashTable which maps
- /// ICCTag signatures (as Integers) to ICCTags.
- ///
- /// On disk the tag table exists as a byte array conventionally aggragted into a
- /// structured sequence of types (bytes, shorts, ints, and floats. The first four bytes
- /// are the integer count of tags in the table. This is followed by an array of triplets,
- /// one for each tag. The triplets each contain three integers, which are the tag signature,
- /// the offset of the tag in the byte array and the length of the tag in bytes.
- /// The tag data follows. Each tag consists of an integer (4 bytes) tag type, a reserved integer
- /// and the tag data, which varies depending on the tag.
- ///
- ///
- ///
- ///
- /// 1.0
- ///
- /// Bruce A. Kern
- ///
- [Serializable]
- public class ICCTagTable : System.Collections.Hashtable
- {
- //UPGRADE_NOTE: Final was removed from the declaration of 'eol '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- private static readonly System.String eol = System.Environment.NewLine;
- //UPGRADE_NOTE: Final was removed from the declaration of 'offTagCount '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- //UPGRADE_NOTE: The initialization of 'offTagCount' was moved to static method 'icc.tags.ICCTagTable'. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1005'"
- private static readonly int offTagCount;
- //UPGRADE_NOTE: Final was removed from the declaration of 'offTags '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- //UPGRADE_NOTE: The initialization of 'offTags' was moved to static method 'icc.tags.ICCTagTable'. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1005'"
- private static readonly int offTags;
-
- //UPGRADE_NOTE: Final was removed from the declaration of 'trios '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- private System.Collections.ArrayList trios = System.Collections.ArrayList.Synchronized(new System.Collections.ArrayList(10));
-
- private int tagCount;
-
-
- private class Triplet
- {
- /// Tag identifier
- internal int signature;
- /// absolute offset of tag data
- internal int offset;
- /// length of tag data
- internal int count;
- /// size of an entry
- //UPGRADE_NOTE: Final was removed from the declaration of 'size '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- //UPGRADE_NOTE: The initialization of 'size' was moved to static method 'icc.tags.ICCTagTable.Triplet'. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1005'"
- public static readonly int size;
-
-
- internal Triplet(int signature, int offset, int count)
- {
- this.signature = signature;
- this.offset = offset;
- this.count = count;
- }
- static Triplet()
- {
- size = 3 * ICCProfile.int_size;
- }
- }
-
- /// Representation of a tag table
- /// String
- ///
- //UPGRADE_NOTE: The equivalent of method 'java.util.Hashtable.toString' is not an override method. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1143'"
- public override System.String ToString()
- {
- System.Text.StringBuilder rep = new System.Text.StringBuilder("[ICCTagTable containing " + tagCount + " tags:");
- System.Text.StringBuilder body = new System.Text.StringBuilder(" ");
- System.Collections.IEnumerator keys = Keys.GetEnumerator();
- //UPGRADE_TODO: Method 'java.util.Enumeration.hasMoreElements' was converted to 'System.Collections.IEnumerator.MoveNext' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilEnumerationhasMoreElements'"
- while (keys.MoveNext())
- {
- //UPGRADE_TODO: Method 'java.util.Enumeration.nextElement' was converted to 'System.Collections.IEnumerator.Current' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilEnumerationnextElement'"
- System.Int32 key = (System.Int32)keys.Current;
- ICCTag tag = (ICCTag)this[key];
- body.Append(eol).Append(tag.ToString());
- }
- rep.Append(ColorSpace.indent(" ", body));
- return rep.Append("]").ToString();
- }
-
-
- /// Factory method for creating a tag table from raw input.
- /// array of unstructured data representing a tag
- ///
- /// ICCTagTable
- ///
- public static ICCTagTable createInstance(byte[] data)
- {
- ICCTagTable tags = new ICCTagTable(data);
- return tags;
- }
-
-
- /// Ctor used by factory method.
- /// raw tag data
- ///
- protected internal ICCTagTable(byte[] data)
- {
- tagCount = ICCProfile.getInt(data, offTagCount);
-
- int offset = offTags;
- for (int i = 0; i < tagCount; ++i)
- {
- int signature = ICCProfile.getInt(data, offset);
- int tagOffset = ICCProfile.getInt(data, offset + ICCProfile.int_size);
- int length = ICCProfile.getInt(data, offset + 2 * ICCProfile.int_size);
- trios.Add(new Triplet(signature, tagOffset, length));
- offset += 3 * ICCProfile.int_size;
- }
-
-
- System.Collections.IEnumerator Enum = trios.GetEnumerator();
- //UPGRADE_TODO: Method 'java.util.Enumeration.hasMoreElements' was converted to 'System.Collections.IEnumerator.MoveNext' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilEnumerationhasMoreElements'"
- while (Enum.MoveNext())
- {
- //UPGRADE_TODO: Method 'java.util.Enumeration.nextElement' was converted to 'System.Collections.IEnumerator.Current' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilEnumerationnextElement'"
- Triplet trio = (Triplet)Enum.Current;
- ICCTag tag = ICCTag.createInstance(trio.signature, data, trio.offset, trio.count);
- System.Object tempObject;
- tempObject = this[(System.Int32)tag.signature];
- this[(System.Int32)tag.signature] = tag;
- System.Object generatedAux2 = tempObject;
- }
- }
-
-
- /// Output the table to a disk
- /// RandomAccessFile which receives the table.
- ///
- ///
- ///
- //UPGRADE_TODO: Class 'java.io.RandomAccessFile' was converted to 'System.IO.FileStream' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaioRandomAccessFile'"
- public virtual void write(System.IO.FileStream raf)
- {
-
- int ntags = trios.Count;
-
- int countOff = ICCProfileHeader.size;
- int tagOff = countOff + ICCProfile.int_size;
- int dataOff = tagOff + 3 * ntags * ICCProfile.int_size;
-
- raf.Seek(countOff, System.IO.SeekOrigin.Begin);
- System.IO.BinaryWriter temp_BinaryWriter;
- temp_BinaryWriter = new System.IO.BinaryWriter(raf);
- temp_BinaryWriter.Write((System.Int32)ntags);
-
- int currentTagOff = tagOff;
- int currentDataOff = dataOff;
-
- System.Collections.IEnumerator enum_Renamed = trios.GetEnumerator();
- //UPGRADE_TODO: Method 'java.util.Enumeration.hasMoreElements' was converted to 'System.Collections.IEnumerator.MoveNext' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilEnumerationhasMoreElements'"
- while (enum_Renamed.MoveNext())
- {
- //UPGRADE_TODO: Method 'java.util.Enumeration.nextElement' was converted to 'System.Collections.IEnumerator.Current' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilEnumerationnextElement'"
- Triplet trio = (Triplet)enum_Renamed.Current;
- ICCTag tag = (ICCTag)this[(System.Int32)trio.signature];
-
- raf.Seek(currentTagOff, System.IO.SeekOrigin.Begin);
- System.IO.BinaryWriter temp_BinaryWriter2;
- temp_BinaryWriter2 = new System.IO.BinaryWriter(raf);
- temp_BinaryWriter2.Write((System.Int32)tag.signature);
- System.IO.BinaryWriter temp_BinaryWriter3;
- temp_BinaryWriter3 = new System.IO.BinaryWriter(raf);
- temp_BinaryWriter3.Write((System.Int32)currentDataOff);
- System.IO.BinaryWriter temp_BinaryWriter4;
- temp_BinaryWriter4 = new System.IO.BinaryWriter(raf);
- temp_BinaryWriter4.Write((System.Int32)tag.count);
- currentTagOff += 3 * CSJ2K.Icc.Tags.ICCTagTable.Triplet.size;
-
- raf.Seek(currentDataOff, System.IO.SeekOrigin.Begin);
- raf.Write(tag.data, tag.offset, tag.count);
- currentDataOff += tag.count;
- }
- }
-
- /* end class ICCTagTable */
- static ICCTagTable()
- {
- offTagCount = ICCProfileHeader.size;
- offTags = offTagCount + ICCProfile.int_size;
- }
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/Icc/Tags/ICCTextDescriptionType.cs b/CSJ2K/Icc/Tags/ICCTextDescriptionType.cs
deleted file mode 100644
index 099c049c..00000000
--- a/CSJ2K/Icc/Tags/ICCTextDescriptionType.cs
+++ /dev/null
@@ -1,69 +0,0 @@
-/// **************************************************************************
-///
-/// $Id: ICCTextDescriptionType.java,v 1.1 2002/07/25 14:56:37 grosbois Exp $
-///
-/// Copyright Eastman Kodak Company, 343 State Street, Rochester, NY 14650
-/// $Date $
-/// ***************************************************************************
-///
-using System;
-namespace CSJ2K.Icc.Tags
-{
-
- /// A text based ICC tag
- ///
- ///
- /// 1.0
- ///
- /// Bruce A. Kern
- ///
- public class ICCTextDescriptionType : ICCTag
- {
-
- /// Tag fields
- //UPGRADE_NOTE: Final was removed from the declaration of 'type '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- new public int type;
- /// Tag fields
- //UPGRADE_NOTE: Final was removed from the declaration of 'reserved '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- public int reserved;
- /// Tag fields
- //UPGRADE_NOTE: Final was removed from the declaration of 'size '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- public int size;
- /// Tag fields
- //UPGRADE_NOTE: Final was removed from the declaration of 'ascii '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- public byte[] ascii;
-
- /// Construct this tag from its constituant parts
- /// tag id
- ///
- /// array of bytes
- ///
- /// to data in the data array
- ///
- /// of data in the data array
- ///
- protected internal ICCTextDescriptionType(int signature, byte[] data, int offset, int length) : base(signature, data, offset, length)
- {
-
- type = ICCProfile.getInt(data, offset);
- offset += ICCProfile.int_size;
-
- reserved = ICCProfile.getInt(data, offset);
- offset += ICCProfile.int_size;
-
- size = ICCProfile.getInt(data, offset);
- offset += ICCProfile.int_size;
-
- ascii = new byte[size - 1];
- Array.Copy(data, offset, ascii, 0, size - 1);
- }
-
- /// Return the string rep of this tag.
- public override System.String ToString()
- {
- return "[" + base.ToString() + " \"" + System.Text.ASCIIEncoding.ASCII.GetString(ascii) + "\"]";
- }
-
- /* end class ICCTextDescriptionType */
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/Icc/Tags/ICCTextType.cs b/CSJ2K/Icc/Tags/ICCTextType.cs
deleted file mode 100644
index 2c11bc9c..00000000
--- a/CSJ2K/Icc/Tags/ICCTextType.cs
+++ /dev/null
@@ -1,63 +0,0 @@
-/// **************************************************************************
-///
-/// $Id: ICCTextType.java,v 1.1 2002/07/25 14:56:37 grosbois Exp $
-///
-/// Copyright Eastman Kodak Company, 343 State Street, Rochester, NY 14650
-/// $Date $
-/// ***************************************************************************
-///
-using System;
-namespace CSJ2K.Icc.Tags
-{
-
- /// A text based ICC tag
- ///
- ///
- /// 1.0
- ///
- /// Bruce A. Kern
- ///
- public class ICCTextType : ICCTag
- {
-
- /// Tag fields
- //UPGRADE_NOTE: Final was removed from the declaration of 'type '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- new public int type;
- /// Tag fields
- //UPGRADE_NOTE: Final was removed from the declaration of 'reserved '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- public int reserved;
- /// Tag fields
- //UPGRADE_NOTE: Final was removed from the declaration of 'ascii '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- public byte[] ascii;
-
- /// Construct this tag from its constituant parts
- /// tag id
- ///
- /// array of bytes
- ///
- /// to data in the data array
- ///
- /// of data in the data array
- ///
- protected internal ICCTextType(int signature, byte[] data, int offset, int length) : base(signature, data, offset, length)
- {
- type = ICCProfile.getInt(data, offset);
- offset += ICCProfile.int_size;
- reserved = ICCProfile.getInt(data, offset);
- offset += ICCProfile.int_size;
- int size = 0;
- while (data[offset + size] != 0)
- ++size;
- ascii = new byte[size];
- Array.Copy(data, offset, ascii, 0, size);
- }
-
- /// Return the string rep of this tag.
- public override System.String ToString()
- {
- return "[" + base.ToString() + " \"" + System.Text.ASCIIEncoding.ASCII.GetString(ascii, 0, ascii.Length) + "\"]";
- }
-
- /* end class ICCTextType */
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/Icc/Tags/ICCViewType.cs b/CSJ2K/Icc/Tags/ICCViewType.cs
deleted file mode 100644
index 87925d8f..00000000
--- a/CSJ2K/Icc/Tags/ICCViewType.cs
+++ /dev/null
@@ -1,28 +0,0 @@
-using CSJ2K.Icc.Types;
-
-namespace CSJ2K.Icc.Tags
-{
- public class ICCViewType : ICCTag
- {
- new public int type;
- public int reserved;
- public XYZNumber CIEilluminant;
- public XYZNumber CIEsurround;
- public int illuminant;
-
- /// Construct this tag from its constituant parts
- /// tag id
- /// array of bytes
- /// to data in the data array
- /// of data in the data array
- protected internal ICCViewType(int signature, byte[] data, int offset, int length)
- : base(signature, data, offset, offset + 2 * ICCProfile.int_size)
- {
- type = ICCProfile.getInt(data, offset);
- reserved = ICCProfile.getInt(data, offset + ICCProfile.int_size);
- CIEilluminant = ICCProfile.getXYZNumber(data, offset + ICCProfile.int_size);
- CIEsurround = ICCProfile.getXYZNumber(data, offset + (ICCProfile.int_size * 3));
- illuminant = ICCProfile.getInt(data, offset + (ICCProfile.int_size * 3));
- }
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/Icc/Tags/ICCXYZType.cs b/CSJ2K/Icc/Tags/ICCXYZType.cs
deleted file mode 100644
index 242ce458..00000000
--- a/CSJ2K/Icc/Tags/ICCXYZType.cs
+++ /dev/null
@@ -1,90 +0,0 @@
-/// **************************************************************************
-///
-/// $Id: ICCXYZType.java,v 1.1 2002/07/25 14:56:37 grosbois Exp $
-///
-/// Copyright Eastman Kodak Company, 343 State Street, Rochester, NY 14650
-/// $Date $
-/// ***************************************************************************
-///
-namespace CSJ2K.Icc.Tags
-{
-
- /// A tag containing a triplet.
- ///
- ///
- ///
- ///
- ///
- ///
- /// 1.0
- ///
- /// Bruce A. Kern
- ///
- public class ICCXYZType : ICCTag
- {
-
- /// x component
- //UPGRADE_NOTE: Final was removed from the declaration of 'x '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- public long x;
- /// y component
- //UPGRADE_NOTE: Final was removed from the declaration of 'y '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- public long y;
- /// z component
- //UPGRADE_NOTE: Final was removed from the declaration of 'z '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- public long z;
-
- /// Normalization utility
- public static long DoubleToXYZ(double x)
- {
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- return (long)System.Math.Floor(x * 65536.0 + 0.5);
- }
-
- /// Normalization utility
- public static double XYZToDouble(long x)
- {
- return x / 65536.0;
- }
-
- /// Construct this tag from its constituant parts
- /// tag id
- ///
- /// array of bytes
- ///
- /// to data in the data array
- ///
- /// of data in the data array
- ///
- protected internal ICCXYZType(int signature, byte[] data, int offset, int length) : base(signature, data, offset, length)
- {
- x = ICCProfile.getInt(data, offset + 2 * ICCProfile.int_size);
- y = ICCProfile.getInt(data, offset + 3 * ICCProfile.int_size);
- z = ICCProfile.getInt(data, offset + 4 * ICCProfile.int_size);
- }
-
-
- /// Return the string rep of this tag.
- public override System.String ToString()
- {
- return "[" + base.ToString() + "(" + x + ", " + y + ", " + z + ")]";
- }
-
-
- /// Write to a file.
- //UPGRADE_TODO: Class 'java.io.RandomAccessFile' was converted to 'System.IO.FileStream' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaioRandomAccessFile'"
- public virtual void write(System.IO.FileStream raf)
- {
- byte[] xb = ICCProfile.setLong(x);
- byte[] yb = ICCProfile.setLong(y);
- byte[] zb = ICCProfile.setLong(z);
-
- // CONVERSION PROBLEM?
- raf.Write(xb, ICCProfile.int_size, 0);
- raf.Write(yb, ICCProfile.int_size, 0);
- raf.Write(zb, ICCProfile.int_size, 0);
- }
-
-
- /* end class ICCXYZType */
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/Icc/Tags/ICCXYZTypeReverse.cs b/CSJ2K/Icc/Tags/ICCXYZTypeReverse.cs
deleted file mode 100644
index 03463fbf..00000000
--- a/CSJ2K/Icc/Tags/ICCXYZTypeReverse.cs
+++ /dev/null
@@ -1,61 +0,0 @@
-/// **************************************************************************
-///
-/// $Id: ICCXYZTypeReverse.java,v 1.1 2002/07/25 14:56:38 grosbois Exp $
-///
-/// Copyright Eastman Kodak Company, 343 State Street, Rochester, NY 14650
-/// $Date $
-/// ***************************************************************************
-///
-namespace CSJ2K.Icc.Tags
-{
-
- /// A tag containing a triplet.
- ///
- ///
- ///
- ///
- ///
- ///
- /// 1.0
- ///
- /// Bruce A. Kern
- ///
- public class ICCXYZTypeReverse : ICCXYZType
- {
-
- /// x component
- //UPGRADE_NOTE: Final was removed from the declaration of 'x '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- new public long x;
- /// y component
- //UPGRADE_NOTE: Final was removed from the declaration of 'y '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- new public long y;
- /// z component
- //UPGRADE_NOTE: Final was removed from the declaration of 'z '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- new public long z;
-
- /// Construct this tag from its constituant parts
- /// tag id
- ///
- /// array of bytes
- ///
- /// to data in the data array
- ///
- /// of data in the data array
- ///
- protected internal ICCXYZTypeReverse(int signature, byte[] data, int offset, int length) : base(signature, data, offset, length)
- {
- z = ICCProfile.getInt(data, offset + 2 * ICCProfile.int_size);
- y = ICCProfile.getInt(data, offset + 3 * ICCProfile.int_size);
- x = ICCProfile.getInt(data, offset + 4 * ICCProfile.int_size);
- }
-
-
- /// Return the string rep of this tag.
- public override System.String ToString()
- {
- return "[" + base.ToString() + "(" + x + ", " + y + ", " + z + ")]";
- }
-
- /* end class ICCXYZTypeReverse */
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/Icc/Types/ICCDateTime.cs b/CSJ2K/Icc/Types/ICCDateTime.cs
deleted file mode 100644
index 4bc1c6c6..00000000
--- a/CSJ2K/Icc/Types/ICCDateTime.cs
+++ /dev/null
@@ -1,87 +0,0 @@
-/// **************************************************************************
-///
-/// $Id: ICCDateTime.java,v 1.1 2002/07/25 14:56:31 grosbois Exp $
-///
-/// Copyright Eastman Kodak Company, 343 State Street, Rochester, NY 14650
-/// $Date $
-/// ***************************************************************************
-///
-namespace CSJ2K.Icc.Types
-{
-
- /// Date Time format for tags
- ///
- ///
- /// 1.0
- ///
- /// Bruce A. Kern
- ///
- public class ICCDateTime
- {
- //UPGRADE_NOTE: Final was removed from the declaration of 'size '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- //UPGRADE_NOTE: The initialization of 'size' was moved to static method 'icc.types.ICCDateTime'. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1005'"
- public static readonly int size;
-
- /// Year datum.
- public short wYear;
- /// Month datum.
- // Number of the actual year (i.e. 1994)
- public short wMonth;
- /// Day datum.
- // Number of the month (1-12)
- public short wDay;
- /// Hour datum.
- // Number of the day
- public short wHours;
- /// Minute datum.
- // Number of hours (0-23)
- public short wMinutes;
- /// Second datum.
- // Number of minutes (0-59)
- public short wSeconds; // Number of seconds (0-59)
-
- /// Construct an ICCDateTime from parts
- public ICCDateTime(short year, short month, short day, short hour, short minute, short second)
- {
- wYear = year; wMonth = month; wDay = day;
- wHours = hour; wMinutes = minute; wSeconds = second;
- }
-
- /// Write an ICCDateTime to a file.
- //UPGRADE_TODO: Class 'java.io.RandomAccessFile' was converted to 'System.IO.FileStream' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaioRandomAccessFile'"
- public virtual void write(System.IO.FileStream raf)
- {
- System.IO.BinaryWriter temp_BinaryWriter;
- temp_BinaryWriter = new System.IO.BinaryWriter(raf);
- temp_BinaryWriter.Write((System.Int16)wYear);
- System.IO.BinaryWriter temp_BinaryWriter2;
- temp_BinaryWriter2 = new System.IO.BinaryWriter(raf);
- temp_BinaryWriter2.Write((System.Int16)wMonth);
- System.IO.BinaryWriter temp_BinaryWriter3;
- temp_BinaryWriter3 = new System.IO.BinaryWriter(raf);
- temp_BinaryWriter3.Write((System.Int16)wDay);
- System.IO.BinaryWriter temp_BinaryWriter4;
- temp_BinaryWriter4 = new System.IO.BinaryWriter(raf);
- temp_BinaryWriter4.Write((System.Int16)wHours);
- System.IO.BinaryWriter temp_BinaryWriter5;
- temp_BinaryWriter5 = new System.IO.BinaryWriter(raf);
- temp_BinaryWriter5.Write((System.Int16)wMinutes);
- System.IO.BinaryWriter temp_BinaryWriter6;
- temp_BinaryWriter6 = new System.IO.BinaryWriter(raf);
- temp_BinaryWriter6.Write((System.Int16)wSeconds);
- }
-
- /// Return a ICCDateTime representation.
- public override System.String ToString()
- {
- //System.String rep = "";
- return System.Convert.ToString(wYear) + "/" + System.Convert.ToString(wMonth) + "/" + System.Convert.ToString(wDay) + " " + System.Convert.ToString(wHours) + ":" + System.Convert.ToString(wMinutes) + ":" + System.Convert.ToString(wSeconds);
- }
-
- /* end class ICCDateTime*/
- static ICCDateTime()
- {
- size = 6 * ICCProfile.short_size;
- }
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/Icc/Types/ICCProfileHeader.cs b/CSJ2K/Icc/Types/ICCProfileHeader.cs
deleted file mode 100644
index c44f31e2..00000000
--- a/CSJ2K/Icc/Types/ICCProfileHeader.cs
+++ /dev/null
@@ -1,230 +0,0 @@
-/// **************************************************************************
-///
-/// $Id: ICCProfileHeader.java,v 1.1 2002/07/25 14:56:31 grosbois Exp $
-///
-/// Copyright Eastman Kodak Company, 343 State Street, Rochester, NY 14650
-/// $Date $
-/// ***************************************************************************
-///
-namespace CSJ2K.Icc.Types
-{
-
-
- /// An ICC profile contains a 128-byte header followed by a variable
- /// number of tags contained in a tag table. This class models the header
- /// portion of the profile. Most fields in the header are ints. Some, such
- /// as data and version are aggregations of ints. This class provides an api to
- /// those fields as well as the definition of standard constants which are used
- /// in the header.
- ///
- ///
- ///
- ///
- /// 1.0
- ///
- /// Bruce A. Kern
- ///
-
- public class ICCProfileHeader
- {
- //UPGRADE_NOTE: Final was removed from the declaration of 'eol '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- private static readonly System.String eol = System.Environment.NewLine;
-
- /// ICCProfile header byte array.
- //private byte[] header = null;
-
-
- /* Define the set of standard signature and type values. Only
- * those codes required for Restricted ICC use are defined here.
- */
- /// Profile header signature
- private static int kdwProfileSignature = ICCProfile.getInt(System.Text.ASCIIEncoding.ASCII.GetBytes("acsp"), 0);
-
- /// Profile header signature
- public static int kdwProfileSigReverse = ICCProfile.getInt(System.Text.ASCIIEncoding.ASCII.GetBytes("psca"), 0);
-
- private const System.String kdwInputProfile = "scnr";
- private const System.String kdwDisplayProfile = "mntr";
- private const System.String kdwRGBData = "RGB ";
- private const System.String kdwGrayData = "GRAY";
- private const System.String kdwXYZData = "XYZ ";
- private const System.String kdwGrayTRCTag = "kTRC";
- private const System.String kdwRedColorantTag = "rXYZ";
- private const System.String kdwGreenColorantTag = "gXYZ";
- private const System.String kdwBlueColorantTag = "bXYZ";
- private const System.String kdwRedTRCTag = "rTRC";
- private const System.String kdwGreenTRCTag = "gTRC";
- private const System.String kdwBlueTRCTag = "bTRC";
-
- /* Offsets into ICCProfile header byte array. */
-
- private static int offProfileSize = 0;
- private static int offCMMTypeSignature = offProfileSize + ICCProfile.int_size;
- private static int offProfileVersion = offCMMTypeSignature + ICCProfile.int_size;
- private static int offProfileClass = offProfileVersion + ICCProfileVersion.size;
- private static int offColorSpaceType = offProfileClass + ICCProfile.int_size;
- private static int offPCSType = offColorSpaceType + ICCProfile.int_size;
- private static int offDateTime = offPCSType + ICCProfile.int_size;
- private static int offProfileSignature = offDateTime + ICCDateTime.size;
- private static int offPlatformSignature = offProfileSignature + ICCProfile.int_size;
- private static int offCMMFlags = offPlatformSignature + ICCProfile.int_size;
- private static int offDeviceManufacturer = offCMMFlags + ICCProfile.int_size;
- private static int offDeviceModel = offDeviceManufacturer + ICCProfile.int_size;
- private static int offDeviceAttributes1 = offDeviceModel + ICCProfile.int_size;
- private static int offDeviceAttributesReserved = offDeviceAttributes1 + ICCProfile.int_size;
- private static int offRenderingIntent = offDeviceAttributesReserved + ICCProfile.int_size;
- private static int offPCSIlluminant = offRenderingIntent + ICCProfile.int_size;
- private static int offCreatorSig = offPCSIlluminant + XYZNumber.size;
- private static int offReserved = offCreatorSig + ICCProfile.int_size;
- /// Size of the header
- public static int size = offReserved + 44 * ICCProfile.byte_size;
-
- /// Header field
- /* Header fields mapped to primitive types. */
- public int dwProfileSize;
- /// Header field
- // Size of the entire profile in bytes
- public int dwCMMTypeSignature;
- /// Header field
- // The preferred CMM for this profile
- public int dwProfileClass;
- /// Header field
- // Profile/Device class signature
- public int dwColorSpaceType;
- /// Header field
- // Colorspace signature
- public int dwPCSType;
- /// Header field
- // PCS type signature
- public int dwProfileSignature;
- /// Header field
- // Must be 'acsp' (0x61637370)
- public int dwPlatformSignature;
- /// Header field
- // Primary platform for which this profile was created
- public int dwCMMFlags;
- /// Header field
- // Flags to indicate various hints for the CMM
- public int dwDeviceManufacturer;
- /// Header field
- // Signature of device manufacturer
- public int dwDeviceModel;
- /// Header field
- // Signature of device model
- public int dwDeviceAttributes1;
- /// Header field
- // Attributes of the device
- public int dwDeviceAttributesReserved;
- /// Header field
- public int dwRenderingIntent;
- /// Header field
- // Desired rendering intent for this profile
- public int dwCreatorSig;
- /// Header field
- // Profile creator signature
-
- public byte[] reserved = new byte[44]; //
-
- /// Header field
- /* Header fields mapped to ggregate types. */
- public ICCProfileVersion profileVersion;
- /// Header field
- // Version of the profile format on which
- public ICCDateTime dateTime;
- /// Header field
- // Date and time of profile creation// this profile is based
- public XYZNumber PCSIlluminant; // Illuminant used for this profile
-
-
- /// Construct and empty header
- public ICCProfileHeader()
- {
- }
-
- /// Construct a header from a complete ICCProfile
- /// [] -- holds ICCProfile contents
- ///
- public ICCProfileHeader(byte[] data)
- {
-
- dwProfileSize = ICCProfile.getInt(data, offProfileSize);
- dwCMMTypeSignature = ICCProfile.getInt(data, offCMMTypeSignature);
- dwProfileClass = ICCProfile.getInt(data, offProfileClass);
- dwColorSpaceType = ICCProfile.getInt(data, offColorSpaceType);
- dwPCSType = ICCProfile.getInt(data, offPCSType);
- dwProfileSignature = ICCProfile.getInt(data, offProfileSignature);
- dwPlatformSignature = ICCProfile.getInt(data, offPlatformSignature);
- dwCMMFlags = ICCProfile.getInt(data, offCMMFlags);
- dwDeviceManufacturer = ICCProfile.getInt(data, offDeviceManufacturer);
- dwDeviceModel = ICCProfile.getInt(data, offDeviceModel);
- dwDeviceAttributes1 = ICCProfile.getInt(data, offDeviceAttributesReserved);
- dwDeviceAttributesReserved = ICCProfile.getInt(data, offDeviceAttributesReserved);
- dwRenderingIntent = ICCProfile.getInt(data, offRenderingIntent);
- dwCreatorSig = ICCProfile.getInt(data, offCreatorSig);
- profileVersion = ICCProfile.getICCProfileVersion(data, offProfileVersion);
- dateTime = ICCProfile.getICCDateTime(data, offDateTime);
- PCSIlluminant = ICCProfile.getXYZNumber(data, offPCSIlluminant);
-
- for (int i = 0; i < reserved.Length; ++i)
- reserved[i] = data[offReserved + i];
- }
-
- /// Write out this ICCProfile header to a RandomAccessFile
- /// sink for data
- ///
- ///
- ///
- //UPGRADE_TODO: Class 'java.io.RandomAccessFile' was converted to 'System.IO.FileStream' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaioRandomAccessFile'"
- public virtual void write(System.IO.FileStream raf)
- {
-
- raf.Seek(offProfileSize, System.IO.SeekOrigin.Begin); raf.WriteByte((System.Byte)dwProfileSize);
- raf.Seek(offCMMTypeSignature, System.IO.SeekOrigin.Begin); raf.WriteByte((System.Byte)dwCMMTypeSignature);
- raf.Seek(offProfileVersion, System.IO.SeekOrigin.Begin); profileVersion.write(raf);
- raf.Seek(offProfileClass, System.IO.SeekOrigin.Begin); raf.WriteByte((System.Byte)dwProfileClass);
- raf.Seek(offColorSpaceType, System.IO.SeekOrigin.Begin); raf.WriteByte((System.Byte)dwColorSpaceType);
- raf.Seek(offPCSType, System.IO.SeekOrigin.Begin); raf.WriteByte((System.Byte)dwPCSType);
- raf.Seek(offDateTime, System.IO.SeekOrigin.Begin); dateTime.write(raf);
- raf.Seek(offProfileSignature, System.IO.SeekOrigin.Begin); raf.WriteByte((System.Byte)dwProfileSignature);
- raf.Seek(offPlatformSignature, System.IO.SeekOrigin.Begin); raf.WriteByte((System.Byte)dwPlatformSignature);
- raf.Seek(offCMMFlags, System.IO.SeekOrigin.Begin); raf.WriteByte((System.Byte)dwCMMFlags);
- raf.Seek(offDeviceManufacturer, System.IO.SeekOrigin.Begin); raf.WriteByte((System.Byte)dwDeviceManufacturer);
- raf.Seek(offDeviceModel, System.IO.SeekOrigin.Begin); raf.WriteByte((System.Byte)dwDeviceModel);
- raf.Seek(offDeviceAttributes1, System.IO.SeekOrigin.Begin); raf.WriteByte((System.Byte)dwDeviceAttributes1);
- raf.Seek(offDeviceAttributesReserved, System.IO.SeekOrigin.Begin); raf.WriteByte((System.Byte)dwDeviceAttributesReserved);
- raf.Seek(offRenderingIntent, System.IO.SeekOrigin.Begin); raf.WriteByte((System.Byte)dwRenderingIntent);
- raf.Seek(offPCSIlluminant, System.IO.SeekOrigin.Begin); PCSIlluminant.write(raf);
- raf.Seek(offCreatorSig, System.IO.SeekOrigin.Begin); raf.WriteByte((System.Byte)dwCreatorSig);
- raf.Seek(offReserved, System.IO.SeekOrigin.Begin);
- raf.Write(reserved, 0, reserved.Length);
- //SupportClass.RandomAccessFileSupport.WriteRandomFile(reserved, raf);
- }
-
-
- /// String representation of class
- public override System.String ToString()
- {
- System.Text.StringBuilder rep = new System.Text.StringBuilder("[ICCProfileHeader: ");
-
- rep.Append(eol + " ProfileSize: " + System.Convert.ToString(dwProfileSize, 16));
- rep.Append(eol + " CMMTypeSignature: " + System.Convert.ToString(dwCMMTypeSignature, 16));
- rep.Append(eol + " ProfileClass: " + System.Convert.ToString(dwProfileClass, 16));
- rep.Append(eol + " ColorSpaceType: " + System.Convert.ToString(dwColorSpaceType, 16));
- rep.Append(eol + " dwPCSType: " + System.Convert.ToString(dwPCSType, 16));
- rep.Append(eol + " dwProfileSignature: " + System.Convert.ToString(dwProfileSignature, 16));
- rep.Append(eol + " dwPlatformSignature: " + System.Convert.ToString(dwPlatformSignature, 16));
- rep.Append(eol + " dwCMMFlags: " + System.Convert.ToString(dwCMMFlags, 16));
- rep.Append(eol + "dwDeviceManufacturer: " + System.Convert.ToString(dwDeviceManufacturer, 16));
- rep.Append(eol + " dwDeviceModel: " + System.Convert.ToString(dwDeviceModel, 16));
- rep.Append(eol + " dwDeviceAttributes1: " + System.Convert.ToString(dwDeviceAttributes1, 16));
- rep.Append(eol + " dwRenderingIntent: " + System.Convert.ToString(dwRenderingIntent, 16));
- rep.Append(eol + " dwCreatorSig: " + System.Convert.ToString(dwCreatorSig, 16));
- rep.Append(eol + " profileVersion: " + profileVersion);
- rep.Append(eol + " dateTime: " + dateTime);
- rep.Append(eol + " PCSIlluminant: " + PCSIlluminant);
- return rep.Append("]").ToString();
- }
-
- /* end class ICCProfileHeader */
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/Icc/Types/ICCProfileVersion.cs b/CSJ2K/Icc/Types/ICCProfileVersion.cs
deleted file mode 100644
index c1df9347..00000000
--- a/CSJ2K/Icc/Types/ICCProfileVersion.cs
+++ /dev/null
@@ -1,66 +0,0 @@
-/// **************************************************************************
-///
-/// $Id: ICCProfileVersion.java,v 1.1 2002/07/25 14:56:31 grosbois Exp $
-///
-/// Copyright Eastman Kodak Company, 343 State Street, Rochester, NY 14650
-/// $Date $
-/// ***************************************************************************
-///
-namespace CSJ2K.Icc.Types
-{
-
- /// This class describes the ICCProfile Version as contained in
- /// the header of the ICC Profile.
- ///
- ///
- ///
- ///
- ///
- ///
- /// 1.0
- ///
- /// Bruce A. Kern
- ///
- public class ICCProfileVersion
- {
- /// Field size
- //UPGRADE_NOTE: Final was removed from the declaration of 'size '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- //UPGRADE_NOTE: The initialization of 'size' was moved to static method 'icc.types.ICCProfileVersion'. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1005'"
- public static readonly int size;
-
- /// Major revision number in binary coded decimal
- public byte uMajor;
- /// Minor revision in high nibble, bug fix revision
- /// in low nibble, both in binary coded decimal
- ///
- public byte uMinor;
-
- private byte reserved1;
- private byte reserved2;
-
- /// Construct from constituent parts.
- public ICCProfileVersion(byte major, byte minor, byte res1, byte res2)
- {
- uMajor = major; uMinor = minor; reserved1 = res1; reserved2 = res2;
- }
-
- /// Construct from file content.
- //UPGRADE_TODO: Class 'java.io.RandomAccessFile' was converted to 'System.IO.FileStream' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaioRandomAccessFile'"
- public virtual void write(System.IO.FileStream raf)
- {
- raf.WriteByte(uMajor); raf.WriteByte(uMinor); raf.WriteByte(reserved1); raf.WriteByte(reserved2);
- }
-
- /// String representation of class instance.
- public override System.String ToString()
- {
- return "Version " + uMajor + "." + uMinor;
- }
-
- /* end class ICCProfileVersion */
- static ICCProfileVersion()
- {
- size = 4 * ICCProfile.byte_size;
- }
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/Icc/Types/XYZNumber.cs b/CSJ2K/Icc/Types/XYZNumber.cs
deleted file mode 100644
index 17e91501..00000000
--- a/CSJ2K/Icc/Types/XYZNumber.cs
+++ /dev/null
@@ -1,84 +0,0 @@
-/// **************************************************************************
-///
-/// $Id: XYZNumber.java,v 1.1 2002/07/25 14:56:31 grosbois Exp $
-///
-/// Copyright Eastman Kodak Company, 343 State Street, Rochester, NY 14650
-/// $Date $
-/// ***************************************************************************
-///
-namespace CSJ2K.Icc.Types
-{
-
- /// A convientient representation for the contents of the
- /// ICCXYZTypeTag class.
- ///
- ///
- ///
- ///
- /// 1.0
- ///
- /// Bruce A. Kern
- ///
- public class XYZNumber
- {
- //UPGRADE_NOTE: Final was removed from the declaration of 'size '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- //UPGRADE_NOTE: The initialization of 'size' was moved to static method 'icc.types.XYZNumber'. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1005'"
- public static readonly int size;
-
- /// x value
- public int dwX;
- /// y value
- // X tristimulus value
- public int dwY;
- /// z value
- // Y tristimulus value
- public int dwZ; // Z tristimulus value
-
- /// Construct from constituent parts.
- public XYZNumber(int x, int y, int z)
- {
- dwX = x; dwY = y; dwZ = z;
- }
-
- /// Normalization utility
- public static int DoubleToXYZ(double x)
- {
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- return (int)System.Math.Floor(x * 65536.0 + 0.5);
- }
-
- /// Normalization utility
- public static double XYZToDouble(int x)
- {
- return (double)x / 65536.0;
- }
-
- /// Write to a file
- //UPGRADE_TODO: Class 'java.io.RandomAccessFile' was converted to 'System.IO.FileStream' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaioRandomAccessFile'"
- public virtual void write(System.IO.FileStream raf)
- {
- System.IO.BinaryWriter temp_BinaryWriter;
- temp_BinaryWriter = new System.IO.BinaryWriter(raf);
- temp_BinaryWriter.Write((System.Int32)dwX);
- System.IO.BinaryWriter temp_BinaryWriter2;
- temp_BinaryWriter2 = new System.IO.BinaryWriter(raf);
- temp_BinaryWriter2.Write((System.Int32)dwY);
- System.IO.BinaryWriter temp_BinaryWriter3;
- temp_BinaryWriter3 = new System.IO.BinaryWriter(raf);
- temp_BinaryWriter3.Write((System.Int32)dwZ);
- }
-
- /// String representation of class instance.
- public override System.String ToString()
- {
- return "[" + dwX + ", " + dwY + ", " + dwZ + "]";
- }
-
-
- /* end class XYZNumber */
- static XYZNumber()
- {
- size = 3 * ICCProfile.int_size;
- }
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/J2KEncoder.cs b/CSJ2K/J2KEncoder.cs
deleted file mode 100644
index d47b69e1..00000000
--- a/CSJ2K/J2KEncoder.cs
+++ /dev/null
@@ -1,226 +0,0 @@
-#region Using Statements
-using CSJ2K.j2k.codestream.writer;
-using CSJ2K.j2k.encoder;
-using CSJ2K.j2k.entropy.encoder;
-using CSJ2K.j2k.image;
-using CSJ2K.j2k.image.forwcomptransf;
-using CSJ2K.j2k.image.input;
-using CSJ2K.j2k.quantization.quantizer;
-using CSJ2K.j2k.roi.encoder;
-using CSJ2K.j2k.util;
-using CSJ2K.j2k.wavelet.analysis;
-using System;
-using System.Collections.Generic;
-using System.Drawing;
-using System.IO;
-#endregion
-
-namespace CSJ2K
-{
- public static class J2KEncoder
- {
- #region Default Encoding Parameters
-
- private readonly static string[][] pinfo = {
- new string[] { "debug", null,
- "Print debugging messages when an error is encountered.","off"},
- new string[] { "disable_jp2_extension", "[on|off]",
- "JJ2000 automatically adds .jp2 extension when using 'file_format'"+
- "option. This option disables it when on.", "off"},
- new string[] { "file_format", "[on|off]",
- "Puts the JPEG 2000 codestream in a JP2 file format wrapper.","off"},
- new string[] { "pph_tile", "[on|off]",
- "Packs the packet headers in the tile headers.","off"},
- new string[] { "pph_main", "[on|off]",
- "Packs the packet headers in the main header.","off"},
- new string[] { "pfile", "",
- "Loads the arguments from the specified file. Arguments that are "+
- "specified on the command line override the ones from the file.\n"+
- "The arguments file is a simple text file with one argument per "+
- "line of the following form:\n" +
- " =\n"+
- "If the argument is of boolean type (i.e. its presence turns a "+
- "feature on), then the 'on' value turns it on, while the 'off' "+
- "value turns it off. The argument name does not include the '-' "+
- "or '+' character. Long lines can be broken into several lines "+
- "by terminating them with '\'. Lines starting with '#' are "+
- "considered as comments. This option is not recursive: any 'pfile' "+
- "argument appearing in the file is ignored.",null},
- new string[] { "tile_parts", "",
- "This option specifies the maximum number of packets to have in "+
- "one tile-part. 0 means include all packets in first tile-part "+
- "of each tile","0"},
- new string[] { "tiles", " ",
- "This option specifies the maximum tile dimensions to use. "+
- "If both dimensions are 0 then no tiling is used.","0 0"},
- new string[] { "ref", " ",
- "Sets the origin of the image in the canvas system. It sets the "+
- "coordinate of the top-left corner of the image reference grid, "+
- "with respect to the canvas origin","0 0"},
- new string[] { "tref", " ",
- "Sets the origin of the tile partitioning on the reference grid, "+
- "with respect to the canvas origin. The value of 'x' ('y') "+
- "specified can not be larger than the 'x' one specified in the ref "+
- "option.","0 0"},
- new string[] { "rate", "
- ///
- ///
- public class ModuleSpec : System.ICloneable
- {
- virtual public ModuleSpec Copy
- {
- get
- {
- return (ModuleSpec)this.Clone();
- }
-
- }
-
- /// The identifier for a specification module that applies only to
- /// components
- ///
- public const byte SPEC_TYPE_COMP = 0;
-
- /// The identifier for a specification module that applies only to tiles
- public const byte SPEC_TYPE_TILE = 1;
-
- /// The identifier for a specification module that applies both to tiles
- /// and components
- ///
- public const byte SPEC_TYPE_TILE_COMP = 2;
-
- /// The identifier for default specification
- public const byte SPEC_DEF = 0;
-
- /// The identifier for "component default" specification
- public const byte SPEC_COMP_DEF = 1;
-
- /// The identifier for "tile default" specification
- public const byte SPEC_TILE_DEF = 2;
-
- /// The identifier for a "tile-component" specification
- public const byte SPEC_TILE_COMP = 3;
-
- /// The type of the specification module
- protected internal int specType;
-
- /// The number of tiles
- protected internal int nTiles = 0;
-
- /// The number of components
- protected internal int nComp = 0;
-
- /// The spec type for each tile-component. The first index is the tile
- /// index, the second is the component index.
- ///
- protected internal byte[][] specValType;
-
- /// Default value for each tile-component
- protected internal System.Object def = null;
-
- /// The default value for each component. Null if no component
- /// specific value is defined
- ///
- protected internal System.Object[] compDef = null;
-
- /// The default value for each tile. Null if no tile specific value is
- /// defined
- ///
- protected internal System.Object[] tileDef = null;
-
- /// The specific value for each tile-component. Value of tile 16 component
- /// 3 is accessible through the hash value "t16c3". Null if no
- /// tile-component specific value is defined
- ///
- protected internal System.Collections.Hashtable tileCompVal;
-
- public virtual System.Object Clone()
- {
- ModuleSpec ms;
- try
- {
- ms = (ModuleSpec)base.MemberwiseClone();
- }
- //UPGRADE_NOTE: Exception 'java.lang.CloneNotSupportedException' was converted to 'System.Exception' which has different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1100'"
- catch (System.Exception)
- {
- throw new System.ApplicationException("Error when cloning ModuleSpec instance");
- }
- // Create a copy of the specValType array
- ms.specValType = new byte[nTiles][];
- for (int i = 0; i < nTiles; i++)
- {
- ms.specValType[i] = new byte[nComp];
- }
- for (int t = 0; t < nTiles; t++)
- {
- for (int c = 0; c < nComp; c++)
- {
- ms.specValType[t][c] = specValType[t][c];
- }
- }
- // Create a copy of tileDef
- if (tileDef != null)
- {
- ms.tileDef = new System.Object[nTiles];
- for (int t = 0; t < nTiles; t++)
- {
- ms.tileDef[t] = tileDef[t];
- }
- }
- // Create a copy of tileCompVal
- if (tileCompVal != null)
- {
- ms.tileCompVal = System.Collections.Hashtable.Synchronized(new System.Collections.Hashtable());
- System.String tmpKey;
- System.Object tmpVal;
- //UPGRADE_TODO: Method 'java.util.Enumeration.hasMoreElements' was converted to 'System.Collections.IEnumerator.MoveNext' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilEnumerationhasMoreElements'"
- for (System.Collections.IEnumerator e = tileCompVal.Keys.GetEnumerator(); e.MoveNext();)
- {
- //UPGRADE_TODO: Method 'java.util.Enumeration.nextElement' was converted to 'System.Collections.IEnumerator.Current' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilEnumerationnextElement'"
- tmpKey = ((System.String)e.Current);
- tmpVal = tileCompVal[tmpKey];
- ms.tileCompVal[tmpKey] = tmpVal;
- }
- }
- return ms;
- }
-
- /// Rotate the ModuleSpec instance by 90 degrees (this modifies only tile
- /// and tile-component specifications).
- ///
- ///
- /// Number of tiles along horizontal and vertical axis after
- /// rotation.
- ///
- ///
- public virtual void rotate90(Coord anT)
- {
- // Rotate specValType
- byte[][] tmpsvt = new byte[nTiles][];
- int ax, ay;
- Coord bnT = new Coord(anT.y, anT.x);
- for (int by = 0; by < bnT.y; by++)
- {
- for (int bx = 0; bx < bnT.x; bx++)
- {
- ay = bx;
- ax = bnT.y - by - 1;
- tmpsvt[ay * anT.x + ax] = specValType[by * bnT.x + bx];
- }
- }
- specValType = tmpsvt;
-
- // Rotate tileDef
- if (tileDef != null)
- {
- System.Object[] tmptd = new System.Object[nTiles];
- for (int by = 0; by < bnT.y; by++)
- {
- for (int bx = 0; bx < bnT.x; bx++)
- {
- ay = bx;
- ax = bnT.y - by - 1;
- tmptd[ay * anT.x + ax] = tileDef[by * bnT.x + bx];
- }
- }
- tileDef = tmptd;
- }
-
- // Rotate tileCompVal
- if (tileCompVal != null && tileCompVal.Count > 0)
- {
- System.Collections.Hashtable tmptcv = System.Collections.Hashtable.Synchronized(new System.Collections.Hashtable());
- System.String tmpKey;
- System.Object tmpVal;
- int btIdx, atIdx;
- int i1, i2;
- int bx, by;
- //UPGRADE_TODO: Method 'java.util.Enumeration.hasMoreElements' was converted to 'System.Collections.IEnumerator.MoveNext' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilEnumerationhasMoreElements'"
- for (System.Collections.IEnumerator e = tileCompVal.Keys.GetEnumerator(); e.MoveNext();)
- {
- //UPGRADE_TODO: Method 'java.util.Enumeration.nextElement' was converted to 'System.Collections.IEnumerator.Current' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilEnumerationnextElement'"
- tmpKey = ((System.String)e.Current);
- tmpVal = tileCompVal[tmpKey];
- i1 = tmpKey.IndexOf('t');
- i2 = tmpKey.IndexOf('c');
- btIdx = (System.Int32.Parse(tmpKey.Substring(i1 + 1, (i2) - (i1 + 1))));
- bx = btIdx % bnT.x;
- by = btIdx / bnT.x;
- ay = bx;
- ax = bnT.y - by - 1;
- atIdx = ax + ay * anT.x;
- tmptcv["t" + atIdx + tmpKey.Substring(i2)] = tmpVal;
- }
- tileCompVal = tmptcv;
- }
- }
-
- /// Constructs a 'ModuleSpec' object, initializing all the components and
- /// tiles to the 'SPEC_DEF' spec val type, for the specified number of
- /// components and tiles.
- ///
- ///
- /// The number of tiles
- ///
- ///
- /// The number of components
- ///
- ///
- /// the type of the specification module i.e. tile specific,
- /// component specific or both.
- ///
- ///
- public ModuleSpec(int nt, int nc, byte type)
- {
- nTiles = nt;
- nComp = nc;
- specValType = new byte[nt][];
- for (int i = 0; i < nt; i++)
- {
- specValType[i] = new byte[nc];
- }
- switch (type)
- {
-
- case SPEC_TYPE_TILE:
- specType = SPEC_TYPE_TILE;
- break;
-
- case SPEC_TYPE_COMP:
- specType = SPEC_TYPE_COMP;
- break;
-
- case SPEC_TYPE_TILE_COMP:
- specType = SPEC_TYPE_TILE_COMP;
- break;
- }
- }
-
- /// Sets default value for this module
- ///
- ///
- public virtual void setDefault(System.Object value_Renamed)
- {
- def = value_Renamed;
- }
-
- /// Gets default value for this module.
- ///
- ///
- /// The default value (Must be casted before use)
- ///
- ///
- public virtual System.Object getDefault()
- {
- return def;
- }
-
- /// Sets default value for specified component and specValType tag if
- /// allowed by its priority.
- ///
- ///
- /// Component index
- ///
- ///
- public virtual void setCompDef(int c, System.Object value_Renamed)
- {
- if (specType == SPEC_TYPE_TILE)
- {
- //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Object.toString' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'"
- System.String errMsg = "Option whose value is '" + value_Renamed + "' cannot be " + "specified for components as it is a 'tile only' specific " + "option";
- throw new System.ApplicationException(errMsg);
- }
- if (compDef == null)
- {
- compDef = new System.Object[nComp];
- }
- for (int i = 0; i < nTiles; i++)
- {
- if (specValType[i][c] < SPEC_COMP_DEF)
- {
- specValType[i][c] = SPEC_COMP_DEF;
- }
- }
- compDef[c] = value_Renamed;
- }
-
- /// Gets default value of the specified component. If no specification have
- /// been entered for this component, returns default value.
- ///
- ///
- /// Component index
- ///
- ///
- /// The default value for this component (Must be casted before
- /// use)
- ///
- ///
- ///
- ///
- ///
- public virtual System.Object getCompDef(int c)
- {
- if (specType == SPEC_TYPE_TILE)
- {
- throw new System.ApplicationException("Illegal use of ModuleSpec class");
- }
- if (compDef == null || compDef[c] == null)
- {
- return getDefault();
- }
- else
- {
- return compDef[c];
- }
- }
-
- /// Sets default value for specified tile and specValType tag if allowed by
- /// its priority.
- ///
- ///
- /// Tile index.
- ///
- ///
- public virtual void setTileDef(int t, System.Object value_Renamed)
- {
- if (specType == SPEC_TYPE_COMP)
- {
- //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Object.toString' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'"
- System.String errMsg = "Option whose value is '" + value_Renamed + "' cannot be " + "specified for tiles as it is a 'component only' specific " + "option";
- throw new System.ApplicationException(errMsg);
- }
- if (tileDef == null)
- {
- tileDef = new System.Object[nTiles];
- }
- for (int i = 0; i < nComp; i++)
- {
- if (specValType[t][i] < SPEC_TILE_DEF)
- {
- specValType[t][i] = SPEC_TILE_DEF;
- }
- }
- tileDef[t] = value_Renamed;
- }
-
- /// Gets default value of the specified tile. If no specification has been
- /// entered, it returns the default value.
- ///
- ///
- /// Tile index
- ///
- ///
- /// The default value for this tile (Must be casted before use)
- ///
- ///
- ///
- ///
- ///
- public virtual System.Object getTileDef(int t)
- {
- if (specType == SPEC_TYPE_COMP)
- {
- throw new System.ApplicationException("Illegal use of ModuleSpec class");
- }
- if (tileDef == null || tileDef[t] == null)
- {
- return getDefault();
- }
- else
- {
- return tileDef[t];
- }
- }
-
- /// Sets value for specified tile-component.
- ///
- ///
- /// Tie index
- ///
- ///
- /// Component index
- ///
- ///
- public virtual void setTileCompVal(int t, int c, System.Object value_Renamed)
- {
- if (specType != SPEC_TYPE_TILE_COMP)
- {
- //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Object.toString' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'"
- System.String errMsg = "Option whose value is '" + value_Renamed + "' cannot be " + "specified for ";
- switch (specType)
- {
-
- case SPEC_TYPE_TILE:
- errMsg += "components as it is a 'tile only' specific option";
- break;
-
- case SPEC_TYPE_COMP:
- errMsg += "tiles as it is a 'component only' specific option";
- break;
- }
- throw new System.ApplicationException(errMsg);
- }
- if (tileCompVal == null)
- tileCompVal = System.Collections.Hashtable.Synchronized(new System.Collections.Hashtable());
- specValType[t][c] = SPEC_TILE_COMP;
- tileCompVal["t" + t + "c" + c] = value_Renamed;
- }
-
- /// Gets value of specified tile-component. This method calls getSpec but
- /// has a public access.
- ///
- ///
- /// Tile index
- ///
- ///
- /// Component index
- ///
- ///
- /// The value of this tile-component (Must be casted before use)
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- public virtual System.Object getTileCompVal(int t, int c)
- {
- if (specType != SPEC_TYPE_TILE_COMP)
- {
- throw new System.ApplicationException("Illegal use of ModuleSpec class");
- }
- return getSpec(t, c);
- }
-
- /// Gets value of specified tile-component without knowing if a specific
- /// tile-component value has been previously entered. It first check if a
- /// tile-component specific value has been entered, then if a tile specific
- /// value exist, then if a component specific value exist. If not the
- /// default value is returned.
- ///
- ///
- /// Tile index
- ///
- ///
- /// Component index
- ///
- ///
- /// Value for this tile component.
- ///
- ///
- protected internal virtual System.Object getSpec(int t, int c)
- {
- switch (specValType[t][c])
- {
-
- case SPEC_DEF:
- return getDefault();
-
- case SPEC_COMP_DEF:
- return getCompDef(c);
-
- case SPEC_TILE_DEF:
- return getTileDef(t);
-
- case SPEC_TILE_COMP:
- return tileCompVal["t" + t + "c" + c];
-
- default:
- throw new System.ArgumentException("Not recognized spec type");
-
- }
- }
-
- /// Return the spec type of the given tile-component.
- ///
- ///
- /// Tile index
- ///
- ///
- /// Component index
- ///
- ///
- public virtual byte getSpecValType(int t, int c)
- {
- return specValType[t][c];
- }
-
- /// Whether or not specifications have been entered for the given
- /// component.
- ///
- ///
- /// Index of the component
- ///
- ///
- /// True if component specification has been defined
- ///
- ///
- public virtual bool isCompSpecified(int c)
- {
- if (compDef == null || compDef[c] == null)
- {
- return false;
- }
- else
- {
- return true;
- }
- }
-
- /// Whether or not specifications have been entered for the given tile.
- ///
- ///
- /// Index of the tile
- ///
- ///
- /// True if tile specification has been entered
- ///
- ///
- public virtual bool isTileSpecified(int t)
- {
- if (tileDef == null || tileDef[t] == null)
- {
- return false;
- }
- else
- {
- return true;
- }
- }
-
- /// Whether or not a tile-component specification has been defined
- ///
- ///
- /// Tile index
- ///
- ///
- /// Component index
- ///
- ///
- /// True if a tile-component specification has been defined.
- ///
- ///
- public virtual bool isTileCompSpecified(int t, int c)
- {
- if (tileCompVal == null || tileCompVal["t" + t + "c" + c] == null)
- {
- return false;
- }
- else
- {
- return true;
- }
- }
-
- /// This method is responsible of parsing tile indexes set and component
- /// indexes set for an option. Such an argument must follow the following
- /// policy:
- ///
- /// t<indexes set> or c<indexes set> where
- /// tile or component indexes are separated by commas or a dashes.
- ///
- /// Example:
- ///
t0,3,4 means tiles with indexes 0, 3 and 4.
- /// t2-4 means tiles with indexes 2,3 and 4.
- ///
- /// It returns a boolean array skteching which tile or component are
- /// concerned by the next parameters.
- ///
- ///
- /// The word to parse.
- ///
- ///
- /// Maximum authorized index
- ///
- ///
- /// Indexes concerned by this parameter.
- ///
- ///
- public static bool[] parseIdx(System.String word, int maxIdx)
- {
- int nChar = word.Length; // Number of characters
- char c = word[0]; // current character
- int idx = -1; // Current (tile or component) index
- int lastIdx = -1; // Last (tile or component) index
- bool isDash = false; // Whether or not last separator was a dash
-
- bool[] idxSet = new bool[maxIdx];
- int i = 1; // index of the current character
-
- while (i < nChar)
- {
- c = word[i];
- if (System.Char.IsDigit(c))
- {
- if (idx == -1)
- {
- idx = 0;
- }
- idx = idx * 10 + (c - '0');
- }
- else
- {
- if (idx == -1 || (c != ',' && c != '-'))
- {
- throw new System.ArgumentException("Bad construction for " + "parameter: " + word);
- }
- if (idx < 0 || idx >= maxIdx)
- {
- throw new System.ArgumentException("Out of range index " + "in " + "parameter `" + word + "' : " + idx);
- }
-
- // Found a comma
- if (c == ',')
- {
- if (isDash)
- {
- // Previously found a dash, fill idxSet
- for (int j = lastIdx + 1; j < idx; j++)
- {
- idxSet[j] = true;
- }
- }
- isDash = false;
- }
- else
- {
- // Found a dash
- isDash = true;
- }
-
- // Udate idxSet
- idxSet[idx] = true;
- lastIdx = idx;
- idx = -1;
- }
- i++;
- }
-
- // Process last found index
- if (idx < 0 || idx >= maxIdx)
- {
- throw new System.ArgumentException("Out of range index in " + "parameter `" + word + "' : " + idx);
- }
- if (isDash)
- {
- for (int j = lastIdx + 1; j < idx; j++)
- {
- idxSet[j] = true;
- }
- }
- idxSet[idx] = true;
-
- return idxSet;
- }
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/NoNextElementException.cs b/CSJ2K/j2k/NoNextElementException.cs
deleted file mode 100644
index 1b2b1fa5..00000000
--- a/CSJ2K/j2k/NoNextElementException.cs
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
-* CVS identifier:
-*
-* $Id: NoNextElementException.java,v 1.9 2000/09/05 09:22:12 grosbois Exp $
-*
-* Class: NoNextElementException
-*
-* Description: Exception to indicate that there is no next
-* element.
-*
-*
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-*
-*
-*
-*/
-using System;
-namespace CSJ2K.j2k
-{
-
- /// This exception is thrown whenever a next???? method is called and
- /// there is no next element to return.
- ///
- ///
- [Serializable]
- public class NoNextElementException : System.SystemException
- {
-
- /// Constructs a new NoNextElementException exception with no
- /// detail message.
- ///
- ///
- ///
- public NoNextElementException() : base()
- {
- }
-
- /// Constructs a new NoNextElementException exception with
- /// the specified detail message.
- ///
- ///
- /// The detail message.
- ///
- ///
- ///
- public NoNextElementException(System.String s) : base(s)
- {
- }
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/StringSpec.cs b/CSJ2K/j2k/StringSpec.cs
deleted file mode 100644
index 311c20d5..00000000
--- a/CSJ2K/j2k/StringSpec.cs
+++ /dev/null
@@ -1,276 +0,0 @@
-/*
-* CVS identifier:
-*
-* $Id: StringSpec.java,v 1.17 2000/11/30 13:14:07 grosbois Exp $
-*
-* Class: StringSpec
-*
-* Description: String specification for an option
-*
-*
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-* */
-using CSJ2K.j2k.util;
-namespace CSJ2K.j2k
-{
-
- /// This class extends ModuleSpec class in order to hold tile-component
- /// specifications using Strings.
- ///
- ///
- ///
- ///
- ///
- public class StringSpec : ModuleSpec
- {
-
- /// Constructs an empty 'StringSpec' with specified number of
- /// tile and components. This constructor is called by the decoder.
- ///
- ///
- /// Number of tiles
- ///
- ///
- /// Number of components
- ///
- ///
- /// the type of the specification module i.e. tile specific,
- /// component specific or both.
- ///
- ///
- public StringSpec(int nt, int nc, byte type) : base(nt, nc, type)
- {
- }
-
- /// Constructs a new 'StringSpec' for the specified number of
- /// components:tiles and the arguments of optName
- /// option. This constructor is called by the encoder. It also
- /// checks that the arguments belongs to the recognized arguments
- /// list.
- ///
- /// Note: The arguments must not start with 't' or 'c'
- /// since it is reserved for respectively tile and components
- /// indexes specification.
- ///
- ///
- /// The number of tiles
- ///
- ///
- /// The number of components
- ///
- ///
- /// the type of the specification module i.e. tile specific,
- /// component specific or both.
- ///
- ///
- /// of the option using boolean spec.
- ///
- ///
- /// The list of all recognized argument in a String array
- ///
- ///
- /// The ParameterList
- ///
- ///
- public StringSpec(int nt, int nc, byte type, System.String optName, System.String[] list, ParameterList pl) : base(nt, nc, type)
- {
-
- System.String param = pl.getParameter(optName);
- bool recognized = false;
-
- if (param == null)
- {
- param = pl.DefaultParameterList.getParameter(optName);
- for (int i = list.Length - 1; i >= 0; i--)
- if (param.ToUpper().Equals(list[i].ToUpper()))
- recognized = true;
- if (!recognized)
- throw new System.ArgumentException("Default parameter of " + "option -" + optName + " not" + " recognized: " + param);
- setDefault(param);
- return;
- }
-
- // Parse argument
- SupportClass.Tokenizer stk = new SupportClass.Tokenizer(param);
- System.String word; // current word
- byte curSpecType = SPEC_DEF; // Specification type of the
- // current parameter
- bool[] tileSpec = null; // Tiles concerned by the
- // specification
- bool[] compSpec = null; // Components concerned by the specification
- //System.Boolean value_Renamed;
-
- while (stk.HasMoreTokens())
- {
- word = stk.NextToken();
-
- switch (word[0])
- {
-
- case 't': // Tiles specification
- tileSpec = parseIdx(word, nTiles);
- if (curSpecType == SPEC_COMP_DEF)
- {
- curSpecType = SPEC_TILE_COMP;
- }
- else
- {
- curSpecType = SPEC_TILE_DEF;
- }
- break;
-
- case 'c': // Components specification
- compSpec = parseIdx(word, nComp);
- if (curSpecType == SPEC_TILE_DEF)
- {
- curSpecType = SPEC_TILE_COMP;
- }
- else
- curSpecType = SPEC_COMP_DEF;
- break;
-
- default:
- recognized = false;
-
- for (int i = list.Length - 1; i >= 0; i--)
- if (word.ToUpper().Equals(list[i].ToUpper()))
- recognized = true;
- if (!recognized)
- throw new System.ArgumentException("Default parameter of " + "option -" + optName + " not" + " recognized: " + word);
-
- if (curSpecType == SPEC_DEF)
- {
- setDefault(word);
- }
- else if (curSpecType == SPEC_TILE_DEF)
- {
- for (int i = tileSpec.Length - 1; i >= 0; i--)
- if (tileSpec[i])
- {
- setTileDef(i, word);
- }
- }
- else if (curSpecType == SPEC_COMP_DEF)
- {
- for (int i = compSpec.Length - 1; i >= 0; i--)
- if (compSpec[i])
- {
- setCompDef(i, word);
- }
- }
- else
- {
- for (int i = tileSpec.Length - 1; i >= 0; i--)
- {
- for (int j = compSpec.Length - 1; j >= 0; j--)
- {
- if (tileSpec[i] && compSpec[j])
- {
- setTileCompVal(i, j, word);
- }
- }
- }
- }
-
- // Re-initialize
- curSpecType = SPEC_DEF;
- tileSpec = null;
- compSpec = null;
- break;
-
- }
- }
-
- // Check that default value has been specified
- if (getDefault() == null)
- {
- int ndefspec = 0;
- for (int t = nt - 1; t >= 0; t--)
- {
- for (int c = nc - 1; c >= 0; c--)
- {
- if (specValType[t][c] == SPEC_DEF)
- {
- ndefspec++;
- }
- }
- }
-
- // If some tile-component have received no specification, it takes
- // the default value defined in ParameterList
- if (ndefspec != 0)
- {
- param = pl.DefaultParameterList.getParameter(optName);
- for (int i = list.Length - 1; i >= 0; i--)
- if (param.ToUpper().Equals(list[i].ToUpper()))
- recognized = true;
- if (!recognized)
- throw new System.ArgumentException("Default parameter of " + "option -" + optName + " not" + " recognized: " + param);
- setDefault(param);
- }
- else
- {
- // All tile-component have been specified, takes the first
- // tile-component value as default.
- setDefault(getSpec(0, 0));
- switch (specValType[0][0])
- {
-
- case SPEC_TILE_DEF:
- for (int c = nc - 1; c >= 0; c--)
- {
- if (specValType[0][c] == SPEC_TILE_DEF)
- specValType[0][c] = SPEC_DEF;
- }
- tileDef[0] = null;
- break;
-
- case SPEC_COMP_DEF:
- for (int t = nt - 1; t >= 0; t--)
- {
- if (specValType[t][0] == SPEC_COMP_DEF)
- specValType[t][0] = SPEC_DEF;
- }
- compDef[0] = null;
- break;
-
- case SPEC_TILE_COMP:
- specValType[0][0] = SPEC_DEF;
- tileCompVal["t0c0"] = null;
- break;
- }
- }
- }
- }
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/codestream/CBlkCoordInfo.cs b/CSJ2K/j2k/codestream/CBlkCoordInfo.cs
deleted file mode 100644
index bb16675d..00000000
--- a/CSJ2K/j2k/codestream/CBlkCoordInfo.cs
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
-* CVS identifier:
-*
-* $Id: CBlkCoordInfo.java,v 1.9 2001/09/14 09:32:53 grosbois Exp $
-*
-* Class: CBlkCoordInfo
-*
-* Description: Used to store the code-blocks coordinates.
-*
-*
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-* */
-using CSJ2K.j2k.image;
-namespace CSJ2K.j2k.codestream
-{
-
- /// This class is used to store the coordinates of code-blocks.
- ///
- ///
- public class CBlkCoordInfo : CoordInfo
- {
-
- /// The code-block horizontal and vertical indexes
- public Coord idx;
-
- /// Constructor. Creates a CBlkCoordInfo object.
- ///
- ///
- public CBlkCoordInfo()
- {
- this.idx = new Coord();
- }
-
- /// Constructor. Creates a CBlkCoordInfo object width specified code-block
- /// vertical and horizontal indexes.
- ///
- ///
- /// Code-block vertical index.
- ///
- ///
- /// Code-block horizontal index.
- ///
- ///
- public CBlkCoordInfo(int m, int n)
- {
- this.idx = new Coord(n, m);
- }
-
- /// Returns code-block's information in a String
- ///
- ///
- /// String with code-block's information
- ///
- ///
- public override System.String ToString()
- {
- return base.ToString() + ",idx=" + idx;
- }
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/codestream/CoordInfo.cs b/CSJ2K/j2k/codestream/CoordInfo.cs
deleted file mode 100644
index 43aaf6ef..00000000
--- a/CSJ2K/j2k/codestream/CoordInfo.cs
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
-* CVS identifier:
-*
-* $Id: CoordInfo.java,v 1.10 2001/09/14 09:32:11 grosbois Exp $
-*
-* Class: CoordInfo
-*
-* Description: Used to store the coordinates of code-blocks/packets
-*
-*
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-* */
-namespace CSJ2K.j2k.codestream
-{
-
- /// This class is used to store the coordinates of objects such as code-blocks
- /// or precincts. As this is an abstract class, it cannot be used directly but
- /// derived classes have been created for code-blocks and packets
- /// (CBlkCoordInfo and PrecCoordInfo).
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- public abstract class CoordInfo
- {
-
- /// Horizontal upper left coordinate in the subband
- public int ulx;
-
- /// Vertical upper left coordinate in the subband
- public int uly;
-
- /// Object's width
- public int w;
-
- /// Object's height
- public int h;
-
- /// Constructor. Creates a CoordInfo object.
- ///
- ///
- /// The horizontal upper left coordinate in the subband
- ///
- ///
- /// The vertical upper left coordinate in the subband
- ///
- ///
- /// The width
- ///
- ///
- /// The height
- ///
- ///
- /// The object's index
- ///
- ///
- public CoordInfo(int ulx, int uly, int w, int h)
- {
- this.ulx = ulx;
- this.uly = uly;
- this.w = w;
- this.h = h;
- }
-
- /// Empty contructor
- public CoordInfo()
- {
- }
-
- /// Returns object's information in a String
- ///
- ///
- /// String with object's information
- ///
- ///
- public override System.String ToString()
- {
- return "ulx=" + ulx + ",uly=" + uly + ",w=" + w + ",h=" + h;
- }
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/codestream/CorruptedCodestreamException.cs b/CSJ2K/j2k/codestream/CorruptedCodestreamException.cs
deleted file mode 100644
index f2cd0593..00000000
--- a/CSJ2K/j2k/codestream/CorruptedCodestreamException.cs
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
-* CVS identifier:
-*
-* $Id: CorruptedCodestreamException.java,v 1.6 2000/09/05 09:22:33 grosbois
-* Exp $
-*
-* Class: CorruptedCodestreamException
-*
-* Description: Exception thrown when illegal bit stream
-* values are decoded.
-*
-*
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-* */
-using System;
-namespace CSJ2K.j2k.codestream
-{
-
- /// This exception is thrown whenever an illegal value is read from a bit
- /// stream. The cause can be either a corrupted bit stream, or a a bit stream
- /// which is illegal.
- ///
- ///
- [Serializable]
- public class CorruptedCodestreamException : System.IO.IOException
- {
-
- /// Constructs a new CorruptedCodestreamException exception with
- /// no detail message.
- ///
- ///
- public CorruptedCodestreamException() : base()
- {
- }
-
- /// Constructs a new CorruptedCodestreamException exception with
- /// the specified detail message.
- ///
- ///
- /// The detail message.
- ///
- ///
- public CorruptedCodestreamException(System.String s) : base(s)
- {
- }
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/codestream/HeaderInfo.cs b/CSJ2K/j2k/codestream/HeaderInfo.cs
deleted file mode 100644
index 917ca577..00000000
--- a/CSJ2K/j2k/codestream/HeaderInfo.cs
+++ /dev/null
@@ -1,1368 +0,0 @@
-/*
-* CVS identifier:
-*
-* $Id: HeaderInfo.java,v 1.3 2001/10/26 16:30:33 grosbois Exp $
-*
-* Class: HeaderInfo
-*
-* Description: Holds information found in main and tile-part
-* headers
-*
-*
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-* */
-using CSJ2K.j2k.wavelet;
-namespace CSJ2K.j2k.codestream
-{
-
- /// Classe that holds information found in the marker segments of the main and
- /// tile-part headers. There is one inner-class per marker segment type found
- /// in these headers.
- ///
- ///
- public class HeaderInfo : FilterTypes, System.ICloneable
- {
- /// Returns a new instance of SIZ
- virtual public SIZ NewSIZ
- {
- get
- {
- return new SIZ(this);
- }
-
- }
- /// Returns a new instance of SOT
- virtual public SOT NewSOT
- {
- get
- {
- return new SOT(this);
- }
-
- }
- /// Returns a new instance of COD
- virtual public COD NewCOD
- {
- get
- {
- return new COD(this);
- }
-
- }
- /// Returns a new instance of COC
- virtual public COC NewCOC
- {
- get
- {
- return new COC(this);
- }
-
- }
- /// Returns a new instance of RGN
- virtual public RGN NewRGN
- {
- get
- {
- return new RGN(this);
- }
-
- }
- /// Returns a new instance of QCD
- virtual public QCD NewQCD
- {
- get
- {
- return new QCD(this);
- }
-
- }
- /// Returns a new instance of QCC
- virtual public QCC NewQCC
- {
- get
- {
- return new QCC(this);
- }
-
- }
- /// Returns a new instance of POC
- virtual public POC NewPOC
- {
- get
- {
- return new POC(this);
- }
-
- }
- /// Returns a new instance of CRG
- virtual public CRG NewCRG
- {
- get
- {
- return new CRG(this);
- }
-
- }
- /// Returns a new instance of COM
- virtual public COM NewCOM
- {
- get
- {
- ncom++; return new COM(this);
- }
-
- }
- /// Returns the number of found COM marker segments
- virtual public int NumCOM
- {
- get
- {
- return ncom;
- }
-
- }
-
- //UPGRADE_NOTE: Field 'EnclosingInstance' was added to class 'SIZ' to access its enclosing instance. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1019'"
- /// Internal class holding information found in the SIZ marker segment
- public class SIZ : System.ICloneable
- {
- public SIZ(HeaderInfo enclosingInstance)
- {
- InitBlock(enclosingInstance);
- }
- private void InitBlock(HeaderInfo enclosingInstance)
- {
- this.enclosingInstance = enclosingInstance;
- }
- private HeaderInfo enclosingInstance;
- virtual public int MaxCompWidth
- {
- get
- {
- if (compWidth == null)
- {
- compWidth = new int[csiz];
- for (int cc = 0; cc < csiz; cc++)
- {
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- compWidth[cc] = (int)(System.Math.Ceiling((xsiz) / (double)xrsiz[cc]) - System.Math.Ceiling(x0siz / (double)xrsiz[cc]));
- }
- }
- if (maxCompWidth == -1)
- {
- for (int c = 0; c < csiz; c++)
- {
- if (compWidth[c] > maxCompWidth)
- {
- maxCompWidth = compWidth[c];
- }
- }
- }
- return maxCompWidth;
- }
-
- }
- virtual public int MaxCompHeight
- {
- get
- {
- if (compHeight == null)
- {
- compHeight = new int[csiz];
- for (int cc = 0; cc < csiz; cc++)
- {
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- compHeight[cc] = (int)(System.Math.Ceiling((ysiz) / (double)yrsiz[cc]) - System.Math.Ceiling(y0siz / (double)yrsiz[cc]));
- }
- }
- if (maxCompHeight == -1)
- {
- for (int c = 0; c < csiz; c++)
- {
- if (compHeight[c] != maxCompHeight)
- {
- maxCompHeight = compHeight[c];
- }
- }
- }
- return maxCompHeight;
- }
-
- }
- virtual public int NumTiles
- {
- get
- {
- if (numTiles == -1)
- {
- numTiles = ((xsiz - xt0siz + xtsiz - 1) / xtsiz) * ((ysiz - yt0siz + ytsiz - 1) / ytsiz);
- }
- return numTiles;
- }
-
- }
- virtual public SIZ Copy
- {
- get
- {
- SIZ ms = null;
- try
- {
- ms = (SIZ)this.Clone();
- }
- //UPGRADE_NOTE: Exception 'java.lang.CloneNotSupportedException' was converted to 'System.Exception' which has different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1100'"
- catch (System.Exception)
- {
- throw new System.ApplicationException("Cannot clone SIZ marker segment");
- }
- return ms;
- }
-
- }
- public HeaderInfo Enclosing_Instance
- {
- get
- {
- return enclosingInstance;
- }
-
- }
- public int lsiz;
- public int rsiz;
- public int xsiz;
- public int ysiz;
- public int x0siz;
- public int y0siz;
- public int xtsiz;
- public int ytsiz;
- public int xt0siz;
- public int yt0siz;
- public int csiz;
- public int[] ssiz;
- public int[] xrsiz;
- public int[] yrsiz;
-
- /// Component widths
- private int[] compWidth = null;
- /// Maximum width among all components
- private int maxCompWidth = -1;
- /// Component heights
- private int[] compHeight = null;
- /// Maximum height among all components
- private int maxCompHeight = -1;
- /// Width of the specified tile-component
- ///
- ///
- /// Tile index
- ///
- ///
- /// Component index
- ///
- ///
- public virtual int getCompImgWidth(int c)
- {
- if (compWidth == null)
- {
- compWidth = new int[csiz];
- for (int cc = 0; cc < csiz; cc++)
- {
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- compWidth[cc] = (int)(System.Math.Ceiling((xsiz) / (double)xrsiz[cc]) - System.Math.Ceiling(x0siz / (double)xrsiz[cc]));
- }
- }
- return compWidth[c];
- }
- public virtual int getCompImgHeight(int c)
- {
- if (compHeight == null)
- {
- compHeight = new int[csiz];
- for (int cc = 0; cc < csiz; cc++)
- {
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- compHeight[cc] = (int)(System.Math.Ceiling((ysiz) / (double)yrsiz[cc]) - System.Math.Ceiling(y0siz / (double)yrsiz[cc]));
- }
- }
- return compHeight[c];
- }
- private int numTiles = -1;
- private bool[] origSigned = null;
- public virtual bool isOrigSigned(int c)
- {
- if (origSigned == null)
- {
- origSigned = new bool[csiz];
- for (int cc = 0; cc < csiz; cc++)
- {
- origSigned[cc] = ((SupportClass.URShift(ssiz[cc], CSJ2K.j2k.codestream.Markers.SSIZ_DEPTH_BITS)) == 1);
- }
- }
- return origSigned[c];
- }
- private int[] origBitDepth = null;
- public virtual int getOrigBitDepth(int c)
- {
- if (origBitDepth == null)
- {
- origBitDepth = new int[csiz];
- for (int cc = 0; cc < csiz; cc++)
- {
- origBitDepth[cc] = (ssiz[cc] & ((1 << CSJ2K.j2k.codestream.Markers.SSIZ_DEPTH_BITS) - 1)) + 1;
- }
- }
- return origBitDepth[c];
- }
-
- /// Display information found in SIZ marker segment
- public override System.String ToString()
- {
- System.String str = "\n --- SIZ (" + lsiz + " bytes) ---\n";
- str += (" Capabilities : " + rsiz + "\n");
- str += (" Image dim. : " + (xsiz - x0siz) + "x" + (ysiz - y0siz) + ", (off=" + x0siz + "," + y0siz + ")\n");
- str += (" Tile dim. : " + xtsiz + "x" + ytsiz + ", (off=" + xt0siz + "," + yt0siz + ")\n");
- str += (" Component(s) : " + csiz + "\n");
- str += " Orig. depth : ";
- for (int i = 0; i < csiz; i++)
- {
- str += (getOrigBitDepth(i) + " ");
- }
- str += "\n";
- str += " Orig. signed : ";
- for (int i = 0; i < csiz; i++)
- {
- str += (isOrigSigned(i) + " ");
- }
- str += "\n";
- str += " Subs. factor : ";
- for (int i = 0; i < csiz; i++)
- {
- str += (xrsiz[i] + "," + yrsiz[i] + " ");
- }
- str += "\n";
- return str;
- }
- //UPGRADE_TODO: The following method was automatically generated and it must be implemented in order to preserve the class logic. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1232'"
- virtual public System.Object Clone()
- {
- return null;
- }
- }
-
- //UPGRADE_NOTE: Field 'EnclosingInstance' was added to class 'SOT' to access its enclosing instance. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1019'"
- /// Internal class holding information found in the SOt marker segments
- public class SOT
- {
- public SOT(HeaderInfo enclosingInstance)
- {
- InitBlock(enclosingInstance);
- }
- private void InitBlock(HeaderInfo enclosingInstance)
- {
- this.enclosingInstance = enclosingInstance;
- }
- private HeaderInfo enclosingInstance;
- public HeaderInfo Enclosing_Instance
- {
- get
- {
- return enclosingInstance;
- }
-
- }
- public int lsot;
- public int isot;
- public int psot;
- public int tpsot;
- public int tnsot;
-
- /// Display information found in this SOT marker segment
- public override System.String ToString()
- {
- System.String str = "\n --- SOT (" + lsot + " bytes) ---\n";
- str += ("Tile index : " + isot + "\n");
- str += ("Tile-part length : " + psot + " bytes\n");
- str += ("Tile-part index : " + tpsot + "\n");
- str += ("Num. of tile-parts : " + tnsot + "\n");
- str += "\n";
- return str;
- }
- }
-
- //UPGRADE_NOTE: Field 'EnclosingInstance' was added to class 'COD' to access its enclosing instance. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1019'"
- /// Internal class holding information found in the COD marker segments
- public class COD : System.ICloneable
- {
- public COD(HeaderInfo enclosingInstance)
- {
- InitBlock(enclosingInstance);
- }
- private void InitBlock(HeaderInfo enclosingInstance)
- {
- this.enclosingInstance = enclosingInstance;
- }
- private HeaderInfo enclosingInstance;
- virtual public COD Copy
- {
- get
- {
- COD ms = null;
- try
- {
- ms = (COD)this.Clone();
- }
- //UPGRADE_NOTE: Exception 'java.lang.CloneNotSupportedException' was converted to 'System.Exception' which has different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1100'"
- catch (System.Exception)
- {
- throw new System.ApplicationException("Cannot clone SIZ marker segment");
- }
- return ms;
- }
-
- }
- public HeaderInfo Enclosing_Instance
- {
- get
- {
- return enclosingInstance;
- }
-
- }
- public int lcod;
- public int scod;
- public int sgcod_po; // Progression order
- public int sgcod_nl; // Number of layers
- public int sgcod_mct; // Multiple component transformation
- public int spcod_ndl; // Number of decomposition levels
- public int spcod_cw; // Code-blocks width
- public int spcod_ch; // Code-blocks height
- public int spcod_cs; // Code-blocks style
- public int[] spcod_t = new int[1]; // Transformation
- public int[] spcod_ps; // Precinct size
- /// Display information found in this COD marker segment
- public override System.String ToString()
- {
- System.String str = "\n --- COD (" + lcod + " bytes) ---\n";
- str += " Coding style : ";
- if (scod == 0)
- {
- str += "Default";
- }
- else
- {
- if ((scod & CSJ2K.j2k.codestream.Markers.SCOX_PRECINCT_PARTITION) != 0)
- str += "Precints ";
- if ((scod & CSJ2K.j2k.codestream.Markers.SCOX_USE_SOP) != 0)
- str += "SOP ";
- if ((scod & CSJ2K.j2k.codestream.Markers.SCOX_USE_EPH) != 0)
- str += "EPH ";
- int cb0x = ((scod & CSJ2K.j2k.codestream.Markers.SCOX_HOR_CB_PART) != 0) ? 1 : 0;
- int cb0y = ((scod & CSJ2K.j2k.codestream.Markers.SCOX_VER_CB_PART) != 0) ? 1 : 0;
- if (cb0x != 0 || cb0y != 0)
- {
- str += "Code-blocks offset";
- str += ("\n Cblk partition : " + cb0x + "," + cb0y);
- }
- }
- str += "\n";
- str += " Cblk style : ";
- if (spcod_cs == 0)
- {
- str += "Default";
- }
- else
- {
- if ((spcod_cs & 0x1) != 0)
- str += "Bypass ";
- if ((spcod_cs & 0x2) != 0)
- str += "Reset ";
- if ((spcod_cs & 0x4) != 0)
- str += "Terminate ";
- if ((spcod_cs & 0x8) != 0)
- str += "Vert_causal ";
- if ((spcod_cs & 0x10) != 0)
- str += "Predict ";
- if ((spcod_cs & 0x20) != 0)
- str += "Seg_symb ";
- }
- str += "\n";
- str += (" Num. of levels : " + spcod_ndl + "\n");
- switch (sgcod_po)
- {
-
- case CSJ2K.j2k.codestream.ProgressionType.LY_RES_COMP_POS_PROG:
- str += " Progress. type : LY_RES_COMP_POS_PROG\n";
- break;
-
- case CSJ2K.j2k.codestream.ProgressionType.RES_LY_COMP_POS_PROG:
- str += " Progress. type : RES_LY_COMP_POS_PROG\n";
- break;
-
- case CSJ2K.j2k.codestream.ProgressionType.RES_POS_COMP_LY_PROG:
- str += " Progress. type : RES_POS_COMP_LY_PROG\n";
- break;
-
- case CSJ2K.j2k.codestream.ProgressionType.POS_COMP_RES_LY_PROG:
- str += " Progress. type : POS_COMP_RES_LY_PROG\n";
- break;
-
- case CSJ2K.j2k.codestream.ProgressionType.COMP_POS_RES_LY_PROG:
- str += " Progress. type : COMP_POS_RES_LY_PROG\n";
- break;
- }
- str += (" Num. of layers : " + sgcod_nl + "\n");
- str += (" Cblk dimension : " + (1 << (spcod_cw + 2)) + "x" + (1 << (spcod_ch + 2)) + "\n");
- switch (spcod_t[0])
- {
-
- case CSJ2K.j2k.wavelet.FilterTypes_Fields.W9X7:
- str += " Filter : 9-7 irreversible\n";
- break;
-
- case CSJ2K.j2k.wavelet.FilterTypes_Fields.W5X3:
- str += " Filter : 5-3 reversible\n";
- break;
- }
- str += (" Multi comp tr. : " + (sgcod_mct == 1) + "\n");
- if (spcod_ps != null)
- {
- str += " Precincts : ";
- for (int i = 0; i < spcod_ps.Length; i++)
- {
- str += ((1 << (spcod_ps[i] & 0x000F)) + "x" + (1 << (((spcod_ps[i] & 0x00F0) >> 4))) + " ");
- }
- }
- str += "\n";
- return str;
- }
- //UPGRADE_TODO: The following method was automatically generated and it must be implemented in order to preserve the class logic. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1232'"
- virtual public System.Object Clone()
- {
- return null;
- }
- }
-
- //UPGRADE_NOTE: Field 'EnclosingInstance' was added to class 'COC' to access its enclosing instance. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1019'"
- /// Internal class holding information found in the COC marker segments
- public class COC
- {
- public COC(HeaderInfo enclosingInstance)
- {
- InitBlock(enclosingInstance);
- }
- private void InitBlock(HeaderInfo enclosingInstance)
- {
- this.enclosingInstance = enclosingInstance;
- }
- private HeaderInfo enclosingInstance;
- public HeaderInfo Enclosing_Instance
- {
- get
- {
- return enclosingInstance;
- }
-
- }
- public int lcoc;
- public int ccoc;
- public int scoc;
- public int spcoc_ndl; // Number of decomposition levels
- public int spcoc_cw;
- public int spcoc_ch;
- public int spcoc_cs;
- public int[] spcoc_t = new int[1];
- public int[] spcoc_ps;
- /// Display information found in this COC marker segment
- public override System.String ToString()
- {
- System.String str = "\n --- COC (" + lcoc + " bytes) ---\n";
- str += (" Component : " + ccoc + "\n");
- str += " Coding style : ";
- if (scoc == 0)
- {
- str += "Default";
- }
- else
- {
- if ((scoc & 0x1) != 0)
- str += "Precints ";
- if ((scoc & 0x2) != 0)
- str += "SOP ";
- if ((scoc & 0x4) != 0)
- str += "EPH ";
- }
- str += "\n";
- str += " Cblk style : ";
- if (spcoc_cs == 0)
- {
- str += "Default";
- }
- else
- {
- if ((spcoc_cs & 0x1) != 0)
- str += "Bypass ";
- if ((spcoc_cs & 0x2) != 0)
- str += "Reset ";
- if ((spcoc_cs & 0x4) != 0)
- str += "Terminate ";
- if ((spcoc_cs & 0x8) != 0)
- str += "Vert_causal ";
- if ((spcoc_cs & 0x10) != 0)
- str += "Predict ";
- if ((spcoc_cs & 0x20) != 0)
- str += "Seg_symb ";
- }
- str += "\n";
- str += (" Num. of levels : " + spcoc_ndl + "\n");
- str += (" Cblk dimension : " + (1 << (spcoc_cw + 2)) + "x" + (1 << (spcoc_ch + 2)) + "\n");
- switch (spcoc_t[0])
- {
-
- case CSJ2K.j2k.wavelet.FilterTypes_Fields.W9X7:
- str += " Filter : 9-7 irreversible\n";
- break;
-
- case CSJ2K.j2k.wavelet.FilterTypes_Fields.W5X3:
- str += " Filter : 5-3 reversible\n";
- break;
- }
- if (spcoc_ps != null)
- {
- str += " Precincts : ";
- for (int i = 0; i < spcoc_ps.Length; i++)
- {
- str += ((1 << (spcoc_ps[i] & 0x000F)) + "x" + (1 << (((spcoc_ps[i] & 0x00F0) >> 4))) + " ");
- }
- }
- str += "\n";
- return str;
- }
- }
-
- //UPGRADE_NOTE: Field 'EnclosingInstance' was added to class 'RGN' to access its enclosing instance. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1019'"
- /// Internal class holding information found in the RGN marker segments
- public class RGN
- {
- public RGN(HeaderInfo enclosingInstance)
- {
- InitBlock(enclosingInstance);
- }
- private void InitBlock(HeaderInfo enclosingInstance)
- {
- this.enclosingInstance = enclosingInstance;
- }
- private HeaderInfo enclosingInstance;
- public HeaderInfo Enclosing_Instance
- {
- get
- {
- return enclosingInstance;
- }
-
- }
- public int lrgn;
- public int crgn;
- public int srgn;
- public int sprgn;
- /// Display information found in this RGN marker segment
- public override System.String ToString()
- {
- System.String str = "\n --- RGN (" + lrgn + " bytes) ---\n";
- str += (" Component : " + crgn + "\n");
- if (srgn == 0)
- {
- str += " ROI style : Implicit\n";
- }
- else
- {
- str += " ROI style : Unsupported\n";
- }
- str += (" ROI shift : " + sprgn + "\n");
- str += "\n";
- return str;
- }
- }
-
- //UPGRADE_NOTE: Field 'EnclosingInstance' was added to class 'QCD' to access its enclosing instance. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1019'"
- /// Internal class holding information found in the QCD marker segments
- public class QCD
- {
- public QCD(HeaderInfo enclosingInstance)
- {
- InitBlock(enclosingInstance);
- }
- private void InitBlock(HeaderInfo enclosingInstance)
- {
- this.enclosingInstance = enclosingInstance;
- }
- private HeaderInfo enclosingInstance;
- virtual public int QuantType
- {
- get
- {
- if (qType == -1)
- {
- qType = sqcd & ~(CSJ2K.j2k.codestream.Markers.SQCX_GB_MSK << CSJ2K.j2k.codestream.Markers.SQCX_GB_SHIFT);
- }
- return qType;
- }
-
- }
- virtual public int NumGuardBits
- {
- get
- {
- if (gb == -1)
- {
- gb = (sqcd >> CSJ2K.j2k.codestream.Markers.SQCX_GB_SHIFT) & CSJ2K.j2k.codestream.Markers.SQCX_GB_MSK;
- }
- return gb;
- }
-
- }
- public HeaderInfo Enclosing_Instance
- {
- get
- {
- return enclosingInstance;
- }
-
- }
- public int lqcd;
- public int sqcd;
- public int[][] spqcd;
-
- private int qType = -1;
- private int gb = -1;
-
- /// Display information found in this QCD marker segment
- public override System.String ToString()
- {
- System.String str = "\n --- QCD (" + lqcd + " bytes) ---\n";
- str += " Quant. type : ";
- int qt = QuantType;
- if (qt == CSJ2K.j2k.codestream.Markers.SQCX_NO_QUANTIZATION)
- str += "No quantization \n";
- else if (qt == CSJ2K.j2k.codestream.Markers.SQCX_SCALAR_DERIVED)
- str += "Scalar derived\n";
- else if (qt == CSJ2K.j2k.codestream.Markers.SQCX_SCALAR_EXPOUNDED)
- str += "Scalar expounded\n";
- str += (" Guard bits : " + NumGuardBits + "\n");
- if (qt == CSJ2K.j2k.codestream.Markers.SQCX_NO_QUANTIZATION)
- {
- str += " Exponents :\n";
- int exp;
- for (int i = 0; i < spqcd.Length; i++)
- {
- for (int j = 0; j < spqcd[i].Length; j++)
- {
- if (i == 0 && j == 0)
- {
- exp = (spqcd[0][0] >> CSJ2K.j2k.codestream.Markers.SQCX_EXP_SHIFT) & CSJ2K.j2k.codestream.Markers.SQCX_EXP_MASK;
- str += ("\tr=0 : " + exp + "\n");
- }
- else if (i != 0 && j > 0)
- {
- exp = (spqcd[i][j] >> CSJ2K.j2k.codestream.Markers.SQCX_EXP_SHIFT) & CSJ2K.j2k.codestream.Markers.SQCX_EXP_MASK;
- str += ("\tr=" + i + ",s=" + j + " : " + exp + "\n");
- }
- }
- }
- }
- else
- {
- str += " Exp / Mantissa : \n";
- int exp;
- double mantissa;
- for (int i = 0; i < spqcd.Length; i++)
- {
- for (int j = 0; j < spqcd[i].Length; j++)
- {
- if (i == 0 && j == 0)
- {
- exp = (spqcd[0][0] >> 11) & 0x1f;
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- mantissa = (-1f - ((float)(spqcd[0][0] & 0x07ff)) / (1 << 11)) / (-1 << exp);
- str += ("\tr=0 : " + exp + " / " + mantissa + "\n");
- }
- else if (i != 0 && j > 0)
- {
- exp = (spqcd[i][j] >> 11) & 0x1f;
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- mantissa = (-1f - ((float)(spqcd[i][j] & 0x07ff)) / (1 << 11)) / (-1 << exp);
- str += ("\tr=" + i + ",s=" + j + " : " + exp + " / " + mantissa + "\n");
- }
- }
- }
- }
- str += "\n";
- return str;
- }
- }
-
- //UPGRADE_NOTE: Field 'EnclosingInstance' was added to class 'QCC' to access its enclosing instance. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1019'"
- /// Internal class holding information found in the QCC marker segments
- public class QCC
- {
- public QCC(HeaderInfo enclosingInstance)
- {
- InitBlock(enclosingInstance);
- }
- private void InitBlock(HeaderInfo enclosingInstance)
- {
- this.enclosingInstance = enclosingInstance;
- }
- private HeaderInfo enclosingInstance;
- virtual public int QuantType
- {
- get
- {
- if (qType == -1)
- {
- qType = sqcc & ~(CSJ2K.j2k.codestream.Markers.SQCX_GB_MSK << CSJ2K.j2k.codestream.Markers.SQCX_GB_SHIFT);
- }
- return qType;
- }
-
- }
- virtual public int NumGuardBits
- {
- get
- {
- if (gb == -1)
- {
- gb = (sqcc >> CSJ2K.j2k.codestream.Markers.SQCX_GB_SHIFT) & CSJ2K.j2k.codestream.Markers.SQCX_GB_MSK;
- }
- return gb;
- }
-
- }
- public HeaderInfo Enclosing_Instance
- {
- get
- {
- return enclosingInstance;
- }
-
- }
- public int lqcc;
- public int cqcc;
- public int sqcc;
- public int[][] spqcc;
-
- private int qType = -1;
- private int gb = -1;
-
- /// Display information found in this QCC marker segment
- public override System.String ToString()
- {
- System.String str = "\n --- QCC (" + lqcc + " bytes) ---\n";
- str += (" Component : " + cqcc + "\n");
- str += " Quant. type : ";
- int qt = QuantType;
- if (qt == CSJ2K.j2k.codestream.Markers.SQCX_NO_QUANTIZATION)
- str += "No quantization \n";
- else if (qt == CSJ2K.j2k.codestream.Markers.SQCX_SCALAR_DERIVED)
- str += "Scalar derived\n";
- else if (qt == CSJ2K.j2k.codestream.Markers.SQCX_SCALAR_EXPOUNDED)
- str += "Scalar expounded\n";
- str += (" Guard bits : " + NumGuardBits + "\n");
- if (qt == CSJ2K.j2k.codestream.Markers.SQCX_NO_QUANTIZATION)
- {
- str += " Exponents :\n";
- int exp;
- for (int i = 0; i < spqcc.Length; i++)
- {
- for (int j = 0; j < spqcc[i].Length; j++)
- {
- if (i == 0 && j == 0)
- {
- exp = (spqcc[0][0] >> CSJ2K.j2k.codestream.Markers.SQCX_EXP_SHIFT) & CSJ2K.j2k.codestream.Markers.SQCX_EXP_MASK;
- str += ("\tr=0 : " + exp + "\n");
- }
- else if (i != 0 && j > 0)
- {
- exp = (spqcc[i][j] >> CSJ2K.j2k.codestream.Markers.SQCX_EXP_SHIFT) & CSJ2K.j2k.codestream.Markers.SQCX_EXP_MASK;
- str += ("\tr=" + i + ",s=" + j + " : " + exp + "\n");
- }
- }
- }
- }
- else
- {
- str += " Exp / Mantissa : \n";
- int exp;
- double mantissa;
- for (int i = 0; i < spqcc.Length; i++)
- {
- for (int j = 0; j < spqcc[i].Length; j++)
- {
- if (i == 0 && j == 0)
- {
- exp = (spqcc[0][0] >> 11) & 0x1f;
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- mantissa = (-1f - ((float)(spqcc[0][0] & 0x07ff)) / (1 << 11)) / (-1 << exp);
- str += ("\tr=0 : " + exp + " / " + mantissa + "\n");
- }
- else if (i != 0 && j > 0)
- {
- exp = (spqcc[i][j] >> 11) & 0x1f;
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- mantissa = (-1f - ((float)(spqcc[i][j] & 0x07ff)) / (1 << 11)) / (-1 << exp);
- str += ("\tr=" + i + ",s=" + j + " : " + exp + " / " + mantissa + "\n");
- }
- }
- }
- }
- str += "\n";
- return str;
- }
- }
-
- //UPGRADE_NOTE: Field 'EnclosingInstance' was added to class 'POC' to access its enclosing instance. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1019'"
- /// Internal class holding information found in the POC marker segments
- public class POC
- {
- public POC(HeaderInfo enclosingInstance)
- {
- InitBlock(enclosingInstance);
- }
- private void InitBlock(HeaderInfo enclosingInstance)
- {
- this.enclosingInstance = enclosingInstance;
- }
- private HeaderInfo enclosingInstance;
- public HeaderInfo Enclosing_Instance
- {
- get
- {
- return enclosingInstance;
- }
-
- }
- public int lpoc;
- public int[] rspoc;
- public int[] cspoc;
- public int[] lyepoc;
- public int[] repoc;
- public int[] cepoc;
- public int[] ppoc;
- /// Display information found in this POC marker segment
- public override System.String ToString()
- {
- System.String str = "\n --- POC (" + lpoc + " bytes) ---\n";
- str += " Chg_idx RSpoc CSpoc LYEpoc REpoc CEpoc Ppoc\n";
- for (int chg = 0; chg < rspoc.Length; chg++)
- {
- str += (" " + chg + " " + rspoc[chg] + " " + cspoc[chg] + " " + lyepoc[chg] + " " + repoc[chg] + " " + cepoc[chg]);
- switch (ppoc[chg])
- {
-
- case CSJ2K.j2k.codestream.ProgressionType.LY_RES_COMP_POS_PROG:
- str += " LY_RES_COMP_POS_PROG\n";
- break;
-
- case CSJ2K.j2k.codestream.ProgressionType.RES_LY_COMP_POS_PROG:
- str += " RES_LY_COMP_POS_PROG\n";
- break;
-
- case CSJ2K.j2k.codestream.ProgressionType.RES_POS_COMP_LY_PROG:
- str += " RES_POS_COMP_LY_PROG\n";
- break;
-
- case CSJ2K.j2k.codestream.ProgressionType.POS_COMP_RES_LY_PROG:
- str += " POS_COMP_RES_LY_PROG\n";
- break;
-
- case CSJ2K.j2k.codestream.ProgressionType.COMP_POS_RES_LY_PROG:
- str += " COMP_POS_RES_LY_PROG\n";
- break;
- }
- }
- str += "\n";
- return str;
- }
- }
-
- //UPGRADE_NOTE: Field 'EnclosingInstance' was added to class 'CRG' to access its enclosing instance. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1019'"
- /// Internal class holding information found in the CRG marker segment
- public class CRG
- {
- public CRG(HeaderInfo enclosingInstance)
- {
- InitBlock(enclosingInstance);
- }
- private void InitBlock(HeaderInfo enclosingInstance)
- {
- this.enclosingInstance = enclosingInstance;
- }
- private HeaderInfo enclosingInstance;
- public HeaderInfo Enclosing_Instance
- {
- get
- {
- return enclosingInstance;
- }
-
- }
- public int lcrg;
- public int[] xcrg;
- public int[] ycrg;
- /// Display information found in the CRG marker segment
- public override System.String ToString()
- {
- System.String str = "\n --- CRG (" + lcrg + " bytes) ---\n";
- for (int c = 0; c < xcrg.Length; c++)
- {
- str += (" Component " + c + " offset : " + xcrg[c] + "," + ycrg[c] + "\n");
- }
- str += "\n";
- return str;
- }
- }
-
- //UPGRADE_NOTE: Field 'EnclosingInstance' was added to class 'COM' to access its enclosing instance. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1019'"
- /// Internal class holding information found in the COM marker segments
- public class COM
- {
- public COM(HeaderInfo enclosingInstance)
- {
- InitBlock(enclosingInstance);
- }
- private void InitBlock(HeaderInfo enclosingInstance)
- {
- this.enclosingInstance = enclosingInstance;
- }
- private HeaderInfo enclosingInstance;
- public HeaderInfo Enclosing_Instance
- {
- get
- {
- return enclosingInstance;
- }
-
- }
- public int lcom;
- public int rcom;
- public byte[] ccom;
- /// Display information found in the COM marker segment
- public override System.String ToString()
- {
- System.String str = "\n --- COM (" + lcom + " bytes) ---\n";
- if (rcom == 0)
- {
- str += " Registration : General use (binary values)\n";
- }
- else if (rcom == 1)
- {
- str += (" Registration : General use (IS 8859-15:1999 " + "(Latin) values)\n");
- str += (" Text : " + System.Text.ASCIIEncoding.ASCII.GetString(ccom) + "\n");
- }
- else
- {
- str += " Registration : Unknown\n";
- }
- str += "\n";
- return str;
- }
- }
-
- /// Reference to the SIZ marker segment found in main header
- public SIZ sizValue;
-
- /// Reference to the SOT marker segments found in tile-part headers. The
- /// kwy is given by "t"+tileIdx"_tp"+tilepartIndex.
- ///
- public System.Collections.Hashtable sotValue = System.Collections.Hashtable.Synchronized(new System.Collections.Hashtable());
-
- /// Reference to the COD marker segments found in main and first tile-part
- /// header. The key is either "main" or "t"+tileIdx.
- ///
- public System.Collections.Hashtable codValue = System.Collections.Hashtable.Synchronized(new System.Collections.Hashtable());
-
- /// Reference to the COC marker segments found in main and first tile-part
- /// header. The key is either "main_c"+componentIndex or
- /// "t"+tileIdx+"_c"+component_index.
- ///
- public System.Collections.Hashtable cocValue = System.Collections.Hashtable.Synchronized(new System.Collections.Hashtable());
-
- /// Reference to the RGN marker segments found in main and first tile-part
- /// header. The key is either "main_c"+componentIndex or
- /// "t"+tileIdx+"_c"+component_index.
- ///
- public System.Collections.Hashtable rgnValue = System.Collections.Hashtable.Synchronized(new System.Collections.Hashtable());
-
- /// Reference to the QCD marker segments found in main and first tile-part
- /// header. The key is either "main" or "t"+tileIdx.
- ///
- public System.Collections.Hashtable qcdValue = System.Collections.Hashtable.Synchronized(new System.Collections.Hashtable());
-
- /// Reference to the QCC marker segments found in main and first tile-part
- /// header. They key is either "main_c"+componentIndex or
- /// "t"+tileIdx+"_c"+component_index.
- ///
- public System.Collections.Hashtable qccValue = System.Collections.Hashtable.Synchronized(new System.Collections.Hashtable());
-
- /// Reference to the POC marker segments found in main and first tile-part
- /// header. They key is either "main" or "t"+tileIdx.
- ///
- public System.Collections.Hashtable pocValue = System.Collections.Hashtable.Synchronized(new System.Collections.Hashtable());
-
- /// Reference to the CRG marker segment found in main header
- public CRG crgValue;
-
- /// Reference to the COM marker segments found in main and tile-part
- /// headers. The key is either "main_"+comIdx or "t"+tileIdx+"_"+comIdx.
- ///
- public System.Collections.Hashtable comValue = System.Collections.Hashtable.Synchronized(new System.Collections.Hashtable());
-
- /// Number of found COM marker segment
- private int ncom = 0;
-
- /// Display information found in the different marker segments of the main
- /// header
- ///
- public virtual System.String toStringMainHeader()
- {
- int nc = sizValue.csiz;
- // SIZ
- System.String str = "" + sizValue;
- // COD
- if (codValue["main"] != null)
- {
- str += ("" + ((COD)codValue["main"]));
- }
- // COCs
- for (int c = 0; c < nc; c++)
- {
- if (cocValue["main_c" + c] != null)
- {
- str += ("" + ((COC)cocValue["main_c" + c]));
- }
- }
- // QCD
- if (qcdValue["main"] != null)
- {
- str += ("" + ((QCD)qcdValue["main"]));
- }
- // QCCs
- for (int c = 0; c < nc; c++)
- {
- if (qccValue["main_c" + c] != null)
- {
- str += ("" + ((QCC)qccValue["main_c" + c]));
- }
- }
- // RGN
- for (int c = 0; c < nc; c++)
- {
- if (rgnValue["main_c" + c] != null)
- {
- str += ("" + ((RGN)rgnValue["main_c" + c]));
- }
- }
- // POC
- if (pocValue["main"] != null)
- {
- str += ("" + ((POC)pocValue["main"]));
- }
- // CRG
- if (crgValue != null)
- {
- str += ("" + crgValue);
- }
- // COM
- for (int i = 0; i < ncom; i++)
- {
- if (comValue["main_" + i] != null)
- {
- str += ("" + ((COM)comValue["main_" + i]));
- }
- }
- return str;
- }
-
- /// Returns information found in the tile-part headers of a given tile.
- ///
- ///
- /// index of the tile
- ///
- ///
- /// Number of tile-parts
- ///
- ///
- public virtual System.String toStringTileHeader(int t, int ntp)
- {
- int nc = sizValue.csiz;
- System.String str = "";
- // SOT
- for (int i = 0; i < ntp; i++)
- {
- str += ("Tile-part " + i + ", tile " + t + ":\n");
- str += ("" + ((SOT)sotValue["t" + t + "_tp" + i]));
- }
- // COD
- if (codValue["t" + t] != null)
- {
- str += ("" + ((COD)codValue["t" + t]));
- }
- // COCs
- for (int c = 0; c < nc; c++)
- {
- if (cocValue["t" + t + "_c" + c] != null)
- {
- str += ("" + ((COC)cocValue["t" + t + "_c" + c]));
- }
- }
- // QCD
- if (qcdValue["t" + t] != null)
- {
- str += ("" + ((QCD)qcdValue["t" + t]));
- }
- // QCCs
- for (int c = 0; c < nc; c++)
- {
- if (qccValue["t" + t + "_c" + c] != null)
- {
- str += ("" + ((QCC)qccValue["t" + t + "_c" + c]));
- }
- }
- // RGN
- for (int c = 0; c < nc; c++)
- {
- if (rgnValue["t" + t + "_c" + c] != null)
- {
- str += ("" + ((RGN)rgnValue["t" + t + "_c" + c]));
- }
- }
- // POC
- if (pocValue["t" + t] != null)
- {
- str += ("" + ((POC)pocValue["t" + t]));
- }
- return str;
- }
-
- /// Returns information found in the tile-part headers of a given tile
- /// exception the SOT marker segment.
- ///
- ///
- /// index of the tile
- ///
- ///
- /// Number of tile-parts
- ///
- ///
- public virtual System.String toStringThNoSOT(int t, int ntp)
- {
- int nc = sizValue.csiz;
- System.String str = "";
- // COD
- if (codValue["t" + t] != null)
- {
- str += ("" + ((COD)codValue["t" + t]));
- }
- // COCs
- for (int c = 0; c < nc; c++)
- {
- if (cocValue["t" + t + "_c" + c] != null)
- {
- str += ("" + ((COC)cocValue["t" + t + "_c" + c]));
- }
- }
- // QCD
- if (qcdValue["t" + t] != null)
- {
- str += ("" + ((QCD)qcdValue["t" + t]));
- }
- // QCCs
- for (int c = 0; c < nc; c++)
- {
- if (qccValue["t" + t + "_c" + c] != null)
- {
- str += ("" + ((QCC)qccValue["t" + t + "_c" + c]));
- }
- }
- // RGN
- for (int c = 0; c < nc; c++)
- {
- if (rgnValue["t" + t + "_c" + c] != null)
- {
- str += ("" + ((RGN)rgnValue["t" + t + "_c" + c]));
- }
- }
- // POC
- if (pocValue["t" + t] != null)
- {
- str += ("" + ((POC)pocValue["t" + t]));
- }
- return str;
- }
-
- /// Returns a copy of this object
- public virtual HeaderInfo getCopy(int nt)
- {
- HeaderInfo nhi = null;
- // SIZ
- try
- {
- nhi = (HeaderInfo)Clone();
- }
- //UPGRADE_NOTE: Exception 'java.lang.CloneNotSupportedException' was converted to 'System.Exception' which has different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1100'"
- catch (System.Exception)
- {
- throw new System.ApplicationException("Cannot clone HeaderInfo instance");
- }
- nhi.sizValue = sizValue.Copy;
- // COD
- if (codValue["main"] != null)
- {
- COD ms = (COD)codValue["main"];
- nhi.codValue["main"] = ms.Copy;
- }
- for (int t = 0; t < nt; t++)
- {
- if (codValue["t" + t] != null)
- {
- COD ms = (COD)codValue["t" + t];
- nhi.codValue["t" + t] = ms.Copy;
- }
- }
- return nhi;
- }
- //UPGRADE_TODO: The following method was automatically generated and it must be implemented in order to preserve the class logic. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1232'"
- virtual public System.Object Clone()
- {
- return null;
- }
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/codestream/Markers.cs b/CSJ2K/j2k/codestream/Markers.cs
deleted file mode 100644
index 522e5d19..00000000
--- a/CSJ2K/j2k/codestream/Markers.cs
+++ /dev/null
@@ -1,158 +0,0 @@
-/*
-* CVS identifier:
-*
-* $Id: Markers.java,v 1.13 2001/09/14 09:31:40 grosbois Exp $
-*
-* Class: Markers
-*
-* Description: Defines the values of the markers in JPEG 2000 codestream
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-* */
-namespace CSJ2K.j2k.codestream
-{
-
- /// This interface defines the values of the different markers in the JPEG 2000
- /// codestream. There are 16 bit values, always appearing in big-endian (most
- /// significant byte first) and byte-aligned in the codestream. This interface
- /// also defines some other constants such as bit-masks and bit-shifts.
- ///
- ///
- public struct Markers
- {
- /// Start of codestream (SOC): 0xFF4F
- public const short SOC = unchecked((short)0xff4f);
- /// Start of tile-part (SOT): 0xFF90
- public const short SOT = unchecked((short)0xff90);
- /// Start of data (SOD): 0xFF93
- public const short SOD = unchecked((short)0xff93);
- /// End of codestream (EOC): 0xFFD9
- public const short EOC = unchecked((short)0xffd9);
- /// SIZ marker (Image and tile size): 0xFF51
- public const short SIZ = unchecked((short)0xff51);
- /// No special capabilities (baseline) in codestream, in Rsiz field of SIZ
- /// marker: 0x00. All flag bits are turned off
- ///
- public const int RSIZ_BASELINE = 0x00;
- /// Error resilience marker flag bit in Rsiz field in SIZ marker: 0x01
- public const int RSIZ_ER_FLAG = 0x01;
- /// ROI present marker flag bit in Rsiz field in SIZ marker: 0x02
- public const int RSIZ_ROI = 0x02;
- /// Component bitdepth bits in Ssiz field in SIZ marker: 7
- public const int SSIZ_DEPTH_BITS = 7;
- /// The maximum number of component bitdepth
- public const int MAX_COMP_BITDEPTH = 38;
- /// Coding style default (COD): 0xFF52
- public const short COD = unchecked((short)0xff52);
- /// Coding style component (COC): 0xFF53
- public const short COC = unchecked((short)0xff53);
- /// Precinct used flag
- public const int SCOX_PRECINCT_PARTITION = 1;
- /// Use start of packet marker
- public const int SCOX_USE_SOP = 2;
- /// Use end of packet header marker
- public const int SCOX_USE_EPH = 4;
- /// Horizontal code-block partition origin is at x=1
- public const int SCOX_HOR_CB_PART = 8;
- /// Vertical code-block partition origin is at y=1
- public const int SCOX_VER_CB_PART = 16;
- /// The default size exponent of the precincts
- public const int PRECINCT_PARTITION_DEF_SIZE = 0xffff;
- // ** RGN marker segment **
- /// Region-of-interest (RGN): 0xFF5E
- public const short RGN = unchecked((short)0xff5e);
- /// Implicit (i.e. max-shift) ROI flag for Srgn field in RGN marker
- /// segment: 0x00
- ///
- public const int SRGN_IMPLICIT = 0x00;
- /// Quantization default (QCD): 0xFF5C
- public const short QCD = unchecked((short)0xff5c);
- /// Quantization component (QCC): 0xFF5D
- public const short QCC = unchecked((short)0xff5d);
- /// Guard bits shift in SQCX field: 5
- public const int SQCX_GB_SHIFT = 5;
- /// Guard bits mask in SQCX field: 7
- public const int SQCX_GB_MSK = 7;
- /// No quantization (i.e. embedded reversible) flag for Sqcd or Sqcc
- /// (Sqcx) fields: 0x00.
- ///
- public const int SQCX_NO_QUANTIZATION = 0x00;
- /// Scalar derived (i.e. LL values only) quantization flag for Sqcd or
- /// Sqcc (Sqcx) fields: 0x01.
- ///
- public const int SQCX_SCALAR_DERIVED = 0x01;
- /// Scalar expounded (i.e. all values) quantization flag for Sqcd or Sqcc
- /// (Sqcx) fields: 0x02.
- ///
- public const int SQCX_SCALAR_EXPOUNDED = 0x02;
- /// Exponent shift in SPQCX when no quantization: 3
- public const int SQCX_EXP_SHIFT = 3;
- /// Exponent bitmask in SPQCX when no quantization: 3
- public const int SQCX_EXP_MASK = (1 << 5) - 1;
- /// The "SOP marker segments used" flag within Sers: 1
- public const int ERS_SOP = 1;
- /// The "segmentation symbols used" flag within Sers: 2
- public const int ERS_SEG_SYMBOLS = 2;
- // ** Progression order change **
- public const short POC = unchecked((short)0xff5f);
- /// Tile-part lengths (TLM): 0xFF55
- public const short TLM = unchecked((short)0xff55);
- /// Packet length, main header (PLM): 0xFF57
- public const short PLM = unchecked((short)0xff57);
- /// Packet length, tile-part header (PLT): 0xFF58
- public const short PLT = unchecked((short)0xff58);
- /// Packed packet headers, main header (PPM): 0xFF60
- public const short PPM = unchecked((short)0xff60);
- /// Packed packet headers, tile-part header (PPT): 0xFF61
- public const short PPT = unchecked((short)0xff61);
- /// Maximum length of PPT marker segment
- public const int MAX_LPPT = 65535;
- /// Maximum length of PPM marker segment
- public const int MAX_LPPM = 65535;
- /// Start pf packet (SOP): 0xFF91
- public const short SOP = unchecked((short)0xff91);
- /// Length of SOP marker (in bytes)
- public const short SOP_LENGTH = 6;
- /// End of packet header (EPH): 0xFF92
- public const short EPH = unchecked((short)0xff92);
- /// Length of EPH marker (in bytes)
- public const short EPH_LENGTH = 2;
- /// Component registration (CRG): 0xFF63
- public const short CRG = unchecked((short)0xff63);
- /// Comment (COM): 0xFF64
- public const short COM = unchecked((short)0xff64);
- /// General use registration value (binary) (COM): 0x0000
- public const short RCOM_BINARY = 0;
- /// General use registration value (latin) (COM): 0x0001
- public const short RCOM_LATIN = 1;
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/codestream/PrecCoordInfo.cs b/CSJ2K/j2k/codestream/PrecCoordInfo.cs
deleted file mode 100644
index 7b081c9b..00000000
--- a/CSJ2K/j2k/codestream/PrecCoordInfo.cs
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
-* CVS identifier:
-*
-* $Id: PrecCoordInfo.java,v 1.9 2001/09/14 09:33:22 grosbois Exp $
-*
-* Class: PrecCoordInfo
-*
-* Description: Used to store the coordinates precincts.
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-* */
-namespace CSJ2K.j2k.codestream
-{
-
- /// This class is used to store the coordinates of precincts.
- ///
- ///
- public class PrecCoordInfo : CoordInfo
- {
-
- /// Horizontal upper left coordinate in the reference grid
- public int xref;
-
- /// Vertical upper left coordinate on the reference grid
- public int yref;
-
- /// Constructor. Creates a PrecCoordInfo object.
- ///
- ///
- /// Horizontal upper left coordinate in the subband
- ///
- ///
- /// Vertical upper left coordinate in the subband
- ///
- ///
- /// Precinct's width
- ///
- ///
- /// Precinct's height
- ///
- ///
- /// The horizontal coordinate on the reference grid
- ///
- ///
- /// The vertical coordinate on the reference grid
- ///
- ///
- public PrecCoordInfo(int ulx, int uly, int w, int h, int xref, int yref) : base(ulx, uly, w, h)
- {
- this.xref = xref;
- this.yref = yref;
- }
-
- /// Empty Constructor. Creates an empty PrecCoordInfo object.
- ///
- ///
- public PrecCoordInfo() : base()
- {
- }
-
- /// Returns precinct's information in a String
- ///
- ///
- /// String with precinct's information
- ///
- ///
- public override System.String ToString()
- {
- return base.ToString() + ", xref=" + xref + ", yref=" + yref;
- }
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/codestream/PrecInfo.cs b/CSJ2K/j2k/codestream/PrecInfo.cs
deleted file mode 100644
index b2cfe121..00000000
--- a/CSJ2K/j2k/codestream/PrecInfo.cs
+++ /dev/null
@@ -1,147 +0,0 @@
-/*
-* CVS identifier:
-*
-* $Id: PrecInfo.java,v 1.2 2001/09/20 10:03:45 grosbois Exp $
-*
-* Class: PrecInfo
-*
-* Description: Keeps information about a precinct
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-* */
-namespace CSJ2K.j2k.codestream
-{
-
- /// Class that holds precinct coordinates and references to contained
- /// code-blocks in each subband.
- ///
- ///
- public class PrecInfo
- {
-
- /// Precinct horizontal upper-left coordinate in the reference grid
- public int rgulx;
-
- /// Precinct vertical upper-left coordinate in the reference grid
- public int rguly;
-
- /// Precinct width reported in the reference grid
- public int rgw;
-
- /// Precinct height reported in the reference grid
- public int rgh;
-
- /// Precinct horizontal upper-left coordinate in the corresponding
- /// resolution level
- ///
- public int ulx;
-
- /// Precinct vertical upper-left coordinate in the corresponding
- /// resolution level
- ///
- public int uly;
-
- /// Precinct width in the corresponding resolution level
- public int w;
-
- /// Precinct height in the corresponding resolution level
- public int h;
-
- /// Resolution level index
- public int r;
-
- /// Code-blocks belonging to this precinct in each subbands of the
- /// resolution level
- ///
- public CBlkCoordInfo[][][] cblk;
-
- /// Number of code-blocks in each subband belonging to this precinct
- public int[] nblk;
-
- /// Class constructor.
- ///
- ///
- /// Resolution level index.
- ///
- /// Precinct horizontal offset.
- ///
- /// Precinct vertical offset.
- ///
- /// Precinct width.
- ///
- /// Precinct height.
- ///
- /// Precinct horizontal offset in the image reference grid.
- ///
- /// Precinct horizontal offset in the image reference grid.
- ///
- /// Precinct width in the reference grid.
- ///
- /// Precinct height in the reference grid.
- ///
- ///
- public PrecInfo(int r, int ulx, int uly, int w, int h, int rgulx, int rguly, int rgw, int rgh)
- {
- this.r = r;
- this.ulx = ulx;
- this.uly = uly;
- this.w = w;
- this.h = h;
- this.rgulx = rgulx;
- this.rguly = rguly;
- this.rgw = rgw;
- this.rgh = rgh;
-
- if (r == 0)
- {
- cblk = new CBlkCoordInfo[1][][];
- nblk = new int[1];
- }
- else
- {
- cblk = new CBlkCoordInfo[4][][];
- nblk = new int[4];
- }
- }
-
- /// Returns PrecInfo object information in a String
- ///
- ///
- /// PrecInfo information
- ///
- ///
- public override System.String ToString()
- {
- return "ulx=" + ulx + ",uly=" + uly + ",w=" + w + ",h=" + h + ",rgulx=" + rgulx + ",rguly=" + rguly + ",rgw=" + rgw + ",rgh=" + rgh;
- }
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/codestream/ProgressionType.cs b/CSJ2K/j2k/codestream/ProgressionType.cs
deleted file mode 100644
index 1a1f7655..00000000
--- a/CSJ2K/j2k/codestream/ProgressionType.cs
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
-* CVS identifier:
-*
-* $Id: ProgressionType.java,v 1.16 2001/07/25 16:21:06 grosbois Exp $
-*
-* Class: ProgressionType
-*
-* Description: The definition of the different bit stream
-* profiles.
-*
-*
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-* */
-namespace CSJ2K.j2k.codestream
-{
-
- /// This interface defines the identifiers for the different codestream
- /// profiles and progression types.
- ///
- /// Each progressive type has a different number: 'LY_RES_COMP_POS_PROG',
- /// 'RES_LY_COMP_POS_PROG', 'RES_POS_COMP_LY_PROG', 'POS_COMP_RES_LY_PROG' or
- /// 'COMP_POS_RES_LY_PROG'. These are the same identifiers are used in the
- /// codestream syntax.
- ///
- ///
This interface defines the constants only. In order to use the constants
- /// in any other class you can either use the fully qualified name (e.g.,
- /// ProgressionType.LY_RES_COMP_POS_PROG) or declare this interface in
- /// the implements clause of the class and then access the identifier
- /// directly.
- ///
- ///
- public struct ProgressionType
- {
- /// The codestream is Layer/Resolution/Component/Position progressive : 0
- ///
- ///
- public const int LY_RES_COMP_POS_PROG = 0;
- /// The codestream is Resolution/Layer/Component/Position progressive : 1
- ///
- ///
- public const int RES_LY_COMP_POS_PROG = 1;
- /// The codestream is Resolution/Position/Component/Layer progressive : 2
- ///
- ///
- public const int RES_POS_COMP_LY_PROG = 2;
- /// The codestream is Position/Component/Resolution/Layer progressive : 3
- ///
- ///
- public const int POS_COMP_RES_LY_PROG = 3;
- /// The codestream is Component/Position/Resolution/Layer progressive : 4
- ///
- ///
- public const int COMP_POS_RES_LY_PROG = 4;
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/codestream/reader/BitstreamReaderAgent.cs b/CSJ2K/j2k/codestream/reader/BitstreamReaderAgent.cs
deleted file mode 100644
index c4f51b9e..00000000
--- a/CSJ2K/j2k/codestream/reader/BitstreamReaderAgent.cs
+++ /dev/null
@@ -1,1272 +0,0 @@
-/*
-* CVS identifier:
-*
-* $Id: BitstreamReaderAgent.java,v 1.27 2002/07/25 14:59:32 grosbois Exp $
-*
-* Class: BitstreamReaderAgent
-*
-* Description: The generic interface for bit stream
-* transport agents.
-*
-*
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-* */
-using CSJ2K.j2k.decoder;
-using CSJ2K.j2k.entropy.decoder;
-using CSJ2K.j2k.image;
-using CSJ2K.j2k.io;
-using CSJ2K.j2k.quantization.dequantizer;
-using CSJ2K.j2k.util;
-using CSJ2K.j2k.wavelet;
-using CSJ2K.j2k.wavelet.synthesis;
-namespace CSJ2K.j2k.codestream.reader
-{
-
- /// This is the generic interface for bit stream reader agents. A bit stream
- /// reader agent is an entity that allows reading from a bit stream and
- /// requesting compressed code-blocks. It can be a simple file reader, or a
- /// network connection, or anything else.
- ///
- /// The bit stream reader agent allows to make request for compressed block
- /// data in any order. The amount of data returned would normally depend on the
- /// data available at the time of the request, be it from a file or from a
- /// network connection.
- ///
- /// The bit stream reader agent has the notion of a current tile, and
- /// coordinates are relative to the current tile, where applicable.
- ///
- /// Resolution level 0 is the lowest resolution level, i.e. the LL subband
- /// alone.
- ///
- ///
- public abstract class BitstreamReaderAgent : CodedCBlkDataSrcDec
- {
- /// Returns the horizontal code-block partition origin. Allowable values
- /// are 0 and 1, nothing else.
- ///
- ///
- virtual public int CbULX
- {
- get
- {
- return hd.CbULX;
- }
-
- }
- /// Returns the vertical code-block partition origin. Allowable values are
- /// 0 and 1, nothing else.
- ///
- ///
- virtual public int CbULY
- {
- get
- {
- return hd.CbULY;
- }
-
- }
- /// Returns the number of components in the image.
- ///
- ///
- /// The number of components in the image.
- ///
- ///
- virtual public int NumComps
- {
- get
- {
- return nc;
- }
-
- }
- /// Returns the index of the current tile, relative to a standard scan-line
- /// order.
- ///
- ///
- /// The current tile's index (starts at 0).
- ///
- ///
- virtual public int TileIdx
- {
- get
- {
- return ctY * ntX + ctX;
- }
-
- }
- /// Returns the parameters that are used in this class and implementing
- /// classes. It returns a 2D String array. Each of the 1D arrays is for a
- /// different option, and they have 3 elements. The first element is the
- /// option name, the second one is the synopsis and the third one is a long
- /// description of what the parameter is. The synopsis or description may
- /// be 'null', in which case it is assumed that there is no synopsis or
- /// description of the option, respectively. Null may be returned if no
- /// options are supported.
- ///
- ///
- /// the options name, their synopsis and their explanation, or null
- /// if no options are supported.
- ///
- ///
- public static System.String[][] ParameterInfo
- {
- get
- {
- return pinfo;
- }
-
- }
- /// Returns the image resolution level to reconstruct from the
- /// codestream. This value cannot be computed before every main and tile
- /// headers are read.
- ///
- ///
- /// The image resolution level
- ///
- ///
- virtual public int ImgRes
- {
- get
- {
- return targetRes;
- }
-
- }
- /// Return the target decoding rate in bits per pixel.
- ///
- ///
- /// Target decoding rate in bpp.
- ///
- ///
- virtual public float TargetRate
- {
- get
- {
- return trate;
- }
-
- }
- /// Return the actual decoding rate in bits per pixel.
- ///
- ///
- /// Actual decoding rate in bpp.
- ///
- ///
- virtual public float ActualRate
- {
- get
- {
- arate = anbytes * 8f / hd.MaxCompImgWidth / hd.MaxCompImgHeight;
- return arate;
- }
-
- }
- /// Return the target number of read bytes.
- ///
- ///
- /// Target decoding rate in bytes.
- ///
- ///
- virtual public int TargetNbytes
- {
- get
- {
- return tnbytes;
- }
-
- }
- /// Return the actual number of read bytes.
- ///
- ///
- /// Actual decoding rate in bytes.
- ///
- ///
- virtual public int ActualNbytes
- {
- get
- {
- return anbytes;
- }
-
- }
- /// Returns the horizontal offset of tile partition
- virtual public int TilePartULX
- {
- get
- {
- return hd.getTilingOrigin(null).x;
- }
-
- }
- /// Returns the vertical offset of tile partition
- virtual public int TilePartULY
- {
- get
- {
- return hd.getTilingOrigin(null).y;
- }
-
- }
- /// Returns the nominal tile width
- virtual public int NomTileWidth
- {
- get
- {
- return hd.NomTileWidth;
- }
-
- }
- /// Returns the nominal tile height
- virtual public int NomTileHeight
- {
- get
- {
- return hd.NomTileHeight;
- }
-
- }
-
- /// The decoder specifications
- protected internal DecoderSpecs decSpec;
-
- /// Whether or not the components in the current tile uses a derived
- /// quantization step size (only relevant in non reversible quantization
- /// mode). This field is actualized by the setTile method in
- /// FileBitstreamReaderAgent.
- ///
- ///
- ///
- ///
- ///
- protected internal bool[] derived = null;
-
- /// Number of guard bits off all component in the current tile. This field
- /// is actualized by the setTile method in FileBitstreamReaderAgent.
- ///
- ///
- ///
- ///
- ///
- protected internal int[] gb = null;
-
- /// Dequantization parameters of all subbands and all components in the
- /// current tile. The value is actualized by the setTile method in
- /// FileBitstreamReaderAgent.
- ///
- ///
- ///
- ///
- ///
- protected internal StdDequantizerParams[] params_Renamed = null;
-
- /// The prefix for bit stream reader options: 'B'
- public const char OPT_PREFIX = 'B';
-
- /// The list of parameters that is accepted by the bit stream
- /// readers. They start with 'B'.
- ///
- //UPGRADE_NOTE: Final was removed from the declaration of 'pinfo'. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- private static readonly System.String[][] pinfo = null;
-
- /// The maximum number of decompostion levels for each component of the
- /// current tile. It means that component c has mdl[c]+1 resolution levels
- /// (indexed from 0 to mdl[c])
- ///
- ///
- protected internal int[] mdl;
-
- /// The number of components
- //UPGRADE_NOTE: Final was removed from the declaration of 'nc '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- protected internal int nc;
-
- /// Image resolution level to generate
- protected internal int targetRes;
-
- /// The subband trees for each component in the current tile. Each element
- /// in the array is the root element of the subband tree for a
- /// component. The number of magnitude bits in each subband (magBits member
- /// variable) is not initialized.
- ///
- ///
- protected internal SubbandSyn[] subbTrees;
-
- /// The image width on the hi-res reference grid
- //UPGRADE_NOTE: Final was removed from the declaration of 'imgW '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- protected internal int imgW;
-
- /// The image width on the hi-res reference grid
- //UPGRADE_NOTE: Final was removed from the declaration of 'imgH '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- protected internal int imgH;
-
- /// The horizontal coordinate of the image origin in the canvas system, on
- /// the reference grid.
- ///
- //UPGRADE_NOTE: Final was removed from the declaration of 'ax '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- protected internal int ax;
-
- /// The vertical coordinate of the image origin in the canvas system, on
- /// the reference grid.
- ///
- //UPGRADE_NOTE: Final was removed from the declaration of 'ay '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- protected internal int ay;
-
- /// The horizontal coordinate of the tiling origin in the canvas system, on
- /// the reference grid.
- ///
- //UPGRADE_NOTE: Final was removed from the declaration of 'px '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- protected internal int px;
-
- /// The vertical coordinate of the tiling origin in the canvas system, on
- /// the reference grid.
- ///
- //UPGRADE_NOTE: Final was removed from the declaration of 'py '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- protected internal int py;
-
- /// The horizontal offsets of the upper-left corner of the current tile
- /// (not active tile) with respect to the canvas origin, in the component
- /// hi-res grid, for each component.
- ///
- //UPGRADE_NOTE: Final was removed from the declaration of 'offX '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- protected internal int[] offX;
-
- /// The vertical offsets of the upper-left corner of the current tile (not
- /// active tile) with respect to the canvas origin, in the component hi-res
- /// grid, for each component.
- ///
- //UPGRADE_NOTE: Final was removed from the declaration of 'offY '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- protected internal int[] offY;
-
- /// The horizontal coordinates of the upper-left corner of the active
- /// tile, with respect to the canvas origin, in the component hi-res grid,
- /// for each component.
- ///
- //UPGRADE_NOTE: Final was removed from the declaration of 'culx '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- protected internal int[] culx;
-
- /// The vertical coordinates of the upper-left corner of the active tile,
- /// with respect to the canvas origin, in the component hi-res grid, for
- /// each component.
- ///
- //UPGRADE_NOTE: Final was removed from the declaration of 'culy '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- protected internal int[] culy;
-
- /// The nominal tile width, in the hi-res reference grid
- //UPGRADE_NOTE: Final was removed from the declaration of 'ntW '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- protected internal int ntW;
-
- /// The nominal tile height, in the hi-res reference grid
- //UPGRADE_NOTE: Final was removed from the declaration of 'ntH '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- protected internal int ntH;
-
- /// The number of tile in the horizontal direction
- //UPGRADE_NOTE: Final was removed from the declaration of 'ntX '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- protected internal int ntX;
-
- /// The number of tiles in the vertical direction
- //UPGRADE_NOTE: Final was removed from the declaration of 'ntY '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- protected internal int ntY;
-
- /// The total number of tiles
- //UPGRADE_NOTE: Final was removed from the declaration of 'nt '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- protected internal int nt;
-
- /// The current tile horizontal index
- protected internal int ctX;
-
- /// The current tile vertical index
- protected internal int ctY;
-
- /// The decoded bit stream header
- //UPGRADE_NOTE: Final was removed from the declaration of 'hd '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- protected internal HeaderDecoder hd;
-
- /// Number of bytes targeted to be read
- protected internal int tnbytes;
-
- /// Actual number of read bytes
- protected internal int anbytes;
-
- /// Target decoding rate in bpp
- protected internal float trate;
-
- /// Actual decoding rate in bpp
- protected internal float arate;
-
- /// Initializes members of this class. This constructor takes a
- /// HeaderDecoder object. This object must be initialized by the
- /// constructor of the implementing class from the header of the bit
- /// stream.
- ///
- ///
- /// The decoded header of the bit stream from where to initialize
- /// the values.
- ///
- ///
- /// The decoder specifications
- ///
- ///
- protected internal BitstreamReaderAgent(HeaderDecoder hd, DecoderSpecs decSpec)
- {
- Coord co;
- //int i, j, max;
-
- this.decSpec = decSpec;
- this.hd = hd;
-
- // Number of components
- nc = hd.NumComps;
- offX = new int[nc];
- offY = new int[nc];
- culx = new int[nc];
- culy = new int[nc];
-
- // Image size and origin
- imgW = hd.ImgWidth;
- imgH = hd.ImgHeight;
- ax = hd.ImgULX;
- ay = hd.ImgULY;
-
- // Tiles
- co = hd.getTilingOrigin(null);
- px = co.x;
- py = co.y;
- ntW = hd.NomTileWidth;
- ntH = hd.NomTileHeight;
- ntX = (ax + imgW - px + ntW - 1) / ntW;
- ntY = (ay + imgH - py + ntH - 1) / ntH;
- nt = ntX * ntY;
- }
-
- /// Returns the component subsampling factor in the horizontal direction,
- /// for the specified component. This is, approximately, the ratio of
- /// dimensions between the reference grid and the component itself, see the
- /// 'ImgData' interface desription for details.
- ///
- ///
- /// The index of the component (between 0 and N-1)
- ///
- ///
- /// The horizontal subsampling factor of component 'c'
- ///
- ///
- ///
- ///
- ///
- public int getCompSubsX(int c)
- {
- return hd.getCompSubsX(c);
- }
-
- /// Returns the component subsampling factor in the vertical direction, for
- /// the specified component. This is, approximately, the ratio of
- /// dimensions between the reference grid and the component itself, see the
- /// 'ImgData' interface desription for details.
- ///
- ///
- /// The index of the component (between 0 and C-1)
- ///
- ///
- /// The vertical subsampling factor of component 'c'
- ///
- ///
- ///
- ///
- ///
- public virtual int getCompSubsY(int c)
- {
- return hd.getCompSubsY(c);
- }
-
- /// Returns the overall width of the current tile in pixels for the given
- /// (tile) resolution level. This is the tile's width without accounting
- /// for any component subsampling.
- ///
- /// Note: Tile resolution level indexes may be different from
- /// tile-component resolution index. They are indeed indexed starting from
- /// the lowest number of decomposition levels of each component of the
- /// tile.
- ///
- /// For an image (1 tile) with 2 components (component 0 having 2
- /// decomposition levels and component 1 having 3 decomposition levels),
- /// the first (tile-)component has 3 resolution levels and the second one
- /// has 4 resolution levels, whereas the tile has only 3 resolution levels
- /// available.
- ///
- ///
- /// The (tile) resolution level.
- ///
- ///
- /// The current tile's width in pixels.
- ///
- ///
- public virtual int getTileWidth(int rl)
- {
- // The minumum number of decomposition levels between all the
- // components
- int mindl = decSpec.dls.getMinInTile(TileIdx);
- if (rl > mindl)
- {
- throw new System.ArgumentException("Requested resolution level" + " is not available for, at " + "least, one component in " + "tile: " + ctX + "x" + ctY);
- }
- int ctulx, ntulx;
- int dl = mindl - rl; // Number of decomposition to obtain this
- // resolution
-
- // Calculate starting X of current tile at hi-res
- ctulx = (ctX == 0) ? ax : px + ctX * ntW;
- // Calculate starting X of next tile X-wise at hi-res
- ntulx = (ctX < ntX - 1) ? px + (ctX + 1) * ntW : ax + imgW;
-
- // The difference at the rl resolution level is the width
- return (ntulx + (1 << dl) - 1) / (1 << dl) - (ctulx + (1 << dl) - 1) / (1 << dl);
- }
-
- /// Returns the overall height of the current tile in pixels, for the given
- /// resolution level. This is the tile's height without accounting for any
- /// component subsampling.
- ///
- /// Note: Tile resolution level indexes may be different from
- /// tile-component resolution index. They are indeed indexed starting from
- /// the lowest number of decomposition levels of each component of the
- /// tile.
- ///
- /// For an image (1 tile) with 2 components (component 0 having 2
- /// decomposition levels and component 1 having 3 decomposition levels),
- /// the first (tile-)component has 3 resolution levels and the second one
- /// has 4 resolution levels, whereas the tile has only 3 resolution levels
- /// available.
- ///
- ///
- /// The (tile) resolution level.
- ///
- ///
- /// The total current tile's height in pixels.
- ///
- ///
- public virtual int getTileHeight(int rl)
- {
- // The minumum number of decomposition levels between all the
- // components
- int mindl = decSpec.dls.getMinInTile(TileIdx);
- if (rl > mindl)
- {
- throw new System.ArgumentException("Requested resolution level" + " is not available for, at " + "least, one component in" + " tile: " + ctX + "x" + ctY);
- }
-
- int ctuly, ntuly;
- int dl = mindl - rl; // Number of decomposition to obtain this
- // resolution
-
- // Calculate starting Y of current tile at hi-res
- ctuly = (ctY == 0) ? ay : py + ctY * ntH;
- // Calculate starting Y of next tile Y-wise at hi-res
- ntuly = (ctY < ntY - 1) ? py + (ctY + 1) * ntH : ay + imgH;
- // The difference at the rl level is the height
- return (ntuly + (1 << dl) - 1) / (1 << dl) - (ctuly + (1 << dl) - 1) / (1 << dl);
- }
-
- /// Returns the overall width of the image in pixels, for the given (image)
- /// resolution level. This is the image's width without accounting for any
- /// component subsampling or tiling.
- ///
- /// Note: Image resolution level indexes may differ from tile-component
- /// resolution index. They are indeed indexed starting from the lowest
- /// number of decomposition levels of each component of each tile.
- ///
- /// Example: For an image (1 tile) with 2 components (component 0 having
- /// 2 decomposition levels and component 1 having 3 decomposition levels),
- /// the first (tile-) component has 3 resolution levels and the second one
- /// has 4 resolution levels, whereas the image has only 3 resolution levels
- /// available.
- ///
- ///
- /// The image resolution level.
- ///
- ///
- /// The total image's width in pixels.
- ///
- ///
- public virtual int getImgWidth(int rl)
- {
- // The minimum number of decomposition levels of each
- // tile-component
- int mindl = decSpec.dls.Min;
- if (rl > mindl)
- {
- throw new System.ArgumentException("Requested resolution level" + " is not available for, at " + "least, one tile-component");
- }
- // Retrieve number of decomposition levels corresponding to
- // this resolution level
- int dl = mindl - rl;
- return (ax + imgW + (1 << dl) - 1) / (1 << dl) - (ax + (1 << dl) - 1) / (1 << dl);
- }
-
- /// Returns the overall height of the image in pixels, for the given
- /// resolution level. This is the image's height without accounting for any
- /// component subsampling or tiling.
- ///
- /// Note: Image resolution level indexes may differ from tile-component
- /// resolution index. They are indeed indexed starting from the lowest
- /// number of decomposition levels of each component of each tile.
- ///
- /// Example: For an image (1 tile) with 2 components (component 0 having
- /// 2 decomposition levels and component 1 having 3 decomposition levels),
- /// the first (tile-) component has 3 resolution levels and the second one
- /// has 4 resolution levels, whereas the image has only 3 resolution levels
- /// available.
- ///
- ///
- /// The image resolution level, from 0 to L.
- ///
- ///
- /// The total image's height in pixels.
- ///
- ///
- public virtual int getImgHeight(int rl)
- {
- int mindl = decSpec.dls.Min;
- if (rl > mindl)
- {
- throw new System.ArgumentException("Requested resolution level" + " is not available for, at " + "least, one tile-component");
- }
- // Retrieve number of decomposition levels corresponding to this
- // resolution level
- int dl = mindl - rl;
- return (ay + imgH + (1 << dl) - 1) / (1 << dl) - (ay + (1 << dl) - 1) / (1 << dl);
- }
-
- /// Returns the horizontal coordinate of the image origin, the top-left
- /// corner, in the canvas system, on the reference grid at the specified
- /// resolution level.
- ///
- /// Note: Image resolution level indexes may differ from tile-component
- /// resolution index. They are indeed indexed starting from the lowest
- /// number of decomposition levels of each component of each tile.
- ///
- /// Example: For an image (1 tile) with 2 components (component 0 having
- /// 2 decomposition levels and component 1 having 3 decomposition levels),
- /// the first (tile-) component has 3 resolution levels and the second one
- /// has 4 resolution levels, whereas the image has only 3 resolution levels
- /// available.
- ///
- ///
- /// The resolution level, from 0 to L.
- ///
- ///
- /// The horizontal coordinate of the image origin in the canvas
- /// system, on the reference grid.
- ///
- ///
- public virtual int getImgULX(int rl)
- {
- int mindl = decSpec.dls.Min;
- if (rl > mindl)
- {
- throw new System.ArgumentException("Requested resolution level" + " is not available for, at " + "least, one tile-component");
- }
- // Retrieve number of decomposition levels corresponding to this
- // resolution level
- int dl = mindl - rl;
- return (ax + (1 << dl) - 1) / (1 << dl);
- }
-
- /// Returns the vertical coordinate of the image origin, the top-left
- /// corner, in the canvas system, on the reference grid at the specified
- /// resolution level.
- ///
- /// Note: Image resolution level indexes may differ from tile-component
- /// resolution index. They are indeed indexed starting from the lowest
- /// number of decomposition levels of each component of each tile.
- ///
- /// Example: For an image (1 tile) with 2 components (component 0 having
- /// 2 decomposition levels and component 1 having 3 decomposition levels),
- /// the first (tile-) component has 3 resolution levels and the second one
- /// has 4 resolution levels, whereas the image has only 3 resolution levels
- /// available.
- ///
- ///
- /// The resolution level, from 0 to L.
- ///
- ///
- /// The vertical coordinate of the image origin in the canvas
- /// system, on the reference grid.
- ///
- ///
- public virtual int getImgULY(int rl)
- {
- int mindl = decSpec.dls.Min;
- if (rl > mindl)
- {
- throw new System.ArgumentException("Requested resolution level" + " is not available for, at " + "least, one tile-component");
- }
- // Retrieve number of decomposition levels corresponding to this
- // resolution level
- int dl = mindl - rl;
- return (ay + (1 << dl) - 1) / (1 << dl);
- }
-
- /// Returns the width in pixels of the specified tile-component for the
- /// given (tile-component) resolution level.
- ///
- ///
- /// The tile index
- ///
- ///
- /// The index of the component, from 0 to N-1.
- ///
- ///
- /// The resolution level, from 0 to L.
- ///
- ///
- /// The width in pixels of component c in tile t
- /// for resolution level rl.
- ///
- ///
- public int getTileCompWidth(int t, int c, int rl)
- {
- int tIdx = TileIdx;
- if (t != tIdx)
- {
- throw new System.ApplicationException("Asking the tile-component width of a tile " + "different from the current one.");
- }
- int ntulx;
- int dl = mdl[c] - rl;
- // Calculate starting X of next tile X-wise at reference grid hi-res
- ntulx = (ctX < ntX - 1) ? px + (ctX + 1) * ntW : ax + imgW;
- // Convert reference grid hi-res to component grid hi-res
- ntulx = (ntulx + hd.getCompSubsX(c) - 1) / hd.getCompSubsX(c);
- // Starting X of current tile at component grid hi-res is culx[c]
- // The difference at the rl level is the width
- return (ntulx + (1 << dl) - 1) / (1 << dl) - (culx[c] + (1 << dl) - 1) / (1 << dl);
- }
-
- /// Returns the height in pixels of the specified tile-component for the
- /// given (tile-component) resolution level.
- ///
- ///
- /// The tile index.
- ///
- ///
- /// The index of the component, from 0 to N-1.
- ///
- ///
- /// The resolution level, from 0 to L.
- ///
- ///
- /// The height in pixels of component c in the current
- /// tile.
- ///
- ///
- public int getTileCompHeight(int t, int c, int rl)
- {
- int tIdx = TileIdx;
- if (t != tIdx)
- {
- throw new System.ApplicationException("Asking the tile-component width of a tile " + "different from the current one.");
- }
- int ntuly;
- int dl = mdl[c] - rl; // Revert level indexation (0 is hi-res)
- // Calculate starting Y of next tile Y-wise at reference grid hi-res
- ntuly = (ctY < ntY - 1) ? py + (ctY + 1) * ntH : ay + imgH;
- // Convert reference grid hi-res to component grid hi-res
- ntuly = (ntuly + hd.getCompSubsY(c) - 1) / hd.getCompSubsY(c);
- // Starting Y of current tile at component grid hi-res is culy[c]
- // The difference at the rl level is the height
- return (ntuly + (1 << dl) - 1) / (1 << dl) - (culy[c] + (1 << dl) - 1) / (1 << dl);
- }
-
- /// Returns the width in pixels of the specified component in the overall
- /// image, for the given (component) resolution level.
- ///
- /// Note: Component resolution level indexes may differ from
- /// tile-component resolution index. They are indeed indexed starting from
- /// the lowest number of decomposition levels of same component of each
- /// tile.
- ///
- /// Example: For an image (2 tiles) with 1 component (tile 0 having 2
- /// decomposition levels and tile 1 having 3 decomposition levels), the
- /// first tile(-component) has 3 resolution levels and the second one has 4
- /// resolution levels, whereas the component has only 3 resolution levels
- /// available.
- ///
- ///
- /// The index of the component, from 0 to N-1.
- ///
- ///
- /// The resolution level, from 0 to L.
- ///
- ///
- /// The width in pixels of component c in the overall
- /// image.
- ///
- ///
- public int getCompImgWidth(int c, int rl)
- {
- int sx, ex;
- int dl = decSpec.dls.getMinInComp(c) - rl;
- // indexation (0 is hi-res)
- // Calculate image starting x at component hi-res grid
- sx = (ax + hd.getCompSubsX(c) - 1) / hd.getCompSubsX(c);
- // Calculate image ending (excluding) x at component hi-res grid
- ex = (ax + imgW + hd.getCompSubsX(c) - 1) / hd.getCompSubsX(c);
- // The difference at the rl level is the width
- return (ex + (1 << dl) - 1) / (1 << dl) - (sx + (1 << dl) - 1) / (1 << dl);
- }
-
- /// Returns the height in pixels of the specified component in the overall
- /// image, for the given (component) resolution level.
- ///
- /// Note: Component resolution level indexes may differ from
- /// tile-component resolution index. They are indeed indexed starting from
- /// the lowest number of decomposition levels of same component of each
- /// tile.
- ///
- /// Example: For an image (2 tiles) with 1 component (tile 0 having 2
- /// decomposition levels and tile 1 having 3 decomposition levels), the
- /// first tile(-component) has 3 resolution levels and the second one has 4
- /// resolution levels, whereas the component has only 3 resolution levels
- /// available.
- ///
- ///
- /// The index of the component, from 0 to N-1.
- ///
- ///
- /// The resolution level, from 0 to L.
- ///
- ///
- /// The height in pixels of component c in the overall
- /// image.
- ///
- ///
- public int getCompImgHeight(int c, int rl)
- {
- int sy, ey;
- int dl = decSpec.dls.getMinInComp(c) - rl;
- // indexation (0 is hi-res)
- // Calculate image starting x at component hi-res grid
- sy = (ay + hd.getCompSubsY(c) - 1) / hd.getCompSubsY(c);
- // Calculate image ending (excluding) x at component hi-res grid
- ey = (ay + imgH + hd.getCompSubsY(c) - 1) / hd.getCompSubsY(c);
- // The difference at the rl level is the width
- return (ey + (1 << dl) - 1) / (1 << dl) - (sy + (1 << dl) - 1) / (1 << dl);
- }
-
- /// Changes the current tile, given the new indexes. An
- /// IllegalArgumentException is thrown if the indexes do not correspond to
- /// a valid tile.
- ///
- ///
- /// The horizontal indexes the tile.
- ///
- ///
- /// The vertical indexes of the new tile.
- ///
- ///
- public abstract void setTile(int x, int y);
-
- /// Advances to the next tile, in standard scan-line order (by rows then
- /// columns). An NoNextElementException is thrown if the current tile is
- /// the last one (i.e. there is no next tile).
- ///
- ///
- public abstract void nextTile();
-
- /// Returns the indexes of the current tile. These are the horizontal and
- /// vertical indexes of the current tile.
- ///
- ///
- /// If not null this object is used to return the information. If
- /// null a new one is created and returned.
- ///
- ///
- /// The current tile's indexes (vertical and horizontal indexes).
- ///
- ///
- public Coord getTile(Coord co)
- {
- if (co != null)
- {
- co.x = ctX;
- co.y = ctY;
- return co;
- }
- else
- {
- return new Coord(ctX, ctY);
- }
- }
-
- /// Returns the horizontal coordinate of the upper-left corner of the
- /// specified resolution in the given component of the current tile.
- ///
- ///
- /// The component index.
- ///
- ///
- /// The resolution level index.
- ///
- ///
- public int getResULX(int c, int rl)
- {
- int dl = mdl[c] - rl;
- if (dl < 0)
- {
- throw new System.ArgumentException("Requested resolution level" + " is not available for, at " + "least, one component in " + "tile: " + ctX + "x" + ctY);
- }
- int tx0 = (int)System.Math.Max(px + ctX * ntW, ax);
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- int tcx0 = (int)System.Math.Ceiling(tx0 / (double)getCompSubsX(c));
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- return (int)System.Math.Ceiling(tcx0 / (double)(1 << dl));
- }
-
- /// Returns the vertical coordinate of the upper-left corner of the
- /// specified component in the given component of the current tile.
- ///
- ///
- /// The component index.
- ///
- ///
- /// The resolution level index.
- ///
- ///
- public int getResULY(int c, int rl)
- {
- int dl = mdl[c] - rl;
- if (dl < 0)
- {
- throw new System.ArgumentException("Requested resolution level" + " is not available for, at " + "least, one component in " + "tile: " + ctX + "x" + ctY);
- }
- int ty0 = (int)System.Math.Max(py + ctY * ntH, ay);
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- int tcy0 = (int)System.Math.Ceiling(ty0 / (double)getCompSubsY(c));
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- return (int)System.Math.Ceiling(tcy0 / (double)(1 << dl));
- }
-
- /// Returns the number of tiles in the horizontal and vertical directions.
- ///
- ///
- /// If not null this object is used to return the information. If
- /// null a new one is created and returned.
- ///
- ///
- /// The number of tiles in the horizontal (Coord.x) and vertical
- /// (Coord.y) directions.
- ///
- ///
- public Coord getNumTiles(Coord co)
- {
- if (co != null)
- {
- co.x = ntX;
- co.y = ntY;
- return co;
- }
- else
- {
- return new Coord(ntX, ntY);
- }
- }
-
- /// Returns the total number of tiles in the image.
- ///
- ///
- /// The total number of tiles in the image.
- ///
- ///
- public int getNumTiles()
- {
- return ntX * ntY;
- }
-
- /// Returns the subband tree, for the specified tile-component. This method
- /// returns the root element of the subband tree structure, see Subband and
- /// SubbandSyn. The tree comprises all the available resolution levels.
- ///
- /// Note: this method is not able to return subband tree for a tile
- /// different than the current one.
- ///
- /// The number of magnitude bits ('magBits' member variable) for each
- /// subband is not initialized.
- ///
- ///
- /// The tile index
- ///
- ///
- /// The index of the component, from 0 to C-1.
- ///
- ///
- /// The root of the tree structure.
- ///
- ///
- public SubbandSyn getSynSubbandTree(int t, int c)
- {
- if (t != TileIdx)
- {
- throw new System.ArgumentException("Can not request subband" + " tree of a different tile" + " than the current one");
- }
- if (c < 0 || c >= nc)
- {
- throw new System.ArgumentException("Component index out of range");
- }
- return subbTrees[c];
- }
-
- /// Creates a bit stream reader of the correct type that works on the
- /// provided RandomAccessIO, with the special parameters from the parameter
- /// list.
- ///
- ///
- /// The RandomAccessIO source from which to read the bit stream.
- ///
- ///
- /// Header of the codestream.
- ///
- ///
- /// The parameter list containing parameters applicable to the
- /// bit stream read (other parameters may also be present).
- ///
- ///
- /// The decoder specifications
- ///
- ///
- /// Whether or not to print information found in
- /// codestream.
- ///
- ///
- /// Reference to the HeaderInfo instance.
- ///
- ///
- /// If an I/O error occurs while reading initial
- /// data from the bit stream.
- ///
- /// If an unrecognised bit stream
- /// reader option is present.
- ///
- ///
- public static BitstreamReaderAgent createInstance(RandomAccessIO in_Renamed, HeaderDecoder hd, ParameterList pl, DecoderSpecs decSpec, bool cdstrInfo, HeaderInfo hi)
- {
-
- // Check parameters
- pl.checkList(BitstreamReaderAgent.OPT_PREFIX, CSJ2K.j2k.util.ParameterList.toNameArray(BitstreamReaderAgent.ParameterInfo));
-
- return new FileBitstreamReaderAgent(hd, in_Renamed, decSpec, pl, cdstrInfo, hi);
- }
-
- /// Returns the precinct partition width for the specified tile-component
- /// and (tile-component) resolution level.
- ///
- ///
- /// the tile index
- ///
- ///
- /// The index of the component (between 0 and N-1)
- ///
- ///
- /// The resolution level, from 0 to L.
- ///
- ///
- /// the precinct partition width for the specified component,
- /// resolution level and tile.
- ///
- ///
- public int getPPX(int t, int c, int rl)
- {
- return decSpec.pss.getPPX(t, c, rl);
- }
-
- /// Returns the precinct partition height for the specified tile-component
- /// and (tile-component) resolution level.
- ///
- ///
- /// The tile index
- ///
- ///
- /// The index of the component (between 0 and N-1)
- ///
- ///
- /// The resolution level, from 0 to L.
- ///
- ///
- /// The precinct partition height in the specified component, for
- /// the specified resolution level, for the current tile.
- ///
- ///
- public int getPPY(int t, int c, int rl)
- {
- return decSpec.pss.getPPY(t, c, rl);
- }
-
- /// Initialises subbands fields, such as number of code-blocks, code-blocks
- /// dimension and number of magnitude bits, in the subband tree. The
- /// nominal code-block width/height depends on the precincts dimensions if
- /// used. The way the number of magnitude bits is computed depends on the
- /// quantization type (reversible, derived, expounded).
- ///
- ///
- /// The component index
- ///
- ///
- /// The subband tree to be initialised.
- ///
- ///
- protected internal virtual void initSubbandsFields(int c, SubbandSyn sb)
- {
- int t = TileIdx;
- int rl = sb.resLvl;
- int cbw, cbh;
-
- cbw = decSpec.cblks.getCBlkWidth(ModuleSpec.SPEC_TILE_COMP, t, c);
- cbh = decSpec.cblks.getCBlkHeight(ModuleSpec.SPEC_TILE_COMP, t, c);
-
- if (!sb.isNode)
- {
- // Code-block dimensions
- if (hd.precinctPartitionUsed())
- {
- // The precinct partition is used
- int ppxExp, ppyExp, cbwExp, cbhExp;
-
- // Get exponents
- ppxExp = MathUtil.log2(getPPX(t, c, rl));
- ppyExp = MathUtil.log2(getPPY(t, c, rl));
- cbwExp = MathUtil.log2(cbw);
- cbhExp = MathUtil.log2(cbh);
-
- switch (sb.resLvl)
- {
-
- case 0:
- sb.nomCBlkW = (cbwExp < ppxExp ? (1 << cbwExp) : (1 << ppxExp));
- sb.nomCBlkH = (cbhExp < ppyExp ? (1 << cbhExp) : (1 << ppyExp));
- break;
-
-
- default:
- sb.nomCBlkW = (cbwExp < ppxExp - 1 ? (1 << cbwExp) : (1 << (ppxExp - 1)));
- sb.nomCBlkH = (cbhExp < ppyExp - 1 ? (1 << cbhExp) : (1 << (ppyExp - 1)));
- break;
-
- }
- }
- else
- {
- sb.nomCBlkW = cbw;
- sb.nomCBlkH = cbh;
- }
-
- // Number of code-blocks
- if (sb.numCb == null)
- sb.numCb = new Coord();
- if (sb.w == 0 || sb.h == 0)
- {
- sb.numCb.x = 0;
- sb.numCb.y = 0;
- }
- else
- {
- int cb0x = CbULX;
- int cb0y = CbULY;
- int tmp;
-
- // Projects code-block partition origin to subband. Since the
- // origin is always 0 or 1, it projects to the low-pass side
- // (throught the ceil operator) as itself (i.e. no change) and
- // to the high-pass side (through the floor operator) as 0,
- // always.
- int acb0x = cb0x;
- int acb0y = cb0y;
-
- switch (sb.sbandIdx)
- {
-
- case Subband.WT_ORIENT_LL:
- // No need to project since all low-pass => nothing to do
- break;
-
- case Subband.WT_ORIENT_HL:
- acb0x = 0;
- break;
-
- case Subband.WT_ORIENT_LH:
- acb0y = 0;
- break;
-
- case Subband.WT_ORIENT_HH:
- acb0x = 0;
- acb0y = 0;
- break;
-
- default:
- throw new System.ApplicationException("Internal JJ2000 error");
-
- }
- if (sb.ulcx - acb0x < 0 || sb.ulcy - acb0y < 0)
- {
- throw new System.ArgumentException("Invalid code-blocks " + "partition origin or " + "image offset in the " + "reference grid.");
- }
-
- // NOTE: when calculating "floor()" by integer division the
- // dividend and divisor must be positive, we ensure that by
- // adding the divisor to the dividend and then substracting 1
- // to the result of the division
-
- tmp = sb.ulcx - acb0x + sb.nomCBlkW;
- sb.numCb.x = (tmp + sb.w - 1) / sb.nomCBlkW - (tmp / sb.nomCBlkW - 1);
-
- tmp = sb.ulcy - acb0y + sb.nomCBlkH;
- sb.numCb.y = (tmp + sb.h - 1) / sb.nomCBlkH - (tmp / sb.nomCBlkH - 1);
- }
-
- // Number of magnitude bits
- if (derived[c])
- {
- sb.magbits = gb[c] + (params_Renamed[c].exp[0][0] - (mdl[c] - sb.level)) - 1;
- }
- else
- {
- sb.magbits = gb[c] + params_Renamed[c].exp[sb.resLvl][sb.sbandIdx] - 1;
- }
- }
- else
- {
- initSubbandsFields(c, (SubbandSyn)sb.LL);
- initSubbandsFields(c, (SubbandSyn)sb.HL);
- initSubbandsFields(c, (SubbandSyn)sb.LH);
- initSubbandsFields(c, (SubbandSyn)sb.HH);
- }
- }
- public abstract CSJ2K.j2k.entropy.decoder.DecLyrdCBlk getCodeBlock(int param1, int param2, int param3, CSJ2K.j2k.wavelet.synthesis.SubbandSyn param4, int param5, int param6, CSJ2K.j2k.entropy.decoder.DecLyrdCBlk param7);
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/codestream/reader/CBlkInfo.cs b/CSJ2K/j2k/codestream/reader/CBlkInfo.cs
deleted file mode 100644
index 3d16ebf8..00000000
--- a/CSJ2K/j2k/codestream/reader/CBlkInfo.cs
+++ /dev/null
@@ -1,173 +0,0 @@
-/*
-* CVS identifier:
-*
-* $Id: CBlkInfo.java,v 1.12 2001/09/14 08:32:15 grosbois Exp $
-*
-* Class: CBlkInfo
-*
-* Description: Object containing code-block informations.
-*
-*
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-* */
-namespace CSJ2K.j2k.codestream.reader
-{
-
- /// This class contains location of code-blocks' piece of codewords (there is
- /// one piece per layer) and some other information.
- ///
- ///
- public class CBlkInfo
- {
-
- /// Upper-left x-coordinate of the code-block (relative to the tile)
- public int ulx;
-
- /// Upper-left y-coordinate of the code-block (relative to the tile)
- public int uly;
-
- /// Width of the code-block
- public int w;
-
- /// Height of the code-block
- public int h;
-
- /// The number of most significant bits which are skipped for this
- /// code-block (= Mb-1-bitDepth).
- ///
- public int msbSkipped;
-
- /// Length of each piece of code-block's codewords
- public int[] len;
-
- /// Offset of each piece of code-block's codewords in the file
- public int[] off;
-
- /// The number of truncation point for each layer
- public int[] ntp;
-
- /// The cumulative number of truncation points
- public int ctp;
-
- /// The length of each segment (used with regular termination or in
- /// selective arithmetic bypass coding mode)
- ///
- public int[][] segLen;
-
- /// Index of the packet where each layer has been found
- public int[] pktIdx;
-
- /// Constructs a new instance with specified number of layers and
- /// code-block coordinates. The number corresponds to the maximum piece of
- /// codeword for one code-block.
- ///
- ///
- /// The uper-left x-coordinate
- ///
- ///
- /// The uper-left y-coordinate
- ///
- ///
- /// Width of the code-block
- ///
- ///
- /// Height of the code-block
- ///
- ///
- /// The number of layers
- ///
- ///
- public CBlkInfo(int ulx, int uly, int w, int h, int nl)
- {
- this.ulx = ulx;
- this.uly = uly;
- this.w = w;
- this.h = h;
- off = new int[nl];
- len = new int[nl];
- ntp = new int[nl];
- segLen = new int[nl][];
- pktIdx = new int[nl];
- for (int i = nl - 1; i >= 0; i--)
- {
- pktIdx[i] = -1;
- }
- }
-
- /// Adds the number of new truncation for specified layer.
- ///
- ///
- /// layer index
- ///
- ///
- /// Number of new truncation points
- ///
- ///
- public virtual void addNTP(int l, int newtp)
- {
- ntp[l] = newtp;
- ctp = 0;
- for (int lIdx = 0; lIdx <= l; lIdx++)
- {
- ctp += ntp[lIdx];
- }
- }
-
- /// Object information in a string.
- ///
- ///
- /// Object information
- ///
- ///
- public override System.String ToString()
- {
- System.String string_Renamed = "(ulx,uly,w,h)= (" + ulx + "," + uly + "," + w + "," + h;
- string_Renamed += (") " + msbSkipped + " MSB bit(s) skipped\n");
- if (len != null)
- for (int i = 0; i < len.Length; i++)
- {
- string_Renamed += ("\tl:" + i + ", start:" + off[i] + ", len:" + len[i] + ", ntp:" + ntp[i] + ", pktIdx=" + pktIdx[i]);
- if (segLen != null && segLen[i] != null)
- {
- string_Renamed += " { ";
- for (int j = 0; j < segLen[i].Length; j++)
- string_Renamed += (segLen[i][j] + " ");
- string_Renamed += "}";
- }
- string_Renamed += "\n";
- }
- string_Renamed += ("\tctp=" + ctp);
- return string_Renamed;
- }
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/codestream/reader/FileBitstreamReaderAgent.cs b/CSJ2K/j2k/codestream/reader/FileBitstreamReaderAgent.cs
deleted file mode 100644
index 33ff6031..00000000
--- a/CSJ2K/j2k/codestream/reader/FileBitstreamReaderAgent.cs
+++ /dev/null
@@ -1,2727 +0,0 @@
-/*
-* CVS identifier:
-*
-* $Id: FileBitstreamReaderAgent.java,v 1.68 2002/07/19 12:34:38 grosbois Exp $
-*
-* Class: FileBitstreamReaderAgent
-*
-* Description: Retrieve code-blocks codewords in the bit stream
-*
-*
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-* */
-using CSJ2K.j2k.decoder;
-using CSJ2K.j2k.entropy.decoder;
-using CSJ2K.j2k.image;
-using CSJ2K.j2k.io;
-using CSJ2K.j2k.quantization.dequantizer;
-using CSJ2K.j2k.util;
-using CSJ2K.j2k.wavelet.synthesis;
-using System;
-namespace CSJ2K.j2k.codestream.reader
-{
-
- /// This class reads the bit stream (with the help of HeaderDecoder for tile
- /// headers and PktDecoder for packets header and body) and retrives location
- /// of all code-block's codewords.
- ///
- /// Note: All tile-parts headers are read by the constructor whereas packets
- /// are processed when decoding related tile (when setTile method is
- /// called).
- ///
- /// In parsing mode, the reader simulates a virtual layer-resolution
- /// progressive bit stream with the same truncation points in each code-block,
- /// whereas in truncation mode, only the first bytes are taken into account (it
- /// behaves like if it is a real truncated codestream).
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- public class FileBitstreamReaderAgent : BitstreamReaderAgent
- {
- /// Gets the reference to the CBlkInfo array
- virtual public CBlkInfo[][][][][] CBlkInfo
- {
- get
- {
- return cbI;
- }
-
- }
-
- /// Whether or not the last read Psot value was zero. Only the Psot in the
- /// last tile-part in the codestream can have such a value.
- ///
- private bool isPsotEqualsZero = true;
-
- /// Reference to the PktDecoder instance
- public PktDecoder pktDec;
-
- /// Reference to the ParameterList instance
- private ParameterList pl;
-
- /// The RandomAccessIO where to get data from
- private RandomAccessIO in_Renamed;
-
- /// Offset of the first packet in each tile-part in each tile
- private int[][] firstPackOff;
-
- /// Returns the number of tile-part found for a given tile
- ///
- ///
- /// Tile index
- ///
- ///
- ///
- public virtual int getNumTileParts(int t)
- {
- if (firstPackOff == null || firstPackOff[t] == null)
- {
- throw new System.ApplicationException("Tile " + t + " not found in input codestream.");
- }
- return firstPackOff[t].Length;
- }
-
- /// Number of bytes allocated to each tile. In parsing mode, this number
- /// is related to the tile length in the codestream whereas in truncation
- /// mode all the rate is affected to the first tiles.
- ///
- private int[] nBytes;
-
- /// Whether or not to print information found in codestream
- private bool printInfo = false;
-
- /// Backup of the number of bytes allocated to each tile. This array is
- /// used to restore the number of bytes to read in each tile when the
- /// codestream is read several times (for instance when decoding an R,G,B
- /// image to three output files)
- ///
- ///
- private int[] baknBytes;
-
- /// Length of each tile-part (written in Psot)
- private int[][] tilePartLen;
-
- /// Total length of each tile
- private int[] totTileLen;
-
- /// Total length of tiles' header
- private int[] totTileHeadLen;
-
- /// First tile part header length
- private int firstTilePartHeadLen;
-
- /// Total length of all tile parts in all tiles
- private double totAllTileLen;
-
- /// Length of main header
- private int mainHeadLen;
-
- /// Length of main and tile-parts headers
- private int headLen = 0;
-
- /// Length of all tile-part headers
- private int[][] tilePartHeadLen;
-
- /// Length of each packet head found in the tile
- private System.Collections.ArrayList pktHL;
-
- /// Layer starting positions
- public System.Collections.Generic.List layerStarts;
-
- /// True if truncation mode is used. False if parsing mode
- private bool isTruncMode;
-
- /// The number of tile-parts that remain to read
- private int remainingTileParts;
-
- /// The number of tile-parts read so far for each tile
- private int[] tilePartsRead;
-
- /// Thetotal number of tile-parts read so far
- private int totTilePartsRead = 0;
-
- /// The number of found tile-parts in each tile.
- private int[] tileParts;
-
- /// The current tile part being used
- private int curTilePart;
-
- /// The number of the tile-parts found in the codestream after reading the
- /// tp'th tile-part of tile t
- ///
- private int[][] tilePartNum;
-
- /// Whether or not a EOC marker has been found instead of a SOT
- private bool isEOCFound = false;
-
- /// Reference to the HeaderInfo instance (used when reading SOT marker
- /// segments)
- ///
- private HeaderInfo hi;
-
- /// Array containing information for all the code-blocks:
- ///
- ///
- /// - 1st dim: component index.
- /// - 2nd dim: resolution level index.
- /// - 3rd dim: subband index.
- /// - 4th/5th dim: code-block index (vert. and horiz.).
- ///
- ///
- private CBlkInfo[][][][][] cbI;
-
- /// The maximum number of layers to decode for any code-block
- private int lQuit;
-
- /// Whether or not to use only first progression order
- private bool usePOCQuit = false;
-
- /// Reads all tiles headers and keep offset of their first
- /// packet. Finally it calls the rate allocation method.
- ///
- ///
- /// HeaderDecoder of the codestream.
- ///
- ///
- /// The input stream where to read bit-stream.
- ///
- ///
- /// The decoder specifications
- ///
- ///
- /// The ParameterList instance created from the
- /// command-line arguments.
- ///
- ///
- /// Whether or not to print information found in
- /// codestream.
- ///
- ///
- ///
- ///
- ///
- public FileBitstreamReaderAgent(HeaderDecoder hd, RandomAccessIO ehs, DecoderSpecs decSpec, ParameterList pl, bool cdstrInfo, HeaderInfo hi) : base(hd, decSpec)
- {
-
- this.pl = pl;
- this.printInfo = cdstrInfo;
- this.hi = hi;
-
- // Check whether quit conditiosn used
- usePOCQuit = pl.getBooleanParameter("poc_quit");
-
- // Get decoding rate
- bool rateInBytes;
- bool parsing = pl.getBooleanParameter("parsing");
- try
- {
- trate = pl.getFloatParameter("rate");
- if (trate == -1)
- {
- trate = System.Single.MaxValue;
- }
- }
- catch (System.FormatException)
- {
- throw new System.ApplicationException("Invalid value in 'rate' option: " + pl.getParameter("rate"));
- }
- catch (System.ArgumentException)
- {
- throw new System.ApplicationException("'rate' option is missing");
- }
-
- try
- {
- tnbytes = pl.getIntParameter("nbytes");
- }
- catch (System.FormatException)
- {
- throw new System.ApplicationException("Invalid value in 'nbytes' option: " + pl.getParameter("nbytes"));
- }
- catch (System.ArgumentException)
- {
- throw new System.ApplicationException("'nbytes' option is missing");
- }
-
- // Check that '-rate' and '-nbytes' are not used at the same time
- ParameterList defaults = pl.DefaultParameterList;
- if (tnbytes != defaults.getFloatParameter("nbytes"))
- {
- rateInBytes = true;
- }
- else
- {
- rateInBytes = false;
- }
-
- if (rateInBytes)
- {
- trate = tnbytes * 8f / hd.MaxCompImgWidth / hd.MaxCompImgHeight;
- }
- else
- {
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- tnbytes = (int)(trate * hd.MaxCompImgWidth * hd.MaxCompImgHeight) / 8;
- if (tnbytes < 0) tnbytes = int.MaxValue;
- }
- isTruncMode = !pl.getBooleanParameter("parsing");
-
- // Check if quit conditions are being used
- int ncbQuit;
- try
- {
- ncbQuit = pl.getIntParameter("ncb_quit");
- }
- catch (System.FormatException)
- {
- throw new System.ApplicationException("Invalid value in 'ncb_quit' option: " + pl.getParameter("ncb_quit"));
- }
- catch (System.ArgumentException)
- {
- throw new System.ApplicationException("'ncb_quit' option is missing");
- }
- if (ncbQuit != -1 && !isTruncMode)
- {
- throw new System.ApplicationException("Cannot use -parsing and -ncb_quit condition at " + "the same time.");
- }
-
- try
- {
- lQuit = pl.getIntParameter("l_quit");
- }
- catch (System.FormatException)
- {
- throw new System.ApplicationException("Invalid value in 'l_quit' option: " + pl.getParameter("l_quit"));
- }
- catch (System.ArgumentException)
- {
- throw new System.ApplicationException("'l_quit' option is missing");
- }
-
- // initializations
- in_Renamed = ehs;
- pktDec = new PktDecoder(decSpec, hd, ehs, this, isTruncMode, ncbQuit);
-
- tileParts = new int[nt];
- totTileLen = new int[nt];
- tilePartLen = new int[nt][];
- tilePartNum = new int[nt][];
- firstPackOff = new int[nt][];
- tilePartsRead = new int[nt];
- totTileHeadLen = new int[nt];
- tilePartHeadLen = new int[nt][];
- nBytes = new int[nt];
- baknBytes = new int[nt];
- hd.nTileParts = new int[nt];
-
- // CONVERSION PROBLEM?
- //this.isTruncMode = isTruncMode;
- int t = 0, pos, tp = 0, tptot = 0;
-
- // Keeps main header's length, takes file format overhead into account
- int cdstreamStart = hd.mainHeadOff; // Codestream offset in the file
- mainHeadLen = in_Renamed.Pos - cdstreamStart;
- headLen = mainHeadLen;
-
- // If ncb and lbody quit conditions are used, headers are not counted
- if (ncbQuit == -1)
- {
- anbytes = mainHeadLen;
- }
- else
- {
- anbytes = 0;
- }
-
- // If cannot even read the first tile-part
- if (anbytes > tnbytes)
- {
- throw new System.ApplicationException("Requested bitrate is too small.");
- }
-
- // Read all tile-part headers from all tiles.
- int tilePartStart;
- bool rateReached = false;
- int mdl;
- //int numtp = 0;
- totAllTileLen = 0;
- remainingTileParts = nt; // at least as many tile-parts as tiles
- int maxTP = nt; // If maximum 1 tile part per tile specified
-
- try
- {
- while (remainingTileParts != 0)
- {
-
- tilePartStart = in_Renamed.Pos;
- // Read tile-part header
- try
- {
- t = readTilePartHeader();
- if (isEOCFound)
- {
- // Some tiles are missing but the
- // codestream is OK
- break;
- }
- tp = tilePartsRead[t];
- if (isPsotEqualsZero)
- {
- // Psot may equals zero for the
- // last tile-part: it is assumed that this tile-part
- // contain all data until EOC
- tilePartLen[t][tp] = in_Renamed.length() - 2 - tilePartStart;
- }
- }
- catch (System.IO.EndOfStreamException e)
- {
- firstPackOff[t][tp] = in_Renamed.length();
- throw e;
- }
-
- pos = in_Renamed.Pos;
-
- // In truncation mode, if target decoding rate is reached in
- // tile-part header, skips the tile-part and stop reading
- // unless the ncb and lbody quit condition is in use
- if (isTruncMode && ncbQuit == -1)
- {
- if ((pos - cdstreamStart) > tnbytes)
- {
- firstPackOff[t][tp] = in_Renamed.length();
- rateReached = true;
- break;
- }
- }
-
- // Set tile part position and header length
- firstPackOff[t][tp] = pos;
- tilePartHeadLen[t][tp] = (pos - tilePartStart);
-
- // Update length counters
- totTileLen[t] += tilePartLen[t][tp];
- totTileHeadLen[t] += tilePartHeadLen[t][tp];
- totAllTileLen += tilePartLen[t][tp];
- if (isTruncMode)
- {
- if (anbytes + tilePartLen[t][tp] > tnbytes)
- {
- anbytes += tilePartHeadLen[t][tp];
- headLen += tilePartHeadLen[t][tp];
- rateReached = true;
- nBytes[t] += (tnbytes - anbytes);
- break;
- }
- else
- {
- anbytes += tilePartHeadLen[t][tp];
- headLen += tilePartHeadLen[t][tp];
- nBytes[t] += (tilePartLen[t][tp] - tilePartHeadLen[t][tp]);
- }
- }
- else
- {
- if (anbytes + tilePartHeadLen[t][tp] > tnbytes)
- {
- break;
- }
- else
- {
- anbytes += tilePartHeadLen[t][tp];
- headLen += tilePartHeadLen[t][tp];
- }
- }
-
- // If this is first tile-part, remember header length
- if (tptot == 0)
- firstTilePartHeadLen = tilePartHeadLen[t][tp];
-
- // Go to the beginning of next tile part
- tilePartsRead[t]++;
- in_Renamed.seek(tilePartStart + tilePartLen[t][tp]);
- remainingTileParts--;
- maxTP--;
- tptot++;
-
- // If Psot of the current tile-part was equal to zero, it is
- // assumed that it contains all data until the EOC marker
- if (isPsotEqualsZero)
- {
- if (remainingTileParts != 0)
- {
- FacilityManager.getMsgLogger().printmsg(CSJ2K.j2k.util.MsgLogger_Fields.WARNING, "Some tile-parts have not " + "been found. The codestream may be corrupted.");
- }
- break;
- }
- }
- }
- catch (System.IO.EndOfStreamException)
- {
- if (printInfo)
- {
- }
- FacilityManager.getMsgLogger().printmsg(CSJ2K.j2k.util.MsgLogger_Fields.WARNING, "Codestream truncated in tile " + t);
-
- // Set specified rate to end of file if valid
- int fileLen = in_Renamed.length();
- if (fileLen < tnbytes)
- {
- tnbytes = fileLen;
- trate = tnbytes * 8f / hd.MaxCompImgWidth / hd.MaxCompImgHeight;
- }
-
- // Bit-rate allocation
- if (!isTruncMode)
- {
- allocateRate();
- }
-
- // Update 'res' value once all tile-part headers are read
- if (pl.getParameter("res") == null)
- {
- targetRes = decSpec.dls.Min;
- }
- else
- {
- try
- {
- targetRes = pl.getIntParameter("res");
- if (targetRes < 0)
- {
- throw new System.ArgumentException("Specified negative " + "resolution level " + "index: " + targetRes);
- }
- }
- catch (System.FormatException)
- {
- throw new System.ArgumentException("Invalid resolution level " + "index ('-res' option) " + pl.getParameter("res"));
- }
- }
-
- // Verify reduction in resolution level
- mdl = decSpec.dls.Min;
- if (targetRes > mdl)
- {
- FacilityManager.getMsgLogger().printmsg(CSJ2K.j2k.util.MsgLogger_Fields.WARNING, "Specified resolution level (" + targetRes + ") is larger" + " than the maximum value. Setting it to " + mdl + " (maximum value)");
- targetRes = mdl;
- }
-
- // Backup nBytes
- for (int tIdx = 0; tIdx < nt; tIdx++)
- {
- baknBytes[tIdx] = nBytes[tIdx];
- }
-
- return;
- }
- remainingTileParts = 0;
-
- // Update 'res' value once all tile-part headers are read
- if (pl.getParameter("res") == null)
- {
- targetRes = decSpec.dls.Min;
- }
- else
- {
- try
- {
- targetRes = pl.getIntParameter("res");
- if (targetRes < 0)
- {
- throw new System.ArgumentException("Specified negative " + "resolution level index: " + targetRes);
- }
- }
- catch (System.FormatException)
- {
- throw new System.ArgumentException("Invalid resolution level " + "index ('-res' option) " + pl.getParameter("res"));
- }
- }
-
- // Verify reduction in resolution level
- mdl = decSpec.dls.Min;
- if (targetRes > mdl)
- {
- FacilityManager.getMsgLogger().printmsg(CSJ2K.j2k.util.MsgLogger_Fields.WARNING, "Specified resolution level (" + targetRes + ") is larger" + " than the maximum possible. Setting it to " + mdl + " (maximum possible)");
- targetRes = mdl;
- }
-
- if (printInfo)
- {
- }
-
- // Check presence of EOC marker is decoding rate not reached or if
- // this marker has not been found yet
- if (!isEOCFound && !isPsotEqualsZero)
- {
- try
- {
- short eocCheck = 0;
- if (in_Renamed.Pos + sizeof(short) <= in_Renamed.length())
- eocCheck = in_Renamed.readShort();
-
- if (!rateReached && !isPsotEqualsZero && eocCheck != CSJ2K.j2k.codestream.Markers.EOC)
- {
- FacilityManager.getMsgLogger().printmsg(CSJ2K.j2k.util.MsgLogger_Fields.WARNING, "EOC marker not found. " + "Codestream is corrupted.");
- }
- }
- catch (System.IO.EndOfStreamException)
- {
- FacilityManager.getMsgLogger().printmsg(CSJ2K.j2k.util.MsgLogger_Fields.WARNING, "EOC marker is missing");
- }
- }
-
- // Bit-rate allocation
- if (!isTruncMode)
- {
- allocateRate();
- }
- else
- {
- // Take EOC into account if rate is not reached
- if (in_Renamed.Pos >= tnbytes)
- anbytes += 2;
- }
-
- // Backup nBytes
- for (int tIdx = 0; tIdx < nt; tIdx++)
- {
- baknBytes[tIdx] = nBytes[tIdx];
- if (printInfo)
- {
- FacilityManager.getMsgLogger().println("" + hi.toStringTileHeader(tIdx, tilePartLen[tIdx].Length), 2, 2);
- }
- }
- }
-
- /// Allocates output bit-rate for each tile in parsing mode: The allocator
- /// simulates the truncation of a virtual layer-resolution progressive
- /// codestream.
- ///
- ///
- private void allocateRate()
- {
- int stopOff = tnbytes;
-
- // In parsing mode, the bitrate is allocated related to each tile's
- // length in the bit stream
-
- // EOC marker's length
- anbytes += 2;
-
- // If there are too few bytes to read the tile part headers throw an
- // error
- if (anbytes > stopOff)
- {
- throw new System.ApplicationException("Requested bitrate is too small for parsing");
- }
-
- // Calculate bitrate for each tile
- int rem = stopOff - anbytes;
- int totnByte = rem;
- for (int t = nt - 1; t > 0; t--)
- {
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- rem -= (nBytes[t] = (int)(totnByte * (totTileLen[t] / totAllTileLen)));
- }
- nBytes[0] = rem;
- }
-
- /// Reads SOT marker segment of the tile-part header and calls related
- /// methods of the HeaderDecoder to read other markers segments. The
- /// tile-part header is entirely read when a SOD marker is encountered.
- ///
- ///
- /// The tile number of the tile part that was read
- ///
- ///
- private int readTilePartHeader()
- {
- HeaderInfo.SOT ms = hi.NewSOT;
-
- // SOT marker
- short marker = in_Renamed.readShort();
- if (marker != CSJ2K.j2k.codestream.Markers.SOT)
- {
- if (marker == CSJ2K.j2k.codestream.Markers.EOC)
- {
- isEOCFound = true;
- return -1;
- }
- else
- {
- throw new CorruptedCodestreamException("SOT tag not found " + "in tile-part start");
- }
- }
- isEOCFound = false;
-
- // Lsot (shall equals 10)
- int lsot = in_Renamed.readUnsignedShort();
- ms.lsot = lsot;
- if (lsot != 10)
- throw new CorruptedCodestreamException("Wrong length for " + "SOT marker segment: " + lsot);
-
- // Isot
- int tile = in_Renamed.readUnsignedShort();
- ms.isot = tile;
- if (tile > 65534)
- {
- throw new CorruptedCodestreamException("Tile index too high in " + "tile-part.");
- }
-
- // Psot
- int psot = in_Renamed.readInt();
- ms.psot = psot;
- isPsotEqualsZero = (psot != 0) ? false : true;
- if (psot < 0)
- {
- throw new NotImplementedException("Tile length larger " + "than maximum supported");
- }
- // TPsot
- int tilePart = in_Renamed.read();
- ms.tpsot = tilePart;
- if (tilePart != tilePartsRead[tile] || tilePart < 0 || tilePart > 254)
- {
- throw new CorruptedCodestreamException("Out of order tile-part");
- }
- // TNsot
- int nrOfTileParts = in_Renamed.read();
- ms.tnsot = nrOfTileParts;
- hi.sotValue["t" + tile + "_tp" + tilePart] = ms;
- if (nrOfTileParts == 0)
- {
- // The number of tile-part is not specified in
- // this tile-part header.
-
- // Assumes that there will be another tile-part in the codestream
- // that will indicate the number of tile-parts for this tile)
- int nExtraTp;
- if (tileParts[tile] == 0 || tileParts[tile] == tilePartLen.Length)
- {
- // Then there are two tile-parts (one is the current and the
- // other will indicate the number of tile-part for this tile)
- nExtraTp = 2;
- remainingTileParts += 1;
- }
- else
- {
- // There is already one scheduled extra tile-part. In this
- // case just add place for the current one
- nExtraTp = 1;
- }
-
- tileParts[tile] += nExtraTp;
- nrOfTileParts = tileParts[tile];
- FacilityManager.getMsgLogger().printmsg(CSJ2K.j2k.util.MsgLogger_Fields.WARNING, "Header of tile-part " + tilePart + " of tile " + tile + ", does not indicate the total" + " number of tile-parts. Assuming that there are " + nrOfTileParts + " tile-parts for this tile.");
-
- // Increase and re-copy tilePartLen array
- int[] tmpA = tilePartLen[tile];
- tilePartLen[tile] = new int[nrOfTileParts];
- for (int i = 0; i < nrOfTileParts - nExtraTp; i++)
- {
- tilePartLen[tile][i] = tmpA[i];
- }
-
- // Increase and re-copy tilePartNum array
- tmpA = tilePartNum[tile];
- tilePartNum[tile] = new int[nrOfTileParts];
- for (int i = 0; i < nrOfTileParts - nExtraTp; i++)
- {
- tilePartNum[tile][i] = tmpA[i];
- }
-
- // Increase and re-copy firsPackOff array
- tmpA = firstPackOff[tile];
- firstPackOff[tile] = new int[nrOfTileParts];
- for (int i = 0; i < nrOfTileParts - nExtraTp; i++)
- {
- firstPackOff[tile][i] = tmpA[i];
- }
-
- // Increase and re-copy tilePartHeadLen array
- tmpA = tilePartHeadLen[tile];
- tilePartHeadLen[tile] = new int[nrOfTileParts];
- for (int i = 0; i < nrOfTileParts - nExtraTp; i++)
- {
- tilePartHeadLen[tile][i] = tmpA[i];
- }
- }
- else
- {
- // The number of tile-parts is specified in the tile-part
- // header
-
- // Check if it is consistant with what was found in previous
- // tile-part headers
-
- if (tileParts[tile] == 0)
- {
- // First tile-part: OK
- remainingTileParts += nrOfTileParts - 1;
- tileParts[tile] = nrOfTileParts;
- tilePartLen[tile] = new int[nrOfTileParts];
- tilePartNum[tile] = new int[nrOfTileParts];
- firstPackOff[tile] = new int[nrOfTileParts];
- tilePartHeadLen[tile] = new int[nrOfTileParts];
- }
- else if (tileParts[tile] > nrOfTileParts)
- {
- // Already found more tile-parts than signaled here
- throw new CorruptedCodestreamException("Invalid number " + "of tile-parts in" + " tile " + tile + ": " + nrOfTileParts);
- }
- else
- {
- // Signaled number of tile-part fits with number of
- // previously found tile-parts
- remainingTileParts += nrOfTileParts - tileParts[tile];
-
- if (tileParts[tile] != nrOfTileParts)
- {
-
- // Increase and re-copy tilePartLen array
- int[] tmpA = tilePartLen[tile];
- tilePartLen[tile] = new int[nrOfTileParts];
- for (int i = 0; i < tileParts[tile] - 1; i++)
- {
- tilePartLen[tile][i] = tmpA[i];
- }
-
- // Increase and re-copy tilePartNum array
- tmpA = tilePartNum[tile];
- tilePartNum[tile] = new int[nrOfTileParts];
- for (int i = 0; i < tileParts[tile] - 1; i++)
- {
- tilePartNum[tile][i] = tmpA[i];
- }
-
- // Increase and re-copy firstPackOff array
- tmpA = firstPackOff[tile];
- firstPackOff[tile] = new int[nrOfTileParts];
- for (int i = 0; i < tileParts[tile] - 1; i++)
- {
- firstPackOff[tile][i] = tmpA[i];
- }
-
- // Increase and re-copy tilePartHeadLen array
- tmpA = tilePartHeadLen[tile];
- tilePartHeadLen[tile] = new int[nrOfTileParts];
- for (int i = 0; i < tileParts[tile] - 1; i++)
- {
- tilePartHeadLen[tile][i] = tmpA[i];
- }
- }
- }
- }
-
- // Other markers
- hd.resetHeaderMarkers();
- hd.nTileParts[tile] = nrOfTileParts;
- // Decode and store the tile-part header (i.e. until a SOD marker is
- // found)
- do
- {
- hd.extractTilePartMarkSeg(in_Renamed.readShort(), in_Renamed, tile, tilePart);
- }
- while ((hd.NumFoundMarkSeg & CSJ2K.j2k.codestream.reader.HeaderDecoder.SOD_FOUND) == 0);
-
- // Read each marker segment previously found
- hd.readFoundTilePartMarkSeg(tile, tilePart);
-
- tilePartLen[tile][tilePart] = psot;
-
- tilePartNum[tile][tilePart] = totTilePartsRead;
- totTilePartsRead++;
-
- // Add to list of which tile each successive tile-part belongs.
- // This list is needed if there are PPM markers used
- hd.TileOfTileParts = tile;
-
- return tile;
- }
-
- /// Reads packets of the current tile according to the
- /// layer-resolution-component-position progressiveness.
- ///
- ///
- /// Index of the first layer for each component and resolution.
- ///
- ///
- /// Index of the last layer.
- ///
- ///
- /// Index of the first resolution level.
- ///
- ///
- /// Index of the last resolution level.
- ///
- ///
- /// Index of the first component.
- ///
- ///
- /// Index of the last component.
- ///
- ///
- /// True if rate has been reached.
- ///
- ///
- private bool readLyResCompPos(int[][] lys, int lye, int ress, int rese, int comps, int compe)
- {
-
- int minlys = 10000;
- for (int c = comps; c < compe; c++)
- {
- //loop on components
- // Check if this component exists
- if (c >= mdl.Length)
- continue;
-
- for (int r = ress; r < rese; r++)
- {
- //loop on resolution levels
- if (lys[c] != null && r < lys[c].Length && lys[c][r] < minlys)
- {
- minlys = lys[c][r];
- }
- }
- }
-
- int t = TileIdx;
- int start;
- bool status = false;
- int lastByte = firstPackOff[t][curTilePart] + tilePartLen[t][curTilePart] - 1 - tilePartHeadLen[t][curTilePart];
- int numLayers = ((System.Int32)decSpec.nls.getTileDef(t));
- int nPrec = 1;
- int hlen, plen;
- bool pph = false;
- if (((System.Boolean)decSpec.pphs.getTileDef(t)))
- {
- pph = true;
- }
- for (int l = minlys; l < lye; l++)
- {
- // store the layer starting position
- layerStarts.Add(in_Renamed.Pos);
-
- // loop on layers
- for (int r = ress; r < rese; r++)
- {
- // loop on resolution levels
- for (int c = comps; c < compe; c++)
- {
- // loop on components
- // Checks if component exists
- if (c >= mdl.Length)
- continue;
- // Checks if resolution level exists
- if (r >= lys[c].Length)
- continue;
- if (r > mdl[c])
- continue;
- // Checks if layer exists
- if (l < lys[c][r] || l >= numLayers)
- continue;
-
- nPrec = pktDec.getNumPrecinct(c, r);
- for (int p = 0; p < nPrec; p++)
- {
- // loop on precincts
- start = in_Renamed.Pos;
-
- // If packed packet headers are used, there is no need
- // to check that there are bytes enough to read header
- if (pph)
- {
- pktDec.readPktHead(l, r, c, p, cbI[c][r], nBytes);
- }
-
- // If we are about to read outside of tile-part,
- // skip to next tile-part
- if (start > lastByte && curTilePart < firstPackOff[t].Length - 1)
- {
- curTilePart++;
- in_Renamed.seek(firstPackOff[t][curTilePart]);
- lastByte = in_Renamed.Pos + tilePartLen[t][curTilePart] - 1 - tilePartHeadLen[t][curTilePart];
- }
-
- // Read SOP marker segment if necessary
- status = pktDec.readSOPMarker(nBytes, p, c, r);
-
- if (status)
- {
- if (printInfo)
- {
- }
- return true;
- }
-
- if (!pph)
- {
- status = pktDec.readPktHead(l, r, c, p, cbI[c][r], nBytes);
- }
-
- if (status)
- {
- if (printInfo)
- {
- }
- return true;
- }
-
- // Store packet's head length
- hlen = in_Renamed.Pos - start;
- pktHL.Add((System.Int32)hlen);
-
- // Reads packet's body
- status = pktDec.readPktBody(l, r, c, p, cbI[c][r], nBytes);
- plen = in_Renamed.Pos - start;
-
- if (status)
- {
- if (printInfo)
- {
- }
- return true;
- }
- } // end loop on precincts
- } // end loop on components
- } // end loop on resolution levels
- } // end loop on layers
-
- if (printInfo)
- {
- }
- return false; // Decoding rate was not reached
- }
-
- /// Reads packets of the current tile according to the
- /// resolution-layer-component-position progressiveness.
- ///
- ///
- /// Index of the first layer for each component and resolution.
- ///
- ///
- /// Index of the last layer.
- ///
- ///
- /// Index of the first resolution level.
- ///
- ///
- /// Index of the last resolution level.
- ///
- ///
- /// Index of the first component.
- ///
- ///
- /// Index of the last component.
- ///
- ///
- /// True if rate has been reached.
- ///
- ///
- private bool readResLyCompPos(int[][] lys, int lye, int ress, int rese, int comps, int compe)
- {
-
- int t = TileIdx; // Current tile index
- bool status = false; // True if decoding rate is reached when
- int lastByte = firstPackOff[t][curTilePart] + tilePartLen[t][curTilePart] - 1 - tilePartHeadLen[t][curTilePart];
- int minlys = 10000;
- for (int c = comps; c < compe; c++)
- {
- //loop on components
- // Check if this component exists
- if (c >= mdl.Length)
- continue;
-
- for (int r = ress; r < rese; r++)
- {
- //loop on resolution levels
- if (r > mdl[c])
- continue;
- if (lys[c] != null && r < lys[c].Length && lys[c][r] < minlys)
- {
- minlys = lys[c][r];
- }
- }
- }
-
- int numLayers = ((System.Int32)decSpec.nls.getTileDef(t));
- bool pph = false;
- if (((System.Boolean)decSpec.pphs.getTileDef(t)))
- {
- pph = true;
- }
- int nPrec = 1;
- int start;
- int hlen, plen;
- for (int r = ress; r < rese; r++)
- {
- // loop on resolution levels
- for (int l = minlys; l < lye; l++)
- {
- // loop on layers
- for (int c = comps; c < compe; c++)
- {
- // loop on components
- // Checks if component exists
- if (c >= mdl.Length)
- continue;
- // Checks if resolution level exists
- if (r > mdl[c])
- continue;
- if (r >= lys[c].Length)
- continue;
- // Checks if layer exists
- if (l < lys[c][r] || l >= numLayers)
- continue;
-
- nPrec = pktDec.getNumPrecinct(c, r);
-
- for (int p = 0; p < nPrec; p++)
- {
- // loop on precincts
- start = in_Renamed.Pos;
-
- // If packed packet headers are used, there is no need
- // to check that there are bytes enough to read header
- if (pph)
- {
- pktDec.readPktHead(l, r, c, p, cbI[c][r], nBytes);
- }
-
- // If we are about to read outside of tile-part,
- // skip to next tile-part
- if (start > lastByte && curTilePart < firstPackOff[t].Length - 1)
- {
- curTilePart++;
- in_Renamed.seek(firstPackOff[t][curTilePart]);
- lastByte = in_Renamed.Pos + tilePartLen[t][curTilePart] - 1 - tilePartHeadLen[t][curTilePart];
- }
-
- // Read SOP marker segment if necessary
- status = pktDec.readSOPMarker(nBytes, p, c, r);
-
- if (status)
- {
- if (printInfo)
- {
- }
- return true;
- }
-
- if (!pph)
- {
- status = pktDec.readPktHead(l, r, c, p, cbI[c][r], nBytes);
- }
-
- if (status)
- {
- if (printInfo)
- {
- }
- // Output rate of EOF reached
- return true;
- }
-
- // Store packet's head length
- hlen = in_Renamed.Pos - start;
- pktHL.Add((System.Int32)hlen);
-
- // Reads packet's body
- status = pktDec.readPktBody(l, r, c, p, cbI[c][r], nBytes);
- plen = in_Renamed.Pos - start;
-
- if (status)
- {
- if (printInfo)
- {
- }
- // Output rate or EOF reached
- return true;
- }
- } // end loop on precincts
- } // end loop on components
- } // end loop on layers
- } // end loop on resolution levels
-
- if (printInfo)
- {
- }
- return false; // Decoding rate was not reached
- }
-
- /// Reads packets of the current tile according to the
- /// resolution-position-component-layer progressiveness.
- ///
- ///
- /// Index of the first layer for each component and resolution.
- ///
- ///
- /// Index of the last layer.
- ///
- ///
- /// Index of the first resolution level.
- ///
- ///
- /// Index of the last resolution level.
- ///
- ///
- /// Index of the first component.
- ///
- ///
- /// Index of the last component.
- ///
- ///
- /// True if rate has been reached.
- ///
- ///
- private bool readResPosCompLy(int[][] lys, int lye, int ress, int rese, int comps, int compe)
- {
- // Computes current tile offset in the reference grid
-
- Coord nTiles = getNumTiles(null);
- Coord tileI = getTile(null);
- int x0siz = hd.ImgULX;
- int y0siz = hd.ImgULY;
- int xsiz = x0siz + hd.ImgWidth;
- int ysiz = y0siz + hd.ImgHeight;
- int xt0siz = TilePartULX;
- int yt0siz = TilePartULY;
- int xtsiz = NomTileWidth;
- int ytsiz = NomTileHeight;
- int tx0 = (tileI.x == 0) ? x0siz : xt0siz + tileI.x * xtsiz;
- int ty0 = (tileI.y == 0) ? y0siz : yt0siz + tileI.y * ytsiz;
- int tx1 = (tileI.x != nTiles.x - 1) ? xt0siz + (tileI.x + 1) * xtsiz : xsiz;
- int ty1 = (tileI.y != nTiles.y - 1) ? yt0siz + (tileI.y + 1) * ytsiz : ysiz;
-
- // Get precinct information (number,distance between two consecutive
- // precincts in the reference grid) in each component and resolution
- // level
- int t = TileIdx; // Current tile index
- PrecInfo prec; // temporary variable
- int p; // Current precinct index
- int gcd_x = 0; // Horiz. distance between 2 precincts in the ref. grid
- int gcd_y = 0; // Vert. distance between 2 precincts in the ref. grid
- int nPrec = 0; // Total number of found precincts
- int[][] nextPrec = new int[compe][]; // Next precinct index in each
- // component and resolution level
- int minlys = 100000; // minimum layer start index of each component
- int minx = tx1; // Horiz. offset of the second precinct in the
- // reference grid
- int miny = ty1; // Vert. offset of the second precinct in the
- // reference grid.
- int maxx = tx0; // Max. horiz. offset of precincts in the ref. grid
- int maxy = ty0; // Max. vert. offset of precincts in the ref. grid
- //Coord numPrec;
- for (int c = comps; c < compe; c++)
- {
- // components
- for (int r = ress; r < rese; r++)
- {
- // resolution levels
- if (c >= mdl.Length)
- continue;
- if (r > mdl[c])
- continue;
- nextPrec[c] = new int[mdl[c] + 1];
- if (lys[c] != null && r < lys[c].Length && lys[c][r] < minlys)
- {
- minlys = lys[c][r];
- }
- p = pktDec.getNumPrecinct(c, r) - 1;
- for (; p >= 0; p--)
- {
- prec = pktDec.getPrecInfo(c, r, p);
- if (prec.rgulx != tx0)
- {
- if (prec.rgulx < minx)
- minx = prec.rgulx;
- if (prec.rgulx > maxx)
- maxx = prec.rgulx;
- }
- if (prec.rguly != ty0)
- {
- if (prec.rguly < miny)
- miny = prec.rguly;
- if (prec.rguly > maxy)
- maxy = prec.rguly;
- }
-
- if (nPrec == 0)
- {
- gcd_x = prec.rgw;
- gcd_y = prec.rgh;
- }
- else
- {
- gcd_x = MathUtil.gcd(gcd_x, prec.rgw);
- gcd_y = MathUtil.gcd(gcd_y, prec.rgh);
- }
- nPrec++;
- } // precincts
- } // resolution levels
- } // components
-
- if (nPrec == 0)
- {
- throw new System.ApplicationException("Image cannot have no precinct");
- }
-
- int pyend = (maxy - miny) / gcd_y + 1;
- int pxend = (maxx - minx) / gcd_x + 1;
- int x, y;
- int hlen, plen;
- int start;
- bool status = false;
- int lastByte = firstPackOff[t][curTilePart] + tilePartLen[t][curTilePart] - 1 - tilePartHeadLen[t][curTilePart];
- int numLayers = ((System.Int32)decSpec.nls.getTileDef(t));
- bool pph = false;
- if (((System.Boolean)decSpec.pphs.getTileDef(t)))
- {
- pph = true;
- }
- for (int r = ress; r < rese; r++)
- {
- // loop on resolution levels
- y = ty0;
- x = tx0;
- for (int py = 0; py <= pyend; py++)
- {
- // Vertical precincts
- for (int px = 0; px <= pxend; px++)
- {
- // Horiz. precincts
- for (int c = comps; c < compe; c++)
- {
- // Components
- if (c >= mdl.Length)
- continue;
- if (r > mdl[c])
- continue;
- if (nextPrec[c][r] >= pktDec.getNumPrecinct(c, r))
- {
- continue;
- }
- prec = pktDec.getPrecInfo(c, r, nextPrec[c][r]);
- if ((prec.rgulx != x) || (prec.rguly != y))
- {
- continue;
- }
- for (int l = minlys; l < lye; l++)
- {
- // layers
- if (r >= lys[c].Length)
- continue;
- if (l < lys[c][r] || l >= numLayers)
- continue;
-
- start = in_Renamed.Pos;
-
- // If packed packet headers are used, there is no
- // need to check that there are bytes enough to
- // read header
- if (pph)
- {
- pktDec.readPktHead(l, r, c, nextPrec[c][r], cbI[c][r], nBytes);
- }
-
- // If we are about to read outside of tile-part,
- // skip to next tile-part
- if (start > lastByte && curTilePart < firstPackOff[t].Length - 1)
- {
- curTilePart++;
- in_Renamed.seek(firstPackOff[t][curTilePart]);
- lastByte = in_Renamed.Pos + tilePartLen[t][curTilePart] - 1 - tilePartHeadLen[t][curTilePart];
- }
-
- // Read SOP marker segment if necessary
- status = pktDec.readSOPMarker(nBytes, nextPrec[c][r], c, r);
-
- if (status)
- {
- if (printInfo)
- {
- }
- return true;
- }
-
- if (!pph)
- {
- status = pktDec.readPktHead(l, r, c, nextPrec[c][r], cbI[c][r], nBytes);
- }
-
- if (status)
- {
- if (printInfo)
- {
- }
- return true;
- }
-
- // Store packet's head length
- hlen = in_Renamed.Pos - start;
- pktHL.Add((System.Int32)hlen);
-
- // Reads packet's body
- status = pktDec.readPktBody(l, r, c, nextPrec[c][r], cbI[c][r], nBytes);
- plen = in_Renamed.Pos - start;
-
- if (status)
- {
- if (printInfo)
- {
- }
- return true;
- }
- } // layers
- nextPrec[c][r]++;
- } // Components
- if (px != pxend)
- {
- x = minx + px * gcd_x;
- }
- else
- {
- x = tx0;
- }
- } // Horizontal precincts
- if (py != pyend)
- {
- y = miny + py * gcd_y;
- }
- else
- {
- y = ty0;
- }
- } // Vertical precincts
- } // end loop on resolution levels
-
- if (printInfo)
- {
- }
- return false; // Decoding rate was not reached
- }
-
- /// Reads packets of the current tile according to the
- /// position-component-resolution-layer progressiveness.
- ///
- ///
- /// Index of the first layer for each component and resolution.
- ///
- ///
- /// Index of the last layer.
- ///
- ///
- /// Index of the first resolution level.
- ///
- ///
- /// Index of the last resolution level.
- ///
- ///
- /// Index of the first component.
- ///
- ///
- /// Index of the last component.
- ///
- ///
- /// True if rate has been reached.
- ///
- ///
- private bool readPosCompResLy(int[][] lys, int lye, int ress, int rese, int comps, int compe)
- {
- Coord nTiles = getNumTiles(null);
- Coord tileI = getTile(null);
- int x0siz = hd.ImgULX;
- int y0siz = hd.ImgULY;
- int xsiz = x0siz + hd.ImgWidth;
- int ysiz = y0siz + hd.ImgHeight;
- int xt0siz = TilePartULX;
- int yt0siz = TilePartULY;
- int xtsiz = NomTileWidth;
- int ytsiz = NomTileHeight;
- int tx0 = (tileI.x == 0) ? x0siz : xt0siz + tileI.x * xtsiz;
- int ty0 = (tileI.y == 0) ? y0siz : yt0siz + tileI.y * ytsiz;
- int tx1 = (tileI.x != nTiles.x - 1) ? xt0siz + (tileI.x + 1) * xtsiz : xsiz;
- int ty1 = (tileI.y != nTiles.y - 1) ? yt0siz + (tileI.y + 1) * ytsiz : ysiz;
-
- // Get precinct information (number,distance between two consecutive
- // precincts in the reference grid) in each component and resolution
- // level
- int t = TileIdx; // Current tile index
- PrecInfo prec; // temporary variable
- int p; // Current precinct index
- int gcd_x = 0; // Horiz. distance between 2 precincts in the ref. grid
- int gcd_y = 0; // Vert. distance between 2 precincts in the ref. grid
- int nPrec = 0; // Total number of found precincts
- int[][] nextPrec = new int[compe][]; // Next precinct index in each
- // component and resolution level
- int minlys = 100000; // minimum layer start index of each component
- int minx = tx1; // Horiz. offset of the second precinct in the
- // reference grid
- int miny = ty1; // Vert. offset of the second precinct in the
- // reference grid.
- int maxx = tx0; // Max. horiz. offset of precincts in the ref. grid
- int maxy = ty0; // Max. vert. offset of precincts in the ref. grid
- //Coord numPrec;
- for (int c = comps; c < compe; c++)
- {
- // components
- for (int r = ress; r < rese; r++)
- {
- // resolution levels
- if (c >= mdl.Length)
- continue;
- if (r > mdl[c])
- continue;
- nextPrec[c] = new int[mdl[c] + 1];
- if (lys[c] != null && r < lys[c].Length && lys[c][r] < minlys)
- {
- minlys = lys[c][r];
- }
- p = pktDec.getNumPrecinct(c, r) - 1;
- for (; p >= 0; p--)
- {
- prec = pktDec.getPrecInfo(c, r, p);
- if (prec.rgulx != tx0)
- {
- if (prec.rgulx < minx)
- minx = prec.rgulx;
- if (prec.rgulx > maxx)
- maxx = prec.rgulx;
- }
- if (prec.rguly != ty0)
- {
- if (prec.rguly < miny)
- miny = prec.rguly;
- if (prec.rguly > maxy)
- maxy = prec.rguly;
- }
-
- if (nPrec == 0)
- {
- gcd_x = prec.rgw;
- gcd_y = prec.rgh;
- }
- else
- {
- gcd_x = MathUtil.gcd(gcd_x, prec.rgw);
- gcd_y = MathUtil.gcd(gcd_y, prec.rgh);
- }
- nPrec++;
- } // precincts
- } // resolution levels
- } // components
-
- if (nPrec == 0)
- {
- throw new System.ApplicationException("Image cannot have no precinct");
- }
-
- int pyend = (maxy - miny) / gcd_y + 1;
- int pxend = (maxx - minx) / gcd_x + 1;
- int hlen, plen;
- int start;
- bool status = false;
- int lastByte = firstPackOff[t][curTilePart] + tilePartLen[t][curTilePart] - 1 - tilePartHeadLen[t][curTilePart];
- int numLayers = ((System.Int32)decSpec.nls.getTileDef(t));
- bool pph = false;
- if (((System.Boolean)decSpec.pphs.getTileDef(t)))
- {
- pph = true;
- }
-
- int y = ty0;
- int x = tx0;
- for (int py = 0; py <= pyend; py++)
- {
- // Vertical precincts
- for (int px = 0; px <= pxend; px++)
- {
- // Horiz. precincts
- for (int c = comps; c < compe; c++)
- {
- // Components
- if (c >= mdl.Length)
- continue;
- for (int r = ress; r < rese; r++)
- {
- // Resolution levels
- if (r > mdl[c])
- continue;
- if (nextPrec[c][r] >= pktDec.getNumPrecinct(c, r))
- {
- continue;
- }
- prec = pktDec.getPrecInfo(c, r, nextPrec[c][r]);
- if ((prec.rgulx != x) || (prec.rguly != y))
- {
- continue;
- }
- for (int l = minlys; l < lye; l++)
- {
- // Layers
- if (r >= lys[c].Length)
- continue;
- if (l < lys[c][r] || l >= numLayers)
- continue;
-
- start = in_Renamed.Pos;
-
- // If packed packet headers are used, there is no
- // need to check that there are bytes enough to
- // read header
- if (pph)
- {
- pktDec.readPktHead(l, r, c, nextPrec[c][r], cbI[c][r], nBytes);
- }
-
- // If we are about to read outside of tile-part,
- // skip to next tile-part
- if (start > lastByte && curTilePart < firstPackOff[t].Length - 1)
- {
- curTilePart++;
- in_Renamed.seek(firstPackOff[t][curTilePart]);
- lastByte = in_Renamed.Pos + tilePartLen[t][curTilePart] - 1 - tilePartHeadLen[t][curTilePart];
- }
-
- // Read SOP marker segment if necessary
- status = pktDec.readSOPMarker(nBytes, nextPrec[c][r], c, r);
-
- if (status)
- {
- if (printInfo)
- {
- }
- return true;
- }
-
- if (!pph)
- {
- status = pktDec.readPktHead(l, r, c, nextPrec[c][r], cbI[c][r], nBytes);
- }
-
- if (status)
- {
- if (printInfo)
- {
- }
- return true;
- }
-
- // Store packet's head length
- hlen = in_Renamed.Pos - start;
- pktHL.Add((System.Int32)hlen);
-
- // Reads packet's body
- status = pktDec.readPktBody(l, r, c, nextPrec[c][r], cbI[c][r], nBytes);
- plen = in_Renamed.Pos - start;
-
- if (status)
- {
- if (printInfo)
- {
- }
- return true;
- }
- } // layers
- nextPrec[c][r]++;
- } // Resolution levels
- } // Components
- if (px != pxend)
- {
- x = minx + px * gcd_x;
- }
- else
- {
- x = tx0;
- }
- } // Horizontal precincts
- if (py != pyend)
- {
- y = miny + py * gcd_y;
- }
- else
- {
- y = ty0;
- }
- } // Vertical precincts
-
- if (printInfo)
- {
- }
- return false; // Decoding rate was not reached
- }
-
- /// Reads packets of the current tile according to the
- /// component-position-resolution-layer progressiveness.
- ///
- ///
- /// Index of the first layer for each component and resolution.
- ///
- ///
- /// Index of the last layer.
- ///
- ///
- /// Index of the first resolution level.
- ///
- ///
- /// Index of the last resolution level.
- ///
- ///
- /// Index of the first component.
- ///
- ///
- /// Index of the last component.
- ///
- ///
- /// True if rate has been reached.
- ///
- ///
- private bool readCompPosResLy(int[][] lys, int lye, int ress, int rese, int comps, int compe)
- {
- Coord nTiles = getNumTiles(null);
- Coord tileI = getTile(null);
- int x0siz = hd.ImgULX;
- int y0siz = hd.ImgULY;
- int xsiz = x0siz + hd.ImgWidth;
- int ysiz = y0siz + hd.ImgHeight;
- int xt0siz = TilePartULX;
- int yt0siz = TilePartULY;
- int xtsiz = NomTileWidth;
- int ytsiz = NomTileHeight;
- int tx0 = (tileI.x == 0) ? x0siz : xt0siz + tileI.x * xtsiz;
- int ty0 = (tileI.y == 0) ? y0siz : yt0siz + tileI.y * ytsiz;
- int tx1 = (tileI.x != nTiles.x - 1) ? xt0siz + (tileI.x + 1) * xtsiz : xsiz;
- int ty1 = (tileI.y != nTiles.y - 1) ? yt0siz + (tileI.y + 1) * ytsiz : ysiz;
-
- // Get precinct information (number,distance between two consecutive
- // precincts in the reference grid) in each component and resolution
- // level
- int t = TileIdx; // Current tile index
- PrecInfo prec; // temporary variable
- int p; // Current precinct index
- int gcd_x = 0; // Horiz. distance between 2 precincts in the ref. grid
- int gcd_y = 0; // Vert. distance between 2 precincts in the ref. grid
- int nPrec = 0; // Total number of found precincts
- int[][] nextPrec = new int[compe][]; // Next precinct index in each
- // component and resolution level
- int minlys = 100000; // minimum layer start index of each component
- int minx = tx1; // Horiz. offset of the second precinct in the
- // reference grid
- int miny = ty1; // Vert. offset of the second precinct in the
- // reference grid.
- int maxx = tx0; // Max. horiz. offset of precincts in the ref. grid
- int maxy = ty0; // Max. vert. offset of precincts in the ref. grid
- //Coord numPrec;
- for (int c = comps; c < compe; c++)
- {
- // components
- for (int r = ress; r < rese; r++)
- {
- // resolution levels
- if (c >= mdl.Length)
- continue;
- if (r > mdl[c])
- continue;
- nextPrec[c] = new int[mdl[c] + 1];
- if (lys[c] != null && r < lys[c].Length && lys[c][r] < minlys)
- {
- minlys = lys[c][r];
- }
- p = pktDec.getNumPrecinct(c, r) - 1;
- for (; p >= 0; p--)
- {
- prec = pktDec.getPrecInfo(c, r, p);
- if (prec.rgulx != tx0)
- {
- if (prec.rgulx < minx)
- minx = prec.rgulx;
- if (prec.rgulx > maxx)
- maxx = prec.rgulx;
- }
- if (prec.rguly != ty0)
- {
- if (prec.rguly < miny)
- miny = prec.rguly;
- if (prec.rguly > maxy)
- maxy = prec.rguly;
- }
-
- if (nPrec == 0)
- {
- gcd_x = prec.rgw;
- gcd_y = prec.rgh;
- }
- else
- {
- gcd_x = MathUtil.gcd(gcd_x, prec.rgw);
- gcd_y = MathUtil.gcd(gcd_y, prec.rgh);
- }
- nPrec++;
- } // precincts
- } // resolution levels
- } // components
-
- if (nPrec == 0)
- {
- throw new System.ApplicationException("Image cannot have no precinct");
- }
-
- int pyend = (maxy - miny) / gcd_y + 1;
- int pxend = (maxx - minx) / gcd_x + 1;
- int hlen, plen;
- int start;
- bool status = false;
- int lastByte = firstPackOff[t][curTilePart] + tilePartLen[t][curTilePart] - 1 - tilePartHeadLen[t][curTilePart];
- int numLayers = ((System.Int32)decSpec.nls.getTileDef(t));
- bool pph = false;
- if (((System.Boolean)decSpec.pphs.getTileDef(t)))
- {
- pph = true;
- }
-
- int x, y;
- for (int c = comps; c < compe; c++)
- {
- // components
- if (c >= mdl.Length)
- continue;
- y = ty0;
- x = tx0;
- for (int py = 0; py <= pyend; py++)
- {
- // Vertical precincts
- for (int px = 0; px <= pxend; px++)
- {
- // Horiz. precincts
- for (int r = ress; r < rese; r++)
- {
- // Resolution levels
- if (r > mdl[c])
- continue;
- if (nextPrec[c][r] >= pktDec.getNumPrecinct(c, r))
- {
- continue;
- }
- prec = pktDec.getPrecInfo(c, r, nextPrec[c][r]);
- if ((prec.rgulx != x) || (prec.rguly != y))
- {
- continue;
- }
-
- for (int l = minlys; l < lye; l++)
- {
- // Layers
- if (r >= lys[c].Length)
- continue;
- if (l < lys[c][r])
- continue;
-
- start = in_Renamed.Pos;
-
- // If packed packet headers are used, there is no
- // need to check that there are bytes enough to
- // read header
- if (pph)
- {
- pktDec.readPktHead(l, r, c, nextPrec[c][r], cbI[c][r], nBytes);
- }
-
- // If we are about to read outside of tile-part,
- // skip to next tile-part
- if (start > lastByte && curTilePart < firstPackOff[t].Length - 1)
- {
- curTilePart++;
- in_Renamed.seek(firstPackOff[t][curTilePart]);
- lastByte = in_Renamed.Pos + tilePartLen[t][curTilePart] - 1 - tilePartHeadLen[t][curTilePart];
- }
-
- // Read SOP marker segment if necessary
- status = pktDec.readSOPMarker(nBytes, nextPrec[c][r], c, r);
-
- if (status)
- {
- if (printInfo)
- {
- }
- return true;
- }
-
- if (!pph)
- {
- status = pktDec.readPktHead(l, r, c, nextPrec[c][r], cbI[c][r], nBytes);
- }
-
- if (status)
- {
- if (printInfo)
- {
- }
- return true;
- }
-
- // Store packet's head length
- hlen = in_Renamed.Pos - start;
- pktHL.Add((System.Int32)hlen);
-
- // Reads packet's body
- status = pktDec.readPktBody(l, r, c, nextPrec[c][r], cbI[c][r], nBytes);
- plen = in_Renamed.Pos - start;
-
- if (status)
- {
- if (printInfo)
- {
- }
- return true;
- }
- } // layers
- nextPrec[c][r]++;
- } // Resolution levels
- if (px != pxend)
- {
- x = minx + px * gcd_x;
- }
- else
- {
- x = tx0;
- }
- } // Horizontal precincts
- if (py != pyend)
- {
- y = miny + py * gcd_y;
- }
- else
- {
- y = ty0;
- }
- } // Vertical precincts
- } // components
-
- if (printInfo)
- {
- }
- return false; // Decoding rate was not reached
- }
-
- /// Finish initialization of members for specified tile, reads packets head
- /// of each tile and keeps location of each code-block's codewords. The
- /// last 2 tasks are done by calling specific methods of PktDecoder.
- ///
- /// Then, if a parsing output rate is defined, it keeps information of
- /// first layers only. This operation simulates a creation of a
- /// layer-resolution-component progressive bit-stream which will be next
- /// truncated and decoded.
- ///
- ///
- /// Tile index
- ///
- ///
- ///
- ///
- ///
- private void readTilePkts(int t)
- {
- pktHL = System.Collections.ArrayList.Synchronized(new System.Collections.ArrayList(10));
- layerStarts = new System.Collections.Generic.List(5);
-
- // Number of layers
- int nl = ((System.Int32)decSpec.nls.getTileDef(t));
-
- // If packed packet headers was used, get the packet headers for this
- // tile
- if (((System.Boolean)decSpec.pphs.getTileDef(t)))
- {
- // Gets packed headers as separate input stream
- System.IO.MemoryStream pphbais = hd.getPackedPktHead(t);
-
- // Restarts PktDecoder instance
- cbI = pktDec.restart(this.nc, mdl, nl, cbI, true, pphbais);
- }
- else
- {
- // Restarts PktDecoder instance
- cbI = pktDec.restart(this.nc, mdl, nl, cbI, false, null);
- }
-
- // Reads packets of the tile according to the progression order
- int[][] pocSpec = ((int[][])decSpec.pcs.getTileDef(t));
- int nChg = (pocSpec == null) ? 1 : pocSpec.Length;
-
- // Create an array containing information about changes (progression
- // order type, layers index start, layer index end, resolution level
- // start, resolution level end, component index start, component index
- // end). There is one row per progresion order
- int[][] change = new int[nChg][];
- for (int i = 0; i < nChg; i++)
- {
- change[i] = new int[6];
- }
- int idx = 0; // Index of the current progression order
-
- change[0][1] = 0; // layer start
-
- if (pocSpec == null)
- {
- change[idx][0] = ((System.Int32)decSpec.pos.getTileDef(t));
- // Progression type found in COx marker segments
- change[idx][1] = nl; // Layer index end
- change[idx][2] = 0; // resolution level start
- change[idx][3] = decSpec.dls.getMaxInTile(t) + 1; // res. level end
- change[idx][4] = 0; // Component index start
- change[idx][5] = this.nc; // Component index end
- }
- else
- {
- for (idx = 0; idx < nChg; idx++)
- {
- change[idx][0] = pocSpec[idx][5];
- change[idx][1] = pocSpec[idx][2]; // layer end
- change[idx][2] = pocSpec[idx][0]; // res. lev. start
- change[idx][3] = pocSpec[idx][3]; // res. lev. end
- change[idx][4] = pocSpec[idx][1]; // Comp. index start
- change[idx][5] = pocSpec[idx][4]; // Comp. index end
- }
- }
-
- // Seeks to the first packet of the first tile-part
- try
- {
- // If in truncation mode, the first tile-part may be beyond the
- // target decoding rate. In this case, the offset of the first
- // packet is not defined.
- if (isTruncMode && firstPackOff == null || firstPackOff[t] == null)
- {
- return;
- }
- in_Renamed.seek(firstPackOff[t][0]);
- }
- catch (System.IO.EndOfStreamException)
- {
- FacilityManager.getMsgLogger().printmsg(CSJ2K.j2k.util.MsgLogger_Fields.WARNING, "Codestream truncated in tile " + t);
- return;
- }
-
- curTilePart = 0;
-
- // Start and end indexes for layers, resolution levels and components.
- int lye, ress, rese, comps, compe;
- bool status = false;
- int nb = nBytes[t];
- int[][] lys = new int[this.nc][];
- for (int c = 0; c < this.nc; c++)
- {
- lys[c] = new int[((System.Int32)decSpec.dls.getTileCompVal(t, c)) + 1];
- }
-
- try
- {
- for (int chg = 0; chg < nChg; chg++)
- {
-
- lye = change[chg][1];
- ress = change[chg][2];
- rese = change[chg][3];
- comps = change[chg][4];
- compe = change[chg][5];
-
- switch (change[chg][0])
- {
-
- case CSJ2K.j2k.codestream.ProgressionType.LY_RES_COMP_POS_PROG:
- status = readLyResCompPos(lys, lye, ress, rese, comps, compe);
- break;
-
- case CSJ2K.j2k.codestream.ProgressionType.RES_LY_COMP_POS_PROG:
- status = readResLyCompPos(lys, lye, ress, rese, comps, compe);
- break;
-
- case CSJ2K.j2k.codestream.ProgressionType.RES_POS_COMP_LY_PROG:
- status = readResPosCompLy(lys, lye, ress, rese, comps, compe);
- break;
-
- case CSJ2K.j2k.codestream.ProgressionType.POS_COMP_RES_LY_PROG:
- status = readPosCompResLy(lys, lye, ress, rese, comps, compe);
- break;
-
- case CSJ2K.j2k.codestream.ProgressionType.COMP_POS_RES_LY_PROG:
- status = readCompPosResLy(lys, lye, ress, rese, comps, compe);
- break;
-
- default:
- throw new System.ArgumentException("Not recognized " + "progression type");
-
- }
-
- // Update next first layer index
- for (int c = comps; c < compe; c++)
- {
- if (c >= lys.Length)
- continue;
- for (int r = ress; r < rese; r++)
- {
- if (r >= lys[c].Length)
- continue;
- lys[c][r] = lye;
- }
- }
-
- if (status || usePOCQuit)
- {
- break;
- }
- }
- }
- catch (System.IO.EndOfStreamException e)
- {
- // Should never happen. Truncated codestream are normally found by
- // the class constructor
- throw e;
- }
-
- // In truncation mode, update the number of read bytes
- if (isTruncMode)
- {
- anbytes += nb - nBytes[t];
-
- // If truncation rate is reached
- if (status)
- {
- nBytes[t] = 0;
- }
- }
- else if (nBytes[t] < (totTileLen[t] - totTileHeadLen[t]))
- {
- // In parsing mode, if there is not enough rate to entirely read the
- // tile. Then, parses the bit stream so as to create a virtual
- // layer-resolution-component progressive bit stream that will be
- // truncated and decoded afterwards.
- CBlkInfo cb;
-
- // Systematicaly reject all remaining code-blocks if one
- // code-block, at least, is refused.
- bool reject;
- // Stop reading any data from the bit stream
- bool stopCount = false;
- // Length of each packet's head (in an array)
- int[] pktHeadLen = new int[pktHL.Count];
- for (int i = pktHL.Count - 1; i >= 0; i--)
- {
- pktHeadLen[i] = ((System.Int32)pktHL[i]);
- }
-
- // Parse each code-block, layer per layer until nBytes[t] is
- // reached
- reject = false;
- for (int l = 0; l < nl; l++)
- {
- // layers
- if (cbI == null)
- continue;
- int nc = cbI.Length;
-
- int mres = 0;
- for (int c = 0; c < nc; c++)
- {
- if (cbI[c] != null && cbI[c].Length > mres)
- mres = cbI[c].Length;
- }
- for (int r = 0; r < mres; r++)
- {
- // resolutions
-
- int msub = 0;
- for (int c = 0; c < nc; c++)
- {
- if (cbI[c] != null && cbI[c][r] != null && cbI[c][r].Length > msub)
- msub = cbI[c][r].Length;
- }
- for (int s = 0; s < msub; s++)
- {
- // subbands
- // Only LL subband resolution level 0
- if (r == 0 && s != 0)
- {
- continue;
- }
- else if (r != 0 && s == 0)
- {
- // No LL subband in resolution level > 0
- continue;
- }
-
- int mnby = 0;
- for (int c = 0; c < nc; c++)
- {
- if (cbI[c] != null && cbI[c][r] != null && cbI[c][r][s] != null && cbI[c][r][s].Length > mnby)
- mnby = cbI[c][r][s].Length;
- }
- for (int m = 0; m < mnby; m++)
- {
-
- int mnbx = 0;
- for (int c = 0; c < nc; c++)
- {
- if (cbI[c] != null && cbI[c][r] != null && cbI[c][r][s] != null && cbI[c][r][s][m] != null && cbI[c][r][s][m].Length > mnbx)
- mnbx = cbI[c][r][s][m].Length;
- }
- for (int n = 0; n < mnbx; n++)
- {
-
- for (int c = 0; c < nc; c++)
- {
-
- if (cbI[c] == null || cbI[c][r] == null || cbI[c][r][s] == null || cbI[c][r][s][m] == null || cbI[c][r][s][m][n] == null)
- {
- continue;
- }
- cb = cbI[c][r][s][m][n];
-
- // If no code-block has been refused until
- // now
- if (!reject)
- {
- // Rate is to low to allow reading of
- // packet's head
- if (nBytes[t] < pktHeadLen[cb.pktIdx[l]])
- {
- // Stop parsing
- stopCount = true;
- // Reject all next
- // code-blocks
- reject = true;
- }
- else
- {
- // Rate is enough to read packet's
- // head
- if (!stopCount)
- {
- //If parsing was not stopped
- //Takes into account packet's
- //head length
- nBytes[t] -= pktHeadLen[cb.pktIdx[l]];
- anbytes += pktHeadLen[cb.pktIdx[l]];
- // Set packet's head length to
- // 0, so that it won't be
- // taken into account next
- // time
- pktHeadLen[cb.pktIdx[l]] = 0;
- }
- }
- }
- // Code-block has no data in this layer
- if (cb.len[l] == 0)
- {
- continue;
- }
-
- // Accepts code-block if length is enough,
- // if this code-block was not refused in a
- // previous layer and if no code-block was
- // refused in current component
- if (cb.len[l] < nBytes[t] && !reject)
- {
- nBytes[t] -= cb.len[l];
- anbytes += cb.len[l];
- }
- else
- {
- // Refuses code-block
- // Forgets code-block's data
- cb.len[l] = cb.off[l] = cb.ntp[l] = 0;
- // Refuses all other code-block in
- // current and next component
- reject = true;
- }
- } // End loop on components
- } // End loop on horiz. code-blocks
- } // End loop on vert. code-blocks
- } // End loop on subbands
- } // End loop on resolutions
- } // End loop on layers
- }
- else
- {
- // No parsing for this tile, adds tile's body to the total
- // number of read bytes.
- anbytes += totTileLen[t] - totTileHeadLen[t];
- if (t < getNumTiles() - 1)
- {
- nBytes[t + 1] += nBytes[t] - (totTileLen[t] - totTileHeadLen[t]);
- }
- }
- }
-
-
-
- /// Changes the current tile, given the new indexes. An
- /// IllegalArgumentException is thrown if the indexes do not correspond to
- /// a valid tile.
- ///
- ///
- /// The horizontal indexes the tile.
- ///
- ///
- /// The vertical indexes of the new tile.
- ///
- ///
- public override void setTile(int x, int y)
- {
-
- int i; // counter
- // Check validity of tile indexes
- if (x < 0 || y < 0 || x >= ntX || y >= ntY)
- {
- throw new System.ArgumentException();
- }
- int t = (y * ntX + x);
-
- // Reset number of read bytes if needed
- if (t == 0)
- {
- anbytes = headLen;
- if (!isTruncMode)
- {
- anbytes += 2;
- }
- // Restore values of nBytes
- for (int tIdx = 0; tIdx < nt; tIdx++)
- {
- nBytes[tIdx] = baknBytes[tIdx];
- }
- }
-
- // Set the new current tile
- ctX = x;
- ctY = y;
- // Calculate tile relative points
- int ctox = (x == 0) ? ax : px + x * ntW;
- int ctoy = (y == 0) ? ay : py + y * ntH;
- for (i = nc - 1; i >= 0; i--)
- {
- culx[i] = (ctox + hd.getCompSubsX(i) - 1) / hd.getCompSubsX(i);
- culy[i] = (ctoy + hd.getCompSubsY(i) - 1) / hd.getCompSubsY(i);
- offX[i] = (px + x * ntW + hd.getCompSubsX(i) - 1) / hd.getCompSubsX(i);
- offY[i] = (py + y * ntH + hd.getCompSubsY(i) - 1) / hd.getCompSubsY(i);
- }
-
- // Initialize subband tree and number of resolution levels
- subbTrees = new SubbandSyn[nc];
- mdl = new int[nc];
- derived = new bool[nc];
- params_Renamed = new StdDequantizerParams[nc];
- gb = new int[nc];
-
- for (int c = 0; c < nc; c++)
- {
- derived[c] = decSpec.qts.isDerived(t, c);
- params_Renamed[c] = (StdDequantizerParams)decSpec.qsss.getTileCompVal(t, c);
- gb[c] = ((System.Int32)decSpec.gbs.getTileCompVal(t, c));
- mdl[c] = ((System.Int32)decSpec.dls.getTileCompVal(t, c));
-
- subbTrees[c] = new SubbandSyn(getTileCompWidth(t, c, mdl[c]), getTileCompHeight(t, c, mdl[c]), getResULX(c, mdl[c]), getResULY(c, mdl[c]), mdl[c], decSpec.wfs.getHFilters(t, c), decSpec.wfs.getVFilters(t, c));
- initSubbandsFields(c, subbTrees[c]);
- }
-
- // Read tile's packets
- try
- {
- readTilePkts(t);
- }
- catch (System.IO.IOException e)
- {
- SupportClass.WriteStackTrace(e, Console.Error);
- throw new System.ApplicationException("IO Error when reading tile " + x + " x " + y);
- }
- }
-
- /// Advances to the next tile, in standard scan-line order (by rows then
- /// columns). A NoNextElementException is thrown if the current tile is the
- /// last one (i.e. there is no next tile).
- ///
- ///
- public override void nextTile()
- {
- if (ctX == ntX - 1 && ctY == ntY - 1)
- {
- // Already at last tile
- throw new NoNextElementException();
- }
- else if (ctX < ntX - 1)
- {
- // If not at end of current tile line
- setTile(ctX + 1, ctY);
- }
- else
- {
- // Go to first tile at next line
- setTile(0, ctY + 1);
- }
- }
-
- /// Returns the specified coded code-block, for the specified component, in
- /// the current tile. The first layer to return is indicated by 'fl'. The
- /// number of layers that is returned depends on 'nl' and the amount of
- /// available data.
- ///
- /// The argument 'fl' is to be used by subsequent calls to this method
- /// for the same code-block. In this way supplemental data can be retrieved
- /// at a later time. The fact that data from more than one layer can be
- /// returned means that several packets from the same code-block, of the
- /// same component, and the same tile, have been concatenated.
- ///
- /// The returned compressed code-block can have its progressive
- /// attribute set. If this attribute is set it means that more data can be
- /// obtained by subsequent calls to this method (subject to transmission
- /// delays, etc). If the progressive attribute is not set it means that the
- /// returned data is all the data that can be obtained for the specified
- /// code-block.
- ///
- /// The compressed code-block is uniquely specified by the current tile,
- /// the component (identified by 'c'), the subband (indentified by 'sb')
- /// and the code-block vertical and horizontal indexes 'n' and 'm'.
- ///
- /// The 'ulx' and 'uly' members of the returned 'DecLyrdCBlk' object
- /// contain the coordinates of the top-left corner of the block, with
- /// respect to the tile, not the subband.
- ///
- ///
- /// The index of the component, from 0 to N-1.
- ///
- ///
- /// The vertical index of the code-block to return, in the
- /// specified subband.
- ///
- ///
- /// The horizontal index of the code-block to return, in the
- /// specified subband.
- ///
- ///
- /// The subband in whic the requested code-block is.
- ///
- ///
- /// The first layer to return.
- ///
- ///
- /// The number of layers to return, if negative all available
- /// layers are returned, starting at 'fl'.
- ///
- ///
- /// If not null this object is used to return the compressed
- /// code-block. If null a new object is created and returned. If the data
- /// array in ccb is not null then it can be reused to return the compressed
- /// data.
- ///
- ///
- /// The compressed code-block, with a certain number of layers
- /// determined by the available data and 'nl'.
- ///
- ///
- public override DecLyrdCBlk getCodeBlock(int c, int m, int n, SubbandSyn sb, int fl, int nl, DecLyrdCBlk ccb)
- {
-
- int t = TileIdx;
- CBlkInfo rcb; // requested code-block
- int r = sb.resLvl; // Resolution level
- int s = sb.sbandIdx; // Subband index
- int tpidx;
- int passtype;
-
- // Number of layers
- int numLayers = ((System.Int32)decSpec.nls.getTileDef(t));
- int options = ((System.Int32)decSpec.ecopts.getTileCompVal(t, c));
- if (nl < 0)
- {
- nl = numLayers - fl + 1;
- }
-
- // If the l quit condition is used, Make sure that no layer
- // after lquit is returned
- if (lQuit != -1 && fl + nl > lQuit)
- {
- nl = lQuit - fl;
- }
-
- // Check validity of resquested resolution level (according to the
- // "-res" option).
- int maxdl = getSynSubbandTree(t, c).resLvl;
- if (r > targetRes + maxdl - decSpec.dls.Min)
- {
- throw new System.ApplicationException("JJ2000 error: requesting a code-block " + "disallowed by the '-res' option.");
- }
-
- // Check validity of all the arguments
- try
- {
- rcb = cbI[c][r][s][m][n];
-
- if (fl < 1 || fl > numLayers || fl + nl - 1 > numLayers)
- {
- throw new System.ArgumentException();
- }
- }
- catch (System.IndexOutOfRangeException)
- {
- throw new System.ArgumentException("Code-block (t:" + t + ", c:" + c + ", r:" + r + ", s:" + s + ", " + m + "x" + (+n) + ") not found in codestream");
- }
- catch (System.NullReferenceException)
- {
- throw new System.ArgumentException("Code-block (t:" + t + ", c:" + c + ", r:" + r + ", s:" + s + ", " + m + "x" + n + ") not found in bit stream");
- }
-
- // Create DecLyrdCBlk object if necessary
- if (ccb == null)
- {
- ccb = new DecLyrdCBlk();
- }
- ccb.m = m;
- ccb.n = n;
- ccb.nl = 0;
- ccb.dl = 0;
- ccb.nTrunc = 0;
-
- if (rcb == null)
- {
- // This code-block was skipped when reading. Returns no data
- ccb.skipMSBP = 0;
- ccb.prog = false;
- ccb.w = ccb.h = ccb.ulx = ccb.uly = 0;
- return ccb;
- }
-
- // ccb initialization
- ccb.skipMSBP = rcb.msbSkipped;
- ccb.ulx = rcb.ulx;
- ccb.uly = rcb.uly;
- ccb.w = rcb.w;
- ccb.h = rcb.h;
- ccb.ftpIdx = 0;
-
- // Search for index of first truncation point (first layer where
- // length of data is not zero)
- int l = 0;
- while ((l < rcb.len.Length) && (rcb.len[l] == 0))
- {
- ccb.ftpIdx += rcb.ntp[l];
- l++;
- }
-
- // Calculate total length, number of included layer and number of
- // truncation points
- for (l = fl - 1; l < fl + nl - 1; l++)
- {
- ccb.nl++;
- ccb.dl += rcb.len[l];
- ccb.nTrunc += rcb.ntp[l];
- }
-
- // Calculate number of terminated segments
- int nts;
- if ((options & CSJ2K.j2k.entropy.StdEntropyCoderOptions.OPT_TERM_PASS) != 0)
- {
- // Regular termination in use One segment per pass
- // (i.e. truncation point)
- nts = ccb.nTrunc - ccb.ftpIdx;
- }
- else if ((options & CSJ2K.j2k.entropy.StdEntropyCoderOptions.OPT_BYPASS) != 0)
- {
- // Selective arithmetic coding bypass mode in use, but no regular
- // termination: 1 segment upto the end of the last pass of the 4th
- // most significant bit-plane, and, in each following bit-plane,
- // one segment upto the end of the 2nd pass and one upto the end
- // of the 3rd pass.
-
- if (ccb.nTrunc <= CSJ2K.j2k.entropy.StdEntropyCoderOptions.FIRST_BYPASS_PASS_IDX)
- {
- nts = 1;
- }
- else
- {
- nts = 1;
- // Adds one for each terminated pass
- for (tpidx = ccb.ftpIdx; tpidx < ccb.nTrunc; tpidx++)
- {
- if (tpidx >= CSJ2K.j2k.entropy.StdEntropyCoderOptions.FIRST_BYPASS_PASS_IDX - 1)
- {
- passtype = (tpidx + CSJ2K.j2k.entropy.StdEntropyCoderOptions.NUM_EMPTY_PASSES_IN_MS_BP) % CSJ2K.j2k.entropy.StdEntropyCoderOptions.NUM_PASSES;
- if (passtype == 1 || passtype == 2)
- {
- // lazy pass just before MQ pass or MQ pass just
- // before lazy pass => terminated
- nts++;
- }
- }
- }
- }
- }
- else
- {
- // Nothing special in use, just one terminated segment
- nts = 1;
- }
-
- // ccb.data creation
- if (ccb.data == null || ccb.data.Length < ccb.dl)
- {
- ccb.data = new byte[ccb.dl];
- }
-
- // ccb.tsLengths creation
- if (nts > 1 && (ccb.tsLengths == null || ccb.tsLengths.Length < nts))
- {
- ccb.tsLengths = new int[nts];
- }
- else if (nts > 1 && (options & (CSJ2K.j2k.entropy.StdEntropyCoderOptions.OPT_BYPASS | CSJ2K.j2k.entropy.StdEntropyCoderOptions.OPT_TERM_PASS)) == CSJ2K.j2k.entropy.StdEntropyCoderOptions.OPT_BYPASS)
- {
- ArrayUtil.intArraySet(ccb.tsLengths, 0);
- }
-
- // Fill ccb with compressed data
- int dataIdx = -1;
- tpidx = ccb.ftpIdx;
- int ctp = ccb.ftpIdx; // Cumulative number of truncation
- // point for the current layer layer
- int tsidx = 0;
- int j;
-
- for (l = fl - 1; l < fl + nl - 1; l++)
- {
- ctp += rcb.ntp[l];
- // No data in this layer
- if (rcb.len[l] == 0)
- continue;
-
- // Read data
- // NOTE: we should never get an EOFException here since all
- // data is checked to be within the file.
- try
- {
- in_Renamed.seek(rcb.off[l]);
- in_Renamed.readFully(ccb.data, dataIdx + 1, rcb.len[l]);
- dataIdx += rcb.len[l];
- }
- catch (System.IO.IOException e)
- {
- JJ2KExceptionHandler.handleException(e);
- }
-
- // Get the terminated segment lengths, if any
- if (nts == 1)
- continue;
- if ((options & CSJ2K.j2k.entropy.StdEntropyCoderOptions.OPT_TERM_PASS) != 0)
- {
- // Regular termination => each pass is terminated
- for (j = 0; tpidx < ctp; j++, tpidx++)
- {
- if (rcb.segLen[l] != null)
- {
- ccb.tsLengths[tsidx++] = rcb.segLen[l][j];
- }
- else
- {
- // Only one terminated segment in packet
- ccb.tsLengths[tsidx++] = rcb.len[l];
- }
- }
- }
- else
- {
- // Lazy coding without regular termination
- for (j = 0; tpidx < ctp; tpidx++)
- {
- if (tpidx >= CSJ2K.j2k.entropy.StdEntropyCoderOptions.FIRST_BYPASS_PASS_IDX - 1)
- {
- passtype = (tpidx + CSJ2K.j2k.entropy.StdEntropyCoderOptions.NUM_EMPTY_PASSES_IN_MS_BP) % CSJ2K.j2k.entropy.StdEntropyCoderOptions.NUM_PASSES;
- if (passtype != 0)
- {
- // lazy pass just before MQ pass or MQ
- // pass just before lazy pass =>
- // terminated
- if (rcb.segLen[l] != null)
- {
- ccb.tsLengths[tsidx++] += rcb.segLen[l][j++];
- rcb.len[l] -= rcb.segLen[l][j - 1];
- }
- else
- {
- // Only one terminated segment in packet
- ccb.tsLengths[tsidx++] += rcb.len[l];
- rcb.len[l] = 0;
- }
- }
- }
- }
-
- // Last length in packet always in (either terminated segment
- // or contribution to terminated segment)
- if (rcb.segLen[l] != null && j < rcb.segLen[l].Length)
- {
- ccb.tsLengths[tsidx] += rcb.segLen[l][j];
- rcb.len[l] -= rcb.segLen[l][j];
- }
- else
- {
- // Only one terminated segment in packet
- if (tsidx < nts)
- {
- ccb.tsLengths[tsidx] += rcb.len[l];
- rcb.len[l] = 0;
- }
- }
- }
- }
- if (nts == 1 && ccb.tsLengths != null)
- {
- ccb.tsLengths[0] = ccb.dl;
- }
-
- // Set the progressive flag
- int lastlayer = fl + nl - 1;
- if (lastlayer < numLayers - 1)
- {
- for (l = lastlayer + 1; l < numLayers; l++)
- {
- // It remains data for this code-block in the bit stream
- if (rcb.len[l] != 0)
- {
- ccb.prog = true;
- }
- }
- }
-
- return ccb;
- }
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/codestream/reader/HeaderDecoder.cs b/CSJ2K/j2k/codestream/reader/HeaderDecoder.cs
deleted file mode 100644
index 06b00db9..00000000
--- a/CSJ2K/j2k/codestream/reader/HeaderDecoder.cs
+++ /dev/null
@@ -1,3089 +0,0 @@
-/*
-* CVS identifier:
-*
-* $Id: HeaderDecoder.java,v 1.61 2002/07/25 15:01:00 grosbois Exp $
-*
-* Class: HeaderDecoder
-*
-* Description: Reads main and tile-part headers.
-*
-*
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-* */
-using CSJ2K.Color;
-using CSJ2K.Icc;
-using CSJ2K.j2k.decoder;
-using CSJ2K.j2k.entropy.decoder;
-using CSJ2K.j2k.image;
-using CSJ2K.j2k.io;
-using CSJ2K.j2k.quantization.dequantizer;
-using CSJ2K.j2k.roi;
-using CSJ2K.j2k.util;
-using CSJ2K.j2k.wavelet.synthesis;
-using System;
-namespace CSJ2K.j2k.codestream.reader
-{
-
- /// This class reads main and tile-part headers from the codestream given a
- /// RandomAccessIO instance located at the beginning of the codestream (i.e
- /// just before the SOC marker) or at the beginning of a tile-part (i.e. just
- /// before a SOT marker segment) respectively.
- ///
- /// A marker segment includes a marker and eventually marker segment
- /// parameters. It is designed by the three letters code of the marker
- /// associated with the marker segment. JPEG 2000 part 1 defines 6 types of
- /// markers segments:
- ///
- ///
- /// - Delimiting : SOC, SOT, SOD, EOC
- ///
- /// - Fixed information: SIZ.
- ///
- /// - Functional: COD, COC, RGN, QCD, QCC,POC.
- ///
- /// - In bit-stream: SOP, EPH.
- ///
- /// - Pointer: TLM, PLM, PLT, PPM, PPT.
- ///
- /// - Informational: CRG, COM.
- ///
- ///
- /// The main header is read when the constructor is called whereas tile-part
- /// headers are read when the FileBitstreamReaderAgent instance is created. The
- /// reading is done in 2 passes:
- ///
- ///
- /// - All marker segments are buffered and their corresponding flag is
- /// activated (extractMainMarkSeg and extractTilePartMarkSeg methods).
- ///
- /// - Buffered marker segment are analyzed in a logical way and
- /// specifications are stored in appropriate member of DecoderSpecs instance
- /// (readFoundMainMarkSeg and readFoundTilePartMarkSeg methods).
- ///
- ///
- /// Whenever a marker segment is not recognized a warning message is
- /// displayed and its length parameter is used to skip it.
- ///
- /// The information found in this header is stored in HeaderInfo and
- /// DecoderSpecs instances.
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- public class HeaderDecoder
- {
- /// Return the maximum height among all components
- ///
- ///
- /// Maximum component height
- ///
- ///
- virtual public int MaxCompImgHeight
- {
- get
- {
- return hi.sizValue.MaxCompHeight;
- }
-
- }
- /// Return the maximum width among all components
- ///
- ///
- /// Maximum component width
- ///
- ///
- virtual public int MaxCompImgWidth
- {
- get
- {
- return hi.sizValue.MaxCompWidth;
- }
-
- }
- /// Returns the image width in the reference grid.
- ///
- ///
- /// The image width in the reference grid
- ///
- ///
- virtual public int ImgWidth
- {
- get
- {
- return hi.sizValue.xsiz - hi.sizValue.x0siz;
- }
-
- }
- /// Returns the image height in the reference grid.
- ///
- ///
- /// The image height in the reference grid
- ///
- ///
- virtual public int ImgHeight
- {
- get
- {
- return hi.sizValue.ysiz - hi.sizValue.y0siz;
- }
-
- }
- /// Return the horizontal upper-left coordinate of the image in the
- /// reference grid.
- ///
- ///
- /// The horizontal coordinate of the image origin.
- ///
- ///
- virtual public int ImgULX
- {
- get
- {
- return hi.sizValue.x0siz;
- }
-
- }
- /// Return the vertical upper-left coordinate of the image in the reference
- /// grid.
- ///
- ///
- /// The vertical coordinate of the image origin.
- ///
- ///
- virtual public int ImgULY
- {
- get
- {
- return hi.sizValue.y0siz;
- }
-
- }
- /// Returns the nominal width of the tiles in the reference grid.
- ///
- ///
- /// The nominal tile width, in the reference grid.
- ///
- ///
- virtual public int NomTileWidth
- {
- get
- {
- return hi.sizValue.xtsiz;
- }
-
- }
- /// Returns the nominal width of the tiles in the reference grid.
- ///
- ///
- /// The nominal tile width, in the reference grid.
- ///
- ///
- virtual public int NomTileHeight
- {
- get
- {
- return hi.sizValue.ytsiz;
- }
-
- }
- /// Returns the number of components in the image.
- ///
- ///
- /// The number of components in the image.
- ///
- ///
- virtual public int NumComps
- {
- get
- {
- return nComp;
- }
-
- }
- /// Returns the horizontal code-block partition origin.Allowable values are
- /// 0 and 1, nothing else.
- ///
- ///
- virtual public int CbULX
- {
- get
- {
- return cb0x;
- }
-
- }
- /// Returns the vertical code-block partition origin. Allowable values are
- /// 0 and 1, nothing else.
- ///
- ///
- virtual public int CbULY
- {
- get
- {
- return cb0y;
- }
-
- }
- /// Return the DecoderSpecs instance filled when reading the headers
- ///
- ///
- /// The DecoderSpecs of the decoder
- ///
- ///
- virtual public DecoderSpecs DecoderSpecs
- {
- get
- {
- return decSpec;
- }
-
- }
- /// Returns the parameters that are used in this class. It returns a 2D
- /// String array. Each of the 1D arrays is for a different option, and they
- /// have 3 elements. The first element is the option name, the second one
- /// is the synopsis and the third one is a long description of what the
- /// parameter is. The synopsis or description may be 'null', in which case
- /// it is assumed that there is no synopsis or description of the option,
- /// respectively.
- ///
- ///
- /// the options name, their synopsis and their explanation.
- ///
- ///
- public static System.String[][] ParameterInfo
- {
- get
- {
- return pinfo;
- }
-
- }
- /// Return the number of tiles in the image
- ///
- ///
- /// The number of tiles
- ///
- ///
- virtual public int NumTiles
- {
- get
- {
- return nTiles;
- }
-
- }
- /// Sets the tile of each tile part in order. This information is needed
- /// for identifying which packet header belongs to which tile when using
- /// the PPM marker.
- ///
- ///
- /// The tile number that the present tile part belongs to.
- ///
- ///
- virtual public int TileOfTileParts
- {
- set
- {
- if (nPPMMarkSeg != 0)
- {
- tileOfTileParts.Add((System.Int32)value);
- }
- }
-
- }
- /// Returns the number of found marker segments in the current header.
- ///
- ///
- /// The number of marker segments found in the current header.
- ///
- ///
- virtual public int NumFoundMarkSeg
- {
- get
- {
- return nfMarkSeg;
- }
-
- }
-
- /// The prefix for header decoder options: 'H'
- public const char OPT_PREFIX = 'H';
-
- /// The list of parameters that is accepted for quantization. Options
- /// for quantization start with 'Q'.
- ///
- //UPGRADE_NOTE: Final was removed from the declaration of 'pinfo'. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- private static readonly System.String[][] pinfo = null;
-
- /// The reference to the HeaderInfo instance holding the information found
- /// in headers
- ///
- private HeaderInfo hi;
-
- /// Whether or not to display general information
- //private bool verbose;
-
- /// Current header information in a string
- private System.String hdStr = "";
-
- /// The number of tiles within the image
- private int nTiles;
-
- /// The number of tile parts in each tile
- public int[] nTileParts;
-
- /// Used to store which markers have been already read, by using flag
- /// bits. The different markers are marked with XXX_FOUND flags, such as
- /// SIZ_FOUND
- ///
- private int nfMarkSeg = 0;
-
- /// Counts number of COC markers found in the header
- private int nCOCMarkSeg = 0;
-
- /// Counts number of QCC markers found in the header
- private int nQCCMarkSeg = 0;
-
- /// Counts number of COM markers found in the header
- private int nCOMMarkSeg = 0;
-
- /// Counts number of RGN markers found in the header
- private int nRGNMarkSeg = 0;
-
- /// Counts number of PPM markers found in the header
- private int nPPMMarkSeg = 0;
-
- /// Counts number of PPT markers found in the header
- private int[][] nPPTMarkSeg = null;
-
- /// Flag bit for SIZ marker segment found
- private const int SIZ_FOUND = 1;
-
- /// Flag bit for COD marker segment found
- private const int COD_FOUND = 1 << 1;
-
- /// Flag bit for COC marker segment found
- private const int COC_FOUND = 1 << 2;
-
- /// Flag bit for QCD marker segment found
- private const int QCD_FOUND = 1 << 3;
-
- /// Flag bit for TLM marker segment found
- private const int TLM_FOUND = 1 << 4;
-
- /// Flag bit for PLM marker segment found
- private const int PLM_FOUND = 1 << 5;
-
- /// Flag bit for SOT marker segment found
- private const int SOT_FOUND = 1 << 6;
-
- /// Flag bit for PLT marker segment found
- private const int PLT_FOUND = 1 << 7;
-
- /// Flag bit for QCC marker segment found
- private const int QCC_FOUND = 1 << 8;
-
- /// Flag bit for RGN marker segment found
- private const int RGN_FOUND = 1 << 9;
-
- /// Flag bit for POC marker segment found
- private const int POC_FOUND = 1 << 10;
-
- /// Flag bit for COM marker segment found
- private const int COM_FOUND = 1 << 11;
-
- /// Flag bit for SOD marker segment found
- public const int SOD_FOUND = 1 << 13;
-
- /// Flag bit for SOD marker segment found
- public const int PPM_FOUND = 1 << 14;
-
- /// Flag bit for SOD marker segment found
- public const int PPT_FOUND = 1 << 15;
-
- /// Flag bit for CRG marker segment found
- public const int CRG_FOUND = 1 << 16;
-
- /// The reset mask for new tiles
- //UPGRADE_NOTE: Final was removed from the declaration of 'TILE_RESET '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- //private static readonly int TILE_RESET = ~ (PLM_FOUND | SIZ_FOUND | RGN_FOUND);
-
- /// HashTable used to store temporary marker segment byte buffers
- private System.Collections.Hashtable ht = null;
-
- /// The number of components in the image
- private int nComp;
-
- /// The horizontal code-block partition origin
- private int cb0x = -1;
-
- /// The vertical code-block partition origin
- private int cb0y = -1;
-
- /// The decoder specifications
- private DecoderSpecs decSpec;
-
- /// Is the precinct partition used
- internal bool precinctPartitionIsUsed;
-
- /// The offset of the main header in the input stream
- public int mainHeadOff;
-
- /// Vector containing info as to which tile each tilepart belong
- private System.Collections.ArrayList tileOfTileParts;
-
- /// Array containing the Nppm and Ippm fields of the PPM marker segments
- private byte[][] pPMMarkerData;
-
- /// Array containing the Ippm fields of the PPT marker segments
- private byte[][][][] tilePartPkdPktHeaders;
-
- /// The packed packet headers if the PPM or PPT markers are used
- private System.IO.MemoryStream[] pkdPktHeaders;
-
- /// Returns the tiling origin, referred to as '(Px,Py)' in the 'ImgData'
- /// interface.
- ///
- ///
- /// If not null this object is used to return the information. If
- /// null a new one is created and returned.
- ///
- ///
- /// The coordinate of the tiling origin, in the canvas system, on
- /// the reference grid.
- ///
- ///
- ///
- ///
- ///
- public Coord getTilingOrigin(Coord co)
- {
- if (co != null)
- {
- co.x = hi.sizValue.xt0siz;
- co.y = hi.sizValue.yt0siz;
- return co;
- }
- else
- {
- return new Coord(hi.sizValue.xt0siz, hi.sizValue.yt0siz);
- }
- }
-
- /// Returns true if the original data of the specified component was
- /// signed. If the data was not signed a level shift has to be applied at
- /// the end of the decompression chain.
- ///
- ///
- /// The index of the component
- ///
- ///
- /// True if the original image component was signed.
- ///
- ///
- public bool isOriginalSigned(int c)
- {
- return hi.sizValue.isOrigSigned(c);
- }
-
- /// Returns the original bitdepth of the specified component.
- ///
- ///
- /// The index of the component
- ///
- ///
- /// The bitdepth of the component
- ///
- ///
- public int getOriginalBitDepth(int c)
- {
- return hi.sizValue.getOrigBitDepth(c);
- }
-
- /// Returns the component sub-sampling factor, with respect to the
- /// reference grid, along the horizontal direction for the specified
- /// component.
- ///
- ///
- /// The index of the component
- ///
- ///
- /// The component sub-sampling factor X-wise.
- ///
- ///
- public int getCompSubsX(int c)
- {
- return hi.sizValue.xrsiz[c];
- }
-
- /// Returns the component sub-sampling factor, with respect to the
- /// reference grid, along the vertical direction for the specified
- /// component.
- ///
- ///
- /// The index of the component
- ///
- ///
- /// The component sub-sampling factor Y-wise.
- ///
- ///
- public int getCompSubsY(int c)
- {
- return hi.sizValue.yrsiz[c];
- }
-
- /// Returns the dequantizer parameters. Dequantizer parameters normally are
- /// the quantization step sizes, see DequantizerParams.
- ///
- ///
- /// The source of data for the dequantizer.
- ///
- ///
- /// The number of range bits for each component. Must be
- /// the number of range bits of the mixed components.
- ///
- ///
- /// The DecoderSpecs instance after any image manipulation.
- ///
- ///
- /// The dequantizer
- ///
- ///
- public Dequantizer createDequantizer(CBlkQuantDataSrcDec src, int[] rb, DecoderSpecs decSpec2)
- {
- return new StdDequantizer(src, rb, decSpec2);
- }
-
- /// Returns the precinct partition width for the specified tile-component
- /// and resolution level.
- ///
- ///
- /// the component index
- ///
- ///
- /// the tile index
- ///
- ///
- /// the resolution level
- ///
- ///
- /// The precinct partition width for the specified tile-component
- /// and resolution level
- ///
- ///
- public int getPPX(int t, int c, int rl)
- {
- return decSpec.pss.getPPX(t, c, rl);
- }
-
- /// Returns the precinct partition height for the specified tile-component
- /// and resolution level.
- ///
- ///
- /// the component index
- ///
- ///
- /// the tile index
- ///
- ///
- /// the resolution level
- ///
- ///
- /// The precinct partition height for the specified tile-component
- /// and resolution level
- ///
- ///
- public int getPPY(int t, int c, int rl)
- {
- return decSpec.pss.getPPY(t, c, rl);
- }
-
- /// Returns the boolean used to know if the precinct partition is used
- ///
- ///
- public bool precinctPartitionUsed()
- {
- return precinctPartitionIsUsed;
- }
-
- /// Reads a wavelet filter from the codestream and returns the filter
- /// object that implements it.
- ///
- ///
- /// The encoded header stream from where to read the info
- ///
- ///
- /// Int array of one element to return the type of the
- /// wavelet filter.
- ///
- ///
- //UPGRADE_TODO: Class 'java.io.DataInputStream' was converted to 'System.IO.BinaryReader' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaioDataInputStream'"
- private SynWTFilter readFilter(System.IO.BinaryReader ehs, int[] filtIdx)
- {
- int kid; // the filter id
-
- kid = filtIdx[0] = ehs.ReadByte();
- if (kid >= (1 << 7))
- {
- throw new NotImplementedException("Custom filters not supported");
- }
- // Return filter based on ID
- switch (kid)
- {
-
- case CSJ2K.j2k.wavelet.FilterTypes_Fields.W9X7:
- return new SynWTFilterFloatLift9x7();
-
- case CSJ2K.j2k.wavelet.FilterTypes_Fields.W5X3:
- return new SynWTFilterIntLift5x3();
-
- default:
- throw new CorruptedCodestreamException("Specified wavelet filter " + "not" + " JPEG 2000 part I " + "compliant");
-
- }
- }
-
- /// Checks that the marker segment length is correct.
- ///
- ///
- /// The encoded header stream
- ///
- ///
- /// The string identifying the marker, such as "SIZ marker"
- ///
- ///
- /// If an I/O error occurs
- ///
- ///
- //UPGRADE_TODO: Class 'java.io.DataInputStream' was converted to 'System.IO.BinaryReader' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaioDataInputStream'"
- public virtual void checkMarkerLength(System.IO.BinaryReader ehs, System.String str)
- {
- long available;
- available = ehs.BaseStream.Length - ehs.BaseStream.Position;
- if ((int)available != 0)
- {
- FacilityManager.getMsgLogger().printmsg(CSJ2K.j2k.util.MsgLogger_Fields.WARNING, str + " length was short, attempting to resync.");
- }
- }
-
- /// Reads the SIZ marker segment and realigns the codestream at the point
- /// where the next marker segment should be found.
- ///
- /// SIZ is a fixed information marker segment containing informations
- /// about image and tile sizes. It is required in the main header
- /// immediately after SOC.
- ///
- ///
- /// The encoded header stream
- ///
- ///
- /// If an I/O error occurs while reading from the
- /// encoded header stream
- ///
- ///
- //UPGRADE_TODO: Class 'java.io.DataInputStream' was converted to 'System.IO.BinaryReader' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaioDataInputStream'"
- private void readSIZ(System.IO.BinaryReader ehs)
- {
- HeaderInfo.SIZ ms = hi.NewSIZ;
- hi.sizValue = ms;
-
- // Read the length of SIZ marker segment (Lsiz)
- ms.lsiz = ehs.ReadUInt16();
-
- // Read the capability of the codestream (Rsiz)
- ms.rsiz = ehs.ReadUInt16();
- if (ms.rsiz > 2)
- {
- throw new System.ApplicationException("Codestream capabiities not JPEG 2000 - Part I" + " compliant");
- }
-
- // Read image size
- ms.xsiz = ehs.ReadInt32();
- ms.ysiz = ehs.ReadInt32();
- if (ms.xsiz <= 0 || ms.ysiz <= 0)
- {
- throw new System.IO.IOException("JJ2000 does not support images whose " + "width and/or height not in the " + "range: 1 -- (2^31)-1");
- }
-
- // Read image offset
- ms.x0siz = ehs.ReadInt32();
- ms.y0siz = ehs.ReadInt32();
- if (ms.x0siz < 0 || ms.y0siz < 0)
- {
- throw new System.IO.IOException("JJ2000 does not support images offset " + "not in the range: 0 -- (2^31)-1");
- }
-
- // Read size of tile
- ms.xtsiz = ehs.ReadInt32();
- ms.ytsiz = ehs.ReadInt32();
- if (ms.xtsiz <= 0 || ms.ytsiz <= 0)
- {
- throw new System.IO.IOException("JJ2000 does not support tiles whose " + "width and/or height are not in " + "the range: 1 -- (2^31)-1");
- }
-
- // Read upper-left tile offset
- ms.xt0siz = ehs.ReadInt32();
- ms.yt0siz = ehs.ReadInt32();
- if (ms.xt0siz < 0 || ms.yt0siz < 0)
- {
- throw new System.IO.IOException("JJ2000 does not support tiles whose " + "offset is not in " + "the range: 0 -- (2^31)-1");
- }
-
- // Read number of components and initialize related arrays
- nComp = ms.csiz = ehs.ReadUInt16();
- if (nComp < 1 || nComp > 16384)
- {
- throw new System.ArgumentException("Number of component out of " + "range 1--16384: " + nComp);
- }
-
- ms.ssiz = new int[nComp];
- ms.xrsiz = new int[nComp];
- ms.yrsiz = new int[nComp];
-
- // Read bit-depth and down-sampling factors of each component
- for (int i = 0; i < nComp; i++)
- {
- ms.ssiz[i] = ehs.ReadByte();
- ms.xrsiz[i] = ehs.ReadByte();
- ms.yrsiz[i] = ehs.ReadByte();
- }
-
- // Check marker length
- checkMarkerLength(ehs, "SIZ marker");
-
- // Create needed ModuleSpec
- nTiles = ms.NumTiles;
-
- // Finish initialization of decSpec
- decSpec = new DecoderSpecs(nTiles, nComp);
- }
-
- /// Reads a CRG marker segment and checks its length. CRG is an
- /// informational marker segment that allows specific registration of
- /// components with respect to each other.
- ///
- ///
- /// The encoded header stream
- ///
- ///
- //UPGRADE_TODO: Class 'java.io.DataInputStream' was converted to 'System.IO.BinaryReader' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaioDataInputStream'"
- private void readCRG(System.IO.BinaryReader ehs)
- {
- HeaderInfo.CRG ms = hi.NewCRG;
- hi.crgValue = ms;
-
- ms.lcrg = ehs.ReadUInt16();
- ms.xcrg = new int[nComp];
- ms.ycrg = new int[nComp];
-
- FacilityManager.getMsgLogger().printmsg(CSJ2K.j2k.util.MsgLogger_Fields.WARNING, "Information in CRG marker segment " + "not taken into account. This may affect the display " + "of the decoded image.");
- for (int c = 0; c < nComp; c++)
- {
- ms.xcrg[c] = ehs.ReadUInt16();
- ms.ycrg[c] = ehs.ReadUInt16();
- }
-
- // Check marker length
- checkMarkerLength(ehs, "CRG marker");
- }
-
- /// Reads a COM marker segments and realigns the bit stream at the point
- /// where the next marker segment should be found. COM is an informational
- /// marker segment that allows to include unstructured data in the main and
- /// tile-part headers.
- ///
- ///
- /// The encoded header stream
- ///
- ///
- /// Flag indicating whether or not this marker segment is read
- /// from the main header.
- ///
- ///
- /// The index of the current tile
- ///
- ///
- /// Occurence of this COM marker in eith main or tile-part
- /// header
- ///
- ///
- /// If an I/O error occurs while reading from the
- /// encoded header stream
- ///
- ///
- //UPGRADE_TODO: Class 'java.io.DataInputStream' was converted to 'System.IO.BinaryReader' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaioDataInputStream'"
- private void readCOM(System.IO.BinaryReader ehs, bool mainh, int tileIdx, int comIdx)
- {
- HeaderInfo.COM ms = hi.NewCOM;
-
- // Read length of COM field
- ms.lcom = ehs.ReadUInt16();
-
- // Read the registration value of the COM marker segment
- ms.rcom = ehs.ReadUInt16();
- switch (ms.rcom)
- {
- case CSJ2K.j2k.codestream.Markers.RCOM_BINARY:
- case CSJ2K.j2k.codestream.Markers.RCOM_LATIN:
- ms.ccom = new byte[ms.lcom - 4];
- for (int i = 0; i < ms.lcom - 4; i++)
- {
- ms.ccom[i] = ehs.ReadByte();
- }
- break;
- default:
- // --- Unknown or unsupported markers ---
- // (skip them and see if we can get way with it)
- FacilityManager.getMsgLogger().printmsg(CSJ2K.j2k.util.MsgLogger_Fields.WARNING, "COM marker registered as " + ms.rcom + " unknown, ignoring (this might crash the " + "decoder or decode a quality degraded or even " + "useless image)");
- System.IO.BinaryReader temp_BinaryReader;
- System.Int64 temp_Int64;
- temp_BinaryReader = ehs;
- temp_Int64 = temp_BinaryReader.BaseStream.Position;
- temp_Int64 = temp_BinaryReader.BaseStream.Seek(ms.lcom - 4, System.IO.SeekOrigin.Current) - temp_Int64;
- // CONVERSION PROBLEM?
- int generatedAux2 = (int)temp_Int64; //Ignore this field for the moment
- break;
-
- }
-
- if (mainh)
- {
- hi.comValue["main_" + comIdx] = ms;
- }
- else
- {
- hi.comValue["t" + tileIdx + "_" + comIdx] = ms;
- }
-
- // Check marker length
- checkMarkerLength(ehs, "COM marker");
- }
-
- /// Reads a QCD marker segment and realigns the codestream at the point
- /// where the next marker should be found. QCD is a functional marker
- /// segment that describes the quantization default.
- ///
- ///
- /// The encoded stream.
- ///
- ///
- /// Flag indicating whether or not this marker segment is read
- /// from the main header.
- ///
- ///
- /// The index of the current tile
- ///
- ///
- /// Tile-part index
- ///
- ///
- /// If an I/O error occurs while reading from the
- /// encoded header stream.
- ///
- ///
- //UPGRADE_TODO: Class 'java.io.DataInputStream' was converted to 'System.IO.BinaryReader' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaioDataInputStream'"
- private void readQCD(System.IO.BinaryReader ehs, bool mainh, int tileIdx, int tpIdx)
- {
- StdDequantizerParams qParms;
- int guardBits;
- int[][] exp;
- float[][] nStep = null;
- HeaderInfo.QCD ms = hi.NewQCD;
-
- // Lqcd (length of QCD field)
- ms.lqcd = ehs.ReadUInt16();
-
- // Sqcd (quantization style)
- ms.sqcd = ehs.ReadByte();
-
- guardBits = ms.NumGuardBits;
- int qType = ms.QuantType;
-
- if (mainh)
- {
- hi.qcdValue["main"] = ms;
- // If the main header is being read set default value of
- // dequantization spec
- switch (qType)
- {
-
- case CSJ2K.j2k.codestream.Markers.SQCX_NO_QUANTIZATION:
- decSpec.qts.setDefault("reversible");
- break;
-
- case CSJ2K.j2k.codestream.Markers.SQCX_SCALAR_DERIVED:
- decSpec.qts.setDefault("derived");
- break;
-
- case CSJ2K.j2k.codestream.Markers.SQCX_SCALAR_EXPOUNDED:
- decSpec.qts.setDefault("expounded");
- break;
-
- default:
- throw new CorruptedCodestreamException("Unknown or " + "unsupported " + "quantization style " + "in Sqcd field, QCD " + "marker main header");
-
- }
- }
- else
- {
- hi.qcdValue["t" + tileIdx] = ms;
- // If the tile header is being read set default value of
- // dequantization spec for tile
- switch (qType)
- {
-
- case CSJ2K.j2k.codestream.Markers.SQCX_NO_QUANTIZATION:
- decSpec.qts.setTileDef(tileIdx, "reversible");
- break;
-
- case CSJ2K.j2k.codestream.Markers.SQCX_SCALAR_DERIVED:
- decSpec.qts.setTileDef(tileIdx, "derived");
- break;
-
- case CSJ2K.j2k.codestream.Markers.SQCX_SCALAR_EXPOUNDED:
- decSpec.qts.setTileDef(tileIdx, "expounded");
- break;
-
- default:
- throw new CorruptedCodestreamException("Unknown or " + "unsupported " + "quantization style " + "in Sqcd field, QCD " + "marker, tile header");
-
- }
- }
-
- qParms = new StdDequantizerParams();
-
- if (qType == CSJ2K.j2k.codestream.Markers.SQCX_NO_QUANTIZATION)
- {
- int maxrl = (mainh ? ((System.Int32)decSpec.dls.getDefault()) : ((System.Int32)decSpec.dls.getTileDef(tileIdx)));
- int j, rl; // i removed
- int minb, maxb, hpd;
- int tmp;
-
- exp = qParms.exp = new int[maxrl + 1][];
- int[][] tmpArray = new int[maxrl + 1][];
- for (int i2 = 0; i2 < maxrl + 1; i2++)
- {
- tmpArray[i2] = new int[4];
- }
- ms.spqcd = tmpArray;
-
- for (rl = 0; rl <= maxrl; rl++)
- {
- // Loop on resolution levels
- // Find the number of subbands in the resolution level
- if (rl == 0)
- {
- // Only the LL subband
- minb = 0;
- maxb = 1;
- }
- else
- {
- // Dyadic decomposition
- hpd = 1;
-
- // Adapt hpd to resolution level
- if (hpd > maxrl - rl)
- {
- hpd -= (maxrl - rl);
- }
- else
- {
- hpd = 1;
- }
- // Determine max and min subband index
- minb = 1 << ((hpd - 1) << 1); // minb = 4^(hpd-1)
- maxb = 1 << (hpd << 1); // maxb = 4^hpd
- }
- // Allocate array for subbands in resolution level
- exp[rl] = new int[maxb];
-
- for (j = minb; j < maxb; j++)
- {
- tmp = ms.spqcd[rl][j] = ehs.ReadByte();
- exp[rl][j] = (tmp >> CSJ2K.j2k.codestream.Markers.SQCX_EXP_SHIFT) & CSJ2K.j2k.codestream.Markers.SQCX_EXP_MASK;
- }
- } // end for rl
- }
- else
- {
- int maxrl = (qType == CSJ2K.j2k.codestream.Markers.SQCX_SCALAR_DERIVED) ? 0 : (mainh ? ((System.Int32)decSpec.dls.getDefault()) : ((System.Int32)decSpec.dls.getTileDef(tileIdx)));
- int j, rl; // i removed
- int minb, maxb, hpd;
- int tmp;
-
- exp = qParms.exp = new int[maxrl + 1][];
- nStep = qParms.nStep = new float[maxrl + 1][];
- int[][] tmpArray2 = new int[maxrl + 1][];
- for (int i3 = 0; i3 < maxrl + 1; i3++)
- {
- tmpArray2[i3] = new int[4];
- }
- ms.spqcd = tmpArray2;
-
- for (rl = 0; rl <= maxrl; rl++)
- {
- // Loop on resolution levels
- // Find the number of subbands in the resolution level
- if (rl == 0)
- {
- // Only the LL subband
- minb = 0;
- maxb = 1;
- }
- else
- {
- // Dyadic decomposition
- hpd = 1;
-
- // Adapt hpd to resolution level
- if (hpd > maxrl - rl)
- {
- hpd -= (maxrl - rl);
- }
- else
- {
- hpd = 1;
- }
- // Determine max and min subband index
- minb = 1 << ((hpd - 1) << 1); // minb = 4^(hpd-1)
- maxb = 1 << (hpd << 1); // maxb = 4^hpd
- }
- // Allocate array for subbands in resolution level
- exp[rl] = new int[maxb];
- nStep[rl] = new float[maxb];
-
- for (j = minb; j < maxb; j++)
- {
- tmp = ms.spqcd[rl][j] = ehs.ReadUInt16();
- exp[rl][j] = (tmp >> 11) & 0x1f;
- // NOTE: the formula below does not support more than 5
- // bits for the exponent, otherwise (-1< Reads a QCC marker segment and realigns the codestream at the point
- /// where the next marker should be found. QCC is a functional marker
- /// segment that describes the quantization of one component.
- ///
- ///
- /// The encoded stream.
- ///
- ///
- /// Flag indicating whether or not this marker segment is read
- /// from the main header.
- ///
- ///
- /// The index of the current tile
- ///
- ///
- /// Tile-part index
- ///
- ///
- /// If an I/O error occurs while reading from the
- /// encoded header stream.
- ///
- ///
- //UPGRADE_TODO: Class 'java.io.DataInputStream' was converted to 'System.IO.BinaryReader' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaioDataInputStream'"
- private void readQCC(System.IO.BinaryReader ehs, bool mainh, int tileIdx, int tpIdx)
- {
- int cComp; // current component
- int tmp;
- StdDequantizerParams qParms;
- int[][] expC;
- float[][] nStepC = null;
- HeaderInfo.QCC ms = hi.NewQCC;
-
- // Lqcc (length of QCC field)
- ms.lqcc = ehs.ReadUInt16();
-
- // Cqcc
- if (nComp < 257)
- {
- cComp = ms.cqcc = ehs.ReadByte();
- }
- else
- {
- cComp = ms.cqcc = ehs.ReadUInt16();
- }
- if (cComp >= nComp)
- {
- throw new CorruptedCodestreamException("Invalid component " + "index in QCC marker");
- }
-
- // Sqcc (quantization style)
- ms.sqcc = ehs.ReadByte();
- int guardBits = ms.NumGuardBits;
- int qType = ms.QuantType;
-
- if (mainh)
- {
- hi.qccValue["main_c" + cComp] = ms;
- // If main header is being read, set default for component in all
- // tiles
- switch (qType)
- {
-
- case CSJ2K.j2k.codestream.Markers.SQCX_NO_QUANTIZATION:
- decSpec.qts.setCompDef(cComp, "reversible");
- break;
-
- case CSJ2K.j2k.codestream.Markers.SQCX_SCALAR_DERIVED:
- decSpec.qts.setCompDef(cComp, "derived");
- break;
-
- case CSJ2K.j2k.codestream.Markers.SQCX_SCALAR_EXPOUNDED:
- decSpec.qts.setCompDef(cComp, "expounded");
- break;
-
- default:
- throw new CorruptedCodestreamException("Unknown or " + "unsupported " + "quantization style " + "in Sqcd field, QCD " + "marker, main header");
-
- }
- }
- else
- {
- hi.qccValue["t" + tileIdx + "_c" + cComp] = ms;
- // If tile header is being read, set value for component in
- // this tiles
- switch (qType)
- {
-
- case CSJ2K.j2k.codestream.Markers.SQCX_NO_QUANTIZATION:
- decSpec.qts.setTileCompVal(tileIdx, cComp, "reversible");
- break;
-
- case CSJ2K.j2k.codestream.Markers.SQCX_SCALAR_DERIVED:
- decSpec.qts.setTileCompVal(tileIdx, cComp, "derived");
- break;
-
- case CSJ2K.j2k.codestream.Markers.SQCX_SCALAR_EXPOUNDED:
- decSpec.qts.setTileCompVal(tileIdx, cComp, "expounded");
- break;
-
- default:
- throw new CorruptedCodestreamException("Unknown or " + "unsupported " + "quantization style " + "in Sqcd field, QCD " + "marker, main header");
-
- }
- }
-
- // Decode all dequantizer params
- qParms = new StdDequantizerParams();
-
- if (qType == CSJ2K.j2k.codestream.Markers.SQCX_NO_QUANTIZATION)
- {
- int maxrl = (mainh ? ((System.Int32)decSpec.dls.getCompDef(cComp)) : ((System.Int32)decSpec.dls.getTileCompVal(tileIdx, cComp)));
- int j, rl; // i removed
- int minb, maxb, hpd;
-
- expC = qParms.exp = new int[maxrl + 1][];
- int[][] tmpArray = new int[maxrl + 1][];
- for (int i2 = 0; i2 < maxrl + 1; i2++)
- {
- tmpArray[i2] = new int[4];
- }
- ms.spqcc = tmpArray;
-
- for (rl = 0; rl <= maxrl; rl++)
- {
- // Loop on resolution levels
- // Find the number of subbands in the resolution level
- if (rl == 0)
- {
- // Only the LL subband
- minb = 0;
- maxb = 1;
- }
- else
- {
- // Dyadic decomposition
- hpd = 1;
-
- // Adapt hpd to resolution level
- if (hpd > maxrl - rl)
- {
- hpd -= (maxrl - rl);
- }
- else
- {
- hpd = 1;
- }
- // Determine max and min subband index
- minb = 1 << ((hpd - 1) << 1); // minb = 4^(hpd-1)
- maxb = 1 << (hpd << 1); // maxb = 4^hpd
- }
- // Allocate array for subbands in resolution level
- expC[rl] = new int[maxb];
-
- for (j = minb; j < maxb; j++)
- {
- tmp = ms.spqcc[rl][j] = ehs.ReadByte();
- expC[rl][j] = (tmp >> CSJ2K.j2k.codestream.Markers.SQCX_EXP_SHIFT) & CSJ2K.j2k.codestream.Markers.SQCX_EXP_MASK;
- }
- } // end for rl
- }
- else
- {
- int maxrl = (qType == CSJ2K.j2k.codestream.Markers.SQCX_SCALAR_DERIVED) ? 0 : (mainh ? ((System.Int32)decSpec.dls.getCompDef(cComp)) : ((System.Int32)decSpec.dls.getTileCompVal(tileIdx, cComp)));
- int j, rl; // i removed
- int minb, maxb, hpd;
-
- nStepC = qParms.nStep = new float[maxrl + 1][];
- expC = qParms.exp = new int[maxrl + 1][];
- int[][] tmpArray2 = new int[maxrl + 1][];
- for (int i3 = 0; i3 < maxrl + 1; i3++)
- {
- tmpArray2[i3] = new int[4];
- }
- ms.spqcc = tmpArray2;
-
- for (rl = 0; rl <= maxrl; rl++)
- {
- // Loop on resolution levels
- // Find the number of subbands in the resolution level
- if (rl == 0)
- {
- // Only the LL subband
- minb = 0;
- maxb = 1;
- }
- else
- {
- // Dyadic decomposition
- hpd = 1;
-
- // Adapt hpd to resolution level
- if (hpd > maxrl - rl)
- {
- hpd -= (maxrl - rl);
- }
- else
- {
- hpd = 1;
- }
- // Determine max and min subband index
- minb = 1 << ((hpd - 1) << 1); // minb = 4^(hpd-1)
- maxb = 1 << (hpd << 1); // maxb = 4^hpd
- }
- // Allocate array for subbands in resolution level
- expC[rl] = new int[maxb];
- nStepC[rl] = new float[maxb];
-
- for (j = minb; j < maxb; j++)
- {
- tmp = ms.spqcc[rl][j] = ehs.ReadUInt16();
- expC[rl][j] = (tmp >> 11) & 0x1f;
- // NOTE: the formula below does not support more than 5
- // bits for the exponent, otherwise (-1< Reads a COD marker segment and realigns the codestream where the next
- /// marker should be found.
- ///
- ///
- /// The encoder header stream.
- ///
- ///
- /// Flag indicating whether or not this marker segment is read
- /// from the main header.
- ///
- ///
- /// The index of the current tile
- ///
- ///
- /// Tile-part index
- ///
- ///
- /// If an I/O error occurs while reading from the
- /// encoder header stream
- ///
- ///
- //UPGRADE_TODO: Class 'java.io.DataInputStream' was converted to 'System.IO.BinaryReader' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaioDataInputStream'"
- private void readCOD(System.IO.BinaryReader ehs, bool mainh, int tileIdx, int tpIdx)
- {
- int cstyle; // The block style
- SynWTFilter[] hfilters, vfilters;
- //int l;
- System.Int32[] cblk;
- System.String errMsg;
- //bool sopUsed = false;
- //bool ephUsed = false;
- HeaderInfo.COD ms = hi.NewCOD;
-
- // Lcod (marker length)
- ms.lcod = ehs.ReadUInt16();
-
- // Scod (block style)
- // We only support wavelet transformed data
- cstyle = ms.scod = ehs.ReadByte();
-
- if ((cstyle & CSJ2K.j2k.codestream.Markers.SCOX_PRECINCT_PARTITION) != 0)
- {
- precinctPartitionIsUsed = true;
- // Remove flag
- cstyle &= ~(CSJ2K.j2k.codestream.Markers.SCOX_PRECINCT_PARTITION);
- }
- else
- {
- precinctPartitionIsUsed = false;
- }
-
- // SOP markers
- if (mainh)
- {
- hi.codValue["main"] = ms;
-
- if ((cstyle & CSJ2K.j2k.codestream.Markers.SCOX_USE_SOP) != 0)
- {
- // SOP markers are used
- decSpec.sops.setDefault((System.Object)"true".ToUpper().Equals("TRUE"));
- //sopUsed = true;
- // Remove flag
- cstyle &= ~(CSJ2K.j2k.codestream.Markers.SCOX_USE_SOP);
- }
- else
- {
- // SOP markers are not used
- decSpec.sops.setDefault((System.Object)"false".ToUpper().Equals("TRUE"));
- }
- }
- else
- {
- hi.codValue["t" + tileIdx] = ms;
-
- if ((cstyle & CSJ2K.j2k.codestream.Markers.SCOX_USE_SOP) != 0)
- {
- // SOP markers are used
- decSpec.sops.setTileDef(tileIdx, (System.Object)"true".ToUpper().Equals("TRUE"));
- //sopUsed = true;
- // Remove flag
- cstyle &= ~(CSJ2K.j2k.codestream.Markers.SCOX_USE_SOP);
- }
- else
- {
- // SOP markers are not used
- decSpec.sops.setTileDef(tileIdx, (System.Object)"false".ToUpper().Equals("TRUE"));
- }
- }
-
- // EPH markers
- if (mainh)
- {
- if ((cstyle & CSJ2K.j2k.codestream.Markers.SCOX_USE_EPH) != 0)
- {
- // EPH markers are used
- decSpec.ephs.setDefault((System.Object)"true".ToUpper().Equals("TRUE"));
- //ephUsed = true;
- // Remove flag
- cstyle &= ~(CSJ2K.j2k.codestream.Markers.SCOX_USE_EPH);
- }
- else
- {
- // EPH markers are not used
- decSpec.ephs.setDefault((System.Object)"false".ToUpper().Equals("TRUE"));
- }
- }
- else
- {
- if ((cstyle & CSJ2K.j2k.codestream.Markers.SCOX_USE_EPH) != 0)
- {
- // EPH markers are used
- decSpec.ephs.setTileDef(tileIdx, (System.Object)"true".ToUpper().Equals("TRUE"));
- //ephUsed = true;
- // Remove flag
- cstyle &= ~(CSJ2K.j2k.codestream.Markers.SCOX_USE_EPH);
- }
- else
- {
- // EPH markers are not used
- decSpec.ephs.setTileDef(tileIdx, (System.Object)"false".ToUpper().Equals("TRUE"));
- }
- }
-
- // Code-block partition origin
- if ((cstyle & (CSJ2K.j2k.codestream.Markers.SCOX_HOR_CB_PART | CSJ2K.j2k.codestream.Markers.SCOX_VER_CB_PART)) != 0)
- {
- FacilityManager.getMsgLogger().printmsg(CSJ2K.j2k.util.MsgLogger_Fields.WARNING, "Code-block partition origin " + "different from (0,0). This is defined in JPEG 2000" + " part 2 and may not be supported by all JPEG " + "2000 decoders.");
- }
- if ((cstyle & CSJ2K.j2k.codestream.Markers.SCOX_HOR_CB_PART) != 0)
- {
- if (cb0x != -1 && cb0x == 0)
- {
- throw new System.ArgumentException("Code-block partition " + "origin redefined in new" + " COD marker segment. Not" + " supported by JJ2000");
- }
- cb0x = 1;
- cstyle &= ~(CSJ2K.j2k.codestream.Markers.SCOX_HOR_CB_PART);
- }
- else
- {
- if (cb0x != -1 && cb0x == 1)
- {
- throw new System.ArgumentException("Code-block partition " + "origin redefined in new" + " COD marker segment. Not" + " supported by JJ2000");
- }
- cb0x = 0;
- }
- if ((cstyle & CSJ2K.j2k.codestream.Markers.SCOX_VER_CB_PART) != 0)
- {
- if (cb0y != -1 && cb0y == 0)
- {
- throw new System.ArgumentException("Code-block partition " + "origin redefined in new" + " COD marker segment. Not" + " supported by JJ2000");
- }
- cb0y = 1;
- cstyle &= ~(CSJ2K.j2k.codestream.Markers.SCOX_VER_CB_PART);
- }
- else
- {
- if (cb0y != -1 && cb0y == 1)
- {
- throw new System.ArgumentException("Code-block partition " + "origin redefined in new" + " COD marker segment. Not" + " supported by JJ2000");
- }
- cb0y = 0;
- }
-
- // SGcod
- // Read the progressive order
- ms.sgcod_po = ehs.ReadByte();
-
- // Read the number of layers
- ms.sgcod_nl = ehs.ReadUInt16();
- if (ms.sgcod_nl <= 0 || ms.sgcod_nl > 65535)
- {
- throw new CorruptedCodestreamException("Number of layers out of " + "range: 1--65535");
- }
-
- // Multiple component transform
- ms.sgcod_mct = ehs.ReadByte();
-
- // SPcod
- // decomposition levels
- int mrl = ms.spcod_ndl = ehs.ReadByte();
- if (mrl > 32)
- {
- throw new CorruptedCodestreamException("Number of decomposition " + "levels out of range: " + "0--32");
- }
-
- // Read the code-blocks dimensions
- cblk = new System.Int32[2];
- ms.spcod_cw = ehs.ReadByte();
- cblk[0] = (System.Int32)(1 << (ms.spcod_cw + 2));
- if (cblk[0] < CSJ2K.j2k.entropy.StdEntropyCoderOptions.MIN_CB_DIM || cblk[0] > CSJ2K.j2k.entropy.StdEntropyCoderOptions.MAX_CB_DIM)
- {
- errMsg = "Non-valid code-block width in SPcod field, " + "COD marker";
- throw new CorruptedCodestreamException(errMsg);
- }
- ms.spcod_ch = ehs.ReadByte();
- cblk[1] = (System.Int32)(1 << (ms.spcod_ch + 2));
- if (cblk[1] < CSJ2K.j2k.entropy.StdEntropyCoderOptions.MIN_CB_DIM || cblk[1] > CSJ2K.j2k.entropy.StdEntropyCoderOptions.MAX_CB_DIM)
- {
- errMsg = "Non-valid code-block height in SPcod field, " + "COD marker";
- throw new CorruptedCodestreamException(errMsg);
- }
- if ((cblk[0] * cblk[1]) > CSJ2K.j2k.entropy.StdEntropyCoderOptions.MAX_CB_AREA)
- {
- errMsg = "Non-valid code-block area in SPcod field, " + "COD marker";
- throw new CorruptedCodestreamException(errMsg);
- }
- if (mainh)
- {
- decSpec.cblks.setDefault((System.Object)(cblk));
- }
- else
- {
- decSpec.cblks.setTileDef(tileIdx, (System.Object)(cblk));
- }
-
- // Style of the code-block coding passes
- int ecOptions = ms.spcod_cs = ehs.ReadByte();
- if ((ecOptions & ~(CSJ2K.j2k.entropy.StdEntropyCoderOptions.OPT_BYPASS | CSJ2K.j2k.entropy.StdEntropyCoderOptions.OPT_RESET_MQ | CSJ2K.j2k.entropy.StdEntropyCoderOptions.OPT_TERM_PASS | CSJ2K.j2k.entropy.StdEntropyCoderOptions.OPT_VERT_STR_CAUSAL | CSJ2K.j2k.entropy.StdEntropyCoderOptions.OPT_PRED_TERM | CSJ2K.j2k.entropy.StdEntropyCoderOptions.OPT_SEG_SYMBOLS)) != 0)
- {
- throw new CorruptedCodestreamException("Unknown \"code-block " + "style\" in SPcod field, " + "COD marker: 0x" + System.Convert.ToString(ecOptions, 16));
- }
-
- // Read wavelet filter for tile or image
- hfilters = new SynWTFilter[1];
- vfilters = new SynWTFilter[1];
- hfilters[0] = readFilter(ehs, ms.spcod_t);
- vfilters[0] = hfilters[0];
-
- // Fill the filter spec
- // If this is the main header, set the default value, if it is the
- // tile header, set default for this tile
- SynWTFilter[][] hvfilters = new SynWTFilter[2][];
- hvfilters[0] = hfilters;
- hvfilters[1] = vfilters;
-
- // Get precinct partition sizes
- System.Collections.ArrayList[] v = new System.Collections.ArrayList[2];
- v[0] = System.Collections.ArrayList.Synchronized(new System.Collections.ArrayList(10));
- v[1] = System.Collections.ArrayList.Synchronized(new System.Collections.ArrayList(10));
- int val = CSJ2K.j2k.codestream.Markers.PRECINCT_PARTITION_DEF_SIZE;
- if (!precinctPartitionIsUsed)
- {
- System.Int32 w, h;
- w = (System.Int32)(1 << (val & 0x000F));
- v[0].Add(w);
- h = (System.Int32)(1 << (((val & 0x00F0) >> 4)));
- v[1].Add(h);
- }
- else
- {
- ms.spcod_ps = new int[mrl + 1];
- for (int rl = mrl; rl >= 0; rl--)
- {
- System.Int32 w, h;
- val = ms.spcod_ps[mrl - rl] = ehs.ReadByte();
- w = (System.Int32)(1 << (val & 0x000F));
- v[0].Insert(0, w);
- h = (System.Int32)(1 << (((val & 0x00F0) >> 4)));
- v[1].Insert(0, h);
- }
- }
- if (mainh)
- {
- decSpec.pss.setDefault(v);
- }
- else
- {
- decSpec.pss.setTileDef(tileIdx, v);
- }
- precinctPartitionIsUsed = true;
-
- // Check marker length
- checkMarkerLength(ehs, "COD marker");
-
- // Store specifications in decSpec
- if (mainh)
- {
- decSpec.wfs.setDefault(hvfilters);
- decSpec.dls.setDefault((System.Object)mrl);
- decSpec.ecopts.setDefault((System.Object)ecOptions);
- decSpec.cts.setDefault((System.Object)ms.sgcod_mct);
- decSpec.nls.setDefault((System.Object)ms.sgcod_nl);
- decSpec.pos.setDefault((System.Object)ms.sgcod_po);
- }
- else
- {
- decSpec.wfs.setTileDef(tileIdx, hvfilters);
- decSpec.dls.setTileDef(tileIdx, (System.Object)mrl);
- decSpec.ecopts.setTileDef(tileIdx, (System.Object)ecOptions);
- decSpec.cts.setTileDef(tileIdx, (System.Object)ms.sgcod_mct);
- decSpec.nls.setTileDef(tileIdx, (System.Object)ms.sgcod_nl);
- decSpec.pos.setTileDef(tileIdx, (System.Object)ms.sgcod_po);
- }
- }
-
- /// Reads the COC marker segment and realigns the codestream where the next
- /// marker should be found.
- ///
- ///
- /// The encoder header stream.
- ///
- ///
- /// Flag indicating whether or not this marker segment is read
- /// from the main header.
- ///
- ///
- /// The index of the current tile
- ///
- ///
- /// Tile-part index
- ///
- ///
- /// If an I/O error occurs while reading from the
- /// encoder header stream
- ///
- ///
- //UPGRADE_TODO: Class 'java.io.DataInputStream' was converted to 'System.IO.BinaryReader' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaioDataInputStream'"
- private void readCOC(System.IO.BinaryReader ehs, bool mainh, int tileIdx, int tpIdx)
- {
- int cComp; // current component
- SynWTFilter[] hfilters, vfilters;
- //int tmp, l;
- int ecOptions;
- System.Int32[] cblk;
- System.String errMsg;
- HeaderInfo.COC ms = hi.NewCOC;
-
- // Lcoc (marker length)
- ms.lcoc = ehs.ReadUInt16();
-
- // Ccoc
- if (nComp < 257)
- {
- cComp = ms.ccoc = ehs.ReadByte();
- }
- else
- {
- cComp = ms.ccoc = ehs.ReadUInt16();
- }
- if (cComp >= nComp)
- {
- throw new CorruptedCodestreamException("Invalid component index " + "in QCC marker");
- }
-
- // Scoc (block style)
- int cstyle = ms.scoc = ehs.ReadByte();
- if ((cstyle & CSJ2K.j2k.codestream.Markers.SCOX_PRECINCT_PARTITION) != 0)
- {
- precinctPartitionIsUsed = true;
- // Remove flag
- cstyle &= ~(CSJ2K.j2k.codestream.Markers.SCOX_PRECINCT_PARTITION);
- }
- else
- {
- precinctPartitionIsUsed = false;
- }
-
- // SPcoc
-
- // decomposition levels
- int mrl = ms.spcoc_ndl = ehs.ReadByte();
-
- // Read the code-blocks dimensions
- cblk = new System.Int32[2];
- ms.spcoc_cw = ehs.ReadByte();
- cblk[0] = (System.Int32)(1 << (ms.spcoc_cw + 2));
- if (cblk[0] < CSJ2K.j2k.entropy.StdEntropyCoderOptions.MIN_CB_DIM || cblk[0] > CSJ2K.j2k.entropy.StdEntropyCoderOptions.MAX_CB_DIM)
- {
- errMsg = "Non-valid code-block width in SPcod field, " + "COC marker";
- throw new CorruptedCodestreamException(errMsg);
- }
- ms.spcoc_ch = ehs.ReadByte();
- cblk[1] = (System.Int32)(1 << (ms.spcoc_ch + 2));
- if (cblk[1] < CSJ2K.j2k.entropy.StdEntropyCoderOptions.MIN_CB_DIM || cblk[1] > CSJ2K.j2k.entropy.StdEntropyCoderOptions.MAX_CB_DIM)
- {
- errMsg = "Non-valid code-block height in SPcod field, " + "COC marker";
- throw new CorruptedCodestreamException(errMsg);
- }
- if ((cblk[0] * cblk[1]) > CSJ2K.j2k.entropy.StdEntropyCoderOptions.MAX_CB_AREA)
- {
- errMsg = "Non-valid code-block area in SPcod field, " + "COC marker";
- throw new CorruptedCodestreamException(errMsg);
- }
- if (mainh)
- {
- decSpec.cblks.setCompDef(cComp, (System.Object)(cblk));
- }
- else
- {
- decSpec.cblks.setTileCompVal(tileIdx, cComp, (System.Object)(cblk));
- }
-
- // Read entropy block mode options
- // NOTE: currently OPT_SEG_SYMBOLS is not included here
- ecOptions = ms.spcoc_cs = ehs.ReadByte();
- if ((ecOptions & ~(CSJ2K.j2k.entropy.StdEntropyCoderOptions.OPT_BYPASS | CSJ2K.j2k.entropy.StdEntropyCoderOptions.OPT_RESET_MQ | CSJ2K.j2k.entropy.StdEntropyCoderOptions.OPT_TERM_PASS | CSJ2K.j2k.entropy.StdEntropyCoderOptions.OPT_VERT_STR_CAUSAL | CSJ2K.j2k.entropy.StdEntropyCoderOptions.OPT_PRED_TERM | CSJ2K.j2k.entropy.StdEntropyCoderOptions.OPT_SEG_SYMBOLS)) != 0)
- {
- throw new CorruptedCodestreamException("Unknown \"code-block " + "context\" in SPcoc field, " + "COC marker: 0x" + System.Convert.ToString(ecOptions, 16));
- }
-
- // Read wavelet filter for tile or image
- hfilters = new SynWTFilter[1];
- vfilters = new SynWTFilter[1];
- hfilters[0] = readFilter(ehs, ms.spcoc_t);
- vfilters[0] = hfilters[0];
-
- // Fill the filter spec
- // If this is the main header, set the default value, if it is the
- // tile header, set default for this tile
- SynWTFilter[][] hvfilters = new SynWTFilter[2][];
- hvfilters[0] = hfilters;
- hvfilters[1] = vfilters;
-
- // Get precinct partition sizes
- System.Collections.ArrayList[] v = new System.Collections.ArrayList[2];
- v[0] = System.Collections.ArrayList.Synchronized(new System.Collections.ArrayList(10));
- v[1] = System.Collections.ArrayList.Synchronized(new System.Collections.ArrayList(10));
- int val = CSJ2K.j2k.codestream.Markers.PRECINCT_PARTITION_DEF_SIZE;
- if (!precinctPartitionIsUsed)
- {
- System.Int32 w, h;
- w = (System.Int32)(1 << (val & 0x000F));
- v[0].Add(w);
- h = (System.Int32)(1 << (((val & 0x00F0) >> 4)));
- v[1].Add(h);
- }
- else
- {
- ms.spcoc_ps = new int[mrl + 1];
- for (int rl = mrl; rl >= 0; rl--)
- {
- System.Int32 w, h;
- val = ms.spcoc_ps[rl] = ehs.ReadByte();
- w = (System.Int32)(1 << (val & 0x000F));
- v[0].Insert(0, w);
- h = (System.Int32)(1 << (((val & 0x00F0) >> 4)));
- v[1].Insert(0, h);
- }
- }
- if (mainh)
- {
- decSpec.pss.setCompDef(cComp, v);
- }
- else
- {
- decSpec.pss.setTileCompVal(tileIdx, cComp, v);
- }
- precinctPartitionIsUsed = true;
-
- // Check marker length
- checkMarkerLength(ehs, "COD marker");
-
- if (mainh)
- {
- hi.cocValue["main_c" + cComp] = ms;
- decSpec.wfs.setCompDef(cComp, hvfilters);
- decSpec.dls.setCompDef(cComp, (System.Object)mrl);
- decSpec.ecopts.setCompDef(cComp, (System.Object)ecOptions);
- }
- else
- {
- hi.cocValue["t" + tileIdx + "_c" + cComp] = ms;
- decSpec.wfs.setTileCompVal(tileIdx, cComp, hvfilters);
- decSpec.dls.setTileCompVal(tileIdx, cComp, (System.Object)mrl);
- decSpec.ecopts.setTileCompVal(tileIdx, cComp, (System.Object)ecOptions);
- }
- }
-
- /// Reads the POC marker segment and realigns the codestream where the next
- /// marker should be found.
- ///
- ///
- /// The encoder header stream.
- ///
- ///
- /// Flag indicating whether or not this marker segment is read
- /// from the main header.
- ///
- ///
- /// The index of the current tile
- ///
- ///
- /// Tile-part index
- ///
- ///
- /// If an I/O error occurs while reading from the
- /// encoder header stream
- ///
- ///
- //UPGRADE_TODO: Class 'java.io.DataInputStream' was converted to 'System.IO.BinaryReader' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaioDataInputStream'"
- private void readPOC(System.IO.BinaryReader ehs, bool mainh, int t, int tpIdx)
- {
-
- bool useShort = (nComp >= 256) ? true : false;
- int tmp;
- int nOldChg = 0;
- HeaderInfo.POC ms;
- if (mainh || hi.pocValue["t" + t] == null)
- {
- ms = hi.NewPOC;
- }
- else
- {
- ms = (HeaderInfo.POC)hi.pocValue["t" + t];
- nOldChg = ms.rspoc.Length;
- }
-
- // Lpoc
- ms.lpoc = ehs.ReadUInt16();
-
- // Compute the number of new progression changes
- // newChg = (lpoc - Lpoc(2)) / (RSpoc(1) + CSpoc(2) +
- // LYEpoc(2) + REpoc(1) + CEpoc(2) + Ppoc (1) )
- int newChg = (ms.lpoc - 2) / (5 + (useShort ? 4 : 2));
- int ntotChg = nOldChg + newChg;
-
- int[][] change;
- if (nOldChg != 0)
- {
- // Creates new arrays
- int[][] tmpArray = new int[ntotChg][];
- for (int i = 0; i < ntotChg; i++)
- {
- tmpArray[i] = new int[6];
- }
- change = tmpArray;
- int[] tmprspoc = new int[ntotChg];
- int[] tmpcspoc = new int[ntotChg];
- int[] tmplyepoc = new int[ntotChg];
- int[] tmprepoc = new int[ntotChg];
- int[] tmpcepoc = new int[ntotChg];
- int[] tmpppoc = new int[ntotChg];
-
- // Copy old values
- int[][] prevChg = (int[][])decSpec.pcs.getTileDef(t);
- for (int chg = 0; chg < nOldChg; chg++)
- {
- change[chg] = prevChg[chg];
- tmprspoc[chg] = ms.rspoc[chg];
- tmpcspoc[chg] = ms.cspoc[chg];
- tmplyepoc[chg] = ms.lyepoc[chg];
- tmprepoc[chg] = ms.repoc[chg];
- tmpcepoc[chg] = ms.cepoc[chg];
- tmpppoc[chg] = ms.ppoc[chg];
- }
- ms.rspoc = tmprspoc;
- ms.cspoc = tmpcspoc;
- ms.lyepoc = tmplyepoc;
- ms.repoc = tmprepoc;
- ms.cepoc = tmpcepoc;
- ms.ppoc = tmpppoc;
- }
- else
- {
- int[][] tmpArray2 = new int[newChg][];
- for (int i2 = 0; i2 < newChg; i2++)
- {
- tmpArray2[i2] = new int[6];
- }
- change = tmpArray2;
- ms.rspoc = new int[newChg];
- ms.cspoc = new int[newChg];
- ms.lyepoc = new int[newChg];
- ms.repoc = new int[newChg];
- ms.cepoc = new int[newChg];
- ms.ppoc = new int[newChg];
- }
-
- for (int chg = nOldChg; chg < ntotChg; chg++)
- {
- // RSpoc
- change[chg][0] = ms.rspoc[chg] = ehs.ReadByte();
-
- // CSpoc
- if (useShort)
- {
- change[chg][1] = ms.cspoc[chg] = ehs.ReadUInt16();
- }
- else
- {
- change[chg][1] = ms.cspoc[chg] = ehs.ReadByte();
- }
-
- // LYEpoc
- change[chg][2] = ms.lyepoc[chg] = ehs.ReadUInt16();
- if (change[chg][2] < 1)
- {
- throw new CorruptedCodestreamException("LYEpoc value must be greater than 1 in POC marker " + "segment of tile " + t + ", tile-part " + tpIdx);
- }
-
- // REpoc
- change[chg][3] = ms.repoc[chg] = ehs.ReadByte();
- if (change[chg][3] <= change[chg][0])
- {
- throw new CorruptedCodestreamException("REpoc value must be greater than RSpoc in POC marker " + "segment of tile " + t + ", tile-part " + tpIdx);
- }
-
- // CEpoc
- if (useShort)
- {
- change[chg][4] = ms.cepoc[chg] = ehs.ReadUInt16();
- }
- else
- {
- tmp = ms.cepoc[chg] = ehs.ReadByte();
- if (tmp == 0)
- {
- change[chg][4] = 0;
- }
- else
- {
- change[chg][4] = tmp;
- }
- }
- if (change[chg][4] <= change[chg][1])
- {
- throw new CorruptedCodestreamException("CEpoc value must be greater than CSpoc in POC marker " + "segment of tile " + t + ", tile-part " + tpIdx);
- }
-
- // Ppoc
- change[chg][5] = ms.ppoc[chg] = ehs.ReadByte();
- }
-
- // Check marker length
- checkMarkerLength(ehs, "POC marker");
-
- // Register specifications
- if (mainh)
- {
- hi.pocValue["main"] = ms;
- decSpec.pcs.setDefault(change);
- }
- else
- {
- hi.pocValue["t" + t] = ms;
- decSpec.pcs.setTileDef(t, change);
- }
- }
-
- /// Reads TLM marker segment and realigns the codestream where the next
- /// marker should be found. Informations stored in these fields are
- /// currently NOT taken into account.
- ///
- ///
- /// The encoder header stream.
- ///
- ///
- /// If an I/O error occurs while reading from the
- /// encoder header stream
- ///
- ///
- //UPGRADE_TODO: Class 'java.io.DataInputStream' was converted to 'System.IO.BinaryReader' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaioDataInputStream'"
- private void readTLM(System.IO.BinaryReader ehs)
- {
- int length;
-
- length = ehs.ReadUInt16();
- //Ignore all informations contained
- System.IO.BinaryReader temp_BinaryReader;
- System.Int64 temp_Int64;
- temp_BinaryReader = ehs;
- temp_Int64 = temp_BinaryReader.BaseStream.Position;
- temp_Int64 = temp_BinaryReader.BaseStream.Seek(length - 2, System.IO.SeekOrigin.Current) - temp_Int64;
- // CONVERSION PROBLEM?
- int generatedAux = (int)temp_Int64;
-
- FacilityManager.getMsgLogger().printmsg(CSJ2K.j2k.util.MsgLogger_Fields.INFO, "Skipping unsupported TLM marker");
- }
-
- /// Reads PLM marker segment and realigns the codestream where the next
- /// marker should be found. Informations stored in these fields are
- /// currently not taken into account.
- ///
- ///
- /// The encoder header stream.
- ///
- ///
- /// If an I/O error occurs while reading from the
- /// encoder header stream
- ///
- ///
- //UPGRADE_TODO: Class 'java.io.DataInputStream' was converted to 'System.IO.BinaryReader' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaioDataInputStream'"
- private void readPLM(System.IO.BinaryReader ehs)
- {
- int length;
-
- length = ehs.ReadUInt16();
- //Ignore all informations contained
- System.IO.BinaryReader temp_BinaryReader;
- System.Int64 temp_Int64;
- temp_BinaryReader = ehs;
- temp_Int64 = temp_BinaryReader.BaseStream.Position;
- temp_Int64 = temp_BinaryReader.BaseStream.Seek(length - 2, System.IO.SeekOrigin.Current) - temp_Int64;
- // CONVERSION PROBLEM?
- int generatedAux = (int)temp_Int64;
-
- FacilityManager.getMsgLogger().printmsg(CSJ2K.j2k.util.MsgLogger_Fields.INFO, "Skipping unsupported PLM marker");
- }
-
- /// Reads the PLT fields and realigns the codestream where the next marker
- /// should be found. Informations stored in these fields are currently NOT
- /// taken into account.
- ///
- ///
- /// The encoder header stream.
- ///
- ///
- /// If an I/O error occurs while reading from the
- /// encoder header stream
- ///
- ///
- //UPGRADE_TODO: Class 'java.io.DataInputStream' was converted to 'System.IO.BinaryReader' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaioDataInputStream'"
- private void readPLTFields(System.IO.BinaryReader ehs)
- {
- int length;
-
- length = ehs.ReadUInt16();
- //Ignore all informations contained
- System.IO.BinaryReader temp_BinaryReader;
- System.Int64 temp_Int64;
- temp_BinaryReader = ehs;
- temp_Int64 = temp_BinaryReader.BaseStream.Position;
- temp_Int64 = temp_BinaryReader.BaseStream.Seek(length - 2, System.IO.SeekOrigin.Current) - temp_Int64;
- // CONVERSION PROBLEM?
- int generatedAux = (int)temp_Int64;
-
- FacilityManager.getMsgLogger().printmsg(CSJ2K.j2k.util.MsgLogger_Fields.INFO, "Skipping unsupported PLT marker");
- }
-
- /// Reads the RGN marker segment of the codestream header.
- ///
- /// May be used in tile or main header. If used in main header, it
- /// refers to the maxshift value of a component in all tiles. When used in
- /// tile header, only the particular tile-component is affected.
- ///
- ///
- /// The encoder header stream.
- ///
- ///
- /// Flag indicating whether or not this marker segment is read
- /// from the main header.
- ///
- ///
- /// The index of the current tile
- ///
- ///
- /// Tile-part index
- ///
- ///
- /// If an I/O error occurs while reading from the
- /// encoder header stream
- ///
- ///
- //UPGRADE_TODO: Class 'java.io.DataInputStream' was converted to 'System.IO.BinaryReader' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaioDataInputStream'"
- private void readRGN(System.IO.BinaryReader ehs, bool mainh, int tileIdx, int tpIdx)
- {
- int comp; // ROI component
- //int i; // loop variable
- //int tempComp; // Component for
- HeaderInfo.RGN ms = hi.NewRGN;
-
- // Lrgn (marker length)
- ms.lrgn = ehs.ReadUInt16();
-
- // Read component
- ms.crgn = comp = (nComp < 257) ? ehs.ReadByte() : ehs.ReadUInt16();
- if (comp >= nComp)
- {
- throw new CorruptedCodestreamException("Invalid component " + "index in RGN marker" + comp);
- }
-
- // Read type of RGN.(Srgn)
- ms.srgn = ehs.ReadByte();
-
- // Check that we can handle it.
- if (ms.srgn != CSJ2K.j2k.codestream.Markers.SRGN_IMPLICIT)
- throw new CorruptedCodestreamException("Unknown or unsupported " + "Srgn parameter in ROI " + "marker");
-
- if (decSpec.rois == null)
- {
- // No maxshift spec defined
- // Create needed ModuleSpec
- decSpec.rois = new MaxShiftSpec(nTiles, nComp, ModuleSpec.SPEC_TYPE_TILE_COMP);
- }
-
- // SPrgn
- ms.sprgn = ehs.ReadByte();
-
- if (mainh)
- {
- hi.rgnValue["main_c" + comp] = ms;
- decSpec.rois.setCompDef(comp, (System.Object)ms.sprgn);
- }
- else
- {
- hi.rgnValue["t" + tileIdx + "_c" + comp] = ms;
- decSpec.rois.setTileCompVal(tileIdx, comp, (System.Object)ms.sprgn);
- }
-
- // Check marker length
- checkMarkerLength(ehs, "RGN marker");
- }
-
- /// Reads the PPM marker segment of the main header.
- ///
- ///
- /// The encoder header stream.
- ///
- ///
- /// If an I/O error occurs while reading from the
- /// encoder header stream
- ///
- ///
- //UPGRADE_TODO: Class 'java.io.DataInputStream' was converted to 'System.IO.BinaryReader' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaioDataInputStream'"
- private void readPPM(System.IO.BinaryReader ehs)
- {
- int curMarkSegLen;
- int indx; // i, len, off removed
- int remSegLen;
- //byte[] b;
-
- // If first time readPPM method is called allocate arrays for packed
- // packet data
- if (pPMMarkerData == null)
- {
- pPMMarkerData = new byte[nPPMMarkSeg][];
- tileOfTileParts = System.Collections.ArrayList.Synchronized(new System.Collections.ArrayList(10));
- decSpec.pphs.setDefault((System.Object)true);
- }
-
- // Lppm (marker length)
- curMarkSegLen = ehs.ReadUInt16();
- remSegLen = curMarkSegLen - 3;
-
- // Zppm (index of PPM marker)
- indx = ehs.ReadByte();
-
- // Read Nppm and Ippm data
- pPMMarkerData[indx] = new byte[remSegLen];
- ehs.BaseStream.Read(pPMMarkerData[indx], 0, remSegLen); //SupportClass.ReadInput(ehs.BaseStream, pPMMarkerData[indx], 0, remSegLen);
-
- // Check marker length
- checkMarkerLength(ehs, "PPM marker");
- }
-
- /// Reads the PPT marker segment of the main header.
- ///
- ///
- /// The encoder header stream.
- ///
- ///
- /// The tile to which the current tile part belongs
- ///
- ///
- /// Tile-part index
- ///
- ///
- /// If an I/O error occurs while reading from the
- /// encoder header stream
- ///
- ///
- //UPGRADE_TODO: Class 'java.io.DataInputStream' was converted to 'System.IO.BinaryReader' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaioDataInputStream'"
- private void readPPT(System.IO.BinaryReader ehs, int tile, int tpIdx)
- {
- int curMarkSegLen;
- int indx; // len = 0; removed
- byte[] temp;
-
- if (tilePartPkdPktHeaders == null)
- {
- tilePartPkdPktHeaders = new byte[nTiles][][][];
- }
-
- if (tilePartPkdPktHeaders[tile] == null)
- {
- tilePartPkdPktHeaders[tile] = new byte[nTileParts[tile]][][];
- }
-
- if (tilePartPkdPktHeaders[tile][tpIdx] == null)
- {
- tilePartPkdPktHeaders[tile][tpIdx] = new byte[nPPTMarkSeg[tile][tpIdx]][];
- }
-
- // Lppt (marker length)
- curMarkSegLen = ehs.ReadUInt16();
-
- // Zppt (index of PPT marker)
- indx = ehs.ReadByte();
-
- // Ippt (packed packet headers)
- temp = new byte[curMarkSegLen - 3];
- ehs.BaseStream.Read(temp, 0, temp.Length); //SupportClass.ReadInput(ehs.BaseStream, temp, 0, temp.Length);
- tilePartPkdPktHeaders[tile][tpIdx][indx] = temp;
-
- // Check marker length
- checkMarkerLength(ehs, "PPT marker");
-
- decSpec.pphs.setTileDef(tile, (System.Object)true);
- }
-
- /// This method extract a marker segment from the main header and stores it
- /// into a byte buffer for the second pass. The marker segment is first
- /// identified. Then its flag is activated. Finally, its content is
- /// buffered into a byte array stored in an hashTable.
- ///
- /// If the marker is not recognized, it prints a warning and skips it
- /// according to its length.
- ///
- /// SIZ marker segment shall be the first encountered marker segment.
- ///
- ///
- /// The marker segment to process
- ///
- ///
- /// The encoded header stream
- ///
- ///
- private void extractMainMarkSeg(short marker, RandomAccessIO ehs)
- {
- if (nfMarkSeg == 0)
- {
- // First non-delimiting marker of the header
- // JPEG 2000 part 1 specify that it must be SIZ
- if (marker != CSJ2K.j2k.codestream.Markers.SIZ)
- {
- throw new CorruptedCodestreamException("First marker after " + "SOC " + "must be SIZ " + System.Convert.ToString(marker, 16));
- }
- }
-
- System.String htKey = ""; // Name used as a key for the hash-table
- if (ht == null)
- {
- ht = System.Collections.Hashtable.Synchronized(new System.Collections.Hashtable());
- }
-
- switch (marker)
- {
-
- case CSJ2K.j2k.codestream.Markers.SIZ:
- if ((nfMarkSeg & SIZ_FOUND) != 0)
- {
- throw new CorruptedCodestreamException("More than one SIZ marker " + "segment found in main " + "header");
- }
- nfMarkSeg |= SIZ_FOUND;
- htKey = "SIZ";
- break;
-
- case CSJ2K.j2k.codestream.Markers.SOD:
- throw new CorruptedCodestreamException("SOD found in main header");
-
- case CSJ2K.j2k.codestream.Markers.EOC:
- throw new CorruptedCodestreamException("EOC found in main header");
-
- case CSJ2K.j2k.codestream.Markers.SOT:
- if ((nfMarkSeg & SOT_FOUND) != 0)
- {
- throw new CorruptedCodestreamException("More than one SOT " + "marker " + "found right after " + "main " + "or tile header");
- }
- nfMarkSeg |= SOT_FOUND;
- return;
-
- case CSJ2K.j2k.codestream.Markers.COD:
- if ((nfMarkSeg & COD_FOUND) != 0)
- {
- throw new CorruptedCodestreamException("More than one COD " + "marker " + "found in main header");
- }
- nfMarkSeg |= COD_FOUND;
- htKey = "COD";
- break;
-
- case CSJ2K.j2k.codestream.Markers.COC:
- nfMarkSeg |= COC_FOUND;
- htKey = "COC" + (nCOCMarkSeg++);
- break;
-
- case CSJ2K.j2k.codestream.Markers.QCD:
- if ((nfMarkSeg & QCD_FOUND) != 0)
- {
- throw new CorruptedCodestreamException("More than one QCD " + "marker " + "found in main header");
- }
- nfMarkSeg |= QCD_FOUND;
- htKey = "QCD";
- break;
-
- case CSJ2K.j2k.codestream.Markers.QCC:
- nfMarkSeg |= QCC_FOUND;
- htKey = "QCC" + (nQCCMarkSeg++);
- break;
-
- case CSJ2K.j2k.codestream.Markers.RGN:
- nfMarkSeg |= RGN_FOUND;
- htKey = "RGN" + (nRGNMarkSeg++);
- break;
-
- case CSJ2K.j2k.codestream.Markers.COM:
- nfMarkSeg |= COM_FOUND;
- htKey = "COM" + (nCOMMarkSeg++);
- break;
-
- case CSJ2K.j2k.codestream.Markers.CRG:
- if ((nfMarkSeg & CRG_FOUND) != 0)
- {
- throw new CorruptedCodestreamException("More than one CRG " + "marker " + "found in main header");
- }
- nfMarkSeg |= CRG_FOUND;
- htKey = "CRG";
- break;
-
- case CSJ2K.j2k.codestream.Markers.PPM:
- nfMarkSeg |= PPM_FOUND;
- htKey = "PPM" + (nPPMMarkSeg++);
- break;
-
- case CSJ2K.j2k.codestream.Markers.TLM:
- if ((nfMarkSeg & TLM_FOUND) != 0)
- {
- throw new CorruptedCodestreamException("More than one TLM " + "marker " + "found in main header");
- }
- nfMarkSeg |= TLM_FOUND;
- break;
-
- case CSJ2K.j2k.codestream.Markers.PLM:
- if ((nfMarkSeg & PLM_FOUND) != 0)
- {
- throw new CorruptedCodestreamException("More than one PLM " + "marker " + "found in main header");
- }
- FacilityManager.getMsgLogger().printmsg(CSJ2K.j2k.util.MsgLogger_Fields.WARNING, "PLM marker segment found but " + "not used by by JJ2000 decoder.");
- nfMarkSeg |= PLM_FOUND;
- htKey = "PLM";
- break;
-
- case CSJ2K.j2k.codestream.Markers.POC:
- if ((nfMarkSeg & POC_FOUND) != 0)
- {
- throw new CorruptedCodestreamException("More than one POC " + "marker segment found " + "in main header");
- }
- nfMarkSeg |= POC_FOUND;
- htKey = "POC";
- break;
-
- case CSJ2K.j2k.codestream.Markers.PLT:
- throw new CorruptedCodestreamException("PLT found in main header");
-
- case CSJ2K.j2k.codestream.Markers.PPT:
- throw new CorruptedCodestreamException("PPT found in main header");
-
- default:
- htKey = "UNKNOWN";
- FacilityManager.getMsgLogger().printmsg(CSJ2K.j2k.util.MsgLogger_Fields.WARNING, "Non recognized marker segment (0x" + System.Convert.ToString(marker, 16) + ") in main header!");
- break;
-
- }
-
- if (marker < unchecked((short)0xffffff30) || marker > unchecked((short)0xffffff3f))
- {
- // Read marker segment length and create corresponding byte buffer
- int markSegLen = ehs.readUnsignedShort();
- byte[] buf = new byte[markSegLen];
-
- // Copy data (after re-insertion of the marker segment length);
- buf[0] = (byte)((markSegLen >> 8) & 0xFF);
- buf[1] = (byte)(markSegLen & 0xFF);
- ehs.readFully(buf, 2, markSegLen - 2);
-
- if (!htKey.Equals("UNKNOWN"))
- {
- // Store array in hashTable
- ht[htKey] = buf;
- }
- }
- }
-
- /// This method extracts a marker segment in a tile-part header and stores
- /// it into a byte buffer for the second pass. The marker is first
- /// recognized, then its flag is activated and, finally, its content is
- /// buffered in an element of byte arrays accessible thanks to a hashTable.
- /// If a marker segment is not recognized, it prints a warning and skip it
- /// according to its length.
- ///
- ///
- /// The marker to process
- ///
- ///
- /// The encoded header stream
- ///
- ///
- /// The index of the current tile
- ///
- ///
- /// The index of the current tile part
- ///
- ///
- public virtual void extractTilePartMarkSeg(short marker, RandomAccessIO ehs, int tileIdx, int tilePartIdx)
- {
-
- System.String htKey = ""; // Name used as a hash-table key
- if (ht == null)
- {
- ht = System.Collections.Hashtable.Synchronized(new System.Collections.Hashtable());
- }
-
- switch (marker)
- {
-
- case CSJ2K.j2k.codestream.Markers.SOT:
- throw new CorruptedCodestreamException("Second SOT marker " + "segment found in tile-" + "part header");
-
- case CSJ2K.j2k.codestream.Markers.SIZ:
- throw new CorruptedCodestreamException("SIZ found in tile-part" + " header");
-
- case CSJ2K.j2k.codestream.Markers.EOC:
- throw new CorruptedCodestreamException("EOC found in tile-part" + " header");
-
- case CSJ2K.j2k.codestream.Markers.TLM:
- throw new CorruptedCodestreamException("TLM found in tile-part" + " header");
-
- case CSJ2K.j2k.codestream.Markers.PLM:
- throw new CorruptedCodestreamException("PLM found in tile-part" + " header");
-
- case CSJ2K.j2k.codestream.Markers.PPM:
- throw new CorruptedCodestreamException("PPM found in tile-part" + " header");
-
- case CSJ2K.j2k.codestream.Markers.COD:
- if ((nfMarkSeg & COD_FOUND) != 0)
- {
- throw new CorruptedCodestreamException("More than one COD " + "marker " + "found in tile-part" + " header");
- }
- nfMarkSeg |= COD_FOUND;
- htKey = "COD";
- break;
-
- case CSJ2K.j2k.codestream.Markers.COC:
- nfMarkSeg |= COC_FOUND;
- htKey = "COC" + (nCOCMarkSeg++);
- break;
-
- case CSJ2K.j2k.codestream.Markers.QCD:
- if ((nfMarkSeg & QCD_FOUND) != 0)
- {
- throw new CorruptedCodestreamException("More than one QCD " + "marker " + "found in tile-part" + " header");
- }
- nfMarkSeg |= QCD_FOUND;
- htKey = "QCD";
- break;
-
- case CSJ2K.j2k.codestream.Markers.QCC:
- nfMarkSeg |= QCC_FOUND;
- htKey = "QCC" + (nQCCMarkSeg++);
- break;
-
- case CSJ2K.j2k.codestream.Markers.RGN:
- nfMarkSeg |= RGN_FOUND;
- htKey = "RGN" + (nRGNMarkSeg++);
- break;
-
- case CSJ2K.j2k.codestream.Markers.COM:
- nfMarkSeg |= COM_FOUND;
- htKey = "COM" + (nCOMMarkSeg++);
- break;
-
- case CSJ2K.j2k.codestream.Markers.CRG:
- throw new CorruptedCodestreamException("CRG marker found in " + "tile-part header");
-
- case CSJ2K.j2k.codestream.Markers.PPT:
- nfMarkSeg |= PPT_FOUND;
- if (nPPTMarkSeg == null)
- {
- nPPTMarkSeg = new int[nTiles][];
- }
- if (nPPTMarkSeg[tileIdx] == null)
- {
- nPPTMarkSeg[tileIdx] = new int[nTileParts[tileIdx]];
- }
- htKey = "PPT" + (nPPTMarkSeg[tileIdx][tilePartIdx]++);
- break;
-
- case CSJ2K.j2k.codestream.Markers.SOD:
- nfMarkSeg |= SOD_FOUND;
- return;
-
- case CSJ2K.j2k.codestream.Markers.POC:
- if ((nfMarkSeg & POC_FOUND) != 0)
- throw new CorruptedCodestreamException("More than one POC " + "marker segment found " + "in tile-part" + " header");
- nfMarkSeg |= POC_FOUND;
- htKey = "POC";
- break;
-
- case CSJ2K.j2k.codestream.Markers.PLT:
- if ((nfMarkSeg & PLM_FOUND) != 0)
- {
- throw new CorruptedCodestreamException("PLT marker found even" + "though PLM marker " + "found in main header");
- }
- FacilityManager.getMsgLogger().printmsg(CSJ2K.j2k.util.MsgLogger_Fields.WARNING, "PLT marker segment found but " + "not used by JJ2000 decoder.");
- htKey = "UNKNOWN";
- break;
-
- default:
- htKey = "UNKNOWN";
- FacilityManager.getMsgLogger().printmsg(CSJ2K.j2k.util.MsgLogger_Fields.WARNING, "Non recognized marker segment (0x" + System.Convert.ToString(marker, 16) + ") in tile-part header" + " of tile " + tileIdx + " !");
- break;
-
- }
-
- // Read marker segment length and create corresponding byte buffer
- int markSegLen = ehs.readUnsignedShort();
- byte[] buf = new byte[markSegLen];
-
- // Copy data (after re-insertion of marker segment length);
- buf[0] = (byte)((markSegLen >> 8) & 0xFF);
- buf[1] = (byte)(markSegLen & 0xFF);
- ehs.readFully(buf, 2, markSegLen - 2);
-
- if (!htKey.Equals("UNKNOWN"))
- {
- // Store array in hashTable
- ht[htKey] = buf;
- }
- }
-
- /// Retrieves and reads all marker segments found in the main header during
- /// the first pass.
- ///
- ///
- private void readFoundMainMarkSeg()
- {
- //UPGRADE_TODO: Class 'java.io.DataInputStream' was converted to 'System.IO.BinaryReader' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaioDataInputStream'"
- //System.IO.BinaryReader dis;
- System.IO.MemoryStream bais;
-
- // SIZ marker segment
- if ((nfMarkSeg & SIZ_FOUND) != 0)
- {
- bais = new System.IO.MemoryStream((byte[])ht["SIZ"]);
- readSIZ(new CSJ2K.Util.EndianBinaryReader(bais, true));
- bais.Dispose();
- }
-
- // COM marker segments
- if ((nfMarkSeg & COM_FOUND) != 0)
- {
- for (int i = 0; i < nCOMMarkSeg; i++)
- {
- bais = new System.IO.MemoryStream((byte[])ht["COM" + i]);
- readCOM(new CSJ2K.Util.EndianBinaryReader(bais, true), true, 0, i);
- bais.Dispose();
- }
- }
-
- // CRG marker segment
- if ((nfMarkSeg & CRG_FOUND) != 0)
- {
- bais = new System.IO.MemoryStream((byte[])ht["CRG"]);
- readCRG(new CSJ2K.Util.EndianBinaryReader(bais, true));
- bais.Dispose();
- }
-
- // COD marker segment
- if ((nfMarkSeg & COD_FOUND) != 0)
- {
- bais = new System.IO.MemoryStream((byte[])ht["COD"]);
- readCOD(new CSJ2K.Util.EndianBinaryReader(bais, true), true, 0, 0);
- bais.Dispose();
- }
-
- // COC marker segments
- if ((nfMarkSeg & COC_FOUND) != 0)
- {
- for (int i = 0; i < nCOCMarkSeg; i++)
- {
- bais = new System.IO.MemoryStream((byte[])ht["COC" + i]);
- readCOC(new CSJ2K.Util.EndianBinaryReader(bais, true), true, 0, 0);
- bais.Dispose();
- }
- }
-
- // RGN marker segment
- if ((nfMarkSeg & RGN_FOUND) != 0)
- {
- for (int i = 0; i < nRGNMarkSeg; i++)
- {
- bais = new System.IO.MemoryStream((byte[])ht["RGN" + i]);
- readRGN(new CSJ2K.Util.EndianBinaryReader(bais, true), true, 0, 0);
- bais.Dispose();
- }
- }
-
- // QCD marker segment
- if ((nfMarkSeg & QCD_FOUND) != 0)
- {
- bais = new System.IO.MemoryStream((byte[])ht["QCD"]);
- readQCD(new CSJ2K.Util.EndianBinaryReader(bais, true), true, 0, 0);
- bais.Dispose();
- }
-
- // QCC marker segments
- if ((nfMarkSeg & QCC_FOUND) != 0)
- {
- for (int i = 0; i < nQCCMarkSeg; i++)
- {
- bais = new System.IO.MemoryStream((byte[])ht["QCC" + i]);
- readQCC(new CSJ2K.Util.EndianBinaryReader(bais, true), true, 0, 0);
- bais.Dispose();
- }
- }
-
- // POC marker segment
- if ((nfMarkSeg & POC_FOUND) != 0)
- {
- bais = new System.IO.MemoryStream((byte[])ht["POC"]);
- readPOC(new CSJ2K.Util.EndianBinaryReader(bais, true), true, 0, 0);
- bais.Dispose();
- }
-
- // PPM marker segments
- if ((nfMarkSeg & PPM_FOUND) != 0)
- {
- for (int i = 0; i < nPPMMarkSeg; i++)
- {
- bais = new System.IO.MemoryStream((byte[])ht["PPM" + i]);
- readPPM(new CSJ2K.Util.EndianBinaryReader(bais));
- bais.Dispose();
- }
- }
-
- // Reset the hashtable
- ht = null;
- }
-
- /// Retrieves and reads all marker segments previously found in the
- /// tile-part header.
- ///
- ///
- /// The index of the current tile
- ///
- ///
- /// Index of the current tile-part
- ///
- ///
- public virtual void readFoundTilePartMarkSeg(int tileIdx, int tpIdx)
- {
-
- //UPGRADE_TODO: Class 'java.io.DataInputStream' was converted to 'System.IO.BinaryReader' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaioDataInputStream'"
- //CSJ2K.EndianBinaryReader dis;
- System.IO.MemoryStream bais;
-
- // COD marker segment
- if ((nfMarkSeg & COD_FOUND) != 0)
- {
- bais = new System.IO.MemoryStream((byte[])ht["COD"]);
- readCOD(new CSJ2K.Util.EndianBinaryReader(bais, true), false, tileIdx, tpIdx);
- }
-
- // COC marker segments
- if ((nfMarkSeg & COC_FOUND) != 0)
- {
- for (int i = 0; i < nCOCMarkSeg; i++)
- {
- bais = new System.IO.MemoryStream((byte[])ht["COC" + i]);
- readCOC(new CSJ2K.Util.EndianBinaryReader(bais, true), false, tileIdx, tpIdx);
- }
- }
-
- // RGN marker segment
- if ((nfMarkSeg & RGN_FOUND) != 0)
- {
- for (int i = 0; i < nRGNMarkSeg; i++)
- {
- bais = new System.IO.MemoryStream((byte[])ht["RGN" + i]);
- readRGN(new CSJ2K.Util.EndianBinaryReader(bais, true), false, tileIdx, tpIdx);
- }
- }
-
- // QCD marker segment
- if ((nfMarkSeg & QCD_FOUND) != 0)
- {
- bais = new System.IO.MemoryStream((byte[])ht["QCD"]);
- readQCD(new CSJ2K.Util.EndianBinaryReader(bais, true), false, tileIdx, tpIdx);
- }
-
- // QCC marker segments
- if ((nfMarkSeg & QCC_FOUND) != 0)
- {
- for (int i = 0; i < nQCCMarkSeg; i++)
- {
- bais = new System.IO.MemoryStream((byte[])ht["QCC" + i]);
- readQCC(new CSJ2K.Util.EndianBinaryReader(bais, true), false, tileIdx, tpIdx);
- }
- }
-
- // POC marker segment
- if ((nfMarkSeg & POC_FOUND) != 0)
- {
- bais = new System.IO.MemoryStream((byte[])ht["POC"]);
- readPOC(new CSJ2K.Util.EndianBinaryReader(bais, true), false, tileIdx, tpIdx);
- }
-
- // COM marker segments
- if ((nfMarkSeg & COM_FOUND) != 0)
- {
- for (int i = 0; i < nCOMMarkSeg; i++)
- {
- bais = new System.IO.MemoryStream((byte[])ht["COM" + i]);
- readCOM(new CSJ2K.Util.EndianBinaryReader(bais, true), false, tileIdx, i);
- }
- }
-
- // PPT marker segments
- if ((nfMarkSeg & PPT_FOUND) != 0)
- {
- for (int i = 0; i < nPPTMarkSeg[tileIdx][tpIdx]; i++)
- {
- bais = new System.IO.MemoryStream((byte[])ht["PPT" + i]);
- readPPT(new CSJ2K.Util.EndianBinaryReader(bais, true), tileIdx, tpIdx);
- }
- }
-
- // Reset ht
- ht = null;
- }
-
- /// Creates a HeaderDecoder instance and read in two passes the main header
- /// of the codestream. The first and last marker segments shall be
- /// respectively SOC and SOT.
- ///
- ///
- /// The encoded header stream where marker segments are
- /// extracted.
- ///
- ///
- /// The ParameterList object of the decoder
- ///
- ///
- /// The HeaderInfo holding information found in marker segments
- ///
- ///
- /// If an I/O error occurs while reading from the
- /// encoded header stream.
- ///
- /// If the end of the encoded header stream is
- /// reached before getting all the data.
- ///
- /// If invalid data is found in the
- /// codestream main header.
- ///
- ///
- public HeaderDecoder(RandomAccessIO ehs, ParameterList pl, HeaderInfo hi)
- {
-
- this.hi = hi;
- // CONVERSION PROBLEM?
- //this.verbose = verbose;
-
- pl.checkList(OPT_PREFIX, ParameterList.toNameArray(pinfo));
-
- mainHeadOff = ehs.Pos;
- if (((short)ehs.readShort()) != CSJ2K.j2k.codestream.Markers.SOC)
- {
- throw new CorruptedCodestreamException("SOC marker segment not " + " found at the " + "beginning of the " + "codestream.");
- }
-
- // First Pass: Decode and store main header information until the SOT
- // marker segment is found
- nfMarkSeg = 0;
- do
- {
- extractMainMarkSeg(ehs.readShort(), ehs);
- }
- while ((nfMarkSeg & SOT_FOUND) == 0); //Stop when SOT is found
- ehs.seek(ehs.Pos - 2); // Realign codestream on SOT marker
-
- // Second pass: Read each marker segment previously found
- readFoundMainMarkSeg();
- }
-
- /// Creates and returns the entropy decoder corresponding to the
- /// information read from the codestream header and with the special
- /// additional parameters from the parameter list.
- ///
- ///
- /// The bit stream reader agent where to get code-block data
- /// from.
- ///
- ///
- /// The parameter list containing parameters applicable to the
- /// entropy decoder (other parameters can also be present).
- ///
- ///
- /// The entropy decoder
- ///
- ///
- public virtual EntropyDecoder createEntropyDecoder(CodedCBlkDataSrcDec src, ParameterList pl)
- {
- bool doer;
- bool verber;
- int mMax;
-
- // Check parameters
- pl.checkList(EntropyDecoder.OPT_PREFIX, ParameterList.toNameArray(EntropyDecoder.ParameterInfo));
- // Get error detection option
- doer = pl.getBooleanParameter("Cer");
- // Get verbose error detection option
- verber = pl.getBooleanParameter("Cverber");
-
- // Get maximum number of bit planes from m quit condition
- mMax = pl.getIntParameter("m_quit");
- return new StdEntropyDecoder(src, decSpec, doer, verber, mMax);
- }
-
- /// Creates and returns the EnumeratedColorSpaceMapper
- /// corresponding to the information read from the JP2 image file
- /// via the ColorSpace parameter.
- ///
- ///
- /// The bit stream reader agent where to get code-block
- /// data from.
- ///
- /// provides color space information from the image file
- ///
- ///
- /// The color space mapping object
- ///
- /// image access exception
- ///
- /// if image contains a bad icc profile
- ///
- /// if image contains a bad colorspace box
- ///
- ///
- public virtual BlkImgDataSrc createColorSpaceMapper(BlkImgDataSrc src, CSJ2K.Color.ColorSpace csMap)
- {
- return ColorSpaceMapper.createInstance(src, csMap);
- }
-
- /// Creates and returns the ChannelDefinitonMapper which maps the
- /// input channels to the channel definition for the appropriate
- /// colorspace.
- ///
- ///
- /// The bit stream reader agent where to get code-block
- /// data from.
- ///
- /// provides color space information from the image file
- ///
- ///
- /// The channel definition mapping object
- ///
- /// image access exception
- ///
- /// if image contains a bad colorspace box
- ///
- ///
- public virtual BlkImgDataSrc createChannelDefinitionMapper(BlkImgDataSrc src, CSJ2K.Color.ColorSpace csMap)
- {
- return ChannelDefinitionMapper.createInstance(src, csMap);
- }
-
- /// Creates and returns the PalettizedColorSpaceMapper which uses
- /// the input samples as indicies into a sample palette to
- /// construct the output.
- ///
- ///
- /// The bit stream reader agent where to get code-block
- /// data from.
- ///
- /// provides color space information from the image file
- ///
- ///
- /// a PalettizedColorSpaceMapper instance
- ///
- /// image access exception
- ///
- /// if image contains a bad colorspace box
- ///
- ///
- public virtual BlkImgDataSrc createPalettizedColorSpaceMapper(BlkImgDataSrc src, CSJ2K.Color.ColorSpace csMap)
- {
- return PalettizedColorSpaceMapper.createInstance(src, csMap);
- }
-
- /// Creates and returns the Resampler which converts the input
- /// source to one in which all channels have the same number of
- /// samples. This is required for colorspace conversions.
- ///
- ///
- /// The bit stream reader agent where to get code-block
- /// data from.
- ///
- /// provides color space information from the image file
- ///
- ///
- /// The resampled BlkImgDataSrc
- ///
- /// image access exception
- ///
- /// if image contains a bad colorspace box
- ///
- ///
- public virtual BlkImgDataSrc createResampler(BlkImgDataSrc src, CSJ2K.Color.ColorSpace csMap)
- {
- return Resampler.createInstance(src, csMap);
- }
-
- /// Creates and returns the ROIDeScaler corresponding to the information
- /// read from the codestream header and with the special additional
- /// parameters from the parameter list.
- ///
- ///
- /// The bit stream reader agent where to get code-block data
- /// from.
- ///
- ///
- /// The parameter list containing parameters applicable to the
- /// entropy decoder (other parameters can also be present).
- ///
- ///
- /// The DecoderSpecs instance after any image manipulation.
- ///
- ///
- /// The ROI descaler.
- ///
- ///
- public virtual ROIDeScaler createROIDeScaler(CBlkQuantDataSrcDec src, ParameterList pl, DecoderSpecs decSpec2)
- {
- return ROIDeScaler.createInstance(src, pl, decSpec2);
- }
-
- /// Method that resets members indicating which markers have already been
- /// found
- ///
- ///
- public virtual void resetHeaderMarkers()
- {
- // The found status of PLM remains since only PLM OR PLT allowed
- // Same goes for PPM and PPT
- nfMarkSeg = nfMarkSeg & (PLM_FOUND | PPM_FOUND);
- nCOCMarkSeg = 0;
- nQCCMarkSeg = 0;
- nCOMMarkSeg = 0;
- nRGNMarkSeg = 0;
- }
-
- /// Print information about the current header.
- ///
- ///
- /// Information in a String
- ///
- ///
- public override System.String ToString()
- {
- return hdStr;
- }
-
- /// Return the packed packet headers for a given tile.
- ///
- ///
- /// An input stream containing the packed packet headers for a
- /// particular tile
- ///
- ///
- /// If an I/O error occurs while reading from the
- /// encoder header stream
- ///
- ///
- public virtual System.IO.MemoryStream getPackedPktHead(int tile)
- {
-
- if (pkdPktHeaders == null)
- {
- int i, t;
- pkdPktHeaders = new System.IO.MemoryStream[nTiles];
- for (i = nTiles - 1; i >= 0; i--)
- {
- pkdPktHeaders[i] = new System.IO.MemoryStream();
- }
- if (nPPMMarkSeg != 0)
- {
- // If this is first time packed packet headers are requested,
- // create packed packet headers from Nppm and Ippm fields
- int nppm;
- int nTileParts = tileOfTileParts.Count;
- byte[] temp;
- System.IO.MemoryStream pph;
- System.IO.MemoryStream allNppmIppm = new System.IO.MemoryStream();
-
- // Concatenate all Nppm and Ippm fields
- for (i = 0; i < nPPMMarkSeg; i++)
- {
- byte[] temp_byteArray;
- temp_byteArray = pPMMarkerData[i];
- allNppmIppm.Write(temp_byteArray, 0, temp_byteArray.Length);
- }
- pph = new System.IO.MemoryStream(allNppmIppm.ToArray());
-
- // Read all packed packet headers and concatenate for each
- // tile part
- for (i = 0; i < nTileParts; i++)
- {
- t = ((System.Int32)tileOfTileParts[i]);
- // get Nppm value
- nppm = (pph.ReadByte() << 24) | (pph.ReadByte() << 16) | (pph.ReadByte() << 8) | (pph.ReadByte());
-
- temp = new byte[nppm];
- // get ippm field
- pph.Read(temp, 0, temp.Length); //SupportClass.ReadInput(pph, temp, 0, temp.Length);
- byte[] temp_byteArray2;
- temp_byteArray2 = temp;
- pkdPktHeaders[t].Write(temp_byteArray2, 0, temp_byteArray2.Length);
- }
- }
- else
- {
- int tp;
- // Write all packed packet headers to pkdPktHeaders
- for (t = nTiles - 1; t >= 0; t--)
- {
- for (tp = 0; tp < nTileParts[t]; tp++)
- {
- for (i = 0; i < nPPTMarkSeg[t][tp]; i++)
- {
- byte[] temp_byteArray3;
- temp_byteArray3 = tilePartPkdPktHeaders[t][tp][i];
- pkdPktHeaders[t].Write(temp_byteArray3, 0, temp_byteArray3.Length);
- }
- }
- }
- }
- }
-
- return new System.IO.MemoryStream(pkdPktHeaders[tile].ToArray());
- }
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/codestream/reader/PktDecoder.cs b/CSJ2K/j2k/codestream/reader/PktDecoder.cs
deleted file mode 100644
index aab6bd6a..00000000
--- a/CSJ2K/j2k/codestream/reader/PktDecoder.cs
+++ /dev/null
@@ -1,1679 +0,0 @@
-using CSJ2K.j2k.decoder;
-using CSJ2K.j2k.image;
-using CSJ2K.j2k.io;
-using CSJ2K.j2k.util;
-/// CVS identifier:
-///
-/// $Id: PktDecoder.java,v 1.46 2002/07/19 12:35:14 grosbois Exp $
-///
-/// Class: PktDecoder
-///
-/// Description: Reads packets heads and keeps location of
-/// code-blocks' codewords
-///
-///
-///
-/// COPYRIGHT:
-///
-/// This software module was originally developed by Raphaël Grosbois and
-/// Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-/// Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-/// Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-/// Centre France S.A) in the course of development of the JPEG2000
-/// standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-/// software module is an implementation of a part of the JPEG 2000
-/// Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-/// Systems AB and Canon Research Centre France S.A (collectively JJ2000
-/// Partners) agree not to assert against ISO/IEC and users of the JPEG
-/// 2000 Standard (Users) any of their rights under the copyright, not
-/// including other intellectual property rights, for this software module
-/// with respect to the usage by ISO/IEC and Users of this software module
-/// or modifications thereof for use in hardware or software products
-/// claiming conformance to the JPEG 2000 Standard. Those intending to use
-/// this software module in hardware or software products are advised that
-/// their use may infringe existing patents. The original developers of
-/// this software module, JJ2000 Partners and ISO/IEC assume no liability
-/// for use of this software module or modifications thereof. No license
-/// or right to this software module is granted for non JPEG 2000 Standard
-/// conforming products. JJ2000 Partners have full right to use this
-/// software module for his/her own purpose, assign or donate this
-/// software module to any third party and to inhibit third parties from
-/// using this software module for non JPEG 2000 Standard conforming
-/// products. This copyright notice must be included in all copies or
-/// derivative works of this software module.
-///
-/// Copyright (c) 1999/2000 JJ2000 Partners.
-///
-///
-using CSJ2K.j2k.wavelet.synthesis;
-namespace CSJ2K.j2k.codestream.reader
-{
-
- /// This class is used to read packet's head and body. All the members must be
- /// re-initialized at the beginning of each tile thanks to the restart()
- /// method.
- ///
- ///
- public class PktDecoder
- {
-
- /// Reference to the codestream reader agent
- private BitstreamReaderAgent src;
-
- /// Flag indicating whether packed packet header was used for this tile
- private bool pph = false;
-
- /// The packed packet header if it was used
- private System.IO.MemoryStream pphbais;
-
- /// Reference to decoder specifications
- private DecoderSpecs decSpec;
-
- /// Reference to the HeaderDecoder
- private HeaderDecoder hd;
-
- /// Initial value of the state variable associated with code-block
- /// length.
- ///
- //UPGRADE_NOTE: Final was removed from the declaration of 'INIT_LBLOCK '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- private int INIT_LBLOCK = 3;
-
- /// The wrapper to read bits for the packet heads
- private PktHeaderBitReader bin;
-
- /// Reference to the stream where to read from
- private RandomAccessIO ehs;
-
- /// Maximum number of precincts :
- ///
- ///
- /// - 1st dim: component index.
- /// - 2nd dim: resolution level index.
- ///
- ///
- ///
- private Coord[][] numPrec;
-
- /// Index of the current tile
- private int tIdx;
-
- /// Array containing the coordinates, width, height, indexes, ... of the
- /// precincts in the current tile:
- ///
- ///
- /// - 1st dim: component index.
- /// - 2nd dim: resolution level index.
- /// - 3rd dim: precinct index.
- ///
- ///
- ///
- private PrecInfo[][][] ppinfo;
-
- /// Lblock value used to read code size information in each packet head:
- ///
- ///
- /// - 1st dim: component index.
- /// - 2nd dim: resolution level index.
- /// - 3rd dim: subband index.
- /// - 4th/5th dim: code-block index (vert. and horiz.).
- ///
- ///
- ///
- private int[][][][][] lblock;
-
- /// Tag tree used to read inclusion informations in packet's head:
- ///
- ///
- /// - 1st dim: component index.
- /// - 2nd dim: resolution level index.
- /// - 3rd dim: precinct index.
- /// - 4th dim: subband index.
- ///
- ///
- private TagTreeDecoder[][][][] ttIncl;
-
- /// Tag tree used to read bit-depth information in packet's head:
- ///
- ///
- /// - 1st dim: component index.
- /// - 2nd dim: resolution level index.
- /// - 3rd dim: precinct index.
- /// - 4th dim: subband index.
- ///
- ///
- ///
- private TagTreeDecoder[][][][] ttMaxBP;
-
- /// Number of layers in t he current tile
- private int nl = 0;
-
- /// The number of components
- private int nc;
-
- /// Whether or not SOP marker segment are used
- private bool sopUsed = false;
-
- /// Whether or not EPH marker are used
- private bool ephUsed = false;
-
- /// Index of the current packet in the tile. Used with SOP marker segment
- ///
- ///
- private int pktIdx;
-
- /// List of code-blocks found in last read packet head (one list
- /// per subband)
- ///
- private System.Collections.ArrayList[] cblks;
-
- /// Number of codeblocks encountered. used for ncb quit condition
- private int ncb;
-
- /// Maximum number of codeblocks to read before ncb quit condition is
- /// reached
- ///
- private int maxCB;
-
- /// Flag indicating whether ncb quit condition has been reached
- private bool ncbQuit;
-
- /// The tile in which the ncb quit condition was reached
- private int tQuit;
-
- /// The component in which the ncb quit condition was reached
- private int cQuit;
-
- /// The subband in which the ncb quit condition was reached
- private int sQuit;
-
- /// The resolution in which the ncb quit condition was reached
- private int rQuit;
-
- /// The x position of the last code block before ncb quit reached
- private int xQuit;
-
- /// The y position of the last code block before ncb quit reached
- private int yQuit;
-
- /// True if truncation mode is used. False if it is parsing mode
- private bool isTruncMode;
-
- /// Creates an empty PktDecoder object associated with given decoder
- /// specifications and HeaderDecoder. This object must be initialized
- /// thanks to the restart method before being used.
- ///
- ///
- /// The decoder specifications.
- ///
- ///
- /// The HeaderDecoder instance.
- ///
- ///
- /// The stream where to read data from.
- ///
- ///
- /// The bit stream reader agent.
- ///
- ///
- /// Whether or not truncation mode is required.
- ///
- ///
- /// The maximum number of code-blocks to read before ncbquit
- ///
- ///
- ///
- public PktDecoder(DecoderSpecs decSpec, HeaderDecoder hd, RandomAccessIO ehs, BitstreamReaderAgent src, bool isTruncMode, int maxCB)
- {
- this.decSpec = decSpec;
- this.hd = hd;
- this.ehs = ehs;
- this.isTruncMode = isTruncMode;
- bin = new PktHeaderBitReader(ehs);
- this.src = src;
- ncb = 0;
- ncbQuit = false;
- this.maxCB = maxCB;
- }
-
-
- /// Re-initialize the PktDecoder instance at the beginning of a new tile.
- ///
- ///
- /// The number of components in this tile
- ///
- ///
- /// The maximum number of decomposition level in each component
- /// of this tile
- ///
- ///
- /// The number of layers in this tile
- ///
- ///
- /// The code-blocks array
- ///
- ///
- /// Flag indicating whether packed packet headers was used
- ///
- ///
- /// Stream containing the packed packet headers
- ///
- ///
- public virtual CBlkInfo[][][][][] restart(int nc, int[] mdl, int nl, CBlkInfo[][][][][] cbI, bool pph, System.IO.MemoryStream pphbais)
- {
- this.nc = nc;
- this.nl = nl;
- this.tIdx = src.TileIdx;
- this.pph = pph;
- this.pphbais = pphbais;
-
- sopUsed = ((System.Boolean)decSpec.sops.getTileDef(tIdx));
- pktIdx = 0;
- ephUsed = ((System.Boolean)decSpec.ephs.getTileDef(tIdx));
-
- cbI = new CBlkInfo[nc][][][][];
- lblock = new int[nc][][][][];
- ttIncl = new TagTreeDecoder[nc][][][];
- ttMaxBP = new TagTreeDecoder[nc][][][];
- numPrec = new Coord[nc][];
- ppinfo = new PrecInfo[nc][][];
-
- // Used to compute the maximum number of precincts for each resolution
- // level
- int tcx0, tcy0, tcx1, tcy1; // Current tile position in the domain of
- // the image component
- int trx0, try0, trx1, try1; // Current tile position in the reduced
- // resolution image domain
- //int xrsiz, yrsiz; // Component sub-sampling factors
-
- SubbandSyn root, sb;
- int mins, maxs;
- Coord nBlk = null;
- int cb0x = src.CbULX;
- int cb0y = src.CbULY;
-
- for (int c = 0; c < nc; c++)
- {
- cbI[c] = new CBlkInfo[mdl[c] + 1][][][];
- lblock[c] = new int[mdl[c] + 1][][][];
- ttIncl[c] = new TagTreeDecoder[mdl[c] + 1][][];
- ttMaxBP[c] = new TagTreeDecoder[mdl[c] + 1][][];
- numPrec[c] = new Coord[mdl[c] + 1];
- ppinfo[c] = new PrecInfo[mdl[c] + 1][];
-
- // Get the tile-component coordinates on the reference grid
- tcx0 = src.getResULX(c, mdl[c]);
- tcy0 = src.getResULY(c, mdl[c]);
- tcx1 = tcx0 + src.getTileCompWidth(tIdx, c, mdl[c]);
- tcy1 = tcy0 + src.getTileCompHeight(tIdx, c, mdl[c]);
-
- for (int r = 0; r <= mdl[c]; r++)
- {
-
- // Tile's coordinates in the reduced resolution image domain
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- trx0 = (int)System.Math.Ceiling(tcx0 / (double)(1 << (mdl[c] - r)));
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- try0 = (int)System.Math.Ceiling(tcy0 / (double)(1 << (mdl[c] - r)));
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- trx1 = (int)System.Math.Ceiling(tcx1 / (double)(1 << (mdl[c] - r)));
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- try1 = (int)System.Math.Ceiling(tcy1 / (double)(1 << (mdl[c] - r)));
-
- // Calculate the maximum number of precincts for each
- // resolution level taking into account tile specific options.
- double twoppx = (double)getPPX(tIdx, c, r);
- double twoppy = (double)getPPY(tIdx, c, r);
- numPrec[c][r] = new Coord();
- if (trx1 > trx0)
- {
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- numPrec[c][r].x = (int)System.Math.Ceiling((trx1 - cb0x) / twoppx) - (int)System.Math.Floor((trx0 - cb0x) / twoppx);
- }
- else
- {
- numPrec[c][r].x = 0;
- }
- if (try1 > try0)
- {
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- numPrec[c][r].y = (int)System.Math.Ceiling((try1 - cb0y) / twoppy) - (int)System.Math.Floor((try0 - cb0y) / twoppy);
- }
- else
- {
- numPrec[c][r].y = 0;
- }
-
- // First and last subbands indexes
- mins = (r == 0) ? 0 : 1;
- maxs = (r == 0) ? 1 : 4;
-
- int maxPrec = numPrec[c][r].x * numPrec[c][r].y;
-
- ttIncl[c][r] = new TagTreeDecoder[maxPrec][];
- for (int i = 0; i < maxPrec; i++)
- {
- ttIncl[c][r][i] = new TagTreeDecoder[maxs + 1];
- }
- ttMaxBP[c][r] = new TagTreeDecoder[maxPrec][];
- for (int i2 = 0; i2 < maxPrec; i2++)
- {
- ttMaxBP[c][r][i2] = new TagTreeDecoder[maxs + 1];
- }
- cbI[c][r] = new CBlkInfo[maxs + 1][][];
- lblock[c][r] = new int[maxs + 1][][];
-
- ppinfo[c][r] = new PrecInfo[maxPrec];
- fillPrecInfo(c, r, mdl[c]);
-
- root = (SubbandSyn)src.getSynSubbandTree(tIdx, c);
- for (int s = mins; s < maxs; s++)
- {
- sb = (SubbandSyn)root.getSubbandByIdx(r, s);
- nBlk = sb.numCb;
-
- cbI[c][r][s] = new CBlkInfo[nBlk.y][];
- for (int i3 = 0; i3 < nBlk.y; i3++)
- {
- cbI[c][r][s][i3] = new CBlkInfo[nBlk.x];
- }
- lblock[c][r][s] = new int[nBlk.y][];
- for (int i4 = 0; i4 < nBlk.y; i4++)
- {
- lblock[c][r][s][i4] = new int[nBlk.x];
- }
-
- for (int i = nBlk.y - 1; i >= 0; i--)
- {
- ArrayUtil.intArraySet(lblock[c][r][s][i], INIT_LBLOCK);
- }
- } // loop on subbands
- } // End loop on resolution levels
- } // End loop on components
-
- return cbI;
- }
-
- /// Retrives precincts and code-blocks coordinates in the given resolution,
- /// level and component. Finishes TagTreeEncoder initialization as well.
- ///
- ///
- /// Component index.
- ///
- ///
- /// Resolution level index.
- ///
- ///
- /// Number of decomposition level in component c.
- ///
- ///
- private void fillPrecInfo(int c, int r, int mdl)
- {
- if (ppinfo[c][r].Length == 0)
- return; // No precinct in this
- // resolution level
-
- Coord tileI = src.getTile(null);
- Coord nTiles = src.getNumTiles(null);
-
- int xsiz, ysiz, x0siz, y0siz;
- int xt0siz, yt0siz;
- int xtsiz, ytsiz;
-
- xt0siz = src.TilePartULX;
- yt0siz = src.TilePartULY;
- xtsiz = src.NomTileWidth;
- ytsiz = src.NomTileHeight;
- x0siz = hd.ImgULX;
- y0siz = hd.ImgULY;
- xsiz = hd.ImgWidth;
- ysiz = hd.ImgHeight;
-
- int tx0 = (tileI.x == 0) ? x0siz : xt0siz + tileI.x * xtsiz;
- int ty0 = (tileI.y == 0) ? y0siz : yt0siz + tileI.y * ytsiz;
- int tx1 = (tileI.x != nTiles.x - 1) ? xt0siz + (tileI.x + 1) * xtsiz : xsiz;
- int ty1 = (tileI.y != nTiles.y - 1) ? yt0siz + (tileI.y + 1) * ytsiz : ysiz;
-
- int xrsiz = hd.getCompSubsX(c);
- int yrsiz = hd.getCompSubsY(c);
-
- int tcx0 = src.getResULX(c, mdl);
- int tcy0 = src.getResULY(c, mdl);
- int tcx1 = tcx0 + src.getTileCompWidth(tIdx, c, mdl);
- int tcy1 = tcy0 + src.getTileCompHeight(tIdx, c, mdl);
-
- int ndl = mdl - r;
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- int trx0 = (int)System.Math.Ceiling(tcx0 / (double)(1 << ndl));
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- int try0 = (int)System.Math.Ceiling(tcy0 / (double)(1 << ndl));
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- int trx1 = (int)System.Math.Ceiling(tcx1 / (double)(1 << ndl));
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- int try1 = (int)System.Math.Ceiling(tcy1 / (double)(1 << ndl));
-
- int cb0x = src.CbULX;
- int cb0y = src.CbULY;
-
- double twoppx = (double)getPPX(tIdx, c, r);
- double twoppy = (double)getPPY(tIdx, c, r);
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- int twoppx2 = (int)(twoppx / 2);
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- int twoppy2 = (int)(twoppy / 2);
-
- // Precincts are located at (cb0x+i*twoppx,cb0y+j*twoppy)
- // Valid precincts are those which intersect with the current
- // resolution level
- int maxPrec = ppinfo[c][r].Length;
- int nPrec = 0;
-
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- int istart = (int)System.Math.Floor((try0 - cb0y) / twoppy);
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- int iend = (int)System.Math.Floor((try1 - 1 - cb0y) / twoppy);
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- int jstart = (int)System.Math.Floor((trx0 - cb0x) / twoppx);
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- int jend = (int)System.Math.Floor((trx1 - 1 - cb0x) / twoppx);
-
- int acb0x, acb0y;
-
- SubbandSyn root = src.getSynSubbandTree(tIdx, c);
- SubbandSyn sb = null;
-
- int p0x, p0y, p1x, p1y; // Precinct projection in subband
- int s0x, s0y, s1x, s1y; // Active subband portion
- int cw, ch;
- int kstart, kend, lstart, lend, k0, l0;
- int prg_ulx, prg_uly;
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- int prg_w = (int)twoppx << ndl;
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- int prg_h = (int)twoppy << ndl;
- int tmp1, tmp2;
-
- CBlkCoordInfo cb;
-
- for (int i = istart; i <= iend; i++)
- {
- // Vertical precincts
- for (int j = jstart; j <= jend; j++, nPrec++)
- {
- // Horizontal precincts
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- if (j == jstart && (trx0 - cb0x) % (xrsiz * ((int)twoppx)) != 0)
- {
- prg_ulx = tx0;
- }
- else
- {
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- prg_ulx = cb0x + j * xrsiz * ((int)twoppx << ndl);
- }
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- if (i == istart && (try0 - cb0y) % (yrsiz * ((int)twoppy)) != 0)
- {
- prg_uly = ty0;
- }
- else
- {
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- prg_uly = cb0y + i * yrsiz * ((int)twoppy << ndl);
- }
-
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- ppinfo[c][r][nPrec] = new PrecInfo(r, (int)(cb0x + j * twoppx), (int)(cb0y + i * twoppy), (int)twoppx, (int)twoppy, prg_ulx, prg_uly, prg_w, prg_h);
-
- if (r == 0)
- {
- // LL subband
- acb0x = cb0x;
- acb0y = cb0y;
-
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- p0x = acb0x + j * (int)twoppx;
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- p1x = p0x + (int)twoppx;
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- p0y = acb0y + i * (int)twoppy;
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- p1y = p0y + (int)twoppy;
-
- sb = (SubbandSyn)root.getSubbandByIdx(0, 0);
- s0x = (p0x < sb.ulcx) ? sb.ulcx : p0x;
- s1x = (p1x > sb.ulcx + sb.w) ? sb.ulcx + sb.w : p1x;
- s0y = (p0y < sb.ulcy) ? sb.ulcy : p0y;
- s1y = (p1y > sb.ulcy + sb.h) ? sb.ulcy + sb.h : p1y;
-
- // Code-blocks are located at (acb0x+k*cw,acb0y+l*ch)
- cw = sb.nomCBlkW;
- ch = sb.nomCBlkH;
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- k0 = (int)System.Math.Floor((sb.ulcy - acb0y) / (double)ch);
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- kstart = (int)System.Math.Floor((s0y - acb0y) / (double)ch);
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- kend = (int)System.Math.Floor((s1y - 1 - acb0y) / (double)ch);
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- l0 = (int)System.Math.Floor((sb.ulcx - acb0x) / (double)cw);
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- lstart = (int)System.Math.Floor((s0x - acb0x) / (double)cw);
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- lend = (int)System.Math.Floor((s1x - 1 - acb0x) / (double)cw);
-
- if (s1x - s0x <= 0 || s1y - s0y <= 0)
- {
- ppinfo[c][r][nPrec].nblk[0] = 0;
- ttIncl[c][r][nPrec][0] = new TagTreeDecoder(0, 0);
- ttMaxBP[c][r][nPrec][0] = new TagTreeDecoder(0, 0);
- }
- else
- {
- ttIncl[c][r][nPrec][0] = new TagTreeDecoder(kend - kstart + 1, lend - lstart + 1);
- ttMaxBP[c][r][nPrec][0] = new TagTreeDecoder(kend - kstart + 1, lend - lstart + 1);
- CBlkCoordInfo[][] tmpArray = new CBlkCoordInfo[kend - kstart + 1][];
- for (int i2 = 0; i2 < kend - kstart + 1; i2++)
- {
- tmpArray[i2] = new CBlkCoordInfo[lend - lstart + 1];
- }
- ppinfo[c][r][nPrec].cblk[0] = tmpArray;
- ppinfo[c][r][nPrec].nblk[0] = (kend - kstart + 1) * (lend - lstart + 1);
-
- for (int k = kstart; k <= kend; k++)
- {
- // Vertical cblks
- for (int l = lstart; l <= lend; l++)
- {
- // Horiz. cblks
- cb = new CBlkCoordInfo(k - k0, l - l0);
- if (l == l0)
- {
- cb.ulx = sb.ulx;
- }
- else
- {
- cb.ulx = sb.ulx + l * cw - (sb.ulcx - acb0x);
- }
- if (k == k0)
- {
- cb.uly = sb.uly;
- }
- else
- {
- cb.uly = sb.uly + k * ch - (sb.ulcy - acb0y);
- }
- tmp1 = acb0x + l * cw;
- tmp1 = (tmp1 > sb.ulcx) ? tmp1 : sb.ulcx;
- tmp2 = acb0x + (l + 1) * cw;
- tmp2 = (tmp2 > sb.ulcx + sb.w) ? sb.ulcx + sb.w : tmp2;
- cb.w = tmp2 - tmp1;
- tmp1 = acb0y + k * ch;
- tmp1 = (tmp1 > sb.ulcy) ? tmp1 : sb.ulcy;
- tmp2 = acb0y + (k + 1) * ch;
- tmp2 = (tmp2 > sb.ulcy + sb.h) ? sb.ulcy + sb.h : tmp2;
- cb.h = tmp2 - tmp1;
- ppinfo[c][r][nPrec].cblk[0][k - kstart][l - lstart] = cb;
- } // Horizontal code-blocks
- } // Vertical code-blocks
- }
- }
- else
- {
- // HL, LH and HH subbands
- // HL subband
- acb0x = 0;
- acb0y = cb0y;
-
- p0x = acb0x + j * twoppx2;
- p1x = p0x + twoppx2;
- p0y = acb0y + i * twoppy2;
- p1y = p0y + twoppy2;
-
- sb = (SubbandSyn)root.getSubbandByIdx(r, 1);
- s0x = (p0x < sb.ulcx) ? sb.ulcx : p0x;
- s1x = (p1x > sb.ulcx + sb.w) ? sb.ulcx + sb.w : p1x;
- s0y = (p0y < sb.ulcy) ? sb.ulcy : p0y;
- s1y = (p1y > sb.ulcy + sb.h) ? sb.ulcy + sb.h : p1y;
-
- // Code-blocks are located at (acb0x+k*cw,acb0y+l*ch)
- cw = sb.nomCBlkW;
- ch = sb.nomCBlkH;
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- k0 = (int)System.Math.Floor((sb.ulcy - acb0y) / (double)ch);
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- kstart = (int)System.Math.Floor((s0y - acb0y) / (double)ch);
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- kend = (int)System.Math.Floor((s1y - 1 - acb0y) / (double)ch);
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- l0 = (int)System.Math.Floor((sb.ulcx - acb0x) / (double)cw);
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- lstart = (int)System.Math.Floor((s0x - acb0x) / (double)cw);
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- lend = (int)System.Math.Floor((s1x - 1 - acb0x) / (double)cw);
-
- if (s1x - s0x <= 0 || s1y - s0y <= 0)
- {
- ppinfo[c][r][nPrec].nblk[1] = 0;
- ttIncl[c][r][nPrec][1] = new TagTreeDecoder(0, 0);
- ttMaxBP[c][r][nPrec][1] = new TagTreeDecoder(0, 0);
- }
- else
- {
- ttIncl[c][r][nPrec][1] = new TagTreeDecoder(kend - kstart + 1, lend - lstart + 1);
- ttMaxBP[c][r][nPrec][1] = new TagTreeDecoder(kend - kstart + 1, lend - lstart + 1);
- CBlkCoordInfo[][] tmpArray2 = new CBlkCoordInfo[kend - kstart + 1][];
- for (int i3 = 0; i3 < kend - kstart + 1; i3++)
- {
- tmpArray2[i3] = new CBlkCoordInfo[lend - lstart + 1];
- }
- ppinfo[c][r][nPrec].cblk[1] = tmpArray2;
- ppinfo[c][r][nPrec].nblk[1] = (kend - kstart + 1) * (lend - lstart + 1);
-
- for (int k = kstart; k <= kend; k++)
- {
- // Vertical cblks
- for (int l = lstart; l <= lend; l++)
- {
- // Horiz. cblks
- cb = new CBlkCoordInfo(k - k0, l - l0);
- if (l == l0)
- {
- cb.ulx = sb.ulx;
- }
- else
- {
- cb.ulx = sb.ulx + l * cw - (sb.ulcx - acb0x);
- }
- if (k == k0)
- {
- cb.uly = sb.uly;
- }
- else
- {
- cb.uly = sb.uly + k * ch - (sb.ulcy - acb0y);
- }
- tmp1 = acb0x + l * cw;
- tmp1 = (tmp1 > sb.ulcx) ? tmp1 : sb.ulcx;
- tmp2 = acb0x + (l + 1) * cw;
- tmp2 = (tmp2 > sb.ulcx + sb.w) ? sb.ulcx + sb.w : tmp2;
- cb.w = tmp2 - tmp1;
- tmp1 = acb0y + k * ch;
- tmp1 = (tmp1 > sb.ulcy) ? tmp1 : sb.ulcy;
- tmp2 = acb0y + (k + 1) * ch;
- tmp2 = (tmp2 > sb.ulcy + sb.h) ? sb.ulcy + sb.h : tmp2;
- cb.h = tmp2 - tmp1;
- ppinfo[c][r][nPrec].cblk[1][k - kstart][l - lstart] = cb;
- } // Horizontal code-blocks
- } // Vertical code-blocks
- }
-
- // LH subband
- acb0x = cb0x;
- acb0y = 0;
-
- p0x = acb0x + j * twoppx2;
- p1x = p0x + twoppx2;
- p0y = acb0y + i * twoppy2;
- p1y = p0y + twoppy2;
-
- sb = (SubbandSyn)root.getSubbandByIdx(r, 2);
- s0x = (p0x < sb.ulcx) ? sb.ulcx : p0x;
- s1x = (p1x > sb.ulcx + sb.w) ? sb.ulcx + sb.w : p1x;
- s0y = (p0y < sb.ulcy) ? sb.ulcy : p0y;
- s1y = (p1y > sb.ulcy + sb.h) ? sb.ulcy + sb.h : p1y;
-
- // Code-blocks are located at (acb0x+k*cw,acb0y+l*ch)
- cw = sb.nomCBlkW;
- ch = sb.nomCBlkH;
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- k0 = (int)System.Math.Floor((sb.ulcy - acb0y) / (double)ch);
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- kstart = (int)System.Math.Floor((s0y - acb0y) / (double)ch);
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- kend = (int)System.Math.Floor((s1y - 1 - acb0y) / (double)ch);
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- l0 = (int)System.Math.Floor((sb.ulcx - acb0x) / (double)cw);
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- lstart = (int)System.Math.Floor((s0x - acb0x) / (double)cw);
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- lend = (int)System.Math.Floor((s1x - 1 - acb0x) / (double)cw);
-
- if (s1x - s0x <= 0 || s1y - s0y <= 0)
- {
- ppinfo[c][r][nPrec].nblk[2] = 0;
- ttIncl[c][r][nPrec][2] = new TagTreeDecoder(0, 0);
- ttMaxBP[c][r][nPrec][2] = new TagTreeDecoder(0, 0);
- }
- else
- {
- ttIncl[c][r][nPrec][2] = new TagTreeDecoder(kend - kstart + 1, lend - lstart + 1);
- ttMaxBP[c][r][nPrec][2] = new TagTreeDecoder(kend - kstart + 1, lend - lstart + 1);
- CBlkCoordInfo[][] tmpArray3 = new CBlkCoordInfo[kend - kstart + 1][];
- for (int i4 = 0; i4 < kend - kstart + 1; i4++)
- {
- tmpArray3[i4] = new CBlkCoordInfo[lend - lstart + 1];
- }
- ppinfo[c][r][nPrec].cblk[2] = tmpArray3;
- ppinfo[c][r][nPrec].nblk[2] = (kend - kstart + 1) * (lend - lstart + 1);
-
- for (int k = kstart; k <= kend; k++)
- {
- // Vertical cblks
- for (int l = lstart; l <= lend; l++)
- {
- // Horiz cblks
- cb = new CBlkCoordInfo(k - k0, l - l0);
- if (l == l0)
- {
- cb.ulx = sb.ulx;
- }
- else
- {
- cb.ulx = sb.ulx + l * cw - (sb.ulcx - acb0x);
- }
- if (k == k0)
- {
- cb.uly = sb.uly;
- }
- else
- {
- cb.uly = sb.uly + k * ch - (sb.ulcy - acb0y);
- }
- tmp1 = acb0x + l * cw;
- tmp1 = (tmp1 > sb.ulcx) ? tmp1 : sb.ulcx;
- tmp2 = acb0x + (l + 1) * cw;
- tmp2 = (tmp2 > sb.ulcx + sb.w) ? sb.ulcx + sb.w : tmp2;
- cb.w = tmp2 - tmp1;
- tmp1 = acb0y + k * ch;
- tmp1 = (tmp1 > sb.ulcy) ? tmp1 : sb.ulcy;
- tmp2 = acb0y + (k + 1) * ch;
- tmp2 = (tmp2 > sb.ulcy + sb.h) ? sb.ulcy + sb.h : tmp2;
- cb.h = tmp2 - tmp1;
- ppinfo[c][r][nPrec].cblk[2][k - kstart][l - lstart] = cb;
- } // Horizontal code-blocks
- } // Vertical code-blocks
- }
-
- // HH subband
- acb0x = 0;
- acb0y = 0;
-
- p0x = acb0x + j * twoppx2;
- p1x = p0x + twoppx2;
- p0y = acb0y + i * twoppy2;
- p1y = p0y + twoppy2;
-
- sb = (SubbandSyn)root.getSubbandByIdx(r, 3);
- s0x = (p0x < sb.ulcx) ? sb.ulcx : p0x;
- s1x = (p1x > sb.ulcx + sb.w) ? sb.ulcx + sb.w : p1x;
- s0y = (p0y < sb.ulcy) ? sb.ulcy : p0y;
- s1y = (p1y > sb.ulcy + sb.h) ? sb.ulcy + sb.h : p1y;
-
- // Code-blocks are located at (acb0x+k*cw,acb0y+l*ch)
- cw = sb.nomCBlkW;
- ch = sb.nomCBlkH;
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- k0 = (int)System.Math.Floor((sb.ulcy - acb0y) / (double)ch);
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- kstart = (int)System.Math.Floor((s0y - acb0y) / (double)ch);
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- kend = (int)System.Math.Floor((s1y - 1 - acb0y) / (double)ch);
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- l0 = (int)System.Math.Floor((sb.ulcx - acb0x) / (double)cw);
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- lstart = (int)System.Math.Floor((s0x - acb0x) / (double)cw);
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- lend = (int)System.Math.Floor((s1x - 1 - acb0x) / (double)cw);
-
- if (s1x - s0x <= 0 || s1y - s0y <= 0)
- {
- ppinfo[c][r][nPrec].nblk[3] = 0;
- ttIncl[c][r][nPrec][3] = new TagTreeDecoder(0, 0);
- ttMaxBP[c][r][nPrec][3] = new TagTreeDecoder(0, 0);
- }
- else
- {
- ttIncl[c][r][nPrec][3] = new TagTreeDecoder(kend - kstart + 1, lend - lstart + 1);
- ttMaxBP[c][r][nPrec][3] = new TagTreeDecoder(kend - kstart + 1, lend - lstart + 1);
- CBlkCoordInfo[][] tmpArray4 = new CBlkCoordInfo[kend - kstart + 1][];
- for (int i5 = 0; i5 < kend - kstart + 1; i5++)
- {
- tmpArray4[i5] = new CBlkCoordInfo[lend - lstart + 1];
- }
- ppinfo[c][r][nPrec].cblk[3] = tmpArray4;
- ppinfo[c][r][nPrec].nblk[3] = (kend - kstart + 1) * (lend - lstart + 1);
-
- for (int k = kstart; k <= kend; k++)
- {
- // Vertical cblks
- for (int l = lstart; l <= lend; l++)
- {
- // Horiz cblks
- cb = new CBlkCoordInfo(k - k0, l - l0);
- if (l == l0)
- {
- cb.ulx = sb.ulx;
- }
- else
- {
- cb.ulx = sb.ulx + l * cw - (sb.ulcx - acb0x);
- }
- if (k == k0)
- {
- cb.uly = sb.uly;
- }
- else
- {
- cb.uly = sb.uly + k * ch - (sb.ulcy - acb0y);
- }
- tmp1 = acb0x + l * cw;
- tmp1 = (tmp1 > sb.ulcx) ? tmp1 : sb.ulcx;
- tmp2 = acb0x + (l + 1) * cw;
- tmp2 = (tmp2 > sb.ulcx + sb.w) ? sb.ulcx + sb.w : tmp2;
- cb.w = tmp2 - tmp1;
- tmp1 = acb0y + k * ch;
- tmp1 = (tmp1 > sb.ulcy) ? tmp1 : sb.ulcy;
- tmp2 = acb0y + (k + 1) * ch;
- tmp2 = (tmp2 > sb.ulcy + sb.h) ? sb.ulcy + sb.h : tmp2;
- cb.h = tmp2 - tmp1;
- ppinfo[c][r][nPrec].cblk[3][k - kstart][l - lstart] = cb;
- } // Horizontal code-blocks
- } // Vertical code-blocks
- }
- }
- } // Horizontal precincts
- } // Vertical precincts
- }
-
- /// Gets the number of precincts in a given component and resolution level.
- ///
- ///
- /// Component index
- ///
- ///
- /// Resolution index
- ///
- ///
- public virtual int getNumPrecinct(int c, int r)
- {
- return numPrec[c][r].x * numPrec[c][r].y;
- }
-
- /// Read specified packet head and found length of each code-block's piece
- /// of codewords as well as number of skipped most significant bit-planes.
- ///
- ///
- /// layer index
- ///
- ///
- /// Resolution level index
- ///
- ///
- /// Component index
- ///
- ///
- /// Precinct index
- ///
- ///
- /// CBlkInfo array of relevant component and resolution
- /// level.
- ///
- ///
- /// The number of bytes to read in each tile before reaching
- /// output rate (used by truncation mode)
- ///
- ///
- /// True if specified output rate or EOF is reached.
- ///
- ///
- public virtual bool readPktHead(int l, int r, int c, int p, CBlkInfo[][][] cbI, int[] nb)
- {
-
- CBlkInfo ccb;
- int nSeg; // number of segment to read
- int cbLen; // Length of cblk's code-words
- int ltp; // last truncation point index
- int passtype; // coding pass type
- TagTreeDecoder tdIncl, tdBD;
- int tmp, tmp2, totnewtp, lblockCur, tpidx;
- int sumtotnewtp = 0;
- Coord cbc;
- int startPktHead = ehs.Pos;
- if (startPktHead >= ehs.length())
- {
- // EOF reached at the beginning of this packet head
- return true;
- }
- int tIdx = src.TileIdx;
- PktHeaderBitReader bin;
- int mend, nend;
- int b;
- SubbandSyn sb;
- SubbandSyn root = src.getSynSubbandTree(tIdx, c);
-
- // If packed packet headers was used, use separate stream for reading
- // of packet headers
- if (pph)
- {
- bin = new PktHeaderBitReader(pphbais);
- }
- else
- {
- bin = this.bin;
- }
-
- int mins = (r == 0) ? 0 : 1;
- int maxs = (r == 0) ? 1 : 4;
-
- bool precFound = false;
- for (int s = mins; s < maxs; s++)
- {
- if (p < ppinfo[c][r].Length)
- {
- precFound = true;
- }
- }
- if (!precFound)
- {
- return false;
- }
-
- PrecInfo prec = ppinfo[c][r][p];
-
- // Synchronize for bit reading
- bin.sync();
-
- // If packet is empty there is no info in it (i.e. no code-blocks)
- if (bin.readBit() == 0)
- {
- // No code-block is included
- cblks = new System.Collections.ArrayList[maxs + 1];
- for (int s = mins; s < maxs; s++)
- {
- cblks[s] = System.Collections.ArrayList.Synchronized(new System.Collections.ArrayList(10));
- }
- pktIdx++;
-
- // If truncation mode, checks if output rate is reached
- // unless ncb quit condition is used in which case headers
- // are not counted
- if (isTruncMode && maxCB == -1)
- {
- tmp = ehs.Pos - startPktHead;
- if (tmp > nb[tIdx])
- {
- nb[tIdx] = 0;
- return true;
- }
- else
- {
- nb[tIdx] -= tmp;
- }
- }
-
- // Read EPH marker if needed
- if (ephUsed)
- {
- readEPHMarker(bin);
- }
- return false;
- }
-
- // Packet is not empty => decode info
- // Loop on each subband in this resolution level
- if (cblks == null || cblks.Length < maxs + 1)
- {
- cblks = new System.Collections.ArrayList[maxs + 1];
- }
-
- for (int s = mins; s < maxs; s++)
- {
- if (cblks[s] == null)
- {
- cblks[s] = System.Collections.ArrayList.Synchronized(new System.Collections.ArrayList(10));
- }
- else
- {
- cblks[s].Clear();
- }
- sb = (SubbandSyn)root.getSubbandByIdx(r, s);
- // No code-block in this precinct
- if (prec.nblk[s] == 0)
- {
- // Go to next subband
- continue;
- }
-
- tdIncl = ttIncl[c][r][p][s];
- tdBD = ttMaxBP[c][r][p][s];
-
- mend = (prec.cblk[s] == null) ? 0 : prec.cblk[s].Length;
- for (int m = 0; m < mend; m++)
- {
- // Vertical code-blocks
- nend = (prec.cblk[s][m] == null) ? 0 : prec.cblk[s][m].Length;
- for (int n = 0; n < nend; n++)
- {
- // Horizontal code-blocks
- cbc = prec.cblk[s][m][n].idx;
- b = cbc.x + cbc.y * sb.numCb.x;
-
- ccb = cbI[s][cbc.y][cbc.x];
-
- try
- {
- // If code-block not included in previous layer(s)
- if (ccb == null || ccb.ctp == 0)
- {
- if (ccb == null)
- {
- ccb = cbI[s][cbc.y][cbc.x] = new CBlkInfo(prec.cblk[s][m][n].ulx, prec.cblk[s][m][n].uly, prec.cblk[s][m][n].w, prec.cblk[s][m][n].h, nl);
- }
- ccb.pktIdx[l] = pktIdx;
-
- // Read inclusion using tag-tree
- tmp = tdIncl.update(m, n, l + 1, bin);
- if (tmp > l)
- {
- // Not included
- continue;
- }
-
- // Read bitdepth using tag-tree
- tmp = 1; // initialization
- for (tmp2 = 1; tmp >= tmp2; tmp2++)
- {
- tmp = tdBD.update(m, n, tmp2, bin);
- }
- ccb.msbSkipped = tmp2 - 2;
-
- // New code-block => at least one truncation point
- totnewtp = 1;
- ccb.addNTP(l, 0);
-
- // Check whether ncb quit condition is reached
- ncb++;
-
- if (maxCB != -1 && !ncbQuit && ncb == maxCB)
- {
- // ncb quit contidion reached
- ncbQuit = true;
- tQuit = tIdx;
- cQuit = c;
- sQuit = s;
- rQuit = r;
- xQuit = cbc.x;
- yQuit = cbc.y;
- }
- }
- else
- {
- // If code-block already included in one of
- // the previous layers.
-
- ccb.pktIdx[l] = pktIdx;
-
- // If not inclused
- if (bin.readBit() != 1)
- {
- continue;
- }
-
- // At least 1 more truncation point than
- // prev. packet
- totnewtp = 1;
- }
-
- // Read new truncation points
- if (bin.readBit() == 1)
- {
- // if bit is 1
- totnewtp++;
-
- // if next bit is 0 do nothing
- if (bin.readBit() == 1)
- {
- //if is 1
- totnewtp++;
-
- tmp = bin.readBits(2);
- totnewtp += tmp;
-
- // If next 2 bits are not 11 do nothing
- if (tmp == 0x3)
- {
- //if 11
- tmp = bin.readBits(5);
- totnewtp += tmp;
-
- // If next 5 bits are not 11111 do nothing
- if (tmp == 0x1F)
- {
- //if 11111
- totnewtp += bin.readBits(7);
- }
- }
- }
- }
- ccb.addNTP(l, totnewtp);
- sumtotnewtp += totnewtp;
- cblks[s].Add(prec.cblk[s][m][n]);
-
- // Code-block length
-
- // -- Compute the number of bit to read to obtain
- // code-block length.
- // numBits = betaLamda + log2(totnewtp);
-
- // The length is signalled for each segment in
- // addition to the final one. The total length is the
- // sum of all segment lengths.
-
- // If regular termination in use, then there is one
- // segment per truncation point present. Otherwise, if
- // selective arithmetic bypass coding mode is present,
- // then there is one termination per bypass/MQ and
- // MQ/bypass transition. Otherwise the only
- // termination is at the end of the code-block.
- int options = ((System.Int32)decSpec.ecopts.getTileCompVal(tIdx, c));
-
- if ((options & CSJ2K.j2k.entropy.StdEntropyCoderOptions.OPT_TERM_PASS) != 0)
- {
- // Regular termination in use, one segment per new
- // pass (i.e. truncation point)
- nSeg = totnewtp;
- }
- else if ((options & CSJ2K.j2k.entropy.StdEntropyCoderOptions.OPT_BYPASS) != 0)
- {
- // Selective arithmetic coding bypass coding mode
- // in use, but no regular termination 1 segment up
- // to the end of the last pass of the 4th most
- // significant bit-plane, and, in each following
- // bit-plane, one segment upto the end of the 2nd
- // pass and one upto the end of the 3rd pass.
-
- if (ccb.ctp <= CSJ2K.j2k.entropy.StdEntropyCoderOptions.FIRST_BYPASS_PASS_IDX)
- {
- nSeg = 1;
- }
- else
- {
- nSeg = 1; // One at least for last pass
- // And one for each other terminated pass
- for (tpidx = ccb.ctp - totnewtp; tpidx < ccb.ctp - 1; tpidx++)
- {
- if (tpidx >= CSJ2K.j2k.entropy.StdEntropyCoderOptions.FIRST_BYPASS_PASS_IDX - 1)
- {
- passtype = (tpidx + CSJ2K.j2k.entropy.StdEntropyCoderOptions.NUM_EMPTY_PASSES_IN_MS_BP) % CSJ2K.j2k.entropy.StdEntropyCoderOptions.NUM_PASSES;
- if (passtype == 1 || passtype == 2)
- {
- // bypass coding just before MQ
- // pass or MQ pass just before
- // bypass coding => terminated
- nSeg++;
- }
- }
- }
- }
- }
- else
- {
- // Nothing special in use, just one segment
- nSeg = 1;
- }
-
- // Reads lblock increment (common to all segments)
- while (bin.readBit() != 0)
- {
- lblock[c][r][s][cbc.y][cbc.x]++;
- }
-
- if (nSeg == 1)
- {
- // Only one segment in packet
- cbLen = bin.readBits(lblock[c][r][s][cbc.y][cbc.x] + MathUtil.log2(totnewtp));
- }
- else
- {
- // We must read one length per segment
- ccb.segLen[l] = new int[nSeg];
- cbLen = 0;
- int j;
- if ((options & CSJ2K.j2k.entropy.StdEntropyCoderOptions.OPT_TERM_PASS) != 0)
- {
- // Regular termination: each pass is terminated
- for (tpidx = ccb.ctp - totnewtp, j = 0; tpidx < ccb.ctp; tpidx++, j++)
- {
-
- lblockCur = lblock[c][r][s][cbc.y][cbc.x];
-
- tmp = bin.readBits(lblockCur);
- ccb.segLen[l][j] = tmp;
- cbLen += tmp;
- }
- }
- else
- {
- // Bypass coding: only some passes are
- // terminated
- ltp = ccb.ctp - totnewtp - 1;
- for (tpidx = ccb.ctp - totnewtp, j = 0; tpidx < ccb.ctp - 1; tpidx++)
- {
- if (tpidx >= CSJ2K.j2k.entropy.StdEntropyCoderOptions.FIRST_BYPASS_PASS_IDX - 1)
- {
- passtype = (tpidx + CSJ2K.j2k.entropy.StdEntropyCoderOptions.NUM_EMPTY_PASSES_IN_MS_BP) % CSJ2K.j2k.entropy.StdEntropyCoderOptions.NUM_PASSES;
- if (passtype == 0)
- continue;
-
- lblockCur = lblock[c][r][s][cbc.y][cbc.x];
- tmp = bin.readBits(lblockCur + MathUtil.log2(tpidx - ltp));
- ccb.segLen[l][j] = tmp;
- cbLen += tmp;
- ltp = tpidx;
- j++;
- }
- }
- // Last pass has always the length sent
- lblockCur = lblock[c][r][s][cbc.y][cbc.x];
- tmp = bin.readBits(lblockCur + MathUtil.log2(tpidx - ltp));
- cbLen += tmp;
- ccb.segLen[l][j] = tmp;
- }
- }
- ccb.len[l] = cbLen;
-
- // If truncation mode, checks if output rate is reached
- // unless ncb and lbody quit contitions used.
- if (isTruncMode && maxCB == -1)
- {
- tmp = ehs.Pos - startPktHead;
- if (tmp > nb[tIdx])
- {
- nb[tIdx] = 0;
- // Remove found information in this code-block
- if (l == 0)
- {
- cbI[s][cbc.y][cbc.x] = null;
- }
- else
- {
- ccb.off[l] = ccb.len[l] = 0;
- ccb.ctp -= ccb.ntp[l];
- ccb.ntp[l] = 0;
- ccb.pktIdx[l] = -1;
- }
- return true;
- }
- }
- }
- catch (System.IO.EndOfStreamException)
- {
- // Remove found information in this code-block
- if (l == 0)
- {
- cbI[s][cbc.y][cbc.x] = null;
- }
- else
- {
- ccb.off[l] = ccb.len[l] = 0;
- ccb.ctp -= ccb.ntp[l];
- ccb.ntp[l] = 0;
- ccb.pktIdx[l] = -1;
- }
- // throw new EOFException();
- return true;
- }
- } // End loop on horizontal code-blocks
- } // End loop on vertical code-blocks
- } // End loop on subbands
-
- // Read EPH marker if needed
- if (ephUsed)
- {
- readEPHMarker(bin);
- }
-
- pktIdx++;
-
- // If truncation mode, checks if output rate is reached
- if (isTruncMode && maxCB == -1)
- {
- tmp = ehs.Pos - startPktHead;
- if (tmp > nb[tIdx])
- {
- nb[tIdx] = 0;
- return true;
- }
- else
- {
- nb[tIdx] -= tmp;
- }
- }
- return false;
- }
-
- /// Reads specificied packet body in order to find offset of each
- /// code-block's piece of codeword. This use the list of found code-blocks
- /// in previous red packet head.
- ///
- ///
- /// layer index
- ///
- ///
- /// Resolution level index
- ///
- ///
- /// Component index
- ///
- ///
- /// Precinct index
- ///
- ///
- /// CBlkInfo array of relevant component and resolution
- /// level.
- ///
- ///
- /// The remainding number of bytes to read from the bit stream in
- /// each tile before reaching the decoding rate (in truncation mode)
- ///
- ///
- /// True if decoding rate is reached
- ///
- ///
- public virtual bool readPktBody(int l, int r, int c, int p, CBlkInfo[][][] cbI, int[] nb)
- {
- int curOff = ehs.Pos;
- //Coord curCB;
- CBlkInfo ccb;
- bool stopRead = false;
- int tIdx = src.TileIdx;
- Coord cbc;
-
- bool precFound = false;
- int mins = (r == 0) ? 0 : 1;
- int maxs = (r == 0) ? 1 : 4;
- for (int s = mins; s < maxs; s++)
- {
- if (p < ppinfo[c][r].Length)
- {
- precFound = true;
- }
- }
- if (!precFound)
- {
- return false;
- }
-
- for (int s = mins; s < maxs; s++)
- {
- for (int numCB = 0; numCB < cblks[s].Count; numCB++)
- {
- cbc = ((CBlkCoordInfo)cblks[s][numCB]).idx;
- ccb = cbI[s][cbc.y][cbc.x];
- ccb.off[l] = curOff;
- curOff += ccb.len[l];
- try
- {
- ehs.seek(curOff);
- }
- catch (System.IO.EndOfStreamException)
- {
- if (l == 0)
- {
- cbI[s][cbc.y][cbc.x] = null;
- }
- else
- {
- ccb.off[l] = ccb.len[l] = 0;
- ccb.ctp -= ccb.ntp[l];
- ccb.ntp[l] = 0;
- ccb.pktIdx[l] = -1;
- }
-
- // JH: If we try and seek past the end of the stream just stop the decoding
- curOff = ehs.length() - 1;
- ehs.seek(curOff);
- stopRead = true;
- return true;
- //throw new System.IO.EndOfStreamException();
- }
-
- // If truncation mode
- if (isTruncMode)
- {
- if (stopRead || ccb.len[l] > nb[tIdx])
- {
- // Remove found information in this code-block
- if (l == 0)
- {
- cbI[s][cbc.y][cbc.x] = null;
- }
- else
- {
- ccb.off[l] = ccb.len[l] = 0;
- ccb.ctp -= ccb.ntp[l];
- ccb.ntp[l] = 0;
- ccb.pktIdx[l] = -1;
- }
- stopRead = true;
- }
- if (!stopRead)
- {
- nb[tIdx] -= ccb.len[l];
- }
- }
- // If ncb quit condition reached
- if (ncbQuit && r == rQuit && s == sQuit && cbc.x == xQuit && cbc.y == yQuit && tIdx == tQuit && c == cQuit)
- {
- cbI[s][cbc.y][cbc.x] = null;
- stopRead = true;
- }
- } // Loop on code-blocks
- } // End loop on subbands
-
- // Seek to the end of the packet
- ehs.seek(curOff);
-
- if (stopRead)
- {
- return true;
- }
- else
- {
- return false;
- }
- }
-
-
- /// Returns the precinct partition width for the specified component,
- /// resolution level and tile.
- ///
- ///
- /// the tile index
- ///
- ///
- /// The index of the component (between 0 and C-1)
- ///
- ///
- /// The resolution level, from 0 to L.
- ///
- ///
- /// the precinct partition width for the specified component,
- /// resolution level and tile.
- ///
- ///
- public int getPPX(int t, int c, int r)
- {
- return decSpec.pss.getPPX(t, c, r);
- }
-
- /// Returns the precinct partition height for the specified component,
- /// resolution level and tile.
- ///
- ///
- /// the tile index
- ///
- ///
- /// The index of the component (between 0 and C-1)
- ///
- ///
- /// The resolution level, from 0 to L.
- ///
- ///
- /// the precinct partition height in the specified component, for
- /// the specified resolution level, for the current tile.
- ///
- ///
- public int getPPY(int t, int c, int rl)
- {
- return decSpec.pss.getPPY(t, c, rl);
- }
-
- /// Try to read a SOP marker and check that its sequence number if not out
- /// of sequence. If so, an error is thrown.
- ///
- ///
- /// The number of bytes left to read from each tile
- ///
- ///
- /// Precinct index
- ///
- ///
- /// Resolution level index
- ///
- ///
- /// Component index
- ///
- ///
- public virtual bool readSOPMarker(int[] nBytes, int p, int c, int r)
- {
- int val;
- byte[] sopArray = new byte[6];
- int tIdx = src.TileIdx;
- int mins = (r == 0) ? 0 : 1;
- int maxs = (r == 0) ? 1 : 4;
- bool precFound = false;
- for (int s = mins; s < maxs; s++)
- {
- if (p < ppinfo[c][r].Length)
- {
- precFound = true;
- }
- }
- if (!precFound)
- {
- return false;
- }
-
- // If SOP markers are not used, return
- if (!sopUsed)
- {
- return false;
- }
-
- // Check if SOP is used for this packet
- int pos = ehs.Pos;
- if ((short)((ehs.read() << 8) | ehs.read()) != CSJ2K.j2k.codestream.Markers.SOP)
- {
- ehs.seek(pos);
- return false;
- }
- ehs.seek(pos);
-
- // If length of SOP marker greater than remaining bytes to read for
- // this tile return true
- if (nBytes[tIdx] < 6)
- {
- return true;
- }
- nBytes[tIdx] -= 6;
-
- // Read marker into array 'sopArray'
- ehs.readFully(sopArray, 0, CSJ2K.j2k.codestream.Markers.SOP_LENGTH);
-
- // Check if this is the correct marker
- val = sopArray[0];
- val <<= 8;
- val |= sopArray[1];
- if (val != CSJ2K.j2k.codestream.Markers.SOP)
- {
- throw new System.ApplicationException("Corrupted Bitstream: Could not parse SOP " + "marker !");
- }
-
- // Check if length is correct
- val = (sopArray[2] & 0xff);
- val <<= 8;
- val |= (sopArray[3] & 0xff);
- if (val != 4)
- {
- throw new System.ApplicationException("Corrupted Bitstream: Corrupted SOP marker !");
- }
-
- // Check if sequence number if ok
- val = (sopArray[4] & 0xff);
- val <<= 8;
- val |= (sopArray[5] & 0xff);
-
- if (!pph && val != pktIdx)
- {
- throw new System.ApplicationException("Corrupted Bitstream: SOP marker out of " + "sequence !");
- }
- if (pph && val != pktIdx - 1)
- {
- // if packed packet headers are used, packet header was read
- // before SOP marker segment
- throw new System.ApplicationException("Corrupted Bitstream: SOP marker out of " + "sequence !");
- }
- return false;
- }
-
- /// Try to read an EPH marker. If it is not possible then an Error is
- /// thrown.
- ///
- ///
- /// The packet header reader to read the EPH marker from
- ///
- ///
- public virtual void readEPHMarker(PktHeaderBitReader bin)
- {
- int val;
- byte[] ephArray = new byte[2];
-
- if (bin.usebais)
- {
- bin.bais.Read(ephArray, 0, CSJ2K.j2k.codestream.Markers.EPH_LENGTH);
- }
- else
- {
- bin.in_Renamed.readFully(ephArray, 0, CSJ2K.j2k.codestream.Markers.EPH_LENGTH);
- }
-
- // Check if this is the correct marker
- val = ephArray[0];
- val <<= 8;
- val |= ephArray[1];
- if (val != CSJ2K.j2k.codestream.Markers.EPH)
- {
- throw new System.ApplicationException("Corrupted Bitstream: Could not parse EPH " + "marker ! ");
- }
- }
-
- /// Get PrecInfo instance of the specified resolution level, component and
- /// precinct.
- ///
- ///
- /// Component index.
- ///
- ///
- /// Resolution level index.
- ///
- ///
- /// Precinct index.
- ///
- ///
- public virtual PrecInfo getPrecInfo(int c, int r, int p)
- {
- return ppinfo[c][r][p];
- }
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/codestream/reader/PktHeaderBitReader.cs b/CSJ2K/j2k/codestream/reader/PktHeaderBitReader.cs
deleted file mode 100644
index 31846da8..00000000
--- a/CSJ2K/j2k/codestream/reader/PktHeaderBitReader.cs
+++ /dev/null
@@ -1,288 +0,0 @@
-/*
-* CVS identifier:
-*
-* $Id: PktHeaderBitReader.java,v 1.10 2001/09/14 09:29:45 grosbois Exp $
-*
-* Class: PktHeaderBitReader
-*
-* Description: Bit based reader for packet headers
-*
-*
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-* */
-using CSJ2K.j2k.io;
-namespace CSJ2K.j2k.codestream.reader
-{
-
- /// This class provides a bit based reading facility from a byte based one,
- /// applying the bit unstuffing procedure as required by the packet headers.
- ///
- ///
- //UPGRADE_NOTE: The access modifier for this class or class field has been changed in order to prevent compilation errors due to the visibility level. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1296'"
- public class PktHeaderBitReader
- {
-
- /// The byte based source of data
- internal RandomAccessIO in_Renamed;
-
- /// The byte array that is the source of data if the PktHeaderBitReader
- /// is instantiated with a buffer instead of a RandomAccessIO
- ///
- internal System.IO.MemoryStream bais;
-
- /// Flag indicating whether the data should be read from the buffer
- internal bool usebais;
-
- /// The current bit buffer
- internal int bbuf;
-
- /// The position of the next bit to read in the bit buffer (0 means
- /// empty, 8 full)
- ///
- internal int bpos;
-
- /// The next bit buffer, if bit stuffing occurred (i.e. current bit
- /// buffer holds 0xFF)
- ///
- internal int nextbbuf;
-
- /// Instantiates a 'PktHeaderBitReader' that gets the byte data from the
- /// given source.
- ///
- ///
- /// The source of byte data
- ///
- ///
- internal PktHeaderBitReader(RandomAccessIO in_Renamed)
- {
- this.in_Renamed = in_Renamed;
- usebais = false;
- }
-
- /// Instantiates a 'PktHeaderBitReader' that gets the byte data from the
- /// given source.
- ///
- ///
- /// The source of byte data
- ///
- ///
- internal PktHeaderBitReader(System.IO.MemoryStream bais)
- {
- this.bais = bais;
- usebais = true;
- }
-
- /// Reads a single bit from the input.
- ///
- ///
- /// The read bit (0 or 1)
- ///
- ///
- /// If an I/O error occurred
- ///
- /// If teh end of file has been reached
- ///
- ///
- internal int readBit()
- {
- if (bpos == 0)
- {
- // Is bit buffer empty?
- if (bbuf != 0xFF)
- {
- // No bit stuffing
- if (usebais)
- {
- bbuf = bais.ReadByte();
- }
- else
- {
- bbuf = in_Renamed.read();
- }
- bpos = 8;
- if (bbuf == 0xFF)
- {
- // If new bit stuffing get next byte
- if (usebais)
- {
- nextbbuf = bais.ReadByte();
- }
- else
- {
- nextbbuf = in_Renamed.read();
- }
- }
- }
- else
- {
- // We had bit stuffing, nextbuf can not be 0xFF
- bbuf = nextbbuf;
- bpos = 7;
- }
- }
- return (bbuf >> --bpos) & 0x01;
- }
-
- /// Reads a specified number of bits and returns them in a single
- /// integer. The bits are returned in the 'n' least significant bits of the
- /// returned integer. The maximum number of bits that can be read is 31.
- ///
- ///
- /// The number of bits to read
- ///
- ///
- /// The read bits, packed in the 'n' LSBs.
- ///
- ///
- /// If an I/O error occurred
- ///
- /// If teh end of file has been reached
- ///
- ///
- internal int readBits(int n)
- {
- int bits; // The read bits
-
- // Can we get all bits from the bit buffer?
- if (n <= bpos)
- {
- return (bbuf >> (bpos -= n)) & ((1 << n) - 1);
- }
- else
- {
- // NOTE: The implementation need not be recursive but the not
- // recursive one exploits a bug in the IBM x86 JIT and caused
- // incorrect decoding (Diego Santa Cruz).
- bits = 0;
- do
- {
- // Get all the bits we can from the bit buffer
- bits <<= bpos;
- n -= bpos;
- bits |= readBits(bpos);
- // Get an extra bit to load next byte (here bpos is 0)
- if (bbuf != 0xFF)
- {
- // No bit stuffing
- if (usebais)
- {
- bbuf = bais.ReadByte();
- }
- else
- {
- bbuf = in_Renamed.read();
- }
-
- bpos = 8;
- if (bbuf == 0xFF)
- {
- // If new bit stuffing get next byte
- if (usebais)
- {
- nextbbuf = bais.ReadByte();
- }
- else
- {
- nextbbuf = in_Renamed.read();
- }
- }
- }
- else
- {
- // We had bit stuffing, nextbuf can not be 0xFF
- bbuf = nextbbuf;
- bpos = 7;
- }
- }
- while (n > bpos);
- // Get the last bits, if any
- bits <<= n;
- bits |= (bbuf >> (bpos -= n)) & ((1 << n) - 1);
- // Return result
- return bits;
- }
- }
-
- /// Synchronizes this object with the underlying byte based input. It
- /// discards and buffered bits and gets ready to read bits from the current
- /// position in the underlying byte based input.
- ///
- /// This method should always be called when some data has been read
- /// directly from the underlying byte based input since the last call to
- /// 'readBits()' or 'readBit()' before a new call to any of those
- /// methods.
- ///
- ///
- internal virtual void sync()
- {
- bbuf = 0;
- bpos = 0;
- }
-
- /// Sets the underlying byte based input to the given object. This method
- /// discards any currently buffered bits and gets ready to start reading
- /// bits from 'in'.
- ///
- /// This method is equivalent to creating a new 'PktHeaderBitReader'
- /// object.
- ///
- ///
- /// The source of byte data
- ///
- ///
- internal virtual void setInput(RandomAccessIO in_Renamed)
- {
- this.in_Renamed = in_Renamed;
- bbuf = 0;
- bpos = 0;
- }
-
- /// Sets the underlying byte based input to the given object. This method
- /// discards any currently buffered bits and gets ready to start reading
- /// bits from 'in'.
- ///
- /// This method is equivalent to creating a new 'PktHeaderBitReader'
- /// object.
- ///
- ///
- /// The source of byte data
- ///
- ///
- internal virtual void setInput(System.IO.MemoryStream bais)
- {
- this.bais = bais;
- bbuf = 0;
- bpos = 0;
- }
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/codestream/reader/PktInfo.cs b/CSJ2K/j2k/codestream/reader/PktInfo.cs
deleted file mode 100644
index b717e8f1..00000000
--- a/CSJ2K/j2k/codestream/reader/PktInfo.cs
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
-* CVS identifier:
-*
-* $Id: PktInfo.java,v 1.7 2001/02/14 10:54:49 grosbois Exp $
-*
-* Class: PktInfo
-*
-* Description: Object containing packet informations.
-*
-*
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-* */
-namespace CSJ2K.j2k.codestream.reader
-{
-
- /// This class defines an object used to countain informations about a packet
- /// to which the current code-block belongs.
- ///
- ///
- ///
- ///
- ///
- public class PktInfo
- {
-
- /// Index of the packet
- public int packetIdx;
-
- /// The layer associated with the current code-block in this packet.
- public int layerIdx;
-
- /// The code-block offset in the codestream (for this packet)
- public int cbOff = 0;
-
- /// The length of the code-block in this packet (in bytes)
- public int cbLength;
-
- /// The length of each terminated segment in the packet. The total is the
- /// same as 'cbLength'. It can be null if there is only one terminated
- /// segment, in which case 'cbLength' holds the legth of that segment
- ///
- ///
- public int[] segLengths;
-
- /// The number of truncation points that appear in this packet, and all
- /// previous packets, for this code-block. This is the number of passes
- /// that can be decoded with the information in this packet and all
- /// previous ones.
- ///
- ///
- public int numTruncPnts;
-
- /// Classe's constructor.
- ///
- ///
- /// The layer index for the code-block in this packet
- ///
- ///
- /// The packet index
- ///
- ///
- public PktInfo(int lyIdx, int pckIdx)
- {
- layerIdx = lyIdx;
- packetIdx = pckIdx;
- }
-
- /// Object information in a string.
- ///
- ///
- /// Object information
- ///
- ///
- public override System.String ToString()
- {
- return "packet " + packetIdx + " (lay:" + layerIdx + ", off:" + cbOff + ", len:" + cbLength + ", numTruncPnts:" + numTruncPnts + ")\n";
- }
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/codestream/reader/TagTreeDecoder.cs b/CSJ2K/j2k/codestream/reader/TagTreeDecoder.cs
deleted file mode 100644
index 1260f754..00000000
--- a/CSJ2K/j2k/codestream/reader/TagTreeDecoder.cs
+++ /dev/null
@@ -1,304 +0,0 @@
-/*
-* CVS identifier:
-*
-* $Id: TagTreeDecoder.java,v 1.7 2001/08/23 08:04:48 grosbois Exp $
-*
-* Class: TagTreeDecoder
-*
-* Description: Decoder of tag trees
-*
-*
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-* */
-using CSJ2K.j2k.util;
-namespace CSJ2K.j2k.codestream.reader
-{
-
- /// This class implements the tag tree decoder. A tag tree codes a 2D matrix of
- /// integer elements in an efficient way. The decoding procedure 'update()'
- /// updates a value of the matrix from a stream of coded data, given a
- /// threshold. This procedure decodes enough information to identify whether or
- /// not the value is greater than or equal to the threshold, and updates the
- /// value accordingly.
- ///
- /// In general the decoding procedure must follow the same sequence of
- /// elements and thresholds as the encoding one. The encoder is implemented by
- /// the TagTreeEncoder class.
- ///
- /// Tag trees that have one dimension, or both, as 0 are allowed for
- /// convenience. Of course no values can be set or coded in such cases.
- ///
- ///
- ///
- ///
- ///
- public class TagTreeDecoder
- {
- /// Returns the number of leafs along the horizontal direction.
- ///
- ///
- /// The number of leafs along the horizontal direction.
- ///
- ///
- virtual public int Width
- {
- get
- {
- return w;
- }
-
- }
- /// Returns the number of leafs along the vertical direction.
- ///
- ///
- /// The number of leafs along the vertical direction.
- ///
- ///
- virtual public int Height
- {
- get
- {
- return h;
- }
-
- }
-
- /// The horizontal dimension of the base level
- protected internal int w;
-
- /// The vertical dimensions of the base level
- protected internal int h;
-
- /// The number of levels in the tag tree
- protected internal int lvls;
-
- /// The tag tree values. The first index is the level, starting at level 0
- /// (leafs). The second index is the element within the level, in
- /// lexicographical order.
- ///
- protected internal int[][] treeV;
-
- /// The tag tree state. The first index is the level, starting at level 0
- /// (leafs). The second index is the element within the level, in
- /// lexicographical order.
- ///
- protected internal int[][] treeS;
-
- /// Creates a tag tree decoder with 'w' elements along the horizontal
- /// dimension and 'h' elements along the vertical direction. The total
- /// number of elements is thus 'vdim' x 'hdim'.
- ///
- /// The values of all elements are initialized to Integer.MAX_VALUE
- /// (i.e. no information decoded so far). The states are initialized all to
- /// 0.
- ///
- ///
- /// The number of elements along the vertical direction.
- ///
- ///
- /// The number of elements along the horizontal direction.
- ///
- ///
- public TagTreeDecoder(int h, int w)
- {
- int i;
-
- // Check arguments
- if (w < 0 || h < 0)
- {
- throw new System.ArgumentException();
- }
- // Initialize dimensions
- this.w = w;
- this.h = h;
- // Calculate the number of levels
- if (w == 0 || h == 0)
- {
- lvls = 0; // Empty tree
- }
- else
- {
- lvls = 1;
- while (h != 1 || w != 1)
- {
- // Loop until we reach root
- w = (w + 1) >> 1;
- h = (h + 1) >> 1;
- lvls++;
- }
- }
- // Allocate tree values and states
- treeV = new int[lvls][];
- treeS = new int[lvls][];
- w = this.w;
- h = this.h;
- for (i = 0; i < lvls; i++)
- {
- treeV[i] = new int[h * w];
- // Initialize to infinite value
- ArrayUtil.intArraySet(treeV[i], System.Int32.MaxValue);
-
- // (no need to initialize to 0 since it's the default)
- treeS[i] = new int[h * w];
- w = (w + 1) >> 1;
- h = (h + 1) >> 1;
- }
- }
-
- /// Decodes information for the specified element of the tree, given the
- /// threshold, and updates its value. The information that can be decoded
- /// is whether or not the value of the element is greater than, or equal
- /// to, the value of the threshold.
- ///
- ///
- /// The vertical index of the element.
- ///
- ///
- /// The horizontal index of the element.
- ///
- ///
- /// The threshold to use in decoding. It must be non-negative.
- ///
- ///
- /// The stream from where to read the coded information.
- ///
- ///
- /// The updated value at position (m,n).
- ///
- ///
- /// If an I/O error occurs while reading from 'in'.
- ///
- ///
- /// If the ned of the 'in' stream is reached before
- /// getting all the necessary data.
- ///
- ///
- public virtual int update(int m, int n, int t, PktHeaderBitReader in_Renamed)
- {
- int k, tmin;
- int idx, ts, tv;
-
- // Check arguments
- if (m >= h || n >= w || t < 0)
- {
- throw new System.ArgumentException();
- }
-
- // Initialize
- k = lvls - 1;
- tmin = treeS[k][0];
-
- // Loop on levels
- idx = (m >> k) * ((w + (1 << k) - 1) >> k) + (n >> k);
- while (true)
- {
- // Cache state and value
- ts = treeS[k][idx];
- tv = treeV[k][idx];
- if (ts < tmin)
- {
- ts = tmin;
- }
- while (t > ts)
- {
- if (tv >= ts)
- {
- // We are not done yet
- if (in_Renamed.readBit() == 0)
- {
- // '0' bit
- // We know that 'value' > treeS[k][idx]
- ts++;
- }
- else
- {
- // '1' bit
- // We know that 'value' = treeS[k][idx]
- tv = ts++;
- }
- // Increment of treeS[k][idx] done above
- }
- else
- {
- // We are done, we can set ts and get out
- ts = t;
- break; // get out of this while
- }
- }
- // Update state and value
- treeS[k][idx] = ts;
- treeV[k][idx] = tv;
- // Update tmin or terminate
- if (k > 0)
- {
- tmin = ts < tv ? ts : tv;
- k--;
- // Index of element for next iteration
- idx = (m >> k) * ((w + (1 << k) - 1) >> k) + (n >> k);
- }
- else
- {
- // Return the updated value
- return tv;
- }
- }
- }
-
- /// Returns the current value of the specified element in the tag
- /// tree. This is the value as last updated by the update() method.
- ///
- ///
- /// The vertical index of the element.
- ///
- ///
- /// The horizontal index of the element.
- ///
- ///
- /// The current value of the element.
- ///
- ///
- ///
- ///
- ///
- public virtual int getValue(int m, int n)
- {
- // Check arguments
- if (m >= h || n >= w)
- {
- throw new System.ArgumentException();
- }
- // Return value
- return treeV[0][m * w + n];
- }
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/codestream/writer/BitOutputBuffer.cs b/CSJ2K/j2k/codestream/writer/BitOutputBuffer.cs
deleted file mode 100644
index e3aff569..00000000
--- a/CSJ2K/j2k/codestream/writer/BitOutputBuffer.cs
+++ /dev/null
@@ -1,315 +0,0 @@
-/*
-* CVS identifier:
-*
-* $Id: BitOutputBuffer.java,v 1.9 2002/07/19 12:40:05 grosbois Exp $
-*
-* Class: BitOutputBuffer
-*
-* Description:
-*
-*
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-* */
-using CSJ2K.j2k.util;
-using System;
-namespace CSJ2K.j2k.codestream.writer
-{
-
- /// This class implements a buffer for writing bits, with the required bit
- /// stuffing policy for the packet headers. The bits are stored in a byte array
- /// in the order in which they are written. The byte array is automatically
- /// reallocated and enlarged whenever necessary. A BitOutputBuffer object may
- /// be reused by calling its 'reset()' method.
- ///
- /// NOTE: The methods implemented in this class are intended to be used only
- /// in writing packet heads, since a special bit stuffing procedure is used, as
- /// required for the packet heads.
- ///
- ///
- public class BitOutputBuffer
- {
- /// Returns the current length of the buffer, in bytes.
- ///
- /// This method is declared final to increase performance.
- ///
- ///
- /// The currebt length of the buffer in bytes.
- ///
- ///
- virtual public int Length
- {
- get
- {
- if (avbits == 8)
- {
- // A integral number of bytes
- return curbyte;
- }
- else
- {
- // Some bits in last byte
- return curbyte + 1;
- }
- }
-
- }
- /// Returns the byte buffer. This is the internal byte buffer so it should
- /// not be modified. Only the first N elements have valid data, where N is
- /// the value returned by 'getLength()'
- ///
- /// This method is declared final to increase performance.
- ///
- ///
- /// The internal byte buffer.
- ///
- ///
- virtual public byte[] Buffer
- {
- get
- {
- return buf;
- }
-
- }
-
- /// The buffer where we store the data
- internal byte[] buf;
-
- /// The position of the current byte to write
- internal int curbyte;
-
- /// The number of available bits in the current byte
- internal int avbits = 8;
-
- /// The increment size for the buffer, 16 bytes. This is the
- /// number of bytes that are added to the buffer each time it is
- /// needed to enlarge it.
- ///
- // This must be always 6 or larger.
- public const int SZ_INCR = 16;
-
- /// The initial size for the buffer, 32 bytes.
- public const int SZ_INIT = 32;
-
- /// Creates a new BitOutputBuffer width a buffer of length
- /// 'SZ_INIT'.
- ///
- ///
- public BitOutputBuffer()
- {
- buf = new byte[SZ_INIT];
- }
-
- /// Resets the buffer. This rewinds the current position to the start of
- /// the buffer and sets all tha data to 0. Note that no new buffer is
- /// allocated, so this will affect any data that was returned by the
- /// 'getBuffer()' method.
- ///
- ///
- public virtual void reset()
- {
- //int i;
- // Reinit pointers
- curbyte = 0;
- avbits = 8;
- ArrayUtil.byteArraySet(buf, (byte)0);
- }
-
- /// Writes a bit to the buffer at the current position. The value 'bit'
- /// must be either 0 or 1, otherwise it corrupts the bits that have been
- /// already written. The buffer is enlarged, by 'SZ_INCR' bytes, if
- /// necessary.
- ///
- /// This method is declared final to increase performance.
- ///
- ///
- /// The bit to write, 0 or 1.
- ///
- ///
- public void writeBit(int bit)
- {
- buf[curbyte] |= (byte)(bit << --avbits);
- if (avbits > 0)
- {
- // There is still place in current byte for next bit
- return;
- }
- else
- {
- // End of current byte => goto next
- if (buf[curbyte] != (byte)SupportClass.Identity(0xFF))
- {
- // We don't need bit stuffing
- avbits = 8;
- }
- else
- {
- // We need to stuff a bit (next MSBit is 0)
- avbits = 7;
- }
- curbyte++;
- if (curbyte == buf.Length)
- {
- // We are at end of 'buf' => extend it
- byte[] oldbuf = buf;
- buf = new byte[oldbuf.Length + SZ_INCR];
- Array.Copy(oldbuf, 0, buf, 0, oldbuf.Length);
- }
- }
- }
-
- /// Writes the n least significant bits of 'bits' to the buffer at the
- /// current position. The least significant bit is written last. The 32-n
- /// most significant bits of 'bits' must be 0, otherwise corruption of the
- /// buffer will result. The buffer is enlarged, by 'SZ_INCR' bytes, if
- /// necessary.
- ///
- /// This method is declared final to increase performance.
- ///
- ///
- /// The bits to write.
- ///
- ///
- /// The number of LSBs in 'bits' to write.
- ///
- ///
- public void writeBits(int bits, int n)
- {
- // Check that we have enough place in 'buf' for n bits, and that we do
- // not fill last byte, taking into account possibly stuffed bits (max
- // 2)
- if (((buf.Length - curbyte) << 3) - 8 + avbits <= n + 2)
- {
- // Not enough place, extend it
- byte[] oldbuf = buf;
- buf = new byte[oldbuf.Length + SZ_INCR];
- 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
- }
- // Now write the bits
- if (n >= avbits)
- {
- // Complete the current byte
- n -= avbits;
- buf[curbyte] |= (byte)(bits >> n);
- if (buf[curbyte] != (byte)SupportClass.Identity(0xFF))
- {
- // We don't need bit stuffing
- avbits = 8;
- }
- else
- {
- // We need to stuff a bit (next MSBit is 0)
- avbits = 7;
- }
- curbyte++;
- // Write whole bytes
- while (n >= avbits)
- {
- n -= avbits;
- // CONVERSION PROBLEM?
- buf[curbyte] |= (byte)((bits >> n) & (~(1 << avbits)));
- if (buf[curbyte] != (byte)SupportClass.Identity(0xFF))
- {
- // We don't need bit
- // stuffing
- avbits = 8;
- }
- else
- {
- // We need to stuff a bit (next MSBit is 0)
- avbits = 7;
- }
- curbyte++;
- }
- }
- // Finish last byte (we know that now n < avbits)
- if (n > 0)
- {
- avbits -= n;
- buf[curbyte] |= (byte)((bits & ((1 << n) - 1)) << avbits);
- }
- if (avbits == 0)
- {
- // Last byte is full
- if (buf[curbyte] != (byte)SupportClass.Identity(0xFF))
- {
- // We don't need bit stuffing
- avbits = 8;
- }
- else
- {
- // We need to stuff a bit (next MSBit is 0)
- avbits = 7;
- }
- curbyte++; // We already ensured that we have enough place
- }
- }
-
- /// Returns the byte buffer data in a new array. This is a copy of the
- /// internal byte buffer. If 'data' is non-null it is used to return the
- /// data. This array should be large enough to contain all the data,
- /// otherwise a IndexOutOfBoundsException is thrown by the Java system. The
- /// number of elements returned is what 'getLength()' returns.
- ///
- ///
- /// If non-null this array is used to return the data, which
- /// mus be large enough. Otherwise a new one is created and returned.
- ///
- ///
- /// The byte buffer data.
- ///
- ///
- public virtual byte[] toByteArray(byte[] data)
- {
- if (data == null)
- {
- data = new byte[(avbits == 8) ? curbyte : curbyte + 1];
- }
- Array.Copy(buf, 0, data, 0, (avbits == 8) ? curbyte : curbyte + 1);
- return data;
- }
-
- /// Prints information about this object for debugging purposes
- ///
- ///
- /// Information about the object.
- ///
- ///
- public override System.String ToString()
- {
- return "bits written = " + (curbyte * 8 + (8 - avbits)) + ", curbyte = " + curbyte + ", avbits = " + avbits;
- }
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/codestream/writer/CodestreamWriter.cs b/CSJ2K/j2k/codestream/writer/CodestreamWriter.cs
deleted file mode 100644
index 107ff7d3..00000000
--- a/CSJ2K/j2k/codestream/writer/CodestreamWriter.cs
+++ /dev/null
@@ -1,231 +0,0 @@
-/*
-* CVS identifier:
-*
-* $Id: CodestreamWriter.java,v 1.11 2001/07/24 17:03:30 grosbois Exp $
-*
-* Class: CodestreamWriter
-*
-* Description: Interface for writing bit streams
-*
-*
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-* */
-namespace CSJ2K.j2k.codestream.writer
-{
-
- /// This is the abstract class for writing to a codestream. A codestream
- /// corresponds to headers (main and tile-parts) and packets. Each packet has a
- /// head and a body. The codestream always has a maximum number of bytes that
- /// can be written to it. After that many number of bytes no more data is
- /// written to the codestream but the number of bytes is counted so that the
- /// value returned by getMaxAvailableBytes() is negative. If the number of
- /// bytes is unlimited a ridicoulosly large value, such as Integer.MAX_VALUE,
- /// is equivalent.
- ///
- /// Data writting to the codestream can be simulated. In this case, no byto
- /// is effectively written to the codestream but the resulting number of bytes
- /// is calculated and returned (although it is not accounted in the bit
- /// stream). This can be used in rate control loops.
- ///
- /// Implementing classes should write the header of the bit stream before
- /// writing any packets. The bit stream header can be written with the help of
- /// the HeaderEncoder class.
- ///
- ///
- ///
- ///
- ///
- public abstract class CodestreamWriter
- {
- /// Returns the number of bytes remaining available in the codestream. This
- /// is the maximum allowed number of bytes minus the number of bytes that
- /// have already been written to the bit stream. If more bytes have been
- /// written to the bit stream than the maximum number of allowed bytes,
- /// then a negative value is returned.
- ///
- ///
- /// The number of bytes remaining available in the bit stream.
- ///
- ///
- public abstract int MaxAvailableBytes { get; }
- /// Returns the current length of the entire codestream.
- ///
- ///
- /// the current length of the codestream
- ///
- ///
- public abstract int Length { get; }
- /// Gives the offset of the end of last packet containing ROI information
- ///
- ///
- /// End of last ROI packet
- ///
- ///
- public abstract int OffLastROIPkt { get; }
-
- /// The number of bytes already written to the bit stream
- protected internal int ndata = 0;
-
- /// The maximum number of bytes that can be written to the bit stream
- protected internal int maxBytes;
-
- /// Allocates this object and initializes the maximum number of bytes.
- ///
- ///
- /// The maximum number of bytes that can be written to the
- /// codestream.
- ///
- ///
- protected internal CodestreamWriter(int mb)
- {
- maxBytes = mb;
- }
-
- /// Writes a packet head into the codestream and returns the number of
- /// bytes used by this header. If in simulation mode then no data is
- /// effectively written to the codestream but the number of bytes is
- /// calculated. This can be used for iterative rate allocation.
- ///
- /// If the number of bytes that has to be written to the codestream is
- /// more than the space left (as returned by getMaxAvailableBytes()), only
- /// the data that does not exceed the allowed length is effectively written
- /// and the rest is discarded. However the value returned by the method is
- /// the total length of the packet, as if all of it was written to the bit
- /// stream.
- ///
- /// If the codestream header has not been commited yet and if 'sim' is
- /// false, then the bit stream header is automatically commited (see
- /// commitBitstreamHeader() method) before writting the packet.
- ///
- ///
- /// The packet head data.
- ///
- ///
- /// The number of bytes in the packet head.
- ///
- ///
- /// Simulation mode flag. If true nothing is written to the bit
- /// stream, but the number of bytes that would be written is returned.
- ///
- ///
- /// Start of packet header marker flag. This flag indicates
- /// whether or not SOP markers should be written. If true, SOP markers
- /// should be written, if false, they should not.
- ///
- ///
- /// End of Packet Header marker flag. This flag indicates
- /// whether or not EPH markers should be written. If true, EPH markers
- /// should be written, if false, they should not.
- ///
- ///
- /// The number of bytes spent by the packet head.
- ///
- ///
- /// If an I/O error occurs while writing to the
- /// output stream.
- ///
- ///
- ///
- ///
- ///
- public abstract int writePacketHead(byte[] head, int hlen, bool sim, bool sop, bool eph);
-
- /// Writes a packet body to the codestream and returns the number of bytes
- /// used by this body. If in simulation mode then no data is written to the
- /// bit stream but the number of bytes is calculated. This can be used for
- /// iterative rate allocation.
- ///
- /// If the number of bytes that has to be written to the codestream is
- /// more than the space left (as returned by getMaxAvailableBytes()), only
- /// the data that does not exceed the allowed length is effectively written
- /// and the rest is discarded. However the value returned by the method is
- /// the total length of the packet, as if all of it was written to the bit
- /// stream.
- ///
- ///
- /// The packet body data.
- ///
- ///
- /// The number of bytes in the packet body.
- ///
- ///
- /// Simulation mode flag. If true nothing is written to the bit
- /// stream, but the number of bytes that would be written is returned.
- ///
- ///
- /// Whether or not there is ROI information in this packet
- ///
- ///
- /// Number of byte to read in packet body to get all the ROI
- /// information
- ///
- ///
- /// The number of bytes spent by the packet body.
- ///
- ///
- /// If an I/O error occurs while writing to the
- /// output stream.
- ///
- ///
- ///
- ///
- ///
- public abstract int writePacketBody(byte[] body, int blen, bool sim, bool roiInPkt, int roiLen);
-
-
- /// Closes the underlying resource (file, stream, network connection,
- /// etc.). After a CodestreamWriter is closed no more data can be written
- /// to it.
- ///
- ///
- /// If an I/O error occurs while closing the
- /// resource.
- ///
- ///
- public abstract void close();
-
- /// Writes the header data to the bit stream, if it has not been already
- /// done. In some implementations this method can be called only once, and
- /// an IllegalArgumentException is thrown if called more than once.
- ///
- ///
- /// If an I/O error occurs while writing the data.
- ///
- ///
- /// If this method has already been
- /// called.
- ///
- ///
- public abstract void commitBitstreamHeader(HeaderEncoder he);
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/codestream/writer/FileCodestreamWriter.cs b/CSJ2K/j2k/codestream/writer/FileCodestreamWriter.cs
deleted file mode 100644
index 08834383..00000000
--- a/CSJ2K/j2k/codestream/writer/FileCodestreamWriter.cs
+++ /dev/null
@@ -1,461 +0,0 @@
-/*
-* CVS identifier:
-*
-* $Id: FileCodestreamWriter.java,v 1.15 2001/09/14 09:29:22 grosbois Exp $
-*
-* Class: FileCodestreamWriter
-*
-* Description: Implementation of the bit stream writer for streams.
-*
-*
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-* */
-namespace CSJ2K.j2k.codestream.writer
-{
-
- /// This class implements a CodestreamWriter for Java streams. The streams can
- /// be files or network connections, or any other resource that presents itself
- /// as a OutputStream. See the CodestreamWriter abstract class for more details
- /// on the implementation of the CodestreamWriter abstract class.
- ///
- /// Before any packet data is written to the bit stream (even in simulation
- /// mode) the complete header should be written otherwise incorrect estimates
- /// are given by getMaxAvailableBytes() for rate allocation.
- ///
- ///
- ///
- ///
- ///
- public class FileCodestreamWriter : CodestreamWriter
- {
- /// Returns the number of bytes remaining available in the bit stream. This
- /// is the maximum allowed number of bytes minus the number of bytes that
- /// have already been written to the bit stream. If more bytes have been
- /// written to the bit stream than the maximum number of allowed bytes,
- /// then a negative value is returned.
- ///
- ///
- /// The number of bytes remaining available in the bit stream.
- ///
- ///
- override public int MaxAvailableBytes
- {
- get
- {
- return maxBytes - ndata;
- }
-
- }
- /// Returns the current length of the entire bit stream.
- ///
- ///
- /// the current length of the bit stream
- ///
- ///
- override public int Length
- {
- get
- {
- if (MaxAvailableBytes >= 0)
- {
- return ndata;
- }
- else
- {
- return maxBytes;
- }
- }
-
- }
- /// Gives the offset of the end of last packet containing ROI information
- ///
- ///
- /// End of last ROI packet
- ///
- ///
- override public int OffLastROIPkt
- {
- get
- {
- return offLastROIPkt;
- }
-
- }
-
- /// The upper limit for the value of the Nsop field of the SOP marker
- private const int SOP_MARKER_LIMIT = 65535;
-
- /// Index of the current tile
- //private int tileIdx = 0;
-
- /// The file to write
- private System.IO.Stream out_Renamed;
-
- /// The number of bytes already written to the codestream, excluding the
- /// header length, magic number and header length info.
- ///
- new internal int ndata = 0;
-
- /// The default buffer length, 1024 bytes
- public static int DEF_BUF_LEN = 1024;
-
- /// Array used to store the SOP markers values
- internal byte[] sopMarker;
-
- /// Array used to store the EPH markers values
- internal byte[] ephMarker;
-
- /// The packet index (when start of packet markers i.e. SOP markers) are
- /// used.
- ///
- internal int packetIdx = 0;
-
- /// Offset of end of last packet containing ROI information
- private int offLastROIPkt = 0;
-
- /// Length of last packets containing no ROI information
- private int lenLastNoROI = 0;
-
- /// Opens the file 'file' for writing the codestream. The magic number is
- /// written to the bit stream. Normally, the header encoder must be empty
- /// (i.e. no data has been written to it yet). A BufferedOutputStream is
- /// used on top of the file to increase throughput, the length of the
- /// buffer is DEF_BUF_LEN.
- ///
- ///
- /// The file where to write the bit stream
- ///
- ///
- /// The maximum number of bytes that can be written to the bit
- /// stream.
- ///
- ///
- /// If an error occurs while trying to open the file
- /// for writing or while writing the magic number.
- ///
- ///
- public FileCodestreamWriter(System.IO.FileInfo file, int mb) : base(mb)
- {
- //UPGRADE_TODO: Constructor 'java.io.FileOutputStream.FileOutputStream' was converted to 'System.IO.FileStream.FileStream' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaioFileOutputStreamFileOutputStream_javaioFile'"
- out_Renamed = new System.IO.BufferedStream(new System.IO.FileStream(file.FullName, System.IO.FileMode.Create), DEF_BUF_LEN);
- initSOP_EPHArrays();
- }
-
- /// Opens the file named 'fname' for writing the bit stream, using the 'he'
- /// header encoder. The magic number is written to the bit
- /// stream. Normally, the header encoder must be empty (i.e. no data has
- /// been written to it yet). A BufferedOutputStream is used on top of the
- /// file to increase throughput, the length of the buffer is DEF_BUF_LEN.
- ///
- ///
- /// The name of file where to write the bit stream
- ///
- ///
- /// The maximum number of bytes that can be written to the bit
- /// stream.
- ///
- ///
- /// The encoder's specifications
- ///
- ///
- /// If an error occurs while trying to open the file
- /// for writing or while writing the magic number.
- ///
- ///
- public FileCodestreamWriter(System.String fname, int mb) : base(mb)
- {
- //UPGRADE_TODO: Constructor 'java.io.FileOutputStream.FileOutputStream' was converted to 'System.IO.FileStream.FileStream' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaioFileOutputStreamFileOutputStream_javalangString'"
- out_Renamed = new System.IO.BufferedStream(new System.IO.FileStream(fname, System.IO.FileMode.Create), DEF_BUF_LEN);
- initSOP_EPHArrays();
- }
-
- /// Uses the output stream 'os' for writing the bit stream, using the 'he'
- /// header encoder. The magic number is written to the bit
- /// stream. Normally, the header encoder must be empty (i.e. no data has
- /// been written to it yet). No BufferedOutputStream is used on top of the
- /// output stream 'os'.
- ///
- ///
- /// The output stream where to write the bit stream.
- ///
- ///
- /// The maximum number of bytes that can be written to the bit
- /// stream.
- ///
- ///
- /// If an error occurs while writing the magic
- /// number to the 'os' output stream.
- ///
- ///
- public FileCodestreamWriter(System.IO.Stream os, int mb) : base(mb)
- {
- out_Renamed = os;
- initSOP_EPHArrays();
- }
-
- /// Writes a packet head to the bit stream and returns the number of bytes
- /// used by this header. It returns the total number of bytes that the
- /// packet head takes in the bit stream. If in simulation mode then no data
- /// is written to the bit stream but the number of bytes is
- /// calculated. This can be used for iterative rate allocation.
- ///
- /// If the length of the data that is to be written to the bit stream is
- /// more than the space left (as returned by getMaxAvailableBytes()) only
- /// the data that does not exceed the allowed length is written, the rest
- /// is discarded. However the value returned by the method is the total
- /// length of the packet, as if all of it was written to the bit stream.
- ///
- ///
If the bit stream header has not been commited yet and 'sim' is
- /// false, then the bit stream header is automatically commited (see
- /// commitBitstreamHeader() method) before writting the packet.
- ///
- ///
- /// The packet head data.
- ///
- ///
- /// The number of bytes in the packet head.
- ///
- ///
- /// Simulation mode flag. If true nothing is written to the bit
- /// stream, but the number of bytes that would be written is returned.
- ///
- ///
- /// Start of packet header marker flag. This flag indicates
- /// whether or not SOP markers should be written. If true, SOP markers
- /// should be written, if false, they should not.
- ///
- ///
- /// End of Packet Header marker flag. This flag indicates
- /// whether or not EPH markers should be written. If true, EPH markers
- /// should be written, if false, they should not.
- ///
- ///
- /// The number of bytes spent by the packet head.
- ///
- ///
- /// If an I/O error occurs while writing to the
- /// output stream.
- ///
- ///
- ///
- ///
- ///
- public override int writePacketHead(byte[] head, int hlen, bool sim, bool sop, bool eph)
- {
- // CONVERSION PROBLEM?
- int len = hlen + (sop ? (int)CSJ2K.j2k.codestream.Markers.SOP_LENGTH : 0) + (eph ? (int)CSJ2K.j2k.codestream.Markers.EPH_LENGTH : 0);
-
- // If not in simulation mode write the data
- if (!sim)
- {
- // Write the head bytes
- if (MaxAvailableBytes < len)
- {
- len = MaxAvailableBytes;
- }
-
- if (len > 0)
- {
- // Write Start Of Packet header markers if necessary
- if (sop)
- {
- // The first 4 bytes of the array have been filled in the
- // classe's constructor.
- sopMarker[4] = (byte)(packetIdx >> 8);
- sopMarker[5] = (byte)(packetIdx);
- out_Renamed.Write(sopMarker, 0, CSJ2K.j2k.codestream.Markers.SOP_LENGTH);
- packetIdx++;
- if (packetIdx > SOP_MARKER_LIMIT)
- {
- // Reset SOP value as we have reached its upper limit
- packetIdx = 0;
- }
- }
- out_Renamed.Write(head, 0, hlen);
- // Update data length
- ndata += len;
-
- // Write End of Packet Header markers if necessary
- if (eph)
- {
- out_Renamed.Write(ephMarker, 0, CSJ2K.j2k.codestream.Markers.EPH_LENGTH);
- }
-
- // Deal with ROI Information
- lenLastNoROI += len;
- }
- }
- return len;
- }
-
- /// Writes a packet body to the bit stream and returns the number of bytes
- /// used by this body .If in simulation mode then no data is written to the
- /// bit stream but the number of bytes is calculated. This can be used for
- /// iterative rate allocation.
- ///
- /// If the length of the data that is to be written to the bit stream is
- /// more than the space left (as returned by getMaxAvailableBytes()) only
- /// the data that does not exceed the allowed length is written, the rest
- /// is discarded. However the value returned by the method is the total
- /// length of the packet body , as if all of it was written to the bit
- /// stream.
- ///
- ///
- /// The packet body data.
- ///
- ///
- /// The number of bytes in the packet body.
- ///
- ///
- /// Simulation mode flag. If true nothing is written to the bit
- /// stream, but the number of bytes that would be written is returned.
- ///
- ///
- /// Whether or not this packet contains ROI information
- ///
- ///
- /// Number of byte to read in packet body to get all the ROI
- /// information
- ///
- ///
- /// The number of bytes spent by the packet body.
- ///
- ///
- /// If an I/O error occurs while writing to the
- /// output stream.
- ///
- ///
- ///
- ///
- ///
- public override int writePacketBody(byte[] body, int blen, bool sim, bool roiInPkt, int roiLen)
- {
-
- int len = blen;
-
- // If not in simulation mode write the data
- if (!sim)
- {
- // Write the body bytes
- len = blen;
- if (MaxAvailableBytes < len)
- {
- len = MaxAvailableBytes;
- }
- if (blen > 0)
- {
- out_Renamed.Write(body, 0, len);
- }
- // Update data length
- ndata += len;
-
- // Deal with ROI information
- if (roiInPkt)
- {
- offLastROIPkt += lenLastNoROI + roiLen;
- lenLastNoROI = len - roiLen;
- }
- else
- {
- lenLastNoROI += len;
- }
- }
- return len;
- }
-
- /// Writes the EOC marker and closes the underlying stream.
- ///
- ///
- /// If an error occurs while closing the underlying
- /// stream.
- ///
- ///
- public override void close()
- {
-
- // Write the EOC marker and close the codestream.
- // CONVERSION PROBLEM?
- out_Renamed.WriteByte((byte)SupportClass.URShift(CSJ2K.j2k.codestream.Markers.EOC, 8));
- out_Renamed.WriteByte((byte)(CSJ2K.j2k.codestream.Markers.EOC & 0x00FF));
-
- ndata += 2; // Add two to length of codestream for EOC marker
-
- out_Renamed.Close();
- }
-
- /// Writes the header data in the codestream and actualize ndata with the
- /// header length. The header is either a MainHeaderEncoder or a
- /// TileHeaderEncoder.
- ///
- ///
- /// The current header encoder.
- ///
- ///
- /// If an I/O error occurs while writing the data.
- ///
- ///
- public override void commitBitstreamHeader(HeaderEncoder he)
- {
- // Actualize ndata
- ndata += he.Length;
- he.writeTo(out_Renamed); // Write the header
- // Reset packet index used for SOP markers
- packetIdx = 0;
-
- // Deal with ROI information
- lenLastNoROI += he.Length;
- }
-
- /// Performs the initialisation of the arrays that are used to store the
- /// values used to write SOP and EPH markers
- ///
- ///
- private void initSOP_EPHArrays()
- {
-
- // Allocate and set first values of SOP marker as they will not be
- // modified
- sopMarker = new byte[CSJ2K.j2k.codestream.Markers.SOP_LENGTH];
- sopMarker[0] = unchecked((byte)(CSJ2K.j2k.codestream.Markers.SOP >> 8));
- sopMarker[1] = (byte)SupportClass.Identity(CSJ2K.j2k.codestream.Markers.SOP);
- sopMarker[2] = (byte)0x00;
- sopMarker[3] = (byte)0x04;
-
- // Allocate and set values of EPH marker as they will not be
- // modified
- ephMarker = new byte[CSJ2K.j2k.codestream.Markers.EPH_LENGTH];
- ephMarker[0] = unchecked((byte)(CSJ2K.j2k.codestream.Markers.EPH >> 8));
- ephMarker[1] = (byte)SupportClass.Identity(CSJ2K.j2k.codestream.Markers.EPH);
- }
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/codestream/writer/HeaderEncoder.cs b/CSJ2K/j2k/codestream/writer/HeaderEncoder.cs
deleted file mode 100644
index e6cc5267..00000000
--- a/CSJ2K/j2k/codestream/writer/HeaderEncoder.cs
+++ /dev/null
@@ -1,2074 +0,0 @@
-/*
-* CVS identifier:
-*
-* $Id: HeaderEncoder.java,v 1.43 2001/10/12 09:02:14 grosbois Exp $
-*
-* Class: HeaderEncoder
-*
-* Description: Write codestream headers.
-*
-*
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-* */
-using CSJ2K.j2k.encoder;
-using CSJ2K.j2k.entropy;
-using CSJ2K.j2k.entropy.encoder;
-using CSJ2K.j2k.image;
-using CSJ2K.j2k.io;
-using CSJ2K.j2k.quantization.quantizer;
-using CSJ2K.j2k.roi.encoder;
-using CSJ2K.j2k.util;
-using CSJ2K.j2k.wavelet.analysis;
-namespace CSJ2K.j2k.codestream.writer
-{
-
- /// This class writes almost of the markers and marker segments in main header
- /// and in tile-part headers. It is created by the run() method of the Encoder
- /// instance.
- ///
- /// A marker segment includes a marker and eventually marker segment
- /// parameters. It is designed by the three letter code of the marker
- /// associated with the marker segment. JPEG 2000 part I defines 6 types of
- /// markers:
- ///
- /// - Delimiting : SOC,SOT,SOD,EOC (written in FileCodestreamWriter).
- /// - Fixed information: SIZ.
- /// - Functional: COD,COC,RGN,QCD,QCC,POC.
- /// - In bit-stream: SOP,EPH.
- /// - Pointer: TLM,PLM,PLT,PPM,PPT.
- /// - Informational: CRG,COM.
- ///
- ///
- /// Main Header is written when Encoder instance calls encodeMainHeader
- /// whereas tile-part headers are written when the EBCOTRateAllocator instance
- /// calls encodeTilePartHeader.
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- public class HeaderEncoder
- {
- /// Returns the parameters that are used in this class and implementing
- /// classes. It returns a 2D String array. Each of the 1D arrays is for a
- /// different option, and they have 3 elements. The first element is the
- /// option name, the second one is the synopsis, the third one is a long
- /// description of what the parameter is and the fourth is its default
- /// value. The synopsis or description may be 'null', in which case it is
- /// assumed that there is no synopsis or description of the option,
- /// respectively. Null may be returned if no options are supported.
- ///
- ///
- /// the options name, their synopsis and their explanation, or null
- /// if no options are supported.
- ///
- ///
- public static System.String[][] ParameterInfo
- {
- get
- {
- return pinfo;
- }
-
- }
- /// Returns the byte-buffer used to store the codestream header.
- ///
- ///
- /// A byte array countaining codestream header
- ///
- ///
- virtual protected internal byte[] Buffer
- {
- get
- {
- return baos.ToArray();
- }
-
- }
- /// Returns the length of the header.
- ///
- ///
- /// The length of the header in bytes
- ///
- ///
- virtual public int Length
- {
- get
- {
- return (int)hbuf.BaseStream.Length;
- }
-
- }
- /// Returns the number of bytes used in the codestream header's buffer.
- ///
- ///
- /// Header length in buffer (without any header overhead)
- ///
- ///
- virtual protected internal int BufferLength
- {
- get
- {
- return (int)baos.Length;
- }
-
- }
-
- /// The prefix for the header encoder options: 'H'
- public const char OPT_PREFIX = 'H';
-
- /// The list of parameters that are accepted for the header encoder
- /// module. Options for this modules start with 'H'.
- ///
- //UPGRADE_NOTE: Final was removed from the declaration of 'pinfo'. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- private static readonly System.String[][] pinfo = new System.String[][] { new System.String[] { "Hjj2000_COM", null, "Writes or not the JJ2000 COM marker in the " + "codestream", "off" }, new System.String[] { "HCOM", "[#[#]]", "Adds COM marker segments in the codestream. Comments must be " + "separated with '#' and are written into distinct maker segments.", null } };
-
- /// Nominal range bit of the component defining default values in QCD for
- /// main header
- ///
- private int defimgn;
-
- /// Nominal range bit of the component defining default values in QCD for
- /// tile headers
- ///
- private int deftilenr;
-
- /// The number of components in the image
- private int nComp;
-
- /// Whether or not to write the JJ2000 COM marker segment
- private bool enJJ2KMarkSeg = true;
-
- /// Other COM marker segments specified in the command line
- private System.String otherCOMMarkSeg = null;
-
- /// The ByteArrayOutputStream to store header data. This handler is kept
- /// in order to use methods not accessible from a general
- /// DataOutputStream. For the other methods, it's better to use variable
- /// hbuf.
- ///
- ///
- ///
- ///
- protected internal System.IO.MemoryStream baos;
-
- /// The DataOutputStream to store header data. This kind of object is
- /// useful to write short, int, .... It's constructor takes baos as
- /// parameter.
- ///
- ///
- ///
- ///
- ///
- //UPGRADE_TODO: Class 'java.io.DataOutputStream' was converted to 'System.IO.BinaryWriter' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaioDataOutputStream'"
- protected internal System.IO.BinaryWriter hbuf;
-
- /// The image data reader. Source of original data info
- protected internal ImgData origSrc;
-
- /// An array specifying, for each component,if the data was signed or not
- ///
- ///
- protected internal bool[] isOrigSig;
-
- /// Reference to the rate allocator
- protected internal PostCompRateAllocator ralloc;
-
- /// Reference to the DWT module
- protected internal ForwardWT dwt;
-
- /// Reference to the tiler module
- protected internal Tiler tiler;
-
- /// Reference to the ROI module
- protected internal ROIScaler roiSc;
-
- /// The encoder specifications
- protected internal EncoderSpecs encSpec;
-
- /// Initializes the header writer with the references to the coding chain.
- ///
- ///
- /// The original image data (before any component mixing,
- /// tiling, etc.)
- ///
- ///
- /// An array specifying for each component if it was
- /// originally signed or not.
- ///
- ///
- /// The discrete wavelet transform module.
- ///
- ///
- /// The tiler module.
- ///
- ///
- /// The encoder specifications
- ///
- ///
- /// The ROI scaler module.
- ///
- ///
- /// The post compression rate allocator.
- ///
- ///
- /// ParameterList instance.
- ///
- ///
- public HeaderEncoder(ImgData origsrc, bool[] isorigsig, ForwardWT dwt, Tiler tiler, EncoderSpecs encSpec, ROIScaler roiSc, PostCompRateAllocator ralloc, ParameterList pl)
- {
- pl.checkList(OPT_PREFIX, CSJ2K.j2k.util.ParameterList.toNameArray(pinfo));
- if (origsrc.NumComps != isorigsig.Length)
- {
- throw new System.ArgumentException();
- }
- this.origSrc = origsrc;
- this.isOrigSig = isorigsig;
- this.dwt = dwt;
- this.tiler = tiler;
- this.encSpec = encSpec;
- this.roiSc = roiSc;
- this.ralloc = ralloc;
-
- baos = new System.IO.MemoryStream();
- //UPGRADE_TODO: Class 'java.io.DataOutputStream' was converted to 'System.IO.BinaryWriter' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaioDataOutputStream'"
- hbuf = new CSJ2K.Util.EndianBinaryWriter(baos, true);
- nComp = origsrc.NumComps;
- enJJ2KMarkSeg = pl.getBooleanParameter("Hjj2000_COM");
- otherCOMMarkSeg = pl.getParameter("HCOM");
- }
-
- /// Resets the contents of this HeaderEncoder to its initial state. It
- /// erases all the data in the header buffer and reactualizes the
- /// headerLength field of the bit stream writer.
- ///
- ///
- public virtual void reset()
- {
- //UPGRADE_ISSUE: Method 'java.io.ByteArrayOutputStream.reset' was not converted. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1000_javaioByteArrayOutputStreamreset'"
- // CONVERSION PROBLEM?
- //baos.reset();
- baos.SetLength(0);
- //UPGRADE_TODO: Class 'java.io.DataOutputStream' was converted to 'System.IO.BinaryWriter' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaioDataOutputStream'"
- hbuf = new CSJ2K.Util.EndianBinaryWriter(baos, true); //new System.IO.BinaryWriter(baos);
- }
-
- /// Writes the header to the specified BinaryDataOutput.
- ///
- ///
- /// Where to write the header.
- ///
- ///
- public virtual void writeTo(BinaryDataOutput out_Renamed)
- {
- int i, len;
- byte[] buf;
-
- buf = Buffer;
- len = Length;
-
- for (i = 0; i < len; i++)
- {
- out_Renamed.writeByte(buf[i]);
- }
- }
-
- /// Writes the header to the specified OutputStream.
- ///
- ///
- /// Where to write the header.
- ///
- ///
- public virtual void writeTo(System.IO.Stream out_Renamed)
- {
- out_Renamed.Write(Buffer, 0, BufferLength);
- }
-
- /// Start Of Codestream marker (SOC) signalling the beginning of a
- /// codestream.
- ///
- ///
- private void writeSOC()
- {
- hbuf.Write((System.Int16)CSJ2K.j2k.codestream.Markers.SOC);
- }
-
- /// Writes SIZ marker segment of the codestream header. It is a fixed
- /// information marker segment containing informations about image and tile
- /// sizes. It is required in the main header immediately after SOC marker
- /// segment.
- ///
- ///
- private void writeSIZ()
- {
- int tmp;
-
- // SIZ marker
- hbuf.Write((System.Int16)CSJ2K.j2k.codestream.Markers.SIZ);
-
- // Lsiz (Marker length) corresponding to
- // Lsiz(2 bytes)+Rsiz(2)+Xsiz(4)+Ysiz(4)+XOsiz(4)+YOsiz(4)+
- // XTsiz(4)+YTsiz(4)+XTOsiz(4)+YTOsiz(4)+Csiz(2)+
- // (Ssiz(1)+XRsiz(1)+YRsiz(1))*nComp
- // markSegLen = 38 + 3*nComp;
- int markSegLen = 38 + 3 * nComp;
- hbuf.Write((System.Int16)markSegLen);
-
- // Rsiz (codestream capabilities)
- hbuf.Write((System.Int16)0); // JPEG 2000 - Part I
-
- // Xsiz (original image width)
- hbuf.Write(tiler.ImgWidth + tiler.ImgULX);
-
- // Ysiz (original image height)
- hbuf.Write(tiler.ImgHeight + tiler.ImgULY);
-
- // XOsiz (horizontal offset from the origin of the reference
- // grid to the left side of the image area)
- hbuf.Write(tiler.ImgULX);
-
- // YOsiz (vertical offset from the origin of the reference
- // grid to the top side of the image area)
- hbuf.Write(tiler.ImgULY);
-
- // XTsiz (nominal tile width)
- hbuf.Write(tiler.NomTileWidth);
-
- // YTsiz (nominal tile height)
- hbuf.Write(tiler.NomTileHeight);
-
- Coord torig = tiler.getTilingOrigin(null);
- // XTOsiz (Horizontal offset from the origin of the reference
- // grid to the left side of the first tile)
- hbuf.Write(torig.x);
-
- // YTOsiz (Vertical offset from the origin of the reference
- // grid to the top side of the first tile)
- hbuf.Write(torig.y);
-
- // Csiz (number of components)
- hbuf.Write((System.Int16)nComp);
-
- // Bit-depth and downsampling factors.
- for (int c = 0; c < nComp; c++)
- {
- // Loop on each component
-
- // Ssiz bit-depth before mixing
- tmp = origSrc.getNomRangeBits(c) - 1;
-
- tmp |= ((isOrigSig[c] ? 1 : 0) << CSJ2K.j2k.codestream.Markers.SSIZ_DEPTH_BITS);
- hbuf.Write((System.Byte)tmp);
-
- // XRsiz (component sub-sampling value x-wise)
- hbuf.Write((System.Byte)tiler.getCompSubsX(c));
-
- // YRsiz (component sub-sampling value y-wise)
- hbuf.Write((System.Byte)tiler.getCompSubsY(c));
- } // End loop on each component
- }
-
- /// Writes COD marker segment. COD is a functional marker segment
- /// containing the code style default (coding style, decomposition,
- /// layering) used for compressing all the components in an image.
- ///
- /// The values can be overriden for an individual component by a COC
- /// marker in either the main or the tile header.
- ///
- ///
- /// Flag indicating whether this marker belongs to the main
- /// header
- ///
- ///
- /// Tile index if the marker belongs to a tile-part header
- ///
- ///
- ///
- ///
- ///
- protected internal virtual void writeCOD(bool mh, int tileIdx)
- {
- AnWTFilter[][] filt;
- bool precinctPartitionUsed;
- int tmp;
- int mrl = 0, a = 0;
- int ppx = 0, ppy = 0;
- Progression[] prog;
-
- if (mh)
- {
- mrl = ((System.Int32)encSpec.dls.getDefault());
- // get default precinct size
- ppx = encSpec.pss.getPPX(-1, -1, mrl);
- ppy = encSpec.pss.getPPY(-1, -1, mrl);
- prog = (Progression[])(encSpec.pocs.getDefault());
- }
- else
- {
- mrl = ((System.Int32)encSpec.dls.getTileDef(tileIdx));
- // get precinct size for specified tile
- ppx = encSpec.pss.getPPX(tileIdx, -1, mrl);
- ppy = encSpec.pss.getPPY(tileIdx, -1, mrl);
- prog = (Progression[])(encSpec.pocs.getTileDef(tileIdx));
- }
-
- if (ppx != CSJ2K.j2k.codestream.Markers.PRECINCT_PARTITION_DEF_SIZE || ppy != CSJ2K.j2k.codestream.Markers.PRECINCT_PARTITION_DEF_SIZE)
- {
- precinctPartitionUsed = true;
- }
- else
- {
- precinctPartitionUsed = false;
- }
-
- if (precinctPartitionUsed)
- {
- // If precinct partition is used we add one byte per resolution
- // level i.e. mrl+1 (+1 for resolution 0).
- a = mrl + 1;
- }
-
- // Write COD marker
- hbuf.Write((System.Int16)CSJ2K.j2k.codestream.Markers.COD);
-
- // Lcod (marker segment length (in bytes)) Basic : Lcod(2
- // bytes)+Scod(1)+SGcod(4)+SPcod(5+a) where:
- // a=0 if no precinct partition is used
- // a=mrl+1 if precinct partition used
- int markSegLen = 12 + a;
- hbuf.Write((System.Int16)markSegLen);
-
- // Scod (coding style parameter)
- tmp = 0;
- if (precinctPartitionUsed)
- {
- tmp = CSJ2K.j2k.codestream.Markers.SCOX_PRECINCT_PARTITION;
- }
-
- // Are SOP markers used ?
- if (mh)
- {
- //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Object.toString' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'"
- if (((System.String)encSpec.sops.getDefault().ToString()).ToUpper().Equals("on".ToUpper()))
- {
- tmp |= CSJ2K.j2k.codestream.Markers.SCOX_USE_SOP;
- }
- }
- else
- {
- //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Object.toString' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'"
- if (((System.String)encSpec.sops.getTileDef(tileIdx).ToString()).ToUpper().Equals("on".ToUpper()))
- {
- tmp |= CSJ2K.j2k.codestream.Markers.SCOX_USE_SOP;
- }
- }
-
- // Are EPH markers used ?
- if (mh)
- {
- //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Object.toString' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'"
- if (((System.String)encSpec.ephs.getDefault().ToString()).ToUpper().Equals("on".ToUpper()))
- {
- tmp |= CSJ2K.j2k.codestream.Markers.SCOX_USE_EPH;
- }
- }
- else
- {
- //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Object.toString' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'"
- if (((System.String)encSpec.ephs.getTileDef(tileIdx).ToString()).ToUpper().Equals("on".ToUpper()))
- {
- tmp |= CSJ2K.j2k.codestream.Markers.SCOX_USE_EPH;
- }
- }
- if (dwt.CbULX != 0)
- tmp |= CSJ2K.j2k.codestream.Markers.SCOX_HOR_CB_PART;
- if (dwt.CbULY != 0)
- tmp |= CSJ2K.j2k.codestream.Markers.SCOX_VER_CB_PART;
- hbuf.Write((System.Byte)tmp);
-
- // SGcod
- // Progression order
- hbuf.Write((System.Byte)prog[0].type);
-
- // Number of layers
- hbuf.Write((System.Int16)ralloc.NumLayers);
-
- // Multiple component transform
- // CSsiz (Color transform)
- System.String str = null;
- if (mh)
- {
- str = ((System.String)encSpec.cts.getDefault());
- }
- else
- {
- str = ((System.String)encSpec.cts.getTileDef(tileIdx));
- }
-
- if (str.Equals("none"))
- {
- hbuf.Write((System.Byte)0);
- }
- else
- {
- hbuf.Write((System.Byte)1);
- }
-
- // SPcod
- // Number of decomposition levels
- hbuf.Write((System.Byte)mrl);
-
- // Code-block width and height
- if (mh)
- {
- // main header, get default values
- tmp = encSpec.cblks.getCBlkWidth(ModuleSpec.SPEC_DEF, -1, -1);
- hbuf.Write((System.Byte)(MathUtil.log2(tmp) - 2));
- tmp = encSpec.cblks.getCBlkHeight(ModuleSpec.SPEC_DEF, -1, -1);
- hbuf.Write((System.Byte)(MathUtil.log2(tmp) - 2));
- }
- else
- {
- // tile header, get tile default values
- tmp = encSpec.cblks.getCBlkWidth(ModuleSpec.SPEC_TILE_DEF, tileIdx, -1);
- hbuf.Write((System.Byte)(MathUtil.log2(tmp) - 2));
- tmp = encSpec.cblks.getCBlkHeight(ModuleSpec.SPEC_TILE_DEF, tileIdx, -1);
- hbuf.Write((System.Byte)(MathUtil.log2(tmp) - 2));
- }
-
- // Style of the code-block coding passes
- tmp = 0;
- if (mh)
- {
- // Main header
- // Selective arithmetic coding bypass ?
- if (((System.String)encSpec.bms.getDefault()).Equals("on"))
- {
- tmp |= CSJ2K.j2k.entropy.StdEntropyCoderOptions.OPT_BYPASS;
- }
- // MQ reset after each coding pass ?
- if (((System.String)encSpec.mqrs.getDefault()).Equals("on"))
- {
- tmp |= CSJ2K.j2k.entropy.StdEntropyCoderOptions.OPT_RESET_MQ;
- }
- // MQ termination after each arithmetically coded coding pass ?
- if (((System.String)encSpec.rts.getDefault()).Equals("on"))
- {
- tmp |= CSJ2K.j2k.entropy.StdEntropyCoderOptions.OPT_TERM_PASS;
- }
- // Vertically stripe-causal context mode ?
- if (((System.String)encSpec.css.getDefault()).Equals("on"))
- {
- tmp |= CSJ2K.j2k.entropy.StdEntropyCoderOptions.OPT_VERT_STR_CAUSAL;
- }
- // Predictable termination ?
- if (((System.String)encSpec.tts.getDefault()).Equals("predict"))
- {
- tmp |= CSJ2K.j2k.entropy.StdEntropyCoderOptions.OPT_PRED_TERM;
- }
- // Error resilience segmentation symbol insertion ?
- if (((System.String)encSpec.sss.getDefault()).Equals("on"))
- {
- tmp |= CSJ2K.j2k.entropy.StdEntropyCoderOptions.OPT_SEG_SYMBOLS;
- }
- }
- else
- {
- // Tile header
- // Selective arithmetic coding bypass ?
- if (((System.String)encSpec.bms.getTileDef(tileIdx)).Equals("on"))
- {
- tmp |= CSJ2K.j2k.entropy.StdEntropyCoderOptions.OPT_BYPASS;
- }
- // MQ reset after each coding pass ?
- if (((System.String)encSpec.mqrs.getTileDef(tileIdx)).Equals("on"))
- {
- tmp |= CSJ2K.j2k.entropy.StdEntropyCoderOptions.OPT_RESET_MQ;
- }
- // MQ termination after each arithmetically coded coding pass ?
- if (((System.String)encSpec.rts.getTileDef(tileIdx)).Equals("on"))
- {
- tmp |= CSJ2K.j2k.entropy.StdEntropyCoderOptions.OPT_TERM_PASS;
- }
- // Vertically stripe-causal context mode ?
- if (((System.String)encSpec.css.getTileDef(tileIdx)).Equals("on"))
- {
- tmp |= CSJ2K.j2k.entropy.StdEntropyCoderOptions.OPT_VERT_STR_CAUSAL;
- }
- // Predictable termination ?
- if (((System.String)encSpec.tts.getTileDef(tileIdx)).Equals("predict"))
- {
- tmp |= CSJ2K.j2k.entropy.StdEntropyCoderOptions.OPT_PRED_TERM;
- }
- // Error resilience segmentation symbol insertion ?
- if (((System.String)encSpec.sss.getTileDef(tileIdx)).Equals("on"))
- {
- tmp |= CSJ2K.j2k.entropy.StdEntropyCoderOptions.OPT_SEG_SYMBOLS;
- }
- }
- hbuf.Write((System.Byte)tmp);
-
- // Wavelet transform
- // Wavelet Filter
- if (mh)
- {
- filt = ((AnWTFilter[][])encSpec.wfs.getDefault());
- hbuf.Write((System.Byte)filt[0][0].FilterType);
- }
- else
- {
- filt = ((AnWTFilter[][])encSpec.wfs.getTileDef(tileIdx));
- hbuf.Write((System.Byte)filt[0][0].FilterType);
- }
-
- // Precinct partition
- if (precinctPartitionUsed)
- {
- // Write the precinct size for each resolution level + 1
- // (resolution 0) if precinct partition is used.
- System.Collections.ArrayList[] v = null;
- if (mh)
- {
- v = (System.Collections.ArrayList[])encSpec.pss.getDefault();
- }
- else
- {
- v = (System.Collections.ArrayList[])encSpec.pss.getTileDef(tileIdx);
- }
- for (int r = mrl; r >= 0; r--)
- {
- if (r >= v[1].Count)
- {
- tmp = ((System.Int32)v[1][v[1].Count - 1]);
- }
- else
- {
- tmp = ((System.Int32)v[1][r]);
- }
- int yExp = (MathUtil.log2(tmp) << 4) & 0x00F0;
-
- if (r >= v[0].Count)
- {
- tmp = ((System.Int32)v[0][v[0].Count - 1]);
- }
- else
- {
- tmp = ((System.Int32)v[0][r]);
- }
- int xExp = MathUtil.log2(tmp) & 0x000F;
- hbuf.Write((System.Byte)(yExp | xExp));
- }
- }
- }
-
- /// Writes COC marker segment . It is a functional marker containing the
- /// coding style for one component (coding style, decomposition, layering).
- ///
- /// Its values overrides any value previously set in COD in the main
- /// header or in the tile header.
- ///
- ///
- /// Flag indicating whether the main header is to be written.
- ///
- ///
- /// Tile index.
- ///
- ///
- /// index of the component which need use of the COC marker
- /// segment.
- ///
- ///
- ///
- ///
- ///
- protected internal virtual void writeCOC(bool mh, int tileIdx, int compIdx)
- {
- AnWTFilter[][] filt;
- bool precinctPartitionUsed;
- int tmp;
- int mrl = 0, a = 0;
- int ppx = 0, ppy = 0;
- Progression[] prog;
-
- if (mh)
- {
- mrl = ((System.Int32)encSpec.dls.getCompDef(compIdx));
- // Get precinct size for specified component
- ppx = encSpec.pss.getPPX(-1, compIdx, mrl);
- ppy = encSpec.pss.getPPY(-1, compIdx, mrl);
- prog = (Progression[])(encSpec.pocs.getCompDef(compIdx));
- }
- else
- {
- mrl = ((System.Int32)encSpec.dls.getTileCompVal(tileIdx, compIdx));
- // Get precinct size for specified component/tile
- ppx = encSpec.pss.getPPX(tileIdx, compIdx, mrl);
- ppy = encSpec.pss.getPPY(tileIdx, compIdx, mrl);
- prog = (Progression[])(encSpec.pocs.getTileCompVal(tileIdx, compIdx));
- }
-
- if (ppx != CSJ2K.j2k.codestream.Markers.PRECINCT_PARTITION_DEF_SIZE || ppy != CSJ2K.j2k.codestream.Markers.PRECINCT_PARTITION_DEF_SIZE)
- {
- precinctPartitionUsed = true;
- }
- else
- {
- precinctPartitionUsed = false;
- }
- if (precinctPartitionUsed)
- {
- // If precinct partition is used we add one byte per resolution
- // level i.e. mrl+1 (+1 for resolution 0).
- a = mrl + 1;
- }
-
- // COC marker
- hbuf.Write((System.Int16)CSJ2K.j2k.codestream.Markers.COC);
-
- // Lcoc (marker segment length (in bytes))
- // Basic: Lcoc(2 bytes)+Scoc(1)+ Ccoc(1 or 2)+SPcod(5+a)
- int markSegLen = 8 + ((nComp < 257) ? 1 : 2) + a;
-
- // Rounded to the nearest even value greater or equals
- hbuf.Write((System.Int16)markSegLen);
-
- // Ccoc
- if (nComp < 257)
- {
- hbuf.Write((System.Byte)compIdx);
- }
- else
- {
- hbuf.Write((System.Int16)compIdx);
- }
-
- // Scod (coding style parameter)
- tmp = 0;
- if (precinctPartitionUsed)
- {
- tmp = CSJ2K.j2k.codestream.Markers.SCOX_PRECINCT_PARTITION;
- }
- hbuf.Write((System.Byte)tmp);
-
-
- // SPcoc
-
- // Number of decomposition levels
- hbuf.Write((System.Byte)mrl);
-
- // Code-block width and height
- if (mh)
- {
- // main header, get component default values
- tmp = encSpec.cblks.getCBlkWidth(ModuleSpec.SPEC_COMP_DEF, -1, compIdx);
- hbuf.Write((System.Byte)(MathUtil.log2(tmp) - 2));
- tmp = encSpec.cblks.getCBlkHeight(ModuleSpec.SPEC_COMP_DEF, -1, compIdx);
- hbuf.Write((System.Byte)(MathUtil.log2(tmp) - 2));
- }
- else
- {
- // tile header, get tile component values
- tmp = encSpec.cblks.getCBlkWidth(ModuleSpec.SPEC_TILE_COMP, tileIdx, compIdx);
- hbuf.Write((System.Byte)(MathUtil.log2(tmp) - 2));
- tmp = encSpec.cblks.getCBlkHeight(ModuleSpec.SPEC_TILE_COMP, tileIdx, compIdx);
- hbuf.Write((System.Byte)(MathUtil.log2(tmp) - 2));
- }
-
- // Entropy coding mode options
- tmp = 0;
- if (mh)
- {
- // Main header
- // Lazy coding mode ?
- if (((System.String)encSpec.bms.getCompDef(compIdx)).Equals("on"))
- {
- tmp |= CSJ2K.j2k.entropy.StdEntropyCoderOptions.OPT_BYPASS;
- }
- // MQ reset after each coding pass ?
- if (((System.String)encSpec.mqrs.getCompDef(compIdx)).ToUpper().Equals("on".ToUpper()))
- {
- tmp |= CSJ2K.j2k.entropy.StdEntropyCoderOptions.OPT_RESET_MQ;
- }
- // MQ termination after each arithmetically coded coding pass ?
- if (((System.String)encSpec.rts.getCompDef(compIdx)).Equals("on"))
- {
- tmp |= CSJ2K.j2k.entropy.StdEntropyCoderOptions.OPT_TERM_PASS;
- }
- // Vertically stripe-causal context mode ?
- if (((System.String)encSpec.css.getCompDef(compIdx)).Equals("on"))
- {
- tmp |= CSJ2K.j2k.entropy.StdEntropyCoderOptions.OPT_VERT_STR_CAUSAL;
- }
- // Predictable termination ?
- if (((System.String)encSpec.tts.getCompDef(compIdx)).Equals("predict"))
- {
- tmp |= CSJ2K.j2k.entropy.StdEntropyCoderOptions.OPT_PRED_TERM;
- }
- // Error resilience segmentation symbol insertion ?
- if (((System.String)encSpec.sss.getCompDef(compIdx)).Equals("on"))
- {
- tmp |= CSJ2K.j2k.entropy.StdEntropyCoderOptions.OPT_SEG_SYMBOLS;
- }
- }
- else
- {
- // Tile Header
- if (((System.String)encSpec.bms.getTileCompVal(tileIdx, compIdx)).Equals("on"))
- {
- tmp |= CSJ2K.j2k.entropy.StdEntropyCoderOptions.OPT_BYPASS;
- }
- // MQ reset after each coding pass ?
- if (((System.String)encSpec.mqrs.getTileCompVal(tileIdx, compIdx)).Equals("on"))
- {
- tmp |= CSJ2K.j2k.entropy.StdEntropyCoderOptions.OPT_RESET_MQ;
- }
- // MQ termination after each arithmetically coded coding pass ?
- if (((System.String)encSpec.rts.getTileCompVal(tileIdx, compIdx)).Equals("on"))
- {
- tmp |= CSJ2K.j2k.entropy.StdEntropyCoderOptions.OPT_TERM_PASS;
- }
- // Vertically stripe-causal context mode ?
- if (((System.String)encSpec.css.getTileCompVal(tileIdx, compIdx)).Equals("on"))
- {
- tmp |= CSJ2K.j2k.entropy.StdEntropyCoderOptions.OPT_VERT_STR_CAUSAL;
- }
- // Predictable termination ?
- if (((System.String)encSpec.tts.getTileCompVal(tileIdx, compIdx)).Equals("predict"))
- {
- tmp |= CSJ2K.j2k.entropy.StdEntropyCoderOptions.OPT_PRED_TERM;
- }
- // Error resilience segmentation symbol insertion ?
- if (((System.String)encSpec.sss.getTileCompVal(tileIdx, compIdx)).Equals("on"))
- {
- tmp |= CSJ2K.j2k.entropy.StdEntropyCoderOptions.OPT_SEG_SYMBOLS;
- }
- }
- hbuf.Write((System.Byte)tmp);
-
- // Wavelet transform
- // Wavelet Filter
- if (mh)
- {
- filt = ((AnWTFilter[][])encSpec.wfs.getCompDef(compIdx));
- hbuf.Write((System.Byte)filt[0][0].FilterType);
- }
- else
- {
- filt = ((AnWTFilter[][])encSpec.wfs.getTileCompVal(tileIdx, compIdx));
- hbuf.Write((System.Byte)filt[0][0].FilterType);
- }
-
- // Precinct partition
- if (precinctPartitionUsed)
- {
- // Write the precinct size for each resolution level + 1
- // (resolution 0) if precinct partition is used.
- System.Collections.ArrayList[] v = null;
- if (mh)
- {
- v = (System.Collections.ArrayList[])encSpec.pss.getCompDef(compIdx);
- }
- else
- {
- v = (System.Collections.ArrayList[])encSpec.pss.getTileCompVal(tileIdx, compIdx);
- }
- for (int r = mrl; r >= 0; r--)
- {
- if (r >= v[1].Count)
- {
- tmp = ((System.Int32)v[1][v[1].Count - 1]);
- }
- else
- {
- tmp = ((System.Int32)v[1][r]);
- }
- int yExp = (MathUtil.log2(tmp) << 4) & 0x00F0;
-
- if (r >= v[0].Count)
- {
- tmp = ((System.Int32)v[0][v[0].Count - 1]);
- }
- else
- {
- tmp = ((System.Int32)v[0][r]);
- }
- int xExp = MathUtil.log2(tmp) & 0x000F;
- hbuf.Write((System.Byte)(yExp | xExp));
- }
- }
- }
-
- /// Writes QCD marker segment in main header. QCD is a functional marker
- /// segment countaining the quantization default used for compressing all
- /// the components in an image. The values can be overriden for an
- /// individual component by a QCC marker in either the main or the tile
- /// header.
- ///
- ///
- protected internal virtual void writeMainQCD()
- {
- int mrl;
- int qstyle;
-
- float step;
-
- System.String qType = (System.String)encSpec.qts.getDefault();
- //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Float.floatValue' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'"
- float baseStep = (float)((System.Single)encSpec.qsss.getDefault());
- int gb = ((System.Int32)encSpec.gbs.getDefault());
-
- bool isDerived = qType.Equals("derived");
- bool isReversible = qType.Equals("reversible");
-
- mrl = ((System.Int32)encSpec.dls.getDefault());
-
- int nt = dwt.getNumTiles();
- int nc = dwt.NumComps;
- int tmpI;
- int[] tcIdx = new int[2];
- System.String tmpStr;
- bool notFound = true;
- for (int t = 0; t < nt && notFound; t++)
- {
- for (int c = 0; c < nc && notFound; c++)
- {
- tmpI = ((System.Int32)encSpec.dls.getTileCompVal(t, c));
- tmpStr = ((System.String)encSpec.qts.getTileCompVal(t, c));
- if (tmpI == mrl && tmpStr.Equals(qType))
- {
- tcIdx[0] = t; tcIdx[1] = c;
- notFound = false;
- }
- }
- }
- if (notFound)
- {
- throw new System.ApplicationException("Default representative for quantization type " + " and number of decomposition levels not found " + " in main QCD marker segment. " + "You have found a JJ2000 bug.");
- }
- SubbandAn sb, csb, sbRoot = dwt.getAnSubbandTree(tcIdx[0], tcIdx[1]);
- defimgn = dwt.getNomRangeBits(tcIdx[1]);
-
- int nqcd; // Number of quantization step-size to transmit
-
- // Get the quantization style
- qstyle = (isReversible) ? CSJ2K.j2k.codestream.Markers.SQCX_NO_QUANTIZATION : ((isDerived) ? CSJ2K.j2k.codestream.Markers.SQCX_SCALAR_DERIVED : CSJ2K.j2k.codestream.Markers.SQCX_SCALAR_EXPOUNDED);
-
- // QCD marker
- hbuf.Write((System.Int16)CSJ2K.j2k.codestream.Markers.QCD);
-
- // Compute the number of steps to send
- switch (qstyle)
- {
-
- case CSJ2K.j2k.codestream.Markers.SQCX_SCALAR_DERIVED:
- nqcd = 1; // Just the LL value
- break;
-
- case CSJ2K.j2k.codestream.Markers.SQCX_NO_QUANTIZATION:
- case CSJ2K.j2k.codestream.Markers.SQCX_SCALAR_EXPOUNDED:
- // One value per subband
- nqcd = 0;
-
- sb = sbRoot;
-
- // Get the subband at first resolution level
- sb = (SubbandAn)sb.getSubbandByIdx(0, 0);
-
- // Count total number of subbands
- for (int j = 0; j <= mrl; j++)
- {
- csb = sb;
- while (csb != null)
- {
- nqcd++;
- csb = (SubbandAn)csb.nextSubband();
- }
- // Go up one resolution level
- sb = (SubbandAn)sb.NextResLevel;
- }
- break;
-
- default:
- throw new System.ApplicationException("Internal JJ2000 error");
-
- }
-
- // Lqcd (marker segment length (in bytes))
- // Lqcd(2 bytes)+Sqcd(1)+ SPqcd (2*Nqcd)
- int markSegLen = 3 + ((isReversible) ? nqcd : 2 * nqcd);
-
- // Rounded to the nearest even value greater or equals
- hbuf.Write((System.Int16)markSegLen);
-
- // Sqcd
- hbuf.Write((System.Byte)(qstyle + (gb << CSJ2K.j2k.codestream.Markers.SQCX_GB_SHIFT)));
-
- // SPqcd
- switch (qstyle)
- {
-
- case CSJ2K.j2k.codestream.Markers.SQCX_NO_QUANTIZATION:
- sb = sbRoot;
- sb = (SubbandAn)sb.getSubbandByIdx(0, 0);
-
- // Output one exponent per subband
- for (int j = 0; j <= mrl; j++)
- {
- csb = sb;
- while (csb != null)
- {
- int tmp = (defimgn + csb.anGainExp);
- hbuf.Write((System.Byte)(tmp << CSJ2K.j2k.codestream.Markers.SQCX_EXP_SHIFT));
-
- csb = (SubbandAn)csb.nextSubband();
- // Go up one resolution level
- }
- sb = (SubbandAn)sb.NextResLevel;
- }
- break;
-
- case CSJ2K.j2k.codestream.Markers.SQCX_SCALAR_DERIVED:
- sb = sbRoot;
- sb = (SubbandAn)sb.getSubbandByIdx(0, 0);
-
- // Calculate subband step (normalized to unit
- // dynamic range)
- step = baseStep / (1 << sb.level);
-
- // Write exponent-mantissa, 16 bits
- hbuf.Write((System.Int16)StdQuantizer.convertToExpMantissa(step));
- break;
-
- case CSJ2K.j2k.codestream.Markers.SQCX_SCALAR_EXPOUNDED:
- sb = sbRoot;
- sb = (SubbandAn)sb.getSubbandByIdx(0, 0);
-
- // Output one step per subband
- for (int j = 0; j <= mrl; j++)
- {
- csb = sb;
- while (csb != null)
- {
- // Calculate subband step (normalized to unit
- // dynamic range)
- step = baseStep / (csb.l2Norm * (1 << csb.anGainExp));
-
- // Write exponent-mantissa, 16 bits
- hbuf.Write((System.Int16)StdQuantizer.convertToExpMantissa(step));
-
- csb = (SubbandAn)csb.nextSubband();
- }
- // Go up one resolution level
- sb = (SubbandAn)sb.NextResLevel;
- }
- break;
-
- default:
- throw new System.ApplicationException("Internal JJ2000 error");
-
- }
- }
-
- /// Writes QCC marker segment in main header. It is a functional marker
- /// segment countaining the quantization used for compressing the specified
- /// component in an image. The values override for the specified component
- /// what was defined by a QCC marker in either the main or the tile header.
- ///
- ///
- /// Index of the component which needs QCC marker segment.
- ///
- ///
- protected internal virtual void writeMainQCC(int compIdx)
- {
-
- int mrl;
- int qstyle;
- int tIdx = 0;
- float step;
-
- SubbandAn sb, sb2;
- SubbandAn sbRoot;
-
- int imgnr = dwt.getNomRangeBits(compIdx);
- System.String qType = (System.String)encSpec.qts.getCompDef(compIdx);
- //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Float.floatValue' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'"
- float baseStep = (float)((System.Single)encSpec.qsss.getCompDef(compIdx));
- int gb = ((System.Int32)encSpec.gbs.getCompDef(compIdx));
-
- bool isReversible = qType.Equals("reversible");
- bool isDerived = qType.Equals("derived");
-
- mrl = ((System.Int32)encSpec.dls.getCompDef(compIdx));
-
- int nt = dwt.getNumTiles();
- int nc = dwt.NumComps;
- int tmpI;
- System.String tmpStr;
- bool notFound = true;
- for (int t = 0; t < nt && notFound; t++)
- {
- for (int c = 0; c < nc && notFound; c++)
- {
- tmpI = ((System.Int32)encSpec.dls.getTileCompVal(t, c));
- tmpStr = ((System.String)encSpec.qts.getTileCompVal(t, c));
- if (tmpI == mrl && tmpStr.Equals(qType))
- {
- tIdx = t;
- notFound = false;
- }
- }
- }
- if (notFound)
- {
- throw new System.ApplicationException("Default representative for quantization type " + " and number of decomposition levels not found " + " in main QCC (c=" + compIdx + ") marker segment. " + "You have found a JJ2000 bug.");
- }
- sbRoot = dwt.getAnSubbandTree(tIdx, compIdx);
-
- int nqcc; // Number of quantization step-size to transmit
-
- // Get the quantization style
- if (isReversible)
- {
- qstyle = CSJ2K.j2k.codestream.Markers.SQCX_NO_QUANTIZATION;
- }
- else if (isDerived)
- {
- qstyle = CSJ2K.j2k.codestream.Markers.SQCX_SCALAR_DERIVED;
- }
- else
- {
- qstyle = CSJ2K.j2k.codestream.Markers.SQCX_SCALAR_EXPOUNDED;
- }
-
- // QCC marker
- hbuf.Write((System.Int16)CSJ2K.j2k.codestream.Markers.QCC);
-
- // Compute the number of steps to send
- switch (qstyle)
- {
-
- case CSJ2K.j2k.codestream.Markers.SQCX_SCALAR_DERIVED:
- nqcc = 1; // Just the LL value
- break;
-
- case CSJ2K.j2k.codestream.Markers.SQCX_NO_QUANTIZATION:
- case CSJ2K.j2k.codestream.Markers.SQCX_SCALAR_EXPOUNDED:
- // One value per subband
- nqcc = 0;
-
- sb = sbRoot;
- mrl = sb.resLvl;
-
- // Get the subband at first resolution level
- sb = (SubbandAn)sb.getSubbandByIdx(0, 0);
-
- // Find root element for LL subband
- while (sb.resLvl != 0)
- {
- sb = sb.subb_LL;
- }
-
- // Count total number of subbands
- for (int j = 0; j <= mrl; j++)
- {
- sb2 = sb;
- while (sb2 != null)
- {
- nqcc++;
- sb2 = (SubbandAn)sb2.nextSubband();
- }
- // Go up one resolution level
- sb = (SubbandAn)sb.NextResLevel;
- }
- break;
-
- default:
- throw new System.ApplicationException("Internal JJ2000 error");
-
- }
-
- // Lqcc (marker segment length (in bytes))
- // Lqcc(2 bytes)+Cqcc(1 or 2)+Sqcc(1)+ SPqcc (2*Nqcc)
- int markSegLen = 3 + ((nComp < 257) ? 1 : 2) + ((isReversible) ? nqcc : 2 * nqcc);
- hbuf.Write((System.Int16)markSegLen);
-
- // Cqcc
- if (nComp < 257)
- {
- hbuf.Write((System.Byte)compIdx);
- }
- else
- {
- hbuf.Write((System.Int16)compIdx);
- }
-
- // Sqcc (quantization style)
- hbuf.Write((System.Byte)(qstyle + (gb << CSJ2K.j2k.codestream.Markers.SQCX_GB_SHIFT)));
-
- // SPqcc
- switch (qstyle)
- {
-
- case CSJ2K.j2k.codestream.Markers.SQCX_NO_QUANTIZATION:
- // Get resolution level 0 subband
- sb = sbRoot;
- sb = (SubbandAn)sb.getSubbandByIdx(0, 0);
-
- // Output one exponent per subband
- for (int j = 0; j <= mrl; j++)
- {
- sb2 = sb;
- while (sb2 != null)
- {
- int tmp = (imgnr + sb2.anGainExp);
- hbuf.Write((System.Byte)(tmp << CSJ2K.j2k.codestream.Markers.SQCX_EXP_SHIFT));
-
- sb2 = (SubbandAn)sb2.nextSubband();
- }
- // Go up one resolution level
- sb = (SubbandAn)sb.NextResLevel;
- }
- break;
-
- case CSJ2K.j2k.codestream.Markers.SQCX_SCALAR_DERIVED:
- // Get resolution level 0 subband
- sb = sbRoot;
- sb = (SubbandAn)sb.getSubbandByIdx(0, 0);
-
- // Calculate subband step (normalized to unit
- // dynamic range)
- step = baseStep / (1 << sb.level);
-
- // Write exponent-mantissa, 16 bits
- hbuf.Write((System.Int16)StdQuantizer.convertToExpMantissa(step));
- break;
-
- case CSJ2K.j2k.codestream.Markers.SQCX_SCALAR_EXPOUNDED:
- // Get resolution level 0 subband
- sb = sbRoot;
- mrl = sb.resLvl;
-
- sb = (SubbandAn)sb.getSubbandByIdx(0, 0);
-
- for (int j = 0; j <= mrl; j++)
- {
- sb2 = sb;
- while (sb2 != null)
- {
- // Calculate subband step (normalized to unit
- // dynamic range)
- step = baseStep / (sb2.l2Norm * (1 << sb2.anGainExp));
-
- // Write exponent-mantissa, 16 bits
- hbuf.Write((System.Int16)StdQuantizer.convertToExpMantissa(step));
- sb2 = (SubbandAn)sb2.nextSubband();
- }
- // Go up one resolution level
- sb = (SubbandAn)sb.NextResLevel;
- }
- break;
-
- default:
- throw new System.ApplicationException("Internal JJ2000 error");
-
- }
- }
-
- /// Writes QCD marker segment in tile header. QCD is a functional marker
- /// segment countaining the quantization default used for compressing all
- /// the components in an image. The values can be overriden for an
- /// individual component by a QCC marker in either the main or the tile
- /// header.
- ///
- ///
- /// Tile index
- ///
- ///
- protected internal virtual void writeTileQCD(int tIdx)
- {
- int mrl;
- int qstyle;
-
- float step;
- SubbandAn sb, csb, sbRoot;
-
- System.String qType = (System.String)encSpec.qts.getTileDef(tIdx);
- //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Float.floatValue' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'"
- float baseStep = (float)((System.Single)encSpec.qsss.getTileDef(tIdx));
- mrl = ((System.Int32)encSpec.dls.getTileDef(tIdx));
-
- int nc = dwt.NumComps;
- int tmpI;
- System.String tmpStr;
- bool notFound = true;
- int compIdx = 0;
- for (int c = 0; c < nc && notFound; c++)
- {
- tmpI = ((System.Int32)encSpec.dls.getTileCompVal(tIdx, c));
- tmpStr = ((System.String)encSpec.qts.getTileCompVal(tIdx, c));
- if (tmpI == mrl && tmpStr.Equals(qType))
- {
- compIdx = c;
- notFound = false;
- }
- }
- if (notFound)
- {
- throw new System.ApplicationException("Default representative for quantization type " + " and number of decomposition levels not found " + " in tile QCD (t=" + tIdx + ") marker segment. " + "You have found a JJ2000 bug.");
- }
-
- sbRoot = dwt.getAnSubbandTree(tIdx, compIdx);
- deftilenr = dwt.getNomRangeBits(compIdx);
- int gb = ((System.Int32)encSpec.gbs.getTileDef(tIdx));
-
- bool isDerived = qType.Equals("derived");
- bool isReversible = qType.Equals("reversible");
-
- int nqcd; // Number of quantization step-size to transmit
-
- // Get the quantization style
- qstyle = (isReversible) ? CSJ2K.j2k.codestream.Markers.SQCX_NO_QUANTIZATION : ((isDerived) ? CSJ2K.j2k.codestream.Markers.SQCX_SCALAR_DERIVED : CSJ2K.j2k.codestream.Markers.SQCX_SCALAR_EXPOUNDED);
-
- // QCD marker
- hbuf.Write((System.Int16)CSJ2K.j2k.codestream.Markers.QCD);
-
- // Compute the number of steps to send
- switch (qstyle)
- {
-
- case CSJ2K.j2k.codestream.Markers.SQCX_SCALAR_DERIVED:
- nqcd = 1; // Just the LL value
- break;
-
- case CSJ2K.j2k.codestream.Markers.SQCX_NO_QUANTIZATION:
- case CSJ2K.j2k.codestream.Markers.SQCX_SCALAR_EXPOUNDED:
- // One value per subband
- nqcd = 0;
-
- sb = sbRoot;
-
- // Get the subband at first resolution level
- sb = (SubbandAn)sb.getSubbandByIdx(0, 0);
-
- // Count total number of subbands
- for (int j = 0; j <= mrl; j++)
- {
- csb = sb;
- while (csb != null)
- {
- nqcd++;
- csb = (SubbandAn)csb.nextSubband();
- }
- // Go up one resolution level
- sb = (SubbandAn)sb.NextResLevel;
- }
- break;
-
- default:
- throw new System.ApplicationException("Internal JJ2000 error");
-
- }
-
- // Lqcd (marker segment length (in bytes))
- // Lqcd(2 bytes)+Sqcd(1)+ SPqcd (2*Nqcd)
- int markSegLen = 3 + ((isReversible) ? nqcd : 2 * nqcd);
-
- // Rounded to the nearest even value greater or equals
- hbuf.Write((System.Int16)markSegLen);
-
- // Sqcd
- hbuf.Write((System.Byte)(qstyle + (gb << CSJ2K.j2k.codestream.Markers.SQCX_GB_SHIFT)));
-
- // SPqcd
- switch (qstyle)
- {
-
- case CSJ2K.j2k.codestream.Markers.SQCX_NO_QUANTIZATION:
- sb = sbRoot;
- sb = (SubbandAn)sb.getSubbandByIdx(0, 0);
-
- // Output one exponent per subband
- for (int j = 0; j <= mrl; j++)
- {
- csb = sb;
- while (csb != null)
- {
- int tmp = (deftilenr + csb.anGainExp);
- hbuf.Write((System.Byte)(tmp << CSJ2K.j2k.codestream.Markers.SQCX_EXP_SHIFT));
-
- csb = (SubbandAn)csb.nextSubband();
- // Go up one resolution level
- }
- sb = (SubbandAn)sb.NextResLevel;
- }
- break;
-
- case CSJ2K.j2k.codestream.Markers.SQCX_SCALAR_DERIVED:
- sb = sbRoot;
- sb = (SubbandAn)sb.getSubbandByIdx(0, 0);
-
- // Calculate subband step (normalized to unit
- // dynamic range)
- step = baseStep / (1 << sb.level);
-
- // Write exponent-mantissa, 16 bits
- hbuf.Write((System.Int16)StdQuantizer.convertToExpMantissa(step));
- break;
-
- case CSJ2K.j2k.codestream.Markers.SQCX_SCALAR_EXPOUNDED:
- sb = sbRoot;
- sb = (SubbandAn)sb.getSubbandByIdx(0, 0);
-
- // Output one step per subband
- for (int j = 0; j <= mrl; j++)
- {
- csb = sb;
- while (csb != null)
- {
- // Calculate subband step (normalized to unit
- // dynamic range)
- step = baseStep / (csb.l2Norm * (1 << csb.anGainExp));
-
- // Write exponent-mantissa, 16 bits
- hbuf.Write((System.Int16)StdQuantizer.convertToExpMantissa(step));
-
- csb = (SubbandAn)csb.nextSubband();
- }
- // Go up one resolution level
- sb = (SubbandAn)sb.NextResLevel;
- }
- break;
-
- default:
- throw new System.ApplicationException("Internal JJ2000 error");
-
- }
- }
-
- /// Writes QCC marker segment in tile header. It is a functional marker
- /// segment countaining the quantization used for compressing the specified
- /// component in an image. The values override for the specified component
- /// what was defined by a QCC marker in either the main or the tile header.
- ///
- ///
- /// Tile index
- ///
- ///
- /// Index of the component which needs QCC marker segment.
- ///
- ///
- protected internal virtual void writeTileQCC(int t, int compIdx)
- {
-
- int mrl;
- int qstyle;
- float step;
-
- SubbandAn sb, sb2;
- int nqcc; // Number of quantization step-size to transmit
-
- SubbandAn sbRoot = dwt.getAnSubbandTree(t, compIdx);
- int imgnr = dwt.getNomRangeBits(compIdx);
- System.String qType = (System.String)encSpec.qts.getTileCompVal(t, compIdx);
- //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Float.floatValue' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'"
- float baseStep = (float)((System.Single)encSpec.qsss.getTileCompVal(t, compIdx));
- int gb = ((System.Int32)encSpec.gbs.getTileCompVal(t, compIdx));
-
- bool isReversible = qType.Equals("reversible");
- bool isDerived = qType.Equals("derived");
-
- mrl = ((System.Int32)encSpec.dls.getTileCompVal(t, compIdx));
-
- // Get the quantization style
- if (isReversible)
- {
- qstyle = CSJ2K.j2k.codestream.Markers.SQCX_NO_QUANTIZATION;
- }
- else if (isDerived)
- {
- qstyle = CSJ2K.j2k.codestream.Markers.SQCX_SCALAR_DERIVED;
- }
- else
- {
- qstyle = CSJ2K.j2k.codestream.Markers.SQCX_SCALAR_EXPOUNDED;
- }
-
- // QCC marker
- hbuf.Write((System.Int16)CSJ2K.j2k.codestream.Markers.QCC);
-
- // Compute the number of steps to send
- switch (qstyle)
- {
-
- case CSJ2K.j2k.codestream.Markers.SQCX_SCALAR_DERIVED:
- nqcc = 1; // Just the LL value
- break;
-
- case CSJ2K.j2k.codestream.Markers.SQCX_NO_QUANTIZATION:
- case CSJ2K.j2k.codestream.Markers.SQCX_SCALAR_EXPOUNDED:
- // One value per subband
- nqcc = 0;
-
- sb = sbRoot;
- mrl = sb.resLvl;
-
- // Get the subband at first resolution level
- sb = (SubbandAn)sb.getSubbandByIdx(0, 0);
-
- // Find root element for LL subband
- while (sb.resLvl != 0)
- {
- sb = sb.subb_LL;
- }
-
- // Count total number of subbands
- for (int j = 0; j <= mrl; j++)
- {
- sb2 = sb;
- while (sb2 != null)
- {
- nqcc++;
- sb2 = (SubbandAn)sb2.nextSubband();
- }
- // Go up one resolution level
- sb = (SubbandAn)sb.NextResLevel;
- }
- break;
-
- default:
- throw new System.ApplicationException("Internal JJ2000 error");
-
- }
-
- // Lqcc (marker segment length (in bytes))
- // Lqcc(2 bytes)+Cqcc(1 or 2)+Sqcc(1)+ SPqcc (2*Nqcc)
- int markSegLen = 3 + ((nComp < 257) ? 1 : 2) + ((isReversible) ? nqcc : 2 * nqcc);
- hbuf.Write((System.Int16)markSegLen);
-
- // Cqcc
- if (nComp < 257)
- {
- hbuf.Write((System.Byte)compIdx);
- }
- else
- {
- hbuf.Write((System.Int16)compIdx);
- }
-
- // Sqcc (quantization style)
- hbuf.Write((System.Byte)(qstyle + (gb << CSJ2K.j2k.codestream.Markers.SQCX_GB_SHIFT)));
-
- // SPqcc
- switch (qstyle)
- {
-
- case CSJ2K.j2k.codestream.Markers.SQCX_NO_QUANTIZATION:
- // Get resolution level 0 subband
- sb = sbRoot;
- sb = (SubbandAn)sb.getSubbandByIdx(0, 0);
-
- // Output one exponent per subband
- for (int j = 0; j <= mrl; j++)
- {
- sb2 = sb;
- while (sb2 != null)
- {
- int tmp = (imgnr + sb2.anGainExp);
- hbuf.Write((System.Byte)(tmp << CSJ2K.j2k.codestream.Markers.SQCX_EXP_SHIFT));
-
- sb2 = (SubbandAn)sb2.nextSubband();
- }
- // Go up one resolution level
- sb = (SubbandAn)sb.NextResLevel;
- }
- break;
-
- case CSJ2K.j2k.codestream.Markers.SQCX_SCALAR_DERIVED:
- // Get resolution level 0 subband
- sb = sbRoot;
- sb = (SubbandAn)sb.getSubbandByIdx(0, 0);
-
- // Calculate subband step (normalized to unit
- // dynamic range)
- step = baseStep / (1 << sb.level);
-
- // Write exponent-mantissa, 16 bits
- hbuf.Write((System.Int16)StdQuantizer.convertToExpMantissa(step));
- break;
-
- case CSJ2K.j2k.codestream.Markers.SQCX_SCALAR_EXPOUNDED:
- // Get resolution level 0 subband
- sb = sbRoot;
- mrl = sb.resLvl;
-
- sb = (SubbandAn)sb.getSubbandByIdx(0, 0);
-
- for (int j = 0; j <= mrl; j++)
- {
- sb2 = sb;
- while (sb2 != null)
- {
- // Calculate subband step (normalized to unit
- // dynamic range)
- step = baseStep / (sb2.l2Norm * (1 << sb2.anGainExp));
-
- // Write exponent-mantissa, 16 bits
- hbuf.Write((System.Int16)StdQuantizer.convertToExpMantissa(step));
- sb2 = (SubbandAn)sb2.nextSubband();
- }
- // Go up one resolution level
- sb = (SubbandAn)sb.NextResLevel;
- }
- break;
-
- default:
- throw new System.ApplicationException("Internal JJ2000 error");
-
- }
- }
-
- /// Writes POC marker segment. POC is a functional marker segment
- /// containing the bounds and progression order for any progression order
- /// other than default in the codestream.
- ///
- ///
- /// Flag indicating whether the main header is to be written
- ///
- ///
- /// Tile index
- ///
- ///
- protected internal virtual void writePOC(bool mh, int tileIdx)
- {
- int markSegLen = 0; // Segment marker length
- int lenCompField; // Holds the size of any component field as
- // this size depends on the number of
- //components
- Progression[] prog = null; // Holds the progression(s)
- int npoc; // Number of progression order changes
-
- // Get the progression order changes, their number and checks
- // if it is ok
- if (mh)
- {
- prog = (Progression[])(encSpec.pocs.getDefault());
- }
- else
- {
- prog = (Progression[])(encSpec.pocs.getTileDef(tileIdx));
- }
-
- // Calculate the length of a component field (depends on the number of
- // components)
- lenCompField = (nComp < 257 ? 1 : 2);
-
- // POC marker
- hbuf.Write((System.Int16)CSJ2K.j2k.codestream.Markers.POC);
-
- // Lpoc (marker segment length (in bytes))
- // Basic: Lpoc(2 bytes) + npoc * [ RSpoc(1) + CSpoc(1 or 2) +
- // LYEpoc(2) + REpoc(1) + CEpoc(1 or 2) + Ppoc(1) ]
- npoc = prog.Length;
- markSegLen = 2 + npoc * (1 + lenCompField + 2 + 1 + lenCompField + 1);
- hbuf.Write((System.Int16)markSegLen);
-
- // Write each progression order change
- for (int i = 0; i < npoc; i++)
- {
- // RSpoc(i)
- hbuf.Write((System.Byte)prog[i].rs);
- // CSpoc(i)
- if (lenCompField == 2)
- {
- hbuf.Write((System.Int16)prog[i].cs);
- }
- else
- {
- hbuf.Write((System.Byte)prog[i].cs);
- }
- // LYEpoc(i)
- hbuf.Write((System.Int16)prog[i].lye);
- // REpoc(i)
- hbuf.Write((System.Byte)prog[i].re);
- // CEpoc(i)
- if (lenCompField == 2)
- {
- hbuf.Write((System.Int16)prog[i].ce);
- }
- else
- {
- hbuf.Write((System.Byte)prog[i].ce);
- }
- // Ppoc(i)
- hbuf.Write((System.Byte)prog[i].type);
- }
- }
-
-
- /// Write main header. JJ2000 main header corresponds to the following
- /// sequence of marker segments:
- ///
- ///
- /// - SOC
- /// - SIZ
- /// - COD
- /// - COC (if needed)
- /// - QCD
- /// - QCC (if needed)
- /// - POC (if needed)
- ///
- ///
- ///
- public virtual void encodeMainHeader()
- {
- int i;
-
-
- // +---------------------------------+
- // | SOC marker segment |
- // +---------------------------------+
- writeSOC();
-
- // +---------------------------------+
- // | Image and tile SIZe (SIZ) |
- // +---------------------------------+
- writeSIZ();
-
- // +-------------------------------+
- // | COding style Default (COD) |
- // +-------------------------------+
- bool isEresUsed = ((System.String)encSpec.tts.getDefault()).Equals("predict");
- writeCOD(true, 0);
-
- // +---------------------------------+
- // | COding style Component (COC) |
- // +---------------------------------+
- for (i = 0; i < nComp; i++)
- {
- bool isEresUsedinComp = ((System.String)encSpec.tts.getCompDef(i)).Equals("predict");
- if (encSpec.wfs.isCompSpecified(i) || encSpec.dls.isCompSpecified(i) || encSpec.bms.isCompSpecified(i) || encSpec.mqrs.isCompSpecified(i) || encSpec.rts.isCompSpecified(i) || encSpec.sss.isCompSpecified(i) || encSpec.css.isCompSpecified(i) || encSpec.pss.isCompSpecified(i) || encSpec.cblks.isCompSpecified(i) || (isEresUsed != isEresUsedinComp))
- // Some component non-default stuff => need COC
- writeCOC(true, 0, i);
- }
-
- // +-------------------------------+
- // | Quantization Default (QCD) |
- // +-------------------------------+
- writeMainQCD();
-
- // +-------------------------------+
- // | Quantization Component (QCC) |
- // +-------------------------------+
- // Write needed QCC markers
- for (i = 0; i < nComp; i++)
- {
- if (dwt.getNomRangeBits(i) != defimgn || encSpec.qts.isCompSpecified(i) || encSpec.qsss.isCompSpecified(i) || encSpec.dls.isCompSpecified(i) || encSpec.gbs.isCompSpecified(i))
- {
- writeMainQCC(i);
- }
- }
-
- // +--------------------------+
- // | POC maker segment |
- // +--------------------------+
- Progression[] prog = (Progression[])(encSpec.pocs.getDefault());
- if (prog.Length > 1)
- writePOC(true, 0);
-
- // +---------------------------+
- // | Comments (COM) |
- // +---------------------------+
- writeCOM();
- }
-
- /// Write COM marker segment(s) to the codestream.
- ///
- /// This marker is currently written in main header and indicates the
- /// JJ2000 encoder's version that has created the codestream.
- ///
- ///
- private void writeCOM()
- {
- // JJ2000 COM marker segment
- if (enJJ2KMarkSeg)
- {
- System.String str = "Created by: CSJ2K version " + JJ2KInfo.version;
- int markSegLen; // the marker segment length
-
- // COM marker
- hbuf.Write((System.Int16)CSJ2K.j2k.codestream.Markers.COM);
-
- // Calculate length: Lcom(2) + Rcom (2) + string's length;
- markSegLen = 2 + 2 + str.Length;
- hbuf.Write((System.Int16)markSegLen);
-
- // Rcom
- hbuf.Write((System.Int16)1); // General use (IS 8859-15:1999(Latin) values)
-
- byte[] chars = System.Text.ASCIIEncoding.ASCII.GetBytes(str);
- for (int i = 0; i < chars.Length; i++)
- {
- hbuf.Write((byte)chars[i]);
- }
- }
- // other COM marker segments
- if (otherCOMMarkSeg != null)
- {
- SupportClass.Tokenizer stk = new SupportClass.Tokenizer(otherCOMMarkSeg, "#");
- while (stk.HasMoreTokens())
- {
- System.String str = stk.NextToken();
- int markSegLen; // the marker segment length
-
- // COM marker
- hbuf.Write((System.Int16)CSJ2K.j2k.codestream.Markers.COM);
-
- // Calculate length: Lcom(2) + Rcom (2) + string's length;
- markSegLen = 2 + 2 + str.Length;
- hbuf.Write((System.Int16)markSegLen);
-
- // Rcom
- hbuf.Write((System.Int16)1); // General use (IS 8859-15:1999(Latin)
- // values)
-
- byte[] chars = System.Text.ASCIIEncoding.ASCII.GetBytes(str);
- for (int i = 0; i < chars.Length; i++)
- {
- hbuf.Write((byte)chars[i]);
- }
- }
- }
- }
-
- /// Writes the RGN marker segment in the tile header. It describes the
- /// scaling value in each tile component
- ///
- /// May be used in tile or main header. If used in main header, it
- /// refers to a ROI of the whole image, regardless of tiling. When used in
- /// tile header, only the particular tile is affected.
- ///
- ///
- /// The tile index
- ///
- ///
- /// If an I/O error occurs while reading from the
- /// encoder header stream
- ///
- ///
- private void writeRGN(int tIdx)
- {
- int i;
- int markSegLen; // the marker length
-
- // Write one RGN marker per component
- for (i = 0; i < nComp; i++)
- {
- // RGN marker
- hbuf.Write((System.Int16)CSJ2K.j2k.codestream.Markers.RGN);
-
- // Calculate length (Lrgn)
- // Basic: Lrgn (2) + Srgn (1) + SPrgn + one byte
- // or two for component number
- markSegLen = 4 + ((nComp < 257) ? 1 : 2);
- hbuf.Write((System.Int16)markSegLen);
-
- // Write component (Crgn)
- if (nComp < 257)
- {
- hbuf.Write((System.Byte)i);
- }
- else
- {
- hbuf.Write((System.Int16)i);
- }
-
- // Write type of ROI (Srgn)
- hbuf.Write((System.Byte)CSJ2K.j2k.codestream.Markers.SRGN_IMPLICIT);
-
- // Write ROI info (SPrgn)
- hbuf.Write((System.Byte)((System.Int32)(encSpec.rois.getTileCompVal(tIdx, i))));
- }
- }
- /// Writes tile-part header. JJ2000 tile-part header corresponds to the
- /// following sequence of marker segments:
- ///
- ///
- /// - SOT
- /// - COD (if needed)
- /// - COC (if needed)
- /// - QCD (if needed)
- /// - QCC (if needed)
- /// - RGN (if needed)
- /// - POC (if needed)
- /// - SOD
- ///
- ///
- ///
- /// The length of the current tile-part.
- ///
- ///
- /// Index of the tile to write
- ///
- ///
- public virtual void encodeTilePartHeader(int tileLength, int tileIdx)
- {
-
- int tmp;
- Coord numTiles = ralloc.getNumTiles(null);
- ralloc.setTile(tileIdx % numTiles.x, tileIdx / numTiles.x);
-
- // +--------------------------+
- // | SOT maker segment |
- // +--------------------------+
- // SOT marker
- hbuf.Write((System.Byte)SupportClass.URShift(CSJ2K.j2k.codestream.Markers.SOT, 8));
- hbuf.Write((System.Byte)(CSJ2K.j2k.codestream.Markers.SOT & 0x00FF));
-
- // Lsot (10 bytes)
- hbuf.Write((System.Byte)0);
- hbuf.Write((System.Byte)10);
-
- // Isot
- if (tileIdx > 65534)
- {
- throw new System.ArgumentException("Trying to write a tile-part " + "header whose tile index is " + "too high");
- }
- hbuf.Write((System.Byte)(tileIdx >> 8));
- hbuf.Write((System.Byte)tileIdx);
-
- // Psot
- tmp = tileLength;
- hbuf.Write((System.Byte)(tmp >> 24));
- hbuf.Write((System.Byte)(tmp >> 16));
- hbuf.Write((System.Byte)(tmp >> 8));
- hbuf.Write((System.Byte)tmp);
-
- // TPsot
- hbuf.Write((System.Byte)0); // Only one tile-part currently supported !
-
- // TNsot
- hbuf.Write((System.Byte)1); // Only one tile-part currently supported !
-
- // +--------------------------+
- // | COD maker segment |
- // +--------------------------+
- bool isEresUsed = ((System.String)encSpec.tts.getDefault()).Equals("predict");
- bool isEresUsedInTile = ((System.String)encSpec.tts.getTileDef(tileIdx)).Equals("predict");
- bool tileCODwritten = false;
- if (encSpec.wfs.isTileSpecified(tileIdx) || encSpec.cts.isTileSpecified(tileIdx) || encSpec.dls.isTileSpecified(tileIdx) || encSpec.bms.isTileSpecified(tileIdx) || encSpec.mqrs.isTileSpecified(tileIdx) || encSpec.rts.isTileSpecified(tileIdx) || encSpec.css.isTileSpecified(tileIdx) || encSpec.pss.isTileSpecified(tileIdx) || encSpec.sops.isTileSpecified(tileIdx) || encSpec.sss.isTileSpecified(tileIdx) || encSpec.pocs.isTileSpecified(tileIdx) || encSpec.ephs.isTileSpecified(tileIdx) || encSpec.cblks.isTileSpecified(tileIdx) || (isEresUsed != isEresUsedInTile))
- {
- writeCOD(false, tileIdx);
- tileCODwritten = true;
- }
-
- // +--------------------------+
- // | COC maker segment |
- // +--------------------------+
- for (int c = 0; c < nComp; c++)
- {
- bool isEresUsedInTileComp = ((System.String)encSpec.tts.getTileCompVal(tileIdx, c)).Equals("predict");
-
- if (encSpec.wfs.isTileCompSpecified(tileIdx, c) || encSpec.dls.isTileCompSpecified(tileIdx, c) || encSpec.bms.isTileCompSpecified(tileIdx, c) || encSpec.mqrs.isTileCompSpecified(tileIdx, c) || encSpec.rts.isTileCompSpecified(tileIdx, c) || encSpec.css.isTileCompSpecified(tileIdx, c) || encSpec.pss.isTileCompSpecified(tileIdx, c) || encSpec.sss.isTileCompSpecified(tileIdx, c) || encSpec.cblks.isTileCompSpecified(tileIdx, c) || (isEresUsedInTileComp != isEresUsed))
- {
- writeCOC(false, tileIdx, c);
- }
- else if (tileCODwritten)
- {
- if (encSpec.wfs.isCompSpecified(c) || encSpec.dls.isCompSpecified(c) || encSpec.bms.isCompSpecified(c) || encSpec.mqrs.isCompSpecified(c) || encSpec.rts.isCompSpecified(c) || encSpec.sss.isCompSpecified(c) || encSpec.css.isCompSpecified(c) || encSpec.pss.isCompSpecified(c) || encSpec.cblks.isCompSpecified(c) || (encSpec.tts.isCompSpecified(c) && ((System.String)encSpec.tts.getCompDef(c)).Equals("predict")))
- {
- writeCOC(false, tileIdx, c);
- }
- }
- }
-
- // +--------------------------+
- // | QCD maker segment |
- // +--------------------------+
- bool tileQCDwritten = false;
- if (encSpec.qts.isTileSpecified(tileIdx) || encSpec.qsss.isTileSpecified(tileIdx) || encSpec.dls.isTileSpecified(tileIdx) || encSpec.gbs.isTileSpecified(tileIdx))
- {
- writeTileQCD(tileIdx);
- tileQCDwritten = true;
- }
- else
- {
- deftilenr = defimgn;
- }
-
- // +--------------------------+
- // | QCC maker segment |
- // +--------------------------+
- for (int c = 0; c < nComp; c++)
- {
- if (dwt.getNomRangeBits(c) != deftilenr || encSpec.qts.isTileCompSpecified(tileIdx, c) || encSpec.qsss.isTileCompSpecified(tileIdx, c) || encSpec.dls.isTileCompSpecified(tileIdx, c) || encSpec.gbs.isTileCompSpecified(tileIdx, c))
- {
- writeTileQCC(tileIdx, c);
- }
- else if (tileQCDwritten)
- {
- if (encSpec.qts.isCompSpecified(c) || encSpec.qsss.isCompSpecified(c) || encSpec.dls.isCompSpecified(c) || encSpec.gbs.isCompSpecified(c))
- {
- writeTileQCC(tileIdx, c);
- }
- }
- }
-
- // +--------------------------+
- // | RGN maker segment |
- // +--------------------------+
- if (roiSc.useRoi() && (!roiSc.BlockAligned))
- writeRGN(tileIdx);
-
- // +--------------------------+
- // | POC maker segment |
- // +--------------------------+
- Progression[] prog;
- if (encSpec.pocs.isTileSpecified(tileIdx))
- {
- prog = (Progression[])(encSpec.pocs.getTileDef(tileIdx));
- if (prog.Length > 1)
- writePOC(false, tileIdx);
- }
-
- // +--------------------------+
- // | SOD maker |
- // +--------------------------+
- hbuf.Write((System.Byte)SupportClass.URShift(CSJ2K.j2k.codestream.Markers.SOD, 8));
- hbuf.Write((System.Byte)(CSJ2K.j2k.codestream.Markers.SOD & 0x00FF));
- }
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/codestream/writer/PktEncoder.cs b/CSJ2K/j2k/codestream/writer/PktEncoder.cs
deleted file mode 100644
index eda2ca70..00000000
--- a/CSJ2K/j2k/codestream/writer/PktEncoder.cs
+++ /dev/null
@@ -1,1558 +0,0 @@
-/*
-* CVS identifier:
-*
-* $Id: PktEncoder.java,v 1.29 2001/11/08 18:32:09 grosbois Exp $
-*
-* Class: PktEncoder
-*
-* Description: Builds bit stream packets and keeps
-* interpacket dependencies.
-*
-*
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-* */
-using CSJ2K.j2k.encoder;
-using CSJ2K.j2k.entropy.encoder;
-using CSJ2K.j2k.image;
-using CSJ2K.j2k.util;
-using CSJ2K.j2k.wavelet.analysis;
-using System;
-namespace CSJ2K.j2k.codestream.writer
-{
-
- /// This class builds packets and keeps the state information of packet
- /// interdependencies. It also supports saving the state and reverting
- /// (restoring) to the last saved state, with the save() and restore() methods.
- ///
- /// Each time the encodePacket() method is called a new packet is encoded,
- /// the packet header is returned by the method, and the packet body can be
- /// obtained with the getLastBodyBuf() and getLastBodyLen() methods.
- ///
- ///
- public class PktEncoder
- {
- /// Returns the buffer of the body of the last encoded packet. The length
- /// of the body can be retrieved with the getLastBodyLen() method. The
- /// length of the array returned by this method may be larger than the
- /// actual body length.
- ///
- ///
- /// The buffer of body of the last encoded packet.
- ///
- ///
- /// If no packet has been coded since
- /// last reset(), last restore(), or object creation.
- ///
- ///
- ///
- ///
- ///
- virtual public byte[] LastBodyBuf
- {
- get
- {
- if (lbbuf == null)
- {
- throw new System.ArgumentException();
- }
- return lbbuf;
- }
-
- }
- /// Returns the length of the body of the last encoded packet, in
- /// bytes. The body itself can be retrieved with the getLastBodyBuf()
- /// method.
- ///
- ///
- /// The length of the body of last encoded packet, in bytes.
- ///
- ///
- ///
- ///
- ///
- virtual public int LastBodyLen
- {
- get
- {
- return lblen;
- }
-
- }
- /// Returns true if the current packet is writable i.e. should be written.
- /// Returns false otherwise.
- ///
- ///
- virtual public bool PacketWritable
- {
- get
- {
- return packetWritable;
- }
-
- }
- /// Tells if there was ROI information in the last written packet
- ///
- ///
- virtual public bool ROIinPkt
- {
- get
- {
- return roiInPkt;
- }
-
- }
- /// Gives the length to read in current packet body to get all ROI
- /// information
- ///
- virtual public int ROILen
- {
- get
- {
- return roiLen;
- }
-
- }
- /// Returns the parameters that are used in this class and implementing
- /// classes. It returns a 2D String array. Each of the 1D arrays is for a
- /// different option, and they have 3 elements. The first element is the
- /// option name, the second one is the synopsis, the third one is a long
- /// description of what the parameter is and the fourth is its default
- /// value. The synopsis or description may be 'null', in which case it is
- /// assumed that there is no synopsis or description of the option,
- /// respectively. Null may be returned if no options are supported.
- ///
- ///
- /// the options name, their synopsis and their explanation,
- /// or null if no options are supported.
- ///
- ///
- public static System.String[][] ParameterInfo
- {
- get
- {
- return pinfo;
- }
-
- }
-
- /// The prefix for packet encoding options: 'P'
- public const char OPT_PREFIX = 'P';
-
- /// The list of parameters that is accepted for packet encoding.
- //UPGRADE_NOTE: Final was removed from the declaration of 'pinfo'. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- private static readonly System.String[][] pinfo = new System.String[][] { new System.String[] { "Psop", "[] on|off" + "[ [] on|off ...]", "Specifies whether start of packet (SOP) markers should be used. " + "'on' enables, 'off' disables it.", "off" }, new System.String[] { "Peph", "[] on|off" + "[ [] on|off ...]", "Specifies whether end of packet header (EPH) markers should be " + " used. 'on' enables, 'off' disables it.", "off" } };
-
- /// The initial value for the lblock
- private const int INIT_LBLOCK = 3;
-
- /// The source object
- private CodedCBlkDataSrcEnc infoSrc;
-
- /// The encoder specs
- private EncoderSpecs encSpec;
-
- /// The tag tree for inclusion information. The indexes are outlined
- /// below. Note that the layer indexes start at 1, therefore, the layer
- /// index minus 1 is used. The subband indices are used as they are defined
- /// in the Subband class. The tile indices start at 0 and follow a
- /// lexicographical order.
- ///
- ///
- /// - 1st index: tile index, in lexicographical order
- /// - 2nd index: component index
- /// - 3rd index: resolution level
- /// - 4th index: precinct index
- /// - 5th index: subband index
- ///
- ///
- ///
- private TagTreeEncoder[][][][][] ttIncl;
-
- /// The tag tree for the maximum significant bit-plane. The indexes are
- /// outlined below. Note that the layer indexes start at 1, therefore, the
- /// layer index minus 1 is used. The subband indices are used as they are
- /// defined in the Subband class. The tile indices start at 0 and follow a
- /// lexicographical order.
- ///
- ///
- /// - 1st index: tile index, in lexicographical order
- /// - 2nd index: component index
- /// - 3rd index: resolution level
- /// - 4th index: precinct index
- /// - 5th index: subband index
- ///
- ///
- ///
- private TagTreeEncoder[][][][][] ttMaxBP;
-
- /// The base number of bits for sending code-block length information
- /// (referred as Lblock in the JPEG 2000 standard). The indexes are
- /// outlined below. Note that the layer indexes start at 1, therefore, the
- /// layer index minus 1 is used. The subband indices are used as they are
- /// defined in the Subband class. The tile indices start at 0 and follow a
- /// lexicographical order.
- ///
- ///
- /// - 1st index: tile index, in lexicographical order
- /// - 2nd index: component index
- /// - 3rd index: resolution level
- /// - 4th index: subband index
- /// - 5th index: code-block index, in lexicographical order
- ///
- ///
- ///
- private int[][][][][] lblock;
-
- /// The last encoded truncation point for each code-block. A negative value
- /// means that no information has been included for the block, yet. The
- /// indexes are outlined below. The subband indices are used as they are
- /// defined in the Subband class. The tile indices start at 0 and follow a
- /// lexicographical order. The code-block indices follow a lexicographical
- /// order within the subband tile.
- ///
- /// What is actually stored is the index of the element in
- /// CBlkRateDistStats.truncIdxs that gives the real truncation point.
- ///
- ///
- /// - 1st index: tile index, in lexicographical order
- /// - 2nd index: component index
- /// - 3rd index: resolution level
- /// - 4th index: subband index
- /// - 5th index: code-block index, in lexicographical order
- ///
- ///
- ///
- private int[][][][][] prevtIdxs;
-
- /// The saved base number of bits for sending code-block length
- /// information. It is used for restoring previous saved state by
- /// restore(). The indexes are outlined below. Note that the layer indexes
- /// start at 1, therefore, the layer index minus 1 is used. The subband
- /// indices are used as they are defined in the Subband class. The tile
- /// indices start at 0 and follow a lexicographical order.
- ///
- ///
- /// - 1st index: tile index, in lexicographical order
- /// - 2nd index: component index
- /// - 3rd index: resolution level
- /// - 4th index: subband index
- /// - 5th index: code-block index, in lexicographical order
- ///
- ///
- ///
- private int[][][][][] bak_lblock;
-
- /// The saved last encoded truncation point for each code-block. It is used
- /// for restoring previous saved state by restore(). A negative value means
- /// that no information has been included for the block, yet. The indexes
- /// are outlined below. The subband indices are used as they are defined in
- /// the Subband class. The tile indices start at 0 and follow a
- /// lexicographical order. The code-block indices follow a lexicographical
- /// order within the subband tile.
- ///
- ///
- /// - 1st index: tile index, in lexicographical order
- /// - 2nd index: component index
- /// - 3rd index: resolution level
- /// - 4th index: subband index
- /// - 5th index: code-block index, in lexicographical order
- ///
- ///
- ///
- private int[][][][][] bak_prevtIdxs;
-
- /// The body buffer of the last encoded packet
- private byte[] lbbuf;
-
- /// The body length of the last encoded packet
- private int lblen;
-
- /// The saved state
- private bool saved;
-
- /// Whether or not there is ROI information in the last encoded Packet
- private bool roiInPkt = false;
-
- /// Length to read in current packet body to get all the ROI information
- private int roiLen = 0;
-
- /// Array containing the coordinates, width, height, indexes, ... of the
- /// precincts.
- ///
- ///
- /// - 1st dim: tile index.
- /// - 2nd dim: component index.
- /// - 3rd dim: resolution level index.
- /// - 4th dim: precinct index.
- ///
- ///
- ///
- private PrecInfo[][][][] ppinfo;
-
- /// Whether or not the current packet is writable
- private bool packetWritable;
-
- /// Creates a new packet encoder object, using the information from the
- /// 'infoSrc' object.
- ///
- ///
- /// The source of information to construct the object.
- ///
- ///
- /// The encoding parameters.
- ///
- ///
- /// Maximum number of precincts in each tile, component
- /// and resolution level.
- ///
- ///
- /// ParameterList instance that holds command line options
- ///
- ///
- public PktEncoder(CodedCBlkDataSrcEnc infoSrc, EncoderSpecs encSpec, Coord[][][] numPrec, ParameterList pl)
- {
- this.infoSrc = infoSrc;
- this.encSpec = encSpec;
-
- // Check parameters
- pl.checkList(OPT_PREFIX, CSJ2K.j2k.util.ParameterList.toNameArray(pinfo));
-
- // Get number of components and tiles
- int nc = infoSrc.NumComps;
- int nt = infoSrc.getNumTiles();
-
- // Do initial allocation
- ttIncl = new TagTreeEncoder[nt][][][][];
- for (int i = 0; i < nt; i++)
- {
- ttIncl[i] = new TagTreeEncoder[nc][][][];
- }
- ttMaxBP = new TagTreeEncoder[nt][][][][];
- for (int i2 = 0; i2 < nt; i2++)
- {
- ttMaxBP[i2] = new TagTreeEncoder[nc][][][];
- }
- lblock = new int[nt][][][][];
- for (int i3 = 0; i3 < nt; i3++)
- {
- lblock[i3] = new int[nc][][][];
- }
- prevtIdxs = new int[nt][][][][];
- for (int i4 = 0; i4 < nt; i4++)
- {
- prevtIdxs[i4] = new int[nc][][][];
- }
- ppinfo = new PrecInfo[nt][][][];
- for (int i5 = 0; i5 < nt; i5++)
- {
- ppinfo[i5] = new PrecInfo[nc][][];
- }
-
- // Finish allocation
- SubbandAn root, sb;
- int maxs, mins;
- int mrl;
- //Coord tmpCoord = null;
- int numcb; // Number of code-blocks
- //System.Collections.ArrayList cblks = null;
- infoSrc.setTile(0, 0);
- for (int t = 0; t < nt; t++)
- {
- // Loop on tiles
- for (int c = 0; c < nc; c++)
- {
- // Loop on components
- // Get number of resolution levels
- root = infoSrc.getAnSubbandTree(t, c);
- mrl = root.resLvl;
-
- lblock[t][c] = new int[mrl + 1][][];
- ttIncl[t][c] = new TagTreeEncoder[mrl + 1][][];
- ttMaxBP[t][c] = new TagTreeEncoder[mrl + 1][][];
- prevtIdxs[t][c] = new int[mrl + 1][][];
- ppinfo[t][c] = new PrecInfo[mrl + 1][];
-
- for (int r = 0; r <= mrl; r++)
- {
- // Loop on resolution levels
- mins = (r == 0) ? 0 : 1;
- maxs = (r == 0) ? 1 : 4;
-
- int maxPrec = numPrec[t][c][r].x * numPrec[t][c][r].y;
-
- ttIncl[t][c][r] = new TagTreeEncoder[maxPrec][];
- for (int i6 = 0; i6 < maxPrec; i6++)
- {
- ttIncl[t][c][r][i6] = new TagTreeEncoder[maxs];
- }
- ttMaxBP[t][c][r] = new TagTreeEncoder[maxPrec][];
- for (int i7 = 0; i7 < maxPrec; i7++)
- {
- ttMaxBP[t][c][r][i7] = new TagTreeEncoder[maxs];
- }
- prevtIdxs[t][c][r] = new int[maxs][];
- lblock[t][c][r] = new int[maxs][];
-
- // Precincts and code-blocks
- ppinfo[t][c][r] = new PrecInfo[maxPrec];
- fillPrecInfo(t, c, r);
-
- for (int s = mins; s < maxs; s++)
- {
- // Loop on subbands
- sb = (SubbandAn)root.getSubbandByIdx(r, s);
- numcb = sb.numCb.x * sb.numCb.y;
-
- lblock[t][c][r][s] = new int[numcb];
- ArrayUtil.intArraySet(lblock[t][c][r][s], INIT_LBLOCK);
-
- prevtIdxs[t][c][r][s] = new int[numcb];
- ArrayUtil.intArraySet(prevtIdxs[t][c][r][s], -1);
- }
- }
- }
- if (t != nt - 1)
- infoSrc.nextTile();
- }
- }
-
- /// Retrives precincts and code-blocks coordinates in the given resolution,
- /// component and tile. It terminates TagTreeEncoder initialization as
- /// well.
- ///
- ///
- /// Tile index.
- ///
- ///
- /// Component index.
- ///
- ///
- /// Resolution level index.
- ///
- ///
- private void fillPrecInfo(int t, int c, int r)
- {
- if (ppinfo[t][c][r].Length == 0)
- return; // No precinct in this
- // resolution level
-
- Coord tileI = infoSrc.getTile(null);
- Coord nTiles = infoSrc.getNumTiles(null);
-
- int x0siz = infoSrc.ImgULX;
- int y0siz = infoSrc.ImgULY;
- int xsiz = x0siz + infoSrc.ImgWidth;
- int ysiz = y0siz + infoSrc.ImgHeight;
- int xt0siz = infoSrc.TilePartULX;
- int yt0siz = infoSrc.TilePartULY;
- int xtsiz = infoSrc.NomTileWidth;
- int ytsiz = infoSrc.NomTileHeight;
-
- int tx0 = (tileI.x == 0) ? x0siz : xt0siz + tileI.x * xtsiz;
- int ty0 = (tileI.y == 0) ? y0siz : yt0siz + tileI.y * ytsiz;
- int tx1 = (tileI.x != nTiles.x - 1) ? xt0siz + (tileI.x + 1) * xtsiz : xsiz;
- int ty1 = (tileI.y != nTiles.y - 1) ? yt0siz + (tileI.y + 1) * ytsiz : ysiz;
-
- int xrsiz = infoSrc.getCompSubsX(c);
- int yrsiz = infoSrc.getCompSubsY(c);
-
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- int tcx0 = (int)System.Math.Ceiling(tx0 / (double)(xrsiz));
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- int tcy0 = (int)System.Math.Ceiling(ty0 / (double)(yrsiz));
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- int tcx1 = (int)System.Math.Ceiling(tx1 / (double)(xrsiz));
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- int tcy1 = (int)System.Math.Ceiling(ty1 / (double)(yrsiz));
-
- int ndl = infoSrc.getAnSubbandTree(t, c).resLvl - r;
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- int trx0 = (int)System.Math.Ceiling(tcx0 / (double)(1 << ndl));
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- int try0 = (int)System.Math.Ceiling(tcy0 / (double)(1 << ndl));
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- int trx1 = (int)System.Math.Ceiling(tcx1 / (double)(1 << ndl));
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- int try1 = (int)System.Math.Ceiling(tcy1 / (double)(1 << ndl));
-
- int cb0x = infoSrc.CbULX;
- int cb0y = infoSrc.CbULY;
-
- double twoppx = (double)encSpec.pss.getPPX(t, c, r);
- double twoppy = (double)encSpec.pss.getPPY(t, c, r);
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- int twoppx2 = (int)(twoppx / 2);
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- int twoppy2 = (int)(twoppy / 2);
-
- // Precincts are located at (cb0x+i*twoppx,cb0y+j*twoppy)
- // Valid precincts are those which intersect with the current
- // resolution level
- int maxPrec = ppinfo[t][c][r].Length;
- int nPrec = 0;
-
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- int istart = (int)System.Math.Floor((try0 - cb0y) / twoppy);
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- int iend = (int)System.Math.Floor((try1 - 1 - cb0y) / twoppy);
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- int jstart = (int)System.Math.Floor((trx0 - cb0x) / twoppx);
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- int jend = (int)System.Math.Floor((trx1 - 1 - cb0x) / twoppx);
-
- int acb0x, acb0y;
-
- SubbandAn root = infoSrc.getAnSubbandTree(t, c);
- SubbandAn sb = null;
-
- int p0x, p0y, p1x, p1y; // Precinct projection in subband
- int s0x, s0y, s1x, s1y; // Active subband portion
- int cw, ch;
- int kstart, kend, lstart, lend, k0, l0;
- int prg_ulx, prg_uly;
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- int prg_w = (int)twoppx << ndl;
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- int prg_h = (int)twoppy << ndl;
-
- CBlkCoordInfo cb;
-
- for (int i = istart; i <= iend; i++)
- {
- // Vertical precincts
- for (int j = jstart; j <= jend; j++, nPrec++)
- {
- // Horizontal precincts
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- if (j == jstart && (trx0 - cb0x) % (xrsiz * ((int)twoppx)) != 0)
- {
- prg_ulx = tx0;
- }
- else
- {
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- prg_ulx = cb0x + j * xrsiz * ((int)twoppx << ndl);
- }
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- if (i == istart && (try0 - cb0y) % (yrsiz * ((int)twoppy)) != 0)
- {
- prg_uly = ty0;
- }
- else
- {
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- prg_uly = cb0y + i * yrsiz * ((int)twoppy << ndl);
- }
-
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- ppinfo[t][c][r][nPrec] = new PrecInfo(r, (int)(cb0x + j * twoppx), (int)(cb0y + i * twoppy), (int)twoppx, (int)twoppy, prg_ulx, prg_uly, prg_w, prg_h);
-
- if (r == 0)
- {
- // LL subband
- acb0x = cb0x;
- acb0y = cb0y;
-
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- p0x = acb0x + j * (int)twoppx;
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- p1x = p0x + (int)twoppx;
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- p0y = acb0y + i * (int)twoppy;
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- p1y = p0y + (int)twoppy;
-
- sb = (SubbandAn)root.getSubbandByIdx(0, 0);
- s0x = (p0x < sb.ulcx) ? sb.ulcx : p0x;
- s1x = (p1x > sb.ulcx + sb.w) ? sb.ulcx + sb.w : p1x;
- s0y = (p0y < sb.ulcy) ? sb.ulcy : p0y;
- s1y = (p1y > sb.ulcy + sb.h) ? sb.ulcy + sb.h : p1y;
-
- // Code-blocks are located at (acb0x+k*cw,acb0y+l*ch)
- cw = sb.nomCBlkW;
- ch = sb.nomCBlkH;
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- k0 = (int)System.Math.Floor((sb.ulcy - acb0y) / (double)ch);
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- kstart = (int)System.Math.Floor((s0y - acb0y) / (double)ch);
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- kend = (int)System.Math.Floor((s1y - 1 - acb0y) / (double)ch);
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- l0 = (int)System.Math.Floor((sb.ulcx - acb0x) / (double)cw);
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- lstart = (int)System.Math.Floor((s0x - acb0x) / (double)cw);
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- lend = (int)System.Math.Floor((s1x - 1 - acb0x) / (double)cw);
-
- if (s1x - s0x <= 0 || s1y - s0y <= 0)
- {
- ppinfo[t][c][r][nPrec].nblk[0] = 0;
- ttIncl[t][c][r][nPrec][0] = new TagTreeEncoder(0, 0);
- ttMaxBP[t][c][r][nPrec][0] = new TagTreeEncoder(0, 0);
- }
- else
- {
- ttIncl[t][c][r][nPrec][0] = new TagTreeEncoder(kend - kstart + 1, lend - lstart + 1);
- ttMaxBP[t][c][r][nPrec][0] = new TagTreeEncoder(kend - kstart + 1, lend - lstart + 1);
- CBlkCoordInfo[][] tmpArray = new CBlkCoordInfo[kend - kstart + 1][];
- for (int i2 = 0; i2 < kend - kstart + 1; i2++)
- {
- tmpArray[i2] = new CBlkCoordInfo[lend - lstart + 1];
- }
- ppinfo[t][c][r][nPrec].cblk[0] = tmpArray;
- ppinfo[t][c][r][nPrec].nblk[0] = (kend - kstart + 1) * (lend - lstart + 1);
-
- for (int k = kstart; k <= kend; k++)
- {
- // Vertical cblks
- for (int l = lstart; l <= lend; l++)
- {
- // Horiz. cblks
-
- cb = new CBlkCoordInfo(k - k0, l - l0);
- ppinfo[t][c][r][nPrec].cblk[0][k - kstart][l - lstart] = cb;
- } // Horizontal code-blocks
- } // Vertical code-blocks
- }
- }
- else
- {
- // HL, LH and HH subbands
- // HL subband
- acb0x = 0;
- acb0y = cb0y;
-
- p0x = acb0x + j * twoppx2;
- p1x = p0x + twoppx2;
- p0y = acb0y + i * twoppy2;
- p1y = p0y + twoppy2;
-
- sb = (SubbandAn)root.getSubbandByIdx(r, 1);
- s0x = (p0x < sb.ulcx) ? sb.ulcx : p0x;
- s1x = (p1x > sb.ulcx + sb.w) ? sb.ulcx + sb.w : p1x;
- s0y = (p0y < sb.ulcy) ? sb.ulcy : p0y;
- s1y = (p1y > sb.ulcy + sb.h) ? sb.ulcy + sb.h : p1y;
-
- // Code-blocks are located at (acb0x+k*cw,acb0y+l*ch)
- cw = sb.nomCBlkW;
- ch = sb.nomCBlkH;
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- k0 = (int)System.Math.Floor((sb.ulcy - acb0y) / (double)ch);
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- kstart = (int)System.Math.Floor((s0y - acb0y) / (double)ch);
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- kend = (int)System.Math.Floor((s1y - 1 - acb0y) / (double)ch);
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- l0 = (int)System.Math.Floor((sb.ulcx - acb0x) / (double)cw);
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- lstart = (int)System.Math.Floor((s0x - acb0x) / (double)cw);
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- lend = (int)System.Math.Floor((s1x - 1 - acb0x) / (double)cw);
-
- if (s1x - s0x <= 0 || s1y - s0y <= 0)
- {
- ppinfo[t][c][r][nPrec].nblk[1] = 0;
- ttIncl[t][c][r][nPrec][1] = new TagTreeEncoder(0, 0);
- ttMaxBP[t][c][r][nPrec][1] = new TagTreeEncoder(0, 0);
- }
- else
- {
- ttIncl[t][c][r][nPrec][1] = new TagTreeEncoder(kend - kstart + 1, lend - lstart + 1);
- ttMaxBP[t][c][r][nPrec][1] = new TagTreeEncoder(kend - kstart + 1, lend - lstart + 1);
- CBlkCoordInfo[][] tmpArray2 = new CBlkCoordInfo[kend - kstart + 1][];
- for (int i3 = 0; i3 < kend - kstart + 1; i3++)
- {
- tmpArray2[i3] = new CBlkCoordInfo[lend - lstart + 1];
- }
- ppinfo[t][c][r][nPrec].cblk[1] = tmpArray2;
- ppinfo[t][c][r][nPrec].nblk[1] = (kend - kstart + 1) * (lend - lstart + 1);
-
- for (int k = kstart; k <= kend; k++)
- {
- // Vertical cblks
- for (int l = lstart; l <= lend; l++)
- {
- // Horiz. cblks
- cb = new CBlkCoordInfo(k - k0, l - l0);
- ppinfo[t][c][r][nPrec].cblk[1][k - kstart][l - lstart] = cb;
- } // Horizontal code-blocks
- } // Vertical code-blocks
- }
-
- // LH subband
- acb0x = cb0x;
- acb0y = 0;
-
- p0x = acb0x + j * twoppx2;
- p1x = p0x + twoppx2;
- p0y = acb0y + i * twoppy2;
- p1y = p0y + twoppy2;
-
- sb = (SubbandAn)root.getSubbandByIdx(r, 2);
- s0x = (p0x < sb.ulcx) ? sb.ulcx : p0x;
- s1x = (p1x > sb.ulcx + sb.w) ? sb.ulcx + sb.w : p1x;
- s0y = (p0y < sb.ulcy) ? sb.ulcy : p0y;
- s1y = (p1y > sb.ulcy + sb.h) ? sb.ulcy + sb.h : p1y;
-
- // Code-blocks are located at (acb0x+k*cw,acb0y+l*ch)
- cw = sb.nomCBlkW;
- ch = sb.nomCBlkH;
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- k0 = (int)System.Math.Floor((sb.ulcy - acb0y) / (double)ch);
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- kstart = (int)System.Math.Floor((s0y - acb0y) / (double)ch);
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- kend = (int)System.Math.Floor((s1y - 1 - acb0y) / (double)ch);
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- l0 = (int)System.Math.Floor((sb.ulcx - acb0x) / (double)cw);
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- lstart = (int)System.Math.Floor((s0x - acb0x) / (double)cw);
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- lend = (int)System.Math.Floor((s1x - 1 - acb0x) / (double)cw);
-
- if (s1x - s0x <= 0 || s1y - s0y <= 0)
- {
- ppinfo[t][c][r][nPrec].nblk[2] = 0;
- ttIncl[t][c][r][nPrec][2] = new TagTreeEncoder(0, 0);
- ttMaxBP[t][c][r][nPrec][2] = new TagTreeEncoder(0, 0);
- }
- else
- {
- ttIncl[t][c][r][nPrec][2] = new TagTreeEncoder(kend - kstart + 1, lend - lstart + 1);
- ttMaxBP[t][c][r][nPrec][2] = new TagTreeEncoder(kend - kstart + 1, lend - lstart + 1);
- CBlkCoordInfo[][] tmpArray3 = new CBlkCoordInfo[kend - kstart + 1][];
- for (int i4 = 0; i4 < kend - kstart + 1; i4++)
- {
- tmpArray3[i4] = new CBlkCoordInfo[lend - lstart + 1];
- }
- ppinfo[t][c][r][nPrec].cblk[2] = tmpArray3;
- ppinfo[t][c][r][nPrec].nblk[2] = (kend - kstart + 1) * (lend - lstart + 1);
-
- for (int k = kstart; k <= kend; k++)
- {
- // Vertical cblks
- for (int l = lstart; l <= lend; l++)
- {
- // Horiz cblks
- cb = new CBlkCoordInfo(k - k0, l - l0);
- ppinfo[t][c][r][nPrec].cblk[2][k - kstart][l - lstart] = cb;
- } // Horizontal code-blocks
- } // Vertical code-blocks
- }
-
- // HH subband
- acb0x = 0;
- acb0y = 0;
-
- p0x = acb0x + j * twoppx2;
- p1x = p0x + twoppx2;
- p0y = acb0y + i * twoppy2;
- p1y = p0y + twoppy2;
-
- sb = (SubbandAn)root.getSubbandByIdx(r, 3);
- s0x = (p0x < sb.ulcx) ? sb.ulcx : p0x;
- s1x = (p1x > sb.ulcx + sb.w) ? sb.ulcx + sb.w : p1x;
- s0y = (p0y < sb.ulcy) ? sb.ulcy : p0y;
- s1y = (p1y > sb.ulcy + sb.h) ? sb.ulcy + sb.h : p1y;
-
- // Code-blocks are located at (acb0x+k*cw,acb0y+l*ch)
- cw = sb.nomCBlkW;
- ch = sb.nomCBlkH;
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- k0 = (int)System.Math.Floor((sb.ulcy - acb0y) / (double)ch);
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- kstart = (int)System.Math.Floor((s0y - acb0y) / (double)ch);
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- kend = (int)System.Math.Floor((s1y - 1 - acb0y) / (double)ch);
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- l0 = (int)System.Math.Floor((sb.ulcx - acb0x) / (double)cw);
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- lstart = (int)System.Math.Floor((s0x - acb0x) / (double)cw);
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- lend = (int)System.Math.Floor((s1x - 1 - acb0x) / (double)cw);
-
- if (s1x - s0x <= 0 || s1y - s0y <= 0)
- {
- ppinfo[t][c][r][nPrec].nblk[3] = 0;
- ttIncl[t][c][r][nPrec][3] = new TagTreeEncoder(0, 0);
- ttMaxBP[t][c][r][nPrec][3] = new TagTreeEncoder(0, 0);
- }
- else
- {
- ttIncl[t][c][r][nPrec][3] = new TagTreeEncoder(kend - kstart + 1, lend - lstart + 1);
- ttMaxBP[t][c][r][nPrec][3] = new TagTreeEncoder(kend - kstart + 1, lend - lstart + 1);
- CBlkCoordInfo[][] tmpArray4 = new CBlkCoordInfo[kend - kstart + 1][];
- for (int i5 = 0; i5 < kend - kstart + 1; i5++)
- {
- tmpArray4[i5] = new CBlkCoordInfo[lend - lstart + 1];
- }
- ppinfo[t][c][r][nPrec].cblk[3] = tmpArray4;
- ppinfo[t][c][r][nPrec].nblk[3] = (kend - kstart + 1) * (lend - lstart + 1);
-
- for (int k = kstart; k <= kend; k++)
- {
- // Vertical cblks
- for (int l = lstart; l <= lend; l++)
- {
- // Horiz cblks
- cb = new CBlkCoordInfo(k - k0, l - l0);
- ppinfo[t][c][r][nPrec].cblk[3][k - kstart][l - lstart] = cb;
- } // Horizontal code-blocks
- } // Vertical code-blocks
- }
- }
- } // Horizontal precincts
- } // Vertical precincts
- }
-
- /// Encodes a packet and returns the buffer containing the encoded packet
- /// header. The code-blocks appear in a 3D array of CBlkRateDistStats,
- /// 'cbs'. The first index is the tile index in lexicographical order, the
- /// second index is the subband index (as defined in the Subband class),
- /// and the third index is the code-block index (whithin the subband tile)
- /// in lexicographical order as well. The indexes of the new truncation
- /// points for each code-block are specified by the 3D array of int
- /// 'tIndx'. The indices of this array are the same as for cbs. The
- /// truncation point indices in 'tIndx' are the indices of the elements of
- /// the 'truncIdxs' array, of the CBlkRateDistStats class, that give the
- /// real truncation points. If a truncation point index is negative it
- /// means that the code-block has not been included in any layer yet. If
- /// the truncation point is less than or equal to the highest truncation
- /// point used in previous layers then the code-block is not included in
- /// the packet. Otherwise, if larger, the code-block is included in the
- /// packet. The body of the packet can be obtained with the
- /// getLastBodyBuf() and getLastBodyLen() methods.
- ///
- /// Layers must be coded in increasing order, in consecutive manner, for
- /// each tile, component and resolution level (e.g., layer 1, then layer 2,
- /// etc.). For different tile, component and/or resolution level no
- /// particular order must be followed.
- ///
- ///
- /// The layer index (starts at 1).
- ///
- ///
- /// The component index.
- ///
- ///
- /// The resolution level
- ///
- ///
- /// Index of the current tile
- ///
- ///
- /// The 3D array of coded code-blocks.
- ///
- ///
- /// The truncation point indices for each code-block.
- ///
- ///
- /// The header buffer. If null a new BitOutputBuffer is created
- /// and returned. This buffer is reset before anything is written to it.
- ///
- ///
- /// The body buffer. If null a new one is created. If not large
- /// enough a new one is created.
- ///
- ///
- /// The precinct index.
- ///
- ///
- /// The buffer containing the packet header.
- ///
- ///
- public virtual BitOutputBuffer encodePacket(int ly, int c, int r, int t, CBlkRateDistStats[][] cbs, int[][] tIndx, BitOutputBuffer hbuf, byte[] bbuf, int pIdx)
- {
- int b, i, maxi;
- int ncb;
- int thmax;
- int newtp;
- int cblen;
- int prednbits, nbits; // deltabits removed
- TagTreeEncoder cur_ttIncl, cur_ttMaxBP; // inclusion and bit-depth tag
- // trees
- int[] cur_prevtIdxs; // last encoded truncation points
- CBlkRateDistStats[] cur_cbs;
- int[] cur_tIndx; // truncation points to encode
- int minsb = (r == 0) ? 0 : 1;
- int maxsb = (r == 0) ? 1 : 4;
- Coord cbCoord = null;
- SubbandAn root = infoSrc.getAnSubbandTree(t, c);
- SubbandAn sb;
- roiInPkt = false;
- roiLen = 0;
- int mend, nend;
-
- // Checks if a precinct with such an index exists in this resolution
- // level
- if (pIdx >= ppinfo[t][c][r].Length)
- {
- packetWritable = false;
- return hbuf;
- }
- PrecInfo prec = ppinfo[t][c][r][pIdx];
-
- // First, we check if packet is empty (i.e precinct 'pIdx' has no
- // code-block in any of the subbands)
- bool isPrecVoid = true;
-
- for (int s = minsb; s < maxsb; s++)
- {
- if (prec.nblk[s] == 0)
- {
- // The precinct has no code-block in this subband.
- continue;
- }
- else
- {
- // The precinct is not empty in at least one subband ->
- // stop
- isPrecVoid = false;
- break;
- }
- }
-
- if (isPrecVoid)
- {
- packetWritable = true;
-
- if (hbuf == null)
- {
- hbuf = new BitOutputBuffer();
- }
- else
- {
- hbuf.reset();
- }
- if (bbuf == null)
- {
- lbbuf = bbuf = new byte[1];
- }
- hbuf.writeBit(0);
- lblen = 0;
-
- return hbuf;
- }
-
- if (hbuf == null)
- {
- hbuf = new BitOutputBuffer();
- }
- else
- {
- hbuf.reset();
- }
-
- // Invalidate last body buffer
- lbbuf = null;
- lblen = 0;
-
- // Signal that packet is present
- hbuf.writeBit(1);
-
- for (int s = minsb; s < maxsb; s++)
- {
- // Loop on subbands
- sb = (SubbandAn)root.getSubbandByIdx(r, s);
-
- // Go directly to next subband if the precinct has no code-block
- // in the current one.
- if (prec.nblk[s] == 0)
- {
- continue;
- }
-
- cur_ttIncl = ttIncl[t][c][r][pIdx][s];
- cur_ttMaxBP = ttMaxBP[t][c][r][pIdx][s];
- cur_prevtIdxs = prevtIdxs[t][c][r][s];
- cur_cbs = cbs[s];
- cur_tIndx = tIndx[s];
-
- // Set tag tree values for code-blocks in this precinct
- mend = (prec.cblk[s] == null) ? 0 : prec.cblk[s].Length;
- for (int m = 0; m < mend; m++)
- {
- nend = (prec.cblk[s][m] == null) ? 0 : prec.cblk[s][m].Length;
- for (int n = 0; n < nend; n++)
- {
- cbCoord = prec.cblk[s][m][n].idx;
- b = cbCoord.x + cbCoord.y * sb.numCb.x;
-
- if (cur_tIndx[b] > cur_prevtIdxs[b] && cur_prevtIdxs[b] < 0)
- {
- // First inclusion
- cur_ttIncl.setValue(m, n, ly - 1);
- }
- if (ly == 1)
- {
- // First layer, need to set the skip of MSBP
- cur_ttMaxBP.setValue(m, n, cur_cbs[b].skipMSBP);
- }
- }
- }
-
- // Now encode the information
- for (int m = 0; m < prec.cblk[s].Length; m++)
- {
- // Vertical code-blocks
- for (int n = 0; n < prec.cblk[s][m].Length; n++)
- {
- // Horiz. cblks
- cbCoord = prec.cblk[s][m][n].idx;
- b = cbCoord.x + cbCoord.y * sb.numCb.x;
-
- // 1) Inclusion information
- if (cur_tIndx[b] > cur_prevtIdxs[b])
- {
- // Code-block included in this layer
- if (cur_prevtIdxs[b] < 0)
- {
- // First inclusion
- // Encode layer info
- cur_ttIncl.encode(m, n, ly, hbuf);
-
- // 2) Max bitdepth info. Encode value
- thmax = cur_cbs[b].skipMSBP + 1;
- for (i = 1; i <= thmax; i++)
- {
- cur_ttMaxBP.encode(m, n, i, hbuf);
- }
-
- // Count body size for packet
- lblen += cur_cbs[b].truncRates[cur_cbs[b].truncIdxs[cur_tIndx[b]]];
- }
- else
- {
- // Already in previous layer
- // Send "1" bit
- hbuf.writeBit(1);
- // Count body size for packet
- lblen += cur_cbs[b].truncRates[cur_cbs[b].truncIdxs[cur_tIndx[b]]] - cur_cbs[b].truncRates[cur_cbs[b].truncIdxs[cur_prevtIdxs[b]]];
- }
-
- // 3) Truncation point information
- if (cur_prevtIdxs[b] < 0)
- {
- newtp = cur_cbs[b].truncIdxs[cur_tIndx[b]];
- }
- else
- {
- newtp = cur_cbs[b].truncIdxs[cur_tIndx[b]] - cur_cbs[b].truncIdxs[cur_prevtIdxs[b]] - 1;
- }
-
- // Mix of switch and if is faster
- switch (newtp)
- {
-
- case 0:
- hbuf.writeBit(0); // Send one "0" bit
- break;
-
- case 1:
- hbuf.writeBits(2, 2); // Send one "1" and one "0"
- break;
-
- case 2:
- case 3:
- case 4:
- // Send two "1" bits followed by 2 bits
- // representation of newtp-2
- hbuf.writeBits((3 << 2) | (newtp - 2), 4);
- break;
-
- default:
- if (newtp <= 35)
- {
- // Send four "1" bits followed by a five bits
- // representation of newtp-5
- hbuf.writeBits((15 << 5) | (newtp - 5), 9);
- }
- else if (newtp <= 163)
- {
- // Send nine "1" bits followed by a seven bits
- // representation of newtp-36
- hbuf.writeBits((511 << 7) | (newtp - 36), 16);
- }
- else
- {
- throw new System.ArithmeticException("Maximum number " + "of truncation " + "points exceeded");
- }
- break;
-
- }
- }
- else
- {
- // Block not included in this layer
- if (cur_prevtIdxs[b] >= 0)
- {
- // Already in previous layer. Send "0" bit
- hbuf.writeBit(0);
- }
- else
- {
- // Not in any previous layers
- cur_ttIncl.encode(m, n, ly, hbuf);
- }
- // Go to the next one.
- continue;
- }
-
- // Code-block length
-
- // We need to compute the maximum number of bits needed to
- // signal the length of each terminated segment and the
- // final truncation point.
- newtp = 1;
- maxi = cur_cbs[b].truncIdxs[cur_tIndx[b]];
- cblen = (cur_prevtIdxs[b] < 0) ? 0 : cur_cbs[b].truncRates[cur_cbs[b].truncIdxs[cur_prevtIdxs[b]]];
-
- // Loop on truncation points
- i = (cur_prevtIdxs[b] < 0) ? 0 : cur_cbs[b].truncIdxs[cur_prevtIdxs[b]] + 1;
- int minbits = 0;
- for (; i < maxi; i++, newtp++)
- {
- // If terminated truncation point calculate length
- if (cur_cbs[b].isTermPass != null && cur_cbs[b].isTermPass[i])
- {
-
- // Calculate length
- cblen = cur_cbs[b].truncRates[i] - cblen;
-
- // Calculate number of needed bits
- prednbits = lblock[t][c][r][s][b] + MathUtil.log2(newtp);
- minbits = ((cblen > 0) ? MathUtil.log2(cblen) : 0) + 1;
-
- // Update Lblock increment if needed
- for (int j = prednbits; j < minbits; j++)
- {
- lblock[t][c][r][s][b]++;
- hbuf.writeBit(1);
- }
- // Initialize for next length
- newtp = 0;
- cblen = cur_cbs[b].truncRates[i];
- }
- }
-
- // Last truncation point length always sent
-
- // Calculate length
- cblen = cur_cbs[b].truncRates[i] - cblen;
-
- // Calculate number of bits
- prednbits = lblock[t][c][r][s][b] + MathUtil.log2(newtp);
- minbits = ((cblen > 0) ? MathUtil.log2(cblen) : 0) + 1;
- // Update Lblock increment if needed
- for (int j = prednbits; j < minbits; j++)
- {
- lblock[t][c][r][s][b]++;
- hbuf.writeBit(1);
- }
-
- // End of comma-code increment
- hbuf.writeBit(0);
-
- // There can be terminated several segments, send length
- // info for all terminated truncation points in addition
- // to final one
- newtp = 1;
- maxi = cur_cbs[b].truncIdxs[cur_tIndx[b]];
- cblen = (cur_prevtIdxs[b] < 0) ? 0 : cur_cbs[b].truncRates[cur_cbs[b].truncIdxs[cur_prevtIdxs[b]]];
- // Loop on truncation points and count the groups
- i = (cur_prevtIdxs[b] < 0) ? 0 : cur_cbs[b].truncIdxs[cur_prevtIdxs[b]] + 1;
- for (; i < maxi; i++, newtp++)
- {
- // If terminated truncation point, send length
- if (cur_cbs[b].isTermPass != null && cur_cbs[b].isTermPass[i])
- {
-
- cblen = cur_cbs[b].truncRates[i] - cblen;
- nbits = MathUtil.log2(newtp) + lblock[t][c][r][s][b];
- hbuf.writeBits(cblen, nbits);
-
- // Initialize for next length
- newtp = 0;
- cblen = cur_cbs[b].truncRates[i];
- }
- }
- // Last truncation point length is always signalled
- // First calculate number of bits needed to signal
- // Calculate length
- cblen = cur_cbs[b].truncRates[i] - cblen;
- nbits = MathUtil.log2(newtp) + lblock[t][c][r][s][b];
- hbuf.writeBits(cblen, nbits);
- } // End loop on horizontal code-blocks
- } // End loop on vertical code-blocks
- } // End loop on subband
-
- // -> Copy the data to the body buffer
-
- // Ensure size for body data
- if (bbuf == null || bbuf.Length < lblen)
- {
- bbuf = new byte[lblen];
- }
- lbbuf = bbuf;
- lblen = 0;
-
- for (int s = minsb; s < maxsb; s++)
- {
- // Loop on subbands
- sb = (SubbandAn)root.getSubbandByIdx(r, s);
-
- cur_prevtIdxs = prevtIdxs[t][c][r][s];
- cur_cbs = cbs[s];
- cur_tIndx = tIndx[s];
- ncb = cur_prevtIdxs.Length;
-
- mend = (prec.cblk[s] == null) ? 0 : prec.cblk[s].Length;
- for (int m = 0; m < mend; m++)
- {
- // Vertical code-blocks
- nend = (prec.cblk[s][m] == null) ? 0 : prec.cblk[s][m].Length;
- for (int n = 0; n < nend; n++)
- {
- // Horiz. cblks
- cbCoord = prec.cblk[s][m][n].idx;
- b = cbCoord.x + cbCoord.y * sb.numCb.x;
-
- if (cur_tIndx[b] > cur_prevtIdxs[b])
- {
-
- // Block included in this precinct -> Copy data to
- // body buffer and get code-size
- if (cur_prevtIdxs[b] < 0)
- {
- cblen = cur_cbs[b].truncRates[cur_cbs[b].truncIdxs[cur_tIndx[b]]];
- 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]]];
- Array.Copy(cur_cbs[b].data, cur_cbs[b].truncRates[cur_cbs[b].truncIdxs[cur_prevtIdxs[b]]], lbbuf, lblen, cblen);
- }
- lblen += cblen;
-
- // Verifies if this code-block contains new ROI
- // information
- if (cur_cbs[b].nROIcoeff != 0 && (cur_prevtIdxs[b] == -1 || cur_cbs[b].truncIdxs[cur_prevtIdxs[b]] <= cur_cbs[b].nROIcp - 1))
- {
- roiInPkt = true;
- roiLen = lblen;
- }
-
- // Update truncation point
- cur_prevtIdxs[b] = cur_tIndx[b];
- }
- } // End loop on horizontal code-blocks
- } // End loop on vertical code-blocks
- } // End loop on subbands
-
- packetWritable = true;
-
- // Must never happen
- if (hbuf.Length == 0)
- {
- throw new System.ApplicationException("You have found a bug in PktEncoder, method:" + " encodePacket");
- }
-
- return hbuf;
- }
-
- /// Saves the current state of this object. The last saved state
- /// can be restored with the restore() method.
- ///
- ///
- ///
- ///
- ///
- public virtual void save()
- {
- int maxsbi, minsbi;
-
- // Have we done any save yet?
- if (bak_lblock == null)
- {
- // Allocate backup buffers
- bak_lblock = new int[ttIncl.Length][][][][];
- bak_prevtIdxs = new int[ttIncl.Length][][][][];
- for (int t = ttIncl.Length - 1; t >= 0; t--)
- {
- bak_lblock[t] = new int[ttIncl[t].Length][][][];
- bak_prevtIdxs[t] = new int[ttIncl[t].Length][][][];
- for (int c = ttIncl[t].Length - 1; c >= 0; c--)
- {
- bak_lblock[t][c] = new int[lblock[t][c].Length][][];
- bak_prevtIdxs[t][c] = new int[ttIncl[t][c].Length][][];
- for (int r = lblock[t][c].Length - 1; r >= 0; r--)
- {
- bak_lblock[t][c][r] = new int[lblock[t][c][r].Length][];
- bak_prevtIdxs[t][c][r] = new int[prevtIdxs[t][c][r].Length][];
- minsbi = (r == 0) ? 0 : 1;
- maxsbi = (r == 0) ? 1 : 4;
- for (int s = minsbi; s < maxsbi; s++)
- {
- bak_lblock[t][c][r][s] = new int[lblock[t][c][r][s].Length];
- bak_prevtIdxs[t][c][r][s] = new int[prevtIdxs[t][c][r][s].Length];
- }
- }
- }
- }
- }
-
- //-- Save the data
-
- // Use reference caches to minimize array access overhead
- TagTreeEncoder[][][] ttIncl_t_c, ttMaxBP_t_c;
- TagTreeEncoder[][] ttIncl_t_c_r, ttMaxBP_t_c_r;
- int[][][] lblock_t_c, bak_lblock_t_c;
- int[][] prevtIdxs_t_c_r, bak_prevtIdxs_t_c_r;
-
- // Loop on tiles
- for (int t = ttIncl.Length - 1; t >= 0; t--)
- {
- // Loop on components
- for (int c = ttIncl[t].Length - 1; c >= 0; c--)
- {
- // Initialize reference caches
- lblock_t_c = lblock[t][c];
- bak_lblock_t_c = bak_lblock[t][c];
- ttIncl_t_c = ttIncl[t][c];
- ttMaxBP_t_c = ttMaxBP[t][c];
- // Loop on resolution levels
- for (int r = lblock_t_c.Length - 1; r >= 0; r--)
- {
- // Initialize reference caches
- ttIncl_t_c_r = ttIncl_t_c[r];
- ttMaxBP_t_c_r = ttMaxBP_t_c[r];
- prevtIdxs_t_c_r = prevtIdxs[t][c][r];
- bak_prevtIdxs_t_c_r = bak_prevtIdxs[t][c][r];
-
- // Loop on subbands
- minsbi = (r == 0) ? 0 : 1;
- maxsbi = (r == 0) ? 1 : 4;
- for (int s = minsbi; s < maxsbi; s++)
- {
- // Save 'lblock'
- Array.Copy(lblock_t_c[r][s], 0, bak_lblock_t_c[r][s], 0, lblock_t_c[r][s].Length);
- // Save 'prevtIdxs'
- 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
- for (int p = ppinfo[t][c][r].Length - 1; p >= 0; p--)
- {
- if (p < ttIncl_t_c_r.Length)
- {
- // Loop on subbands
- for (int s = minsbi; s < maxsbi; s++)
- {
- ttIncl_t_c_r[p][s].save();
- ttMaxBP_t_c_r[p][s].save();
- } // End loop on subbands
- }
- } // End loop on precincts
- } // End loop on resolutions
- } // End loop on components
- } // End loop on tiles
-
- // Set the saved state
- saved = true;
- }
-
- /// Restores the last saved state of this object. An
- /// IllegalArgumentException is thrown if no state has been saved.
- ///
- ///
- ///
- ///
- ///
- public virtual void restore()
- {
- int maxsbi, minsbi;
-
- if (!saved)
- {
- throw new System.ArgumentException();
- }
-
- // Invalidate last encoded body buffer
- lbbuf = null;
-
- //-- Restore tha data
-
- // Use reference caches to minimize array access overhead
- TagTreeEncoder[][][] ttIncl_t_c, ttMaxBP_t_c;
- TagTreeEncoder[][] ttIncl_t_c_r, ttMaxBP_t_c_r;
- int[][][] lblock_t_c, bak_lblock_t_c;
- int[][] prevtIdxs_t_c_r, bak_prevtIdxs_t_c_r;
-
- // Loop on tiles
- for (int t = ttIncl.Length - 1; t >= 0; t--)
- {
- // Loop on components
- for (int c = ttIncl[t].Length - 1; c >= 0; c--)
- {
- // Initialize reference caches
- lblock_t_c = lblock[t][c];
- bak_lblock_t_c = bak_lblock[t][c];
- ttIncl_t_c = ttIncl[t][c];
- ttMaxBP_t_c = ttMaxBP[t][c];
- // Loop on resolution levels
- for (int r = lblock_t_c.Length - 1; r >= 0; r--)
- {
- // Initialize reference caches
- ttIncl_t_c_r = ttIncl_t_c[r];
- ttMaxBP_t_c_r = ttMaxBP_t_c[r];
- prevtIdxs_t_c_r = prevtIdxs[t][c][r];
- bak_prevtIdxs_t_c_r = bak_prevtIdxs[t][c][r];
-
- // Loop on subbands
- minsbi = (r == 0) ? 0 : 1;
- maxsbi = (r == 0) ? 1 : 4;
- for (int s = minsbi; s < maxsbi; s++)
- {
- // Restore 'lblock'
- Array.Copy(bak_lblock_t_c[r][s], 0, lblock_t_c[r][s], 0, lblock_t_c[r][s].Length);
- // Restore 'prevtIdxs'
- 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
- for (int p = ppinfo[t][c][r].Length - 1; p >= 0; p--)
- {
- if (p < ttIncl_t_c_r.Length)
- {
- // Loop on subbands
- for (int s = minsbi; s < maxsbi; s++)
- {
- ttIncl_t_c_r[p][s].restore();
- ttMaxBP_t_c_r[p][s].restore();
- } // End loop on subbands
- }
- } // End loop on precincts
- } // End loop on resolution levels
- } // End loop on components
- } // End loop on tiles
- }
-
- /// Resets the state of the object to the initial state, as if the object
- /// was just created.
- ///
- ///
- public virtual void reset()
- {
- int maxsbi, minsbi;
-
- // Invalidate save
- saved = false;
- // Invalidate last encoded body buffer
- lbbuf = null;
-
- // Reinitialize each element in the arrays
-
- // Use reference caches to minimize array access overhead
- TagTreeEncoder[][][] ttIncl_t_c, ttMaxBP_t_c;
- TagTreeEncoder[][] ttIncl_t_c_r, ttMaxBP_t_c_r;
- int[][][] lblock_t_c;
- int[][] prevtIdxs_t_c_r;
-
- // Loop on tiles
- for (int t = ttIncl.Length - 1; t >= 0; t--)
- {
- // Loop on components
- for (int c = ttIncl[t].Length - 1; c >= 0; c--)
- {
- // Initialize reference caches
- lblock_t_c = lblock[t][c];
- ttIncl_t_c = ttIncl[t][c];
- ttMaxBP_t_c = ttMaxBP[t][c];
- // Loop on resolution levels
- for (int r = lblock_t_c.Length - 1; r >= 0; r--)
- {
- // Initialize reference caches
- ttIncl_t_c_r = ttIncl_t_c[r];
- ttMaxBP_t_c_r = ttMaxBP_t_c[r];
- prevtIdxs_t_c_r = prevtIdxs[t][c][r];
-
- // Loop on subbands
- minsbi = (r == 0) ? 0 : 1;
- maxsbi = (r == 0) ? 1 : 4;
- for (int s = minsbi; s < maxsbi; s++)
- {
- // Reset 'prevtIdxs'
- ArrayUtil.intArraySet(prevtIdxs_t_c_r[s], -1);
- // Reset 'lblock'
- ArrayUtil.intArraySet(lblock_t_c[r][s], INIT_LBLOCK);
- } // End loop on subbands
-
- // Loop on precincts
- for (int p = ppinfo[t][c][r].Length - 1; p >= 0; p--)
- {
- if (p < ttIncl_t_c_r.Length)
- {
- // Loop on subbands
- for (int s = minsbi; s < maxsbi; s++)
- {
- ttIncl_t_c_r[p][s].reset();
- ttMaxBP_t_c_r[p][s].reset();
- } // End loop on subbands
- }
- } // End loop on precincts
- } // End loop on resolution levels
- } // End loop on components
- } // End loop on tiles
- }
-
- /// Returns information about a given precinct
- ///
- ///
- /// Tile index.
- ///
- ///
- /// Component index.
- ///
- ///
- /// Resolution level index.
- ///
- ///
- /// Precinct index
- ///
- ///
- public virtual PrecInfo getPrecInfo(int t, int c, int r, int p)
- {
- return ppinfo[t][c][r][p];
- }
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/codestream/writer/TagTreeEncoder.cs b/CSJ2K/j2k/codestream/writer/TagTreeEncoder.cs
deleted file mode 100644
index 19009bce..00000000
--- a/CSJ2K/j2k/codestream/writer/TagTreeEncoder.cs
+++ /dev/null
@@ -1,595 +0,0 @@
-/*
-* CVS identifier:
-*
-* $Id: TagTreeEncoder.java,v 1.10 2001/08/17 16:02:06 grosbois Exp $
-*
-* Class: TagTreeEncoder
-*
-* Description: Encoder of tag trees
-*
-*
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-* */
-using CSJ2K.j2k.util;
-using System;
-namespace CSJ2K.j2k.codestream.writer
-{
-
- /// This class implements the tag tree encoder. A tag tree codes a 2D matrix of
- /// integer elements in an efficient way. The encoding procedure 'encode()'
- /// codes information about a value of the matrix, given a threshold. The
- /// procedure encodes the sufficient information to identify whether or not the
- /// value is greater than or equal to the threshold.
- ///
- /// The tag tree saves encoded information to a BitOutputBuffer.
- ///
- /// A particular and useful property of tag trees is that it is possible to
- /// change a value of the matrix, provided both new and old values of the
- /// element are both greater than or equal to the largest threshold which has
- /// yet been supplied to the coding procedure 'encode()'. This property can be
- /// exploited through the 'setValue()' method.
- ///
- /// This class allows saving the state of the tree at any point and
- /// restoring it at a later time, by calling save() and restore().
- ///
- /// A tag tree can also be reused, or restarted, if one of the reset()
- /// methods is called.
- ///
- /// The TagTreeDecoder class implements the tag tree decoder.
- ///
- /// Tag trees that have one dimension, or both, as 0 are allowed for
- /// convenience. Of course no values can be set or coded in such cases.
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- public class TagTreeEncoder
- {
- /// Returns the number of leafs along the horizontal direction.
- ///
- ///
- /// The number of leafs along the horizontal direction.
- ///
- ///
- virtual public int Width
- {
- get
- {
- return w;
- }
-
- }
- /// Returns the number of leafs along the vertical direction.
- ///
- ///
- /// The number of leafs along the vertical direction.
- ///
- ///
- virtual public int Height
- {
- get
- {
- return h;
- }
-
- }
- /// Sets the values of the leafs to the new set of values and updates the
- /// tag tree accordingly. No leaf can change its value if either the new or
- /// old value is smaller than largest threshold which has yet been supplied
- /// to 'encode()'. However such a leaf can keep its old value (i.e. new and
- /// old value must be identical.
- ///
- /// This method is more efficient than the setValue() method if a large
- /// proportion of the leafs change their value. Note that for leafs which
- /// don't have their value defined yet the value should be
- /// Integer.MAX_VALUE (which is the default initialization value).
- ///
- ///
- /// The new values for the leafs, in lexicographical order.
- ///
- ///
- ///
- ///
- ///
- virtual public int[] Values
- {
- set
- {
- int i, maxt;
- if (lvls == 0)
- {
- // Can't set values on empty tree
- throw new System.ArgumentException();
- }
- // Check the values
- maxt = treeS[lvls - 1][0];
- for (i = w * h - 1; i >= 0; i--)
- {
- if ((treeV[0][i] < maxt || value[i] < maxt) && treeV[0][i] != value[i])
- {
- throw new System.ArgumentException();
- }
- // Update leaf value
- treeV[0][i] = value[i];
- }
- // Recalculate tree at other levels
- recalcTreeV();
- }
-
- }
-
- /// The horizontal dimension of the base level
- protected internal int w;
-
- /// The vertical dimensions of the base level
- protected internal int h;
-
- /// The number of levels in the tag tree
- protected internal int lvls;
-
- /// The tag tree values. The first index is the level, starting at level 0
- /// (leafs). The second index is the element within the level, in
- /// lexicographical order.
- ///
- protected internal int[][] treeV;
-
- /// The tag tree state. The first index is the level, starting at level 0
- /// (leafs). The second index is the element within the level, in
- /// lexicographical order.
- ///
- protected internal int[][] treeS;
-
- /// The saved tag tree values. The first index is the level, starting at
- /// level 0 (leafs). The second index is the element within the level, in
- /// lexicographical order.
- ///
- protected internal int[][] treeVbak;
-
- /// The saved tag tree state. The first index is the level, starting at
- /// level 0 (leafs). The second index is the element within the level, in
- /// lexicographical order.
- ///
- protected internal int[][] treeSbak;
-
- /// The saved state. If true the values and states of the tree have been
- /// saved since the creation or last reset.
- ///
- protected internal bool saved;
-
- /// Creates a tag tree encoder with 'w' elements along the horizontal
- /// dimension and 'h' elements along the vertical direction. The total
- /// number of elements is thus 'vdim' x 'hdim'.
- ///
- /// The values of all elements are initialized to Integer.MAX_VALUE.
- ///
- ///
- /// The number of elements along the horizontal direction.
- ///
- ///
- /// The number of elements along the vertical direction.
- ///
- ///
- public TagTreeEncoder(int h, int w)
- {
- int k;
- // Check arguments
- if (w < 0 || h < 0)
- {
- throw new System.ArgumentException();
- }
- // Initialize elements
- init(w, h);
- // Set values to max
- for (k = treeV.Length - 1; k >= 0; k--)
- {
- ArrayUtil.intArraySet(treeV[k], System.Int32.MaxValue);
- }
- }
-
- /// Creates a tag tree encoder with 'w' elements along the horizontal
- /// dimension and 'h' elements along the vertical direction. The total
- /// number of elements is thus 'vdim' x 'hdim'. The values of the leafs in
- /// the tag tree are initialized to the values of the 'val' array.
- ///
- /// The values in the 'val' array are supposed to appear in
- /// lexicographical order, starting at index 0.
- ///
- ///
- /// The number of elements along the horizontal direction.
- ///
- ///
- /// The number of elements along the vertical direction.
- ///
- ///
- /// The values with which initialize the leafs of the tag tree.
- ///
- ///
- public TagTreeEncoder(int h, int w, int[] val)
- {
- int k;
- // Check arguments
- if (w < 0 || h < 0 || val.Length < w * h)
- {
- throw new System.ArgumentException();
- }
- // Initialize elements
- init(w, h);
- // Update leaf values
- for (k = w * h - 1; k >= 0; k--)
- {
- treeV[0][k] = val[k];
- }
- // Calculate values at other levels
- recalcTreeV();
- }
-
- /// Initializes the variables of this class, given the dimensions at the
- /// base level (leaf level). All the state ('treeS' array) and values
- /// ('treeV' array) are intialized to 0. This method is called by the
- /// constructors.
- ///
- ///
- /// The number of elements along the vertical direction.
- ///
- ///
- /// The number of elements along the horizontal direction.
- ///
- ///
- private void init(int w, int h)
- {
- int i;
- // Initialize dimensions
- this.w = w;
- this.h = h;
- // Calculate the number of levels
- if (w == 0 || h == 0)
- {
- lvls = 0;
- }
- else
- {
- lvls = 1;
- while (h != 1 || w != 1)
- {
- // Loop until we reach root
- w = (w + 1) >> 1;
- h = (h + 1) >> 1;
- lvls++;
- }
- }
- // Allocate tree values and states (no need to initialize to 0 since
- // it's the default)
- treeV = new int[lvls][];
- treeS = new int[lvls][];
- w = this.w;
- h = this.h;
- for (i = 0; i < lvls; i++)
- {
- treeV[i] = new int[h * w];
- treeS[i] = new int[h * w];
- w = (w + 1) >> 1;
- h = (h + 1) >> 1;
- }
- }
-
- /// Recalculates the values of the elements in the tag tree, in levels 1
- /// and up, based on the values of the leafs (level 0).
- ///
- ///
- private void recalcTreeV()
- {
- int m, n, bi, lw, tm1, tm2, lh, k;
- // Loop on all other levels, updating minimum
- for (k = 0; k < lvls - 1; k++)
- {
- // Visit all elements in level
- lw = (w + (1 << k) - 1) >> k;
- lh = (h + (1 << k) - 1) >> k;
- for (m = ((lh >> 1) << 1) - 2; m >= 0; m -= 2)
- {
- // All quads with 2 lines
- for (n = ((lw >> 1) << 1) - 2; n >= 0; n -= 2)
- {
- // All quads with 2 columns
- // Take minimum of 4 elements and put it in higher
- // level
- bi = m * lw + n;
- tm1 = (treeV[k][bi] < treeV[k][bi + 1]) ? treeV[k][bi] : treeV[k][bi + 1];
- tm2 = (treeV[k][bi + lw] < treeV[k][bi + lw + 1]) ? treeV[k][bi + lw] : treeV[k][bi + lw + 1];
- treeV[k + 1][(m >> 1) * ((lw + 1) >> 1) + (n >> 1)] = tm1 < tm2 ? tm1 : tm2;
- }
- // Now we may have quad with 1 column, 2 lines
- if (lw % 2 != 0)
- {
- n = ((lw >> 1) << 1);
- // Take minimum of 2 elements and put it in higher
- // level
- bi = m * lw + n;
- treeV[k + 1][(m >> 1) * ((lw + 1) >> 1) + (n >> 1)] = (treeV[k][bi] < treeV[k][bi + lw]) ? treeV[k][bi] : treeV[k][bi + lw];
- }
- }
- // Now we may have quads with 1 line, 2 or 1 columns
- if (lh % 2 != 0)
- {
- m = ((lh >> 1) << 1);
- for (n = ((lw >> 1) << 1) - 2; n >= 0; n -= 2)
- {
- // All quads with 2 columns
- // Take minimum of 2 elements and put it in higher
- // level
- bi = m * lw + n;
- treeV[k + 1][(m >> 1) * ((lw + 1) >> 1) + (n >> 1)] = (treeV[k][bi] < treeV[k][bi + 1]) ? treeV[k][bi] : treeV[k][bi + 1];
- }
- // Now we may have quad with 1 column, 1 line
- if (lw % 2 != 0)
- {
- // Just copy the value
- n = ((lw >> 1) << 1);
- treeV[k + 1][(m >> 1) * ((lw + 1) >> 1) + (n >> 1)] = treeV[k][m * lw + n];
- }
- }
- }
- }
-
- /// Changes the value of a leaf in the tag tree. The new and old values of
- /// the element must be not smaller than the largest threshold which has
- /// yet been supplied to 'encode()'.
- ///
- ///
- /// The vertical index of the element.
- ///
- ///
- /// The horizontal index of the element.
- ///
- ///
- /// The new value of the element.
- ///
- ///
- public virtual void setValue(int m, int n, int v)
- {
- int k, idx;
- // Check arguments
- if (lvls == 0 || n < 0 || n >= w || v < treeS[lvls - 1][0] || treeV[0][m * w + n] < treeS[lvls - 1][0])
- {
- throw new System.ArgumentException();
- }
- // Update the leaf value
- treeV[0][m * w + n] = v;
- // Update all parents
- for (k = 1; k < lvls; k++)
- {
- idx = (m >> k) * ((w + (1 << k) - 1) >> k) + (n >> k);
- if (v < treeV[k][idx])
- {
- // We need to update minimum and continue checking
- // in higher levels
- treeV[k][idx] = v;
- }
- else
- {
- // We are done: v is equal or less to minimum
- // in this level, no other minimums to update.
- break;
- }
- }
- }
-
- /// Encodes information for the specified element of the tree, given the
- /// threshold and sends it to the 'out' stream. The information that is
- /// coded is whether or not the value of the element is greater than or
- /// equal to the value of the threshold.
- ///
- ///
- /// The vertical index of the element.
- ///
- ///
- /// The horizontal index of the element.
- ///
- ///
- /// The threshold to use for encoding. It must be non-negative.
- ///
- ///
- /// The stream where to write the coded information.
- ///
- ///
- public virtual void encode(int m, int n, int t, BitOutputBuffer out_Renamed)
- {
- int k, ts, idx, tmin;
-
- // Check arguments
- if (m >= h || n >= w || t < 0)
- {
- throw new System.ArgumentException();
- }
-
- // Initialize
- k = lvls - 1;
- tmin = treeS[k][0];
-
- // Loop on levels
- while (true)
- {
- // Index of element in level 'k'
- idx = (m >> k) * ((w + (1 << k) - 1) >> k) + (n >> k);
- // Cache state
- ts = treeS[k][idx];
- if (ts < tmin)
- {
- ts = tmin;
- }
- while (t > ts)
- {
- if (treeV[k][idx] > ts)
- {
- out_Renamed.writeBit(0); // Send '0' bit
- }
- else if (treeV[k][idx] == ts)
- {
- out_Renamed.writeBit(1); // Send '1' bit
- }
- else
- {
- // we are done: set ts and get out of this while
- ts = t;
- break;
- }
- // Increment of treeS[k][idx]
- ts++;
- }
- // Update state
- treeS[k][idx] = ts;
- // Update tmin or terminate
- if (k > 0)
- {
- tmin = ts < treeV[k][idx] ? ts : treeV[k][idx];
- k--;
- }
- else
- {
- // Terminate
- return;
- }
- }
- }
-
- /// Saves the current values and state of the tree. Calling restore()
- /// restores the tag tree the saved state.
- ///
- ///
- ///
- ///
- ///
- public virtual void save()
- {
- int k; // i removed
-
- if (treeVbak == null)
- {
- // Nothing saved yet
- // Allocate saved arrays
- // treeV and treeS have the same dimensions
- treeVbak = new int[lvls][];
- treeSbak = new int[lvls][];
- for (k = lvls - 1; k >= 0; k--)
- {
- treeVbak[k] = new int[treeV[k].Length];
- treeSbak[k] = new int[treeV[k].Length];
- }
- }
-
- // Copy the arrays
- for (k = treeV.Length - 1; k >= 0; k--)
- {
- 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
- saved = true;
- }
-
- /// Restores the saved values and state of the tree. An
- /// IllegalArgumentException is thrown if the tree values and state have
- /// not been saved yet.
- ///
- ///
- ///
- ///
- ///
- public virtual void restore()
- {
- int k; // i removed
-
- if (!saved)
- {
- // Nothing saved yet
- throw new System.ArgumentException();
- }
-
- // Copy the arrays
- for (k = lvls - 1; k >= 0; k--)
- {
- Array.Copy(treeVbak[k], 0, treeV[k], 0, treeV[k].Length);
- Array.Copy(treeSbak[k], 0, treeS[k], 0, treeS[k].Length);
- }
- }
-
- /// Resets the tree values and state. All the values are set to
- /// Integer.MAX_VALUE and the states to 0.
- ///
- ///
- public virtual void reset()
- {
- int k;
- // Set all values to Integer.MAX_VALUE
- // and states to 0
- for (k = lvls - 1; k >= 0; k--)
- {
- ArrayUtil.intArraySet(treeV[k], System.Int32.MaxValue);
- ArrayUtil.intArraySet(treeS[k], 0);
- }
- // Invalidate saved tree
- saved = false;
- }
-
- /// Resets the tree values and state. The values are set to the values in
- /// 'val'. The states are all set to 0.
- ///
- ///
- /// The new values for the leafs, in lexicographical order.
- ///
- ///
- public virtual void reset(int[] val)
- {
- int k;
- // Set values for leaf level
- for (k = w * h - 1; k >= 0; k--)
- {
- treeV[0][k] = val[k];
- }
- // Calculate values at other levels
- recalcTreeV();
- // Set all states to 0
- for (k = lvls - 1; k >= 0; k--)
- {
- ArrayUtil.intArraySet(treeS[k], 0);
- }
- // Invalidate saved tree
- saved = false;
- }
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/decoder/DecoderSpecs.cs b/CSJ2K/j2k/decoder/DecoderSpecs.cs
deleted file mode 100644
index 62a32bd6..00000000
--- a/CSJ2K/j2k/decoder/DecoderSpecs.cs
+++ /dev/null
@@ -1,201 +0,0 @@
-/*
-* CVS identifier:
-*
-* $Id: DecoderSpecs.java,v 1.25 2002/07/25 15:06:17 grosbois Exp $
-*
-* Class: DecoderSpecs
-*
-* Description: Hold all decoder specifications
-*
-*
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-* */
-using CSJ2K.j2k.entropy;
-using CSJ2K.j2k.image;
-using CSJ2K.j2k.quantization;
-using CSJ2K.j2k.roi;
-using CSJ2K.j2k.wavelet.synthesis;
-namespace CSJ2K.j2k.decoder
-{
-
- /// This class holds references to each module specifications used in the
- /// decoding chain. This avoid big amount of arguments in method calls. A
- /// specification contains values of each tile-component for one module. All
- /// members must be instance of ModuleSpec class (or its children).
- ///
- ///
- ///
- ///
- ///
- public class DecoderSpecs : System.ICloneable
- {
- /// Returns a copy of the current object.
- ///
- ///
- virtual public DecoderSpecs Copy
- {
- get
- {
- DecoderSpecs decSpec2;
- try
- {
- decSpec2 = (DecoderSpecs)this.Clone();
- }
- //UPGRADE_NOTE: Exception 'java.lang.CloneNotSupportedException' was converted to 'System.Exception' which has different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1100'"
- catch (System.Exception)
- {
- throw new System.ApplicationException("Cannot clone the DecoderSpecs instance");
- }
- // Quantization
- decSpec2.qts = (QuantTypeSpec)qts.Copy;
- decSpec2.qsss = (QuantStepSizeSpec)qsss.Copy;
- decSpec2.gbs = (GuardBitsSpec)gbs.Copy;
- // Wavelet transform
- decSpec2.wfs = (SynWTFilterSpec)wfs.Copy;
- decSpec2.dls = (IntegerSpec)dls.Copy;
- // Component transformation
- decSpec2.cts = (CompTransfSpec)cts.Copy;
- // ROI
- if (rois != null)
- {
- decSpec2.rois = (MaxShiftSpec)rois.Copy;
- }
- return decSpec2;
- }
-
- }
-
- /// ICC Profiling specifications
- public ModuleSpec iccs;
-
- /// ROI maxshift value specifications
- public MaxShiftSpec rois;
-
- /// Quantization type specifications
- public QuantTypeSpec qts;
-
- /// Quantization normalized base step size specifications
- public QuantStepSizeSpec qsss;
-
- /// Number of guard bits specifications
- public GuardBitsSpec gbs;
-
- /// Analysis wavelet filters specifications
- public SynWTFilterSpec wfs;
-
- /// Number of decomposition levels specifications
- public IntegerSpec dls;
-
- /// Number of layers specifications
- public IntegerSpec nls;
-
- /// Progression order specifications
- public IntegerSpec pos;
-
- /// The Entropy decoder options specifications
- public ModuleSpec ecopts;
-
- /// The component transformation specifications
- public CompTransfSpec cts;
-
- /// The progression changes specifications
- public ModuleSpec pcs;
-
- /// The error resilience specifications concerning the entropy
- /// decoder
- ///
- public ModuleSpec ers;
-
- /// Precinct partition specifications
- public PrecinctSizeSpec pss;
-
- /// The Start Of Packet (SOP) markers specifications
- public ModuleSpec sops;
-
- /// The End of Packet Headers (EPH) markers specifications
- public ModuleSpec ephs;
-
- /// Code-blocks sizes specification
- public CBlkSizeSpec cblks;
-
- /// Packed packet header specifications
- public ModuleSpec pphs;
-
- /// Initialize all members with the given number of tiles and components.
- ///
- ///
- /// Number of tiles
- ///
- ///
- /// Number of components
- ///
- ///
- public DecoderSpecs(int nt, int nc)
- {
- // Quantization
- qts = new QuantTypeSpec(nt, nc, ModuleSpec.SPEC_TYPE_TILE_COMP);
- qsss = new QuantStepSizeSpec(nt, nc, ModuleSpec.SPEC_TYPE_TILE_COMP);
- gbs = new GuardBitsSpec(nt, nc, ModuleSpec.SPEC_TYPE_TILE_COMP);
-
- // Wavelet transform
- wfs = new SynWTFilterSpec(nt, nc, ModuleSpec.SPEC_TYPE_TILE_COMP);
- dls = new IntegerSpec(nt, nc, ModuleSpec.SPEC_TYPE_TILE_COMP);
-
- // Component transformation
- cts = new CompTransfSpec(nt, nc, ModuleSpec.SPEC_TYPE_TILE_COMP);
-
- // Entropy decoder
- ecopts = new ModuleSpec(nt, nc, ModuleSpec.SPEC_TYPE_TILE_COMP);
- ers = new ModuleSpec(nt, nc, ModuleSpec.SPEC_TYPE_TILE_COMP);
- cblks = new CBlkSizeSpec(nt, nc, ModuleSpec.SPEC_TYPE_TILE_COMP);
-
- // Precinct partition
- pss = new PrecinctSizeSpec(nt, nc, ModuleSpec.SPEC_TYPE_TILE_COMP, dls);
-
- // Codestream
- nls = new IntegerSpec(nt, nc, ModuleSpec.SPEC_TYPE_TILE);
- pos = new IntegerSpec(nt, nc, ModuleSpec.SPEC_TYPE_TILE);
- pcs = new ModuleSpec(nt, nc, ModuleSpec.SPEC_TYPE_TILE);
- sops = new ModuleSpec(nt, nc, ModuleSpec.SPEC_TYPE_TILE);
- ephs = new ModuleSpec(nt, nc, ModuleSpec.SPEC_TYPE_TILE);
- pphs = new ModuleSpec(nt, nc, ModuleSpec.SPEC_TYPE_TILE);
- iccs = new ModuleSpec(nt, nc, ModuleSpec.SPEC_TYPE_TILE);
- pphs.setDefault((System.Object)false);
- }
- //UPGRADE_TODO: The following method was automatically generated and it must be implemented in order to preserve the class logic. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1232'"
- virtual public System.Object Clone()
- {
- return null;
- }
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/encoder/EncoderSpecs.cs b/CSJ2K/j2k/encoder/EncoderSpecs.cs
deleted file mode 100644
index 28ead9b5..00000000
--- a/CSJ2K/j2k/encoder/EncoderSpecs.cs
+++ /dev/null
@@ -1,187 +0,0 @@
-/*
-* CVS identifier:
-*
-* $Id: EncoderSpecs.java,v 1.35 2001/05/08 16:10:40 grosbois Exp $
-*
-* Class: EncoderSpecs
-*
-* Description: Hold all encoder specifications
-*
-*
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-* */
-using CSJ2K.j2k.entropy;
-using CSJ2K.j2k.image;
-using CSJ2K.j2k.image.forwcomptransf;
-using CSJ2K.j2k.quantization;
-using CSJ2K.j2k.quantization.quantizer;
-using CSJ2K.j2k.roi;
-using CSJ2K.j2k.util;
-using CSJ2K.j2k.wavelet.analysis;
-namespace CSJ2K.j2k.encoder
-{
-
- /// This class holds references to each module specifications used in the
- /// encoding chain. This avoid big amount of arguments in method calls. A
- /// specification contains values of each tile-component for one module. All
- /// members must be instance of ModuleSpec class (or its children).
- ///
- ///
- ///
- ///
- ///
- public class EncoderSpecs
- {
-
- /// ROI maxshift value specifications
- public MaxShiftSpec rois;
-
- /// Quantization type specifications
- public QuantTypeSpec qts;
-
- /// Quantization normalized base step size specifications
- public QuantStepSizeSpec qsss;
-
- /// Number of guard bits specifications
- public GuardBitsSpec gbs;
-
- /// Analysis wavelet filters specifications
- public AnWTFilterSpec wfs;
-
- /// Component transformation specifications
- public CompTransfSpec cts;
-
- /// Number of decomposition levels specifications
- public IntegerSpec dls;
-
- /// The length calculation specifications
- public StringSpec lcs;
-
- /// The termination type specifications
- public StringSpec tts;
-
- /// Error resilience segment symbol use specifications
- public StringSpec sss;
-
- /// Causal stripes specifications
- public StringSpec css;
-
- /// Regular termination specifications
- public StringSpec rts;
-
- /// MQ reset specifications
- public StringSpec mqrs;
-
- /// By-pass mode specifications
- public StringSpec bms;
-
- /// Precinct partition specifications
- public PrecinctSizeSpec pss;
-
- /// Start of packet (SOP) marker use specification
- public StringSpec sops;
-
- /// End of packet header (EPH) marker use specification
- public StringSpec ephs;
-
- /// Code-blocks sizes specification
- public CBlkSizeSpec cblks;
-
- /// Progression/progression changes specification
- public ProgressionSpec pocs;
-
- /// The number of tiles within the image
- public int nTiles;
-
- /// The number of components within the image
- public int nComp;
-
- /// Initialize all members with the given number of tiles and components
- /// and the command-line arguments stored in a ParameterList instance
- ///
- ///
- /// Number of tiles
- ///
- ///
- /// Number of components
- ///
- ///
- /// The image source (used to get the image size)
- ///
- ///
- /// The ParameterList instance
- ///
- ///
- public EncoderSpecs(int nt, int nc, BlkImgDataSrc imgsrc, ParameterList pl)
- {
- nTiles = nt;
- nComp = nc;
-
- // ROI
- rois = new MaxShiftSpec(nt, nc, ModuleSpec.SPEC_TYPE_TILE_COMP);
-
- // Quantization
- pl.checkList(Quantizer.OPT_PREFIX, CSJ2K.j2k.util.ParameterList.toNameArray(Quantizer.ParameterInfo));
- qts = new QuantTypeSpec(nt, nc, ModuleSpec.SPEC_TYPE_TILE_COMP, pl);
- qsss = new QuantStepSizeSpec(nt, nc, ModuleSpec.SPEC_TYPE_TILE_COMP, pl);
- gbs = new GuardBitsSpec(nt, nc, ModuleSpec.SPEC_TYPE_TILE_COMP, pl);
-
- // Wavelet transform
- wfs = new AnWTFilterSpec(nt, nc, ModuleSpec.SPEC_TYPE_TILE_COMP, qts, pl);
- dls = new IntegerSpec(nt, nc, ModuleSpec.SPEC_TYPE_TILE_COMP, pl, "Wlev");
-
- // Component transformation
- cts = new ForwCompTransfSpec(nt, nc, ModuleSpec.SPEC_TYPE_TILE, wfs, pl);
-
- // Entropy coder
- System.String[] strLcs = new System.String[] { "near_opt", "lazy_good", "lazy" };
- lcs = new StringSpec(nt, nc, ModuleSpec.SPEC_TYPE_TILE_COMP, "Clen_calc", strLcs, pl);
- System.String[] strTerm = new System.String[] { "near_opt", "easy", "predict", "full" };
- tts = new StringSpec(nt, nc, ModuleSpec.SPEC_TYPE_TILE_COMP, "Cterm_type", strTerm, pl);
- System.String[] strBoolean = new System.String[] { "on", "off" };
- sss = new StringSpec(nt, nc, ModuleSpec.SPEC_TYPE_TILE_COMP, "Cseg_symbol", strBoolean, pl);
- css = new StringSpec(nt, nc, ModuleSpec.SPEC_TYPE_TILE_COMP, "Ccausal", strBoolean, pl);
- rts = new StringSpec(nt, nc, ModuleSpec.SPEC_TYPE_TILE_COMP, "Cterminate", strBoolean, pl);
- mqrs = new StringSpec(nt, nc, ModuleSpec.SPEC_TYPE_TILE_COMP, "CresetMQ", strBoolean, pl);
- bms = new StringSpec(nt, nc, ModuleSpec.SPEC_TYPE_TILE_COMP, "Cbypass", strBoolean, pl);
- cblks = new CBlkSizeSpec(nt, nc, ModuleSpec.SPEC_TYPE_TILE_COMP, pl);
-
- // Precinct partition
- pss = new PrecinctSizeSpec(nt, nc, ModuleSpec.SPEC_TYPE_TILE_COMP, imgsrc, dls, pl);
-
- // Codestream
- sops = new StringSpec(nt, nc, ModuleSpec.SPEC_TYPE_TILE, "Psop", strBoolean, pl);
- ephs = new StringSpec(nt, nc, ModuleSpec.SPEC_TYPE_TILE, "Peph", strBoolean, pl);
- }
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/entropy/CBlkSizeSpec.cs b/CSJ2K/j2k/entropy/CBlkSizeSpec.cs
deleted file mode 100644
index 2f1a3e91..00000000
--- a/CSJ2K/j2k/entropy/CBlkSizeSpec.cs
+++ /dev/null
@@ -1,537 +0,0 @@
-/*
-* CVS identifier:
-*
-* $Id: CBlkSizeSpec.java,v 1.11 2001/02/14 10:38:18 grosbois Exp $
-*
-* Class: CBlkSizeSpec
-*
-* Description: Specification of the code-blocks size
-*
-*
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-* */
-using CSJ2K.j2k.util;
-namespace CSJ2K.j2k.entropy
-{
-
- /// This class extends ModuleSpec class for code-blocks sizes holding purposes.
- ///
- /// It stores the size a of code-block.
- ///
- ///
- public class CBlkSizeSpec : ModuleSpec
- {
- /// Returns the maximum code-block's width
- ///
- ///
- virtual public int MaxCBlkWidth
- {
- get
- {
- return maxCBlkWidth;
- }
-
- }
- /// Returns the maximum code-block's height
- ///
- ///
- virtual public int MaxCBlkHeight
- {
- get
- {
- return maxCBlkHeight;
- }
-
- }
-
- /// Name of the option
- private const System.String optName = "Cblksiz";
-
- /// The maximum code-block width
- private int maxCBlkWidth = 0;
-
- /// The maximum code-block height
- private int maxCBlkHeight = 0;
-
- /// Creates a new CBlkSizeSpec object for the specified number of tiles and
- /// components.
- ///
- ///
- /// The number of tiles
- ///
- ///
- /// The number of components
- ///
- ///
- /// the type of the specification module i.e. tile specific,
- /// component specific or both.
- ///
- ///
- public CBlkSizeSpec(int nt, int nc, byte type) : base(nt, nc, type)
- {
- }
-
- /// Creates a new CBlkSizeSpec object for the specified number of tiles and
- /// components and the ParameterList instance.
- ///
- ///
- /// The number of tiles
- ///
- ///
- /// The number of components
- ///
- ///
- /// the type of the specification module i.e. tile specific,
- /// component specific or both.
- ///
- ///
- /// The image source (used to get the image size)
- ///
- ///
- /// The ParameterList instance
- ///
- ///
- public CBlkSizeSpec(int nt, int nc, byte type, ParameterList pl) : base(nt, nc, type)
- {
-
- bool firstVal = true;
- System.String param = pl.getParameter(optName);
-
- // Precinct partition is used : parse arguments
- SupportClass.Tokenizer stk = new SupportClass.Tokenizer(param);
- byte curSpecType = SPEC_DEF; // Specification type of the
- // current parameter
- bool[] tileSpec = null; // Tiles concerned by the specification
- bool[] compSpec = null; // Components concerned by the specification
- int ci, ti; // i, xIdx removed
- System.String word = null; // current word
- System.String errMsg = null;
-
- while (stk.HasMoreTokens())
- {
- word = stk.NextToken();
-
- switch (word[0])
- {
-
-
- case 't': // Tiles specification
- tileSpec = parseIdx(word, nTiles);
- if (curSpecType == SPEC_COMP_DEF)
- {
- curSpecType = SPEC_TILE_COMP;
- }
- else
- {
- curSpecType = SPEC_TILE_DEF;
- }
- break;
-
-
- case 'c': // Components specification
- compSpec = parseIdx(word, nComp);
- if (curSpecType == SPEC_TILE_DEF)
- {
- curSpecType = SPEC_TILE_COMP;
- }
- else
- {
- curSpecType = SPEC_COMP_DEF;
- }
- break;
-
-
- default:
- if (!System.Char.IsDigit(word[0]))
- {
- errMsg = "Bad construction for parameter: " + word;
- throw new System.ArgumentException(errMsg);
- }
- System.Int32[] dim = new System.Int32[2];
- // Get code-block's width
- try
- {
- dim[0] = System.Int32.Parse(word);
- // Check that width is not >
- // StdEntropyCoderOptions.MAX_CB_DIM
- if (dim[0] > CSJ2K.j2k.entropy.StdEntropyCoderOptions.MAX_CB_DIM)
- {
- errMsg = "'" + optName + "' option : the code-block's " + "width cannot be greater than " + CSJ2K.j2k.entropy.StdEntropyCoderOptions.MAX_CB_DIM;
- throw new System.ArgumentException(errMsg);
- }
- // Check that width is not <
- // StdEntropyCoderOptions.MIN_CB_DIM
- if (dim[0] < CSJ2K.j2k.entropy.StdEntropyCoderOptions.MIN_CB_DIM)
- {
- errMsg = "'" + optName + "' option : the code-block's " + "width cannot be less than " + CSJ2K.j2k.entropy.StdEntropyCoderOptions.MIN_CB_DIM;
- throw new System.ArgumentException(errMsg);
- }
- // Check that width is a power of 2
- if (dim[0] != (1 << MathUtil.log2(dim[0])))
- {
- errMsg = "'" + optName + "' option : the code-block's " + "width must be a power of 2";
- throw new System.ArgumentException(errMsg);
- }
- }
- catch (System.FormatException)
- {
- errMsg = "'" + optName + "' option : the code-block's " + "width could not be parsed.";
- throw new System.ArgumentException(errMsg);
- }
- // Get the next word in option
- try
- {
- word = stk.NextToken();
- }
- catch (System.ArgumentOutOfRangeException)
- {
- errMsg = "'" + optName + "' option : could not parse the " + "code-block's height";
- throw new System.ArgumentException(errMsg);
- }
- // Get the code-block's height
- try
- {
- dim[1] = System.Int32.Parse(word);
- // Check that height is not >
- // StdEntropyCoderOptions.MAX_CB_DIM
- if (dim[1] > CSJ2K.j2k.entropy.StdEntropyCoderOptions.MAX_CB_DIM)
- {
- errMsg = "'" + optName + "' option : the code-block's " + "height cannot be greater than " + CSJ2K.j2k.entropy.StdEntropyCoderOptions.MAX_CB_DIM;
- throw new System.ArgumentException(errMsg);
- }
- // Check that height is not <
- // StdEntropyCoderOptions.MIN_CB_DIM
- if (dim[1] < CSJ2K.j2k.entropy.StdEntropyCoderOptions.MIN_CB_DIM)
- {
- errMsg = "'" + optName + "' option : the code-block's " + "height cannot be less than " + CSJ2K.j2k.entropy.StdEntropyCoderOptions.MIN_CB_DIM;
- throw new System.ArgumentException(errMsg);
- }
- // Check that height is a power of 2
- if (dim[1] != (1 << MathUtil.log2(dim[1])))
- {
- errMsg = "'" + optName + "' option : the code-block's " + "height must be a power of 2";
- throw new System.ArgumentException(errMsg);
- }
- // Check that the code-block 'area' (i.e. width*height) is
- // not greater than StdEntropyCoderOptions.MAX_CB_AREA
- if (dim[0] * dim[1] > CSJ2K.j2k.entropy.StdEntropyCoderOptions.MAX_CB_AREA)
- {
- errMsg = "'" + optName + "' option : The " + "code-block's area (i.e. width*height) " + "cannot be greater than " + CSJ2K.j2k.entropy.StdEntropyCoderOptions.MAX_CB_AREA;
- throw new System.ArgumentException(errMsg);
- }
- }
- catch (System.FormatException)
- {
- errMsg = "'" + optName + "' option : the code-block's height " + "could not be parsed.";
- throw new System.ArgumentException(errMsg);
- }
-
- // Store the maximum dimensions if necessary
- if (dim[0] > maxCBlkWidth)
- {
- maxCBlkWidth = dim[0];
- }
-
- if (dim[1] > maxCBlkHeight)
- {
- maxCBlkHeight = dim[1];
- }
-
- if (firstVal)
- {
- // This is the first time a value is given so we set it as
- // the default one
- setDefault((System.Object)(dim));
- firstVal = false;
- }
-
- switch (curSpecType)
- {
-
- case SPEC_DEF:
- setDefault((System.Object)(dim));
- break;
-
- case SPEC_TILE_DEF:
- for (ti = tileSpec.Length - 1; ti >= 0; ti--)
- {
- if (tileSpec[ti])
- {
- setTileDef(ti, (System.Object)(dim));
- }
- }
- break;
-
- case SPEC_COMP_DEF:
- for (ci = compSpec.Length - 1; ci >= 0; ci--)
- {
- if (compSpec[ci])
- {
- setCompDef(ci, (System.Object)(dim));
- }
- }
- break;
-
- default:
- for (ti = tileSpec.Length - 1; ti >= 0; ti--)
- {
- for (ci = compSpec.Length - 1; ci >= 0; ci--)
- {
- if (tileSpec[ti] && compSpec[ci])
- {
- setTileCompVal(ti, ci, (System.Object)(dim));
- }
- }
- }
- break;
-
- }
- break;
-
- } // end switch
- }
- }
-
- /// Returns the code-block width :
- ///
- ///
- /// - for the specified tile/component
- /// - for the specified tile
- /// - for the specified component
- /// - default value
- ///
- ///
- /// The value returned depends on the value of the variable 'type' which
- /// can take the following values :
- ///
- ///
- /// - SPEC_DEF -> Default value is returned. t and c values are
- /// ignored
- /// - SPEC_COMP_DEF -> Component default value is returned. t value is
- /// ignored
- /// - SPEC_TILE_DEF -> Tile default value is returned. c value is
- /// ignored
- /// - SPEC_TILE_COMP -> Tile/Component value is returned.
- ///
- ///
- ///
- /// The type of the value we want to be returned
- ///
- ///
- /// The tile index
- ///
- ///
- /// the component index
- ///
- ///
- /// The code-block width for the specified tile and component
- ///
- ///
- public virtual int getCBlkWidth(byte type, int t, int c)
- {
- //UPGRADE_TODO: The 'System.Int32' structure does not have an equivalent to NULL. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1291'"
- System.Int32[] dim = null;
- switch (type)
- {
-
- case SPEC_DEF:
- dim = (System.Int32[])getDefault();
- break;
-
- case SPEC_COMP_DEF:
- dim = (System.Int32[])getCompDef(c);
- break;
-
- case SPEC_TILE_DEF:
- dim = (System.Int32[])getTileDef(t);
- break;
-
- case SPEC_TILE_COMP:
- dim = (System.Int32[])getTileCompVal(t, c);
- break;
- }
- return dim[0];
- }
-
- /// Returns the code-block height:
- ///
- ///
- /// - for the specified tile/component
- /// - for the specified tile
- /// - for the specified component
- /// - default value
- ///
- ///
- /// The value returned depends on the value of the variable 'type' which
- /// can take the following values :
- ///
- ///
- /// - SPEC_DEF -> Default value is returned. t and c values are
- /// ignored
- /// - SPEC_COMP_DEF -> Component default value is returned. t value is
- /// ignored
- /// - SPEC_TILE_DEF -> Tile default value is returned. c value is
- /// ignored
- /// - SPEC_TILE_COMP -> Tile/Component value is returned.
- ///
- ///
- ///
- /// The type of the value we want to be returned
- ///
- ///
- /// The tile index
- ///
- ///
- /// the component index
- ///
- ///
- /// The code-block height for the specified tile and component
- ///
- ///
- public virtual int getCBlkHeight(byte type, int t, int c)
- {
- //UPGRADE_TODO: The 'System.Int32' structure does not have an equivalent to NULL. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1291'"
- System.Int32[] dim = null;
- switch (type)
- {
-
- case SPEC_DEF:
- dim = (System.Int32[])getDefault();
- break;
-
- case SPEC_COMP_DEF:
- dim = (System.Int32[])getCompDef(c);
- break;
-
- case SPEC_TILE_DEF:
- dim = (System.Int32[])getTileDef(t);
- break;
-
- case SPEC_TILE_COMP:
- dim = (System.Int32[])getTileCompVal(t, c);
- break;
- }
- return dim[1];
- }
-
- /// Sets default value for this module
- ///
- ///
- /// Default value
- ///
- ///
- public override void setDefault(System.Object value_Renamed)
- {
- base.setDefault(value_Renamed);
-
- // Store the biggest code-block dimensions
- storeHighestDims((System.Int32[])value_Renamed);
- }
-
- /// Sets default value for specified tile and specValType tag if allowed by
- /// its priority.
- ///
- ///
- /// Tile index.
- ///
- ///
- /// Tile's default value
- ///
- ///
- public override void setTileDef(int t, System.Object value_Renamed)
- {
- base.setTileDef(t, value_Renamed);
-
- // Store the biggest code-block dimensions
- storeHighestDims((System.Int32[])value_Renamed);
- }
-
- /// Sets default value for specified component and specValType tag if
- /// allowed by its priority.
- ///
- ///
- /// Component index
- ///
- ///
- /// Component's default value
- ///
- ///
- public override void setCompDef(int c, System.Object value_Renamed)
- {
- base.setCompDef(c, value_Renamed);
-
- // Store the biggest code-block dimensions
- storeHighestDims((System.Int32[])value_Renamed);
- }
-
- /// Sets value for specified tile-component.
- ///
- ///
- /// Tie index
- ///
- ///
- /// Component index
- ///
- ///
- /// Tile-component's value
- ///
- ///
- public override void setTileCompVal(int t, int c, System.Object value_Renamed)
- {
- base.setTileCompVal(t, c, value_Renamed);
-
- // Store the biggest code-block dimensions
- storeHighestDims((System.Int32[])value_Renamed);
- }
-
- /// Stores the highest code-block width and height
- ///
- ///
- /// The 2 elements array that contains the code-block width and
- /// height.
- ///
- ///
- private void storeHighestDims(System.Int32[] dim)
- {
- // Store the biggest code-block dimensions
- if (dim[0] > maxCBlkWidth)
- {
- maxCBlkWidth = dim[0];
- }
- if (dim[1] > maxCBlkHeight)
- {
- maxCBlkHeight = dim[1];
- }
- }
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/entropy/CodedCBlk.cs b/CSJ2K/j2k/entropy/CodedCBlk.cs
deleted file mode 100644
index d81486e6..00000000
--- a/CSJ2K/j2k/entropy/CodedCBlk.cs
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
-* CVS identifier:
-*
-* $Id: CodedCBlk.java,v 1.9 2001/08/17 09:42:13 grosbois Exp $
-*
-* Class: CodedCBlk
-*
-* Description: The generic coded (compressed) code-block
-*
-*
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-* */
-namespace CSJ2K.j2k.entropy
-{
-
- /// This is the generic class to store coded (compressed) code-block. It stores
- /// the compressed data as well as the necessary side-information.
- ///
- /// This class is normally not used. Instead the EncRDCBlk, EncLyrdCBlk and
- /// the DecLyrdCBlk subclasses are used.
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- public class CodedCBlk
- {
-
- /// The horizontal index of the code-block, within the subband.
- public int n;
-
- /// The vertical index of the code-block, within the subband.
- public int m;
-
- /// The number of skipped most significant bit-planes.
- public int skipMSBP;
-
- /// The compressed data
- public byte[] data;
-
- /// Creates a new CodedCBlk object wit the default values and without
- /// allocating any space for its members.
- ///
- ///
- public CodedCBlk()
- {
- }
-
- /// Creates a new CodedCBlk object with the specified values.
- ///
- ///
- /// The horizontal index of the code-block, within the subband.
- ///
- ///
- /// The vertical index of the code-block, within the subband.
- ///
- ///
- /// The number of skipped most significant bit-planes for
- /// this code-block.
- ///
- ///
- /// The compressed data. This array is referenced by this
- /// object so it should not be modified after.
- ///
- ///
- public CodedCBlk(int m, int n, int skipMSBP, byte[] data)
- {
- this.m = m;
- this.n = n;
- this.skipMSBP = skipMSBP;
- this.data = data;
- }
-
- /// Returns the contents of the object in a string. The string contains the
- /// following data: 'm', 'n', 'skipMSBP' and 'data.length. This is used for
- /// debugging.
- ///
- ///
- /// A string with the contents of the object
- ///
- ///
- public override System.String ToString()
- {
- return "m=" + m + ", n=" + n + ", skipMSBP=" + skipMSBP + ", data.length=" + ((data != null) ? "" + data.Length : "(null)");
- }
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/entropy/PrecinctSizeSpec.cs b/CSJ2K/j2k/entropy/PrecinctSizeSpec.cs
deleted file mode 100644
index 1c3b1b61..00000000
--- a/CSJ2K/j2k/entropy/PrecinctSizeSpec.cs
+++ /dev/null
@@ -1,492 +0,0 @@
-/*
-* CVS identifier:
-*
-* $Id: PrecinctSizeSpec.java,v 1.18 2001/09/14 09:26:58 grosbois Exp $
-*
-* Class: PrecinctSizeSpec
-*
-* Description: Specification of the precinct sizes
-*
-*
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-* */
-using CSJ2K.j2k.image;
-using CSJ2K.j2k.util;
-namespace CSJ2K.j2k.entropy
-{
-
- /// This class extends ModuleSpec class for precinct partition sizes holding
- /// purposes.
- ///
- /// It stores the size a of precinct when precinct partition is used or not.
- /// If precinct partition is used, we can have several packets for a given
- /// resolution level whereas there is only one packet per resolution level if
- /// no precinct partition is used.
- ///
- ///
- public class PrecinctSizeSpec : ModuleSpec
- {
-
- /// Name of the option
- private const System.String optName = "Cpp";
-
- /// Reference to wavelet number of decomposition levels for each
- /// tile-component.
- ///
- private IntegerSpec dls;
-
- /// Creates a new PrecinctSizeSpec object for the specified number of tiles
- /// and components.
- ///
- ///
- /// The number of tiles
- ///
- ///
- /// The number of components
- ///
- ///
- /// the type of the specification module i.e. tile specific,
- /// component specific or both.
- ///
- ///
- /// Reference to the number of decomposition levels
- /// specification
- ///
- ///
- public PrecinctSizeSpec(int nt, int nc, byte type, IntegerSpec dls) : base(nt, nc, type)
- {
- this.dls = dls;
- }
-
- /// Creates a new PrecinctSizeSpec object for the specified number of tiles
- /// and components and the ParameterList instance.
- ///
- ///
- /// The number of tiles
- ///
- ///
- /// The number of components
- ///
- ///
- /// the type of the specification module i.e. tile specific,
- /// component specific or both.
- ///
- ///
- /// The image source (used to get the image size)
- ///
- ///
- /// The ParameterList instance
- ///
- ///
- public PrecinctSizeSpec(int nt, int nc, byte type, BlkImgDataSrc imgsrc, IntegerSpec dls, ParameterList pl) : base(nt, nc, type)
- {
-
- this.dls = dls;
-
- // The precinct sizes are stored in a 2 elements vector array, the
- // first element containing a vector for the precincts width for each
- // resolution level and the second element containing a vector for the
- // precincts height for each resolution level. The precincts sizes are
- // specified from the highest resolution level to the lowest one
- // (i.e. 0). If there are less elements than the number of
- // decomposition levels, the last element is used for all remaining
- // resolution levels (i.e. if the precincts sizes are specified only
- // for resolutions levels 5, 4 and 3, then the precincts size for
- // resolution levels 2, 1 and 0 will be the same as the size used for
- // resolution level 3).
-
- // Boolean used to know if we were previously reading a precinct's
- // size or if we were reading something else.
- bool wasReadingPrecinctSize = false;
-
- System.String param = pl.getParameter(optName);
-
- // Set precinct sizes to default i.e. 2^15 =
- // Markers.PRECINCT_PARTITION_DEF_SIZE
- System.Collections.ArrayList[] tmpv = new System.Collections.ArrayList[2];
- tmpv[0] = System.Collections.ArrayList.Synchronized(new System.Collections.ArrayList(10)); // ppx
- tmpv[0].Add((System.Int32)CSJ2K.j2k.codestream.Markers.PRECINCT_PARTITION_DEF_SIZE);
- tmpv[1] = System.Collections.ArrayList.Synchronized(new System.Collections.ArrayList(10)); // ppy
- tmpv[1].Add((System.Int32)CSJ2K.j2k.codestream.Markers.PRECINCT_PARTITION_DEF_SIZE);
- setDefault(tmpv);
-
- if (param == null)
- {
- // No precinct size specified in the command line so we do not try
- // to parse it.
- return;
- }
-
- // Precinct partition is used : parse arguments
- SupportClass.Tokenizer stk = new SupportClass.Tokenizer(param);
- byte curSpecType = SPEC_DEF; // Specification type of the
- // current parameter
- bool[] tileSpec = null; // Tiles concerned by the specification
- bool[] compSpec = null; // Components concerned by the specification
- int ci, ti; //i, xIdx removed
-
- bool endOfParamList = false;
- System.String word = null; // current word
- System.Int32 w, h;
- System.String errMsg = null;
-
- while ((stk.HasMoreTokens() || wasReadingPrecinctSize) && !endOfParamList)
- {
-
- System.Collections.ArrayList[] v = new System.Collections.ArrayList[2]; // v[0] : ppx, v[1] : ppy
-
- // We do not read the next token if we were reading a precinct's
- // size argument as we have already read the next token into word.
- if (!wasReadingPrecinctSize)
- {
- word = stk.NextToken();
- }
-
- wasReadingPrecinctSize = false;
-
- switch (word[0])
- {
-
-
- case 't': // Tiles specification
- tileSpec = parseIdx(word, nTiles);
- if (curSpecType == SPEC_COMP_DEF)
- {
- curSpecType = SPEC_TILE_COMP;
- }
- else
- {
- curSpecType = SPEC_TILE_DEF;
- }
- break;
-
-
- case 'c': // Components specification
- compSpec = parseIdx(word, nComp);
- if (curSpecType == SPEC_TILE_DEF)
- {
- curSpecType = SPEC_TILE_COMP;
- }
- else
- {
- curSpecType = SPEC_COMP_DEF;
- }
- break;
-
-
- default:
- if (!System.Char.IsDigit(word[0]))
- {
- errMsg = "Bad construction for parameter: " + word;
- throw new System.ArgumentException(errMsg);
- }
-
- // Initialises Vector objects
- v[0] = System.Collections.ArrayList.Synchronized(new System.Collections.ArrayList(10)); // ppx
- v[1] = System.Collections.ArrayList.Synchronized(new System.Collections.ArrayList(10)); // ppy
-
- while (true)
- {
-
- // Now get the precinct dimensions
- try
- {
- // Get precinct width
- w = System.Int32.Parse(word);
-
- // Get next word in argument list
- try
- {
- word = stk.NextToken();
- }
- catch (System.ArgumentOutOfRangeException)
- {
- errMsg = "'" + optName + "' option : could not " + "parse the precinct's width";
- throw new System.ArgumentException(errMsg);
- }
- // Get precinct height
- h = System.Int32.Parse(word);
- if (w != (1 << MathUtil.log2(w)) || h != (1 << MathUtil.log2(h)))
- {
- errMsg = "Precinct dimensions must be powers of 2";
- throw new System.ArgumentException(errMsg);
- }
- }
- catch (System.FormatException)
- {
- errMsg = "'" + optName + "' option : the argument '" + word + "' could not be parsed.";
- throw new System.ArgumentException(errMsg);
- }
- // Store packet's dimensions in Vector arrays
- v[0].Add(w);
- v[1].Add(h);
-
- // Try to get the next token
- if (stk.HasMoreTokens())
- {
- word = stk.NextToken();
- if (!System.Char.IsDigit(word[0]))
- {
- // The next token does not start with a digit so
- // it is not a precinct's size argument. We set
- // the wasReadingPrecinctSize booleen such that we
- // know that we don't have to read another token
- // and check for the end of the parameters list.
- wasReadingPrecinctSize = true;
-
- if (curSpecType == SPEC_DEF)
- {
- setDefault(v);
- }
- else if (curSpecType == SPEC_TILE_DEF)
- {
- for (ti = tileSpec.Length - 1; ti >= 0; ti--)
- {
- if (tileSpec[ti])
- {
- setTileDef(ti, v);
- }
- }
- }
- else if (curSpecType == SPEC_COMP_DEF)
- {
- for (ci = compSpec.Length - 1; ci >= 0; ci--)
- {
- if (compSpec[ci])
- {
- setCompDef(ci, v);
- }
- }
- }
- else
- {
- for (ti = tileSpec.Length - 1; ti >= 0; ti--)
- {
- for (ci = compSpec.Length - 1; ci >= 0; ci--)
- {
- if (tileSpec[ti] && compSpec[ci])
- {
- setTileCompVal(ti, ci, v);
- }
- }
- }
- }
- // Re-initialize
- curSpecType = SPEC_DEF;
- tileSpec = null;
- compSpec = null;
-
- // Go back to 'normal' parsing
- break;
- }
- else
- {
- // Next token starts with a digit so read it
- }
- }
- else
- {
- // We have reached the end of the parameters list so
- // we store the last precinct's sizes and we stop
- if (curSpecType == SPEC_DEF)
- {
- setDefault(v);
- }
- else if (curSpecType == SPEC_TILE_DEF)
- {
- for (ti = tileSpec.Length - 1; ti >= 0; ti--)
- {
- if (tileSpec[ti])
- {
- setTileDef(ti, v);
- }
- }
- }
- else if (curSpecType == SPEC_COMP_DEF)
- {
- for (ci = compSpec.Length - 1; ci >= 0; ci--)
- {
- if (compSpec[ci])
- {
- setCompDef(ci, v);
- }
- }
- }
- else
- {
- for (ti = tileSpec.Length - 1; ti >= 0; ti--)
- {
- for (ci = compSpec.Length - 1; ci >= 0; ci--)
- {
- if (tileSpec[ti] && compSpec[ci])
- {
- setTileCompVal(ti, ci, v);
- }
- }
- }
- }
- endOfParamList = true;
- break;
- }
- } // while (true)
- break;
-
- } // switch
- } // while
- }
-
- /// Returns the precinct partition width in component 'n' and tile 't' at
- /// resolution level 'rl'. If the tile index is equal to -1 or if the
- /// component index is equal to -1 it means that those should not be taken
- /// into account.
- ///
- ///
- /// The tile index, in raster scan order. Specify -1 if it is not
- /// a specific tile.
- ///
- ///
- /// The component index. Specify -1 if it is not a specific
- /// component.
- ///
- ///
- /// The resolution level
- ///
- ///
- /// The precinct partition width in component 'c' and tile 't' at
- /// resolution level 'rl'.
- ///
- ///
- public virtual int getPPX(int t, int c, int rl)
- {
- int mrl, idx;
- System.Collections.ArrayList[] v = null;
- bool tileSpecified = (t != -1 ? true : false);
- bool compSpecified = (c != -1 ? true : false);
-
- // Get the maximum number of decomposition levels and the object
- // (Vector array) containing the precinct dimensions (width and
- // height) for the specified (or not) tile/component
- if (tileSpecified && compSpecified)
- {
- mrl = ((System.Int32)dls.getTileCompVal(t, c));
- v = (System.Collections.ArrayList[])getTileCompVal(t, c);
- }
- else if (tileSpecified && !compSpecified)
- {
- mrl = ((System.Int32)dls.getTileDef(t));
- v = (System.Collections.ArrayList[])getTileDef(t);
- }
- else if (!tileSpecified && compSpecified)
- {
- mrl = ((System.Int32)dls.getCompDef(c));
- v = (System.Collections.ArrayList[])getCompDef(c);
- }
- else
- {
- mrl = ((System.Int32)dls.getDefault());
- v = (System.Collections.ArrayList[])getDefault();
- }
- idx = mrl - rl;
- if (v[0].Count > idx)
- {
- return ((System.Int32)v[0][idx]);
- }
- else
- {
- return ((System.Int32)v[0][v[0].Count - 1]);
- }
- }
-
- /// Returns the precinct partition height in component 'n' and tile 't' at
- /// resolution level 'rl'. If the tile index is equal to -1 or if the
- /// component index is equal to -1 it means that those should not be taken
- /// into account.
- ///
- ///
- /// The tile index, in raster scan order. Specify -1 if it is not
- /// a specific tile.
- ///
- ///
- /// The component index. Specify -1 if it is not a specific
- /// component.
- ///
- ///
- /// The resolution level.
- ///
- ///
- /// The precinct partition width in component 'n' and tile 't' at
- /// resolution level 'rl'.
- ///
- ///
- public virtual int getPPY(int t, int c, int rl)
- {
- int mrl, idx;
- System.Collections.ArrayList[] v = null;
- bool tileSpecified = (t != -1 ? true : false);
- bool compSpecified = (c != -1 ? true : false);
-
- // Get the maximum number of decomposition levels and the object
- // (Vector array) containing the precinct dimensions (width and
- // height) for the specified (or not) tile/component
- if (tileSpecified && compSpecified)
- {
- mrl = ((System.Int32)dls.getTileCompVal(t, c));
- v = (System.Collections.ArrayList[])getTileCompVal(t, c);
- }
- else if (tileSpecified && !compSpecified)
- {
- mrl = ((System.Int32)dls.getTileDef(t));
- v = (System.Collections.ArrayList[])getTileDef(t);
- }
- else if (!tileSpecified && compSpecified)
- {
- mrl = ((System.Int32)dls.getCompDef(c));
- v = (System.Collections.ArrayList[])getCompDef(c);
- }
- else
- {
- mrl = ((System.Int32)dls.getDefault());
- v = (System.Collections.ArrayList[])getDefault();
- }
- idx = mrl - rl;
- if (v[1].Count > idx)
- {
- return ((System.Int32)v[1][idx]);
- }
- else
- {
- return ((System.Int32)v[1][v[1].Count - 1]);
- }
- }
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/entropy/Progression.cs b/CSJ2K/j2k/entropy/Progression.cs
deleted file mode 100644
index b3eea5de..00000000
--- a/CSJ2K/j2k/entropy/Progression.cs
+++ /dev/null
@@ -1,153 +0,0 @@
-/*
-* CVS identifier:
-*
-* $Id : $
-*
-* Class: Progression
-*
-* Description: Holds the type(s) of progression
-*
-*
-* Modified by:
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-*
-*
-*
-*/
-using CSJ2K.j2k.codestream;
-namespace CSJ2K.j2k.entropy
-{
-
- /// This class holds one of the different progression orders defined in
- /// the bit stream. The type(s) of progression order are defined in the
- /// ProgressionType interface. A Progression object is totally defined
- /// by its component start and end, resolution level start and end and
- /// layer start and end indexes. If no progression order change is
- /// defined, there is only Progression instance.
- ///
- ///
- ///
- ///
- ///
- public class Progression
- {
-
- /// Progression type as defined in ProgressionType interface
- public int type;
-
- /// Component index for the start of a progression
- public int cs;
-
- /// Component index for the end of a progression.
- public int ce;
-
- /// Resolution index for the start of a progression
- public int rs;
-
- /// Resolution index for the end of a progression.
- public int re;
-
- /// The index of the last layer.
- public int lye;
-
- /// Constructor.
- ///
- /// Builds a new Progression object with specified type and bounds
- /// of progression.
- ///
- ///
- /// The progression type
- ///
- ///
- /// The component index start
- ///
- ///
- /// The component index end
- ///
- ///
- /// The resolution level index start
- ///
- ///
- /// The resolution level index end
- ///
- ///
- /// The layer index end
- ///
- ///
- public Progression(int type, int cs, int ce, int rs, int re, int lye)
- {
- this.type = type;
- this.cs = cs;
- this.ce = ce;
- this.rs = rs;
- this.re = re;
- this.lye = lye;
- }
-
- public override System.String ToString()
- {
- System.String str = "type= ";
- switch (type)
- {
-
- case CSJ2K.j2k.codestream.ProgressionType.LY_RES_COMP_POS_PROG:
- str += "layer, ";
- break;
-
- case CSJ2K.j2k.codestream.ProgressionType.RES_LY_COMP_POS_PROG:
- str += "res, ";
- break;
-
- case CSJ2K.j2k.codestream.ProgressionType.RES_POS_COMP_LY_PROG:
- str += "res-pos, ";
- break;
-
- case CSJ2K.j2k.codestream.ProgressionType.POS_COMP_RES_LY_PROG:
- str += "pos-comp, ";
- break;
-
- case CSJ2K.j2k.codestream.ProgressionType.COMP_POS_RES_LY_PROG:
- str += "pos-comp, ";
- break;
-
- default:
- throw new System.ApplicationException("Unknown progression type");
-
- }
- str += ("comp.: " + cs + "-" + ce + ", ");
- str += ("res.: " + rs + "-" + re + ", ");
- str += ("layer: up to " + lye);
- return str;
- }
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/entropy/ProgressionSpec.cs b/CSJ2K/j2k/entropy/ProgressionSpec.cs
deleted file mode 100644
index bea02f9f..00000000
--- a/CSJ2K/j2k/entropy/ProgressionSpec.cs
+++ /dev/null
@@ -1,450 +0,0 @@
-/*
-* CVS identifier:
-*
-* $Id: ProgressionSpec.java,v 1.19 2001/05/02 14:08:42 grosbois Exp $
-*
-* Class: ProgressionSpec
-*
-* Description: Specification of the progression(s) type(s) and
-* changes of progression.
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-* */
-using CSJ2K.j2k.codestream;
-using CSJ2K.j2k.util;
-namespace CSJ2K.j2k.entropy
-{
-
- /// This class extends ModuleSpec class for progression type(s) and progression
- /// order changes holding purposes.
- ///
- /// It stores the progression type(s) used in the codestream. There can be
- /// several progression type(s) if progression order changes are used (POC
- /// markers).
- ///
- ///
- public class ProgressionSpec : ModuleSpec
- {
-
- /// Creates a new ProgressionSpec object for the specified number of tiles
- /// and components.
- ///
- ///
- /// The number of tiles
- ///
- ///
- /// The number of components
- ///
- ///
- /// the type of the specification module i.e. tile specific,
- /// component specific or both. The ProgressionSpec class should only be
- /// used only with the type ModuleSpec.SPEC_TYPE_TILE.
- ///
- ///
- public ProgressionSpec(int nt, int nc, byte type) : base(nt, nc, type)
- {
- if (type != ModuleSpec.SPEC_TYPE_TILE)
- {
- throw new System.ApplicationException("Illegal use of class ProgressionSpec !");
- }
- }
-
- /// Creates a new ProgressionSpec object for the specified number of tiles,
- /// components and the ParameterList instance.
- ///
- ///
- /// The number of tiles
- ///
- ///
- /// The number of components
- ///
- ///
- /// The number of layer
- ///
- ///
- /// The number of decomposition levels specifications
- ///
- ///
- /// the type of the specification module. The ProgressionSpec
- /// class should only be used only with the type ModuleSpec.SPEC_TYPE_TILE.
- ///
- ///
- /// The ParameterList instance
- ///
- ///
- public ProgressionSpec(int nt, int nc, int nl, IntegerSpec dls, byte type, ParameterList pl) : base(nt, nc, type)
- {
-
- System.String param = pl.getParameter("Aptype");
- Progression[] prog;
- int mode = -1;
-
- if (param == null)
- {
- // No parameter specified
- if (pl.getParameter("Rroi") == null)
- {
- mode = checkProgMode("res");
- }
- else
- {
- mode = checkProgMode("layer");
- }
-
- if (mode == -1)
- {
- System.String errMsg = "Unknown progression type : '" + param + "'";
- throw new System.ArgumentException(errMsg);
- }
- prog = new Progression[1];
- prog[0] = new Progression(mode, 0, nc, 0, dls.Max + 1, nl);
- setDefault(prog);
- return;
- }
-
- SupportClass.Tokenizer stk = new SupportClass.Tokenizer(param);
- byte curSpecType = SPEC_DEF; // Specification type of the
- // current parameter
- bool[] tileSpec = null; // Tiles concerned by the specification
- System.String word = null; // current word
- System.String errMsg2 = null; // Error message
- bool needInteger = false; // True if an integer value is expected
- int intType = 0; // Type of read integer value (0=index of first
- // resolution level, 1= index of first component, 2=index of first
- // layer not included, 3= index of first resolution level not
- // included, 4= index of first component not included
- System.Collections.ArrayList progression = System.Collections.ArrayList.Synchronized(new System.Collections.ArrayList(10));
- int tmp = 0;
- Progression curProg = null;
-
- while (stk.HasMoreTokens())
- {
- word = stk.NextToken();
-
- switch (word[0])
- {
-
- case 't':
- // If progression were previously found, store them
- if (progression.Count > 0)
- {
- // Ensure that all information has been taken
- curProg.ce = nc;
- curProg.lye = nl;
- curProg.re = dls.Max + 1;
- prog = new Progression[progression.Count];
- progression.CopyTo(prog);
- if (curSpecType == SPEC_DEF)
- {
- setDefault(prog);
- }
- else if (curSpecType == SPEC_TILE_DEF)
- {
- for (int i = tileSpec.Length - 1; i >= 0; i--)
- if (tileSpec[i])
- {
- setTileDef(i, prog);
- }
- }
- }
- progression.Clear();
- intType = -1;
- needInteger = false;
-
- // Tiles specification
- tileSpec = parseIdx(word, nTiles);
- curSpecType = SPEC_TILE_DEF;
- break;
-
- default:
- // Here, words is either a Integer (progression bound index)
- // or a String (progression order type). This is determined by
- // the value of needInteger.
- if (needInteger)
- {
- // Progression bound info
- try
- {
- tmp = (System.Int32.Parse(word));
- }
- catch (System.FormatException)
- {
- // Progression has missing parameters
- throw new System.ArgumentException("Progression " + "order" + " specification " + "has missing " + "parameters: " + param);
- }
-
- switch (intType)
- {
-
- case 0: // cs
- if (tmp < 0 || tmp > (dls.Max + 1))
- throw new System.ArgumentException("Invalid res_start " + "in '-Aptype'" + " option: " + tmp);
- curProg.rs = tmp; break;
-
- case 1: // rs
- if (tmp < 0 || tmp > nc)
- {
- throw new System.ArgumentException("Invalid comp_start " + "in '-Aptype' " + "option: " + tmp);
- }
- curProg.cs = tmp; break;
-
- case 2: // lye
- if (tmp < 0)
- throw new System.ArgumentException("Invalid layer_end " + "in '-Aptype'" + " option: " + tmp);
- if (tmp > nl)
- {
- tmp = nl;
- }
- curProg.lye = tmp; break;
-
- case 3: // ce
- if (tmp < 0)
- throw new System.ArgumentException("Invalid res_end " + "in '-Aptype'" + " option: " + tmp);
- if (tmp > (dls.Max + 1))
- {
- tmp = dls.Max + 1;
- }
- curProg.re = tmp; break;
-
- case 4: // re
- if (tmp < 0)
- throw new System.ArgumentException("Invalid comp_end " + "in '-Aptype'" + " option: " + tmp);
- if (tmp > nc)
- {
- tmp = nc;
- }
- curProg.ce = tmp; break;
- }
-
- if (intType < 4)
- {
- intType++;
- needInteger = true;
- break;
- }
- else if (intType == 4)
- {
- intType = 0;
- needInteger = false;
- break;
- }
- else
- {
- throw new System.ApplicationException("Error in usage of 'Aptype' " + "option: " + param);
- }
- }
-
- if (!needInteger)
- {
- // Progression type info
- mode = checkProgMode(word);
- if (mode == -1)
- {
- errMsg2 = "Unknown progression type : '" + word + "'";
- throw new System.ArgumentException(errMsg2);
- }
- needInteger = true;
- intType = 0;
- if (progression.Count == 0)
- {
- curProg = new Progression(mode, 0, nc, 0, dls.Max + 1, nl);
- }
- else
- {
- curProg = new Progression(mode, 0, nc, 0, dls.Max + 1, nl);
- }
- progression.Add(curProg);
- }
- break;
-
- } // switch
- } // while
-
- if (progression.Count == 0)
- {
- // No progression defined
- if (pl.getParameter("Rroi") == null)
- {
- mode = checkProgMode("res");
- }
- else
- {
- mode = checkProgMode("layer");
- }
- if (mode == -1)
- {
- errMsg2 = "Unknown progression type : '" + param + "'";
- throw new System.ArgumentException(errMsg2);
- }
- prog = new Progression[1];
- prog[0] = new Progression(mode, 0, nc, 0, dls.Max + 1, nl);
- setDefault(prog);
- return;
- }
-
- // Ensure that all information has been taken
- curProg.ce = nc;
- curProg.lye = nl;
- curProg.re = dls.Max + 1;
-
- // Store found progression
- prog = new Progression[progression.Count];
- progression.CopyTo(prog);
-
- if (curSpecType == SPEC_DEF)
- {
- setDefault(prog);
- }
- else if (curSpecType == SPEC_TILE_DEF)
- {
- for (int i = tileSpec.Length - 1; i >= 0; i--)
- if (tileSpec[i])
- {
- setTileDef(i, prog);
- }
- }
-
- // Check that default value has been specified
- if (getDefault() == null)
- {
- int ndefspec = 0;
- for (int t = nt - 1; t >= 0; t--)
- {
- for (int c = nc - 1; c >= 0; c--)
- {
- if (specValType[t][c] == SPEC_DEF)
- {
- ndefspec++;
- }
- }
- }
-
- // If some tile-component have received no specification, they
- // receive the default progressiveness.
- if (ndefspec != 0)
- {
- if (pl.getParameter("Rroi") == null)
- {
- mode = checkProgMode("res");
- }
- else
- {
- mode = checkProgMode("layer");
- }
- if (mode == -1)
- {
- errMsg2 = "Unknown progression type : '" + param + "'";
- throw new System.ArgumentException(errMsg2);
- }
- prog = new Progression[1];
- prog[0] = new Progression(mode, 0, nc, 0, dls.Max + 1, nl);
- setDefault(prog);
- }
- else
- {
- // All tile-component have been specified, takes the first
- // tile-component value as default.
- setDefault(getTileCompVal(0, 0));
- switch (specValType[0][0])
- {
-
- case SPEC_TILE_DEF:
- for (int c = nc - 1; c >= 0; c--)
- {
- if (specValType[0][c] == SPEC_TILE_DEF)
- specValType[0][c] = SPEC_DEF;
- }
- tileDef[0] = null;
- break;
-
- case SPEC_COMP_DEF:
- for (int t = nt - 1; t >= 0; t--)
- {
- if (specValType[t][0] == SPEC_COMP_DEF)
- specValType[t][0] = SPEC_DEF;
- }
- compDef[0] = null;
- break;
-
- case SPEC_TILE_COMP:
- specValType[0][0] = SPEC_DEF;
- tileCompVal["t0c0"] = null;
- break;
- }
- }
- }
- }
-
- /// Check if the progression mode exists and if so, return its integer
- /// value. It returns -1 otherwise.
- ///
- ///
- /// The progression mode stored in a string
- ///
- ///
- /// The integer value of the progression mode or -1 if the
- /// progression mode does not exist.
- ///
- ///
- ///
- ///
- ///
- private int checkProgMode(System.String mode)
- {
- if (mode.Equals("res"))
- {
- return CSJ2K.j2k.codestream.ProgressionType.RES_LY_COMP_POS_PROG;
- }
- else if (mode.Equals("layer"))
- {
- return CSJ2K.j2k.codestream.ProgressionType.LY_RES_COMP_POS_PROG;
- }
- else if (mode.Equals("pos-comp"))
- {
- return CSJ2K.j2k.codestream.ProgressionType.POS_COMP_RES_LY_PROG;
- }
- else if (mode.Equals("comp-pos"))
- {
- return CSJ2K.j2k.codestream.ProgressionType.COMP_POS_RES_LY_PROG;
- }
- else if (mode.Equals("res-pos"))
- {
- return CSJ2K.j2k.codestream.ProgressionType.RES_POS_COMP_LY_PROG;
- }
- else
- {
- // No corresponding progression mode, we return -1.
- return -1;
- }
- }
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/entropy/StdEntropyCoderOptions.cs b/CSJ2K/j2k/entropy/StdEntropyCoderOptions.cs
deleted file mode 100644
index 8543a33c..00000000
--- a/CSJ2K/j2k/entropy/StdEntropyCoderOptions.cs
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
-* CVS identifier:
-*
-* $Id: StdEntropyCoderOptions.java,v 1.10 2001/03/27 09:57:20 grosbois Exp $
-*
-* Class: StdEntropyCoderOptions
-*
-* Description: Entropy coding engine of stripes in
-* code-blocks options
-*
-*
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-* */
-namespace CSJ2K.j2k.entropy
-{
-
- /// This interface define the constants that identify the possible options for
- /// the entropy coder, as well some fixed parameters of the JPEG 2000 entropy
- /// coder.
- ///
- ///
- public struct StdEntropyCoderOptions
- {
- /// The flag bit to indicate that selective arithmetic coding bypass
- /// should be used. In this mode, the significance propagation and
- /// magnitude refinement passes bypass the arithmetic encoder in the fourth
- /// bit-plane and latter ones (but not the cleanup pass). Note that the
- /// transition between raw and AC segments needs terminations (whether or
- /// not OPT_TERM_PASS is used).
- ///
- public readonly static int OPT_BYPASS = 1;
- /// The flag bit to indicate that the MQ states for all contexts should be
- /// reset at the end of each (non-bypassed) coding pass.
- ///
- public readonly static int OPT_RESET_MQ = 1 << 1;
- /// The flag bit to indicate that a termination should be performed after
- /// each coding pass. Note that terminations are applied to both * *
- /// arithmetically coded and bypassed (i.e. raw) passes .
- ///
- public readonly static int OPT_TERM_PASS = 1 << 2;
- /// The flag bit to indicate the vertically stripe-causal context
- /// formation should be used.
- ///
- public readonly static int OPT_VERT_STR_CAUSAL = 1 << 3;
- /// The flag bit to indicate that error resilience info is embedded on MQ
- /// termination. This corresponds to the predictable termination described
- /// in Annex D.4.2 of the FDIS
- ///
- public readonly static int OPT_PRED_TERM = 1 << 4;
- /// The flag bit to indicate that an error resilience segmentation symbol
- /// is to be inserted at the end of each cleanup coding pass. The
- /// segmentation symbol is the four symbol sequence 1010 that are sent
- /// through the MQ coder using the UNIFORM context (as explained in annex
- /// D.5 of FDIS).
- ///
- public readonly static int OPT_SEG_SYMBOLS = 1 << 5;
- /// The minimum code-block dimension. The nominal width or height of a
- /// code-block must never be less than this. It is 4.
- ///
- public readonly static int MIN_CB_DIM = 4;
- /// The maximum code-block dimension. No code-block should be larger,
- /// either in width or height, than this value. It is 1024.
- ///
- public readonly static int MAX_CB_DIM = 1024;
- /// The maximum code-block area (width x height). The surface covered by
- /// a nominal size block should never be larger than this. It is 4096
- ///
- public readonly static int MAX_CB_AREA = 4096;
- /// The stripe height. This is the nominal value of the stripe height. It
- /// is 4.
- ///
- public readonly static int STRIPE_HEIGHT = 4;
- /// The number of coding passes per bit-plane. This is the number of
- /// passes per bit-plane. It is 3.
- ///
- public readonly static int NUM_PASSES = 3;
- /// The number of most significant bit-planes where bypass mode is not to
- /// be used, even if bypass mode is on: 4.
- ///
- public readonly static int NUM_NON_BYPASS_MS_BP = 4;
- /// The number of empty passes in the most significant bit-plane. It is
- /// 2.
- ///
- public readonly static int NUM_EMPTY_PASSES_IN_MS_BP = 2;
- /// The index of the first "raw" pass, if bypass mode is on.
- public readonly static int FIRST_BYPASS_PASS_IDX;
- static StdEntropyCoderOptions()
- {
- FIRST_BYPASS_PASS_IDX = CSJ2K.j2k.entropy.StdEntropyCoderOptions.NUM_PASSES * CSJ2K.j2k.entropy.StdEntropyCoderOptions.NUM_NON_BYPASS_MS_BP - CSJ2K.j2k.entropy.StdEntropyCoderOptions.NUM_EMPTY_PASSES_IN_MS_BP;
- }
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/entropy/decoder/ByteInputBuffer.cs b/CSJ2K/j2k/entropy/decoder/ByteInputBuffer.cs
deleted file mode 100644
index 71fa1d2a..00000000
--- a/CSJ2K/j2k/entropy/decoder/ByteInputBuffer.cs
+++ /dev/null
@@ -1,276 +0,0 @@
-/*
-* CVS identifier:
-*
-* $Id: ByteInputBuffer.java,v 1.13 2001/10/17 17:01:57 grosbois Exp $
-*
-* Class: ByteInputBuffer
-*
-* Description: Provides buffering for byte based input, similar
-* to the standard class ByteArrayInputStream
-*
-* the old jj2000.j2k.io.ByteArrayInput class by
-* Diego SANTA CRUZ, Apr-26-1999
-*
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-* */
-using System;
-namespace CSJ2K.j2k.entropy.decoder
-{
-
- /// This class provides a byte input facility from byte buffers. It is similar
- /// to the ByteArrayInputStream class, but adds the possibility to add data to
- /// the stream after the creation of the object.
- ///
- /// Unlike the ByteArrayInputStream this class is not thread safe (i.e. no
- /// two threads can use the same object at the same time, but different objects
- /// may be used in different threads).
- ///
- /// This class can modify the contents of the buffer given to the
- /// constructor, when the addByteArray() method is called.
- ///
- ///
- ///
- ///
- ///
- public class ByteInputBuffer
- {
-
- /// The byte array containing the data
- private byte[] buf;
-
- /// The index one greater than the last valid character in the input
- /// stream buffer
- ///
- private int count;
-
- /// The index of the next character to read from the input stream buffer
- ///
- ///
- private int pos;
-
- /// Creates a new byte array input stream that reads data from the
- /// specified byte array. The byte array is not copied.
- ///
- ///
- /// the input buffer.
- ///
- ///
- public ByteInputBuffer(byte[] buf)
- {
- this.buf = buf;
- count = buf.Length;
- }
-
- /// Creates a new byte array input stream that reads data from the
- /// specified byte array. Up to length characters are to be read from the
- /// byte array, starting at the indicated offset.
- ///
- /// The byte array is not copied.
- ///
- ///
- /// the input buffer.
- ///
- ///
- /// the offset in the buffer of the first byte to read.
- ///
- ///
- /// the maximum number of bytes to read from the buffer.
- ///
- ///
- public ByteInputBuffer(byte[] buf, int offset, int length)
- {
- this.buf = buf;
- pos = offset;
- count = offset + length;
- }
-
- /// Sets the underlying buffer byte array to the given one, with the given
- /// offset and length. If 'buf' is null then the current byte buffer is
- /// assumed. If 'offset' is negative, then it will be assumed to be
- /// 'off+len', where 'off' and 'len' are the offset and length of the
- /// current byte buffer.
- ///
- /// The byte array is not copied.
- ///
- ///
- /// the input buffer. If null it is the current input buffer.
- ///
- ///
- /// the offset in the buffer of the first byte to read. If
- /// negative it is assumed to be the byte just after the end of the current
- /// input buffer, only permitted if 'buf' is null.
- ///
- ///
- /// the maximum number of bytes to read frmo the buffer.
- ///
- ///
- public virtual void setByteArray(byte[] buf, int offset, int length)
- {
- // In same buffer?
- if (buf == null)
- {
- if (length < 0 || count + length > this.buf.Length)
- {
- throw new System.ArgumentException();
- }
- if (offset < 0)
- {
- pos = count;
- count += length;
- }
- else
- {
- count = offset + length;
- pos = offset;
- }
- }
- else
- {
- // New input buffer
- if (offset < 0 || length < 0 || offset + length > buf.Length)
- {
- throw new System.ArgumentException();
- }
- this.buf = buf;
- count = offset + length;
- pos = offset;
- }
- }
-
- /// Adds the specified data to the end of the byte array stream. This
- /// method modifies the byte array buffer. It can also discard the already
- /// read input.
- ///
- ///
- /// The data to add. The data is copied.
- ///
- ///
- /// The index, in data, of the first element to add to the
- /// stream.
- ///
- ///
- /// The number of elements to add to the array.
- ///
- ///
- //UPGRADE_NOTE: Synchronized keyword was removed from method 'addByteArray'. Lock expression was added. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1027'"
- public virtual void addByteArray(byte[] data, int off, int len)
- {
- lock (this)
- {
- // Check integrity
- if (len < 0 || off < 0 || len + off > buf.Length)
- {
- throw new System.ArgumentException();
- }
- // Copy new data
- if (count + len <= buf.Length)
- {
- // Enough place in 'buf'
- Array.Copy(data, off, buf, count, len);
- count += len;
- }
- else
- {
- if (count - pos + len <= buf.Length)
- {
- // Enough place in 'buf' if we move input data
- // Move buffer
- Array.Copy(buf, pos, buf, 0, count - pos);
- }
- else
- {
- // Not enough place in 'buf', use new buffer
- byte[] oldbuf = buf;
- buf = new byte[count - pos + len];
- // Copy buffer
- Array.Copy(oldbuf, count, buf, 0, count - pos);
- }
- count -= pos;
- pos = 0;
- // Copy new data
- Array.Copy(data, off, buf, count, len);
- count += len;
- }
- }
- }
-
- /// Reads the next byte of data from this input stream. The value byte is
- /// returned as an int in the range 0 to 255. If no byte is available
- /// because the end of the stream has been reached, the EOFException
- /// exception is thrown.
- ///
- /// This method is not synchronized, so it is not thread safe.
- ///
- ///
- /// The byte read in the range 0-255.
- ///
- ///
- /// If the end of the stream is reached.
- ///
- ///
- public virtual int readChecked()
- {
- if (pos < count)
- {
- return (int)buf[pos++] & 0xFF;
- }
- else
- {
- throw new System.IO.EndOfStreamException();
- }
- }
-
- /// Reads the next byte of data from this input stream. The value byte is
- /// returned as an int in the range 0 to 255. If no byte is available
- /// because the end of the stream has been reached, -1 is returned.
- ///
- /// This method is not synchronized, so it is not thread safe.
- ///
- ///
- /// The byte read in the range 0-255, or -1 if the end of stream
- /// has been reached.
- ///
- ///
- public virtual int read()
- {
- if (pos < count)
- {
- return (int)buf[pos++] & 0xFF;
- }
- else
- {
- return -1;
- }
- }
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/entropy/decoder/ByteToBitInput.cs b/CSJ2K/j2k/entropy/decoder/ByteToBitInput.cs
deleted file mode 100644
index c69e707a..00000000
--- a/CSJ2K/j2k/entropy/decoder/ByteToBitInput.cs
+++ /dev/null
@@ -1,195 +0,0 @@
-/*
-* CVS identifier:
-*
-* $Id: ByteToBitInput.java,v 1.14 2002/07/19 12:41:33 grosbois Exp $
-*
-* Class: ByteToBitInput
-*
-* Description: Adapter to perform bit based input from a byte
-* based one.
-*
-*
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-* */
-namespace CSJ2K.j2k.entropy.decoder
-{
-
- /// This class provides an adapter to perform bit based input on byte based
- /// output obejcts that inherit from a 'ByteInputBuffer' class. This class also
- /// performs the bit unstuffing procedure specified for the 'selective
- /// arithmetic coding bypass' mode of the JPEG 2000 entropy coder.
- ///
- ///
- public class ByteToBitInput
- {
-
- /// The byte based input
- internal ByteInputBuffer in_Renamed;
-
- /// The bit buffer
- internal int bbuf;
-
- /// The position of the next bit to get from the byte buffer. When it is
- /// -1 the bit buffer is empty.
- ///
- internal int bpos = -1;
-
- /// Instantiates a new 'ByteToBitInput' object that uses 'in' as the
- /// underlying byte based input.
- ///
- ///
- /// The underlying byte based input.
- ///
- ///
- public ByteToBitInput(ByteInputBuffer in_Renamed)
- {
- this.in_Renamed = in_Renamed;
- }
-
- /// Reads from the bit stream one bit. If 'bpos' is -1 then a byte is read
- /// and loaded into the bit buffer, from where the bit is read. If
- /// necessary the bit unstuffing will be applied.
- ///
- ///
- /// The read bit (0 or 1).
- ///
- ///
- public int readBit()
- {
- if (bpos < 0)
- {
- if ((bbuf & 0xFF) != 0xFF)
- {
- // Normal byte to read
- bbuf = in_Renamed.read();
- bpos = 7;
- }
- else
- {
- // Previous byte is 0xFF => there was bit stuffing
- bbuf = in_Renamed.read();
- bpos = 6;
- }
- }
- return (bbuf >> bpos--) & 0x01;
- }
-
- /// Checks for past errors in the decoding process by verifying the byte
- /// padding with an alternating sequence of 0's and 1's. If an error is
- /// detected it means that the raw bit stream has been wrongly decoded or
- /// that the raw terminated segment length is too long. If no errors are
- /// detected it does not necessarily mean that the raw bit stream has been
- /// correctly decoded.
- ///
- ///
- /// True if errors are found, false otherwise.
- ///
- ///
- public virtual bool checkBytePadding()
- {
- int seq; // Byte padding sequence in last byte
-
- // If there are no spare bits and bbuf is 0xFF (not EOF), then there
- // is a next byte with bit stuffing that we must load.
- if (bpos < 0 && (bbuf & 0xFF) == 0xFF)
- {
- bbuf = in_Renamed.read();
- bpos = 6;
- }
-
- // 1) Not yet read bits in the last byte must be an alternating
- // sequence of 0s and 1s, starting with 0.
- if (bpos >= 0)
- {
- seq = bbuf & ((1 << (bpos + 1)) - 1);
- if (seq != (0x55 >> (7 - bpos)))
- return true;
- }
-
- // 2) We must have already reached the last byte in the terminated
- // segment, unless last bit read is LSB of FF in which case an encoder
- // can output an extra byte which is smaller than 0x80.
- if (bbuf != -1)
- {
- if (bbuf == 0xFF && bpos == 0)
- {
- if ((in_Renamed.read() & 0xFF) >= 0x80)
- return true;
- }
- else
- {
- if (in_Renamed.read() != -1)
- return true;
- }
- }
-
- // Nothing detected
- return false;
- }
-
- /// Flushes (i.e. empties) the bit buffer, without loading any new
- /// bytes. This realigns the input at the next byte boundary, if not
- /// already at one.
- ///
- ///
- internal void flush()
- {
- bbuf = 0; // reset any bit stuffing state
- bpos = -1;
- }
-
- /// Resets the underlying byte input to start a new segment. The bit buffer
- /// is flushed.
- ///
- ///
- /// The byte array containing the byte data. If null the
- /// current byte array is assumed.
- ///
- ///
- /// The index of the first element in 'buf' to be decoded. If
- /// negative the byte just after the previous segment is assumed, only
- /// valid if 'buf' is null.
- ///
- ///
- /// The number of bytes in 'buf' to be decoded. Any subsequent
- /// bytes are taken to be 0xFF.
- ///
- ///
- internal void setByteArray(byte[] buf, int off, int len)
- {
- in_Renamed.setByteArray(buf, off, len);
- bbuf = 0; // reset any bit stuffing state
- bpos = -1;
- }
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/entropy/decoder/CodedCBlkDataSrcDec.cs b/CSJ2K/j2k/entropy/decoder/CodedCBlkDataSrcDec.cs
deleted file mode 100644
index cda5117b..00000000
--- a/CSJ2K/j2k/entropy/decoder/CodedCBlkDataSrcDec.cs
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
-* CVS identifier:
-*
-* $Id: CodedCBlkDataSrcDec.java,v 1.17 2001/09/14 09:26:23 grosbois Exp $
-*
-* Class: CodedCBlkDataSrcDec
-*
-* Description: Interface that defines a source of entropy coded
-* data that is transferred in a code-block by
-* code-block basis (decoder side).
-*
-*
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-* */
-using CSJ2K.j2k.wavelet.synthesis;
-namespace CSJ2K.j2k.entropy.decoder
-{
-
- /// This interface defines a source of entropy coded data and methods to
- /// transfer it in a code-block by code-block basis. In each call to
- /// 'geCodeBlock()' a specified coded code-block is returned.
- ///
- /// This interface is the source of data for the entropy decoder. See the
- /// 'EntropyDecoder' class.
- ///
- /// For each coded-code-block the entropy-coded data is returned along with
- /// its truncation point information in a 'DecLyrdCBlk' object.
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- public interface CodedCBlkDataSrcDec : InvWTData
- {
-
- /// Returns the specified coded code-block, for the specified component, in
- /// the current tile. The first layer to return is indicated by 'fl'. The
- /// number of layers that is returned depends on 'nl' and the amount of
- /// data available.
- ///
- /// The argument 'fl' is to be used by subsequent calls to this method
- /// for the same code-block. In this way supplamental data can be retrieved
- /// at a later time. The fact that data from more than one layer can be
- /// returned means that several packets from the same code-block, of the
- /// same component, and the same tile, have been concatenated.
- ///
- /// The returned compressed code-block can have its progressive
- /// attribute set. If this attribute is set it means that more data can be
- /// obtained by subsequent calls to this method (subject to transmission
- /// delays, etc). If the progressive attribute is not set it means that the
- /// returned data is all the data that can be obtained for the specified
- /// subblock.
- ///
- /// The compressed code-block is uniquely specified by the current tile,
- /// the component (identified by 'c'), the subband (indentified by 'sb')
- /// and the code-bock vertical and horizontal indexes 'm' and 'n'.
- ///
- /// The 'ulx' and 'uly' members of the returned 'DecLyrdCBlk' object
- /// contain the coordinates of the top-left corner of the block, with
- /// respect to the tile, not the subband.
- ///
- ///
- /// The index of the component, from 0 to N-1.
- ///
- ///
- /// The vertical index of the code-block to return, in the
- /// specified subband.
- ///
- ///
- /// The horizontal index of the code-block to return, in the
- /// specified subband.
- ///
- ///
- /// The subband in whic the requested code-block is.
- ///
- ///
- /// The first layer to return.
- ///
- ///
- /// The number of layers to return, if negative all available
- /// layers are returned, starting at 'fl'.
- ///
- ///
- /// If not null this object is used to return the compressed
- /// code-block. If null a new object is created and returned. If the data
- /// array in ccb is not null then it can be reused to return the compressed
- /// data.
- ///
- ///
- /// The compressed code-block, with a certain number of layers
- /// determined by the available data and 'nl'.
- ///
- ///
- DecLyrdCBlk getCodeBlock(int c, int m, int n, SubbandSyn sb, int fl, int nl, DecLyrdCBlk ccb);
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/entropy/decoder/DecLyrdCBlk.cs b/CSJ2K/j2k/entropy/decoder/DecLyrdCBlk.cs
deleted file mode 100644
index 118c7d7f..00000000
--- a/CSJ2K/j2k/entropy/decoder/DecLyrdCBlk.cs
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
-* CVS identifier:
-*
-* $Id: DecLyrdCBlk.java,v 1.9 2001/09/14 09:25:01 grosbois Exp $
-*
-* Class: DecLyrdCBlk
-*
-* Description: The coded (compressed) code-block
-* with layered organization for the decoder.
-*
-*
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-* */
-namespace CSJ2K.j2k.entropy.decoder
-{
-
- /// This class stores coded (compressed) code-blocks that are organized in
- /// layers. This object can contain either all code-block data (i.e. all
- /// layers), or a subset of all the layers that make up the whole compressed
- /// code-block. It is applicable to the decoder engine only. Some data of the
- /// coded-block is stored in the super class, see CodedCBlk.
- ///
- /// A code-block may have its progressive attribute set (i.e. the 'prog'
- /// flag is true). If a code-block is progressive then it means that more data
- /// for it may be obtained for an improved quality. If the progressive flag is
- /// false then no more data is available from the source for this
- /// code-block.
- ///
- ///
- ///
- ///
- ///
- public class DecLyrdCBlk : CodedCBlk
- {
-
- /// The horizontal coordinate of the upper-left corner of the code-block
- public int ulx;
-
- /// The vertical coordinate of the upper left corner of the code-block
- public int uly;
-
- /// The width of the code-block
- public int w;
-
- /// The height of the code-block
- public int h;
-
- /// The coded (compressed) data length. The data is stored in the 'data'
- /// array (see super class).
- ///
- public int dl;
-
- /// The progressive flag, false by default (see above).
- public bool prog;
-
- /// The number of layers in the coded data.
- public int nl;
-
- /// The index of the first truncation point returned
- public int ftpIdx;
-
- /// The total number of truncation points from layer 1 to the last one in
- /// this object. The number of truncation points in 'data' is
- /// 'nTrunc-ftpIdx'.
- ///
- public int nTrunc;
-
- /// The length of each terminated segment. If null then there is only one
- /// terminated segment, and its length is 'dl'. The number of terminated
- /// segments is to be deduced from 'ftpIdx', 'nTrunc' and the coding
- /// options. This array contains all terminated segments from the 'ftpIdx'
- /// truncation point, upto, and including, the 'nTrunc-1' truncation
- /// point. Any data after 'nTrunc-1' is not included in any length.
- ///
- public int[] tsLengths;
-
- /// Object information in a string
- ///
- ///
- /// Information in a string
- ///
- ///
- public override System.String ToString()
- {
- System.String str = "Coded code-block (" + m + "," + n + "): " + skipMSBP + " MSB skipped, " + dl + " bytes, " + nTrunc + " truncation points, " + nl + " layers, " + "progressive=" + prog + ", ulx=" + ulx + ", uly=" + uly + ", w=" + w + ", h=" + h + ", ftpIdx=" + ftpIdx;
- if (tsLengths != null)
- {
- str += " {";
- for (int i = 0; i < tsLengths.Length; i++)
- str += (" " + tsLengths[i]);
- str += " }";
- }
- return str;
- }
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/entropy/decoder/EntropyDecoder.cs b/CSJ2K/j2k/entropy/decoder/EntropyDecoder.cs
deleted file mode 100644
index f776176e..00000000
--- a/CSJ2K/j2k/entropy/decoder/EntropyDecoder.cs
+++ /dev/null
@@ -1,167 +0,0 @@
-/*
-* CVS identifier:
-*
-* $Id: EntropyDecoder.java,v 1.38 2001/09/20 12:48:01 grosbois Exp $
-*
-* Class: EntropyDecoder
-*
-* Description: The abstract class for all entropy decoders.
-*
-*
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-* */
-using CSJ2K.j2k.quantization.dequantizer;
-using CSJ2K.j2k.wavelet.synthesis;
-namespace CSJ2K.j2k.entropy.decoder
-{
-
- /// This is the abstract class from which all entropy decoders must
- /// inherit. This class implements the 'MultiResImgData', therefore it has the
- /// concept of a current tile and all operations are performed on the current
- /// tile.
- ///
- /// Default implementations of the methods in 'MultiResImgData' are provided
- /// through the 'MultiResImgDataAdapter' abstract class.
- ///
- /// Sign magnitude representation is used (instead of two's complement) for
- /// the output data. The most significant bit is used for the sign (0 if
- /// positive, 1 if negative). Then the magnitude of the quantized coefficient
- /// is stored in the next most significat bits. The most significant magnitude
- /// bit corresponds to the most significant bit-plane and so on.
- ///
- ///
- ///
- ///
- ///
- public abstract class EntropyDecoder : MultiResImgDataAdapter, CBlkQuantDataSrcDec
- {
- /// Returns the horizontal code-block partition origin. Allowable values
- /// are 0 and 1, nothing else.
- ///
- ///
- virtual public int CbULX
- {
- get
- {
- return src.CbULX;
- }
-
- }
- /// Returns the vertical code-block partition origin. Allowable values are
- /// 0 and 1, nothing else.
- ///
- ///
- virtual public int CbULY
- {
- get
- {
- return src.CbULY;
- }
-
- }
- /// Returns the parameters that are used in this class and
- /// implementing classes. It returns a 2D String array. Each of the
- /// 1D arrays is for a different option, and they have 3
- /// elements. The first element is the option name, the second one
- /// is the synopsis and the third one is a long description of what
- /// the parameter is. The synopsis or description may be 'null', in
- /// which case it is assumed that there is no synopsis or
- /// description of the option, respectively. Null may be returned
- /// if no options are supported.
- ///
- ///
- /// the options name, their synopsis and their explanation,
- /// or null if no options are supported.
- ///
- ///
- public static System.String[][] ParameterInfo
- {
- get
- {
- return pinfo;
- }
-
- }
-
- /// The prefix for entropy decoder optiojns: 'C'
- public const char OPT_PREFIX = 'C';
-
- /// The list of parameters that is accepted by the entropy
- /// decoders. They start with 'C'.
- ///
- //UPGRADE_NOTE: Final was removed from the declaration of 'pinfo'. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- private static readonly System.String[][] pinfo = new System.String[][] { new System.String[] { "Cverber", "[on|off]", "Specifies if the entropy decoder should be verbose about detected " + "errors. If 'on' a message is printed whenever an error is detected.", "on" }, new System.String[] { "Cer", "[on|off]", "Specifies if error detection should be performed by the entropy " + "decoder engine. If errors are detected they will be concealed and " + "the resulting distortion will be less important. Note that errors " + "can only be detected if the encoder that generated the data " + "included error resilience information.", "on" } };
-
- /// The bit stream transport from where to get the compressed data
- /// (the source)
- ///
- protected internal CodedCBlkDataSrcDec src;
-
- /// Initializes the source of compressed data.
- ///
- ///
- /// From where to obtain the compressed data.
- ///
- ///
- public EntropyDecoder(CodedCBlkDataSrcDec src) : base(src)
- {
- this.src = src;
- }
-
- /// Returns the subband tree, for the specified tile-component. This method
- /// returns the root element of the subband tree structure, see Subband and
- /// SubbandSyn. The tree comprises all the available resolution levels.
- ///
- /// The number of magnitude bits ('magBits' member variable) for
- /// each subband is not initialized.
- ///
- ///
- /// The index of the tile, from 0 to T-1.
- ///
- ///
- /// The index of the component, from 0 to C-1.
- ///
- ///
- /// The root of the tree structure.
- ///
- ///
- public override SubbandSyn getSynSubbandTree(int t, int c)
- {
- return src.getSynSubbandTree(t, c);
- }
- public abstract CSJ2K.j2k.image.DataBlk getCodeBlock(int param1, int param2, int param3, CSJ2K.j2k.wavelet.synthesis.SubbandSyn param4, CSJ2K.j2k.image.DataBlk param5);
- public abstract CSJ2K.j2k.image.DataBlk getInternCodeBlock(int param1, int param2, int param3, CSJ2K.j2k.wavelet.synthesis.SubbandSyn param4, CSJ2K.j2k.image.DataBlk param5);
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/entropy/decoder/MQDecoder.cs b/CSJ2K/j2k/entropy/decoder/MQDecoder.cs
deleted file mode 100644
index eeb1d38c..00000000
--- a/CSJ2K/j2k/entropy/decoder/MQDecoder.cs
+++ /dev/null
@@ -1,811 +0,0 @@
-/*
-* CVS identifier:
-*
-* $Id: MQDecoder.java,v 1.32 2001/10/17 16:58:00 grosbois Exp $
-*
-* Class: MQDecoder
-*
-* Description: Class that encodes a number of bits using the
-* MQ arithmetic decoder
-*
-*
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-* */
-using CSJ2K.j2k.util;
-using System;
-namespace CSJ2K.j2k.entropy.decoder
-{
-
- /// This class implements the MQ arithmetic decoder. It is implemented using
- /// the software conventions decoder for better performance (i.e. execution
- /// time performance). The initial states for each context of the MQ-coder are
- /// specified in the constructor.
- ///
- ///
-
- // A trick to test for increased speed: merge the Qe and mPS into 1 thing by
- // using the sign bit of Qe to signal mPS (positive-or-0 is 0, negative is 1),
- // and doubling the Qe, nMPS and nLPS tables. This gets rid of the swicthLM
- // table since it can be integrated as special cases in the doubled nMPS and
- // nLPS tables. See the JPEG book, chapter 13. The decoded decision can be
- // calculated as (q>>>31).
-
- public class MQDecoder
- {
- /// Returns the number of contexts in the arithmetic coder.
- ///
- ///
- /// The number of contexts
- ///
- ///
- virtual public int NumCtxts
- {
- get
- {
- return I.Length;
- }
-
- }
- /// Returns the underlying 'ByteInputBuffer' from where the MQ coded input
- /// bytes are read.
- ///
- ///
- /// The underlying ByteInputBuffer.
- ///
- ///
- virtual public ByteInputBuffer ByteInputBuffer
- {
- get
- {
- return in_Renamed;
- }
-
- }
-
- /// The data structures containing the probabilities for the LPS
- //UPGRADE_NOTE: Final was removed from the declaration of 'qe'. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- internal static readonly uint[] qe = new uint[] { 0x5601, 0x3401, 0x1801, 0x0ac1, 0x0521, 0x0221, 0x5601, 0x5401, 0x4801, 0x3801, 0x3001, 0x2401, 0x1c01, 0x1601, 0x5601, 0x5401, 0x5101, 0x4801, 0x3801, 0x3401, 0x3001, 0x2801, 0x2401, 0x2201, 0x1c01, 0x1801, 0x1601, 0x1401, 0x1201, 0x1101, 0x0ac1, 0x09c1, 0x08a1, 0x0521, 0x0441, 0x02a1, 0x0221, 0x0141, 0x0111, 0x0085, 0x0049, 0x0025, 0x0015, 0x0009, 0x0005, 0x0001, 0x5601 };
-
- /// The indexes of the next MPS
- //UPGRADE_NOTE: Final was removed from the declaration of 'nMPS'. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- internal static readonly int[] nMPS = new int[] { 1, 2, 3, 4, 5, 38, 7, 8, 9, 10, 11, 12, 13, 29, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 45, 46 };
-
- /// The indexes of the next LPS
- //UPGRADE_NOTE: Final was removed from the declaration of 'nLPS'. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- internal static readonly int[] nLPS = new int[] { 1, 6, 9, 12, 29, 33, 6, 14, 14, 14, 17, 18, 20, 21, 14, 14, 15, 16, 17, 18, 19, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 46 };
-
- /// Whether LPS and MPS should be switched
- //UPGRADE_NOTE: Final was removed from the declaration of 'switchLM'. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- internal static readonly int[] switchLM = new int[] { 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
-
- /// The ByteInputBuffer used to read the compressed bit stream.
- internal ByteInputBuffer in_Renamed;
-
- /// The current most probable signal for each context
- internal int[] mPS;
-
- /// The current index of each context
- internal int[] I;
-
- /// The current bit code
- internal uint c;
-
- /// The bit code counter
- internal uint cT;
-
- /// The current interval
- internal uint a;
-
- /// The last byte read
- internal uint b;
-
- /// Flag indicating if a marker has been found
- internal bool markerFound;
-
- /// The initial state of each context
- //UPGRADE_NOTE: Final was removed from the declaration of 'initStates '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- internal int[] initStates;
-
- /// Instantiates a new MQ-decoder, with the specified number of contexts
- /// and initial states. The compressed bytestream is read from the
- /// 'iStream' object.
- ///
- ///
- /// the stream that contains the coded bits
- ///
- ///
- /// The number of contexts used
- ///
- ///
- /// The initial state for each context. A reference is
- /// kept to this array to reinitialize the contexts whenever 'reset()' or
- /// 'resetCtxts()' is called.
- ///
- ///
- public MQDecoder(ByteInputBuffer iStream, int nrOfContexts, int[] initStates)
- {
- in_Renamed = iStream;
-
- // Default initialization of the statistics bins is MPS=0 and
- // I=0
- I = new int[nrOfContexts];
- mPS = new int[nrOfContexts];
- // Save the initial states
- this.initStates = initStates;
-
- // Initialize
- init();
-
- // Set the contexts
- resetCtxts();
- }
-
- /// Decodes 'n' symbols from the bit stream using the same context
- /// 'ctxt'. If possible the MQ-coder speedup mode will be used to speed up
- /// decoding. The speedup mode is used if Q (the LPS probability for 'ctxt'
- /// is low enough) and the A and C registers permit decoding several MPS
- /// symbols without renormalization.
- ///
- /// Speedup mode should be used when decoding long runs of MPS with high
- /// probability with the same context.
- ///
- ///
This methiod will return the decoded symbols differently if speedup
- /// mode was used or not. If true is returned, then speedup mode was used
- /// and the 'n' decoded symbols are all the same and it is returned ain
- /// bits[0] only. If false is returned then speedup mode was not used, the
- /// decoded symbols are probably not all the same and they are returned in
- /// bits[0], bits[1], ... bits[n-1].
- ///
- ///
- /// The array where to put the decoded symbols. Must be of
- /// length 'n' or more.
- ///
- ///
- /// The context to use in decoding the symbols.
- ///
- ///
- /// The number of symbols to decode.
- ///
- ///
- /// True if speedup mode was used, false if not. If speedup mode
- /// was used then all the decoded symbols are the same and its value is
- /// returned in 'bits[0]' only (not in bits[1], bits[2], etc.).
- ///
- ///
- internal bool fastDecodeSymbols(int[] bits, int ctxt, uint n)
- {
- uint q; // LPS probability for context
- int idx; // Index of current state
- uint la; // cache for A register
- int i; // counter
-
- idx = I[ctxt];
- q = qe[idx];
-
- // This is a first attempt to implement speedup mode, it is probably
- // not the most efficient way of doing it.
-
- if ((q < 0x4000) && (n <= (a - (c >> 16) - 1) / q) && (n <= (a - 0x8000) / q + 1))
- {
- // Q is small enough. There will be no modification of C that
- // affects decoding, and Q can be substracted from A several
- // times. We will decode all MPS.
- a -= n * q;
- if (a >= 0x8000)
- {
- // No renormalization needed
- bits[0] = mPS[ctxt];
- return true; // Done, used speedup mode
- }
- else
- {
- // renormalization needed
- I[ctxt] = nMPS[idx];
- // Renormalize (MPS: no need for while loop)
- if (cT == 0)
- byteIn();
- a <<= 1;
- c <<= 1;
- cT--;
- // End renormalization
- bits[0] = mPS[ctxt];
- return true; // Done, used speedup mode
- }
- }
- else
- {
- // Normal mode
- la = a; // cache A register
- for (i = 0; i < n; i++)
- {
- la -= q;
- if ((c >> 16) < la)
- {
- if (la >= 0x8000)
- {
- bits[i] = mPS[ctxt];
- }
- else
- {
- // -- MPS Exchange
- if (la >= q)
- {
- bits[i] = mPS[ctxt];
- idx = nMPS[idx];
- q = qe[idx];
- // I[ctxt] set at end of loop
- // -- Renormalize (MPS: no need for while loop)
- if (cT == 0)
- byteIn();
- la <<= 1;
- c <<= 1;
- cT--;
- // -- End renormalization
- }
- else
- {
- bits[i] = 1 - mPS[ctxt];
- if (switchLM[idx] == 1)
- mPS[ctxt] = 1 - mPS[ctxt];
- idx = nLPS[idx];
- q = qe[idx];
- // I[ctxt] set at end of loop
- // -- Renormalize
- do
- {
- if (cT == 0)
- byteIn();
- la <<= 1;
- c <<= 1;
- cT--;
- }
- while (la < 0x8000);
- // -- End renormalization
- }
- // -- End MPS Exchange
- }
- }
- else
- {
- c -= (la << 16);
- // -- LPS Exchange
- if (la < q)
- {
- la = q;
- bits[i] = mPS[ctxt];
- idx = nMPS[idx];
- q = qe[idx];
- // I[ctxt] set at end of loop
- // -- Renormalize (MPS: no need for while loop)
- if (cT == 0)
- byteIn();
- la <<= 1;
- c <<= 1;
- cT--;
- // -- End renormalization
- }
- else
- {
- la = q;
- bits[i] = 1 - mPS[ctxt];
- if (switchLM[idx] == 1)
- mPS[ctxt] = 1 - mPS[ctxt];
- idx = nLPS[idx];
- q = qe[idx];
- // I[ctxt] set at end of loop
- // -- Renormalize
- do
- {
- if (cT == 0)
- byteIn();
- la <<= 1;
- c <<= 1;
- cT--;
- }
- while (la < 0x8000);
- // -- End renormalization
- }
- // -- End LPS Exchange
- }
- }
- a = la; // save cached A register
- I[ctxt] = idx; // save current index for context
- return false; // done, did not use speedup mode
- } // End normal mode
- }
-
- /// This function performs the arithmetic decoding. The function receives
- /// an array in which to put the decoded symbols and an array of contexts
- /// with which to decode them.
- ///
- /// Each context has a current MPS and an index describing what the
- /// current probability is for the LPS. Each bit is decoded and if the
- /// probability of the LPS exceeds .5, the MPS and LPS are switched.
- ///
- ///
- /// The array where to place the decoded symbols. It should be
- /// long enough to contain 'n' elements.
- ///
- ///
- /// The context to use in decoding each symbol.
- ///
- ///
- /// The number of symbols to decode
- ///
- ///
- public void decodeSymbols(int[] bits, int[] cX, int n)
- {
- uint q;
- int ctxt;
- uint la; // cache for A register value
- int index;
- int i;
-
- // NOTE: (a < 0x8000) is equivalent to ((a & 0x8000)==0)
- // since 'a' is always less than or equal to 0xFFFF
-
- // NOTE: conditional exchange guarantees that A for MPS is
- // always greater than 0x4000 (i.e. 0.375)
- // => one renormalization shift is enough for MPS
- // => no need to do a renormalization while loop for MPS
-
- for (i = 0; i < n; i++)
- {
- ctxt = cX[i];
-
- index = I[ctxt];
- q = qe[index];
-
- a -= q;
- if ((c >> 16) < a)
- {
- if (a >= 0x8000)
- {
- bits[i] = mPS[ctxt];
- }
- else
- {
- la = a;
- // -- MPS Exchange
- if (la >= q)
- {
- bits[i] = mPS[ctxt];
- I[ctxt] = nMPS[index];
- // -- Renormalize (MPS: no need for while loop)
- if (cT == 0)
- byteIn();
- la <<= 1;
- c <<= 1;
- cT--;
- // -- End renormalization
- }
- else
- {
- bits[i] = 1 - mPS[ctxt];
- if (switchLM[index] == 1)
- mPS[ctxt] = 1 - mPS[ctxt];
- I[ctxt] = nLPS[index];
- // -- Renormalize
- do
- {
- if (cT == 0)
- byteIn();
- la <<= 1;
- c <<= 1;
- cT--;
- }
- while (la < 0x8000);
- // -- End renormalization
- }
- // -- End MPS Exchange
- a = la;
- }
- }
- else
- {
- la = a;
- c -= (la << 16);
- // -- LPS Exchange
- if (la < q)
- {
- la = q;
- bits[i] = mPS[ctxt];
- I[ctxt] = nMPS[index];
- // -- Renormalize (MPS: no need for while loop)
- if (cT == 0)
- byteIn();
- la <<= 1;
- c <<= 1;
- cT--;
- // -- End renormalization
- }
- else
- {
- la = q;
- bits[i] = 1 - mPS[ctxt];
- if (switchLM[index] == 1)
- mPS[ctxt] = 1 - mPS[ctxt];
- I[ctxt] = nLPS[index];
- // -- Renormalize
- do
- {
- if (cT == 0)
- byteIn();
- la <<= 1;
- c <<= 1;
- cT--;
- }
- while (la < 0x8000);
- // -- End renormalization
- }
- // -- End LPS Exchange
-
- a = la;
- }
- }
- }
-
-
- /// Arithmetically decodes one symbol from the bit stream with the given
- /// context and returns its decoded value.
- ///
- /// Each context has a current MPS and an index describing what the
- /// current probability is for the LPS. Each bit is encoded and if the
- /// probability of the LPS exceeds .5, the MPS and LPS are switched.
- ///
- ///
- /// The context to use in decoding the symbol
- ///
- ///
- /// The decoded symbol, 0 or 1.
- ///
- ///
- public int decodeSymbol(int context)
- {
- uint q;
- uint la;
- int index;
- int decision;
-
- index = I[context];
- q = qe[index];
-
- // NOTE: (a < 0x8000) is equivalent to ((a & 0x8000)==0)
- // since 'a' is always less than or equal to 0xFFFF
-
- // NOTE: conditional exchange guarantees that A for MPS is
- // always greater than 0x4000 (i.e. 0.375)
- // => one renormalization shift is enough for MPS
- // => no need to do a renormalization while loop for MPS
-
- a -= q;
- if ((c >> 16) < a)
- {
- if (a >= 0x8000)
- {
- decision = mPS[context];
- }
- else
- {
- la = a;
- // -- MPS Exchange
- if (la >= q)
- {
- decision = mPS[context];
- I[context] = nMPS[index];
- // -- Renormalize (MPS: no need for while loop)
- if (cT == 0)
- byteIn();
- la <<= 1;
- c <<= 1;
- cT--;
- // -- End renormalization
- }
- else
- {
- decision = 1 - mPS[context];
- if (switchLM[index] == 1)
- mPS[context] = 1 - mPS[context];
- I[context] = nLPS[index];
- // -- Renormalize
- do
- {
- if (cT == 0)
- byteIn();
- la <<= 1;
- c <<= 1;
- cT--;
- }
- while (la < 0x8000);
- // -- End renormalization
- }
- // -- End MPS Exchange
- a = la;
- }
- }
- else
- {
- la = a;
- c -= (la << 16);
- // -- LPS Exchange
- if (la < q)
- {
- la = q;
- decision = mPS[context];
- I[context] = nMPS[index];
- // -- Renormalize (MPS: no need for while loop)
- if (cT == 0)
- byteIn();
- la <<= 1;
- c <<= 1;
- cT--;
- // -- End renormalization
- }
- else
- {
- la = q;
- decision = 1 - mPS[context];
- if (switchLM[index] == 1)
- mPS[context] = 1 - mPS[context];
- I[context] = nLPS[index];
- // -- Renormalize
- do
- {
- if (cT == 0)
- byteIn();
- la <<= 1;
- c <<= 1;
- cT--;
- }
- while (la < 0x8000);
- // -- End renormalization
- }
- // -- End LPS Exchange
-
- a = la;
- }
- return decision;
- }
-
- /// Checks for past errors in the decoding process using the predictable
- /// error resilient termination. This works only if the encoder used the
- /// predictable error resilient MQ termination, otherwise it reports wrong
- /// results. If an error is detected it means that the MQ bit stream has
- /// been wrongly decoded or that the MQ terminated segment length is too
- /// long. If no errors are detected it does not necessarily mean that the
- /// MQ bit stream has been correctly decoded.
- ///
- ///
- /// True if errors are found, false otherwise.
- ///
- ///
- public virtual bool checkPredTerm()
- {
- int k; // Number of bits that where added in the termination process
- uint q;
-
- // 1) if everything has been OK, 'b' must be 0xFF if a terminating
- // marker has not yet been found
- if (b != 0xFF && !markerFound)
- return true;
-
- // 2) if cT is not 0, we must have already reached the terminating
- // marker
- if (cT != 0 && !markerFound)
- return true;
-
- // 3) If cT is 1 there where no spare bits at the encoder, this is all
- // that we can check
- if (cT == 1)
- return false;
-
- // 4) if cT is 0, then next byte must be the second byte of a
- // terminating marker (i.e. larger than 0x8F) if the terminating
- // marker has not been reached yet
- if (cT == 0)
- {
- if (!markerFound)
- {
- // Get next byte and check
- b = (uint)in_Renamed.read() & 0xFF;
- if (b <= 0x8F)
- return true;
- }
- // Adjust cT for last byte
- cT = 8;
- }
-
- // 5) Now we can calculate the number 'k' of bits having error
- // resilience information, which is the number of bits left to
- // normalization in the C register, minus 1.
- k = (int)(cT - 1);
-
- // 6) The predictable termination policy is as if an LPS interval was
- // coded that caused a renormalization of 'k' bits, before the
- // termination marker started
-
- // We first check if an LPS is decoded, that causes a renormalization
- // of 'k' bits. Worst case is smallest LPS probability 'q' that causes
- // a renormalization of 'k' bits.
- q = ((uint)0x8000) >> k;
-
- // Check that we can decode an LPS interval of probability 'q'
- a -= q;
- if ((c >> 16) < a)
- {
- // Error: MPS interval decoded
- return true;
- }
- // OK: LPS interval decoded
- c -= (a << 16);
- // -- LPS Exchange
- // Here 'a' can not be smaller than 'q' because the minimum value
- // for 'a' is 0x8000-0x4000=0x4000 and 'q' is set to a value equal
- // to or smaller than that.
- a = q;
- // -- Renormalize
- do
- {
- if (cT == 0)
- byteIn();
- a <<= 1;
- c <<= 1;
- cT--;
- }
- while (a < 0x8000);
- // -- End renormalization
- // -- End LPS Exchange
-
- // 7) Everything seems OK, we have checked the C register for the LPS
- // symbols and ensured that it is followed by bits synthetized by the
- // termination marker.
- return false;
- }
-
- /// This function gets one byte of compressed bits from the in-stream. the
- /// byte is added to c. If the byte is 0xFF and the next byte is greater
- /// than 0x8F, the byte after 0xFF is a marker.
- ///
- ///
- private void byteIn()
- {
- if (!markerFound)
- {
- if (b == 0xFF)
- {
- b = ((uint)in_Renamed.read()) & 0xFF; // Convert EOFs (-1) to 0xFF
-
- if (b > 0x8F)
- {
- markerFound = true;
- // software-convention decoder: c unchanged
- cT = 8;
- }
- else
- {
- c += 0xFE00 - (b << 9);
- cT = 7;
- }
- }
- else
- {
- b = ((uint)in_Renamed.read()) & 0xFF; // Convert EOFs (-1) to 0xFF
- c += 0xFF00 - (b << 8);
- cT = 8;
- }
- }
- else
- {
- // software-convention decoder: c unchanged
- cT = 8;
- }
- }
-
- /// Resets a context to the original probability distribution.
- ///
- ///
- /// The number of the context (it starts at 0).
- ///
- ///
- public void resetCtxt(int c)
- {
- I[c] = initStates[c];
- mPS[c] = 0;
- }
-
- /// Resets a context to the original probability distribution. The original
- /// probability distribution depends on the actual implementation of the
- /// arithmetic coder or decoder.
- ///
- ///
- /// The index of the context (it starts at 0).
- ///
- ///
- public void resetCtxts()
- {
- Array.Copy(initStates, 0, I, 0, I.Length);
- ArrayUtil.intArraySet(mPS, 0);
- }
-
- /// Resets the MQ decoder to start a new segment. This is like recreating a
- /// new MQDecoder object with new input data.
- ///
- ///
- /// The byte array containing the MQ encoded data. If null the
- /// current byte array is assumed.
- ///
- ///
- /// The index of the first element in 'buf' to be decoded. If
- /// negative the byte just after the previous segment is assumed, only
- /// valid if 'buf' is null.
- ///
- ///
- /// The number of bytes in 'buf' to be decoded. Any subsequent
- /// bytes are taken to be 0xFF.
- ///
- ///
- public void nextSegment(byte[] buf, int off, int len)
- {
- // Set the new input
- in_Renamed.setByteArray(buf, off, len);
- // Reinitialize MQ
- init();
- }
-
- /// Initializes the state of the MQ coder, without modifying the current
- /// context states. It sets the registers (A,C,B) and the "marker found"
- /// state to the initial state, to start the decoding of a new segment.
- ///
- /// To have a complete reset of the MQ (as if a new MQDecoder object was
- /// created) 'resetCtxts()' should be called after this method.
- ///
- ///
- private void init()
- {
- // --- INITDEC
- markerFound = false;
-
- // Read first byte
- b = ((uint)in_Renamed.read()) & 0xFF;
-
- // Software conventions decoder
- c = (b ^ 0xFF) << 16;
- byteIn();
- c = c << 7;
- cT = cT - 7;
- a = 0x8000;
-
- // End of INITDEC ---
- }
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/entropy/decoder/StdEntropyDecoder.cs b/CSJ2K/j2k/entropy/decoder/StdEntropyDecoder.cs
deleted file mode 100644
index 1bfc8b89..00000000
--- a/CSJ2K/j2k/entropy/decoder/StdEntropyDecoder.cs
+++ /dev/null
@@ -1,2551 +0,0 @@
-/*
-* CVS identifier:
-*
-* $Id: StdEntropyDecoder.java,v 1.30 2001/10/25 12:12:16 qtxjoas Exp $
-*
-* Class: StdEntropyDecoder
-*
-* Description: Entropy decoding engine of stripes in code-blocks
-*
-*
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-* */
-using CSJ2K.j2k.decoder;
-using CSJ2K.j2k.image;
-using CSJ2K.j2k.util;
-using CSJ2K.j2k.wavelet;
-using CSJ2K.j2k.wavelet.synthesis;
-namespace CSJ2K.j2k.entropy.decoder
-{
-
- /// This class implements the JPEG 2000 entropy decoder, which codes stripes in
- /// code-blocks. This entropy decoding engine decodes one code-block at a time.
- ///
- /// The code-blocks are rectangular and their dimensions must be powers of
- /// 2. Each dimension cannot be smaller than 4 and larger than 256. The product
- /// of the two dimensions (i.e. area of the code-block) cannot exceed 4096.
- ///
- /// Context 0 of the MQ-coder is used as the uniform one (uniform,
- /// non-adaptive probability distribution). Context 1 is used for RLC
- /// coding. Contexts 2-10 are used for zero-coding (ZC), contexts 11-15 are
- /// used for sign-coding (SC) and contexts 16-18 are used for
- /// magnitude-refinement (MR).
- ///
- /// This implementation also provides some timing features. They can be
- /// enabled by setting the 'DO_TIMING' constant of this class to true and
- /// recompiling. The timing uses the 'System.currentTimeMillis()' Java API
- /// call, which returns wall clock time, not the actual CPU time used. The
- /// timing results will be printed on the message output. Since the times
- /// reported are wall clock times and not CPU usage times they can not be added
- /// to find the total used time (i.e. some time might be counted in several
- /// places). When timing is disabled ('DO_TIMING' is false) there is no penalty
- /// if the compiler performs some basic optimizations. Even if not the penalty
- /// should be negligeable.
- ///
- ///
- public class StdEntropyDecoder : EntropyDecoder
- {
-
- /// Whether to collect timing information or not: false. Used as a compile
- /// time directive.
- ///
- private const bool DO_TIMING = false;
-
- /// The cumulative wall time for the entropy coding engine, for each
- /// component.
- ///
- //private long[] time;
-
- /// The bit based input for arithmetic coding bypass (i.e. raw) coding
- private ByteToBitInput bin;
-
- /// The MQ decoder to use. It has in as the underlying source of coded
- /// data.
- ///
- private MQDecoder mq;
-
- /// The decoder spec
- private DecoderSpecs decSpec;
-
- /// The options that are turned on, as flag bits. The options are
- /// 'OPT_TERM_PASS', 'OPT_RESET_MQ', 'OPT_VERT_STR_CAUSAL', 'OPT_BYPASS'
- /// and 'OPT_SEG_SYMBOLS' as defined in the StdEntropyCoderOptions
- /// interface
- ///
- ///
- ///
- ///
- ///
- private int options;
-
- /// Flag to indicate if we should try to detect errors or just ignore any
- /// error resilient information
- ///
- //UPGRADE_NOTE: Final was removed from the declaration of 'doer '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- private bool doer;
-
- /// Flag to indicate if we should be verbose about bit stream errors
- /// detected with the error resilience options
- ///
- //UPGRADE_NOTE: Final was removed from the declaration of 'verber '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- private bool verber;
-
- /// Number of bits used for the Zero Coding lookup table
- private const int ZC_LUT_BITS = 8;
-
- /// Zero Coding context lookup tables for the LH global orientation
- //UPGRADE_NOTE: Final was removed from the declaration of 'ZC_LUT_LH '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- private static readonly int[] ZC_LUT_LH = new int[1 << ZC_LUT_BITS];
-
- /// Zero Coding context lookup tables for the HL global orientation
- //UPGRADE_NOTE: Final was removed from the declaration of 'ZC_LUT_HL '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- private static readonly int[] ZC_LUT_HL = new int[1 << ZC_LUT_BITS];
-
- /// Zero Coding context lookup tables for the HH global orientation
- //UPGRADE_NOTE: Final was removed from the declaration of 'ZC_LUT_HH '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- private static readonly int[] ZC_LUT_HH = new int[1 << ZC_LUT_BITS];
-
- /// Number of bits used for the Sign Coding lookup table
- private const int SC_LUT_BITS = 9;
-
- /// Sign Coding context lookup table. The index into the table is a 9 bit
- /// index, which correspond the the value in the 'state' array shifted by
- /// 'SC_SHIFT'. Bits 8-5 are the signs of the horizontal-left,
- /// horizontal-right, vertical-up and vertical-down neighbors,
- /// respectively. Bit 4 is not used (0 or 1 makes no difference). Bits 3-0
- /// are the significance of the horizontal-left, horizontal-right,
- /// vertical-up and vertical-down neighbors, respectively. The least 4 bits
- /// of the value in the lookup table define the context number and the sign
- /// bit defines the "sign predictor".
- ///
- //UPGRADE_NOTE: Final was removed from the declaration of 'SC_LUT '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- private static readonly int[] SC_LUT = new int[1 << SC_LUT_BITS];
-
- /// The mask to obtain the context index from the 'SC_LUT'
- private const int SC_LUT_MASK = (1 << 4) - 1;
-
- /// The shift to obtain the sign predictor from the 'SC_LUT'. It must be
- /// an unsigned shift.
- ///
- private const int SC_SPRED_SHIFT = 31;
-
- /// The sign bit for int data
- private const int INT_SIGN_BIT = 1 << 31;
-
- /// The number of bits used for the Magnitude Refinement lookup table
- private const int MR_LUT_BITS = 9;
-
- /// Magnitude Refinement context lookup table
- //UPGRADE_NOTE: Final was removed from the declaration of 'MR_LUT '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- private static readonly int[] MR_LUT = new int[1 << MR_LUT_BITS];
-
- /// The number of contexts used
- private const int NUM_CTXTS = 19;
-
- /// The RLC context
- private const int RLC_CTXT = 1;
-
- /// The UNIFORM context (with a uniform probability distribution which
- /// does not adapt)
- ///
- private const int UNIF_CTXT = 0;
-
- /// The initial states for the MQ coder
- //UPGRADE_NOTE: Final was removed from the declaration of 'MQ_INIT'. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- private static readonly int[] MQ_INIT = new int[] { 46, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
-
- /// The 4 bits of the error resilience segmentation symbol (decimal 10,
- /// which is binary sequence 1010)
- ///
- private const int SEG_SYMBOL = 10;
-
- /// The state array for entropy coding. Each element of the state array
- /// stores the state of two coefficients. The lower 16 bits store the state
- /// of a coefficient in row 'i' and column 'j', while the upper 16 bits
- /// store the state of a coefficient in row 'i+1' and column 'j'. The 'i'
- /// row is either the first or the third row of a stripe. This packing of
- /// the states into 32 bit words allows a faster scan of all coefficients
- /// on each coding pass and diminished the amount of data transferred. The
- /// size of the state array is increased by 1 on each side (top, bottom,
- /// left, right) to handle boundary conditions without any special logic.
- ///
- /// The state of a coefficient is stored in the following way in the
- /// lower 16 bits, where bit 0 is the least significant bit. Bit 15 is the
- /// significance of a coefficient (0 if non-significant, 1 otherwise). Bit
- /// 14 is the visited state (i.e. if a coefficient has been coded in the
- /// significance propagation pass of the current bit-plane). Bit 13 is the
- /// "non zero-context" state (i.e. if one of the eight immediate neighbors
- /// is significant it is 1, otherwise is 0). Bits 12 to 9 store the sign of
- /// the already significant left, right, up and down neighbors (1 for
- /// negative, 0 for positive or not yet significant). Bit 8 indicates if
- /// the magnitude refinement has already been applied to the
- /// coefficient. Bits 7 to 4 store the significance of the left, right, up
- /// and down neighbors (1 for significant, 0 for non significant). Bits 3
- /// to 0 store the significance of the diagonal coefficients (up-left,
- /// up-right, down-left and down-right; 1 for significant, 0 for non
- /// significant).
- ///
- ///
The upper 16 bits the state is stored as in the lower 16 bits, but
- /// with the bits shifted up by 16.
- ///
- ///
The lower 16 bits are referred to as "row 1" ("R1") while the upper
- /// 16 bits are referred to as "row 2" ("R2").
- ///
- ///
- //UPGRADE_NOTE: Final was removed from the declaration of 'state '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- private int[] state;
-
- /// The separation between the upper and lower bits in the state array: 16
- ///
- ///
- private const int STATE_SEP = 16;
-
- /// The flag bit for the significance in the state array, for row 1.
- private const int STATE_SIG_R1 = 1 << 15;
-
- /// The flag bit for the "visited" bit in the state array, for row 1.
- private const int STATE_VISITED_R1 = 1 << 14;
-
- /// The flag bit for the "not zero context" bit in the state array, for
- /// row 1. This bit is always the OR of bits STATE_H_L_R1, STATE_H_R_R1,
- /// STATE_V_U_R1, STATE_V_D_R1, STATE_D_UL_R1, STATE_D_UR_R1, STATE_D_DL_R1
- /// and STATE_D_DR_R1.
- ///
- private const int STATE_NZ_CTXT_R1 = 1 << 13;
-
- /// The flag bit for the horizontal-left sign in the state array, for row
- /// 1. This bit can only be set if the STATE_H_L_R1 is also set.
- ///
- private const int STATE_H_L_SIGN_R1 = 1 << 12;
-
- /// The flag bit for the horizontal-right sign in the state array, for
- /// row 1. This bit can only be set if the STATE_H_R_R1 is also set.
- ///
- private const int STATE_H_R_SIGN_R1 = 1 << 11;
-
- /// The flag bit for the vertical-up sign in the state array, for row
- /// 1. This bit can only be set if the STATE_V_U_R1 is also set.
- ///
- private const int STATE_V_U_SIGN_R1 = 1 << 10;
-
- /// The flag bit for the vertical-down sign in the state array, for row
- /// 1. This bit can only be set if the STATE_V_D_R1 is also set.
- ///
- private const int STATE_V_D_SIGN_R1 = 1 << 9;
-
- /// The flag bit for the previous MR primitive applied in the state array,
- /// for row 1.
- ///
- private const int STATE_PREV_MR_R1 = 1 << 8;
-
- /// The flag bit for the horizontal-left significance in the state array,
- /// for row 1.
- ///
- private const int STATE_H_L_R1 = 1 << 7;
-
- /// The flag bit for the horizontal-right significance in the state array,
- /// for row 1.
- ///
- private const int STATE_H_R_R1 = 1 << 6;
-
- /// The flag bit for the vertical-up significance in the state array, for
- /// row 1.
- ///
- private const int STATE_V_U_R1 = 1 << 5;
-
- /// The flag bit for the vertical-down significance in the state array,
- /// for row 1.
- ///
- private const int STATE_V_D_R1 = 1 << 4;
-
- /// The flag bit for the diagonal up-left significance in the state array,
- /// for row 1.
- ///
- private const int STATE_D_UL_R1 = 1 << 3;
-
- /// The flag bit for the diagonal up-right significance in the state
- /// array, for row 1.
- ///
- private const int STATE_D_UR_R1 = 1 << 2;
-
- /// The flag bit for the diagonal down-left significance in the state
- /// array, for row 1.
- ///
- private const int STATE_D_DL_R1 = 1 << 1;
-
- /// The flag bit for the diagonal down-right significance in the state
- /// array , for row 1.
- ///
- private const int STATE_D_DR_R1 = 1;
-
- /// The flag bit for the significance in the state array, for row 2.
- //UPGRADE_NOTE: Final was removed from the declaration of 'STATE_SIG_R2 '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- private static readonly int STATE_SIG_R2 = STATE_SIG_R1 << STATE_SEP;
-
- /// The flag bit for the "visited" bit in the state array, for row 2.
- //UPGRADE_NOTE: Final was removed from the declaration of 'STATE_VISITED_R2 '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- private static readonly int STATE_VISITED_R2 = STATE_VISITED_R1 << STATE_SEP;
-
- /// The flag bit for the "not zero context" bit in the state array, for
- /// row 2. This bit is always the OR of bits STATE_H_L_R2, STATE_H_R_R2,
- /// STATE_V_U_R2, STATE_V_D_R2, STATE_D_UL_R2, STATE_D_UR_R2, STATE_D_DL_R2
- /// and STATE_D_DR_R2.
- ///
- //UPGRADE_NOTE: Final was removed from the declaration of 'STATE_NZ_CTXT_R2 '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- private static readonly int STATE_NZ_CTXT_R2 = STATE_NZ_CTXT_R1 << STATE_SEP;
-
- /// The flag bit for the horizontal-left sign in the state array, for row
- /// 2. This bit can only be set if the STATE_H_L_R2 is also set.
- ///
- //UPGRADE_NOTE: Final was removed from the declaration of 'STATE_H_L_SIGN_R2 '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- private static readonly int STATE_H_L_SIGN_R2 = STATE_H_L_SIGN_R1 << STATE_SEP;
-
- /// The flag bit for the horizontal-right sign in the state array, for row
- /// 2. This bit can only be set if the STATE_H_R_R2 is also set.
- ///
- //UPGRADE_NOTE: Final was removed from the declaration of 'STATE_H_R_SIGN_R2 '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- private static readonly int STATE_H_R_SIGN_R2 = STATE_H_R_SIGN_R1 << STATE_SEP;
-
- /// The flag bit for the vertical-up sign in the state array, for row
- /// 2. This bit can only be set if the STATE_V_U_R2 is also set.
- ///
- //UPGRADE_NOTE: Final was removed from the declaration of 'STATE_V_U_SIGN_R2 '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- private static readonly int STATE_V_U_SIGN_R2 = STATE_V_U_SIGN_R1 << STATE_SEP;
-
- /// The flag bit for the vertical-down sign in the state array, for row
- /// 2. This bit can only be set if the STATE_V_D_R2 is also set.
- ///
- //UPGRADE_NOTE: Final was removed from the declaration of 'STATE_V_D_SIGN_R2 '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- private static readonly int STATE_V_D_SIGN_R2 = STATE_V_D_SIGN_R1 << STATE_SEP;
-
- /// The flag bit for the previous MR primitive applied in the state array,
- /// for row 2.
- ///
- //UPGRADE_NOTE: Final was removed from the declaration of 'STATE_PREV_MR_R2 '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- private static readonly int STATE_PREV_MR_R2 = STATE_PREV_MR_R1 << STATE_SEP;
-
- /// The flag bit for the horizontal-left significance in the state array,
- /// for row 2.
- ///
- //UPGRADE_NOTE: Final was removed from the declaration of 'STATE_H_L_R2 '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- private static readonly int STATE_H_L_R2 = STATE_H_L_R1 << STATE_SEP;
-
- /// The flag bit for the horizontal-right significance in the state array,
- /// for row 2.
- ///
- //UPGRADE_NOTE: Final was removed from the declaration of 'STATE_H_R_R2 '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- private static readonly int STATE_H_R_R2 = STATE_H_R_R1 << STATE_SEP;
-
- /// The flag bit for the vertical-up significance in the state array, for
- /// row 2.
- ///
- //UPGRADE_NOTE: Final was removed from the declaration of 'STATE_V_U_R2 '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- private static readonly int STATE_V_U_R2 = STATE_V_U_R1 << STATE_SEP;
-
- /// The flag bit for the vertical-down significance in the state array,
- /// for row 2.
- ///
- //UPGRADE_NOTE: Final was removed from the declaration of 'STATE_V_D_R2 '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- private static readonly int STATE_V_D_R2 = STATE_V_D_R1 << STATE_SEP;
-
- /// The flag bit for the diagonal up-left significance in the state array,
- /// for row 2.
- ///
- //UPGRADE_NOTE: Final was removed from the declaration of 'STATE_D_UL_R2 '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- private static readonly int STATE_D_UL_R2 = STATE_D_UL_R1 << STATE_SEP;
-
- /// The flag bit for the diagonal up-right significance in the state
- /// array, for row 2.
- ///
- //UPGRADE_NOTE: Final was removed from the declaration of 'STATE_D_UR_R2 '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- private static readonly int STATE_D_UR_R2 = STATE_D_UR_R1 << STATE_SEP;
-
- /// The flag bit for the diagonal down-left significance in the state
- /// array, for row 2.
- ///
- //UPGRADE_NOTE: Final was removed from the declaration of 'STATE_D_DL_R2 '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- private static readonly int STATE_D_DL_R2 = STATE_D_DL_R1 << STATE_SEP;
-
- /// The flag bit for the diagonal down-right significance in the state
- /// array , for row 2.
- ///
- //UPGRADE_NOTE: Final was removed from the declaration of 'STATE_D_DR_R2 '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- private static readonly int STATE_D_DR_R2 = STATE_D_DR_R1 << STATE_SEP;
-
- /// The mask to isolate the significance bits for row 1 and 2 of the state
- /// array.
- ///
- //UPGRADE_NOTE: Final was removed from the declaration of 'SIG_MASK_R1R2 '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- private static readonly int SIG_MASK_R1R2 = STATE_SIG_R1 | STATE_SIG_R2;
-
- /// The mask to isolate the visited bits for row 1 and 2 of the state
- /// array.
- ///
- //UPGRADE_NOTE: Final was removed from the declaration of 'VSTD_MASK_R1R2 '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- private static readonly int VSTD_MASK_R1R2 = STATE_VISITED_R1 | STATE_VISITED_R2;
-
- /// The mask to isolate the bits necessary to identify RLC coding state
- /// (significant, visited and non-zero context, for row 1 and 2).
- ///
- //UPGRADE_NOTE: Final was removed from the declaration of 'RLC_MASK_R1R2 '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- private static readonly int RLC_MASK_R1R2 = STATE_SIG_R1 | STATE_SIG_R2 | STATE_VISITED_R1 | STATE_VISITED_R2 | STATE_NZ_CTXT_R1 | STATE_NZ_CTXT_R2;
-
- /// The mask to obtain the ZC_LUT index from the 'state' information
- // This is needed because of the STATE_V_D_SIGN, STATE_V_U_SIGN,
- // STATE_H_R_SIGN, and STATE_H_L_SIGN bits.
- private const int ZC_MASK = (1 << 8) - 1;
-
- /// The shift to obtain the SC index to 'SC_LUT' from the 'state'
- /// information, for row 1.
- ///
- private const int SC_SHIFT_R1 = 4;
-
- /// The shift to obtain the SC index to 'SC_LUT' from the state
- /// information, for row 2.
- ///
- //UPGRADE_NOTE: Final was removed from the declaration of 'SC_SHIFT_R2 '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- private static readonly int SC_SHIFT_R2 = SC_SHIFT_R1 + STATE_SEP;
-
- /// The bit mask to isolate the state bits relative to the sign coding
- /// lookup table ('SC_LUT').
- ///
- //UPGRADE_NOTE: Final was removed from the declaration of 'SC_MASK '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- private static readonly int SC_MASK = (1 << SC_LUT_BITS) - 1;
-
- /// The mask to obtain the MR index to 'MR_LUT' from the 'state'
- /// information. It is to be applied after the 'MR_SHIFT'
- ///
- private const int MR_MASK = (1 << 9) - 1;
-
- /// The source code-block to entropy code (avoids reallocation for each
- /// code-block).
- ///
- private DecLyrdCBlk srcblk;
-
- /// The maximum number of bit planes to decode for any code-block
- private int mQuit;
-
- /// Instantiates a new entropy decoder engine, with the specified source of
- /// data, nominal block width and height.
- ///
- ///
- /// The source of data
- ///
- ///
- /// The options to use for this encoder. It is a mix of the
- /// 'OPT_TERM_PASS', 'OPT_RESET_MQ', 'OPT_VERT_STR_CAUSAL', 'OPT_BYPASS'
- /// and 'OPT_SEG_SYMBOLS' option flags.
- ///
- ///
- /// If true error detection will be performed, if any error
- /// detection features have been enabled.
- ///
- ///
- /// This flag indicates if the entropy decoder should be
- /// verbose about bit stream errors that are detected and concealed.
- ///
- ///
- /// the maximum number of bit planes to decode according to
- /// the m quit condition
- ///
- ///
- public StdEntropyDecoder(CodedCBlkDataSrcDec src, DecoderSpecs decSpec, bool doer, bool verber, int mQuit) : base(src)
- {
-
- this.decSpec = decSpec;
- this.doer = doer;
- this.verber = verber;
- this.mQuit = mQuit;
-
- // If we do timing create necessary structures
-#if DO_TIMING
- time = new long[src.NumComps];
- // If we are timing make sure that 'finalize' gets called.
- //UPGRADE_ISSUE: Method 'java.lang.System.runFinalizersOnExit' was not converted. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1000_javalangSystem'"
- // CONVERSION PROBLEM?
- //System_Renamed.runFinalizersOnExit(true);
-#endif
-
- // Initialize internal variables
- state = new int[(decSpec.cblks.MaxCBlkWidth + 2) * ((decSpec.cblks.MaxCBlkHeight + 1) / 2 + 2)];
- }
-
-#if DO_TIMING
- /// Prints the timing information, if collected, and calls 'finalize' on
- /// the super class.
- ///
- ///
- ~StdEntropyDecoder()
- {
- int c;
- System.Text.StringBuilder sb;
-
- sb = new System.Text.StringBuilder("StdEntropyDecoder decompression wall " + "clock time:");
- for (c = 0; c < time.Length; c++)
- {
- sb.Append("\n component ");
- sb.Append(c);
- sb.Append(": ");
- sb.Append(time[c]);
- sb.Append(" ms");
- }
- FacilityManager.getMsgLogger().printmsg(CSJ2K.j2k.util.MsgLogger_Fields.INFO, sb.ToString());
-
- //UPGRADE_NOTE: Call to 'super.finalize()' was removed. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1124'"
- }
-#endif
-
- /// Returns the specified code-block in the current tile for the specified
- /// component, as a copy (see below).
- ///
- /// The returned code-block may be progressive, which is indicated by
- /// the 'progressive' variable of the returned 'DataBlk' object. If a
- /// code-block is progressive it means that in a later request to this
- /// method for the same code-block it is possible to retrieve data which is
- /// a better approximation, since meanwhile more data to decode for the
- /// code-block could have been received. If the code-block is not
- /// progressive then later calls to this method for the same code-block
- /// will return the exact same data values.
- ///
- ///
The data returned by this method is always a copy of the internal
- /// data of this object, if any, and it can be modified "in place" without
- /// any problems after being returned. The 'offset' of the returned data is
- /// 0, and the 'scanw' is the same as the code-block width. See the
- /// 'DataBlk' class.
- ///
- ///
The 'ulx' and 'uly' members of the returned 'DataBlk' object
- /// contain the coordinates of the top-left corner of the block, with
- /// respect to the tile, not the subband.
- ///
- ///
- /// The component for which to return the next code-block.
- ///
- ///
- /// The vertical index of the code-block to return, in the
- /// specified subband.
- ///
- ///
- /// The horizontal index of the code-block to return, in the
- /// specified subband.
- ///
- ///
- /// The subband in which the code-block to return is.
- ///
- ///
- /// If non-null this object will be used to return the new
- /// code-block. If null a new one will be allocated and returned. If the
- /// "data" array of the object is non-null it will be reused, if possible,
- /// to return the data.
- ///
- ///
- /// The next code-block in the current tile for component 'n', or
- /// null if all code-blocks for the current tile have been returned.
- ///
- ///
- ///
- ///
- ///
- public override DataBlk getCodeBlock(int c, int m, int n, SubbandSyn sb, DataBlk cblk)
- {
- //long stime = 0L; // Start time for timed sections
- int[] zc_lut; // The ZC lookup table to use
- int[] out_data; // The outupt data buffer
- int npasses; // The number of coding passes to perform
- int curbp; // The current magnitude bit-plane (starts at 30)
- bool error; // Error indicator
- int tslen; // Length of first terminated segment
- int tsidx; // Index of current terminated segment
- ByteInputBuffer in_Renamed = null;
-
- bool isterm;
-
- // Get the code-block to decode
- srcblk = src.getCodeBlock(c, m, n, sb, 1, -1, srcblk);
-
-#if DO_TIMING
- stime = (System.DateTime.Now.Ticks - 621355968000000000) / 10000;
-#endif
-
- // Retrieve options from decSpec
- options = ((System.Int32)decSpec.ecopts.getTileCompVal(tIdx, c));
-
- // Reset state
- ArrayUtil.intArraySet(state, 0);
-
- // Initialize output code-block
- if (cblk == null)
- cblk = new DataBlkInt();
- cblk.progressive = srcblk.prog;
- cblk.ulx = srcblk.ulx;
- cblk.uly = srcblk.uly;
- cblk.w = srcblk.w;
- cblk.h = srcblk.h;
- cblk.offset = 0;
- cblk.scanw = cblk.w;
- out_data = (int[])cblk.Data;
-
- if (out_data == null || out_data.Length < srcblk.w * srcblk.h)
- {
- out_data = new int[srcblk.w * srcblk.h];
- cblk.Data = out_data;
- }
- else
- {
- // Set data values to 0
- ArrayUtil.intArraySet(out_data, 0);
- }
-
- if (srcblk.nl <= 0 || srcblk.nTrunc <= 0)
- {
- // 0 layers => no data to decode => return all 0s
- return cblk;
- }
-
- // Get the length of the first terminated segment
- tslen = (srcblk.tsLengths == null) ? srcblk.dl : srcblk.tsLengths[0];
- tsidx = 0;
- // Initialize for decoding
- npasses = srcblk.nTrunc;
- if (mq == null)
- {
- in_Renamed = new ByteInputBuffer(srcblk.data, 0, tslen);
- mq = new MQDecoder(in_Renamed, NUM_CTXTS, MQ_INIT);
- }
- else
- {
- // We always start by an MQ segment
- mq.nextSegment(srcblk.data, 0, tslen);
- mq.resetCtxts();
- }
- error = false;
-
- if ((options & CSJ2K.j2k.entropy.StdEntropyCoderOptions.OPT_BYPASS) != 0)
- {
- if (bin == null)
- {
- if (in_Renamed == null)
- in_Renamed = mq.ByteInputBuffer;
- bin = new ByteToBitInput(in_Renamed);
- }
- }
-
- // Choose correct ZC lookup table for global orientation
- switch (sb.orientation)
- {
-
- case Subband.WT_ORIENT_HL:
- zc_lut = ZC_LUT_HL;
- break;
-
- case Subband.WT_ORIENT_LH:
- case Subband.WT_ORIENT_LL:
- zc_lut = ZC_LUT_LH;
- break;
-
- case Subband.WT_ORIENT_HH:
- zc_lut = ZC_LUT_HH;
- break;
-
- default:
- throw new System.ApplicationException("JJ2000 internal error");
-
- }
-
- // NOTE: we don't currently detect which is the last magnitude
- // bit-plane so that 'isterm' is true for the last pass of it. Doing
- // so would aid marginally in error detection with the predictable
- // error resilient MQ termination. However, determining which is the
- // last magnitude bit-plane is quite hard (due to ROI, quantization,
- // etc.) and in any case the predictable error resilient termination
- // used without the arithmetic coding bypass and/or regular
- // termination modes is almost useless.
-
- // Loop on bit-planes and passes
-
- curbp = 30 - srcblk.skipMSBP;
-
- // Check for maximum number of bitplanes quit condition
- if (mQuit != -1 && (mQuit * 3 - 2) < npasses)
- {
- npasses = mQuit * 3 - 2;
- }
-
- // First bit-plane has only the cleanup pass
- if (curbp >= 0 && npasses > 0)
- {
- isterm = (options & CSJ2K.j2k.entropy.StdEntropyCoderOptions.OPT_TERM_PASS) != 0 || ((options & CSJ2K.j2k.entropy.StdEntropyCoderOptions.OPT_BYPASS) != 0 && (31 - CSJ2K.j2k.entropy.StdEntropyCoderOptions.NUM_NON_BYPASS_MS_BP - srcblk.skipMSBP) >= curbp);
- error = cleanuppass(cblk, mq, curbp, state, zc_lut, isterm);
- npasses--;
- if (!error || !doer)
- curbp--;
- }
-
- // Other bit-planes have the three coding passes
- if (!error || !doer)
- {
- while (curbp >= 0 && npasses > 0)
- {
-
- if ((options & CSJ2K.j2k.entropy.StdEntropyCoderOptions.OPT_BYPASS) != 0 && (curbp < 31 - CSJ2K.j2k.entropy.StdEntropyCoderOptions.NUM_NON_BYPASS_MS_BP - srcblk.skipMSBP))
- {
- // Use bypass decoding mode (only all bit-planes
- // after the first 4 bit-planes).
-
- // Here starts a new raw segment
- bin.setByteArray(null, -1, srcblk.tsLengths[++tsidx]);
- isterm = (options & CSJ2K.j2k.entropy.StdEntropyCoderOptions.OPT_TERM_PASS) != 0;
- error = rawSigProgPass(cblk, bin, curbp, state, isterm);
- npasses--;
- if (npasses <= 0 || (error && doer))
- break;
-
- if ((options & CSJ2K.j2k.entropy.StdEntropyCoderOptions.OPT_TERM_PASS) != 0)
- {
- // Start a new raw segment
- bin.setByteArray(null, -1, srcblk.tsLengths[++tsidx]);
- }
- isterm = (options & CSJ2K.j2k.entropy.StdEntropyCoderOptions.OPT_TERM_PASS) != 0 || ((options & CSJ2K.j2k.entropy.StdEntropyCoderOptions.OPT_BYPASS) != 0 && (31 - CSJ2K.j2k.entropy.StdEntropyCoderOptions.NUM_NON_BYPASS_MS_BP - srcblk.skipMSBP > curbp));
- error = rawMagRefPass(cblk, bin, curbp, state, isterm);
- }
- else
- {
- // Do not use bypass decoding mode
- if ((options & CSJ2K.j2k.entropy.StdEntropyCoderOptions.OPT_TERM_PASS) != 0)
- {
- // Here starts a new MQ segment
- mq.nextSegment(null, -1, srcblk.tsLengths[++tsidx]);
- }
- isterm = (options & CSJ2K.j2k.entropy.StdEntropyCoderOptions.OPT_TERM_PASS) != 0;
- error = sigProgPass(cblk, mq, curbp, state, zc_lut, isterm);
- npasses--;
- if (npasses <= 0 || (error && doer))
- break;
-
- if ((options & CSJ2K.j2k.entropy.StdEntropyCoderOptions.OPT_TERM_PASS) != 0)
- {
- // Here starts a new MQ segment
- mq.nextSegment(null, -1, srcblk.tsLengths[++tsidx]);
- }
- isterm = (options & CSJ2K.j2k.entropy.StdEntropyCoderOptions.OPT_TERM_PASS) != 0 || ((options & CSJ2K.j2k.entropy.StdEntropyCoderOptions.OPT_BYPASS) != 0 && (31 - CSJ2K.j2k.entropy.StdEntropyCoderOptions.NUM_NON_BYPASS_MS_BP - srcblk.skipMSBP > curbp));
- error = magRefPass(cblk, mq, curbp, state, isterm);
- }
-
- npasses--;
- if (npasses <= 0 || (error && doer))
- break;
-
- if ((options & CSJ2K.j2k.entropy.StdEntropyCoderOptions.OPT_TERM_PASS) != 0 || ((options & CSJ2K.j2k.entropy.StdEntropyCoderOptions.OPT_BYPASS) != 0 && (curbp < 31 - CSJ2K.j2k.entropy.StdEntropyCoderOptions.NUM_NON_BYPASS_MS_BP - srcblk.skipMSBP)))
- {
- // Here starts a new MQ segment
- mq.nextSegment(null, -1, srcblk.tsLengths[++tsidx]);
- }
- isterm = (options & CSJ2K.j2k.entropy.StdEntropyCoderOptions.OPT_TERM_PASS) != 0 || ((options & CSJ2K.j2k.entropy.StdEntropyCoderOptions.OPT_BYPASS) != 0 && (31 - CSJ2K.j2k.entropy.StdEntropyCoderOptions.NUM_NON_BYPASS_MS_BP - srcblk.skipMSBP) >= curbp);
- error = cleanuppass(cblk, mq, curbp, state, zc_lut, isterm);
- npasses--;
- if (error && doer)
- break;
- // Goto next bit-plane
- curbp--;
- }
- }
-
- // If an error ocurred conceal it
- if (error && doer)
- {
- if (verber)
- {
- FacilityManager.getMsgLogger().printmsg(CSJ2K.j2k.util.MsgLogger_Fields.WARNING, "Error detected at bit-plane " + curbp + " in code-block (" + m + "," + n + "), sb_idx " + sb.sbandIdx + ", res. level " + sb.resLvl + ". Concealing...");
- }
- conceal(cblk, curbp);
- }
-
-#if DO_TIMING
- time[c] += (System.DateTime.Now.Ticks - 621355968000000000) / 10000 - stime;
-#endif
-
- // Return decoded block
- return cblk;
- }
-
- /// Returns the specified code-block in the current tile for the specified
- /// component (as a reference or copy).
- ///
- /// The returned code-block may be progressive, which is indicated by
- /// the 'progressive' variable of the returned 'DataBlk' object. If a
- /// code-block is progressive it means that in a later request to this
- /// method for the same code-block it is possible to retrieve data which is
- /// a better approximation, since meanwhile more data to decode for the
- /// code-block could have been received. If the code-block is not
- /// progressive then later calls to this method for the same code-block
- /// will return the exact same data values.
- ///
- /// The data returned by this method can be the data in the internal
- /// buffer of this object, if any, and thus can not be modified by the
- /// caller. The 'offset' and 'scanw' of the returned data can be
- /// arbitrary. See the 'DataBlk' class.
- ///
- /// The 'ulx' and 'uly' members of the returned 'DataBlk' object contain
- /// the coordinates of the top-left corner of the block, with respect to
- /// the tile, not the subband.
- ///
- ///
- /// The component for which to return the next code-block.
- ///
- ///
- /// The vertical index of the code-block to return, in the
- /// specified subband.
- ///
- ///
- /// The horizontal index of the code-block to return, in the
- /// specified subband.
- ///
- ///
- /// The subband in which the code-block to return is.
- ///
- ///
- /// If non-null this object will be used to return the new
- /// code-block. If null a new one will be allocated and returned. If the
- /// "data" array of the object is non-null it will be reused, if possible,
- /// to return the data.
- ///
- ///
- /// The next code-block in the current tile for component 'n', or
- /// null if all code-blocks for the current tile have been returned.
- ///
- ///
- ///
- ///
- ///
- public override DataBlk getInternCodeBlock(int c, int m, int n, SubbandSyn sb, DataBlk cblk)
- {
- return getCodeBlock(c, m, n, sb, cblk);
- }
-
- /// Performs the significance propagation pass on the specified data and
- /// bit-plane. It decodes all insignificant samples which have, at least,
- /// one of its immediate eight neighbors already significant, using the ZC
- /// and SC primitives as needed. It toggles the "visited" state bit to 1
- /// for all those samples.
- ///
- /// This method also checks for segmentation markers if those are
- /// present and returns true if an error is detected, or false
- /// otherwise. If an error is detected it means that the bit stream
- /// contains some erroneous bit that have led to the decoding of incorrect
- /// data. This data affects the whole last decoded bit-plane
- /// (i.e. 'bp'). If 'true' is returned the 'conceal' method should be
- /// called and no more passes should be decoded for this code-block's bit
- /// stream.
- ///
- ///
- /// The code-block data to decode
- ///
- ///
- /// The MQ-coder to use
- ///
- ///
- /// The bit-plane to decode
- ///
- ///
- /// The state information for the code-block
- ///
- ///
- /// The ZC lookup table to use in ZC.
- ///
- ///
- /// If this pass has been terminated. If the pass has been
- /// terminated it can be used to check error resilience.
- ///
- ///
- /// True if an error was detected in the bit stream, false
- /// otherwise.
- ///
- ///
- private bool sigProgPass(DataBlk cblk, MQDecoder mq, int bp, int[] state, int[] zc_lut, bool isterm)
- {
- int j, sj; // The state index for line and stripe
- int k, sk; // The data index for line and stripe
- int dscanw; // The data scan-width
- int sscanw; // The state scan-width
- int jstep; // Stripe to stripe step for 'sj'
- int kstep; // Stripe to stripe step for 'sk'
- int stopsk; // The loop limit on the variable sk
- int csj; // Local copy (i.e. cached) of 'state[j]'
- int setmask; // The mask to set current and lower bit-planes to 1/2
- // approximation
- int sym; // The symbol to code
- int ctxt; // The context to use
- int[] data; // The data buffer
- int s; // The stripe index
- bool causal; // Flag to indicate if stripe-causal context
- // formation is to be used
- int nstripes; // The number of stripes in the code-block
- int sheight; // Height of the current stripe
- int off_ul, off_ur, off_dr, off_dl; // offsets
- bool error; // The error condition
-
- // Initialize local variables
- dscanw = cblk.scanw;
- sscanw = cblk.w + 2;
- jstep = sscanw * CSJ2K.j2k.entropy.StdEntropyCoderOptions.STRIPE_HEIGHT / 2 - cblk.w;
- kstep = dscanw * CSJ2K.j2k.entropy.StdEntropyCoderOptions.STRIPE_HEIGHT - cblk.w;
- setmask = (3 << bp) >> 1;
- data = (int[])cblk.Data;
- nstripes = (cblk.h + CSJ2K.j2k.entropy.StdEntropyCoderOptions.STRIPE_HEIGHT - 1) / CSJ2K.j2k.entropy.StdEntropyCoderOptions.STRIPE_HEIGHT;
- causal = (options & CSJ2K.j2k.entropy.StdEntropyCoderOptions.OPT_VERT_STR_CAUSAL) != 0;
-
- // Pre-calculate offsets in 'state' for diagonal neighbors
- off_ul = -sscanw - 1; // up-left
- off_ur = -sscanw + 1; // up-right
- off_dr = sscanw + 1; // down-right
- off_dl = sscanw - 1; // down-left
-
- // Decode stripe by stripe
- sk = cblk.offset;
- sj = sscanw + 1;
- for (s = nstripes - 1; s >= 0; s--, sk += kstep, sj += jstep)
- {
- sheight = (s != 0) ? CSJ2K.j2k.entropy.StdEntropyCoderOptions.STRIPE_HEIGHT : cblk.h - (nstripes - 1) * CSJ2K.j2k.entropy.StdEntropyCoderOptions.STRIPE_HEIGHT;
- stopsk = sk + cblk.w;
- // Scan by set of 1 stripe column at a time
- for (; sk < stopsk; sk++, sj++)
- {
- // Do half top of column
- j = sj;
- csj = state[j];
- // If any of the two samples is not significant and has a
- // non-zero context (i.e. some neighbor is significant) we can
- // not skip them
- if ((((~csj) & (csj << 2)) & SIG_MASK_R1R2) != 0)
- {
- k = sk;
- // Scan first row
- if ((csj & (STATE_SIG_R1 | STATE_NZ_CTXT_R1)) == STATE_NZ_CTXT_R1)
- {
- // Use zero coding
- if (mq.decodeSymbol(zc_lut[csj & ZC_MASK]) != 0)
- {
- // Became significant
- // Use sign coding
- ctxt = SC_LUT[(SupportClass.URShift(csj, SC_SHIFT_R1)) & SC_MASK];
- sym = mq.decodeSymbol(ctxt & SC_LUT_MASK) ^ (SupportClass.URShift(ctxt, SC_SPRED_SHIFT));
- // Update data
- data[k] = (sym << 31) | setmask;
- // Update state information (significant bit,
- // visited bit, neighbor significant bit of
- // neighbors, non zero context of neighbors, sign
- // of neighbors)
- if (!causal)
- {
- // If in causal mode do not change contexts of
- // previous stripe.
- state[j + off_ul] |= STATE_NZ_CTXT_R2 | STATE_D_DR_R2;
- state[j + off_ur] |= STATE_NZ_CTXT_R2 | STATE_D_DL_R2;
- }
- // Update sign state information of neighbors
- if (sym != 0)
- {
- csj |= STATE_SIG_R1 | STATE_VISITED_R1 | STATE_NZ_CTXT_R2 | STATE_V_U_R2 | STATE_V_U_SIGN_R2;
- if (!causal)
- {
- // If in causal mode do not change
- // contexts of previous stripe.
- state[j - sscanw] |= STATE_NZ_CTXT_R2 | STATE_V_D_R2 | STATE_V_D_SIGN_R2;
- }
- state[j + 1] |= STATE_NZ_CTXT_R1 | STATE_NZ_CTXT_R2 | STATE_H_L_R1 | STATE_H_L_SIGN_R1 | STATE_D_UL_R2;
- state[j - 1] |= STATE_NZ_CTXT_R1 | STATE_NZ_CTXT_R2 | STATE_H_R_R1 | STATE_H_R_SIGN_R1 | STATE_D_UR_R2;
- }
- else
- {
- csj |= STATE_SIG_R1 | STATE_VISITED_R1 | STATE_NZ_CTXT_R2 | STATE_V_U_R2;
- if (!causal)
- {
- // If in causal mode do not change
- // contexts of previous stripe.
- state[j - sscanw] |= STATE_NZ_CTXT_R2 | STATE_V_D_R2;
- }
- state[j + 1] |= STATE_NZ_CTXT_R1 | STATE_NZ_CTXT_R2 | STATE_H_L_R1 | STATE_D_UL_R2;
- state[j - 1] |= STATE_NZ_CTXT_R1 | STATE_NZ_CTXT_R2 | STATE_H_R_R1 | STATE_D_UR_R2;
- }
- }
- else
- {
- csj |= STATE_VISITED_R1;
- }
- }
- if (sheight < 2)
- {
- state[j] = csj;
- continue;
- }
- // Scan second row
- if ((csj & (STATE_SIG_R2 | STATE_NZ_CTXT_R2)) == STATE_NZ_CTXT_R2)
- {
- k += dscanw;
- // Use zero coding
- if (mq.decodeSymbol(zc_lut[(SupportClass.URShift(csj, STATE_SEP)) & ZC_MASK]) != 0)
- {
- // Became significant
- // Use sign coding
- ctxt = SC_LUT[(SupportClass.URShift(csj, SC_SHIFT_R2)) & SC_MASK];
- sym = mq.decodeSymbol(ctxt & SC_LUT_MASK) ^ (SupportClass.URShift(ctxt, SC_SPRED_SHIFT));
- // Update data
- data[k] = (sym << 31) | setmask;
- // Update state information (significant bit,
- // visited bit, neighbor significant bit of
- // neighbors, non zero context of neighbors, sign
- // of neighbors)
- state[j + off_dl] |= STATE_NZ_CTXT_R1 | STATE_D_UR_R1;
- state[j + off_dr] |= STATE_NZ_CTXT_R1 | STATE_D_UL_R1;
- // Update sign state information of neighbors
- if (sym != 0)
- {
- csj |= STATE_SIG_R2 | STATE_VISITED_R2 | STATE_NZ_CTXT_R1 | STATE_V_D_R1 | STATE_V_D_SIGN_R1;
- state[j + sscanw] |= STATE_NZ_CTXT_R1 | STATE_V_U_R1 | STATE_V_U_SIGN_R1;
- state[j + 1] |= STATE_NZ_CTXT_R1 | STATE_NZ_CTXT_R2 | STATE_D_DL_R1 | STATE_H_L_R2 | STATE_H_L_SIGN_R2;
- state[j - 1] |= STATE_NZ_CTXT_R1 | STATE_NZ_CTXT_R2 | STATE_D_DR_R1 | STATE_H_R_R2 | STATE_H_R_SIGN_R2;
- }
- else
- {
- csj |= STATE_SIG_R2 | STATE_VISITED_R2 | STATE_NZ_CTXT_R1 | STATE_V_D_R1;
- state[j + sscanw] |= STATE_NZ_CTXT_R1 | STATE_V_U_R1;
- state[j + 1] |= STATE_NZ_CTXT_R1 | STATE_NZ_CTXT_R2 | STATE_D_DL_R1 | STATE_H_L_R2;
- state[j - 1] |= STATE_NZ_CTXT_R1 | STATE_NZ_CTXT_R2 | STATE_D_DR_R1 | STATE_H_R_R2;
- }
- }
- else
- {
- csj |= STATE_VISITED_R2;
- }
- }
- state[j] = csj;
- }
- // Do half bottom of column
- if (sheight < 3)
- continue;
- j += sscanw;
- csj = state[j];
- // If any of the two samples is not significant and has a
- // non-zero context (i.e. some neighbor is significant) we can
- // not skip them
- if ((((~csj) & (csj << 2)) & SIG_MASK_R1R2) != 0)
- {
- k = sk + (dscanw << 1);
- // Scan first row
- if ((csj & (STATE_SIG_R1 | STATE_NZ_CTXT_R1)) == STATE_NZ_CTXT_R1)
- {
- // Use zero coding
- if (mq.decodeSymbol(zc_lut[csj & ZC_MASK]) != 0)
- {
- // Became significant
- // Use sign coding
- ctxt = SC_LUT[(SupportClass.URShift(csj, SC_SHIFT_R1)) & SC_MASK];
- sym = mq.decodeSymbol(ctxt & SC_LUT_MASK) ^ (SupportClass.URShift(ctxt, SC_SPRED_SHIFT));
- // Update data
- data[k] = (sym << 31) | setmask;
- // Update state information (significant bit,
- // visited bit, neighbor significant bit of
- // neighbors, non zero context of neighbors, sign
- // of neighbors)
- state[j + off_ul] |= STATE_NZ_CTXT_R2 | STATE_D_DR_R2;
- state[j + off_ur] |= STATE_NZ_CTXT_R2 | STATE_D_DL_R2;
- // Update sign state information of neighbors
- if (sym != 0)
- {
- csj |= STATE_SIG_R1 | STATE_VISITED_R1 | STATE_NZ_CTXT_R2 | STATE_V_U_R2 | STATE_V_U_SIGN_R2;
- state[j - sscanw] |= STATE_NZ_CTXT_R2 | STATE_V_D_R2 | STATE_V_D_SIGN_R2;
- state[j + 1] |= STATE_NZ_CTXT_R1 | STATE_NZ_CTXT_R2 | STATE_H_L_R1 | STATE_H_L_SIGN_R1 | STATE_D_UL_R2;
- state[j - 1] |= STATE_NZ_CTXT_R1 | STATE_NZ_CTXT_R2 | STATE_H_R_R1 | STATE_H_R_SIGN_R1 | STATE_D_UR_R2;
- }
- else
- {
- csj |= STATE_SIG_R1 | STATE_VISITED_R1 | STATE_NZ_CTXT_R2 | STATE_V_U_R2;
- state[j - sscanw] |= STATE_NZ_CTXT_R2 | STATE_V_D_R2;
- state[j + 1] |= STATE_NZ_CTXT_R1 | STATE_NZ_CTXT_R2 | STATE_H_L_R1 | STATE_D_UL_R2;
- state[j - 1] |= STATE_NZ_CTXT_R1 | STATE_NZ_CTXT_R2 | STATE_H_R_R1 | STATE_D_UR_R2;
- }
- }
- else
- {
- csj |= STATE_VISITED_R1;
- }
- }
- if (sheight < 4)
- {
- state[j] = csj;
- continue;
- }
- // Scan second row
- if ((csj & (STATE_SIG_R2 | STATE_NZ_CTXT_R2)) == STATE_NZ_CTXT_R2)
- {
- k += dscanw;
- // Use zero coding
- if (mq.decodeSymbol(zc_lut[(SupportClass.URShift(csj, STATE_SEP)) & ZC_MASK]) != 0)
- {
- // Became significant
- // Use sign coding
- ctxt = SC_LUT[(SupportClass.URShift(csj, SC_SHIFT_R2)) & SC_MASK];
- sym = mq.decodeSymbol(ctxt & SC_LUT_MASK) ^ (SupportClass.URShift(ctxt, SC_SPRED_SHIFT));
- // Update data
- data[k] = (sym << 31) | setmask;
- // Update state information (significant bit,
- // visited bit, neighbor significant bit of
- // neighbors, non zero context of neighbors, sign
- // of neighbors)
- state[j + off_dl] |= STATE_NZ_CTXT_R1 | STATE_D_UR_R1;
- state[j + off_dr] |= STATE_NZ_CTXT_R1 | STATE_D_UL_R1;
- // Update sign state information of neighbors
- if (sym != 0)
- {
- csj |= STATE_SIG_R2 | STATE_VISITED_R2 | STATE_NZ_CTXT_R1 | STATE_V_D_R1 | STATE_V_D_SIGN_R1;
- state[j + sscanw] |= STATE_NZ_CTXT_R1 | STATE_V_U_R1 | STATE_V_U_SIGN_R1;
- state[j + 1] |= STATE_NZ_CTXT_R1 | STATE_NZ_CTXT_R2 | STATE_D_DL_R1 | STATE_H_L_R2 | STATE_H_L_SIGN_R2;
- state[j - 1] |= STATE_NZ_CTXT_R1 | STATE_NZ_CTXT_R2 | STATE_D_DR_R1 | STATE_H_R_R2 | STATE_H_R_SIGN_R2;
- }
- else
- {
- csj |= STATE_SIG_R2 | STATE_VISITED_R2 | STATE_NZ_CTXT_R1 | STATE_V_D_R1;
- state[j + sscanw] |= STATE_NZ_CTXT_R1 | STATE_V_U_R1;
- state[j + 1] |= STATE_NZ_CTXT_R1 | STATE_NZ_CTXT_R2 | STATE_D_DL_R1 | STATE_H_L_R2;
- state[j - 1] |= STATE_NZ_CTXT_R1 | STATE_NZ_CTXT_R2 | STATE_D_DR_R1 | STATE_H_R_R2;
- }
- }
- else
- {
- csj |= STATE_VISITED_R2;
- }
- }
- state[j] = csj;
- }
- }
- }
-
- error = false;
-
- // Check the error resilience termination
- if (isterm && (options & CSJ2K.j2k.entropy.StdEntropyCoderOptions.OPT_PRED_TERM) != 0)
- {
- error = mq.checkPredTerm();
- }
-
- // Reset the MQ context states if we need to
- if ((options & CSJ2K.j2k.entropy.StdEntropyCoderOptions.OPT_RESET_MQ) != 0)
- {
- mq.resetCtxts();
- }
-
- // Return error condition
- return error;
- }
-
- /// Performs the significance propagation pass on the specified data and
- /// bit-plane. It decodes all insignificant samples which have, at least,
- /// one of its immediate eight neighbors already significant, using the ZC
- /// and SC primitives as needed. It toggles the "visited" state bit to 1
- /// for all those samples.
- ///
- /// This method bypasses the arithmetic coder and reads "raw" symbols
- /// from the bit stream.
- ///
- /// This method also checks for segmentation markers if those are
- /// present and returns true if an error is detected, or false
- /// otherwise. If an error is detected it measn that the bit stream contains
- /// some erroneous bit that have led to the decoding of incorrect
- /// data. This data affects the whole last decoded bit-plane (i.e. 'bp'). If
- /// 'true' is returned the 'conceal' method should be called and no more
- /// passes should be decoded for this code-block's bit stream.
- ///
- ///
- /// The code-block data to decode
- ///
- ///
- /// The raw bit based input
- ///
- ///
- /// The bit-plane to decode
- ///
- ///
- /// The state information for the code-block
- ///
- ///
- /// If this pass has been terminated. If the pass has been
- /// terminated it can be used to check error resilience.
- ///
- ///
- /// True if an error was detected in the bit stream, false
- /// otherwise.
- ///
- ///
- private bool rawSigProgPass(DataBlk cblk, ByteToBitInput bin, int bp, int[] state, bool isterm)
- {
- int j, sj; // The state index for line and stripe
- int k, sk; // The data index for line and stripe
- int dscanw; // The data scan-width
- int sscanw; // The state scan-width
- int jstep; // Stripe to stripe step for 'sj'
- int kstep; // Stripe to stripe step for 'sk'
- int stopsk; // The loop limit on the variable sk
- int csj; // Local copy (i.e. cached) of 'state[j]'
- int setmask; // The mask to set current and lower bit-planes to 1/2
- // approximation
- int sym; // The symbol to code
- int[] data; // The data buffer
- int s; // The stripe index
- bool causal; // Flag to indicate if stripe-causal context
- // formation is to be used
- int nstripes; // The number of stripes in the code-block
- int sheight; // Height of the current stripe
- int off_ul, off_ur, off_dr, off_dl; // offsets
- bool error; // The error condition
-
- // Initialize local variables
- dscanw = cblk.scanw;
- sscanw = cblk.w + 2;
- jstep = sscanw * CSJ2K.j2k.entropy.StdEntropyCoderOptions.STRIPE_HEIGHT / 2 - cblk.w;
- kstep = dscanw * CSJ2K.j2k.entropy.StdEntropyCoderOptions.STRIPE_HEIGHT - cblk.w;
- setmask = (3 << bp) >> 1;
- data = (int[])cblk.Data;
- nstripes = (cblk.h + CSJ2K.j2k.entropy.StdEntropyCoderOptions.STRIPE_HEIGHT - 1) / CSJ2K.j2k.entropy.StdEntropyCoderOptions.STRIPE_HEIGHT;
- causal = (options & CSJ2K.j2k.entropy.StdEntropyCoderOptions.OPT_VERT_STR_CAUSAL) != 0;
-
- // Pre-calculate offsets in 'state' for diagonal neighbors
- off_ul = -sscanw - 1; // up-left
- off_ur = -sscanw + 1; // up-right
- off_dr = sscanw + 1; // down-right
- off_dl = sscanw - 1; // down-left
-
- // Decode stripe by stripe
- sk = cblk.offset;
- sj = sscanw + 1;
- for (s = nstripes - 1; s >= 0; s--, sk += kstep, sj += jstep)
- {
- sheight = (s != 0) ? CSJ2K.j2k.entropy.StdEntropyCoderOptions.STRIPE_HEIGHT : cblk.h - (nstripes - 1) * CSJ2K.j2k.entropy.StdEntropyCoderOptions.STRIPE_HEIGHT;
- stopsk = sk + cblk.w;
- // Scan by set of 1 stripe column at a time
- for (; sk < stopsk; sk++, sj++)
- {
- // Do half top of column
- j = sj;
- csj = state[j];
- // If any of the two samples is not significant and has a
- // non-zero context (i.e. some neighbor is significant) we can
- // not skip them
- if ((((~csj) & (csj << 2)) & SIG_MASK_R1R2) != 0)
- {
- k = sk;
- // Scan first row
- if ((csj & (STATE_SIG_R1 | STATE_NZ_CTXT_R1)) == STATE_NZ_CTXT_R1)
- {
- // Use zero coding
- if (bin.readBit() != 0)
- {
- // Became significant
- // Use sign coding
- sym = bin.readBit();
- // Update data
- data[k] = (sym << 31) | setmask;
- // Update state information (significant bit,
- // visited bit, neighbor significant bit of
- // neighbors, non zero context of neighbors, sign
- // of neighbors)
- if (!causal)
- {
- // If in causal mode do not change contexts of
- // previous stripe.
- state[j + off_ul] |= STATE_NZ_CTXT_R2 | STATE_D_DR_R2;
- state[j + off_ur] |= STATE_NZ_CTXT_R2 | STATE_D_DL_R2;
- }
- // Update sign state information of neighbors
- if (sym != 0)
- {
- csj |= STATE_SIG_R1 | STATE_VISITED_R1 | STATE_NZ_CTXT_R2 | STATE_V_U_R2 | STATE_V_U_SIGN_R2;
- if (!causal)
- {
- // If in causal mode do not change
- // contexts of previous stripe.
- state[j - sscanw] |= STATE_NZ_CTXT_R2 | STATE_V_D_R2 | STATE_V_D_SIGN_R2;
- }
- state[j + 1] |= STATE_NZ_CTXT_R1 | STATE_NZ_CTXT_R2 | STATE_H_L_R1 | STATE_H_L_SIGN_R1 | STATE_D_UL_R2;
- state[j - 1] |= STATE_NZ_CTXT_R1 | STATE_NZ_CTXT_R2 | STATE_H_R_R1 | STATE_H_R_SIGN_R1 | STATE_D_UR_R2;
- }
- else
- {
- csj |= STATE_SIG_R1 | STATE_VISITED_R1 | STATE_NZ_CTXT_R2 | STATE_V_U_R2;
- if (!causal)
- {
- // If in causal mode do not change
- // contexts of previous stripe.
- state[j - sscanw] |= STATE_NZ_CTXT_R2 | STATE_V_D_R2;
- }
- state[j + 1] |= STATE_NZ_CTXT_R1 | STATE_NZ_CTXT_R2 | STATE_H_L_R1 | STATE_D_UL_R2;
- state[j - 1] |= STATE_NZ_CTXT_R1 | STATE_NZ_CTXT_R2 | STATE_H_R_R1 | STATE_D_UR_R2;
- }
- }
- else
- {
- csj |= STATE_VISITED_R1;
- }
- }
- if (sheight < 2)
- {
- state[j] = csj;
- continue;
- }
- if ((csj & (STATE_SIG_R2 | STATE_NZ_CTXT_R2)) == STATE_NZ_CTXT_R2)
- {
- k += dscanw;
- // Use zero coding
- if (bin.readBit() != 0)
- {
- // Became significant
- // Use sign coding
- sym = bin.readBit();
- // Update data
- data[k] = (sym << 31) | setmask;
- // Update state information (significant bit,
- // visited bit, neighbor significant bit of
- // neighbors, non zero context of neighbors, sign
- // of neighbors)
- state[j + off_dl] |= STATE_NZ_CTXT_R1 | STATE_D_UR_R1;
- state[j + off_dr] |= STATE_NZ_CTXT_R1 | STATE_D_UL_R1;
- // Update sign state information of neighbors
- if (sym != 0)
- {
- csj |= STATE_SIG_R2 | STATE_VISITED_R2 | STATE_NZ_CTXT_R1 | STATE_V_D_R1 | STATE_V_D_SIGN_R1;
- state[j + sscanw] |= STATE_NZ_CTXT_R1 | STATE_V_U_R1 | STATE_V_U_SIGN_R1;
- state[j + 1] |= STATE_NZ_CTXT_R1 | STATE_NZ_CTXT_R2 | STATE_D_DL_R1 | STATE_H_L_R2 | STATE_H_L_SIGN_R2;
- state[j - 1] |= STATE_NZ_CTXT_R1 | STATE_NZ_CTXT_R2 | STATE_D_DR_R1 | STATE_H_R_R2 | STATE_H_R_SIGN_R2;
- }
- else
- {
- csj |= STATE_SIG_R2 | STATE_VISITED_R2 | STATE_NZ_CTXT_R1 | STATE_V_D_R1;
- state[j + sscanw] |= STATE_NZ_CTXT_R1 | STATE_V_U_R1;
- state[j + 1] |= STATE_NZ_CTXT_R1 | STATE_NZ_CTXT_R2 | STATE_D_DL_R1 | STATE_H_L_R2;
- state[j - 1] |= STATE_NZ_CTXT_R1 | STATE_NZ_CTXT_R2 | STATE_D_DR_R1 | STATE_H_R_R2;
- }
- }
- else
- {
- csj |= STATE_VISITED_R2;
- }
- }
- state[j] = csj;
- }
- // Do half bottom of column
- if (sheight < 3)
- continue;
- j += sscanw;
- csj = state[j];
- // If any of the two samples is not significant and has a
- // non-zero context (i.e. some neighbor is significant) we can
- // not skip them
- if ((((~csj) & (csj << 2)) & SIG_MASK_R1R2) != 0)
- {
- k = sk + (dscanw << 1);
- // Scan first row
- if ((csj & (STATE_SIG_R1 | STATE_NZ_CTXT_R1)) == STATE_NZ_CTXT_R1)
- {
- // Use zero coding
- if (bin.readBit() != 0)
- {
- // Became significant
- // Use sign coding
- sym = bin.readBit();
- // Update data
- data[k] = (sym << 31) | setmask;
- // Update state information (significant bit,
- // visited bit, neighbor significant bit of
- // neighbors, non zero context of neighbors, sign
- // of neighbors)
- state[j + off_ul] |= STATE_NZ_CTXT_R2 | STATE_D_DR_R2;
- state[j + off_ur] |= STATE_NZ_CTXT_R2 | STATE_D_DL_R2;
- // Update sign state information of neighbors
- if (sym != 0)
- {
- csj |= STATE_SIG_R1 | STATE_VISITED_R1 | STATE_NZ_CTXT_R2 | STATE_V_U_R2 | STATE_V_U_SIGN_R2;
- state[j - sscanw] |= STATE_NZ_CTXT_R2 | STATE_V_D_R2 | STATE_V_D_SIGN_R2;
- state[j + 1] |= STATE_NZ_CTXT_R1 | STATE_NZ_CTXT_R2 | STATE_H_L_R1 | STATE_H_L_SIGN_R1 | STATE_D_UL_R2;
- state[j - 1] |= STATE_NZ_CTXT_R1 | STATE_NZ_CTXT_R2 | STATE_H_R_R1 | STATE_H_R_SIGN_R1 | STATE_D_UR_R2;
- }
- else
- {
- csj |= STATE_SIG_R1 | STATE_VISITED_R1 | STATE_NZ_CTXT_R2 | STATE_V_U_R2;
- state[j - sscanw] |= STATE_NZ_CTXT_R2 | STATE_V_D_R2;
- state[j + 1] |= STATE_NZ_CTXT_R1 | STATE_NZ_CTXT_R2 | STATE_H_L_R1 | STATE_D_UL_R2;
- state[j - 1] |= STATE_NZ_CTXT_R1 | STATE_NZ_CTXT_R2 | STATE_H_R_R1 | STATE_D_UR_R2;
- }
- }
- else
- {
- csj |= STATE_VISITED_R1;
- }
- }
- if (sheight < 4)
- {
- state[j] = csj;
- continue;
- }
- // Scan second row
- if ((csj & (STATE_SIG_R2 | STATE_NZ_CTXT_R2)) == STATE_NZ_CTXT_R2)
- {
- k += dscanw;
- // Use zero coding
- if (bin.readBit() != 0)
- {
- // Became significant
- // Use sign coding
- sym = bin.readBit();
- // Update data
- data[k] = (sym << 31) | setmask;
- // Update state information (significant bit,
- // visited bit, neighbor significant bit of
- // neighbors, non zero context of neighbors, sign
- // of neighbors)
- state[j + off_dl] |= STATE_NZ_CTXT_R1 | STATE_D_UR_R1;
- state[j + off_dr] |= STATE_NZ_CTXT_R1 | STATE_D_UL_R1;
- // Update sign state information of neighbors
- if (sym != 0)
- {
- csj |= STATE_SIG_R2 | STATE_VISITED_R2 | STATE_NZ_CTXT_R1 | STATE_V_D_R1 | STATE_V_D_SIGN_R1;
- state[j + sscanw] |= STATE_NZ_CTXT_R1 | STATE_V_U_R1 | STATE_V_U_SIGN_R1;
- state[j + 1] |= STATE_NZ_CTXT_R1 | STATE_NZ_CTXT_R2 | STATE_D_DL_R1 | STATE_H_L_R2 | STATE_H_L_SIGN_R2;
- state[j - 1] |= STATE_NZ_CTXT_R1 | STATE_NZ_CTXT_R2 | STATE_D_DR_R1 | STATE_H_R_R2 | STATE_H_R_SIGN_R2;
- }
- else
- {
- csj |= STATE_SIG_R2 | STATE_VISITED_R2 | STATE_NZ_CTXT_R1 | STATE_V_D_R1;
- state[j + sscanw] |= STATE_NZ_CTXT_R1 | STATE_V_U_R1;
- state[j + 1] |= STATE_NZ_CTXT_R1 | STATE_NZ_CTXT_R2 | STATE_D_DL_R1 | STATE_H_L_R2;
- state[j - 1] |= STATE_NZ_CTXT_R1 | STATE_NZ_CTXT_R2 | STATE_D_DR_R1 | STATE_H_R_R2;
- }
- }
- else
- {
- csj |= STATE_VISITED_R2;
- }
- }
- state[j] = csj;
- }
- }
- }
-
- error = false;
-
- // Check the byte padding if the pass is terminated and if the error
- // resilience predictable termination is signaled in COx marker.
- if (isterm && (options & CSJ2K.j2k.entropy.StdEntropyCoderOptions.OPT_PRED_TERM) != 0)
- {
- error = bin.checkBytePadding();
- }
-
- // Return error condition
- return error;
- }
-
- /// Performs the magnitude refinement pass on the specified data and
- /// bit-plane. It decodes the samples which are significant and which do not
- /// have the "visited" state bit turned on, using the MR primitive. The
- /// "visited" state bit is not mofified for any samples.
- ///
- /// This method also checks for segmentation markers if those are
- /// present and returns true if an error is detected, or false
- /// otherwise. If an error is detected it means that the bit stream contains
- /// some erroneous bit that have led to the decoding of incorrect
- /// data. This data affects the whole last decoded bit-plane (i.e. 'bp'). If
- /// 'true' is returned the 'conceal' method should be called and no more
- /// passes should be decoded for this code-block's bit stream.
- ///
- ///
- /// The code-block data to decode
- ///
- ///
- /// The MQ-decoder to use
- ///
- ///
- /// The bit-plane to decode
- ///
- ///
- /// The state information for the code-block
- ///
- ///
- /// If this pass has been terminated. If the pass has been
- /// terminated it can be used to check error resilience.
- ///
- ///
- /// True if an error was detected in the bit stream, false
- /// otherwise.
- ///
- ///
- private bool magRefPass(DataBlk cblk, MQDecoder mq, int bp, int[] state, bool isterm)
- {
- int j, sj; // The state index for line and stripe
- int k, sk; // The data index for line and stripe
- int dscanw; // The data scan-width
- int sscanw; // The state scan-width
- int jstep; // Stripe to stripe step for 'sj'
- int kstep; // Stripe to stripe step for 'sk'
- int stopsk; // The loop limit on the variable sk
- int csj; // Local copy (i.e. cached) of 'state[j]'
- int setmask; // The mask to set lower bit-planes to 1/2 approximation
- int resetmask; // The mask to reset approximation bit-planes
- int sym; // The symbol to decode
- int[] data; // The data buffer
- int s; // The stripe index
- int nstripes; // The number of stripes in the code-block
- int sheight; // Height of the current stripe
- bool error; // The error condition
-
- // Initialize local variables
- dscanw = cblk.scanw;
- sscanw = cblk.w + 2;
- jstep = sscanw * CSJ2K.j2k.entropy.StdEntropyCoderOptions.STRIPE_HEIGHT / 2 - cblk.w;
- kstep = dscanw * CSJ2K.j2k.entropy.StdEntropyCoderOptions.STRIPE_HEIGHT - cblk.w;
- setmask = (1 << bp) >> 1;
- resetmask = (-1) << (bp + 1);
- data = (int[])cblk.Data;
- nstripes = (cblk.h + CSJ2K.j2k.entropy.StdEntropyCoderOptions.STRIPE_HEIGHT - 1) / CSJ2K.j2k.entropy.StdEntropyCoderOptions.STRIPE_HEIGHT;
-
- // Decode stripe by stripe
- sk = cblk.offset;
- sj = sscanw + 1;
- for (s = nstripes - 1; s >= 0; s--, sk += kstep, sj += jstep)
- {
- sheight = (s != 0) ? CSJ2K.j2k.entropy.StdEntropyCoderOptions.STRIPE_HEIGHT : cblk.h - (nstripes - 1) * CSJ2K.j2k.entropy.StdEntropyCoderOptions.STRIPE_HEIGHT;
- stopsk = sk + cblk.w;
- // Scan by set of 1 stripe column at a time
- for (; sk < stopsk; sk++, sj++)
- {
- // Do half top of column
- j = sj;
- csj = state[j];
- // If any of the two samples is significant and not yet
- // visited in the current bit-plane we can not skip them
- if ((((SupportClass.URShift(csj, 1)) & (~csj)) & VSTD_MASK_R1R2) != 0)
- {
- k = sk;
- // Scan first row
- if ((csj & (STATE_SIG_R1 | STATE_VISITED_R1)) == STATE_SIG_R1)
- {
- // Use MR primitive
- sym = mq.decodeSymbol(MR_LUT[csj & MR_MASK]);
- // Update the data
- data[k] &= resetmask;
- data[k] |= (sym << bp) | setmask;
- // Update the STATE_PREV_MR bit
- csj |= STATE_PREV_MR_R1;
- }
- if (sheight < 2)
- {
- state[j] = csj;
- continue;
- }
- // Scan second row
- if ((csj & (STATE_SIG_R2 | STATE_VISITED_R2)) == STATE_SIG_R2)
- {
- k += dscanw;
- // Use MR primitive
- sym = mq.decodeSymbol(MR_LUT[(SupportClass.URShift(csj, STATE_SEP)) & MR_MASK]);
- // Update the data
- data[k] &= resetmask;
- data[k] |= (sym << bp) | setmask;
- // Update the STATE_PREV_MR bit
- csj |= STATE_PREV_MR_R2;
- }
- state[j] = csj;
- }
- // Do half bottom of column
- if (sheight < 3)
- continue;
- j += sscanw;
- csj = state[j];
- // If any of the two samples is significant and not yet
- // visited in the current bit-plane we can not skip them
- if ((((SupportClass.URShift(csj, 1)) & (~csj)) & VSTD_MASK_R1R2) != 0)
- {
- k = sk + (dscanw << 1);
- // Scan first row
- if ((csj & (STATE_SIG_R1 | STATE_VISITED_R1)) == STATE_SIG_R1)
- {
- // Use MR primitive
- sym = mq.decodeSymbol(MR_LUT[csj & MR_MASK]);
- // Update the data
- data[k] &= resetmask;
- data[k] |= (sym << bp) | setmask;
- // Update the STATE_PREV_MR bit
- csj |= STATE_PREV_MR_R1;
- }
- if (sheight < 4)
- {
- state[j] = csj;
- continue;
- }
- // Scan second row
- if ((state[j] & (STATE_SIG_R2 | STATE_VISITED_R2)) == STATE_SIG_R2)
- {
- k += dscanw;
- // Use MR primitive
- sym = mq.decodeSymbol(MR_LUT[(SupportClass.URShift(csj, STATE_SEP)) & MR_MASK]);
- // Update the data
- data[k] &= resetmask;
- data[k] |= (sym << bp) | setmask;
- // Update the STATE_PREV_MR bit
- csj |= STATE_PREV_MR_R2;
- }
- state[j] = csj;
- }
- }
- }
-
- error = false;
-
- // Check the error resilient termination
- if (isterm && (options & CSJ2K.j2k.entropy.StdEntropyCoderOptions.OPT_PRED_TERM) != 0)
- {
- error = mq.checkPredTerm();
- }
-
- // Reset the MQ context states if we need to
- if ((options & CSJ2K.j2k.entropy.StdEntropyCoderOptions.OPT_RESET_MQ) != 0)
- {
- mq.resetCtxts();
- }
-
- // Return error condition
- return error;
- }
-
- /// Performs the magnitude refinement pass on the specified data and
- /// bit-plane. It decodes the samples which are significant and which do
- /// not have the "visited" state bit turned on, using the MR primitive. The
- /// "visited" state bit is not mofified for any samples.
- ///
- /// This method bypasses the arithmetic coder and reads "raw" symbols
- /// from the bit stream.
- ///
- ///
This method also checks for segmentation markers if those are
- /// present and returns true if an error is detected, or false
- /// otherwise. If an error is detected it measn that the bit stream
- /// contains some erroneous bit that have led to the decoding of incorrect
- /// data. This data affects the whole last decoded bit-plane
- /// (i.e. 'bp'). If 'true' is returned the 'conceal' method should be
- /// called and no more passes should be decoded for this code-block's bit
- /// stream.
- ///
- ///
- /// The code-block data to decode
- ///
- ///
- /// The raw bit based input
- ///
- ///
- /// The bit-plane to decode
- ///
- ///
- /// The state information for the code-block
- ///
- ///
- /// If this pass has been terminated. If the pass has been
- /// terminated it can be used to check error resilience.
- ///
- ///
- /// True if an error was detected in the bit stream, false
- /// otherwise.
- ///
- ///
- private bool rawMagRefPass(DataBlk cblk, ByteToBitInput bin, int bp, int[] state, bool isterm)
- {
- int j, sj; // The state index for line and stripe
- int k, sk; // The data index for line and stripe
- int dscanw; // The data scan-width
- int sscanw; // The state scan-width
- int jstep; // Stripe to stripe step for 'sj'
- int kstep; // Stripe to stripe step for 'sk'
- int stopsk; // The loop limit on the variable sk
- int csj; // Local copy (i.e. cached) of 'state[j]'
- int setmask; // The mask to set lower bit-planes to 1/2 approximation
- int resetmask; // The mask to reset approximation bit-planes
- int sym; // The symbol to decode
- int[] data; // The data buffer
- int s; // The stripe index
- int nstripes; // The number of stripes in the code-block
- int sheight; // Height of the current stripe
- bool error; // The error condition
-
- // Initialize local variables
- dscanw = cblk.scanw;
- sscanw = cblk.w + 2;
- jstep = sscanw * CSJ2K.j2k.entropy.StdEntropyCoderOptions.STRIPE_HEIGHT / 2 - cblk.w;
- kstep = dscanw * CSJ2K.j2k.entropy.StdEntropyCoderOptions.STRIPE_HEIGHT - cblk.w;
- setmask = (1 << bp) >> 1;
- resetmask = (-1) << (bp + 1);
- data = (int[])cblk.Data;
- nstripes = (cblk.h + CSJ2K.j2k.entropy.StdEntropyCoderOptions.STRIPE_HEIGHT - 1) / CSJ2K.j2k.entropy.StdEntropyCoderOptions.STRIPE_HEIGHT;
-
- // Decode stripe by stripe
- sk = cblk.offset;
- sj = sscanw + 1;
- for (s = nstripes - 1; s >= 0; s--, sk += kstep, sj += jstep)
- {
- sheight = (s != 0) ? CSJ2K.j2k.entropy.StdEntropyCoderOptions.STRIPE_HEIGHT : cblk.h - (nstripes - 1) * CSJ2K.j2k.entropy.StdEntropyCoderOptions.STRIPE_HEIGHT;
- stopsk = sk + cblk.w;
- // Scan by set of 1 stripe column at a time
- for (; sk < stopsk; sk++, sj++)
- {
- // Do half top of column
- j = sj;
- csj = state[j];
- // If any of the two samples is significant and not yet
- // visited in the current bit-plane we can not skip them
- if ((((SupportClass.URShift(csj, 1)) & (~csj)) & VSTD_MASK_R1R2) != 0)
- {
- k = sk;
- // Scan first row
- if ((csj & (STATE_SIG_R1 | STATE_VISITED_R1)) == STATE_SIG_R1)
- {
- // Read raw bit (no MR primative)
- sym = bin.readBit();
- // Update the data
- data[k] &= resetmask;
- data[k] |= (sym << bp) | setmask;
- // No need to set STATE_PREV_MR_R1 since all magnitude
- // refinement passes to follow are "raw"
- }
- if (sheight < 2)
- continue;
- // Scan second row
- if ((csj & (STATE_SIG_R2 | STATE_VISITED_R2)) == STATE_SIG_R2)
- {
- k += dscanw;
- // Read raw bit (no MR primative)
- sym = bin.readBit();
- // Update the data
- data[k] &= resetmask;
- data[k] |= (sym << bp) | setmask;
- // No need to set STATE_PREV_MR_R1 since all magnitude
- // refinement passes to follow are "raw"
- }
- }
- // Do half bottom of column
- if (sheight < 3)
- continue;
- j += sscanw;
- csj = state[j];
- // If any of the two samples is significant and not yet
- // visited in the current bit-plane we can not skip them
- if ((((SupportClass.URShift(csj, 1)) & (~csj)) & VSTD_MASK_R1R2) != 0)
- {
- k = sk + (dscanw << 1);
- // Scan first row
- if ((csj & (STATE_SIG_R1 | STATE_VISITED_R1)) == STATE_SIG_R1)
- {
- // Read raw bit (no MR primative)
- sym = bin.readBit();
- // Update the data
- data[k] &= resetmask;
- data[k] |= (sym << bp) | setmask;
- // No need to set STATE_PREV_MR_R1 since all magnitude
- // refinement passes to follow are "raw"
- }
- if (sheight < 4)
- continue;
- // Scan second row
- if ((state[j] & (STATE_SIG_R2 | STATE_VISITED_R2)) == STATE_SIG_R2)
- {
- k += dscanw;
- // Read raw bit (no MR primative)
- sym = bin.readBit();
- // Update the data
- data[k] &= resetmask;
- data[k] |= (sym << bp) | setmask;
- // No need to set STATE_PREV_MR_R1 since all magnitude
- // refinement passes to follow are "raw"
- }
- }
- }
- }
-
- error = false;
-
- // Check the byte padding if the pass is terminated and the
- // predictable termination is signaled in COx marker.
- if (isterm && (options & CSJ2K.j2k.entropy.StdEntropyCoderOptions.OPT_PRED_TERM) != 0)
- {
- error = bin.checkBytePadding();
- }
-
- // Return error condition
- return error;
- }
-
- /// Performs the cleanup pass on the specified data and bit-plane. It
- /// decodes all insignificant samples which have its "visited" state bit
- /// off, using the ZC, SC, and RLC primitives. It toggles the "visited"
- /// state bit to 0 (off) for all samples in the code-block.
- ///
- /// This method also checks for segmentation markers if those are
- /// present and returns true if an error is detected, or false
- /// otherwise. If an error is detected it measn that the bit stream
- /// contains some erroneous bit that have led to the decoding of incorrect
- /// data. This data affects the whole last decoded bit-plane
- /// (i.e. 'bp'). If 'true' is returned the 'conceal' method should be
- /// called and no more passes should be decoded for this code-block's bit
- /// stream.
- ///
- ///
- /// The code-block data to code
- ///
- ///
- /// The MQ-coder to use
- ///
- ///
- /// The bit-plane to decode
- ///
- ///
- /// The state information for the code-block
- ///
- ///
- /// The ZC lookup table to use in ZC.
- ///
- ///
- /// If this pass has been terminated. If the pass has been
- /// terminated it can be used to check error resilience.
- ///
- ///
- /// True if an error was detected in the bit stream, false
- /// otherwise.
- ///
- ///
- private bool cleanuppass(DataBlk cblk, MQDecoder mq, int bp, int[] state, int[] zc_lut, bool isterm)
- {
- int j, sj; // The state index for line and stripe
- int k, sk; // The data index for line and stripe
- int dscanw; // The data scan-width
- int sscanw; // The state scan-width
- int jstep; // Stripe to stripe step for 'sj'
- int kstep; // Stripe to stripe step for 'sk'
- int stopsk; // The loop limit on the variable sk
- int csj; // Local copy (i.e. cached) of 'state[j]'
- int setmask; // The mask to set current and lower bit-planes to 1/2
- // approximation
- int sym; // The decoded symbol
- int rlclen; // Length of RLC
- int ctxt; // The context to use
- int[] data; // The data buffer
- int s; // The stripe index
- bool causal; // Flag to indicate if stripe-causal context
- // formation is to be used
- int nstripes; // The number of stripes in the code-block
- int sheight; // Height of the current stripe
- int off_ul, off_ur, off_dr, off_dl; // offsets
- bool error; // The error condition
-
- // Initialize local variables
- dscanw = cblk.scanw;
- sscanw = cblk.w + 2;
- jstep = sscanw * CSJ2K.j2k.entropy.StdEntropyCoderOptions.STRIPE_HEIGHT / 2 - cblk.w;
- kstep = dscanw * CSJ2K.j2k.entropy.StdEntropyCoderOptions.STRIPE_HEIGHT - cblk.w;
- setmask = (3 << bp) >> 1;
- data = (int[])cblk.Data;
- nstripes = (cblk.h + CSJ2K.j2k.entropy.StdEntropyCoderOptions.STRIPE_HEIGHT - 1) / CSJ2K.j2k.entropy.StdEntropyCoderOptions.STRIPE_HEIGHT;
- causal = (options & CSJ2K.j2k.entropy.StdEntropyCoderOptions.OPT_VERT_STR_CAUSAL) != 0;
-
- // Pre-calculate offsets in 'state' for diagonal neighbors
- off_ul = -sscanw - 1; // up-left
- off_ur = -sscanw + 1; // up-right
- off_dr = sscanw + 1; // down-right
- off_dl = sscanw - 1; // down-left
-
- // Decode stripe by stripe
- sk = cblk.offset;
- sj = sscanw + 1;
- for (s = nstripes - 1; s >= 0; s--, sk += kstep, sj += jstep)
- {
- sheight = (s != 0) ? CSJ2K.j2k.entropy.StdEntropyCoderOptions.STRIPE_HEIGHT : cblk.h - (nstripes - 1) * CSJ2K.j2k.entropy.StdEntropyCoderOptions.STRIPE_HEIGHT;
- stopsk = sk + cblk.w;
- // Scan by set of 1 stripe column at a time
- for (; sk < stopsk; sk++, sj++)
- {
- // Start column
- j = sj;
- csj = state[j];
- {
- // Check for RLC: if all samples are not significant, not
- // visited and do not have a non-zero context, and column
- // is full height, we do RLC.
- if (csj == 0 && state[j + sscanw] == 0 && sheight == CSJ2K.j2k.entropy.StdEntropyCoderOptions.STRIPE_HEIGHT)
- {
- if (mq.decodeSymbol(RLC_CTXT) != 0)
- {
- // run-length is significant, decode length
- rlclen = mq.decodeSymbol(UNIF_CTXT) << 1;
- rlclen |= mq.decodeSymbol(UNIF_CTXT);
- // Set 'k' and 'j' accordingly
- k = sk + rlclen * dscanw;
- if (rlclen > 1)
- {
- j += sscanw;
- csj = state[j];
- }
- }
- else
- {
- // RLC is insignificant
- // Goto next column
- continue;
- }
- // We just decoded the length of a significant RLC
- // and a sample became significant
- // Use sign coding
- if ((rlclen & 0x01) == 0)
- {
- // Sample that became significant is first row of
- // its column half
- ctxt = SC_LUT[(csj >> SC_SHIFT_R1) & SC_MASK];
- sym = mq.decodeSymbol(ctxt & SC_LUT_MASK) ^ (SupportClass.URShift(ctxt, SC_SPRED_SHIFT));
- // Update the data
- data[k] = (sym << 31) | setmask;
- // Update state information (significant bit,
- // visited bit, neighbor significant bit of
- // neighbors, non zero context of neighbors, sign
- // of neighbors)
- if (rlclen != 0 || !causal)
- {
- // If in causal mode do not change
- // contexts of previous stripe.
- state[j + off_ul] |= STATE_NZ_CTXT_R2 | STATE_D_DR_R2;
- state[j + off_ur] |= STATE_NZ_CTXT_R2 | STATE_D_DL_R2;
- }
- // Update sign state information of neighbors
- if (sym != 0)
- {
- csj |= STATE_SIG_R1 | STATE_VISITED_R1 | STATE_NZ_CTXT_R2 | STATE_V_U_R2 | STATE_V_U_SIGN_R2;
- if (rlclen != 0 || !causal)
- {
- // If in causal mode do not change
- // contexts of previous stripe.
- state[j - sscanw] |= STATE_NZ_CTXT_R2 | STATE_V_D_R2 | STATE_V_D_SIGN_R2;
- }
- state[j + 1] |= STATE_NZ_CTXT_R1 | STATE_NZ_CTXT_R2 | STATE_H_L_R1 | STATE_H_L_SIGN_R1 | STATE_D_UL_R2;
- state[j - 1] |= STATE_NZ_CTXT_R1 | STATE_NZ_CTXT_R2 | STATE_H_R_R1 | STATE_H_R_SIGN_R1 | STATE_D_UR_R2;
- }
- else
- {
- csj |= STATE_SIG_R1 | STATE_VISITED_R1 | STATE_NZ_CTXT_R2 | STATE_V_U_R2;
- if (rlclen != 0 || !causal)
- {
- // If in causal mode do not change
- // contexts of previous stripe.
- state[j - sscanw] |= STATE_NZ_CTXT_R2 | STATE_V_D_R2;
- }
- state[j + 1] |= STATE_NZ_CTXT_R1 | STATE_NZ_CTXT_R2 | STATE_H_L_R1 | STATE_D_UL_R2;
- state[j - 1] |= STATE_NZ_CTXT_R1 | STATE_NZ_CTXT_R2 | STATE_H_R_R1 | STATE_D_UR_R2;
- }
- // Changes to csj are saved later
- if ((rlclen >> 1) != 0)
- {
- // Sample that became significant is in
- // bottom half of column => jump to bottom
- // half
- //UPGRADE_NOTE: Labeled break statement was changed to a goto statement. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1012'"
- goto top_half_brk;
- }
- // Otherwise sample that became significant is in
- // top half of column => continue on top half
- }
- else
- {
- // Sample that became significant is second row of
- // its column half
- ctxt = SC_LUT[(csj >> SC_SHIFT_R2) & SC_MASK];
- sym = mq.decodeSymbol(ctxt & SC_LUT_MASK) ^ (SupportClass.URShift(ctxt, SC_SPRED_SHIFT));
- // Update the data
- data[k] = (sym << 31) | setmask;
- // Update state information (significant bit,
- // neighbor significant bit of neighbors, non zero
- // context of neighbors, sign of neighbors)
- state[j + off_dl] |= STATE_NZ_CTXT_R1 | STATE_D_UR_R1;
- state[j + off_dr] |= STATE_NZ_CTXT_R1 | STATE_D_UL_R1;
- // Update sign state information of neighbors
- if (sym != 0)
- {
- csj |= STATE_SIG_R2 | STATE_NZ_CTXT_R1 | STATE_V_D_R1 | STATE_V_D_SIGN_R1;
- state[j + sscanw] |= STATE_NZ_CTXT_R1 | STATE_V_U_R1 | STATE_V_U_SIGN_R1;
- state[j + 1] |= STATE_NZ_CTXT_R1 | STATE_NZ_CTXT_R2 | STATE_D_DL_R1 | STATE_H_L_R2 | STATE_H_L_SIGN_R2;
- state[j - 1] |= STATE_NZ_CTXT_R1 | STATE_NZ_CTXT_R2 | STATE_D_DR_R1 | STATE_H_R_R2 | STATE_H_R_SIGN_R2;
- }
- else
- {
- csj |= STATE_SIG_R2 | STATE_NZ_CTXT_R1 | STATE_V_D_R1;
- state[j + sscanw] |= STATE_NZ_CTXT_R1 | STATE_V_U_R1;
- state[j + 1] |= STATE_NZ_CTXT_R1 | STATE_NZ_CTXT_R2 | STATE_D_DL_R1 | STATE_H_L_R2;
- state[j - 1] |= STATE_NZ_CTXT_R1 | STATE_NZ_CTXT_R2 | STATE_D_DR_R1 | STATE_H_R_R2;
- }
- // Save changes to csj
- state[j] = csj;
- if ((rlclen >> 1) != 0)
- {
- // Sample that became significant is in bottom
- // half of column => we're done with this
- // column
- continue;
- }
- // Otherwise sample that became significant is in
- // top half of column => we're done with top
- // column
- j += sscanw;
- csj = state[j];
- //UPGRADE_NOTE: Labeled break statement was changed to a goto statement. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1012'"
- goto top_half_brk;
- }
- }
- // Do half top of column
- // If any of the two samples is not significant and has
- // not been visited in the current bit-plane we can not
- // skip them
- if ((((csj >> 1) | csj) & VSTD_MASK_R1R2) != VSTD_MASK_R1R2)
- {
- k = sk;
- // Scan first row
- if ((csj & (STATE_SIG_R1 | STATE_VISITED_R1)) == 0)
- {
- // Use zero coding
- if (mq.decodeSymbol(zc_lut[csj & ZC_MASK]) != 0)
- {
- // Became significant
- // Use sign coding
- ctxt = SC_LUT[(SupportClass.URShift(csj, SC_SHIFT_R1)) & SC_MASK];
- sym = mq.decodeSymbol(ctxt & SC_LUT_MASK) ^ (SupportClass.URShift(ctxt, SC_SPRED_SHIFT));
- // Update the data
- data[k] = (sym << 31) | setmask;
- // Update state information (significant bit,
- // visited bit, neighbor significant bit of
- // neighbors, non zero context of neighbors,
- // sign of neighbors)
- if (!causal)
- {
- // If in causal mode do not change
- // contexts of previous stripe.
- state[j + off_ul] |= STATE_NZ_CTXT_R2 | STATE_D_DR_R2;
- state[j + off_ur] |= STATE_NZ_CTXT_R2 | STATE_D_DL_R2;
- }
- // Update sign state information of neighbors
- if (sym != 0)
- {
- csj |= STATE_SIG_R1 | STATE_VISITED_R1 | STATE_NZ_CTXT_R2 | STATE_V_U_R2 | STATE_V_U_SIGN_R2;
- if (!causal)
- {
- // If in causal mode do not change
- // contexts of previous stripe.
- state[j - sscanw] |= STATE_NZ_CTXT_R2 | STATE_V_D_R2 | STATE_V_D_SIGN_R2;
- }
- state[j + 1] |= STATE_NZ_CTXT_R1 | STATE_NZ_CTXT_R2 | STATE_H_L_R1 | STATE_H_L_SIGN_R1 | STATE_D_UL_R2;
- state[j - 1] |= STATE_NZ_CTXT_R1 | STATE_NZ_CTXT_R2 | STATE_H_R_R1 | STATE_H_R_SIGN_R1 | STATE_D_UR_R2;
- }
- else
- {
- csj |= STATE_SIG_R1 | STATE_VISITED_R1 | STATE_NZ_CTXT_R2 | STATE_V_U_R2;
- if (!causal)
- {
- // If in causal mode do not change
- // contexts of previous stripe.
- state[j - sscanw] |= STATE_NZ_CTXT_R2 | STATE_V_D_R2;
- }
- state[j + 1] |= STATE_NZ_CTXT_R1 | STATE_NZ_CTXT_R2 | STATE_H_L_R1 | STATE_D_UL_R2;
- state[j - 1] |= STATE_NZ_CTXT_R1 | STATE_NZ_CTXT_R2 | STATE_H_R_R1 | STATE_D_UR_R2;
- }
- }
- }
- if (sheight < 2)
- {
- csj &= ~(STATE_VISITED_R1 | STATE_VISITED_R2);
- state[j] = csj;
- continue;
- }
- // Scan second row
- if ((csj & (STATE_SIG_R2 | STATE_VISITED_R2)) == 0)
- {
- k += dscanw;
- // Use zero coding
- if (mq.decodeSymbol(zc_lut[(SupportClass.URShift(csj, STATE_SEP)) & ZC_MASK]) != 0)
- {
- // Became significant
- // Use sign coding
- ctxt = SC_LUT[(SupportClass.URShift(csj, SC_SHIFT_R2)) & SC_MASK];
- sym = mq.decodeSymbol(ctxt & SC_LUT_MASK) ^ (SupportClass.URShift(ctxt, SC_SPRED_SHIFT));
- // Update the data
- data[k] = (sym << 31) | setmask;
- // Update state information (significant bit,
- // visited bit, neighbor significant bit of
- // neighbors, non zero context of neighbors,
- // sign of neighbors)
- state[j + off_dl] |= STATE_NZ_CTXT_R1 | STATE_D_UR_R1;
- state[j + off_dr] |= STATE_NZ_CTXT_R1 | STATE_D_UL_R1;
- // Update sign state information of neighbors
- if (sym != 0)
- {
- csj |= STATE_SIG_R2 | STATE_VISITED_R2 | STATE_NZ_CTXT_R1 | STATE_V_D_R1 | STATE_V_D_SIGN_R1;
- state[j + sscanw] |= STATE_NZ_CTXT_R1 | STATE_V_U_R1 | STATE_V_U_SIGN_R1;
- state[j + 1] |= STATE_NZ_CTXT_R1 | STATE_NZ_CTXT_R2 | STATE_D_DL_R1 | STATE_H_L_R2 | STATE_H_L_SIGN_R2;
- state[j - 1] |= STATE_NZ_CTXT_R1 | STATE_NZ_CTXT_R2 | STATE_D_DR_R1 | STATE_H_R_R2 | STATE_H_R_SIGN_R2;
- }
- else
- {
- csj |= STATE_SIG_R2 | STATE_VISITED_R2 | STATE_NZ_CTXT_R1 | STATE_V_D_R1;
- state[j + sscanw] |= STATE_NZ_CTXT_R1 | STATE_V_U_R1;
- state[j + 1] |= STATE_NZ_CTXT_R1 | STATE_NZ_CTXT_R2 | STATE_D_DL_R1 | STATE_H_L_R2;
- state[j - 1] |= STATE_NZ_CTXT_R1 | STATE_NZ_CTXT_R2 | STATE_D_DR_R1 | STATE_H_R_R2;
- }
- }
- }
- }
- csj &= ~(STATE_VISITED_R1 | STATE_VISITED_R2);
- state[j] = csj;
- // Do half bottom of column
- if (sheight < 3)
- continue;
- j += sscanw;
- csj = state[j];
- }
- //UPGRADE_NOTE: Label 'top_half_brk' was added. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1011'"
-
- top_half_brk:;
- // end of 'top_half' block
- // If any of the two samples is not significant and has
- // not been visited in the current bit-plane we can not
- // skip them
- if ((((csj >> 1) | csj) & VSTD_MASK_R1R2) != VSTD_MASK_R1R2)
- {
- k = sk + (dscanw << 1);
- // Scan first row
- if ((csj & (STATE_SIG_R1 | STATE_VISITED_R1)) == 0)
- {
- // Use zero coding
- if (mq.decodeSymbol(zc_lut[csj & ZC_MASK]) != 0)
- {
- // Became significant
- // Use sign coding
- ctxt = SC_LUT[(csj >> SC_SHIFT_R1) & SC_MASK];
- sym = mq.decodeSymbol(ctxt & SC_LUT_MASK) ^ (SupportClass.URShift(ctxt, SC_SPRED_SHIFT));
- // Update the data
- data[k] = (sym << 31) | setmask;
- // Update state information (significant bit,
- // visited bit, neighbor significant bit of
- // neighbors, non zero context of neighbors,
- // sign of neighbors)
- state[j + off_ul] |= STATE_NZ_CTXT_R2 | STATE_D_DR_R2;
- state[j + off_ur] |= STATE_NZ_CTXT_R2 | STATE_D_DL_R2;
- // Update sign state information of neighbors
- if (sym != 0)
- {
- csj |= STATE_SIG_R1 | STATE_VISITED_R1 | STATE_NZ_CTXT_R2 | STATE_V_U_R2 | STATE_V_U_SIGN_R2;
- state[j - sscanw] |= STATE_NZ_CTXT_R2 | STATE_V_D_R2 | STATE_V_D_SIGN_R2;
- state[j + 1] |= STATE_NZ_CTXT_R1 | STATE_NZ_CTXT_R2 | STATE_H_L_R1 | STATE_H_L_SIGN_R1 | STATE_D_UL_R2;
- state[j - 1] |= STATE_NZ_CTXT_R1 | STATE_NZ_CTXT_R2 | STATE_H_R_R1 | STATE_H_R_SIGN_R1 | STATE_D_UR_R2;
- }
- else
- {
- csj |= STATE_SIG_R1 | STATE_VISITED_R1 | STATE_NZ_CTXT_R2 | STATE_V_U_R2;
- state[j - sscanw] |= STATE_NZ_CTXT_R2 | STATE_V_D_R2;
- state[j + 1] |= STATE_NZ_CTXT_R1 | STATE_NZ_CTXT_R2 | STATE_H_L_R1 | STATE_D_UL_R2;
- state[j - 1] |= STATE_NZ_CTXT_R1 | STATE_NZ_CTXT_R2 | STATE_H_R_R1 | STATE_D_UR_R2;
- }
- }
- }
- if (sheight < 4)
- {
- csj &= ~(STATE_VISITED_R1 | STATE_VISITED_R2);
- state[j] = csj;
- continue;
- }
- // Scan second row
- if ((csj & (STATE_SIG_R2 | STATE_VISITED_R2)) == 0)
- {
- k += dscanw;
- // Use zero coding
- if (mq.decodeSymbol(zc_lut[(SupportClass.URShift(csj, STATE_SEP)) & ZC_MASK]) != 0)
- {
- // Became significant
- // Use sign coding
- ctxt = SC_LUT[(SupportClass.URShift(csj, SC_SHIFT_R2)) & SC_MASK];
- sym = mq.decodeSymbol(ctxt & SC_LUT_MASK) ^ (SupportClass.URShift(ctxt, SC_SPRED_SHIFT));
- // Update the data
- data[k] = (sym << 31) | setmask;
- // Update state information (significant bit,
- // visited bit, neighbor significant bit of
- // neighbors, non zero context of neighbors,
- // sign of neighbors)
- state[j + off_dl] |= STATE_NZ_CTXT_R1 | STATE_D_UR_R1;
- state[j + off_dr] |= STATE_NZ_CTXT_R1 | STATE_D_UL_R1;
- // Update sign state information of neighbors
- if (sym != 0)
- {
- csj |= STATE_SIG_R2 | STATE_VISITED_R2 | STATE_NZ_CTXT_R1 | STATE_V_D_R1 | STATE_V_D_SIGN_R1;
- state[j + sscanw] |= STATE_NZ_CTXT_R1 | STATE_V_U_R1 | STATE_V_U_SIGN_R1;
- state[j + 1] |= STATE_NZ_CTXT_R1 | STATE_NZ_CTXT_R2 | STATE_D_DL_R1 | STATE_H_L_R2 | STATE_H_L_SIGN_R2;
- state[j - 1] |= STATE_NZ_CTXT_R1 | STATE_NZ_CTXT_R2 | STATE_D_DR_R1 | STATE_H_R_R2 | STATE_H_R_SIGN_R2;
- }
- else
- {
- csj |= STATE_SIG_R2 | STATE_VISITED_R2 | STATE_NZ_CTXT_R1 | STATE_V_D_R1;
- state[j + sscanw] |= STATE_NZ_CTXT_R1 | STATE_V_U_R1;
- state[j + 1] |= STATE_NZ_CTXT_R1 | STATE_NZ_CTXT_R2 | STATE_D_DL_R1 | STATE_H_L_R2;
- state[j - 1] |= STATE_NZ_CTXT_R1 | STATE_NZ_CTXT_R2 | STATE_D_DR_R1 | STATE_H_R_R2;
- }
- }
- }
- }
- csj &= ~(STATE_VISITED_R1 | STATE_VISITED_R2);
- state[j] = csj;
- }
- }
-
- // Decode segment symbol if we need to
- if ((options & CSJ2K.j2k.entropy.StdEntropyCoderOptions.OPT_SEG_SYMBOLS) != 0)
- {
- sym = mq.decodeSymbol(UNIF_CTXT) << 3;
- sym |= mq.decodeSymbol(UNIF_CTXT) << 2;
- sym |= mq.decodeSymbol(UNIF_CTXT) << 1;
- sym |= mq.decodeSymbol(UNIF_CTXT);
- // Set error condition accordingly
- error = sym != SEG_SYMBOL;
- }
- else
- {
- // We can not detect any errors
- error = false;
- }
-
- // Check the error resilience termination
- if (isterm && (options & CSJ2K.j2k.entropy.StdEntropyCoderOptions.OPT_PRED_TERM) != 0)
- {
- error = mq.checkPredTerm();
- }
-
- // Reset the MQ context states if we need to
- if ((options & CSJ2K.j2k.entropy.StdEntropyCoderOptions.OPT_RESET_MQ) != 0)
- {
- mq.resetCtxts();
- }
-
- // Return error condition
- return error;
- }
-
- /// Conceals decoding errors detected in the last bit-plane. The
- /// concealement resets the state of the decoded data to what it was before
- /// the decoding of bit-plane 'bp' started. No more data should be decoded
- /// after this method is called for this code-block's data to which it is
- /// applied.
- ///
- ///
- /// The code-block's data
- ///
- ///
- /// The last decoded bit-plane (which contains errors).
- ///
- ///
- private void conceal(DataBlk cblk, int bp)
- {
- int l; // line index
- int k; // array index
- int kmax; // 'k' limit
- int dk; // Value of data[k]
- int[] data; // the data array
- int setmask; // Bitmask to set approximation to 1/2 of
- // known interval on significant data
- int resetmask; // Bitmask to erase all the data from
- // bit-plane 'bp'
-
- // Initialize masks
- setmask = 1 << bp;
- resetmask = (-1) << (bp);
-
- // Get the data array
- data = (int[])cblk.Data;
-
- // Visit each sample, apply the reset mask to it and add an
- // approximation if significant.
- for (l = cblk.h - 1, k = cblk.offset; l >= 0; l--)
- {
- for (kmax = k + cblk.w; k < kmax; k++)
- {
- dk = data[k];
- if ((dk & resetmask & 0x7FFFFFFF) != 0)
- {
- // Something was decoded in previous bit-planes => set the
- // approximation for previous bit-plane
- data[k] = (dk & resetmask) | setmask;
- }
- else
- {
- // Was insignificant in previous bit-planes = set to zero
- data[k] = 0;
- }
- }
- k += cblk.scanw - cblk.w;
- }
- }
- /// Static initializer: initializes all the lookup tables.
- static StdEntropyDecoder()
- {
- {
- int i, j;
- //double val, deltaMSE;
- int[] inter_sc_lut;
- int ds, us, rs, ls;
- int dsgn, usgn, rsgn, lsgn;
- int h, v;
-
- // Initialize the zero coding lookup tables
-
- // LH
-
- // - No neighbors significant
- ZC_LUT_LH[0] = 2;
- // - No horizontal or vertical neighbors significant
- for (i = 1; i < 16; i++)
- {
- // Two or more diagonal coeffs significant
- ZC_LUT_LH[i] = 4;
- }
- for (i = 0; i < 4; i++)
- {
- // Only one diagonal coeff significant
- ZC_LUT_LH[1 << i] = 3;
- }
- // - No horizontal neighbors significant, diagonal irrelevant
- for (i = 0; i < 16; i++)
- {
- // Only one vertical coeff significant
- ZC_LUT_LH[STATE_V_U_R1 | i] = 5;
- ZC_LUT_LH[STATE_V_D_R1 | i] = 5;
- // The two vertical coeffs significant
- ZC_LUT_LH[STATE_V_U_R1 | STATE_V_D_R1 | i] = 6;
- }
- // - One horiz. neighbor significant, diagonal/vertical non-significant
- ZC_LUT_LH[STATE_H_L_R1] = 7;
- ZC_LUT_LH[STATE_H_R_R1] = 7;
- // - One horiz. significant, no vertical significant, one or more
- // diagonal significant
- for (i = 1; i < 16; i++)
- {
- ZC_LUT_LH[STATE_H_L_R1 | i] = 8;
- ZC_LUT_LH[STATE_H_R_R1 | i] = 8;
- }
- // - One horiz. significant, one or more vertical significant,
- // diagonal irrelevant
- for (i = 1; i < 4; i++)
- {
- for (j = 0; j < 16; j++)
- {
- ZC_LUT_LH[STATE_H_L_R1 | (i << 4) | j] = 9;
- ZC_LUT_LH[STATE_H_R_R1 | (i << 4) | j] = 9;
- }
- }
- // - Two horiz. significant, others irrelevant
- for (i = 0; i < 64; i++)
- {
- ZC_LUT_LH[STATE_H_L_R1 | STATE_H_R_R1 | i] = 10;
- }
-
- // HL
-
- // - No neighbors significant
- ZC_LUT_HL[0] = 2;
- // - No horizontal or vertical neighbors significant
- for (i = 1; i < 16; i++)
- {
- // Two or more diagonal coeffs significant
- ZC_LUT_HL[i] = 4;
- }
- for (i = 0; i < 4; i++)
- {
- // Only one diagonal coeff significant
- ZC_LUT_HL[1 << i] = 3;
- }
- // - No vertical significant, diagonal irrelevant
- for (i = 0; i < 16; i++)
- {
- // One horiz. significant
- ZC_LUT_HL[STATE_H_L_R1 | i] = 5;
- ZC_LUT_HL[STATE_H_R_R1 | i] = 5;
- // Two horiz. significant
- ZC_LUT_HL[STATE_H_L_R1 | STATE_H_R_R1 | i] = 6;
- }
- // - One vert. significant, diagonal/horizontal non-significant
- ZC_LUT_HL[STATE_V_U_R1] = 7;
- ZC_LUT_HL[STATE_V_D_R1] = 7;
- // - One vert. significant, horizontal non-significant, one or more
- // diag. significant
- for (i = 1; i < 16; i++)
- {
- ZC_LUT_HL[STATE_V_U_R1 | i] = 8;
- ZC_LUT_HL[STATE_V_D_R1 | i] = 8;
- }
- // - One vertical significant, one or more horizontal significant,
- // diagonal irrelevant
- for (i = 1; i < 4; i++)
- {
- for (j = 0; j < 16; j++)
- {
- ZC_LUT_HL[(i << 6) | STATE_V_U_R1 | j] = 9;
- ZC_LUT_HL[(i << 6) | STATE_V_D_R1 | j] = 9;
- }
- }
- // - Two vertical significant, others irrelevant
- for (i = 0; i < 4; i++)
- {
- for (j = 0; j < 16; j++)
- {
- ZC_LUT_HL[(i << 6) | STATE_V_U_R1 | STATE_V_D_R1 | j] = 10;
- }
- }
-
- // HH
- int[] twoBits = new int[] { 3, 5, 6, 9, 10, 12 }; // Figures (between 0 and 15)
- // countaning 2 and only 2 bits on in its binary representation.
-
- int[] oneBit = new int[] { 1, 2, 4, 8 }; // Figures (between 0 and 15)
- // countaning 1 and only 1 bit on in its binary representation.
-
- int[] twoLeast = new int[] { 3, 5, 6, 7, 9, 10, 11, 12, 13, 14, 15 }; // Figures
- // (between 0 and 15) countaining, at least, 2 bits on in its
- // binary representation.
-
- int[] threeLeast = new int[] { 7, 11, 13, 14, 15 }; // Figures
- // (between 0 and 15) countaining, at least, 3 bits on in its
- // binary representation.
-
- // - None significant
- ZC_LUT_HH[0] = 2;
-
- // - One horizontal+vertical significant, none diagonal
- for (i = 0; i < oneBit.Length; i++)
- ZC_LUT_HH[oneBit[i] << 4] = 3;
-
- // - Two or more horizontal+vertical significant, diagonal non-signif
- for (i = 0; i < twoLeast.Length; i++)
- ZC_LUT_HH[twoLeast[i] << 4] = 4;
-
- // - One diagonal significant, horiz./vert. non-significant
- for (i = 0; i < oneBit.Length; i++)
- ZC_LUT_HH[oneBit[i]] = 5;
-
- // - One diagonal significant, one horiz.+vert. significant
- for (i = 0; i < oneBit.Length; i++)
- for (j = 0; j < oneBit.Length; j++)
- ZC_LUT_HH[(oneBit[i] << 4) | oneBit[j]] = 6;
-
- // - One diag signif, two or more horiz+vert signif
- for (i = 0; i < twoLeast.Length; i++)
- for (j = 0; j < oneBit.Length; j++)
- ZC_LUT_HH[(twoLeast[i] << 4) | oneBit[j]] = 7;
-
- // - Two diagonal significant, none horiz+vert significant
- for (i = 0; i < twoBits.Length; i++)
- ZC_LUT_HH[twoBits[i]] = 8;
-
- // - Two diagonal significant, one or more horiz+vert significant
- for (j = 0; j < twoBits.Length; j++)
- for (i = 1; i < 16; i++)
- ZC_LUT_HH[(i << 4) | twoBits[j]] = 9;
-
- // - Three or more diagonal significant, horiz+vert irrelevant
- for (i = 0; i < 16; i++)
- for (j = 0; j < threeLeast.Length; j++)
- ZC_LUT_HH[(i << 4) | threeLeast[j]] = 10;
-
-
- // Initialize the SC lookup tables
-
- // Use an intermediate sign code lookup table that is similar to the
- // one in the VM text, in that it depends on the 'h' and 'v'
- // quantities. The index into this table is a 6 bit index, the top 3
- // bits are (h+1) and the low 3 bits (v+1).
- inter_sc_lut = new int[36];
- inter_sc_lut[(2 << 3) | 2] = 15;
- inter_sc_lut[(2 << 3) | 1] = 14;
- inter_sc_lut[(2 << 3) | 0] = 13;
- inter_sc_lut[(1 << 3) | 2] = 12;
- inter_sc_lut[(1 << 3) | 1] = 11;
- inter_sc_lut[(1 << 3) | 0] = 12 | INT_SIGN_BIT;
- inter_sc_lut[(0 << 3) | 2] = 13 | INT_SIGN_BIT;
- inter_sc_lut[(0 << 3) | 1] = 14 | INT_SIGN_BIT;
- inter_sc_lut[(0 << 3) | 0] = 15 | INT_SIGN_BIT;
-
- // Using the intermediate sign code lookup table create the final
- // one. The index into this table is a 9 bit index, the low 4 bits are
- // the significance of the 4 horizontal/vertical neighbors, while the
- // top 4 bits are the signs of those neighbors. The bit in the middle
- // is ignored. This index arrangement matches the state bits in the
- // 'state' array, thus direct addressing of the table can be done from
- // the sate information.
- for (i = 0; i < (1 << SC_LUT_BITS) - 1; i++)
- {
- ds = i & 0x01; // significance of down neighbor
- us = (i >> 1) & 0x01; // significance of up neighbor
- rs = (i >> 2) & 0x01; // significance of right neighbor
- ls = (i >> 3) & 0x01; // significance of left neighbor
- dsgn = (i >> 5) & 0x01; // sign of down neighbor
- usgn = (i >> 6) & 0x01; // sign of up neighbor
- rsgn = (i >> 7) & 0x01; // sign of right neighbor
- lsgn = (i >> 8) & 0x01; // sign of left neighbor
- // Calculate 'h' and 'v' as in VM text
- h = ls * (1 - 2 * lsgn) + rs * (1 - 2 * rsgn);
- h = (h >= -1) ? h : -1;
- h = (h <= 1) ? h : 1;
- v = us * (1 - 2 * usgn) + ds * (1 - 2 * dsgn);
- v = (v >= -1) ? v : -1;
- v = (v <= 1) ? v : 1;
- // Get context and sign predictor from 'inter_sc_lut'
- SC_LUT[i] = inter_sc_lut[(h + 1) << 3 | (v + 1)];
- }
- inter_sc_lut = null;
-
- // Initialize the MR lookup tables
-
- // None significant, prev MR off
- MR_LUT[0] = 16;
- // One or more significant, prev MR off
- for (i = 1; i < (1 << (MR_LUT_BITS - 1)); i++)
- {
- MR_LUT[i] = 17;
- }
- // Previous MR on, significance irrelevant
- for (; i < (1 << MR_LUT_BITS); i++)
- {
- MR_LUT[i] = 18;
- }
- }
- }
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/entropy/encoder/BitToByteOutput.cs b/CSJ2K/j2k/entropy/encoder/BitToByteOutput.cs
deleted file mode 100644
index 7c528f63..00000000
--- a/CSJ2K/j2k/entropy/encoder/BitToByteOutput.cs
+++ /dev/null
@@ -1,304 +0,0 @@
-/*
-* CVS identifier:
-*
-* $Id: BitToByteOutput.java,v 1.16 2001/10/17 16:56:59 grosbois Exp $
-*
-* Class: BitToByteOutput
-*
-* Description: Adapter to perform bit based output on a byte
-* based one.
-*
-*
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-* */
-namespace CSJ2K.j2k.entropy.encoder
-{
-
- /// This class provides an adapter to perform bit based output on byte based
- /// output objects that inherit from a 'ByteOutputBuffer' class. This class
- /// implements the bit stuffing policy needed for the 'selective arithmetic
- /// coding bypass' mode of the entropy coder. This class also delays the output
- /// of a trailing 0xFF, since they are synthetized be the decoder.
- ///
- ///
- class BitToByteOutput
- {
- /// Set the flag according to whether or not the predictable termination is
- /// requested.
- ///
- ///
- /// Whether or not predictable termination is requested.
- ///
- ///
- virtual internal bool PredTerm
- {
- set
- {
- this.isPredTerm = value;
- }
-
- }
-
- /// Whether or not predictable termination is requested. This value is
- /// important when the last byte before termination is an 0xFF
- ///
- private bool isPredTerm = false;
-
- /// The alternating sequence of 0's and 1's used for byte padding
- internal const int PAD_SEQ = 0x2A;
-
- /// Flag that indicates if an FF has been delayed
- internal bool delFF = false;
-
- /// The byte based output
- internal ByteOutputBuffer out_Renamed;
-
- /// The bit buffer
- internal int bbuf;
-
- /// The position of the next bit to put in the bit buffer. When it is 7
- /// the bit buffer 'bbuf' is empty. The value should always be between 7
- /// and 0 (i.e. if it gets to -1, the bit buffer should be immediately
- /// written to the byte output).
- ///
- internal int bpos = 7;
-
- /// The number of written bytes (excluding the bit buffer)
- internal int nb = 0;
-
- /// Instantiates a new 'BitToByteOutput' object that uses 'out' as the
- /// underlying byte based output.
- ///
- ///
- /// The underlying byte based output
- ///
- ///
- internal BitToByteOutput(ByteOutputBuffer out_Renamed)
- {
- this.out_Renamed = out_Renamed;
- }
-
- /// Writes to the bit stream the symbols contained in the 'symbuf'
- /// buffer. The least significant bit of each element in 'symbuf'is
- /// written.
- ///
- ///
- /// The symbols to write
- ///
- ///
- /// The number of symbols in symbuf
- ///
- ///
- internal void writeBits(int[] symbuf, int nsym)
- {
- int i;
- int bbuf, bpos;
- bbuf = this.bbuf;
- bpos = this.bpos;
- // Write symbol by symbol to bit buffer
- for (i = 0; i < nsym; i++)
- {
- bbuf |= (symbuf[i] & 0x01) << (bpos--);
- if (bpos < 0)
- {
- // Bit buffer is full, write it
- if (bbuf != 0xFF)
- {
- // No bit-stuffing needed
- if (delFF)
- {
- // Output delayed 0xFF if any
- out_Renamed.write(0xFF);
- nb++;
- delFF = false;
- }
- out_Renamed.write(bbuf);
- nb++;
- bpos = 7;
- }
- else
- {
- // We need to do bit stuffing on next byte
- delFF = true;
- bpos = 6; // One less bit in next byte
- }
- bbuf = 0;
- }
- }
- this.bbuf = bbuf;
- this.bpos = bpos;
- }
-
- /// Write a bit to the output. The least significant bit of 'bit' is
- /// written to the output.
- ///
- ///
- ///
- ///
- internal void writeBit(int bit)
- {
- bbuf |= (bit & 0x01) << (bpos--);
- if (bpos < 0)
- {
- if (bbuf != 0xFF)
- {
- // No bit-stuffing needed
- if (delFF)
- {
- // Output delayed 0xFF if any
- out_Renamed.write(0xFF);
- nb++;
- delFF = false;
- }
- // Output the bit buffer
- out_Renamed.write(bbuf);
- nb++;
- bpos = 7;
- }
- else
- {
- // We need to do bit stuffing on next byte
- delFF = true;
- bpos = 6; // One less bit in next byte
- }
- bbuf = 0;
- }
- }
-
- /// Writes the contents of the bit buffer and byte aligns the output by
- /// filling bits with an alternating sequence of 0's and 1's.
- ///
- ///
- internal virtual void flush()
- {
- if (delFF)
- {
- // There was a bit stuffing
- if (bpos != 6)
- {
- // Bit buffer is not empty
- // Output delayed 0xFF
- out_Renamed.write(0xFF);
- nb++;
- delFF = false;
- // Pad to byte boundary with an alternating sequence of 0's
- // and 1's.
- bbuf |= (SupportClass.URShift(PAD_SEQ, (6 - bpos)));
- // Output the bit buffer
- out_Renamed.write(bbuf);
- nb++;
- bpos = 7;
- bbuf = 0;
- }
- else if (isPredTerm)
- {
- out_Renamed.write(0xFF);
- nb++;
- out_Renamed.write(0x2A);
- nb++;
- bpos = 7;
- bbuf = 0;
- delFF = false;
- }
- }
- else
- {
- // There was no bit stuffing
- if (bpos != 7)
- {
- // Bit buffer is not empty
- // Pad to byte boundary with an alternating sequence of 0's and
- // 1's.
- bbuf |= (SupportClass.URShift(PAD_SEQ, (6 - bpos)));
- // Output the bit buffer (bbuf can not be 0xFF)
- out_Renamed.write(bbuf);
- nb++;
- bpos = 7;
- bbuf = 0;
- }
- }
- }
-
- /// Terminates the bit stream by calling 'flush()' and then
- /// 'reset()'. Finally, it returns the number of bytes effectively written.
- ///
- ///
- /// The number of bytes effectively written.
- ///
- ///
- public virtual int terminate()
- {
- flush();
- int savedNb = nb;
- reset();
- return savedNb;
- }
-
- /// Resets the bit buffer to empty, without writing anything to the
- /// underlying byte output, and resets the byte count. The underlying byte
- /// output is NOT reset.
- ///
- ///
- internal virtual void reset()
- {
- delFF = false;
- bpos = 7;
- bbuf = 0;
- nb = 0;
- }
-
- /// Returns the length, in bytes, of the output bit stream as written by
- /// this object. If the output bit stream does not have an integer number
- /// of bytes in length then it is rounded to the next integer.
- ///
- ///
- /// The length, in bytes, of the output bit stream.
- ///
- ///
- internal virtual int length()
- {
- if (delFF)
- {
- // If bit buffer is empty we just need 'nb' bytes. If not we need
- // the delayed FF and the padded bit buffer.
- return nb + 2;
- }
- else
- {
- // If the bit buffer is empty, we just need 'nb' bytes. If not, we
- // add length of the padded bit buffer
- return nb + ((bpos == 7) ? 0 : 1);
- }
- }
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/entropy/encoder/ByteOutputBuffer.cs b/CSJ2K/j2k/entropy/encoder/ByteOutputBuffer.cs
deleted file mode 100644
index 67098147..00000000
--- a/CSJ2K/j2k/entropy/encoder/ByteOutputBuffer.cs
+++ /dev/null
@@ -1,184 +0,0 @@
-/*
-* CVS identifier:
-*
-* $Id: ByteOutputBuffer.java,v 1.10 2001/05/17 15:21:16 grosbois Exp $
-*
-* Class: ByteOutputBuffer
-*
-* Description: Provides buffering for byte based output, similar
-* to the standard class ByteArrayOutputStream
-*
-* the old jj2000.j2k.io.ByteArrayOutput class by
-* Diego SANTA CRUZ, Apr-26-1999
-*
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-* */
-using System;
-namespace CSJ2K.j2k.entropy.encoder
-{
-
- /// This class provides a buffering output stream similar to
- /// ByteArrayOutputStream, with some additional methods.
- ///
- /// Once an array has been written to an output stream or to a byte array,
- /// the object can be reused as a new stream if the reset() method is
- /// called.
- ///
- /// Unlike the ByteArrayOutputStream class, this class is not thread
- /// safe.
- ///
- ///
- ///
- ///
- ///
- public class ByteOutputBuffer
- {
-
- /// The buffer where the data is stored
- internal byte[] buf;
-
- /// The number of valid bytes in the buffer
- internal int count;
-
- /// The buffer increase size
- public const int BUF_INC = 512;
-
- /// The default initial buffer size
- public const int BUF_DEF_LEN = 256;
-
- /// Creates a new byte array output stream. The buffer capacity is
- /// initially BUF_DEF_LEN bytes, though its size increases if necessary.
- ///
- ///
- public ByteOutputBuffer()
- {
- buf = new byte[BUF_DEF_LEN];
- }
-
- /// Creates a new byte array output stream, with a buffer capacity of the
- /// specified size, in bytes.
- ///
- ///
- /// the initial size.
- ///
- ///
- public ByteOutputBuffer(int size)
- {
- buf = new byte[size];
- }
-
- /// Writes the specified byte to this byte array output stream. The
- /// functionality provided by this implementation is the same as for the
- /// one in the superclass, however this method is not synchronized and
- /// therefore not safe thread, but faster.
- ///
- ///
- /// The byte to write
- ///
- ///
- public void write(int b)
- {
- if (count == buf.Length)
- {
- // Resize buffer
- byte[] tmpbuf = buf;
- buf = new byte[buf.Length + BUF_INC];
- Array.Copy(tmpbuf, 0, buf, 0, count);
- }
- buf[count++] = (byte)b;
- }
-
- /// Copies the specified part of the stream to the 'outbuf' byte array.
- ///
- ///
- /// The index of the first element in the stream to copy.
- ///
- ///
- /// The number of elements of the array to copy
- ///
- ///
- /// The destination array
- ///
- ///
- /// The index of the first element in 'outbuf' where to write
- /// the data.
- ///
- ///
- public virtual void toByteArray(int off, int len, byte[] outbuf, int outoff)
- {
- // Copy the data
- Array.Copy(buf, off, outbuf, outoff, len);
- }
-
- /// Returns the number of valid bytes in the output buffer (count class
- /// variable).
- ///
- ///
- /// The number of bytes written to the buffer
- ///
- ///
- public virtual int size()
- {
- return count;
- }
-
- /// Discards all the buffered data, by resetting the counter of written
- /// bytes to 0.
- ///
- ///
- public virtual void reset()
- {
- count = 0;
- }
-
- /// Returns the byte buffered at the given position in the buffer. The
- /// position in the buffer is the index of the 'write()' method call after
- /// the last call to 'reset()'.
- ///
- ///
- /// The position of the byte to return
- ///
- ///
- /// The value (betweeb 0-255) of the byte at position 'pos'.
- ///
- ///
- public virtual int getByte(int pos)
- {
- if (pos >= count)
- {
- throw new System.ArgumentException();
- }
- return buf[pos] & 0xFF;
- }
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/entropy/encoder/CBlkRateDistStats.cs b/CSJ2K/j2k/entropy/encoder/CBlkRateDistStats.cs
deleted file mode 100644
index 91f27df5..00000000
--- a/CSJ2K/j2k/entropy/encoder/CBlkRateDistStats.cs
+++ /dev/null
@@ -1,389 +0,0 @@
-/*
-* CVS identifier:
-*
-* $Id: CBlkRateDistStats.java,v 1.11 2001/09/14 09:23:51 grosbois Exp $
-*
-* Class: CBlkRateDistStats
-*
-* Description: The coded (compressed) code-block with
-* rate-distortion statistics.
-*
-*
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-* */
-using CSJ2K.j2k.wavelet.analysis;
-using System;
-namespace CSJ2K.j2k.entropy.encoder
-{
-
- /// This class stores coded (compressed) code-blocks with their associated
- /// rate-distortion statistics. This object should always contain all the
- /// compressed data of the code-block. It is applicable to the encoder engine
- /// only. Some data of the coded-block is stored in the super class, see
- /// CodedCBlk.
- ///
- /// The rate-distortion statistics (i.e. R-D slope) is stored for valid
- /// points only. The set of valid points is determined by the entropy coder
- /// engine itself. Normally they are selected so as to lye in a convex hull,
- /// which can be achived by using the 'selectConvexHull' method of this class,
- /// but some other strategies might be employed.
- ///
- /// The rate (in bytes) for each truncation point (valid or not) is stored
- /// in the 'truncRates' array. The rate of a truncation point is the total
- /// number of bytes in 'data' (see super class) that have to be decoded to
- /// reach the truncation point.
- ///
- /// The slope (reduction of distortion divided by the increase in rate) at
- /// each of the valid truncation points is stored in 'truncSlopes'.
- ///
- /// The index of each valid truncation point is stored in 'truncIdxs'. The
- /// index should be interpreted in the following way: a valid truncation point
- /// at position 'n' has the index 'truncIdxs[n]', the rate
- /// 'truncRates[truncIdxs[n]]' and the slope 'truncSlopes[n]'. The arrays
- /// 'truncIdxs' and 'truncRates' have at least 'nVldTrunc' elements. The
- /// 'truncRates' array has at least 'nTotTrunc' elements.
- ///
- /// In addition the 'isTermPass' array contains a flag for each truncation
- /// point (valid and non-valid ones) that tells if the pass is terminated or
- /// not. If this variable is null then it means that no pass is terminated,
- /// except the last one which always is.
- ///
- /// The compressed data is stored in the 'data' member variable of the super
- /// class.
- ///
- ///
- ///
- ///
- ///
- public class CBlkRateDistStats : CodedCBlk
- {
-
- /// The subband to which the code-block belongs
- public SubbandAn sb;
-
- /// The total number of truncation points
- public int nTotTrunc;
-
- /// The number of valid truncation points
- public int nVldTrunc;
-
- /// The rate (in bytes) for each truncation point (valid and non-valid
- /// ones)
- ///
- public int[] truncRates;
-
- /// The distortion for each truncation point (valid and non-valid ones)
- public double[] truncDists;
-
- /// The negative of the rate-distortion slope for each valid truncation
- /// point
- ///
- public float[] truncSlopes;
-
- /// The indices of the valid truncation points, in increasing order.
- public int[] truncIdxs;
-
- /// Array of flags indicating terminated passes (valid or non-valid
- /// truncation points).
- ///
- public bool[] isTermPass;
-
- /// The number of ROI coefficients in the code-block
- public int nROIcoeff = 0;
-
- /// Number of ROI coding passes
- public int nROIcp = 0;
-
- /// Creates a new CBlkRateDistStats object without allocating any space for
- /// 'truncRates', 'truncSlopes', 'truncDists' and 'truncIdxs' or 'data'.
- ///
- ///
- public CBlkRateDistStats()
- {
- }
-
- /// Creates a new CBlkRateDistStats object and initializes the valid
- /// truncation points, their rates and their slopes, from the 'rates' and
- /// 'dist' arrays. The 'rates', 'dist' and 'termp' arrays must contain the
- /// rate (in bytes), the reduction in distortion (from nothing coded) and
- /// the flag indicating if termination is used, respectively, for each
- /// truncation point.
- ///
- /// The valid truncation points are selected by taking them as lying on
- /// a convex hull. This is done by calling the method
- /// selectConvexHull().
- ///
- /// Note that the arrays 'rates' and 'termp' are copied, not referenced,
- /// so they can be modified after a call to this constructor.
- ///
- ///
- /// The horizontal index of the code-block, within the subband.
- ///
- ///
- /// The vertical index of the code-block, within the subband.
- ///
- ///
- /// The number of skipped most significant bit-planes for
- /// this code-block.
- ///
- ///
- /// The compressed data. This array is referenced by this
- /// object so it should not be modified after.
- ///
- ///
- /// The rates (in bytes) for each truncation point in the
- /// compressed data. This array is modified by the method but no reference
- /// is kept to it.
- ///
- ///
- /// The reduction in distortion (with respect to no
- /// information coded) for each truncation point. This array is modified by
- /// the method but no reference is kept to it.
- ///
- ///
- /// An array of boolean flags indicating, for each pass, if a
- /// pass is terminated or not (true if terminated). If null then it is
- /// assumed that no pass is terminated except the last one which always is.
- ///
- ///
- /// The number of truncation points contained in 'rates', 'dist'
- /// and 'termp'.
- ///
- ///
- /// If false the convex hull is constructed as for lossy
- /// coding. If true it is constructed as for lossless coding, in which case
- /// it is ensured that all bit-planes are sent (i.e. the last truncation
- /// point is always included).
- ///
- ///
- public CBlkRateDistStats(int m, int n, int skipMSBP, byte[] data, int[] rates, double[] dists, bool[] termp, int np, bool inclast) : base(m, n, skipMSBP, data)
- {
- selectConvexHull(rates, dists, termp, np, inclast);
- }
-
- /// Compute the rate-distorsion slopes and selects those that lie in a
- /// convex hull. It will compute the slopes, select the ones that form the
- /// convex hull and initialize the 'truncIdxs' and 'truncSlopes' arrays, as
- /// well as 'nVldTrunc', with the selected truncation points. It will also
- /// initialize 'truncRates' and 'isTermPass' arrays, as well as
- /// 'nTotTrunc', with all the truncation points (selected or not).
- ///
- /// Note that the arrays 'rates' and 'termp' are copied, not
- /// referenced, so they can be modified after a call to this method.
- ///
- ///
- /// The rates (in bytes) for each truncation point in the
- /// compressed data. This array is modified by the method.
- ///
- ///
- /// The reduction in distortion (with respect to no
- /// information coded) for each truncation point. This array is modified by
- /// the method.
- ///
- ///
- /// An array of boolean flags indicating, for each pass, if a
- /// pass is terminated or not (true if terminated). If null then it is
- /// assumed that no pass is terminated except the last one which always is.
- ///
- ///
- /// The number of truncation points contained in 'rates', 'dist'
- /// and 'termp'.
- ///
- ///
- /// If false the convex hull is constructed as for lossy
- /// coding. If true it is constructed as for lossless coding, in which case
- /// it is ensured that all bit-planes are sent (i.e. the last truncation
- /// point is always included).
- ///
- ///
- public virtual void selectConvexHull(int[] rates, double[] dists, bool[] termp, int n, bool inclast)
- {
- int first_pnt; // The first point containing some coded data
- int p; // last selected point
- int k; // current point
- int i; // current valid point
- int npnt; // number of selected (i.e. valid) points
- int delta_rate; // Rate difference
- double delta_dist; // Distortion difference
- float k_slope; // R-D slope for the current point
- float p_slope; // R-D slope for the last selected point
- //int ll_rate; // Rate for "lossless" coding (i.e. all coded info)
-
- // Convention: when a negative value is stored in 'rates' it meas an
- // invalid point. The absolute value is always the rate for that point.
-
- // Look for first point with some coded info (rate not 0)
- first_pnt = 0;
- while (first_pnt < n && rates[first_pnt] <= 0)
- {
- first_pnt++;
- }
-
- // Select the valid points
- npnt = n - first_pnt;
- p_slope = 0f; // To keep compiler happy
- //UPGRADE_NOTE: Label 'ploop' was moved. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1014'"
- do
- {
- p = -1;
- for (k = first_pnt; k < n; k++)
- {
- if (rates[k] < 0)
- {
- // Already invalidated point
- continue;
- }
- // Calculate decrease in distortion and rate
- if (p >= 0)
- {
- delta_rate = rates[k] - rates[p];
- delta_dist = dists[k] - dists[p];
- }
- else
- {
- // This is with respect to no info coded
- delta_rate = rates[k];
- delta_dist = dists[k];
- }
- // If exactly same distortion don't eliminate if the rates are
- // equal, otherwise it can lead to infinite slope in lossless
- // coding.
- if (delta_dist < 0f || (delta_dist == 0f && delta_rate > 0))
- {
- // This point increases distortion => invalidate
- rates[k] = -rates[k];
- npnt--;
- continue; // Goto next point
- }
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- k_slope = (float)(delta_dist / delta_rate);
- // Check that there is a decrease in distortion, slope is not
- // infinite (i.e. delta_dist is not 0) and slope is
- // decreasing.
- if (p >= 0 && (delta_rate <= 0 || k_slope >= p_slope))
- {
- // Last point was not good
- rates[p] = -rates[p]; // Remove p from valid points
- npnt--;
- //UPGRADE_NOTE: Labeled continue statement was changed to a goto statement. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1015'"
- goto ploop; // Restart from the first one
- }
- else
- {
- p_slope = k_slope;
- p = k;
- }
- }
- // If we get to last point we are done
- break;
- //UPGRADE_NOTE: Label 'ploop' was moved. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1014'"
-
- ploop:;
- }
- while (true); // We end the loop with the break statement
-
- // If in lossless mode make sure we don't eliminate any last
- // bit-planes from being sent.
- if (inclast && n > 0 && rates[n - 1] < 0)
- {
- rates[n - 1] = -rates[n - 1];
- // This rate can never be equal to any previous selected rate,
- // given the selection algorithm above, so no problem arises of
- // infinite slopes.
- npnt++;
- }
-
- // Initialize the arrays of this object
- nTotTrunc = n;
- nVldTrunc = npnt;
- truncRates = new int[n];
- truncDists = new double[n];
- truncSlopes = new float[npnt];
- truncIdxs = new int[npnt];
- if (termp != null)
- {
- isTermPass = new bool[n];
- Array.Copy(termp, 0, isTermPass, 0, n);
- }
- else
- {
- isTermPass = null;
- }
- Array.Copy(rates, 0, truncRates, 0, n);
- for (k = first_pnt, p = -1, i = 0; k < n; k++)
- {
- if (rates[k] > 0)
- {
- // A valid point
- truncDists[k] = dists[k];
- if (p < 0)
- {
- // Only arrives at first valid point
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- truncSlopes[i] = (float)(dists[k] / rates[k]);
- }
- else
- {
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- truncSlopes[i] = (float)((dists[k] - dists[p]) / (rates[k] - rates[p]));
- }
- truncIdxs[i] = k;
- i++;
- p = k;
- }
- else
- {
- truncDists[k] = -1;
- truncRates[k] = -truncRates[k];
- }
- }
- }
-
- /// Returns the contents of the object in a string. This is used for
- /// debugging.
- ///
- ///
- /// A string with the contents of the object
- ///
- ///
- public override System.String ToString()
- {
- System.String str = base.ToString() + "\n nVldTrunc=" + nVldTrunc + ", nTotTrunc=" + nTotTrunc + ", num. ROI" + " coeff=" + nROIcoeff + ", num. ROI coding passes=" + nROIcp + ", sb=" + sb.sbandIdx;
- // str += "\n\ttruncRates:\n";
- // for(int i=0; i This interface defines a source of entropy coded data and methods to
- /// transfer it in a code-block by code-block basis. In each call to
- /// 'getNextCodeBlock()' a new coded code-block is returned. The code-block are
- /// retruned in no specific-order.
- ///
- /// This interface is the source of data for the rate allocator. See the
- /// 'PostCompRateAllocator' class.
- ///
- /// For each coded-code-block the entropy-coded data is returned along with
- /// the rate-distortion statistics in a 'CBlkRateDistStats' object.
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- public interface CodedCBlkDataSrcEnc : ForwWTDataProps
- {
-
- /// Returns the next coded code-block in the current tile for the specified
- /// component, as a copy (see below). The order in which code-blocks are
- /// returned is not specified. However each code-block is returned only
- /// once and all code-blocks will be returned if the method is called 'N'
- /// times, where 'N' is the number of code-blocks in the tile. After all
- /// the code-blocks have been returned for the current tile calls to this
- /// method will return 'null'.
- ///
- /// When changing the current tile (through 'setTile()' or 'nextTile()')
- /// this method will always return the first code-block, as if this method
- /// was never called before for the new current tile.
- ///
- /// The data returned by this method is always a copy of the internal
- /// data of this object, if any, and it can be modified "in place" without
- /// any problems after being returned.
- ///
- ///
- /// The component for which to return the next code-block.
- ///
- ///
- /// If non-null this object might be used in returning the coded
- /// code-block in this or any subsequent call to this method. If null a new
- /// one is created and returned. If the 'data' array of 'cbb' is not null
- /// it may be reused to return the compressed data.
- ///
- ///
- /// The next coded code-block in the current tile for component
- /// 'c', or null if all code-blocks for the current tile have been
- /// returned.
- ///
- ///
- ///
- ///
- ///
- CBlkRateDistStats getNextCodeBlock(int c, CBlkRateDistStats ccb);
-
- /// Returns the width of a packet for the specified tile-component and
- /// resolution level.
- ///
- ///
- /// The tile
- ///
- ///
- /// The component
- ///
- ///
- /// The resolution level
- ///
- ///
- /// The width of a packet for the specified tile- component and
- /// resolution level.
- ///
- ///
- int getPPX(int t, int c, int r);
-
- /// Returns the height of a packet for the specified tile-component and
- /// resolution level.
- ///
- ///
- /// The tile
- ///
- ///
- /// The component
- ///
- ///
- /// The resolution level
- ///
- ///
- /// The height of a packet for the specified tile- component and
- /// resolution level.
- ///
- ///
- int getPPY(int t, int c, int r);
-
- /// Returns true if the precinct partition is used for the specified
- /// component and tile, returns false otherwise
- ///
- ///
- /// The component
- ///
- ///
- /// The tile
- ///
- ///
- bool precinctPartitionUsed(int c, int t);
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/entropy/encoder/EBCOTLayer.cs b/CSJ2K/j2k/entropy/encoder/EBCOTLayer.cs
deleted file mode 100644
index 59ca8076..00000000
--- a/CSJ2K/j2k/entropy/encoder/EBCOTLayer.cs
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
-* CVS identifier:
-*
-* $Id: EBCOTLayer.java,v 1.9 2001/05/16 09:40:58 grosbois Exp $
-*
-* Class: EBCOTLayer
-*
-* Description: Storage for layer information,
-* used by EBCOTRateAllocator
-*
-* class that was in EBCOTRateAllocator.
-*
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-* */
-namespace CSJ2K.j2k.entropy.encoder
-{
-
- /// This class holds information about each layer that is to be, or has already
- /// been, allocated . It is used in the rate-allocation process to keep the
- /// necessary layer information. It is used by EBCOTRateAllocator.
- ///
- ///
- ///
- ///
- ///
- class EBCOTLayer
- {
- /// This is the maximum number of bytes that should be allocated for this
- /// and previous layers. This is actually the target length for the layer.
- ///
- ///
- internal int maxBytes;
-
- /// The actual number of bytes which are consumed by the the current and
- /// any previous layers. This is the result from a simulation when the
- /// threshold for the layer has been set.
- ///
- ///
- internal int actualBytes;
-
- /// If true the `maxBytes' value is the hard maximum and the threshold is
- /// determined iteratively. If false the `maxBytes' value is a target
- /// bitrate and the threshold is estimated from summary information
- /// accumulated during block coding.
- ///
- ///
- internal bool optimize;
-
- /// The rate-distortion threshold associated with the bit-stream
- /// layer. When set the layer includes data up to the truncation points
- /// that have a slope no smaller than 'rdThreshold'.
- ///
- ///
- internal float rdThreshold;
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/entropy/encoder/EBCOTRateAllocator.cs b/CSJ2K/j2k/entropy/encoder/EBCOTRateAllocator.cs
deleted file mode 100644
index 58964750..00000000
--- a/CSJ2K/j2k/entropy/encoder/EBCOTRateAllocator.cs
+++ /dev/null
@@ -1,2399 +0,0 @@
-/*
-* CVS identifier:
-*
-* $Id: EBCOTRateAllocator.java,v 1.97 2002/05/22 14:59:44 grosbois Exp $
-*
-* Class: EBCOTRateAllocator
-*
-* Description: Generic interface for post-compression
-* rate allocator.
-*
-*
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-* */
-using CSJ2K.j2k.codestream;
-using CSJ2K.j2k.codestream.writer;
-using CSJ2K.j2k.encoder;
-using CSJ2K.j2k.image;
-using CSJ2K.j2k.util;
-using CSJ2K.j2k.wavelet.analysis;
-namespace CSJ2K.j2k.entropy.encoder
-{
-
- /// This implements the EBCOT post compression rate allocation algorithm. This
- /// algorithm finds the most suitable truncation points for the set of
- /// code-blocks, for each layer target bitrate. It works by first collecting
- /// the rate distortion info from all code-blocks, in all tiles and all
- /// components, and then running the rate-allocation on the whole image at
- /// once, for each layer.
- ///
- /// This implementation also provides some timing features. They can be
- /// enabled by setting the 'DO_TIMING' constant of this class to true and
- /// recompiling. The timing uses the 'System.currentTimeMillis()' Java API
- /// call, which returns wall clock time, not the actual CPU time used. The
- /// timing results will be printed on the message output. Since the times
- /// reported are wall clock times and not CPU usage times they can not be added
- /// to find the total used time (i.e. some time might be counted in several
- /// places). When timing is disabled ('DO_TIMING' is false) there is no penalty
- /// if the compiler performs some basic optimizations. Even if not the penalty
- /// should be negligeable.
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- public class EBCOTRateAllocator : PostCompRateAllocator
- {
-
- /// Whether to collect timing information or not: false. Used as a compile
- /// time directive.
- ///
-
-#if DO_TIMING
- /// The wall time for the initialization.
- //private long initTime;
-
- /// The wall time for the building of layers.
- //private long buildTime;
-
- /// The wall time for the writing of layers.
- //private long writeTime;
-#endif
-
- /// 5D Array containing all the coded code-blocks:
- ///
- ///
- /// - 1st index: tile index
- /// - 2nd index: component index
- /// - 3rd index: resolution level index
- /// - 4th index: subband index
- /// - 5th index: code-block index
- ///
- ///
- ///
- private CBlkRateDistStats[][][][][] cblks;
-
- /// 6D Array containing the indices of the truncation points. It actually
- /// contains the index of the element in CBlkRateDistStats.truncIdxs that
- /// gives the real truncation point index.
- ///
- ///
- /// - 1st index: tile index
- /// - 2nd index: layer index
- /// - 3rd index: component index
- /// - 4th index: resolution level index
- /// - 5th index: subband index
- /// - 6th index: code-block index
- ///
- ///
- ///
- private int[][][][][][] truncIdxs;
-
- /// Number of precincts in each resolution level:
- ///
- ///
- /// - 1st dim: tile index.
- /// - 2nd dim: component index.
- /// - 3nd dim: resolution level index.
- ///
- ///
- ///
- private Coord[][][] numPrec;
-
- /// Array containing the layers information.
- private EBCOTLayer[] layers;
-
- /// The log of 2, natural base
- //UPGRADE_NOTE: Final was removed from the declaration of 'LOG2 '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- private static readonly double LOG2 = System.Math.Log(2);
-
- /// The normalization offset for the R-D summary table
- private const int RD_SUMMARY_OFF = 24;
-
- /// The size of the summary table
- private const int RD_SUMMARY_SIZE = 64;
-
- /// The relative precision for float data. This is the relative tolerance
- /// up to which the layer slope thresholds are calculated.
- ///
- private const float FLOAT_REL_PRECISION = 1e-4f;
-
- /// The precision for float data type, in an absolute sense. Two float
- /// numbers are considered "equal" if they are within this precision.
- ///
- private const float FLOAT_ABS_PRECISION = 1e-10f;
-
- /// Minimum average size of a packet. If layer has less bytes than the
- /// this constant multiplied by number of packets in the layer, then the
- /// layer is skipped.
- ///
- private const int MIN_AVG_PACKET_SZ = 32;
-
- /// The R-D summary information collected from the coding of all
- /// code-blocks. For each entry it contains the accumulated length of all
- /// truncation points that have a slope not less than
- /// '2*(k-RD_SUMMARY_OFF)', where 'k' is the entry index.
- ///
- /// Therefore, the length at entry 'k' is the total number of bytes of
- /// code-block data that would be obtained if the truncation slope was
- /// chosen as '2*(k-RD_SUMMARY_OFF)', without counting the overhead
- /// associated with the packet heads.
- ///
- /// This summary is used to estimate the relation of the R-D slope to
- /// coded length, and to obtain absolute minimums on the slope given a
- /// length.
- ///
- private int[] RDSlopesRates;
-
- /// Packet encoder.
- private PktEncoder pktEnc;
-
- /// The layer specifications
- private LayersInfo lyrSpec;
-
- /// The maximum slope accross all code-blocks and truncation points.
- private float maxSlope;
-
- /// The minimum slope accross all code-blocks and truncation points.
- private float minSlope;
-
- /// Initializes the EBCOT rate allocator of entropy coded data. The layout
- /// of layers, and their bitrate constraints, is specified by the 'lyrs'
- /// parameter.
- ///
- ///
- /// The source of entropy coded data.
- ///
- ///
- /// The layers layout specification.
- ///
- ///
- /// The bit stream writer.
- ///
- ///
- ///
- ///
- ///
- public EBCOTRateAllocator(CodedCBlkDataSrcEnc src, LayersInfo lyrs, CodestreamWriter writer, EncoderSpecs encSpec, ParameterList pl) : base(src, lyrs.TotNumLayers, writer, encSpec)
- {
-
- int minsbi, maxsbi;
- int i;
- SubbandAn sb, sb2;
- Coord ncblks = null;
-
- // If we do timing create necessary structures
-#if DO_TIMING
- // If we are timing make sure that 'finalize' gets called.
- //UPGRADE_ISSUE: Method 'java.lang.System.runFinalizersOnExit' was not converted. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1000_javalangSystem'"
- // CONVERSION PROBLEM?
- //System_Renamed.runFinalizersOnExit(true);
- // The System.runFinalizersOnExit() method is deprecated in Java
- // 1.2 since it can cause a deadlock in some cases. However, here
- // we use it only for profiling purposes and is disabled in
- // production code.
- initTime = 0L;
- buildTime = 0L;
- writeTime = 0L;
-#endif
-
- // Save the layer specs
- lyrSpec = lyrs;
-
- //Initialize the size of the RD slope rates array
- RDSlopesRates = new int[RD_SUMMARY_SIZE];
-
- //Get number of tiles, components
- int nt = src.getNumTiles();
- int nc = NumComps;
-
- //Allocate the coded code-blocks and truncation points indexes arrays
- cblks = new CBlkRateDistStats[nt][][][][];
- for (int i2 = 0; i2 < nt; i2++)
- {
- cblks[i2] = new CBlkRateDistStats[nc][][][];
- }
- truncIdxs = new int[nt][][][][][];
- for (int i3 = 0; i3 < nt; i3++)
- {
- truncIdxs[i3] = new int[num_Layers][][][][];
- for (int i4 = 0; i4 < num_Layers; i4++)
- {
- truncIdxs[i3][i4] = new int[nc][][][];
- }
- }
-
- int cblkPerSubband; // Number of code-blocks per subband
- int mrl; // Number of resolution levels
- int l; // layer index
- int s; //subband index
-
- // Used to compute the maximum number of precincts for each resolution
- // level
- int tx0, ty0, tx1, ty1; // Current tile position in the reference grid
- int tcx0, tcy0, tcx1, tcy1; // Current tile position in the domain of
- // the image component
- int trx0, try0, trx1, try1; // Current tile position in the reduced
- // resolution image domain
- int xrsiz, yrsiz; // Component sub-sampling factors
- Coord tileI = null;
- Coord nTiles = null;
- int xsiz, ysiz, x0siz, y0siz;
- int xt0siz, yt0siz;
- int xtsiz, ytsiz;
-
- int cb0x = src.CbULX;
- int cb0y = src.CbULY;
-
- src.setTile(0, 0);
- for (int t = 0; t < nt; t++)
- {
- // Loop on tiles
- nTiles = src.getNumTiles(nTiles);
- tileI = src.getTile(tileI);
- x0siz = ImgULX;
- y0siz = ImgULY;
- xsiz = x0siz + ImgWidth;
- ysiz = y0siz + ImgHeight;
- xt0siz = src.TilePartULX;
- yt0siz = src.TilePartULY;
- xtsiz = src.NomTileWidth;
- ytsiz = src.NomTileHeight;
-
- // Tile's coordinates on the reference grid
- tx0 = (tileI.x == 0) ? x0siz : xt0siz + tileI.x * xtsiz;
- ty0 = (tileI.y == 0) ? y0siz : yt0siz + tileI.y * ytsiz;
- tx1 = (tileI.x != nTiles.x - 1) ? xt0siz + (tileI.x + 1) * xtsiz : xsiz;
- ty1 = (tileI.y != nTiles.y - 1) ? yt0siz + (tileI.y + 1) * ytsiz : ysiz;
-
- for (int c = 0; c < nc; c++)
- {
- // loop on components
-
- //Get the number of resolution levels
- sb = src.getAnSubbandTree(t, c);
- mrl = sb.resLvl + 1;
-
- // Initialize maximum number of precincts per resolution array
- if (numPrec == null)
- {
- Coord[][][] tmpArray = new Coord[nt][][];
- for (int i5 = 0; i5 < nt; i5++)
- {
- tmpArray[i5] = new Coord[nc][];
- }
- numPrec = tmpArray;
- }
- if (numPrec[t][c] == null)
- {
- numPrec[t][c] = new Coord[mrl];
- }
-
- // Subsampling factors
- xrsiz = src.getCompSubsX(c);
- yrsiz = src.getCompSubsY(c);
-
- // Tile's coordinates in the image component domain
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- tcx0 = (int)System.Math.Ceiling(tx0 / (double)(xrsiz));
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- tcy0 = (int)System.Math.Ceiling(ty0 / (double)(yrsiz));
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- tcx1 = (int)System.Math.Ceiling(tx1 / (double)(xrsiz));
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- tcy1 = (int)System.Math.Ceiling(ty1 / (double)(yrsiz));
-
- cblks[t][c] = new CBlkRateDistStats[mrl][][];
-
- for (l = 0; l < num_Layers; l++)
- {
- truncIdxs[t][l][c] = new int[mrl][][];
- }
-
- for (int r = 0; r < mrl; r++)
- {
- // loop on resolution levels
-
- // Tile's coordinates in the reduced resolution image
- // domain
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- trx0 = (int)System.Math.Ceiling(tcx0 / (double)(1 << (mrl - 1 - r)));
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- try0 = (int)System.Math.Ceiling(tcy0 / (double)(1 << (mrl - 1 - r)));
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- trx1 = (int)System.Math.Ceiling(tcx1 / (double)(1 << (mrl - 1 - r)));
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- try1 = (int)System.Math.Ceiling(tcy1 / (double)(1 << (mrl - 1 - r)));
-
- // Calculate the maximum number of precincts for each
- // resolution level taking into account tile specific
- // options.
- double twoppx = (double)encSpec.pss.getPPX(t, c, r);
- double twoppy = (double)encSpec.pss.getPPY(t, c, r);
- numPrec[t][c][r] = new Coord();
- if (trx1 > trx0)
- {
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- numPrec[t][c][r].x = (int)System.Math.Ceiling((trx1 - cb0x) / twoppx) - (int)System.Math.Floor((trx0 - cb0x) / twoppx);
- }
- else
- {
- numPrec[t][c][r].x = 0;
- }
- if (try1 > try0)
- {
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- numPrec[t][c][r].y = (int)System.Math.Ceiling((try1 - cb0y) / twoppy) - (int)System.Math.Floor((try0 - cb0y) / (double)twoppy);
- }
- else
- {
- numPrec[t][c][r].y = 0;
- }
-
- minsbi = (r == 0) ? 0 : 1;
- maxsbi = (r == 0) ? 1 : 4;
-
- cblks[t][c][r] = new CBlkRateDistStats[maxsbi][];
- for (l = 0; l < num_Layers; l++)
- {
- truncIdxs[t][l][c][r] = new int[maxsbi][];
- }
-
- for (s = minsbi; s < maxsbi; s++)
- {
- // loop on subbands
- //Get the number of blocks in the current subband
- sb2 = (SubbandAn)sb.getSubbandByIdx(r, s);
- ncblks = sb2.numCb;
- cblkPerSubband = ncblks.x * ncblks.y;
- cblks[t][c][r][s] = new CBlkRateDistStats[cblkPerSubband];
-
- for (l = 0; l < num_Layers; l++)
- {
- truncIdxs[t][l][c][r][s] = new int[cblkPerSubband];
- for (i = 0; i < cblkPerSubband; i++)
- {
- truncIdxs[t][l][c][r][s][i] = -1;
- }
- }
- } // End loop on subbands
- } // End lopp on resolution levels
- } // End loop on components
- if (t != nt - 1)
- {
- src.nextTile();
- }
- } // End loop on tiles
-
- //Initialize the packet encoder
- pktEnc = new PktEncoder(src, encSpec, numPrec, pl);
-
- // The layers array has to be initialized after the constructor since
- // it is needed that the bit stream header has been entirely written
- }
-
-#if DO_TIMING
- /// Prints the timing information, if collected, and calls 'finalize' on
- /// the super class.
- ///
- ///
- ~EBCOTRateAllocator()
- {
-
- System.Text.StringBuilder sb;
-
- sb = new System.Text.StringBuilder("EBCOTRateAllocator wall clock times:\n");
- sb.Append(" initialization: ");
- sb.Append(initTime);
- sb.Append(" ms\n");
- sb.Append(" layer building: ");
- sb.Append(buildTime);
- sb.Append(" ms\n");
- sb.Append(" final writing: ");
- sb.Append(writeTime);
- sb.Append(" ms");
- FacilityManager.getMsgLogger().printmsg(CSJ2K.j2k.util.MsgLogger_Fields.INFO, sb.ToString());
- //UPGRADE_NOTE: Call to 'super.finalize()' was removed. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1124'"
- }
-#endif
- /// Runs the rate allocation algorithm and writes the data to the bit
- /// stream writer object provided to the constructor.
- ///
- ///
- public override void runAndWrite()
- {
- //Now, run the rate allocation
- buildAndWriteLayers();
- }
-
- /// Initializes the layers array. This must be called after the main header
- /// has been entirely written or simulated, so as to take its overhead into
- /// account. This method will get all the code-blocks and then initialize
- /// the target bitrates for each layer, according to the specifications.
- ///
- ///
- public override void initialize()
- {
- int n, i, l;
- int ho; // The header overhead (in bytes)
- float np; // The number of pixels divided by the number of bits per byte
- double ls; // Step for log-scale
- double basebytes;
- int lastbytes, newbytes, nextbytes;
- int loopnlyrs;
- int minlsz; // The minimum allowable number of bytes in a layer
- int totenclength;
- int maxpkt;
- int numTiles = src.getNumTiles();
- int numComps = src.NumComps;
- int numLvls;
- int avgPktLen;
-#if DO_TIMING
- long stime = 0L;
-#endif
- // Start by getting all the code-blocks, we need this in order to have
- // an idea of the total encoded bitrate.
- getAllCodeBlocks();
-
-#if DO_TIMING
- stime = (System.DateTime.Now.Ticks - 621355968000000000) / 10000;
-#endif
-
- // Now get the total encoded length
- totenclength = RDSlopesRates[0]; // all the encoded data
- // Make a rough estimation of the packet head overhead, as 2 bytes per
- // packet in average (plus EPH / SOP) , and add that to the total
- // encoded length
- for (int t = 0; t < numTiles; t++)
- {
- avgPktLen = 2;
- // Add SOP length if set
- if (((System.String)encSpec.sops.getTileDef(t)).ToUpper().Equals("on".ToUpper()))
- {
- avgPktLen += CSJ2K.j2k.codestream.Markers.SOP_LENGTH;
- }
- // Add EPH length if set
- if (((System.String)encSpec.ephs.getTileDef(t)).ToUpper().Equals("on".ToUpper()))
- {
- avgPktLen += CSJ2K.j2k.codestream.Markers.EPH_LENGTH;
- }
-
- for (int c = 0; c < numComps; c++)
- {
- numLvls = src.getAnSubbandTree(t, c).resLvl + 1;
- if (!src.precinctPartitionUsed(c, t))
- {
- // Precinct partition is not used so there is only
- // one packet per resolution level/layer
- totenclength += num_Layers * avgPktLen * numLvls;
- }
- else
- {
- // Precinct partition is used so for each
- // component/tile/resolution level, we get the maximum
- // number of packets
- for (int rl = 0; rl < numLvls; rl++)
- {
- maxpkt = numPrec[t][c][rl].x * numPrec[t][c][rl].y;
- totenclength += num_Layers * avgPktLen * maxpkt;
- }
- }
- } // End loop on components
- } // End loop on tiles
-
- // If any layer specifies more than 'totenclength' as its target
- // length then 'totenclength' is used. This is to prevent that
- // estimated layers get excessively large target lengths due to an
- // excessively large target bitrate. At the end the last layer is set
- // to the target length corresponding to the overall target
- // bitrate. Thus, 'totenclength' can not limit the total amount of
- // encoded data, as intended.
-
- ho = headEnc.Length;
- np = src.ImgWidth * src.ImgHeight / 8f;
-
- // SOT marker must be taken into account
- for (int t = 0; t < numTiles; t++)
- {
- headEnc.reset();
- headEnc.encodeTilePartHeader(0, t);
- ho += headEnc.Length;
- }
-
- layers = new EBCOTLayer[num_Layers];
- for (n = num_Layers - 1; n >= 0; n--)
- {
- layers[n] = new EBCOTLayer();
- }
-
- minlsz = 0; // To keep compiler happy
- for (int t = 0; t < numTiles; t++)
- {
- for (int c = 0; c < numComps; c++)
- {
- numLvls = src.getAnSubbandTree(t, c).resLvl + 1;
-
- if (!src.precinctPartitionUsed(c, t))
- {
- // Precinct partition is not used
- minlsz += MIN_AVG_PACKET_SZ * numLvls;
- }
- else
- {
- // Precinct partition is used
- for (int rl = 0; rl < numLvls; rl++)
- {
- maxpkt = numPrec[t][c][rl].x * numPrec[t][c][rl].y;
- minlsz += MIN_AVG_PACKET_SZ * maxpkt;
- }
- }
- } // End loop on components
- } // End loop on tiles
-
- // Initialize layers
- n = 0;
- i = 0;
- lastbytes = 0;
-
- while (n < num_Layers - 1)
- {
- // At an optimized layer
- basebytes = System.Math.Floor(lyrSpec.getTargetBitrate(i) * np);
- if (i < lyrSpec.NOptPoints - 1)
- {
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- nextbytes = (int)(lyrSpec.getTargetBitrate(i + 1) * np);
- // Limit target length to 'totenclength'
- if (nextbytes > totenclength)
- nextbytes = totenclength;
- }
- else
- {
- nextbytes = 1;
- }
- loopnlyrs = lyrSpec.getExtraLayers(i) + 1;
- ls = System.Math.Exp(System.Math.Log((double)nextbytes / basebytes) / loopnlyrs);
- layers[n].optimize = true;
- for (l = 0; l < loopnlyrs; l++)
- {
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- newbytes = (int)basebytes - lastbytes - ho;
- if (newbytes < minlsz)
- {
- // Skip layer (too small)
- basebytes *= ls;
- num_Layers--;
- continue;
- }
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- lastbytes = (int)basebytes - ho;
- layers[n].maxBytes = lastbytes;
- basebytes *= ls;
- n++;
- }
- i++; // Goto next optimization point
- }
-
- // Ensure minimum size of last layer (this one determines overall
- // bitrate)
- n = num_Layers - 2;
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- nextbytes = (int)(lyrSpec.TotBitrate * np) - ho;
- newbytes = nextbytes - ((n >= 0) ? layers[n].maxBytes : 0);
- while (newbytes < minlsz)
- {
- if (num_Layers == 1)
- {
- if (newbytes <= 0)
- {
- throw new System.ArgumentException("Overall target bitrate too " + "low, given the current " + "bit stream header overhead");
- }
- break;
- }
- // Delete last layer
- num_Layers--;
- n--;
- newbytes = nextbytes - ((n >= 0) ? layers[n].maxBytes : 0);
- }
- // Set last layer to the overall target bitrate
- n++;
- layers[n].maxBytes = nextbytes;
- layers[n].optimize = true;
-
- // Re-initialize progression order changes if needed Default values
- Progression[] prog1; // prog2 removed
- prog1 = (Progression[])encSpec.pocs.getDefault();
- int nValidProg = prog1.Length;
- for (int prg = 0; prg < prog1.Length; prg++)
- {
- if (prog1[prg].lye > num_Layers)
- {
- prog1[prg].lye = num_Layers;
- }
- }
- if (nValidProg == 0)
- {
- throw new System.ApplicationException("Unable to initialize rate allocator: No " + "default progression type has been defined.");
- }
-
- // Tile specific values
- for (int t = 0; t < numTiles; t++)
- {
- if (encSpec.pocs.isTileSpecified(t))
- {
- prog1 = (Progression[])encSpec.pocs.getTileDef(t);
- nValidProg = prog1.Length;
- for (int prg = 0; prg < prog1.Length; prg++)
- {
- if (prog1[prg].lye > num_Layers)
- {
- prog1[prg].lye = num_Layers;
- }
- }
- if (nValidProg == 0)
- {
- throw new System.ApplicationException("Unable to initialize rate allocator:" + " No default progression type has been " + "defined for tile " + t);
- }
- }
- } // End loop on tiles
-
-#if DO_TIMING
- initTime += (System.DateTime.Now.Ticks - 621355968000000000) / 10000 - stime;
-#endif
- }
-
- /// This method gets all the coded code-blocks from the EBCOT entropy coder
- /// for every component and every tile. Each coded code-block is stored in
- /// a 5D array according to the component, the resolution level, the tile,
- /// the subband it belongs and its position in the subband.
- ///
- /// For each code-block, the valid slopes are computed and converted
- /// into the mantissa-exponent representation.
- ///
- ///
- private void getAllCodeBlocks()
- {
-
- int numComps, numTiles; // numBytes removed
- int c, r, t, s, sidx, k;
- //int slope;
- SubbandAn subb;
- CBlkRateDistStats ccb = null;
- Coord ncblks = null;
- int last_sidx;
- float fslope;
-#if DO_TIMING
- long stime = 0L;
-#endif
- maxSlope = 0f;
- minSlope = System.Single.MaxValue;
-
- //Get the number of components and tiles
- numComps = src.NumComps;
- numTiles = src.getNumTiles();
-
- 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);
- for (t = 0; t < numTiles; t++)
- {
- //loop on tiles
- nEncCblk = 0;
- cblkToEncode = 0;
- for (c = 0; c < numComps; c++)
- {
- root = src.getAnSubbandTree(t, c);
- for (r = 0; r <= root.resLvl; r++)
- {
- if (r == 0)
- {
- sb = (SubbandAn)root.getSubbandByIdx(0, 0);
- if (sb != null)
- cblkToEncode += sb.numCb.x * sb.numCb.y;
- }
- else
- {
- sb = (SubbandAn)root.getSubbandByIdx(r, 1);
- if (sb != null)
- cblkToEncode += sb.numCb.x * sb.numCb.y;
- sb = (SubbandAn)root.getSubbandByIdx(r, 2);
- if (sb != null)
- cblkToEncode += sb.numCb.x * sb.numCb.y;
- sb = (SubbandAn)root.getSubbandByIdx(r, 3);
- if (sb != null)
- cblkToEncode += sb.numCb.x * sb.numCb.y;
- }
- }
- }
- if (pw != null)
- {
- pw.initProgressWatch(0, cblkToEncode, "Encoding tile " + t + "...");
- }
-
- for (c = 0; c < numComps; c++)
- {
- //loop on components
-
- //Get next coded code-block coordinates
- while ((ccb = src.getNextCodeBlock(c, ccb)) != null)
- {
-#if DO_TIMING
- stime = (System.DateTime.Now.Ticks - 621355968000000000) / 10000;
-#endif
-
- if (pw != null)
- {
- nEncCblk++;
- pw.updateProgressWatch(nEncCblk, null);
- }
-
- subb = ccb.sb;
-
- //Get the coded code-block resolution level index
- r = subb.resLvl;
-
- //Get the coded code-block subband index
- s = subb.sbandIdx;
-
- //Get the number of blocks in the current subband
- ncblks = subb.numCb;
-
- // Add code-block contribution to summary R-D table
- // RDSlopesRates
- last_sidx = -1;
- for (k = ccb.nVldTrunc - 1; k >= 0; k--)
- {
- fslope = ccb.truncSlopes[k];
- if (fslope > maxSlope)
- maxSlope = fslope;
- if (fslope < minSlope)
- minSlope = fslope;
- sidx = getLimitedSIndexFromSlope(fslope);
- for (; sidx > last_sidx; sidx--)
- {
- RDSlopesRates[sidx] += ccb.truncRates[ccb.truncIdxs[k]];
- }
- last_sidx = getLimitedSIndexFromSlope(fslope);
- }
-
- //Fills code-blocks array
- cblks[t][c][r][s][(ccb.m * ncblks.x) + ccb.n] = ccb;
- ccb = null;
-
-#if DO_TIMING
- initTime += (System.DateTime.Now.Ticks - 621355968000000000) / 10000 - stime;
-#endif
- }
- }
-
- if (pw != null)
- {
- pw.terminateProgressWatch();
- }
-
- //Goto next tile
- if (t < numTiles - 1)
- //not at last tile
- src.nextTile();
- }
- }
-
- /// This method builds all the bit stream layers and then writes them to
- /// the output bit stream. Firstly it builds all the layers by computing
- /// the threshold according to the layer target bit-rate, and then it
- /// writes the layer bit streams according to the progressive type.
- ///
- ///
- private void buildAndWriteLayers()
- {
- int nPrec = 0;
- int maxBytes, actualBytes;
- float rdThreshold;
- SubbandAn sb;
- //float threshold;
- BitOutputBuffer hBuff = null;
- byte[] bBuff = null;
- int[] tileLengths; // Length of each tile
- int tmp;
- bool sopUsed; // Should SOP markers be used ?
- bool ephUsed; // Should EPH markers be used ?
- int nc = src.NumComps;
- int nt = src.getNumTiles();
- int mrl;
-#if DO_TIMING
- long stime = 0L;
- stime = (System.DateTime.Now.Ticks - 621355968000000000) / 10000;
-#endif
-
- // Start with the maximum slope
- rdThreshold = maxSlope;
-
- tileLengths = new int[nt];
- actualBytes = 0;
-
- // +------------------------------+
- // | First we build the layers |
- // +------------------------------+
- // Bitstream is simulated to know tile length
- for (int l = 0; l < num_Layers; l++)
- {
- //loop on layers
-
- maxBytes = layers[l].maxBytes;
- if (layers[l].optimize)
- {
- rdThreshold = optimizeBitstreamLayer(l, rdThreshold, maxBytes, actualBytes);
- }
- else
- {
- if (l <= 0 || l >= num_Layers - 1)
- {
- throw new System.ArgumentException("The first and the" + " last layer " + "thresholds" + " must be optimized");
- }
- rdThreshold = estimateLayerThreshold(maxBytes, layers[l - 1]);
- }
-
- for (int t = 0; t < nt; t++)
- {
- //loop on tiles
- if (l == 0)
- {
- // Tile header
- headEnc.reset();
- headEnc.encodeTilePartHeader(0, t);
- tileLengths[t] += headEnc.Length;
- }
-
- for (int c = 0; c < nc; c++)
- {
- //loop on components
-
- // set boolean sopUsed here (SOP markers)
- sopUsed = ((System.String)encSpec.sops.getTileDef(t)).ToUpper().Equals("on".ToUpper());
- // set boolean ephUsed here (EPH markers)
- ephUsed = ((System.String)encSpec.ephs.getTileDef(t)).ToUpper().Equals("on".ToUpper());
-
- // Go to LL band
- sb = src.getAnSubbandTree(t, c);
- mrl = sb.resLvl + 1;
-
- while (sb.subb_LL != null)
- {
- sb = sb.subb_LL;
- }
-
- for (int r = 0; r < mrl; r++)
- {
- // loop on resolution levels
-
- nPrec = numPrec[t][c][r].x * numPrec[t][c][r].y;
- for (int p = 0; p < nPrec; p++)
- {
- // loop on precincts
-
- findTruncIndices(l, c, r, t, sb, rdThreshold, p);
-
- hBuff = pktEnc.encodePacket(l + 1, c, r, t, cblks[t][c][r], truncIdxs[t][l][c][r], hBuff, bBuff, p);
- if (pktEnc.PacketWritable)
- {
- tmp = bsWriter.writePacketHead(hBuff.Buffer, hBuff.Length, true, sopUsed, ephUsed);
- tmp += bsWriter.writePacketBody(pktEnc.LastBodyBuf, pktEnc.LastBodyLen, true, pktEnc.ROIinPkt, pktEnc.ROILen);
- actualBytes += tmp;
- tileLengths[t] += tmp;
- }
- } // End loop on precincts
- sb = sb.parentband;
- } // End loop on resolution levels
- } // End loop on components
- } // end loop on tiles
- layers[l].rdThreshold = rdThreshold;
- layers[l].actualBytes = actualBytes;
- } // end loop on layers
-
-#if DO_TIMING
- buildTime += (System.DateTime.Now.Ticks - 621355968000000000) / 10000 - stime;
- stime = (System.DateTime.Now.Ticks - 621355968000000000) / 10000;
-#endif
- // +--------------------------------------------------+
- // | Write tiles according to their Progression order |
- // +--------------------------------------------------+
- // Reset the packet encoder before writing all packets
- pktEnc.reset();
- Progression[] prog; // Progression(s) in each tile
- int cs, ce, rs, re, lye;
-
- int[] mrlc = new int[nc];
- for (int t = 0; t < nt; t++)
- {
- //loop on tiles
- //int[][] lysA; // layer index start for each component and
- // resolution level
- int[][] lys = new int[nc][];
- for (int c = 0; c < nc; c++)
- {
- mrlc[c] = src.getAnSubbandTree(t, c).resLvl;
- lys[c] = new int[mrlc[c] + 1];
- }
-
- // Tile header
- headEnc.reset();
- headEnc.encodeTilePartHeader(tileLengths[t], t);
- bsWriter.commitBitstreamHeader(headEnc);
- prog = (Progression[])encSpec.pocs.getTileDef(t);
-
- for (int prg = 0; prg < prog.Length; prg++)
- {
- // Loop on progression
- lye = prog[prg].lye;
- cs = prog[prg].cs;
- ce = prog[prg].ce;
- rs = prog[prg].rs;
- re = prog[prg].re;
-
- switch (prog[prg].type)
- {
-
- case CSJ2K.j2k.codestream.ProgressionType.RES_LY_COMP_POS_PROG:
- writeResLyCompPos(t, rs, re, cs, ce, lys, lye);
- break;
-
- case CSJ2K.j2k.codestream.ProgressionType.LY_RES_COMP_POS_PROG:
- writeLyResCompPos(t, rs, re, cs, ce, lys, lye);
- break;
-
- case CSJ2K.j2k.codestream.ProgressionType.POS_COMP_RES_LY_PROG:
- writePosCompResLy(t, rs, re, cs, ce, lys, lye);
- break;
-
- case CSJ2K.j2k.codestream.ProgressionType.COMP_POS_RES_LY_PROG:
- writeCompPosResLy(t, rs, re, cs, ce, lys, lye);
- break;
-
- case CSJ2K.j2k.codestream.ProgressionType.RES_POS_COMP_LY_PROG:
- writeResPosCompLy(t, rs, re, cs, ce, lys, lye);
- break;
-
- default:
- throw new System.ApplicationException("Unsupported bit stream progression type");
-
- } // switch on progression
-
- // Update next first layer index
- for (int c = cs; c < ce; c++)
- for (int r = rs; r < re; r++)
- {
- if (r > mrlc[c])
- continue;
- lys[c][r] = lye;
- }
- } // End loop on progression
- } // End loop on tiles
-
-#if DO_TIMING
- writeTime += (System.DateTime.Now.Ticks - 621355968000000000) / 10000 - stime;
-#endif
- }
-
- /// Write a piece of bit stream according to the
- /// RES_LY_COMP_POS_PROG progression mode and between given bounds
- ///
- ///
- /// Tile index.
- ///
- ///
- /// First resolution level index.
- ///
- ///
- /// Last resolution level index.
- ///
- ///
- /// First component index.
- ///
- ///
- /// Last component index.
- ///
- ///
- /// First layer index for each component and resolution.
- ///
- ///
- /// Index of the last layer.
- ///
- ///
- public virtual void writeResLyCompPos(int t, int rs, int re, int cs, int ce, int[][] lys, int lye)
- {
-
- bool sopUsed; // Should SOP markers be used ?
- bool ephUsed; // Should EPH markers be used ?
- int nc = src.NumComps;
- int[] mrl = new int[nc];
- SubbandAn sb;
- float threshold;
- BitOutputBuffer hBuff = null;
- byte[] bBuff = null;
- int nPrec = 0;
-
- // Max number of resolution levels in the tile
- int maxResLvl = 0;
- for (int c = 0; c < nc; c++)
- {
- mrl[c] = src.getAnSubbandTree(t, c).resLvl;
- if (mrl[c] > maxResLvl)
- maxResLvl = mrl[c];
- }
-
- int minlys; // minimum layer start index of each component
-
- for (int r = rs; r < re; r++)
- {
- //loop on resolution levels
- if (r > maxResLvl)
- continue;
-
- minlys = 100000;
- for (int c = cs; c < ce; c++)
- {
- if (r < lys[c].Length && lys[c][r] < minlys)
- {
- minlys = lys[c][r];
- }
- }
-
- for (int l = minlys; l < lye; l++)
- {
- //loop on layers
- for (int c = cs; c < ce; c++)
- {
- //loop on components
- if (r >= lys[c].Length)
- continue;
- if (l < lys[c][r])
- continue;
-
- // If no more decomposition levels for this component
- if (r > mrl[c])
- continue;
-
- nPrec = numPrec[t][c][r].x * numPrec[t][c][r].y;
- for (int p = 0; p < nPrec; p++)
- {
- // loop on precincts
-
- // set boolean sopUsed here (SOP markers)
- sopUsed = ((System.String)encSpec.sops.getTileDef(t)).Equals("on");
- // set boolean ephUsed here (EPH markers)
- ephUsed = ((System.String)encSpec.ephs.getTileDef(t)).Equals("on");
-
- sb = src.getAnSubbandTree(t, c);
- for (int i = mrl[c]; i > r; i--)
- {
- sb = sb.subb_LL;
- }
-
- threshold = layers[l].rdThreshold;
- findTruncIndices(l, c, r, t, sb, threshold, p);
-
- hBuff = pktEnc.encodePacket(l + 1, c, r, t, cblks[t][c][r], truncIdxs[t][l][c][r], hBuff, bBuff, p);
-
- if (pktEnc.PacketWritable)
- {
- bsWriter.writePacketHead(hBuff.Buffer, hBuff.Length, false, sopUsed, ephUsed);
- bsWriter.writePacketBody(pktEnc.LastBodyBuf, pktEnc.LastBodyLen, false, pktEnc.ROIinPkt, pktEnc.ROILen);
- }
- } // End loop on precincts
- } // End loop on components
- } // End loop on layers
- } // End loop on resolution levels
- }
-
- /// Write a piece of bit stream according to the
- /// LY_RES_COMP_POS_PROG progression mode and between given bounds
- ///
- ///
- /// Tile index.
- ///
- ///
- /// First resolution level index.
- ///
- ///
- /// Last resolution level index.
- ///
- ///
- /// First component index.
- ///
- ///
- /// Last component index.
- ///
- ///
- /// First layer index for each component and resolution.
- ///
- ///
- /// Index of the last layer.
- ///
- ///
- public virtual void writeLyResCompPos(int t, int rs, int re, int cs, int ce, int[][] lys, int lye)
- {
-
- bool sopUsed; // Should SOP markers be used ?
- bool ephUsed; // Should EPH markers be used ?
- int nc = src.NumComps;
- int mrl;
- SubbandAn sb;
- float threshold;
- BitOutputBuffer hBuff = null;
- byte[] bBuff = null;
- int nPrec = 0;
-
- int minlys = 100000; // minimum layer start index of each component
- for (int c = cs; c < ce; c++)
- {
- for (int r = 0; r < lys.Length; r++)
- {
- if (lys[c] != null && r < lys[c].Length && lys[c][r] < minlys)
- {
- minlys = lys[c][r];
- }
- }
- }
-
- for (int l = minlys; l < lye; l++)
- {
- // loop on layers
- for (int r = rs; r < re; r++)
- {
- // loop on resolution level
- for (int c = cs; c < ce; c++)
- {
- // loop on components
- mrl = src.getAnSubbandTree(t, c).resLvl;
- if (r > mrl)
- continue;
- if (r >= lys[c].Length)
- continue;
- if (l < lys[c][r])
- continue;
-
- nPrec = numPrec[t][c][r].x * numPrec[t][c][r].y;
- for (int p = 0; p < nPrec; p++)
- {
- // loop on precincts
-
- // set boolean sopUsed here (SOP markers)
- sopUsed = ((System.String)encSpec.sops.getTileDef(t)).Equals("on");
- // set boolean ephUsed here (EPH markers)
- ephUsed = ((System.String)encSpec.ephs.getTileDef(t)).Equals("on");
-
- sb = src.getAnSubbandTree(t, c);
- for (int i = mrl; i > r; i--)
- {
- sb = sb.subb_LL;
- }
-
- threshold = layers[l].rdThreshold;
- findTruncIndices(l, c, r, t, sb, threshold, p);
-
- hBuff = pktEnc.encodePacket(l + 1, c, r, t, cblks[t][c][r], truncIdxs[t][l][c][r], hBuff, bBuff, p);
-
- if (pktEnc.PacketWritable)
- {
- bsWriter.writePacketHead(hBuff.Buffer, hBuff.Length, false, sopUsed, ephUsed);
- bsWriter.writePacketBody(pktEnc.LastBodyBuf, pktEnc.LastBodyLen, false, pktEnc.ROIinPkt, pktEnc.ROILen);
- }
- } // end loop on precincts
- } // end loop on components
- } // end loop on resolution levels
- } // end loop on layers
- }
-
- /// Write a piece of bit stream according to the
- /// COMP_POS_RES_LY_PROG progression mode and between given bounds
- ///
- ///
- /// Tile index.
- ///
- ///
- /// First resolution level index.
- ///
- ///
- /// Last resolution level index.
- ///
- ///
- /// First component index.
- ///
- ///
- /// Last component index.
- ///
- ///
- /// First layer index for each component and resolution.
- ///
- ///
- /// Index of the last layer.
- ///
- ///
- public virtual void writePosCompResLy(int t, int rs, int re, int cs, int ce, int[][] lys, int lye)
- {
-
- bool sopUsed; // Should SOP markers be used ?
- bool ephUsed; // Should EPH markers be used ?
- int nc = src.NumComps;
- int mrl;
- SubbandAn sb;
- float threshold;
- BitOutputBuffer hBuff = null;
- byte[] bBuff = null;
-
- // Computes current tile offset in the reference grid
- Coord nTiles = src.getNumTiles(null);
- Coord tileI = src.getTile(null);
- int x0siz = src.ImgULX;
- int y0siz = src.ImgULY;
- int xsiz = x0siz + src.ImgWidth;
- int ysiz = y0siz + src.ImgHeight;
- int xt0siz = src.TilePartULX;
- int yt0siz = src.TilePartULY;
- int xtsiz = src.NomTileWidth;
- int ytsiz = src.NomTileHeight;
- int tx0 = (tileI.x == 0) ? x0siz : xt0siz + tileI.x * xtsiz;
- int ty0 = (tileI.y == 0) ? y0siz : yt0siz + tileI.y * ytsiz;
- int tx1 = (tileI.x != nTiles.x - 1) ? xt0siz + (tileI.x + 1) * xtsiz : xsiz;
- int ty1 = (tileI.y != nTiles.y - 1) ? yt0siz + (tileI.y + 1) * ytsiz : ysiz;
-
- // Get precinct information (number,distance between two consecutive
- // precincts in the reference grid) in each component and resolution
- // level
- PrecInfo prec; // temporary variable
- int p; // Current precinct index
- int gcd_x = 0; // Horiz. distance between 2 precincts in the ref. grid
- int gcd_y = 0; // Vert. distance between 2 precincts in the ref. grid
- int nPrec = 0; // Total number of found precincts
- int[][] nextPrec = new int[ce][]; // Next precinct index in each
- // component and resolution level
- int minlys = 100000; // minimum layer start index of each component
- int minx = tx1; // Horiz. offset of the second precinct in the
- // reference grid
- int miny = ty1; // Vert. offset of the second precinct in the
- // reference grid.
- int maxx = tx0; // Max. horiz. offset of precincts in the ref. grid
- int maxy = ty0; // Max. vert. offset of precincts in the ref. grid
- for (int c = cs; c < ce; c++)
- {
- mrl = src.getAnSubbandTree(t, c).resLvl;
- nextPrec[c] = new int[mrl + 1];
- for (int r = rs; r < re; r++)
- {
- if (r > mrl)
- continue;
- if (r < lys[c].Length && lys[c][r] < minlys)
- {
- minlys = lys[c][r];
- }
- p = numPrec[t][c][r].y * numPrec[t][c][r].x - 1;
- for (; p >= 0; p--)
- {
- prec = pktEnc.getPrecInfo(t, c, r, p);
- if (prec.rgulx != tx0)
- {
- if (prec.rgulx < minx)
- minx = prec.rgulx;
- if (prec.rgulx > maxx)
- maxx = prec.rgulx;
- }
- if (prec.rguly != ty0)
- {
- if (prec.rguly < miny)
- miny = prec.rguly;
- if (prec.rguly > maxy)
- maxy = prec.rguly;
- }
-
- if (nPrec == 0)
- {
- gcd_x = prec.rgw;
- gcd_y = prec.rgh;
- }
- else
- {
- gcd_x = MathUtil.gcd(gcd_x, prec.rgw);
- gcd_y = MathUtil.gcd(gcd_y, prec.rgh);
- }
- nPrec++;
- } // precincts
- } // resolution levels
- } // components
-
- if (nPrec == 0)
- {
- throw new System.ApplicationException("Image cannot have no precinct");
- }
-
- int pyend = (maxy - miny) / gcd_y + 1;
- int pxend = (maxx - minx) / gcd_x + 1;
- int y = ty0;
- int x = tx0;
- for (int py = 0; py <= pyend; py++)
- {
- // Vertical precincts
- for (int px = 0; px <= pxend; px++)
- {
- // Horiz. precincts
- for (int c = cs; c < ce; c++)
- {
- // Components
- mrl = src.getAnSubbandTree(t, c).resLvl;
- for (int r = rs; r < re; r++)
- {
- // Resolution levels
- if (r > mrl)
- continue;
- if (nextPrec[c][r] >= numPrec[t][c][r].x * numPrec[t][c][r].y)
- {
- continue;
- }
- prec = pktEnc.getPrecInfo(t, c, r, nextPrec[c][r]);
- if ((prec.rgulx != x) || (prec.rguly != y))
- {
- continue;
- }
- for (int l = minlys; l < lye; l++)
- {
- // Layers
- if (r >= lys[c].Length)
- continue;
- if (l < lys[c][r])
- continue;
-
- // set boolean sopUsed here (SOP markers)
- sopUsed = ((System.String)encSpec.sops.getTileDef(t)).Equals("on");
- // set boolean ephUsed here (EPH markers)
- ephUsed = ((System.String)encSpec.ephs.getTileDef(t)).Equals("on");
-
- sb = src.getAnSubbandTree(t, c);
- for (int i = mrl; i > r; i--)
- {
- sb = sb.subb_LL;
- }
-
- threshold = layers[l].rdThreshold;
- findTruncIndices(l, c, r, t, sb, threshold, nextPrec[c][r]);
-
- hBuff = pktEnc.encodePacket(l + 1, c, r, t, cblks[t][c][r], truncIdxs[t][l][c][r], hBuff, bBuff, nextPrec[c][r]);
-
- if (pktEnc.PacketWritable)
- {
- bsWriter.writePacketHead(hBuff.Buffer, hBuff.Length, false, sopUsed, ephUsed);
- bsWriter.writePacketBody(pktEnc.LastBodyBuf, pktEnc.LastBodyLen, false, pktEnc.ROIinPkt, pktEnc.ROILen);
- }
- } // layers
- nextPrec[c][r]++;
- } // Resolution levels
- } // Components
- if (px != pxend)
- {
- x = minx + px * gcd_x;
- }
- else
- {
- x = tx0;
- }
- } // Horizontal precincts
- if (py != pyend)
- {
- y = miny + py * gcd_y;
- }
- else
- {
- y = ty0;
- }
- } // Vertical precincts
-
- // Check that all precincts have been written
- for (int c = cs; c < ce; c++)
- {
- mrl = src.getAnSubbandTree(t, c).resLvl;
- for (int r = rs; r < re; r++)
- {
- if (r > mrl)
- continue;
- if (nextPrec[c][r] < numPrec[t][c][r].x * numPrec[t][c][r].y - 1)
- {
- throw new System.ApplicationException("JJ2000 bug: One precinct at least has " + "not been written for resolution level " + r + " of component " + c + " in tile " + t + ".");
- }
- }
- }
- }
-
- /// Write a piece of bit stream according to the
- /// COMP_POS_RES_LY_PROG progression mode and between given bounds
- ///
- ///
- /// Tile index.
- ///
- ///
- /// First resolution level index.
- ///
- ///
- /// Last resolution level index.
- ///
- ///
- /// First component index.
- ///
- ///
- /// Last component index.
- ///
- ///
- /// First layer index for each component and resolution.
- ///
- ///
- /// Index of the last layer.
- ///
- ///
- public virtual void writeCompPosResLy(int t, int rs, int re, int cs, int ce, int[][] lys, int lye)
- {
-
- bool sopUsed; // Should SOP markers be used ?
- bool ephUsed; // Should EPH markers be used ?
- int nc = src.NumComps;
- int mrl;
- SubbandAn sb;
- float threshold;
- BitOutputBuffer hBuff = null;
- byte[] bBuff = null;
-
- // Computes current tile offset in the reference grid
- Coord nTiles = src.getNumTiles(null);
- Coord tileI = src.getTile(null);
- int x0siz = src.ImgULX;
- int y0siz = src.ImgULY;
- int xsiz = x0siz + src.ImgWidth;
- int ysiz = y0siz + src.ImgHeight;
- int xt0siz = src.TilePartULX;
- int yt0siz = src.TilePartULY;
- int xtsiz = src.NomTileWidth;
- int ytsiz = src.NomTileHeight;
- int tx0 = (tileI.x == 0) ? x0siz : xt0siz + tileI.x * xtsiz;
- int ty0 = (tileI.y == 0) ? y0siz : yt0siz + tileI.y * ytsiz;
- int tx1 = (tileI.x != nTiles.x - 1) ? xt0siz + (tileI.x + 1) * xtsiz : xsiz;
- int ty1 = (tileI.y != nTiles.y - 1) ? yt0siz + (tileI.y + 1) * ytsiz : ysiz;
-
- // Get precinct information (number,distance between two consecutive
- // precincts in the reference grid) in each component and resolution
- // level
- PrecInfo prec; // temporary variable
- int p; // Current precinct index
- int gcd_x = 0; // Horiz. distance between 2 precincts in the ref. grid
- int gcd_y = 0; // Vert. distance between 2 precincts in the ref. grid
- int nPrec = 0; // Total number of found precincts
- int[][] nextPrec = new int[ce][]; // Next precinct index in each
- // component and resolution level
- int minlys = 100000; // minimum layer start index of each component
- int minx = tx1; // Horiz. offset of the second precinct in the
- // reference grid
- int miny = ty1; // Vert. offset of the second precinct in the
- // reference grid.
- int maxx = tx0; // Max. horiz. offset of precincts in the ref. grid
- int maxy = ty0; // Max. vert. offset of precincts in the ref. grid
- for (int c = cs; c < ce; c++)
- {
- mrl = src.getAnSubbandTree(t, c).resLvl;
- for (int r = rs; r < re; r++)
- {
- if (r > mrl)
- continue;
- nextPrec[c] = new int[mrl + 1];
- if (r < lys[c].Length && lys[c][r] < minlys)
- {
- minlys = lys[c][r];
- }
- p = numPrec[t][c][r].y * numPrec[t][c][r].x - 1;
- for (; p >= 0; p--)
- {
- prec = pktEnc.getPrecInfo(t, c, r, p);
- if (prec.rgulx != tx0)
- {
- if (prec.rgulx < minx)
- minx = prec.rgulx;
- if (prec.rgulx > maxx)
- maxx = prec.rgulx;
- }
- if (prec.rguly != ty0)
- {
- if (prec.rguly < miny)
- miny = prec.rguly;
- if (prec.rguly > maxy)
- maxy = prec.rguly;
- }
-
- if (nPrec == 0)
- {
- gcd_x = prec.rgw;
- gcd_y = prec.rgh;
- }
- else
- {
- gcd_x = MathUtil.gcd(gcd_x, prec.rgw);
- gcd_y = MathUtil.gcd(gcd_y, prec.rgh);
- }
- nPrec++;
- } // precincts
- } // resolution levels
- } // components
-
- if (nPrec == 0)
- {
- throw new System.ApplicationException("Image cannot have no precinct");
- }
-
- int pyend = (maxy - miny) / gcd_y + 1;
- int pxend = (maxx - minx) / gcd_x + 1;
- int y;
- int x;
- for (int c = cs; c < ce; c++)
- {
- // Loop on components
- y = ty0;
- x = tx0;
- mrl = src.getAnSubbandTree(t, c).resLvl;
- for (int py = 0; py <= pyend; py++)
- {
- // Vertical precincts
- for (int px = 0; px <= pxend; px++)
- {
- // Horiz. precincts
- for (int r = rs; r < re; r++)
- {
- // Resolution levels
- if (r > mrl)
- continue;
- if (nextPrec[c][r] >= numPrec[t][c][r].x * numPrec[t][c][r].y)
- {
- continue;
- }
- prec = pktEnc.getPrecInfo(t, c, r, nextPrec[c][r]);
- if ((prec.rgulx != x) || (prec.rguly != y))
- {
- continue;
- }
-
- for (int l = minlys; l < lye; l++)
- {
- // Layers
- if (r >= lys[c].Length)
- continue;
- if (l < lys[c][r])
- continue;
-
- // set boolean sopUsed here (SOP markers)
- sopUsed = ((System.String)encSpec.sops.getTileDef(t)).Equals("on");
- // set boolean ephUsed here (EPH markers)
- ephUsed = ((System.String)encSpec.ephs.getTileDef(t)).Equals("on");
-
- sb = src.getAnSubbandTree(t, c);
- for (int i = mrl; i > r; i--)
- {
- sb = sb.subb_LL;
- }
-
- threshold = layers[l].rdThreshold;
- findTruncIndices(l, c, r, t, sb, threshold, nextPrec[c][r]);
-
- hBuff = pktEnc.encodePacket(l + 1, c, r, t, cblks[t][c][r], truncIdxs[t][l][c][r], hBuff, bBuff, nextPrec[c][r]);
-
- if (pktEnc.PacketWritable)
- {
- bsWriter.writePacketHead(hBuff.Buffer, hBuff.Length, false, sopUsed, ephUsed);
- bsWriter.writePacketBody(pktEnc.LastBodyBuf, pktEnc.LastBodyLen, false, pktEnc.ROIinPkt, pktEnc.ROILen);
- }
- } // Layers
- nextPrec[c][r]++;
- } // Resolution levels
- if (px != pxend)
- {
- x = minx + px * gcd_x;
- }
- else
- {
- x = tx0;
- }
- } // Horizontal precincts
- if (py != pyend)
- {
- y = miny + py * gcd_y;
- }
- else
- {
- y = ty0;
- }
- } // Vertical precincts
- } // components
-
- // Check that all precincts have been written
- for (int c = cs; c < ce; c++)
- {
- mrl = src.getAnSubbandTree(t, c).resLvl;
- for (int r = rs; r < re; r++)
- {
- if (r > mrl)
- continue;
- if (nextPrec[c][r] < numPrec[t][c][r].x * numPrec[t][c][r].y - 1)
- {
- throw new System.ApplicationException("JJ2000 bug: One precinct at least has " + "not been written for resolution level " + r + " of component " + c + " in tile " + t + ".");
- }
- }
- }
- }
-
- /// Write a piece of bit stream according to the
- /// RES_POS_COMP_LY_PROG progression mode and between given bounds
- ///
- ///
- /// Tile index.
- ///
- ///
- /// First resolution level index.
- ///
- ///
- /// Last resolution level index.
- ///
- ///
- /// First component index.
- ///
- ///
- /// Last component index.
- ///
- ///
- /// First layer index for each component and resolution.
- ///
- ///
- /// Last layer index.
- ///
- ///
- public virtual void writeResPosCompLy(int t, int rs, int re, int cs, int ce, int[][] lys, int lye)
- {
-
- bool sopUsed; // Should SOP markers be used ?
- bool ephUsed; // Should EPH markers be used ?
- int nc = src.NumComps;
- int mrl;
- SubbandAn sb;
- float threshold;
- BitOutputBuffer hBuff = null;
- byte[] bBuff = null;
-
- // Computes current tile offset in the reference grid
- Coord nTiles = src.getNumTiles(null);
- Coord tileI = src.getTile(null);
- int x0siz = src.ImgULX;
- int y0siz = src.ImgULY;
- int xsiz = x0siz + src.ImgWidth;
- int ysiz = y0siz + src.ImgHeight;
- int xt0siz = src.TilePartULX;
- int yt0siz = src.TilePartULY;
- int xtsiz = src.NomTileWidth;
- int ytsiz = src.NomTileHeight;
- int tx0 = (tileI.x == 0) ? x0siz : xt0siz + tileI.x * xtsiz;
- int ty0 = (tileI.y == 0) ? y0siz : yt0siz + tileI.y * ytsiz;
- int tx1 = (tileI.x != nTiles.x - 1) ? xt0siz + (tileI.x + 1) * xtsiz : xsiz;
- int ty1 = (tileI.y != nTiles.y - 1) ? yt0siz + (tileI.y + 1) * ytsiz : ysiz;
-
- // Get precinct information (number,distance between two consecutive
- // precincts in the reference grid) in each component and resolution
- // level
- PrecInfo prec; // temporary variable
- int p; // Current precinct index
- int gcd_x = 0; // Horiz. distance between 2 precincts in the ref. grid
- int gcd_y = 0; // Vert. distance between 2 precincts in the ref. grid
- int nPrec = 0; // Total number of found precincts
- int[][] nextPrec = new int[ce][]; // Next precinct index in each
- // component and resolution level
- int minlys = 100000; // minimum layer start index of each component
- int minx = tx1; // Horiz. offset of the second precinct in the
- // reference grid
- int miny = ty1; // Vert. offset of the second precinct in the
- // reference grid.
- int maxx = tx0; // Max. horiz. offset of precincts in the ref. grid
- int maxy = ty0; // Max. vert. offset of precincts in the ref. grid
- for (int c = cs; c < ce; c++)
- {
- mrl = src.getAnSubbandTree(t, c).resLvl;
- nextPrec[c] = new int[mrl + 1];
- for (int r = rs; r < re; r++)
- {
- if (r > mrl)
- continue;
- if (r < lys[c].Length && lys[c][r] < minlys)
- {
- minlys = lys[c][r];
- }
- p = numPrec[t][c][r].y * numPrec[t][c][r].x - 1;
- for (; p >= 0; p--)
- {
- prec = pktEnc.getPrecInfo(t, c, r, p);
- if (prec.rgulx != tx0)
- {
- if (prec.rgulx < minx)
- minx = prec.rgulx;
- if (prec.rgulx > maxx)
- maxx = prec.rgulx;
- }
- if (prec.rguly != ty0)
- {
- if (prec.rguly < miny)
- miny = prec.rguly;
- if (prec.rguly > maxy)
- maxy = prec.rguly;
- }
-
- if (nPrec == 0)
- {
- gcd_x = prec.rgw;
- gcd_y = prec.rgh;
- }
- else
- {
- gcd_x = MathUtil.gcd(gcd_x, prec.rgw);
- gcd_y = MathUtil.gcd(gcd_y, prec.rgh);
- }
- nPrec++;
- } // precincts
- } // resolution levels
- } // components
-
- if (nPrec == 0)
- {
- throw new System.ApplicationException("Image cannot have no precinct");
- }
-
- int pyend = (maxy - miny) / gcd_y + 1;
- int pxend = (maxx - minx) / gcd_x + 1;
- int x, y;
- for (int r = rs; r < re; r++)
- {
- // Resolution levels
- y = ty0;
- x = tx0;
- for (int py = 0; py <= pyend; py++)
- {
- // Vertical precincts
- for (int px = 0; px <= pxend; px++)
- {
- // Horiz. precincts
- for (int c = cs; c < ce; c++)
- {
- // Components
- mrl = src.getAnSubbandTree(t, c).resLvl;
- if (r > mrl)
- continue;
- if (nextPrec[c][r] >= numPrec[t][c][r].x * numPrec[t][c][r].y)
- {
- continue;
- }
- prec = pktEnc.getPrecInfo(t, c, r, nextPrec[c][r]);
- if ((prec.rgulx != x) || (prec.rguly != y))
- {
- continue;
- }
- for (int l = minlys; l < lye; l++)
- {
- if (r >= lys[c].Length)
- continue;
- if (l < lys[c][r])
- continue;
-
- // set boolean sopUsed here (SOP markers)
- sopUsed = ((System.String)encSpec.sops.getTileDef(t)).Equals("on");
- // set boolean ephUsed here (EPH markers)
- ephUsed = ((System.String)encSpec.ephs.getTileDef(t)).Equals("on");
-
- sb = src.getAnSubbandTree(t, c);
- for (int i = mrl; i > r; i--)
- {
- sb = sb.subb_LL;
- }
-
- threshold = layers[l].rdThreshold;
- findTruncIndices(l, c, r, t, sb, threshold, nextPrec[c][r]);
-
- hBuff = pktEnc.encodePacket(l + 1, c, r, t, cblks[t][c][r], truncIdxs[t][l][c][r], hBuff, bBuff, nextPrec[c][r]);
-
- if (pktEnc.PacketWritable)
- {
- bsWriter.writePacketHead(hBuff.Buffer, hBuff.Length, false, sopUsed, ephUsed);
- bsWriter.writePacketBody(pktEnc.LastBodyBuf, pktEnc.LastBodyLen, false, pktEnc.ROIinPkt, pktEnc.ROILen);
- }
- } // layers
- nextPrec[c][r]++;
- } // Components
- if (px != pxend)
- {
- x = minx + px * gcd_x;
- }
- else
- {
- x = tx0;
- }
- } // Horizontal precincts
- if (py != pyend)
- {
- y = miny + py * gcd_y;
- }
- else
- {
- y = ty0;
- }
- } // Vertical precincts
- } // Resolution levels
-
- // Check that all precincts have been written
- for (int c = cs; c < ce; c++)
- {
- mrl = src.getAnSubbandTree(t, c).resLvl;
- for (int r = rs; r < re; r++)
- {
- if (r > mrl)
- continue;
- if (nextPrec[c][r] < numPrec[t][c][r].x * numPrec[t][c][r].y - 1)
- {
- throw new System.ApplicationException("JJ2000 bug: One precinct at least has " + "not been written for resolution level " + r + " of component " + c + " in tile " + t + ".");
- }
- }
- }
- }
-
- /// This function implements the rate-distortion optimization algorithm.
- /// It saves the state of any previously generated bit-stream layers and
- /// then simulate the formation of a new layer in the bit stream as often
- /// as necessary to find the smallest rate-distortion threshold such that
- /// the total number of bytes required to represent the layer does not
- /// exceed `maxBytes' minus `prevBytes'. It then restores the state of any
- /// previously generated bit-stream layers and returns the threshold.
- ///
- ///
- /// The index of the current layer
- ///
- ///
- /// The maximum admissible slope value. Normally the threshold
- /// slope of the previous layer.
- ///
- ///
- /// The maximum number of bytes that can be written. It
- /// includes the length of the current layer bistream length and all the
- /// previous layers bit streams.
- ///
- ///
- /// The number of bytes of all the previous layers.
- ///
- ///
- /// The value of the slope threshold.
- ///
- ///
- private float optimizeBitstreamLayer(int layerIdx, float fmaxt, int maxBytes, int prevBytes)
- {
-
- int nt; // The total number of tiles
- int nc; // The total number of components
- int numLvls; // The total number of resolution levels
- int actualBytes; // Actual number of bytes for a layer
- float fmint; // Minimum of the current threshold interval
- float ft; // Current threshold
- SubbandAn sb; // Current subband
- BitOutputBuffer hBuff; // The packet head buffer
- byte[] bBuff; // The packet body buffer
- int sidx; // The index in the summary table
- bool sopUsed; // Should SOP markers be used ?
- bool ephUsed; // Should EPH markers be used ?
- //int precinctIdx; // Precinct index for current packet
- int nPrec; // Number of precincts in the current resolution level
-
- // Save the packet encoder state
- pktEnc.save();
-
- nt = src.getNumTiles();
- nc = src.NumComps;
- hBuff = null;
- bBuff = null;
-
- // Estimate the minimum slope to start with from the summary
- // information in 'RDSlopesRates'. This is a real minimum since it
- // does not include the packet head overhead, which is always
- // non-zero.
-
- // Look for the summary entry that gives 'maxBytes' or more data
- for (sidx = RD_SUMMARY_SIZE - 1; sidx > 0; sidx--)
- {
- if (RDSlopesRates[sidx] >= maxBytes)
- {
- break;
- }
- }
- // Get the corresponding minimum slope
- fmint = getSlopeFromSIndex(sidx);
- // Ensure that it is smaller the maximum slope
- if (fmint >= fmaxt)
- {
- sidx--;
- fmint = getSlopeFromSIndex(sidx);
- }
- // If we are using the last entry of the summary, then that
- // corresponds to all the data, Thus, set the minimum slope to 0.
- if (sidx <= 0)
- fmint = 0;
-
- // We look for the best threshold 'ft', which is the lowest threshold
- // that generates no more than 'maxBytes' code bytes.
-
- // The search is done iteratively using a binary split algorithm. We
- // start with 'fmaxt' as the maximum possible threshold, and 'fmint'
- // as the minimum threshold. The threshold 'ft' is calculated as the
- // middle point of 'fmaxt'-'fmint' interval. The 'fmaxt' or 'fmint'
- // bounds are moved according to the number of bytes obtained from a
- // simulation, where 'ft' is used as the threshold.
-
- // We stop whenever the interval is sufficiently small, and thus
- // enough precision is achieved.
-
- // Initialize threshold as the middle point of the interval.
- ft = (fmaxt + fmint) / 2f;
- // If 'ft' reaches 'fmint' it means that 'fmaxt' and 'fmint' are so
- // close that the average is 'fmint', due to rounding. Force it to
- // 'fmaxt' instead, since 'fmint' is normally an exclusive lower
- // bound.
- if (ft <= fmint)
- ft = fmaxt;
-
- do
- {
- // Get the number of bytes used by this layer, if 'ft' is the
- // threshold, by simulation.
- actualBytes = prevBytes;
- src.setTile(0, 0);
-
- for (int t = 0; t < nt; t++)
- {
- for (int c = 0; c < nc; c++)
- {
- // set boolean sopUsed here (SOP markers)
- sopUsed = ((System.String)encSpec.sops.getTileDef(t)).ToUpper().Equals("on".ToUpper());
- // set boolean ephUsed here (EPH markers)
- ephUsed = ((System.String)encSpec.ephs.getTileDef(t)).ToUpper().Equals("on".ToUpper());
-
- // Get LL subband
- sb = (SubbandAn)src.getAnSubbandTree(t, c);
- numLvls = sb.resLvl + 1;
- sb = (SubbandAn)sb.getSubbandByIdx(0, 0);
- //loop on resolution levels
- for (int r = 0; r < numLvls; r++)
- {
-
- nPrec = numPrec[t][c][r].x * numPrec[t][c][r].y;
- for (int p = 0; p < nPrec; p++)
- {
-
- findTruncIndices(layerIdx, c, r, t, sb, ft, p);
- hBuff = pktEnc.encodePacket(layerIdx + 1, c, r, t, cblks[t][c][r], truncIdxs[t][layerIdx][c][r], hBuff, bBuff, p);
-
- if (pktEnc.PacketWritable)
- {
- bBuff = pktEnc.LastBodyBuf;
- actualBytes += bsWriter.writePacketHead(hBuff.Buffer, hBuff.Length, true, sopUsed, ephUsed);
- actualBytes += bsWriter.writePacketBody(bBuff, pktEnc.LastBodyLen, true, pktEnc.ROIinPkt, pktEnc.ROILen);
- }
- } // end loop on precincts
- sb = sb.parentband;
- } // End loop on resolution levels
- } // End loop on components
- } // End loop on tiles
-
- // Move the interval bounds according to simulation result
- if (actualBytes > maxBytes)
- {
- // 'ft' is too low and generates too many bytes, make it the
- // new minimum.
- fmint = ft;
- }
- else
- {
- // 'ft' is too high and does not generate as many bytes as we
- // are allowed too, make it the new maximum.
- fmaxt = ft;
- }
-
- // Update 'ft' for the new iteration as the middle point of the
- // new interval.
- ft = (fmaxt + fmint) / 2f;
- // If 'ft' reaches 'fmint' it means that 'fmaxt' and 'fmint' are
- // so close that the average is 'fmint', due to rounding. Force it
- // to 'fmaxt' instead, since 'fmint' is normally an exclusive
- // lower bound.
- if (ft <= fmint)
- ft = fmaxt;
-
- // Restore previous packet encoder state
- pktEnc.restore();
-
- // We continue to iterate, until the threshold reaches the upper
- // limit of the interval, within a FLOAT_REL_PRECISION relative
- // tolerance, or a FLOAT_ABS_PRECISION absolute tolerance. This is
- // the sign that the interval is sufficiently small.
- }
- while (ft < fmaxt * (1f - FLOAT_REL_PRECISION) && ft < (fmaxt - FLOAT_ABS_PRECISION));
-
- // If we have a threshold which is close to 0, set it to 0 so that
- // everything is taken into the layer. This is to avoid not sending
- // some least significant bit-planes in the lossless case. We use the
- // FLOAT_ABS_PRECISION value as a measure of "close" to 0.
- if (ft <= FLOAT_ABS_PRECISION)
- {
- ft = 0f;
- }
- else
- {
- // Otherwise make the threshold 'fmaxt', just to be sure that we
- // will not send more bytes than allowed.
- ft = fmaxt;
- }
- return ft;
- }
-
- /// This function attempts to estimate a rate-distortion slope threshold
- /// which will achieve a target number of code bytes close the
- /// `targetBytes' value.
- ///
- ///
- /// The target number of bytes for the current layer
- ///
- ///
- /// The previous layer information.
- ///
- ///
- /// The value of the slope threshold for the estimated layer
- ///
- ///
- private float estimateLayerThreshold(int targetBytes, EBCOTLayer lastLayer)
- {
- float log_sl1; // The log of the first slope used for interpolation
- float log_sl2; // The log of the second slope used for interpolation
- float log_len1; // The log of the first length used for interpolation
- float log_len2; // The log of the second length used for interpolation
- float log_isl; // The log of the interpolated slope
- float log_ilen; // Log of the interpolated length
- float log_ab; // Log of actual bytes in last layer
- int sidx; // Index into the summary R-D info array
- float log_off; // The log of the offset proportion
- int tlen; // The corrected target layer length
- float lthresh; // The threshold of the last layer
- float eth; // The estimated threshold
-
- // In order to estimate the threshold we base ourselves in the summary
- // R-D info in RDSlopesRates. In order to use it we must compensate
- // for the overhead of the packet heads. The proportion of overhead is
- // estimated using the last layer simulation results.
-
- // NOTE: the model used in this method is that the slope varies
- // linearly with the log of the rate (i.e. length).
-
- // NOTE: the model used in this method is that the distortion is
- // proprotional to a power of the rate. Thus, the slope is also
- // proportional to another power of the rate. This translates as the
- // log of the slope varies linearly with the log of the rate, which is
- // what we use.
-
- // 1) Find the offset of the length predicted from the summary R-D
- // information, to the actual length by using the last layer.
-
- // We ensure that the threshold we use for estimation actually
- // includes some data.
- lthresh = lastLayer.rdThreshold;
- if (lthresh > maxSlope)
- lthresh = maxSlope;
- // If the slope of the last layer is too small then we just include
- // all the rest (not possible to do better).
- if (lthresh < FLOAT_ABS_PRECISION)
- return 0f;
- sidx = getLimitedSIndexFromSlope(lthresh);
- // If the index is outside of the summary info array use the last two,
- // or first two, indexes, as appropriate
- if (sidx >= RD_SUMMARY_SIZE - 1)
- sidx = RD_SUMMARY_SIZE - 2;
-
- // Get the logs of the lengths and the slopes
-
- if (RDSlopesRates[sidx + 1] == 0)
- {
- // Pathological case, we can not use log of 0. Add
- // RDSlopesRates[sidx]+1 bytes to the rates (just a crude simple
- // solution to this rare case)
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- log_len1 = (float)System.Math.Log((RDSlopesRates[sidx] << 1) + 1);
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- log_len2 = (float)System.Math.Log(RDSlopesRates[sidx] + 1);
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- log_ab = (float)System.Math.Log(lastLayer.actualBytes + RDSlopesRates[sidx] + 1);
- }
- else
- {
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- log_len1 = (float)System.Math.Log(RDSlopesRates[sidx]);
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- log_len2 = (float)System.Math.Log(RDSlopesRates[sidx + 1]);
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- log_ab = (float)System.Math.Log(lastLayer.actualBytes);
- }
-
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- log_sl1 = (float)System.Math.Log(getSlopeFromSIndex(sidx));
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- log_sl2 = (float)System.Math.Log(getSlopeFromSIndex(sidx + 1));
-
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- log_isl = (float)System.Math.Log(lthresh);
-
- log_ilen = log_len1 + (log_isl - log_sl1) * (log_len1 - log_len2) / (log_sl1 - log_sl2);
-
- log_off = log_ab - log_ilen;
-
- // Do not use negative offsets (i.e. offset proportion larger than 1)
- // since that is probably a sign that our model is off. To be
- // conservative use an offset of 0 (i.e. offset proportiojn 1).
- if (log_off < 0)
- log_off = 0f;
-
- // 2) Correct the target layer length by the offset.
-
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- tlen = (int)(targetBytes / (float)System.Math.Exp(log_off));
-
- // 3) Find, from the summary R-D info, the thresholds that generate
- // lengths just above and below our corrected target layer length.
-
- // Look for the index in the summary info array that gives the largest
- // length smaller than the target length
- for (sidx = RD_SUMMARY_SIZE - 1; sidx >= 0; sidx--)
- {
- if (RDSlopesRates[sidx] >= tlen)
- break;
- }
- sidx++;
- // Correct if out of the array
- if (sidx >= RD_SUMMARY_SIZE)
- sidx = RD_SUMMARY_SIZE - 1;
- if (sidx <= 0)
- sidx = 1;
-
- // Get the log of the lengths and the slopes that are just above and
- // below the target length.
-
- if (RDSlopesRates[sidx] == 0)
- {
- // Pathological case, we can not use log of 0. Add
- // RDSlopesRates[sidx-1]+1 bytes to the rates (just a crude simple
- // solution to this rare case)
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- log_len1 = (float)System.Math.Log(RDSlopesRates[sidx - 1] + 1);
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- log_len2 = (float)System.Math.Log((RDSlopesRates[sidx - 1] << 1) + 1);
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- log_ilen = (float)System.Math.Log(tlen + RDSlopesRates[sidx - 1] + 1);
- }
- else
- {
- // Normal case, we can safely take the logs.
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- log_len1 = (float)System.Math.Log(RDSlopesRates[sidx]);
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- log_len2 = (float)System.Math.Log(RDSlopesRates[sidx - 1]);
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- log_ilen = (float)System.Math.Log(tlen);
- }
-
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- log_sl1 = (float)System.Math.Log(getSlopeFromSIndex(sidx));
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- log_sl2 = (float)System.Math.Log(getSlopeFromSIndex(sidx - 1));
-
- // 4) Interpolate the two thresholds to find the target threshold.
-
- log_isl = log_sl1 + (log_ilen - log_len1) * (log_sl1 - log_sl2) / (log_len1 - log_len2);
-
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- eth = (float)System.Math.Exp(log_isl);
-
- // Correct out of bounds results
- if (eth > lthresh)
- eth = lthresh;
- if (eth < FLOAT_ABS_PRECISION)
- eth = 0f;
-
- // Return the estimated threshold
- return eth;
- }
-
- /// This function finds the new truncation points indices for a packet. It
- /// does so by including the data from the code-blocks in the component,
- /// resolution level and tile, associated with a R-D slope which is larger
- /// than or equal to 'fthresh'.
- ///
- ///
- /// The index of the current layer
- ///
- ///
- /// The index of the current component
- ///
- ///
- /// The index of the current resolution level
- ///
- ///
- /// The index of the current tile
- ///
- ///
- /// The LL subband in the resolution level lvlIdx, which is
- /// parent of all the subbands in the packet. Except for resolution level 0
- /// this subband is always a node.
- ///
- ///
- /// The value of the rate-distortion threshold
- ///
- ///
- private void findTruncIndices(int layerIdx, int compIdx, int lvlIdx, int tileIdx, SubbandAn subb, float fthresh, int precinctIdx)
- {
- int minsbi, maxsbi, b, n; // bIdx removed
- //Coord ncblks = null;
- SubbandAn sb;
- CBlkRateDistStats cur_cblk;
- PrecInfo prec = pktEnc.getPrecInfo(tileIdx, compIdx, lvlIdx, precinctIdx);
- Coord cbCoord;
-
- sb = subb;
- while (sb.subb_HH != null)
- {
- sb = sb.subb_HH;
- }
- minsbi = (lvlIdx == 0) ? 0 : 1;
- maxsbi = (lvlIdx == 0) ? 1 : 4;
-
- int yend, xend;
-
- sb = (SubbandAn)subb.getSubbandByIdx(lvlIdx, minsbi);
- for (int s = minsbi; s < maxsbi; s++)
- {
- //loop on subbands
- yend = (prec.cblk[s] != null) ? prec.cblk[s].Length : 0;
- for (int y = 0; y < yend; y++)
- {
- xend = (prec.cblk[s][y] != null) ? prec.cblk[s][y].Length : 0;
- for (int x = 0; x < xend; x++)
- {
- cbCoord = prec.cblk[s][y][x].idx;
- b = cbCoord.x + cbCoord.y * sb.numCb.x;
-
- //Get the current code-block
- cur_cblk = cblks[tileIdx][compIdx][lvlIdx][s][b];
- for (n = 0; n < cur_cblk.nVldTrunc; n++)
- {
- if (cur_cblk.truncSlopes[n] < fthresh)
- {
- break;
- }
- else
- {
- continue;
- }
- }
- // Store the index in the code-block truncIdxs that gives
- // the real truncation index.
- truncIdxs[tileIdx][layerIdx][compIdx][lvlIdx][s][b] = n - 1;
- } // End loop on horizontal code-blocks
- } // End loop on vertical code-blocks
- sb = (SubbandAn)sb.nextSubband();
- } // End loop on subbands
- }
-
- /// Returns the index of a slope for the summary table, limiting to the
- /// admissible values. The index is calculated as RD_SUMMARY_OFF plus the
- /// maximum exponent, base 2, that yields a value not larger than the slope
- /// itself.
- ///
- /// If the value to return is lower than 0, 0 is returned. If it is
- /// larger than the maximum table index, then the maximum is returned.
- ///
- ///
- /// The slope value
- ///
- ///
- /// The index for the summary table of the slope.
- ///
- ///
- private static int getLimitedSIndexFromSlope(float slope)
- {
- int idx;
-
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- idx = (int)System.Math.Floor(System.Math.Log(slope) / LOG2) + RD_SUMMARY_OFF;
-
- if (idx < 0)
- {
- return 0;
- }
- else if (idx >= RD_SUMMARY_SIZE)
- {
- return RD_SUMMARY_SIZE - 1;
- }
- else
- {
- return idx;
- }
- }
-
- /// Returns the minimum slope value associated with a summary table
- /// index. This minimum slope is just 2^(index-RD_SUMMARY_OFF).
- ///
- ///
- /// The summary index value.
- ///
- ///
- /// The minimum slope value associated with a summary table index.
- ///
- ///
- private static float getSlopeFromSIndex(int index)
- {
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- return (float)System.Math.Pow(2, (index - RD_SUMMARY_OFF));
- }
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/entropy/encoder/EntropyCoder.cs b/CSJ2K/j2k/entropy/encoder/EntropyCoder.cs
deleted file mode 100644
index 183a7932..00000000
--- a/CSJ2K/j2k/entropy/encoder/EntropyCoder.cs
+++ /dev/null
@@ -1,279 +0,0 @@
-/*
-* CVS identifier:
-*
-* $Id: EntropyCoder.java,v 1.58 2001/09/20 12:40:30 grosbois Exp $
-*
-* Class: EntropyCoder
-*
-* Description: The abstract class for entropy encoders
-*
-*
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-* */
-using CSJ2K.j2k.image;
-using CSJ2K.j2k.quantization.quantizer;
-using CSJ2K.j2k.util;
-using CSJ2K.j2k.wavelet;
-using CSJ2K.j2k.wavelet.analysis;
-namespace CSJ2K.j2k.entropy.encoder
-{
-
- /// This abstract class provides the general interface for block-based entropy
- /// encoders. The input to the entropy coder is the quantized wavelet
- /// coefficients, or codewords, represented in sign magnitude. The output is a
- /// compressed code-block with rate-distortion information.
- ///
- /// The source of data for objects of this class are 'CBlkQuantDataSrcEnc'
- /// objects.
- ///
- /// For more details on the sign magnitude representation used see the
- /// Quantizer class.
- ///
- /// This class provides default implemenations for most of the methods
- /// (wherever it makes sense), under the assumption that the image and
- /// component dimensions, and the tiles, are not modifed by the entropy
- /// coder. If that is not the case for a particular implementation then the
- /// methods should be overriden.
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- public abstract class EntropyCoder : ImgDataAdapter, CodedCBlkDataSrcEnc
- {
- /// Returns the horizontal offset of the code-block partition. Allowable
- /// values are 0 and 1, nothing else.
- ///
- ///
- virtual public int CbULX
- {
- get
- {
- return src.CbULX;
- }
-
- }
- /// Returns the vertical offset of the code-block partition. Allowable
- /// values are 0 and 1, nothing else.
- ///
- ///
- virtual public int CbULY
- {
- get
- {
- return src.CbULY;
- }
-
- }
- /// Returns the parameters that are used in this class and implementing
- /// classes. It returns a 2D String array. Each of the 1D arrays is for a
- /// different option, and they have 3 elements. The first element is the
- /// option name, the second one is the synopsis, the third one is a long
- /// description of what the parameter is and the fourth is its default
- /// value. The synopsis or description may be 'null', in which case it is
- /// assumed that there is no synopsis or description of the option,
- /// respectively. Null may be returned if no options are supported.
- ///
- ///
- /// the options name, their synopsis and their explanation, or null
- /// if no options are supported.
- ///
- ///
- public static System.String[][] ParameterInfo
- {
- get
- {
- return pinfo;
- }
-
- }
-
- /// The prefix for entropy coder options: 'C'
- public const char OPT_PREFIX = 'C';
-
- /// The list of parameters that is accepted for entropy coding. Options
- /// for entropy coding start with 'C'.
- ///
- //UPGRADE_NOTE: Final was removed from the declaration of 'pinfo'. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- private static readonly System.String[][] pinfo = new System.String[][]{new System.String[]{"Cblksiz", "[] " + "[[] ]", "Specifies the maximum code-block size to use for tile-component. " + "The maximum width and height is 1024, however the surface area " + "(i.e. width x height) must not exceed 4096. The minimum width and " + "height is 4.", "64 64"}, new System.String[]{"Cbypass", "[] on|off" + "[ [] on|off ...]", "Uses the lazy coding mode with the entropy coder. This will bypass " + "the MQ coder for some of the coding passes, where the distribution " + "is often close to uniform. Since the MQ codeword will be " + "terminated " + "at least once per lazy pass, it is important to use an efficient " + "termination algorithm, see the 'Cterm_type' option." + "'on' enables, 'off' disables it.", "off"}, new System.String[]{"CresetMQ", "[] on|off" + "[ [] on|off ...]", "If this is enabled the probability estimates of the MQ coder are " + "reset after each arithmetically coded (i.e. non-lazy) coding pass. " + "'on' enables, 'off' disables it.", "off"}, new System.String[]{"Cterminate", "[] on|off" + "[ [] on|off ...]", "If this is enabled the codeword (raw or MQ) is terminated on a " + "byte boundary after each coding pass. In this case it is important " + "to use an efficient termination algorithm, see the 'Cterm' option. " + "'on' enables, 'off' disables it.", "off"}, new System.String[]{"Ccausal", "[] on|off" + "[ [] on|off ...]", "Uses vertically stripe causal context formation. If this is " + "enabled " + "the context formation process in one stripe is independant of the " + "next stripe (i.e. the one below it). 'on' " + "enables, 'off' disables it.", "off"}, new System.String[]{"Cseg_symbol", "[] on|off" + "[ [] on|off ...]",
- "Inserts an error resilience segmentation symbol in the MQ " + "codeword at the end of " + "each bit-plane (cleanup pass). Decoders can use this " + "information to detect and " + "conceal errors.'on' enables, 'off' disables " + "it.", "off"}, new System.String[]{"Cterm_type", "[] near_opt|easy|predict|full" + "[ [] near_opt|easy|predict|full ...]", "Specifies the algorithm used to terminate the MQ codeword. " + "The most efficient one is 'near_opt', which delivers a codeword " + "which in almost all cases is the shortest possible. The 'easy' is " + "a simpler algorithm that delivers a codeword length that is close " + "to the previous one (in average 1 bit longer). The 'predict' is" + " almost " + "the same as the 'easy' but it leaves error resilient information " + "on " + "the spare least significant bits (in average 3.5 bits), which can " + "be used by a decoder to detect errors. The 'full' algorithm " + "performs a full flush of the MQ coder and is highly inefficient.\n" + "It is important to use a good termination policy since the MQ " + "codeword can be terminated quite often, specially if the 'Cbypass'" + " or " + "'Cterminate' options are enabled (in the normal case it would be " + "terminated once per code-block, while if 'Cterminate' is specified " + "it will be done almost 3 times per bit-plane in each code-block).", "near_opt"}, new System.String[]{"Clen_calc", "[] near_opt|lazy_good|lazy" + "[ [] ...]", "Specifies the algorithm to use in calculating the necessary MQ " + "length for each decoding pass. The best one is 'near_opt', which " + "performs a rather sophisticated calculation and provides the best " + "results. The 'lazy_good' and 'lazy' are very simple algorithms " + "that " + "provide rather conservative results, 'lazy_good' one being " + "slightly " + "better. Do not change this option unless you want to experiment " + "the effect of different length calculation algorithms.", "near_opt"}, new
- System.String[]{"Cpp", "[] [ ] " + "[ [] ...]", "Specifies precinct partition dimensions for tile-component. The " + "first " + "two values apply to the highest resolution and the following ones " + "(if " + "any) apply to the remaining resolutions in decreasing order. If " + "less " + "values than the number of decomposition levels are specified, " + "then the " + "last two values are used for the remaining resolutions.", null}};
-
- /// The source of quantized wavelet coefficients
- protected internal CBlkQuantDataSrcEnc src;
-
- /// Initializes the source of quantized wavelet coefficients.
- ///
- ///
- /// The source of quantized wavelet coefficients.
- ///
- ///
- public EntropyCoder(CBlkQuantDataSrcEnc src) : base(src)
- {
- this.src = src;
- }
-
- /// Returns the code-block width for the specified tile and component.
- ///
- ///
- /// The tile index
- ///
- ///
- /// the component index
- ///
- ///
- /// The code-block width for the specified tile and component
- ///
- ///
- public abstract int getCBlkWidth(int t, int c);
-
- /// Returns the code-block height for the specified tile and component.
- ///
- ///
- /// The tile index
- ///
- ///
- /// the component index
- ///
- ///
- /// The code-block height for the specified tile and component
- ///
- ///
- public abstract int getCBlkHeight(int t, int c);
-
- /// Returns the reversibility of the tile-component data that is provided
- /// by the object. Data is reversible when it is suitable for lossless and
- /// lossy-to-lossless compression.
- ///
- /// Since entropy coders themselves are always reversible, it returns
- /// the reversibility of the data that comes from the 'CBlkQuantDataSrcEnc'
- /// source object (i.e. ROIScaler).
- ///
- ///
- /// Tile index
- ///
- ///
- /// Component index
- ///
- ///
- /// true is the data is reversible, false if not.
- ///
- ///
- ///
- ///
- ///
- public virtual bool isReversible(int t, int c)
- {
- return src.isReversible(t, c);
- }
-
- /// Returns a reference to the root of subband tree structure representing
- /// the subband decomposition for the specified tile-component.
- ///
- ///
- /// The index of the tile.
- ///
- ///
- /// The index of the component.
- ///
- ///
- /// The root of the subband tree structure, see Subband.
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- public virtual SubbandAn getAnSubbandTree(int t, int c)
- {
- return src.getAnSubbandTree(t, c);
- }
-
- /// Creates a EntropyCoder object for the appropriate entropy coding
- /// parameters in the parameter list 'pl', and having 'src' as the source
- /// of quantized data.
- ///
- ///
- /// The source of data to be entropy coded
- ///
- ///
- /// The parameter list (or options).
- ///
- ///
- /// Code-block size specifications
- ///
- ///
- /// Precinct partition specifications
- ///
- ///
- /// By-pass mode specifications
- ///
- ///
- /// MQ-reset specifications
- ///
- ///
- /// Regular termination specifications
- ///
- ///
- /// Causal stripes specifications
- ///
- ///
- /// Error resolution segment symbol use specifications
- ///
- ///
- /// Length computation specifications
- ///
- ///
- /// Termination type specifications
- ///
- ///
- /// If an error occurs while parsing
- /// the options in 'pl'
- ///
- ///
- public static EntropyCoder createInstance(CBlkQuantDataSrcEnc src, ParameterList pl, CBlkSizeSpec cblks, PrecinctSizeSpec pss, StringSpec bms, StringSpec mqrs, StringSpec rts, StringSpec css, StringSpec sss, StringSpec lcs, StringSpec tts)
- {
- // Check parameters
- pl.checkList(OPT_PREFIX, CSJ2K.j2k.util.ParameterList.toNameArray(pinfo));
- return new StdEntropyCoder(src, cblks, pss, bms, mqrs, rts, css, sss, lcs, tts);
- }
- public abstract CSJ2K.j2k.entropy.encoder.CBlkRateDistStats getNextCodeBlock(int param1, CSJ2K.j2k.entropy.encoder.CBlkRateDistStats param2);
- public abstract bool precinctPartitionUsed(int param1, int param2);
- public abstract int getPPX(int param1, int param2, int param3);
- public abstract int getPPY(int param1, int param2, int param3);
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/entropy/encoder/LayersInfo.cs b/CSJ2K/j2k/entropy/encoder/LayersInfo.cs
deleted file mode 100644
index 0a567db3..00000000
--- a/CSJ2K/j2k/entropy/encoder/LayersInfo.cs
+++ /dev/null
@@ -1,250 +0,0 @@
-/*
-* CVS identifier:
-*
-* $Id: LayersInfo.java,v 1.7 2001/04/15 14:31:22 grosbois Exp $
-*
-* Class: LayersInfo
-*
-* Description: Specification of a layer
-*
-*
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-* */
-using System;
-namespace CSJ2K.j2k.entropy.encoder
-{
-
- /// This class stores the specification of a layer distribution in the bit
- /// stream. The specification is made of optimization points and a number of
- /// extra layers to add between the optimization points. Each optimization
- /// point creates a layer which is optimized by the rate allocator to the
- /// specified target bitrate. The extra layers are added by the rate allocator
- /// between the optimized layers, with the difference that they are not
- /// optimized (i.e. they have no precise target bitrate).
- ///
- /// The overall target bitrate for the bit stream is always added as the
- /// last optimization point without any extra layers after it. If there are
- /// some optimization points whose target bitrate is larger than the overall
- /// target bitrate, the overall target bitrate will still appear as the last
- /// optimization point, even though it does not follow the increasing target
- /// bitrate order of the other optimization points. The rate allocator is
- /// responsible for eliminating layers that have target bitrates larger than
- /// the overall target bitrate.
- ///
- /// Optimization points can be added with the addOptPoint() method. It takes
- /// the target bitrate for the optimized layer and the number of extra layers
- /// to add after it.
- ///
- /// Information about the total number of layers, total number of
- /// optimization points, target bitrates, etc. can be obtained with the other
- /// methods.
- ///
- ///
- public class LayersInfo
- {
- /// Returns the overall target bitrate for the entire bit stream.
- ///
- ///
- /// The overall target bitrate
- ///
- ///
- virtual public float TotBitrate
- {
- get
- {
- return totbrate;
- }
-
- }
- /// Returns the total number of layers, according to the layer
- /// specification of this object and the overall target bitrate.
- ///
- ///
- /// The total number of layers, according to the layer spec.
- ///
- ///
- virtual public int TotNumLayers
- {
- get
- {
- return totlyrs;
- }
-
- }
- /// Returns the number of layers to optimize, or optimization points, as
- /// specified by this object.
- ///
- ///
- /// The number of optimization points
- ///
- ///
- virtual public int NOptPoints
- {
- get
- {
- // overall target bitrate is counted as extra
- return nopt + 1;
- }
-
- }
-
- /// The initial size for the arrays: 10
- private const int SZ_INIT = 10;
-
- /// The size increment for the arrays
- private const int SZ_INCR = 5;
-
- /// The total number of layers
- // Starts at 1: overall target bitrate is always an extra optimized layer
- internal int totlyrs = 1;
-
- /// The overall target bitrate, for the whole bit stream
- internal float totbrate;
-
- /// The number of optimized layers, or optimization points, without
- /// counting the extra one coming from the overall target bitrate
- ///
- internal int nopt;
-
- /// The target bitrate to which specified layers should be optimized.
- internal float[] optbrate = new float[SZ_INIT];
-
- /// The number of extra layers to be added after an optimized layer. After
- /// the layer that is optimized to optbrate[i], extralyrs[i] extra layers
- /// should be added. These layers are allocated between the bitrate
- /// optbrate[i] and the next optimized bitrate optbrate[i+1] or, if it does
- /// not exist, the overall target bitrate.
- ///
- internal int[] extralyrs = new int[SZ_INIT];
-
- /// Creates a new LayersInfo object. The overall target bitrate 'brate' is
- /// always an extra optimization point, with no extra layers are after
- /// it. Note that any optimization points that are added with addOptPoint()
- /// are always added before the overall target bitrate.
- ///
- ///
- /// The overall target bitrate for the bit stream
- ///
- ///
- public LayersInfo(float brate)
- {
- if (brate <= 0)
- {
- throw new System.ArgumentException("Overall target bitrate must " + "be a positive number");
- }
- totbrate = brate;
- }
-
- /// Returns the target bitrate of the optmimization point 'n'.
- ///
- ///
- /// The optimization point index (starts at 0).
- ///
- ///
- /// The target bitrate (in bpp) for the optimization point 'n'.
- ///
- ///
- public virtual float getTargetBitrate(int n)
- {
- // overall target bitrate is counted as extra
- return (n < nopt) ? optbrate[n] : totbrate;
- }
-
- /// Returns the number of extra layers to add after the optimization point
- /// 'n', but before optimization point 'n+1'. If there is no optimization
- /// point 'n+1' then they should be added before the overall target
- /// bitrate.
- ///
- ///
- /// The optimization point index (starts at 0).
- ///
- ///
- /// The number of extra (unoptimized) layers to add after the
- /// optimization point 'n'
- ///
- ///
- public virtual int getExtraLayers(int n)
- {
- // overall target bitrate is counted as extra
- return (n < nopt) ? extralyrs[n] : 0;
- }
-
- /// Adds a new optimization point, with target bitrate 'brate' and with
- /// 'elyrs' (unoptimized) extra layers after it. The target bitrate 'brate'
- /// must be larger than the previous optimization point. The arguments are
- /// checked and IllegalArgumentException is thrown if they are not correct.
- ///
- ///
- /// The target bitrate for the optimized layer.
- ///
- ///
- /// The number of extra (unoptimized) layers to add after the
- /// optimized layer.
- ///
- ///
- public virtual void addOptPoint(float brate, int elyrs)
- {
- // Check validity of arguments
- if (brate <= 0)
- {
- throw new System.ArgumentException("Target bitrate must be positive");
- }
- if (elyrs < 0)
- {
- throw new System.ArgumentException("The number of extra layers " + "must be 0 or more");
- }
- if (nopt > 0 && optbrate[nopt - 1] >= brate)
- {
- throw new System.ArgumentException("New optimization point must have " + "a target bitrate higher than the " + "preceding one");
- }
- // Check room for new optimization point
- if (optbrate.Length == nopt)
- {
- // Need more room
- float[] tbr = optbrate;
- int[] tel = extralyrs;
- // both arrays always have same size
- optbrate = new float[optbrate.Length + SZ_INCR];
- extralyrs = new int[extralyrs.Length + SZ_INCR];
- Array.Copy(tbr, 0, optbrate, 0, nopt);
- Array.Copy(tel, 0, extralyrs, 0, nopt);
- }
- // Add new optimization point
- optbrate[nopt] = brate;
- extralyrs[nopt] = elyrs;
- nopt++;
- // Update total number of layers
- totlyrs += 1 + elyrs;
- }
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/entropy/encoder/MQCoder.cs b/CSJ2K/j2k/entropy/encoder/MQCoder.cs
deleted file mode 100644
index 197ea158..00000000
--- a/CSJ2K/j2k/entropy/encoder/MQCoder.cs
+++ /dev/null
@@ -1,1560 +0,0 @@
-/*
-* CVS identifier:
-*
-* $Id: MQCoder.java,v 1.36 2002/01/10 10:31:28 grosbois Exp $
-*
-* Class: MQCoder
-*
-* Description: Class that encodes a number of bits using the
-* MQ arithmetic coder
-*
-*
-* Diego SANTA CRUZ, Jul-26-1999 (improved speed)
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-* */
-using CSJ2K.j2k.util;
-using System;
-namespace CSJ2K.j2k.entropy.encoder
-{
-
- /// This class implements the MQ arithmetic coder. When initialized a specific
- /// state can be specified for each context, which may be adapted to the
- /// probability distribution that is expected for that context.
- ///
- /// The type of length calculation and termination can be chosen at
- /// construction time.
- ///
- /// ---- Tricks that have been tried to improve speed ----
- ///
- ///
1) Merging Qe and mPS and doubling the lookup tables
- ///
- /// Merge the mPS into Qe, as the sign bit (if Qe>=0 the sense of MPS is 0, if
- /// Qe<0 the sense is 1), and double the lookup tables. The first half of the
- /// lookup tables correspond to Qe>=0 (i.e. the sense of MPS is 0) and the
- /// second half to Qe<0 (i.e. the sense of MPS is 1). The nLPS lookup table is
- /// modified to incorporate the changes in the sense of MPS, by making it jump
- /// from the first to the second half and vice-versa, when a change is
- /// specified by the swicthLM lookup table. See JPEG book, section 13.2, page
- /// 225.
- ///
- /// There is NO speed improvement in doing this, actually there is a slight
- /// decrease, probably due to the fact that often Q has to be negated. Also the
- /// fact that a brach of the type "if (bit==mPS[li])" is replaced by two
- /// simpler braches of the type "if (bit==0)" and "if (q<0)" may contribute to
- /// that.
- ///
- /// 2) Removing cT
- ///
- /// It is possible to remove the cT counter by setting a flag bit in the high
- /// bits of the C register. This bit will be automatically shifted left
- /// whenever a renormalization shift occurs, which is equivalent to decreasing
- /// cT. When the flag bit reaches the sign bit (leftmost bit), which is
- /// equivalenet to cT==0, the byteOut() procedure is called. This test can be
- /// done efficiently with "c<0" since C is a signed quantity. Care must be
- /// taken in byteOut() to reset the bit in order to not interfere with other
- /// bits in the C register. See JPEG book, page 228.
- ///
- /// There is NO speed improvement in doing this. I don't really know why since
- /// the number of operations whenever a renormalization occurs is
- /// decreased. Maybe it is due to the number of extra operations in the
- /// byteOut(), terminate() and getNumCodedBytes() procedures.
- ///
- /// 3) Change the convention of MPS and LPS.
- ///
- /// Making the LPS interval be above the MPS interval (MQ coder convention is
- /// the opposite) can reduce the number of operations along the MPS path. In
- /// order to generate the same bit stream as with the MQ convention the output
- /// bytes need to be modified accordingly. The basic rule for this is that C =
- /// (C'^0xFF...FF)-A, where C is the codestream for the MQ convention and C' is
- /// the codestream generated by this other convention. Note that this affects
- /// bit-stuffing as well.
- ///
- /// This has not been tested yet.
- ///
- ///
4) Removing normalization while loop on MPS path
- ///
- /// Since in the MPS path Q is guaranteed to be always greater than 0x4000
- /// (decimal 0.375) it is never necessary to do more than 1 renormalization
- /// shift. Therefore the test of the while loop, and the loop itself, can be
- /// removed.
- ///
- /// 5) Simplifying test on A register
- ///
- /// Since A is always less than or equal to 0xFFFF, the test "(a & 0x8000)==0"
- /// can be replaced by the simplete test "a < 0x8000". This test is simpler in
- /// Java since it involves only 1 operation (although the original test can be
- /// converted to only one operation by smart Just-In-Time compilers)
- ///
- /// This change has been integrated in the decoding procedures.
- ///
- /// 6) Speedup mode
- ///
- /// Implemented a method that uses the speedup mode of the MQ-coder if
- /// possible. This should greately improve performance when coding long runs of
- /// MPS symbols that have high probability. However, to take advantage of this,
- /// the entropy coder implementation has to explicetely use it. The generated
- /// bit stream is the same as if no speedup mode would have been used.
- ///
- /// Implemented but performance not tested yet.
- ///
- /// 7) Multiple-symbol coding
- ///
- /// Since the time spent in a method call is non-negligable, coding several
- /// symbols with one method call reduces the overhead per coded symbol. The
- /// decodeSymbols() method implements this. However, to take advantage of it,
- /// the implementation of the entropy coder has to explicitely use it.
- ///
- /// Implemented but performance not tested yet.
- ///
- ///
- public class MQCoder
- {
- /// Set the length calculation type to the specified type.
- ///
- ///
- /// The type of length calculation to use. One of
- /// 'LENGTH_LAZY', 'LENGTH_LAZY_GOOD' or 'LENGTH_NEAR_OPT'.
- ///
- ///
- virtual public int LenCalcType
- {
- set
- {
- // Verify the ttype and ltype
- if (value != LENGTH_LAZY && value != LENGTH_LAZY_GOOD && value != LENGTH_NEAR_OPT)
- {
- throw new System.ArgumentException("Unrecognized length " + "calculation type code: " + value);
- }
-
- if (value == LENGTH_NEAR_OPT)
- {
- if (savedC == null)
- savedC = new int[SAVED_LEN];
- if (savedCT == null)
- savedCT = new int[SAVED_LEN];
- if (savedA == null)
- savedA = new int[SAVED_LEN];
- if (savedB == null)
- savedB = new int[SAVED_LEN];
- if (savedDelFF == null)
- savedDelFF = new bool[SAVED_LEN];
- }
- this.ltype = value;
- }
-
- }
- /// Set termination type to the specified type.
- ///
- ///
- /// The type of termination to use. One of 'TERM_FULL',
- /// 'TERM_NEAR_OPT', 'TERM_EASY' or 'TERM_PRED_ER'.
- ///
- ///
- virtual public int TermType
- {
- set
- {
- if (value != TERM_FULL && value != TERM_NEAR_OPT && value != TERM_EASY && value != TERM_PRED_ER)
- {
- throw new System.ArgumentException("Unrecognized termination " + "type code: " + value);
- }
- this.ttype = value;
- }
-
- }
- /// Returns the number of contexts in the arithmetic coder.
- ///
- ///
- /// The number of contexts
- ///
- ///
- virtual public int NumCtxts
- {
- get
- {
- return I.Length;
- }
-
- }
- /// Returns the number of bytes that are necessary from the compressed
- /// output stream to decode all the symbols that have been coded this
- /// far. The number of returned bytes does not include anything coded
- /// previous to the last time the 'terminate()' or 'reset()' methods where
- /// called.
- ///
- /// The values returned by this method are then to be used in finishing
- /// the length calculation with the 'finishLengthCalculation()' method,
- /// after compensation of the offset in the number of bytes due to previous
- /// terminated segments.
- ///
- /// This method should not be called if the current coding pass is to be
- /// terminated. The 'terminate()' method should be called instead.
- ///
- /// The calculation is done based on the type of length calculation
- /// specified at the constructor.
- ///
- ///
- /// The number of bytes in the compressed output stream necessary
- /// to decode all the information coded this far.
- ///
- ///
- virtual public int NumCodedBytes
- {
- get
- {
- // NOTE: testing these algorithms for correctness is quite
- // difficult. One way is to modify the rate allocator so that not all
- // bit-planes are output if the distortion estimate for last passes is
- // the same as for the previous ones.
-
- switch (ltype)
- {
-
- case LENGTH_LAZY_GOOD:
- // This one is a bit better than LENGTH_LAZY.
- int bitsInN3Bytes; // The minimum amount of bits that can be
- // stored in the 3 bytes following the current byte buffer 'b'.
-
- if (b >= 0xFE)
- {
- // The byte after b can have a bit stuffed so ther could be
- // one less bit available
- bitsInN3Bytes = 22; // 7 + 8 + 7
- }
- else
- {
- // We are sure that next byte after current byte buffer has no
- // bit stuffing
- bitsInN3Bytes = 23; // 8 + 7 + 8
- }
- if ((11 - cT + 16) <= bitsInN3Bytes)
- {
- return nrOfWrittenBytes + (delFF ? 1 : 0) + 1 + 3;
- }
- else
- {
- return nrOfWrittenBytes + (delFF ? 1 : 0) + 1 + 4;
- }
- //goto case LENGTH_LAZY;
-
- case LENGTH_LAZY:
- // This is the very basic one that appears in the VM text
- if ((27 - cT) <= 22)
- {
- return nrOfWrittenBytes + (delFF ? 1 : 0) + 1 + 3;
- }
- else
- {
- return nrOfWrittenBytes + (delFF ? 1 : 0) + 1 + 4;
- }
- //goto case LENGTH_NEAR_OPT;
-
- case LENGTH_NEAR_OPT:
- // This is the best length calculation implemented in this class.
- // It is almost always optimal. In order to calculate the length
- // it is necessary to know which bytes will follow in the MQ
- // bit stream, so we need to wait until termination to perform it.
- // Save the state to perform the calculation later, in
- // finishLengthCalculation()
- saveState();
- // Return current number of output bytes to use it later in
- // finishLengthCalculation()
- return nrOfWrittenBytes;
-
- default:
- throw new System.ApplicationException("Illegal length calculation type code");
-
- }
- }
-
- }
-
- /// Identifier for the lazy length calculation. The lazy length
- /// calculation is not optimal but is extremely simple.
- ///
- public const int LENGTH_LAZY = 0;
-
- /// Identifier for a very simple length calculation. This provides better
- /// results than the 'LENGTH_LAZY' computation. This is the old length
- /// calculation that was implemented in this class.
- ///
- public const int LENGTH_LAZY_GOOD = 1;
-
- /// Identifier for the near optimal length calculation. This calculation
- /// is more complex than the lazy one but provides an almost optimal length
- /// calculation.
- ///
- public const int LENGTH_NEAR_OPT = 2;
-
- /// The identifier fort the termination that uses a full flush. This is
- /// the less efficient termination.
- ///
- public const int TERM_FULL = 0;
-
- /// The identifier for the termination that uses the near optimal length
- /// calculation to terminate the arithmetic codewrod
- ///
- public const int TERM_NEAR_OPT = 1;
-
- /// The identifier for the easy termination that is simpler than the
- /// 'TERM_NEAR_OPT' one but slightly less efficient.
- ///
- public const int TERM_EASY = 2;
-
- /// The identifier for the predictable termination policy for error
- /// resilience. This is the same as the 'TERM_EASY' one but an special
- /// sequence of bits is embodied in the spare bits for error resilience
- /// purposes.
- ///
- public const int TERM_PRED_ER = 3;
-
- /// The data structures containing the probabilities for the LPS
- //UPGRADE_NOTE: Final was removed from the declaration of 'qe'. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- internal static readonly int[] qe = new int[] { 0x5601, 0x3401, 0x1801, 0x0ac1, 0x0521, 0x0221, 0x5601, 0x5401, 0x4801, 0x3801, 0x3001, 0x2401, 0x1c01, 0x1601, 0x5601, 0x5401, 0x5101, 0x4801, 0x3801, 0x3401, 0x3001, 0x2801, 0x2401, 0x2201, 0x1c01, 0x1801, 0x1601, 0x1401, 0x1201, 0x1101, 0x0ac1, 0x09c1, 0x08a1, 0x0521, 0x0441, 0x02a1, 0x0221, 0x0141, 0x0111, 0x0085, 0x0049, 0x0025, 0x0015, 0x0009, 0x0005, 0x0001, 0x5601 };
-
- /// The indexes of the next MPS
- //UPGRADE_NOTE: Final was removed from the declaration of 'nMPS'. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- internal static readonly int[] nMPS = new int[] { 1, 2, 3, 4, 5, 38, 7, 8, 9, 10, 11, 12, 13, 29, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 45, 46 };
-
- /// The indexes of the next LPS
- //UPGRADE_NOTE: Final was removed from the declaration of 'nLPS'. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- internal static readonly int[] nLPS = new int[] { 1, 6, 9, 12, 29, 33, 6, 14, 14, 14, 17, 18, 20, 21, 14, 14, 15, 16, 17, 18, 19, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 46 };
-
- /// Whether LPS and MPS should be switched
- //UPGRADE_NOTE: Final was removed from the declaration of 'switchLM'. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- internal static readonly int[] switchLM = new int[] { 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
- // Having ints proved to be more efficient than booleans
-
- /// The ByteOutputBuffer used to write the compressed bit stream.
- internal ByteOutputBuffer out_Renamed;
-
- /// The current most probable signal for each context
- internal int[] mPS;
-
- /// The current index of each context
- internal int[] I;
-
- /// The current bit code
- internal int c;
-
- /// The bit code counter
- internal int cT;
-
- /// The current interval
- internal int a;
-
- /// The last encoded byte of data
- internal int b;
-
- /// If a 0xFF byte has been delayed and not yet been written to the output
- /// (in the MQ we can never have more than 1 0xFF byte in a row).
- ///
- internal bool delFF;
-
- /// The number of written bytes so far, excluding any delayed 0xFF
- /// bytes. Upon initialization it is -1 to indicated that the byte buffer
- /// 'b' is empty as well.
- ///
- internal int nrOfWrittenBytes = -1;
-
- /// The initial state of each context
- internal int[] initStates;
-
- /// The termination type to use. One of 'TERM_FULL', 'TERM_NEAR_OPT',
- /// 'TERM_EASY' or 'TERM_PRED_ER'.
- ///
- internal int ttype;
-
- /// The length calculation type to use. One of 'LENGTH_LAZY',
- /// 'LENGTH_LAZY_GOOD', 'LENGTH_NEAR_OPT'.
- ///
- internal int ltype;
-
- /// Saved values of the C register. Used for the LENGTH_NEAR_OPT length
- /// calculation.
- ///
- internal int[] savedC;
-
- /// Saved values of CT counter. Used for the LENGTH_NEAR_OPT length
- /// calculation.
- ///
- internal int[] savedCT;
-
- /// Saved values of the A register. Used for the LENGTH_NEAR_OPT length
- /// calculation.
- ///
- internal int[] savedA;
-
- /// Saved values of the B byte buffer. Used for the LENGTH_NEAR_OPT length
- /// calculation.
- ///
- internal int[] savedB;
-
- /// Saved values of the delFF (i.e. delayed 0xFF) state. Used for the
- /// LENGTH_NEAR_OPT length calculation.
- ///
- internal bool[] savedDelFF;
-
- /// Number of saved states. Used for the LENGTH_NEAR_OPT length
- /// calculation.
- ///
- internal int nSaved;
-
- /// The initial length of the arrays to save sates
- //UPGRADE_NOTE: Final was removed from the declaration of 'SAVED_LEN '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- internal static readonly int SAVED_LEN = 32 * CSJ2K.j2k.entropy.StdEntropyCoderOptions.NUM_PASSES;
-
- /// The increase in length for the arrays to save states
- //UPGRADE_NOTE: Final was removed from the declaration of 'SAVED_INC '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- internal static readonly int SAVED_INC = 4 * CSJ2K.j2k.entropy.StdEntropyCoderOptions.NUM_PASSES;
-
- /// Instantiates a new MQ-coder, with the specified number of contexts and
- /// initial states. The compressed bytestream is written to the 'oStream'
- /// object.
- ///
- ///
- /// where to output the compressed data.
- ///
- ///
- /// The number of contexts used by the MQ coder.
- ///
- ///
- /// The initial state for each context. A reference is kept to
- /// this array to reinitialize the contexts whenever 'reset()' or
- /// 'resetCtxts()' is called.
- ///
- ///
- public MQCoder(ByteOutputBuffer oStream, int nrOfContexts, int[] init)
- {
- out_Renamed = oStream;
-
- // --- INITENC
-
- // Default initialization of the statistics bins is MPS=0 and
- // I=0
- I = new int[nrOfContexts];
- mPS = new int[nrOfContexts];
- initStates = init;
-
- a = 0x8000;
- c = 0;
- if (b == 0xFF)
- {
- cT = 13;
- }
- else
- {
- cT = 12;
- }
-
- resetCtxts();
-
- // End of INITENC ---
- b = 0;
- }
-
- /// This method performs the coding of the symbol 'bit', using context
- /// 'ctxt', 'n' times, using the MQ-coder speedup mode if possible.
- ///
- /// If the symbol 'bit' is the current more probable symbol (MPS) and
- /// qe[ctxt]<=0x4000, and (A-0x8000)>=qe[ctxt], speedup mode will be
- /// used. Otherwise the normal mode will be used. The speedup mode can
- /// significantly improve the speed of arithmetic coding when several MPS
- /// symbols, with a high probability distribution, must be coded with the
- /// same context. The generated bit stream is the same as if the normal mode
- /// was used.
- ///
- /// This method is also faster than the 'codeSymbols()' and
- /// 'codeSymbol()' ones, for coding the same symbols with the same context
- /// several times, when speedup mode can not be used, although not
- /// significantly.
- ///
- ///
- /// The symbol do code, 0 or 1.
- ///
- ///
- /// The context to us in coding the symbol.
- ///
- ///
- /// The number of times that the symbol must be coded.
- ///
- ///
- public void fastCodeSymbols(int bit, int ctxt, int n)
- {
- int q; // cache for context's Qe
- int la; // cache for A register
- int nc; // counter for renormalization shifts
- int ns; // the maximum length of a speedup mode run
- int li; // cache for I[ctxt]
-
- li = I[ctxt]; // cache current index
- q = qe[li]; // retrieve current LPS prob.
-
- if ((q <= 0x4000) && (bit == mPS[ctxt]) && ((ns = (a - 0x8000) / q + 1) > 1))
- {
- // Do speed up mode
- // coding MPS, no conditional exchange can occur and
- // speedup mode is possible for more than 1 symbol
- do
- {
- // do as many speedup runs as necessary
- if (n <= ns)
- {
- // All symbols in this run
- // code 'n' symbols
- la = n * q; // accumulated Q
- a -= la;
- c += la;
- if (a >= 0x8000)
- {
- // no renormalization
- I[ctxt] = li; // save the current state
- return; // done
- }
- I[ctxt] = nMPS[li]; // goto next state and save it
- // -- Renormalization (MPS: no need for while loop)
- a <<= 1; // a is doubled
- c <<= 1; // c is doubled
- cT--;
- if (cT == 0)
- {
- byteOut();
- }
- // -- End of renormalization
- return; // done
- }
- else
- {
- // Not all symbols in this run
- // code 'ns' symbols
- la = ns * q; // accumulated Q
- c += la;
- a -= la;
- // cache li and q for next iteration
- li = nMPS[li];
- q = qe[li]; // New q is always less than current one
- // new I[ctxt] is stored in last run
- // Renormalization always occurs since we exceed 'ns'
- // -- Renormalization (MPS: no need for while loop)
- a <<= 1; // a is doubled
- c <<= 1; // c is doubled
- cT--;
- if (cT == 0)
- {
- byteOut();
- }
- // -- End of renormalization
- n -= ns; // symbols left to code
- ns = (a - 0x8000) / q + 1; // max length of next speedup run
- continue; // goto next iteration
- }
- }
- while (n > 0);
- }
- // end speed up mode
- else
- {
- // No speedup mode
- // Either speedup mode is not possible or not worth doing it
- // because of probable conditional exchange
- // Code everything as in normal mode
- la = a; // cache A register in local variable
- do
- {
- if (bit == mPS[ctxt])
- {
- // -- code MPS
- la -= q; // Interval division associated with MPS coding
- if (la >= 0x8000)
- {
- // Interval big enough
- c += q;
- }
- else
- {
- // Interval too short
- if (la < q)
- {
- // Probabilities are inverted
- la = q;
- }
- else
- {
- c += q;
- }
- // cache new li and q for next iteration
- li = nMPS[li];
- q = qe[li];
- // new I[ctxt] is stored after end of loop
- // -- Renormalization (MPS: no need for while loop)
- la <<= 1; // a is doubled
- c <<= 1; // c is doubled
- cT--;
- if (cT == 0)
- {
- byteOut();
- }
- // -- End of renormalization
- }
- }
- else
- {
- // -- code LPS
- la -= q; // Interval division according to LPS coding
- if (la < q)
- {
- c += q;
- }
- else
- {
- la = q;
- }
- if (switchLM[li] != 0)
- {
- mPS[ctxt] = 1 - mPS[ctxt];
- }
- // cache new li and q for next iteration
- li = nLPS[li];
- q = qe[li];
- // new I[ctxt] is stored after end of loop
- // -- Renormalization
- // sligthly better than normal loop
- nc = 0;
- do
- {
- la <<= 1;
- nc++; // count number of necessary shifts
- }
- while (la < 0x8000);
- if (cT > nc)
- {
- c <<= nc;
- cT -= nc;
- }
- else
- {
- do
- {
- c <<= cT;
- nc -= cT;
- // cT = 0; // not necessary
- byteOut();
- }
- while (cT <= nc);
- c <<= nc;
- cT -= nc;
- }
- // -- End of renormalization
- }
- n--;
- }
- while (n > 0);
- I[ctxt] = li; // store new I[ctxt]
- a = la; // save cached A register
- }
- }
-
- /// This function performs the arithmetic encoding of several symbols
- /// together. The function receives an array of symbols that are to be
- /// encoded and an array containing the contexts with which to encode them.
- ///
- /// The advantage of using this function is that the cost of the method
- /// call is amortized by the number of coded symbols per method call.
- ///
- /// Each context has a current MPS and an index describing what the
- /// current probability is for the LPS. Each bit is encoded and if the
- /// probability of the LPS exceeds .5, the MPS and LPS are switched.
- ///
- ///
- /// An array containing the symbols to be encoded. Valid
- /// symbols are 0 and 1.
- ///
- ///
- /// The context for each of the symbols to be encoded.
- ///
- ///
- /// The number of symbols to encode.
- ///
- ///
- public void codeSymbols(int[] bits, int[] cX, int n)
- {
- int q;
- int li; // local cache of I[context]
- int la;
- int nc;
- int ctxt; // context of current symbol
- int i; // counter
-
- // NOTE: here we could use symbol aggregation to speed things up.
- // It remains to be studied.
-
- la = a; // cache A register in local variable
- for (i = 0; i < n; i++)
- {
- // NOTE: (a<0x8000) is equivalent to ((a&0x8000)==0)
- // since 'a' is always less than or equal to 0xFFFF
-
- // NOTE: conditional exchange guarantees that A for MPS is
- // always greater than 0x4000 (i.e. 0.375)
- // => one renormalization shift is enough for MPS
- // => no need to do a renormalization while loop for MPS
-
- ctxt = cX[i];
- li = I[ctxt];
- q = qe[li]; // Retrieve current LPS prob.
-
- if (bits[i] == mPS[ctxt])
- {
- // -- Code MPS
-
- la -= q; // Interval division associated with MPS coding
-
- if (la >= 0x8000)
- {
- // Interval big enough
- c += q;
- }
- else
- {
- // Interval too short
- if (la < q)
- {
- // Probabilities are inverted
- la = q;
- }
- else
- {
- c += q;
- }
-
- I[ctxt] = nMPS[li];
-
- // -- Renormalization (MPS: no need for while loop)
- la <<= 1; // a is doubled
- c <<= 1; // c is doubled
- cT--;
- if (cT == 0)
- {
- byteOut();
- }
- // -- End of renormalization
- }
- }
- else
- {
- // -- Code LPS
- la -= q; // Interval division according to LPS coding
-
- if (la < q)
- {
- c += q;
- }
- else
- {
- la = q;
- }
- if (switchLM[li] != 0)
- {
- mPS[ctxt] = 1 - mPS[ctxt];
- }
- I[ctxt] = nLPS[li];
-
- // -- Renormalization
-
- // sligthly better than normal loop
- nc = 0;
- do
- {
- la <<= 1;
- nc++; // count number of necessary shifts
- }
- while (la < 0x8000);
- if (cT > nc)
- {
- c <<= nc;
- cT -= nc;
- }
- else
- {
- do
- {
- c <<= cT;
- nc -= cT;
- // cT = 0; // not necessary
- byteOut();
- }
- while (cT <= nc);
- c <<= nc;
- cT -= nc;
- }
-
- // -- End of renormalization
- }
- }
- a = la; // save cached A register
- }
-
-
- /// This function performs the arithmetic encoding of one symbol. The
- /// function receives a bit that is to be encoded and a context with which
- /// to encode it.
- ///
- /// Each context has a current MPS and an index describing what the
- /// current probability is for the LPS. Each bit is encoded and if the
- /// probability of the LPS exceeds .5, the MPS and LPS are switched.
- ///
- ///
- /// The symbol to be encoded, must be 0 or 1.
- ///
- ///
- /// the context with which to encode the symbol.
- ///
- ///
- public void codeSymbol(int bit, int context)
- {
- int q;
- int li; // local cache of I[context]
- int la;
- int n;
-
- // NOTE: (a < 0x8000) is equivalent to ((a & 0x8000)==0)
- // since 'a' is always less than or equal to 0xFFFF
-
- // NOTE: conditional exchange guarantees that A for MPS is
- // always greater than 0x4000 (i.e. 0.375)
- // => one renormalization shift is enough for MPS
- // => no need to do a renormalization while loop for MPS
-
- li = I[context];
- q = qe[li]; // Retrieve current LPS prob.
-
- if (bit == mPS[context])
- {
- // -- Code MPS
-
- a -= q; // Interval division associated with MPS coding
-
- if (a >= 0x8000)
- {
- // Interval big enough
- c += q;
- }
- else
- {
- // Interval too short
- if (a < q)
- {
- // Probabilities are inverted
- a = q;
- }
- else
- {
- c += q;
- }
-
- I[context] = nMPS[li];
-
- // -- Renormalization (MPS: no need for while loop)
- a <<= 1; // a is doubled
- c <<= 1; // c is doubled
- cT--;
- if (cT == 0)
- {
- byteOut();
- }
- // -- End of renormalization
- }
- }
- else
- {
- // -- Code LPS
-
- la = a; // cache A register in local variable
- la -= q; // Interval division according to LPS coding
-
- if (la < q)
- {
- c += q;
- }
- else
- {
- la = q;
- }
- if (switchLM[li] != 0)
- {
- mPS[context] = 1 - mPS[context];
- }
- I[context] = nLPS[li];
-
- // -- Renormalization
-
- // sligthly better than normal loop
- n = 0;
- do
- {
- la <<= 1;
- n++; // count number of necessary shifts
- }
- while (la < 0x8000);
- if (cT > n)
- {
- c <<= n;
- cT -= n;
- }
- else
- {
- do
- {
- c <<= cT;
- n -= cT;
- // cT = 0; // not necessary
- byteOut();
- }
- while (cT <= n);
- c <<= n;
- cT -= n;
- }
-
- // -- End of renormalization
- a = la; // save cached A register
- }
- }
-
- /// This function puts one byte of compressed bits in the output stream.
- /// The highest 8 bits of c are then put in b to be the next byte to
- /// write. This method delays the output of any 0xFF bytes until a non 0xFF
- /// byte has to be written to the output bit stream (the 'delFF' variable
- /// signals if there is a delayed 0xff byte).
- ///
- ///
- private void byteOut()
- {
- if (nrOfWrittenBytes >= 0)
- {
- if (b == 0xFF)
- {
- // Delay 0xFF byte
- delFF = true;
- b = SupportClass.URShift(c, 20);
- c &= 0xFFFFF;
- cT = 7;
- }
- else if (c < 0x8000000)
- {
- // Write delayed 0xFF bytes
- if (delFF)
- {
- out_Renamed.write(0xFF);
- delFF = false;
- nrOfWrittenBytes++;
- }
- out_Renamed.write(b);
- nrOfWrittenBytes++;
- b = SupportClass.URShift(c, 19);
- c &= 0x7FFFF;
- cT = 8;
- }
- else
- {
- b++;
- if (b == 0xFF)
- {
- // Delay 0xFF byte
- delFF = true;
- c &= 0x7FFFFFF;
- b = SupportClass.URShift(c, 20);
- c &= 0xFFFFF;
- cT = 7;
- }
- else
- {
- // Write delayed 0xFF bytes
- if (delFF)
- {
- out_Renamed.write(0xFF);
- delFF = false;
- nrOfWrittenBytes++;
- }
- out_Renamed.write(b);
- nrOfWrittenBytes++;
- b = ((SupportClass.URShift(c, 19)) & 0xFF);
- c &= 0x7FFFF;
- cT = 8;
- }
- }
- }
- else
- {
- // NOTE: carry bit can never be set if the byte buffer was empty
- b = (SupportClass.URShift(c, 19));
- c &= 0x7FFFF;
- cT = 8;
- nrOfWrittenBytes++;
- }
- }
-
- /// This function flushes the remaining encoded bits and makes sure that
- /// enough information is written to the bit stream to be able to finish
- /// decoding, and then it reinitializes the internal state of the MQ coder
- /// but without modifying the context states.
- ///
- /// After calling this method the 'finishLengthCalculation()' method
- /// should be called, after compensating the returned length for the length
- /// of previous coded segments, so that the length calculation is
- /// finalized.
- ///
- /// The type of termination used depends on the one specified at the
- /// constructor.
- ///
- ///
- /// The length of the arithmetic codeword after termination, in
- /// bytes.
- ///
- ///
- public virtual int terminate()
- {
- switch (ttype)
- {
-
- case TERM_FULL:
- //sets the remaining bits of the last byte of the coded bits.
- int tempc = c + a;
- c = c | 0xFFFF;
- if (c >= tempc)
- {
- c = c - 0x8000;
- }
-
- int remainingBits = 27 - cT;
-
- // Flushes remainingBits
- do
- {
- c <<= cT;
- if (b != 0xFF)
- {
- remainingBits -= 8;
- }
- else
- {
- remainingBits -= 7;
- }
- byteOut();
- }
- while (remainingBits > 0);
-
- b |= (1 << (-remainingBits)) - 1;
- if (b == 0xFF)
- {
- // Delay 0xFF bytes
- delFF = true;
- }
- else
- {
- // Write delayed 0xFF bytes
- if (delFF)
- {
- out_Renamed.write(0xFF);
- delFF = false;
- nrOfWrittenBytes++;
- }
- out_Renamed.write(b);
- nrOfWrittenBytes++;
- }
- break;
-
- case TERM_PRED_ER:
- case TERM_EASY:
- // The predictable error resilient and easy termination are the
- // same, except for the fact that the easy one can modify the
- // spare bits in the last byte to maximize the likelihood of
- // having a 0xFF, while the error resilient one can not touch
- // these bits.
-
- // In the predictable error resilient case the spare bits will be
- // recalculated by the decoder and it will check if they are the
- // same as as in the codestream and then deduce an error
- // probability from there.
-
- int k; // number of bits to push out
-
- k = (11 - cT) + 1;
-
- c <<= cT;
- for (; k > 0; k -= cT, c <<= cT)
- {
- byteOut();
- }
-
- // Make any spare bits 1s if in easy termination
- if (k < 0 && ttype == TERM_EASY)
- {
- // At this stage there is never a carry bit in C, so we can
- // freely modify the (-k) least significant bits.
- b |= (1 << (-k)) - 1;
- }
-
- byteOut(); // Push contents of byte buffer
- break;
-
- case TERM_NEAR_OPT:
-
- // This algorithm terminates in the shortest possible way, besides
- // the fact any previous 0xFF 0x7F sequences are not
- // eliminated. The probabalility of having those sequences is
- // extremely low.
-
- // The calculation of the length is based on the fact that the
- // decoder will pad the codestream with an endless string of
- // (binary) 1s. If the codestream, padded with 1s, is within the
- // bounds of the current interval then correct decoding is
- // guaranteed. The lower inclusive bound of the current interval
- // is the value of C (i.e. if only lower intervals would be coded
- // in the future). The upper exclusive bound of the current
- // interval is C+A (i.e. if only upper intervals would be coded in
- // the future). We therefore calculate the minimum length that
- // would be needed so that padding with 1s gives a codestream
- // within the interval.
-
- // In general, such a calculation needs the value of the next byte
- // that appears in the codestream. Here, since we are terminating,
- // the next value can be anything we want that lies within the
- // interval, we use the lower bound since this minimizes the
- // length. To calculate the necessary length at any other place
- // than the termination it is necessary to know the next bytes
- // that will appear in the codestream, which involves storing the
- // codestream and the sate of the MQCoder at various points (a
- // worst case approach can be used, but it is much more
- // complicated and the calculated length would be only marginally
- // better than much simple calculations, if not the same).
-
- int cLow;
- int cUp;
- int bLow;
- int bUp;
-
- // Initialize the upper (exclusive) and lower bound (inclusive) of
- // the valid interval (the actual interval is the concatenation of
- // bUp and cUp, and bLow and cLow).
- cLow = c;
- cUp = c + a;
- bLow = bUp = b;
-
- // We start by normalizing the C register to the sate cT = 0
- // (i.e., just before byteOut() is called)
- cLow <<= cT;
- cUp <<= cT;
- // Progate eventual carry bits and reset them in Clow, Cup NOTE:
- // carry bit can never be set if the byte buffer was empty so no
- // problem with propagating a carry into an empty byte buffer.
- if ((cLow & (1 << 27)) != 0)
- {
- // Carry bit in cLow
- if (bLow == 0xFF)
- {
- // We can not propagate carry bit, do bit stuffing
- delFF = true; // delay 0xFF
- // Get next byte buffer
- bLow = SupportClass.URShift(cLow, 20);
- bUp = SupportClass.URShift(cUp, 20);
- cLow &= 0xFFFFF;
- cUp &= 0xFFFFF;
- // Normalize to cT = 0
- cLow <<= 7;
- cUp <<= 7;
- }
- else
- {
- // we can propagate carry bit
- bLow++; // propagate
- cLow &= ~(1 << 27); // reset carry in cLow
- }
- }
- if ((cUp & (1 << 27)) != 0)
- {
- bUp++; // propagate
- cUp &= ~(1 << 27); // reset carry
- }
-
- // From now on there can never be a carry bit on cLow, since we
- // always output bLow.
-
- // Loop testing for the condition and doing byte output if they
- // are not met.
- while (true)
- {
- // If decoder's codestream is within interval stop
- // If preceding byte is 0xFF only values [0,127] are valid
- if (delFF)
- {
- // If delayed 0xFF
- if (bLow <= 127 && bUp > 127)
- break;
- // We will write more bytes so output delayed 0xFF now
- out_Renamed.write(0xFF);
- nrOfWrittenBytes++;
- delFF = false;
- }
- else
- {
- // No delayed 0xFF
- if (bLow <= 255 && bUp > 255)
- break;
- }
-
- // Output next byte
- // We could output anything within the interval, but using
- // bLow simplifies things a lot.
-
- // We should not have any carry bit here
-
- // Output bLow
- if (bLow < 255)
- {
- // Transfer byte bits from C to B
- // (if the byte buffer was empty output nothing)
- if (nrOfWrittenBytes >= 0)
- out_Renamed.write(bLow);
- nrOfWrittenBytes++;
- bUp -= bLow;
- bUp <<= 8;
- // Here bLow would be 0
- bUp |= (SupportClass.URShift(cUp, 19)) & 0xFF;
- bLow = (SupportClass.URShift(cLow, 19)) & 0xFF;
- // Clear upper bits (just pushed out) from cUp Clow.
- cLow &= 0x7FFFF;
- cUp &= 0x7FFFF;
- // Goto next state where CT is 0
- cLow <<= 8;
- cUp <<= 8;
- // Here there can be no carry on Cup, Clow
- }
- else
- {
- // bLow = 0xFF
- // Transfer byte bits from C to B
- // Since the byte to output is 0xFF we can delay it
- delFF = true;
- bUp -= bLow;
- bUp <<= 7;
- // Here bLow would be 0
- bUp |= (cUp >> 20) & 0x7F;
- bLow = (cLow >> 20) & 0x7F;
- // Clear upper bits (just pushed out) from cUp Clow.
- cLow &= 0xFFFFF;
- cUp &= 0xFFFFF;
- // Goto next state where CT is 0
- cLow <<= 7;
- cUp <<= 7;
- // Here there can be no carry on Cup, Clow
- }
- }
- break;
-
- default:
- throw new System.ApplicationException("Illegal termination type code");
-
- }
-
- // Reinitialize the state (without modifying the contexts)
- int len;
-
- len = nrOfWrittenBytes;
- a = 0x8000;
- c = 0;
- b = 0;
- cT = 12;
- delFF = false;
- nrOfWrittenBytes = -1;
-
- // Return the terminated length
- return len;
- }
-
- /// Resets a context to the original probability distribution, and sets its
- /// more probable symbol to 0.
- ///
- ///
- /// The number of the context (it starts at 0).
- ///
- ///
- public void resetCtxt(int c)
- {
- I[c] = initStates[c];
- mPS[c] = 0;
- }
-
- /// Resets all contexts to their original probability distribution and sets
- /// all more probable symbols to 0.
- ///
- ///
- public void resetCtxts()
- {
- Array.Copy(initStates, 0, I, 0, I.Length);
- ArrayUtil.intArraySet(mPS, 0);
- }
-
- /// Reinitializes the MQ coder and the underlying 'ByteOutputBuffer' buffer
- /// as if a new object was instantaited. All the data in the
- /// 'ByteOutputBuffer' buffer is erased and the state and contexts of the
- /// MQ coder are reinitialized). Additionally any saved MQ states are
- /// discarded.
- ///
- ///
- public void reset()
- {
-
- // Reset the output buffer
- out_Renamed.reset();
-
- a = 0x8000;
- c = 0;
- b = 0;
- if (b == 0xFF)
- cT = 13;
- else
- cT = 12;
- resetCtxts();
- nrOfWrittenBytes = -1;
- delFF = false;
-
- nSaved = 0;
- }
-
- /// Saves the current state of the MQ coder (just the registers, not the
- /// contexts) so that a near optimal length calculation can be performed
- /// later.
- ///
- ///
- private void saveState()
- {
- // Increase capacity if necessary
- if (nSaved == savedC.Length)
- {
- System.Object tmp;
- tmp = savedC;
- savedC = new int[nSaved + SAVED_INC];
- // CONVERSION PROBLEM?
- Array.Copy((System.Array)tmp, 0, savedC, 0, nSaved);
- tmp = savedCT;
- savedCT = new int[nSaved + SAVED_INC];
- Array.Copy((System.Array)tmp, 0, savedCT, 0, nSaved);
- tmp = savedA;
- savedA = new int[nSaved + SAVED_INC];
- Array.Copy((System.Array)tmp, 0, savedA, 0, nSaved);
- tmp = savedB;
- savedB = new int[nSaved + SAVED_INC];
- Array.Copy((System.Array)tmp, 0, savedB, 0, nSaved);
- tmp = savedDelFF;
- savedDelFF = new bool[nSaved + SAVED_INC];
- Array.Copy((System.Array)tmp, 0, savedDelFF, 0, nSaved);
- }
- // Save the current sate
- savedC[nSaved] = c;
- savedCT[nSaved] = cT;
- savedA[nSaved] = a;
- savedB[nSaved] = b;
- savedDelFF[nSaved] = delFF;
- nSaved++;
- }
-
- /// Terminates the calculation of the required length for each coding
- /// pass. This method must be called just after the 'terminate()' one has
- /// been called for each terminated MQ segment.
- ///
- /// The values in 'rates' must have been compensated for any offset due
- /// to previous terminated segments, so that the correct index to the
- /// stored coded data is used.
- ///
- ///
- /// The array containing the values returned by
- /// 'getNumCodedBytes()' for each coding pass.
- ///
- ///
- /// The index in the 'rates' array of the last terminated length.
- ///
- ///
- public virtual void finishLengthCalculation(int[] rates, int n)
- {
- if (ltype != LENGTH_NEAR_OPT)
- {
- // For the simple calculations the only thing we need to do is to
- // ensure that the calculated lengths are no greater than the
- // terminated one
- if (n > 0 && rates[n - 1] > rates[n])
- {
- // We need correction
- int tl = rates[n]; // The terminated length
- n--;
- do
- {
- rates[n--] = tl;
- }
- while (n >= 0 && rates[n] > tl);
- }
- }
- else
- {
- // We need to perform the more sophisticated near optimal
- // calculation.
-
- // The calculation of the length is based on the fact that the
- // decoder will pad the codestream with an endless string of
- // (binary) 1s after termination. If the codestream, padded with
- // 1s, is within the bounds of the current interval then correct
- // decoding is guaranteed. The lower inclusive bound of the
- // current interval is the value of C (i.e. if only lower
- // intervals would be coded in the future). The upper exclusive
- // bound of the current interval is C+A (i.e. if only upper
- // intervals would be coded in the future). We therefore calculate
- // the minimum length that would be needed so that padding with 1s
- // gives a codestream within the interval.
-
- // In order to know what will be appended to the current base of
- // the interval we need to know what is in the MQ bit stream after
- // the current last output byte until the termination. This is why
- // this calculation has to be performed after the MQ segment has
- // been entirely coded and terminated.
-
- int cLow; // lower bound on the C register for correct decoding
- int cUp; // upper bound on the C register for correct decoding
- int bLow; // lower bound on the byte buffer for correct decoding
- int bUp; // upper bound on the byte buffer for correct decoding
- int ridx; // index in the rates array of the pass we are
- // calculating
- int sidx; // index in the saved state array
- int clen; // current calculated length
- bool cdFF; // the current delayed FF state
- int nb; // the next byte of output
- int minlen; // minimum possible length
- int maxlen; // maximum possible length
-
- // Start on the first pass of this segment
- ridx = n - nSaved;
- // Minimum allowable length is length of previous termination
- minlen = (ridx - 1 >= 0) ? rates[ridx - 1] : 0;
- // Maximum possible length is the terminated length
- maxlen = rates[n];
- for (sidx = 0; ridx < n; ridx++, sidx++)
- {
- // Load the initial values of the bounds
- cLow = savedC[sidx];
- cUp = savedC[sidx] + savedA[sidx];
- bLow = savedB[sidx];
- bUp = savedB[sidx];
- // Normalize to cT=0 and propagate and reset any carry bits
- cLow <<= savedCT[sidx];
- if ((cLow & 0x8000000) != 0)
- {
- bLow++;
- cLow &= 0x7FFFFFF;
- }
- cUp <<= savedCT[sidx];
- if ((cUp & 0x8000000) != 0)
- {
- bUp++;
- cUp &= 0x7FFFFFF;
- }
- // Initialize current calculated length
- cdFF = savedDelFF[sidx];
- // rates[ridx] contains the number of bytes already output
- // when the state was saved, compensated for the offset in the
- // output stream.
- clen = rates[ridx] + (cdFF ? 1 : 0);
- while (true)
- {
- // If we are at end of coded data then this is the length
- if (clen >= maxlen)
- {
- clen = maxlen;
- break;
- }
- // Check for sufficiency of coded data
- if (cdFF)
- {
- if (bLow < 128 && bUp >= 128)
- {
- // We are done for this pass
- clen--; // Don't need delayed FF
- break;
- }
- }
- else
- {
- if (bLow < 256 && bUp >= 256)
- {
- // We are done for this pass
- break;
- }
- }
- // Update bounds with next byte of coded data and
- // normalize to cT = 0 again.
- nb = (clen >= minlen) ? out_Renamed.getByte(clen) : 0;
- bLow -= nb;
- bUp -= nb;
- clen++;
- if (nb == 0xFF)
- {
- bLow <<= 7;
- bLow |= (cLow >> 20) & 0x7F;
- cLow &= 0xFFFFF;
- cLow <<= 7;
- bUp <<= 7;
- bUp |= (cUp >> 20) & 0x7F;
- cUp &= 0xFFFFF;
- cUp <<= 7;
- cdFF = true;
- }
- else
- {
- bLow <<= 8;
- bLow |= (cLow >> 19) & 0xFF;
- cLow &= 0x7FFFF;
- cLow <<= 8;
- bUp <<= 8;
- bUp |= (cUp >> 19) & 0xFF;
- cUp &= 0x7FFFF;
- cUp <<= 8;
- cdFF = false;
- }
- // Test again
- }
- // Store the rate found
- rates[ridx] = (clen >= minlen) ? clen : minlen;
- }
- // Reset the saved states
- nSaved = 0;
- }
- }
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/entropy/encoder/PostCompRateAllocator.cs b/CSJ2K/j2k/entropy/encoder/PostCompRateAllocator.cs
deleted file mode 100644
index 6bc2b711..00000000
--- a/CSJ2K/j2k/entropy/encoder/PostCompRateAllocator.cs
+++ /dev/null
@@ -1,368 +0,0 @@
-/*
-* CVS identifier:
-*
-* $Id: PostCompRateAllocator.java,v 1.53 2001/08/28 09:24:47 grosbois Exp $
-*
-* Class: PostCompRateAllocator
-*
-* Description: Generic interface for post-compression
-* rate allocator.
-*
-*
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-* */
-using CSJ2K.j2k.codestream;
-using CSJ2K.j2k.codestream.writer;
-using CSJ2K.j2k.encoder;
-using CSJ2K.j2k.image;
-using CSJ2K.j2k.util;
-namespace CSJ2K.j2k.entropy.encoder
-{
-
- /// This is the abstract class from which post-compression rate allocators
- /// which generate layers should inherit. The source of data is a
- /// 'CodedCBlkDataSrcEnc' which delivers entropy coded blocks with
- /// rate-distortion statistics.
- ///
- /// The post compression rate allocator implementation should create the
- /// layers, according to a rate allocation policy, and send the packets to a
- /// CodestreamWriter. Since the rate allocator sends the packets to the bit
- /// stream then it should output the packets to the bit stream in the order
- /// imposed by the bit stream profiles.
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- public abstract class PostCompRateAllocator : ImgDataAdapter
- {
- /// Keep a reference to the header encoder.
- ///
- ///
- /// The header encoder
- ///
- ///
- virtual public HeaderEncoder HeaderEncoder
- {
- set
- {
- this.headEnc = value;
- }
-
- }
- /// Returns the number of layers that are actually generated.
- ///
- ///
- /// The number of layers generated.
- ///
- ///
- virtual public int NumLayers
- {
- get
- {
- return num_Layers;
- }
-
- }
- /// Returns the parameters that are used in this class and implementing
- /// classes. It returns a 2D String array. Each of the 1D arrays is for a
- /// different option, and they have 3 elements. The first element is the
- /// option name, the second one is the synopsis, the third one is a long
- /// description of what the parameter is and the fourth is its default
- /// value. The synopsis or description may be 'null', in which case it is
- /// assumed that there is no synopsis or description of the option,
- /// respectively. Null may be returned if no options are supported.
- ///
- ///
- /// the options name, their synopsis and their explanation,
- /// or null if no options are supported.
- ///
- ///
- public static System.String[][] ParameterInfo
- {
- get
- {
- return pinfo;
- }
-
- }
-
- /// The prefix for rate allocation options: 'A'
- public const char OPT_PREFIX = 'A';
-
- /// The list of parameters that is accepted for entropy coding. Options
- /// for entropy coding start with 'R'.
- ///
- //UPGRADE_NOTE: Final was removed from the declaration of 'pinfo'. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- private static readonly System.String[][] pinfo = new System.String[][]{new System.String[]{"Aptype", "[] res|layer|res-pos|" + "pos-comp|comp-pos [res_start comp_start layer_end res_end " + "comp_end " + "prog] [[res_start comp_start ly_end res_end comp_end prog] ...] [" + "[] ...]", "Specifies which type of progression should be used when " + "generating " + "the codestream. The 'res' value generates a resolution " + "progressive codestream with the number of layers specified by " + "'Alayers' option. The 'layer' value generates a layer progressive " + "codestream with multiple layers. In any case the rate-allocation " + "algorithm optimizes for best quality in each layer. The quality " + "measure is mean squared error (MSE) or a weighted version of it " + "(WMSE). If no progression type is specified or imposed by other " + "modules, the default value is 'layer'.\n" + "It is also possible to describe progression order changes. In " + "this case, 'res_start' is the index (from 0) of the first " + "resolution " + "level, 'comp_start' is the index (from 0) of the first component, " + "'ly_end' is the index (from 0) of the first layer not included, " + "'res_end' is the index (from 0) of the first resolution level not " + "included, 'comp_end' is index (from 0) of the first component not " + "included and 'prog' is the progression type to be used " + "for the rest of the tile/image. Several progression order changes " + "can be specified, one after the other.", null}, new System.String[]{"Alayers", "[ [+] [] [...]] | sl]", "Explicitly specifies the codestream layer formation parameters. " + "The parameter specifies the bitrate to which the first " + "layer should be optimized. The parameter, if present, " + "specifies the number of extra layers that should be added for " + "scalability. These extra layers are not optimized. " + "Any extra and parameters add more layers, in the " +
- "same way. An additional layer is always added at the end, which" + " is " + "optimized to the overall target bitrate of the bit stream. Any " + "layers (optimized or not) whose target bitrate is higher that the " + "overall target bitrate are silently ignored. The bitrates of the " + "extra layers that are added through the parameter are " + "approximately log-spaced between the other target bitrates. If " + "several [+] constructs appear the " + " parameters " + "must appear in increasing order. The rate allocation algorithm " + "ensures that all coded layers have a minimal reasonable size, if " + "not these layers are silently ignored.\n" + "If the 'sl' (i.e. 'single layer') argument is specified, the " + "generated codestream will" + " only contain one layer (with a bit rate specified thanks to the" + " '-rate' or 'nbytes' options).", "0.015 +20 2.0 +10"}};
-
- /// The source of entropy coded data
- protected internal CodedCBlkDataSrcEnc src;
-
- /// The source of entropy coded data
- protected internal EncoderSpecs encSpec;
-
- /// The number of layers.
- protected internal int num_Layers;
-
- /// The bit-stream writer
- internal CodestreamWriter bsWriter;
-
- /// The header encoder
- internal HeaderEncoder headEnc;
-
- /// Initializes the source of entropy coded data.
- ///
- ///
- /// The source of entropy coded data.
- ///
- ///
- /// The number of layers to create
- ///
- ///
- /// The progressive type, as defined in 'ProgressionType'.
- ///
- ///
- /// The packet bit stream writer.
- ///
- ///
- ///
- ///
- ///
- public PostCompRateAllocator(CodedCBlkDataSrcEnc src, int nl, CodestreamWriter bw, EncoderSpecs encSpec) : base(src)
- {
- this.src = src;
- this.encSpec = encSpec;
- num_Layers = nl;
- bsWriter = bw;
- }
-
- /// Initializes the rate allocation points, taking into account header
- /// overhead and such. This method must be called after the header has been
- /// simulated but before calling the runAndWrite() one. The header must be
- /// rewritten after a call to this method since the number of layers may
- /// change.
- ///
- ///
- /// Whether or not the old syntax is used.
- ///
- ///
- ///
- ///
- ///
- public abstract void initialize();
-
- /// Runs the rate allocation algorithm and writes the data to the
- /// bit stream. This must be called after the initialize() method.
- ///
- ///
- ///
- ///
- ///
- public abstract void runAndWrite();
-
- /// Creates a PostCompRateAllocator object for the appropriate rate
- /// allocation parameters in the parameter list 'pl', having 'src' as the
- /// source of entropy coded data, 'rate' as the target bitrate and 'bw' as
- /// the bit stream writer object.
- ///
- ///
- /// The source of entropy coded data.
- ///
- ///
- /// The parameter lis (or options).
- ///
- ///
- /// The target bitrate for the rate allocation
- ///
- ///
- /// The bit stream writer object, where the bit stream data will
- /// be written.
- ///
- ///
- public static PostCompRateAllocator createInstance(CodedCBlkDataSrcEnc src, ParameterList pl, float rate, CodestreamWriter bw, EncoderSpecs encSpec)
- {
- // Check parameters
- pl.checkList(OPT_PREFIX, CSJ2K.j2k.util.ParameterList.toNameArray(pinfo));
-
- // Construct the layer specification from the 'Alayers' option
- LayersInfo lyrs = parseAlayers(pl.getParameter("Alayers"), rate);
-
- int nTiles = encSpec.nTiles;
- int nComp = encSpec.nComp;
- int numLayers = lyrs.TotNumLayers;
-
- // Parse the progressive type
- encSpec.pocs = new ProgressionSpec(nTiles, nComp, numLayers, encSpec.dls, ModuleSpec.SPEC_TYPE_TILE_COMP, pl);
-
- return new EBCOTRateAllocator(src, lyrs, bw, encSpec, pl);
- }
-
- /// Convenience method that parses the 'Alayers' option.
- ///
- ///
- /// The parameters of the 'Alayers' option
- ///
- ///
- /// The overall target bitrate
- ///
- ///
- /// The layer specification.
- ///
- ///
- private static LayersInfo parseAlayers(System.String params_Renamed, float rate)
- {
- LayersInfo lyrs;
- SupportClass.StreamTokenizerSupport stok;
- bool islayer, ratepending;
- float r;
-
- lyrs = new LayersInfo(rate);
- stok = new SupportClass.StreamTokenizerSupport(new System.IO.StringReader(params_Renamed));
- stok.EOLIsSignificant(false);
-
- try
- {
- stok.NextToken();
- }
- catch (System.IO.IOException)
- {
- throw new System.ApplicationException("An IOException has ocurred where it " + "should never occur");
- }
- ratepending = false;
- islayer = false;
- r = 0; // to keep compiler happy
- while (stok.ttype != SupportClass.StreamTokenizerSupport.TT_EOF)
- {
- switch (stok.ttype)
- {
-
- case SupportClass.StreamTokenizerSupport.TT_NUMBER:
- if (islayer)
- {
- // layer parameter
- try
- {
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- lyrs.addOptPoint(r, (int)stok.nval);
- }
- catch (System.ArgumentException e)
- {
- //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Throwable.getMessage' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'"
- throw new System.ArgumentException("Error in 'Alayers' " + "option: " + e.Message);
- }
- ratepending = false;
- islayer = false;
- }
- else
- {
- // rate parameter
- if (ratepending)
- {
- // Add pending rate parameter
- try
- {
- lyrs.addOptPoint(r, 0);
- }
- catch (System.ArgumentException e)
- {
- //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Throwable.getMessage' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'"
- throw new System.ArgumentException("Error in 'Alayers' " + "option: " + e.Message);
- }
- }
- // Now store new rate parameter
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- r = (float)stok.nval;
- ratepending = true;
- }
- break;
-
- case '+':
- if (!ratepending || islayer)
- {
- throw new System.ArgumentException("Layer parameter without " + "previous rate parameter " + "in 'Alayers' option");
- }
- islayer = true; // Next number is layer parameter
- break;
-
- case SupportClass.StreamTokenizerSupport.TT_WORD:
- try
- {
- stok.NextToken();
- }
- catch (System.IO.IOException)
- {
- throw new System.ApplicationException("An IOException has ocurred where it " + "should never occur");
- }
- if (stok.ttype != SupportClass.StreamTokenizerSupport.TT_EOF)
- {
- throw new System.ArgumentException("'sl' argument of " + "'-Alayers' option must be " + "used alone.");
- }
- break;
-
- default:
- throw new System.ArgumentException("Error parsing 'Alayers' " + "option");
-
- }
- try
- {
- stok.NextToken();
- }
- catch (System.IO.IOException)
- {
- throw new System.ApplicationException("An IOException has ocurred where it " + "should never occur");
- }
- }
- if (islayer)
- {
- throw new System.ArgumentException("Error parsing 'Alayers' " + "option");
- }
- if (ratepending)
- {
- try
- {
- lyrs.addOptPoint(r, 0);
- }
- catch (System.ArgumentException e)
- {
- //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Throwable.getMessage' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'"
- throw new System.ArgumentException("Error in 'Alayers' " + "option: " + e.Message);
- }
- }
- return lyrs;
- }
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/entropy/encoder/StdEntropyCoder.cs b/CSJ2K/j2k/entropy/encoder/StdEntropyCoder.cs
deleted file mode 100644
index 4bb3da74..00000000
--- a/CSJ2K/j2k/entropy/encoder/StdEntropyCoder.cs
+++ /dev/null
@@ -1,3725 +0,0 @@
-/*
-* CVS identifier:
-*
-* $Id: StdEntropyCoder.java,v 1.41 2002/07/04 15:53:32 grosbois Exp $
-*
-* Class: StdEntropyCoder
-*
-* Description: Entropy coding engine of stripes in code-blocks
-*
-*
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-* */
-using CSJ2K.j2k.image;
-using CSJ2K.j2k.quantization.quantizer;
-using CSJ2K.j2k.util;
-using CSJ2K.j2k.wavelet;
-using CSJ2K.j2k.wavelet.analysis;
-using System;
-namespace CSJ2K.j2k.entropy.encoder
-{
-
- /// This class implements the JPEG 2000 entropy coder, which codes stripes in
- /// code-blocks. This entropy coding engine can function in a single-threaded
- /// mode where one code-block is encoded at a time, or in a multi-threaded mode
- /// where multiple code-blocks are entropy coded in parallel. The interface
- /// presented by this class is the same in both modes.
- ///
- /// The number of threads used by this entropy coder is specified by the
- /// "jj2000.j2k.entropy.encoder.StdEntropyCoder.nthreads" Java system
- /// property. If set to "0" the single threaded implementation is used. If set
- /// to 'n' ('n' larger than 0) then 'n' extra threads are started by this class
- /// which are used to encode the code-blocks in parallel (i.e. ideally 'n'
- /// code-blocks will be encoded in parallel at a time). On multiprocessor
- /// machines under a "native threads" Java Virtual Machine implementation each
- /// one of these threads can run on a separate processor speeding up the
- /// encoding time. By default the single-threaded implementation is used. The
- /// multi-threaded implementation currently assumes that the vast majority of
- /// consecutive calls to 'getNextCodeBlock()' will be done on the same
- /// component. If this is not the case, the speed-up that can be expected on
- /// multiprocessor machines might be significantly decreased.
- ///
- /// The code-blocks are rectangular, with dimensions which must be powers of
- /// 2. Each dimension has to be no smaller than 4 and no larger than 256. The
- /// product of the two dimensions (i.e. area of the code-block) may not exceed
- /// 4096.
- ///
- /// Context 0 of the MQ-coder is used as the uniform one (uniform,
- /// non-adaptive probability distribution). Context 1 is used for RLC
- /// coding. Contexts 2-10 are used for zero-coding (ZC), contexts 11-15 are
- /// used for sign-coding (SC) and contexts 16-18 are used for
- /// magnitude-refinement (MR).
- ///
- /// This implementation buffers the symbols and calls the MQ coder only once
- /// per stripe and per coding pass, to reduce the method call overhead.
- ///
- /// This implementation also provides some timing features. They can be
- /// enabled by setting the 'DO_TIMING' constant of this class to true and
- /// recompiling. The timing uses the 'System.currentTimeMillis()' Java API
- /// call, which returns wall clock time, not the actual CPU time used. The
- /// timing results will be printed on the message output. Since the times
- /// reported are wall clock times and not CPU usage times they can not be added
- /// to find the total used time (i.e. some time might be counted in several
- /// places). When timing is disabled ('DO_TIMING' is false) there is no penalty
- /// if the compiler performs some basic optimizations. Even if not the penalty
- /// should be negligeable.
- ///
- /// The source module must implement the CBlkQuantDataSrcEnc interface and
- /// code-block's data is received in a CBlkWTData instance. This modules sends
- /// code-block's information in a CBlkRateDistStats instance.
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- public class StdEntropyCoder : EntropyCoder
- {
-
- /// Whether to collect timing information or not: false. Used as a compile
- /// time directive.
- ///
- private const bool DO_TIMING = false;
-
- /// The cumulative wall time for the entropy coding engine, for each
- /// component. In the single-threaded implementation it is the total time,
- /// in the multi-threaded implementation it is the time spent managing the
- /// compressor threads only.
- ///
- //private long[] time;
-
- /// The Java system property name for the number of threads to use:
- /// jj2000.j2k.entropy.encoder.StdEntropyCoder.nthreads
- ///
- public const System.String THREADS_PROP_NAME = "jj2000.j2k.entropy.encoder.StdEntropyCoder.nthreads";
-
- /// The default value for the property in THREADS_PROP_NAME: 0
- public const System.String DEF_THREADS_NUM = "0";
-
- /// The increase in priority for the compressor threads, currently 3. The
- /// compressor threads will have a priority of THREADS_PRIORITY_INC more
- /// than the priority of the thread calling this class constructor. Used
- /// only in the multi-threaded implementation.
- ///
- public const int THREADS_PRIORITY_INC = 0;
-
- /// The pool of threads, for the threaded implementation. It is null, if
- /// non threaded implementation is used
- ///
- private ThreadPool tPool;
-
- /// The queue of idle compressors. Used in multithreaded
- /// implementation only
- ///
- private System.Collections.ArrayList idleComps;
-
- /// The queue of completed compressors, for each component. Used
- /// in multithreaded implementation only.
- ///
- private System.Collections.ArrayList[] completedComps;
-
- /// The number of busy compressors, for each component. Used in
- /// multithreaded implementation only.
- ///
- private int[] nBusyComps;
-
- /// A flag indicating for each component if all the code-blocks of the *
- /// current tile have been returned. Used in multithreaded implementation
- /// only.
- ///
- private bool[] finishedTileComponent;
-
- /// The MQ coder used, for each thread
- private MQCoder[] mqT;
-
- /// The raw bit output used, for each thread
- private BitToByteOutput[] boutT;
-
- /// The output stream used, for each thread
- private ByteOutputBuffer[] outT;
-
- /// The code-block size specifications
- private CBlkSizeSpec cblks;
-
- /// The precinct partition specifications
- private PrecinctSizeSpec pss;
-
- /// By-pass mode specifications
- public StringSpec bms;
-
- /// MQ reset specifications
- public StringSpec mqrs;
-
- /// Regular termination specifications
- public StringSpec rts;
-
- /// Causal stripes specifications
- public StringSpec css;
-
- /// Error resilience segment symbol use specifications
- public StringSpec sss;
-
- /// The length calculation specifications
- public StringSpec lcs;
-
- /// The termination type specifications
- public StringSpec tts;
-
- /// The options that are turned on, as flag bits. One element for each
- /// tile-component. The options are 'OPT_TERM_PASS', 'OPT_RESET_MQ',
- /// 'OPT_VERT_STR_CAUSAL', 'OPT_BYPASS' and 'OPT_SEG_SYMBOLS' as defined in
- /// the StdEntropyCoderOptions interface
- ///
- ///
- ///
- ///
- ///
- private int[][] opts = null;
-
- /// The length calculation type for each tile-component
- private int[][] lenCalc = null;
-
- /// The termination type for each tile-component
- private int[][] tType = null;
-
- /// Number of bits used for the Zero Coding lookup table
- private const int ZC_LUT_BITS = 8;
-
- /// Zero Coding context lookup tables for the LH global orientation
- //UPGRADE_NOTE: Final was removed from the declaration of 'ZC_LUT_LH '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- private static readonly int[] ZC_LUT_LH = new int[1 << ZC_LUT_BITS];
-
- /// Zero Coding context lookup tables for the HL global orientation
- //UPGRADE_NOTE: Final was removed from the declaration of 'ZC_LUT_HL '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- private static readonly int[] ZC_LUT_HL = new int[1 << ZC_LUT_BITS];
-
- /// Zero Coding context lookup tables for the HH global orientation
- //UPGRADE_NOTE: Final was removed from the declaration of 'ZC_LUT_HH '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- private static readonly int[] ZC_LUT_HH = new int[1 << ZC_LUT_BITS];
-
- /// Number of bits used for the Sign Coding lookup table
- private const int SC_LUT_BITS = 9;
-
- /// Sign Coding context lookup table. The index into the table is a 9 bit
- /// index, which correspond the the value in the 'state' array shifted by
- /// 'SC_SHIFT'. Bits 8-5 are the signs of the horizontal-left,
- /// horizontal-right, vertical-up and vertical-down neighbors,
- /// respectively. Bit 4 is not used (0 or 1 makes no difference). Bits 3-0
- /// are the significance of the horizontal-left, horizontal-right,
- /// vertical-up and vertical-down neighbors, respectively. The least 4 bits
- /// of the value in the lookup table define the context number and the sign
- /// bit defines the "sign predictor".
- ///
- //UPGRADE_NOTE: Final was removed from the declaration of 'SC_LUT '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- private static readonly int[] SC_LUT = new int[1 << SC_LUT_BITS];
-
- /// The mask to obtain the context index from the 'SC_LUT'
- private const int SC_LUT_MASK = (1 << 4) - 1;
-
- /// The shift to obtain the sign predictor from the 'SC_LUT'. It must be
- /// an unsigned shift.
- ///
- private const int SC_SPRED_SHIFT = 31;
-
- /// The sign bit for int data
- private const int INT_SIGN_BIT = 1 << 31;
-
- /// The number of bits used for the Magnitude Refinement lookup table
- private const int MR_LUT_BITS = 9;
-
- /// Magnitude Refinement context lookup table
- //UPGRADE_NOTE: Final was removed from the declaration of 'MR_LUT '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- private static readonly int[] MR_LUT = new int[1 << MR_LUT_BITS];
-
- /// The number of contexts used
- private const int NUM_CTXTS = 19;
-
- /// The RLC context
- private const int RLC_CTXT = 1;
-
- /// The UNIFORM context (with a uniform probability distribution which
- /// does not adapt)
- ///
- private const int UNIF_CTXT = 0;
-
- /// The initial states for the MQ coder
- //UPGRADE_NOTE: Final was removed from the declaration of 'MQ_INIT'. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- private static readonly int[] MQ_INIT = new int[] { 46, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
-
- /// The 4 bits of the error resilience segmentation symbol (1010)
- //UPGRADE_NOTE: Final was removed from the declaration of 'SEG_SYMBOLS'. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- private static readonly int[] SEG_SYMBOLS = new int[] { 1, 0, 1, 0 };
-
- /// The 4 contexts for the error resilience segmentation symbol (always
- /// the UNIFORM context, UNIF_CTXT)
- ///
- //UPGRADE_NOTE: Final was removed from the declaration of 'SEG_SYMB_CTXTS '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- private static readonly int[] SEG_SYMB_CTXTS = new int[] { UNIF_CTXT, UNIF_CTXT, UNIF_CTXT, UNIF_CTXT };
-
- /// The state array for each thread. Each element of the state array stores
- /// the state of two coefficients. The lower 16 bits store the state of a
- /// coefficient in row 'i' and column 'j', while the upper 16 bits store
- /// the state of a coefficient in row 'i+1' and column 'j'. The 'i' row is
- /// either the first or the third row of a stripe. This packing of the
- /// states into 32 bit words allows a faster scan of all coefficients on
- /// each coding pass and diminished the amount of data transferred. The
- /// size of the state array is increased by 1 on each side (top, bottom,
- /// left, right) to handle boundary conditions without any special logic.
- ///
- /// The state of a coefficient is stored in the following way in the
- /// lower 16 bits, where bit 0 is the least significant bit. Bit 15 is the
- /// significance of a coefficient (0 if non-significant, 1 otherwise). Bit
- /// 14 is the visited state (i.e. if a coefficient has been coded in the
- /// significance propagation pass of the current bit-plane). Bit 13 is the
- /// "non zero-context" state (i.e. if one of the eight immediate neighbors
- /// is significant it is 1, otherwise is 0). Bits 12 to 9 store the sign of
- /// the already significant left, right, up and down neighbors (1 for
- /// negative, 0 for positive or not yet significant). Bit 8 indicates if
- /// the magnitude refinement has already been applied to the
- /// coefficient. Bits 7 to 4 store the significance of the left, right, up
- /// and down neighbors (1 for significant, 0 for non significant). Bits 3
- /// to 0 store the significance of the diagonal coefficients (up-left,
- /// up-right, down-left and down-right; 1 for significant, 0 for non
- /// significant).
- ///
- /// The upper 16 bits the state is stored as in the lower 16 bits, but
- /// with the bits shifted up by 16.
- ///
- /// The lower 16 bits are referred to as "row 1" ("R1") while the upper
- /// 16 bits are referred to as "row 2" ("R2").
- ///
- ///
- private int[][] stateT;
-
- /* The separation between the upper and lower bits in the state array: 16
- * */
- private const int STATE_SEP = 16;
-
- /// The flag bit for the significance in the state array, for row 1.
- private const int STATE_SIG_R1 = 1 << 15;
-
- /// The flag bit for the "visited" bit in the state array, for row 1.
- private const int STATE_VISITED_R1 = 1 << 14;
-
- /// The flag bit for the "not zero context" bit in the state array, for
- /// row 1. This bit is always the OR of bits STATE_H_L_R1, STATE_H_R_R1,
- /// STATE_V_U_R1, STATE_V_D_R1, STATE_D_UL_R1, STATE_D_UR_R1, STATE_D_DL_R1
- /// and STATE_D_DR_R1.
- ///
- private const int STATE_NZ_CTXT_R1 = 1 << 13;
-
- /// The flag bit for the horizontal-left sign in the state array, for row
- /// 1. This bit can only be set if the STATE_H_L_R1 is also set.
- ///
- private const int STATE_H_L_SIGN_R1 = 1 << 12;
-
- /// The flag bit for the horizontal-right sign in the state array, for
- /// row 1. This bit can only be set if the STATE_H_R_R1 is also set.
- ///
- private const int STATE_H_R_SIGN_R1 = 1 << 11;
-
- /// The flag bit for the vertical-up sign in the state array, for row
- /// 1. This bit can only be set if the STATE_V_U_R1 is also set.
- ///
- private const int STATE_V_U_SIGN_R1 = 1 << 10;
-
- /// The flag bit for the vertical-down sign in the state array, for row
- /// 1. This bit can only be set if the STATE_V_D_R1 is also set.
- ///
- private const int STATE_V_D_SIGN_R1 = 1 << 9;
-
- /// The flag bit for the previous MR primitive applied in the state array,
- /// for row 1.
- ///
- private const int STATE_PREV_MR_R1 = 1 << 8;
-
- /// The flag bit for the horizontal-left significance in the state array,
- /// for row 1.
- ///
- private const int STATE_H_L_R1 = 1 << 7;
-
- /// The flag bit for the horizontal-right significance in the state array,
- /// for row 1.
- ///
- private const int STATE_H_R_R1 = 1 << 6;
-
- /// The flag bit for the vertical-up significance in the state array, for
- /// row 1.
- ///
- private const int STATE_V_U_R1 = 1 << 5;
-
- /// The flag bit for the vertical-down significance in the state array,
- /// for row 1.
- ///
- private const int STATE_V_D_R1 = 1 << 4;
-
- /// The flag bit for the diagonal up-left significance in the state array,
- /// for row 1.
- ///
- private const int STATE_D_UL_R1 = 1 << 3;
-
- /// The flag bit for the diagonal up-right significance in the state
- /// array, for row 1.
- ///
- private const int STATE_D_UR_R1 = 1 << 2;
-
- /// The flag bit for the diagonal down-left significance in the state
- /// array, for row 1.
- ///
- private const int STATE_D_DL_R1 = 1 << 1;
-
- /// The flag bit for the diagonal down-right significance in the state
- /// array , for row 1.
- ///
- private const int STATE_D_DR_R1 = 1;
-
- /// The flag bit for the significance in the state array, for row 2.
- //UPGRADE_NOTE: Final was removed from the declaration of 'STATE_SIG_R2 '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- private static readonly int STATE_SIG_R2 = STATE_SIG_R1 << STATE_SEP;
-
- /// The flag bit for the "visited" bit in the state array, for row 2.
- //UPGRADE_NOTE: Final was removed from the declaration of 'STATE_VISITED_R2 '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- private static readonly int STATE_VISITED_R2 = STATE_VISITED_R1 << STATE_SEP;
-
- /// The flag bit for the "not zero context" bit in the state array, for
- /// row 2. This bit is always the OR of bits STATE_H_L_R2, STATE_H_R_R2,
- /// STATE_V_U_R2, STATE_V_D_R2, STATE_D_UL_R2, STATE_D_UR_R2, STATE_D_DL_R2
- /// and STATE_D_DR_R2.
- ///
- //UPGRADE_NOTE: Final was removed from the declaration of 'STATE_NZ_CTXT_R2 '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- private static readonly int STATE_NZ_CTXT_R2 = STATE_NZ_CTXT_R1 << STATE_SEP;
-
- /// The flag bit for the horizontal-left sign in the state array, for row
- /// 2. This bit can only be set if the STATE_H_L_R2 is also set.
- ///
- //UPGRADE_NOTE: Final was removed from the declaration of 'STATE_H_L_SIGN_R2 '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- private static readonly int STATE_H_L_SIGN_R2 = STATE_H_L_SIGN_R1 << STATE_SEP;
-
- /// The flag bit for the horizontal-right sign in the state array, for
- /// row 2. This bit can only be set if the STATE_H_R_R2 is also set.
- ///
- //UPGRADE_NOTE: Final was removed from the declaration of 'STATE_H_R_SIGN_R2 '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- private static readonly int STATE_H_R_SIGN_R2 = STATE_H_R_SIGN_R1 << STATE_SEP;
-
- /// The flag bit for the vertical-up sign in the state array, for row
- /// 2. This bit can only be set if the STATE_V_U_R2 is also set.
- ///
- //UPGRADE_NOTE: Final was removed from the declaration of 'STATE_V_U_SIGN_R2 '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- private static readonly int STATE_V_U_SIGN_R2 = STATE_V_U_SIGN_R1 << STATE_SEP;
-
- /// The flag bit for the vertical-down sign in the state array, for row
- /// 2. This bit can only be set if the STATE_V_D_R2 is also set.
- ///
- //UPGRADE_NOTE: Final was removed from the declaration of 'STATE_V_D_SIGN_R2 '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- private static readonly int STATE_V_D_SIGN_R2 = STATE_V_D_SIGN_R1 << STATE_SEP;
-
- /// The flag bit for the previous MR primitive applied in the state array,
- /// for row 2.
- ///
- //UPGRADE_NOTE: Final was removed from the declaration of 'STATE_PREV_MR_R2 '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- private static readonly int STATE_PREV_MR_R2 = STATE_PREV_MR_R1 << STATE_SEP;
-
- /// The flag bit for the horizontal-left significance in the state array,
- /// for row 2.
- ///
- //UPGRADE_NOTE: Final was removed from the declaration of 'STATE_H_L_R2 '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- private static readonly int STATE_H_L_R2 = STATE_H_L_R1 << STATE_SEP;
-
- /// The flag bit for the horizontal-right significance in the state array,
- /// for row 2.
- ///
- //UPGRADE_NOTE: Final was removed from the declaration of 'STATE_H_R_R2 '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- private static readonly int STATE_H_R_R2 = STATE_H_R_R1 << STATE_SEP;
-
- /// The flag bit for the vertical-up significance in the state array, for
- /// row 2.
- ///
- //UPGRADE_NOTE: Final was removed from the declaration of 'STATE_V_U_R2 '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- private static readonly int STATE_V_U_R2 = STATE_V_U_R1 << STATE_SEP;
-
- /// The flag bit for the vertical-down significance in the state array,
- /// for row 2.
- ///
- //UPGRADE_NOTE: Final was removed from the declaration of 'STATE_V_D_R2 '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- private static readonly int STATE_V_D_R2 = STATE_V_D_R1 << STATE_SEP;
-
- /// The flag bit for the diagonal up-left significance in the state array,
- /// for row 2.
- ///
- //UPGRADE_NOTE: Final was removed from the declaration of 'STATE_D_UL_R2 '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- private static readonly int STATE_D_UL_R2 = STATE_D_UL_R1 << STATE_SEP;
-
- /// The flag bit for the diagonal up-right significance in the state
- /// array, for row 2.
- ///
- //UPGRADE_NOTE: Final was removed from the declaration of 'STATE_D_UR_R2 '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- private static readonly int STATE_D_UR_R2 = STATE_D_UR_R1 << STATE_SEP;
-
- /// The flag bit for the diagonal down-left significance in the state
- /// array, for row 2.
- ///
- //UPGRADE_NOTE: Final was removed from the declaration of 'STATE_D_DL_R2 '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- private static readonly int STATE_D_DL_R2 = STATE_D_DL_R1 << STATE_SEP;
-
- /// The flag bit for the diagonal down-right significance in the state
- /// array , for row 2.
- ///
- //UPGRADE_NOTE: Final was removed from the declaration of 'STATE_D_DR_R2 '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- private static readonly int STATE_D_DR_R2 = STATE_D_DR_R1 << STATE_SEP;
-
- /// The mask to isolate the significance bits for row 1 and 2 of the state
- /// array.
- ///
- //UPGRADE_NOTE: Final was removed from the declaration of 'SIG_MASK_R1R2 '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- private static readonly int SIG_MASK_R1R2 = STATE_SIG_R1 | STATE_SIG_R2;
-
- /// The mask to isolate the visited bits for row 1 and 2 of the state
- /// array.
- ///
- //UPGRADE_NOTE: Final was removed from the declaration of 'VSTD_MASK_R1R2 '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- private static readonly int VSTD_MASK_R1R2 = STATE_VISITED_R1 | STATE_VISITED_R2;
-
- /// The mask to isolate the bits necessary to identify RLC coding state
- /// (significant, visited and non-zero context, for row 1 and 2).
- ///
- //UPGRADE_NOTE: Final was removed from the declaration of 'RLC_MASK_R1R2 '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- private static readonly int RLC_MASK_R1R2 = STATE_SIG_R1 | STATE_SIG_R2 | STATE_VISITED_R1 | STATE_VISITED_R2 | STATE_NZ_CTXT_R1 | STATE_NZ_CTXT_R2;
-
- /// The mask to obtain the ZC_LUT index from the state information
- // This is needed because of the STATE_V_D_SIGN_R1, STATE_V_U_SIGN_R1,
- // STATE_H_R_SIGN_R1, and STATE_H_L_SIGN_R1 bits.
- private const int ZC_MASK = (1 << 8) - 1;
-
- /// The shift to obtain the SC index to 'SC_LUT' from the state
- /// information, for row 1.
- ///
- private const int SC_SHIFT_R1 = 4;
-
- /// The shift to obtain the SC index to 'SC_LUT' from the state
- /// information, for row 2.
- ///
- //UPGRADE_NOTE: Final was removed from the declaration of 'SC_SHIFT_R2 '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- private static readonly int SC_SHIFT_R2 = SC_SHIFT_R1 + STATE_SEP;
-
- /// The bit mask to isolate the state bits relative to the sign coding
- /// lookup table ('SC_LUT').
- ///
- //UPGRADE_NOTE: Final was removed from the declaration of 'SC_MASK '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- private static readonly int SC_MASK = (1 << SC_LUT_BITS) - 1;
-
- /// The mask to obtain the MR index to 'MR_LUT' from the 'state'
- /// information. It is to be applied after the 'MR_SHIFT'.
- ///
- //UPGRADE_NOTE: Final was removed from the declaration of 'MR_MASK '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- private static readonly int MR_MASK = (1 << MR_LUT_BITS) - 1;
-
- /// The number of bits used to index in the 'fm' lookup table, 7. The 'fs'
- /// table is indexed with one less bit.
- ///
- private const int MSE_LKP_BITS = 7;
-
- private const int MSE_LKP_BITS_M1 = 6;
-
- /// The number of fractional bits used to store data in the 'fm' and 'fs'
- /// lookup tables.
- ///
- private const int MSE_LKP_FRAC_BITS = 13;
-
- /// Distortion estimation lookup table for bits coded using the sign-code
- /// (SC) primative, for lossy coding (i.e. normal).
- ///
- //UPGRADE_NOTE: Final was removed from the declaration of 'FS_LOSSY '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- private static readonly int[] FS_LOSSY = new int[1 << MSE_LKP_BITS_M1];
-
- /// Distortion estimation lookup table for bits coded using the
- /// magnitude-refinement (MR) primative, for lossy coding (i.e. normal)
- ///
- //UPGRADE_NOTE: Final was removed from the declaration of 'FM_LOSSY '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- private static readonly int[] FM_LOSSY = new int[1 << MSE_LKP_BITS];
-
- /// Distortion estimation lookup table for bits coded using the sign-code
- /// (SC) primative, for lossless coding and last bit-plane. This table is
- /// different from 'fs_lossy' since when doing lossless coding the residual
- /// distortion after the last bit-plane is coded is strictly 0.
- ///
- //UPGRADE_NOTE: Final was removed from the declaration of 'FS_LOSSLESS '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- private static readonly int[] FS_LOSSLESS = new int[1 << MSE_LKP_BITS_M1];
-
- /// Distortion estimation lookup table for bits coded using the
- /// magnitude-refinement (MR) primative, for lossless coding and last
- /// bit-plane. This table is different from 'fs_lossless' since when doing
- /// lossless coding the residual distortion after the last bit-plane is
- /// coded is strictly 0.
- ///
- //UPGRADE_NOTE: Final was removed from the declaration of 'FM_LOSSLESS '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- private static readonly int[] FM_LOSSLESS = new int[1 << MSE_LKP_BITS];
-
- /// The buffer for distortion values (avoids reallocation for each
- /// code-block), for each thread.
- ///
- private double[][] distbufT;
-
- /// The buffer for rate values (avoids reallocation for each
- /// code-block), for each thread.
- ///
- private int[][] ratebufT;
-
- /// The buffer for indicating terminated passes (avoids reallocation for
- /// each code-block), for each thread.
- ///
- private bool[][] istermbufT;
-
- /// The source code-block to entropy code (avoids reallocation for each
- /// code-block), for each thread.
- ///
- private CBlkWTData[] srcblkT;
-
- /// Buffer for symbols to send to the MQ-coder, for each thread. Used to
- /// reduce the number of calls to the MQ coder.
- ///
- // NOTE: The symbol buffer has not prooved to be of any great improvement
- // in encoding time, but it does not hurt. It's performance should be
- // better studied under different JVMs.
- private int[][] symbufT;
-
- /// Buffer for the contexts to use when sending buffered symbols to the
- /// MQ-coder, for each thread. Used to reduce the number of calls to the MQ
- /// coder.
- ///
- private int[][] ctxtbufT;
-
- /// boolean used to signal if the precinct partition is used for
- /// each component and each tile.
- ///
- private bool[][] precinctPartition;
-
- //UPGRADE_NOTE: Field 'EnclosingInstance' was added to class 'Compressor' to access its enclosing instance. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1019'"
- /// Class that takes care of running the 'compressCodeBlock()' method with
- /// thread local arguments. Used only in multithreaded implementation.
- ///
- ///
- private class Compressor : IThreadRunnable
- {
- private void InitBlock(StdEntropyCoder enclosingInstance)
- {
- this.enclosingInstance = enclosingInstance;
- }
- private StdEntropyCoder enclosingInstance;
- /// Returns the index of this compressor.
- ///
- ///
- /// The index of this compressor.
- ///
- ///
- virtual public int Idx
- {
- get
- {
- return idx;
- }
-
- }
- public StdEntropyCoder Enclosing_Instance
- {
- get
- {
- return enclosingInstance;
- }
-
- }
- /// The index of this compressor. Used to access thread local
- /// variables
- ///
- //UPGRADE_NOTE: Final was removed from the declaration of 'idx '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- private int idx;
-
- /// The object where to store the compressed code-block
- // Should be private, but some buggy JDK 1.1 compilers complain
- internal CBlkRateDistStats ccb;
-
- /// The component on which to compress
- // Should be private, but some buggy JDK 1.1 compilers complain
- internal int c;
-
- /// The options bitmask to use in compression
- // Should be private, but some buggy JDK 1.1 compilers complain
- internal int options;
-
- /// The reversible flag to use in compression
- // Should be private, but some buggy JDK 1.1 compilers complain
- internal bool rev;
-
- /// The length calculation type to use in compression
- // Should be private, but some buggy JDK 1.1 compilers complain
- internal int lcType;
-
- /// The MQ termination type to use in compression
- // Should be private, but some buggy JDK 1.1 compilers complain
- internal int tType;
-
- /// The cumulative wall time for this compressor, for each
- /// component.
- ///
- //private long[] time;
-
- /// Creates a new compressor object with the given index.
- ///
- ///
- /// The index of this compressor.
- ///
- ///
- internal Compressor(StdEntropyCoder enclosingInstance, int idx)
- {
- InitBlock(enclosingInstance);
- this.idx = idx;
-#if DO_TIMING
- time = new long[Enclosing_Instance.src.NumComps];
-#endif
- }
-
- /// Calls the 'compressCodeBlock()' method with thread local
- /// arguments. Once completed it adds itself to the 'completedComps[c]'
- /// stack, where 'c' is the component for which this compressor is
- /// running. This last step occurs even if exceptions are thrown by the
- /// 'compressCodeBlock()' method.
- ///
- ///
- public virtual void Run()
- {
- // Start the code-block compression
- try
- {
-#if DO_TIMING
- long stime = 0L;
- stime = (System.DateTime.Now.Ticks - 621355968000000000) / 10000;
-#endif
- CSJ2K.j2k.entropy.encoder.StdEntropyCoder.compressCodeBlock(c, ccb, Enclosing_Instance.srcblkT[idx], Enclosing_Instance.mqT[idx], Enclosing_Instance.boutT[idx], Enclosing_Instance.outT[idx], Enclosing_Instance.stateT[idx], Enclosing_Instance.distbufT[idx], Enclosing_Instance.ratebufT[idx], Enclosing_Instance.istermbufT[idx], Enclosing_Instance.symbufT[idx], Enclosing_Instance.ctxtbufT[idx], options, rev, lcType, tType);
-#if DO_TIMING
- time[c] += (System.DateTime.Now.Ticks - 621355968000000000) / 10000 - stime;
-#endif
- }
- finally
- {
- // Join the queue of completed compression, even if exceptions
- // occurred.
- Enclosing_Instance.completedComps[c].Add(this);
- }
- }
- }
-
- /// Instantiates a new entropy coder engine, with the specified source of
- /// data, nominal block width and height.
- ///
- /// If the 'OPT_PRED_TERM' option is given then the MQ termination must
- /// be 'TERM_PRED_ER' or an exception is thrown.
- ///
- ///
- /// The source of data
- ///
- ///
- /// Code-block size specifications
- ///
- ///
- /// Precinct partition specifications
- ///
- ///
- /// By-pass mode specifications
- ///
- ///
- /// MQ-reset specifications
- ///
- ///
- /// Regular termination specifications
- ///
- ///
- /// Causal stripes specifications
- ///
- ///
- /// Error resolution segment symbol use specifications
- ///
- ///
- /// Length computation specifications
- ///
- ///
- /// Termination type specifications
- ///
- ///
- ///
- ///
- ///
- public StdEntropyCoder(CBlkQuantDataSrcEnc src, CBlkSizeSpec cblks, PrecinctSizeSpec pss, StringSpec bms, StringSpec mqrs, StringSpec rts, StringSpec css, StringSpec sss, StringSpec lcs, StringSpec tts) : base(src)
- {
- this.cblks = cblks;
- this.pss = pss;
- this.bms = bms;
- this.mqrs = mqrs;
- this.rts = rts;
- this.css = css;
- this.sss = sss;
- this.lcs = lcs;
- this.tts = tts;
- int maxCBlkWidth, maxCBlkHeight;
- int i; // Counter
- int nt; // The number of threads
- int tsl; // Size for thread structures
-
- // Get the biggest width/height for the code-blocks
- maxCBlkWidth = cblks.MaxCBlkWidth;
- maxCBlkHeight = cblks.MaxCBlkHeight;
-
- nt = Environment.ProcessorCount;
- /*
- // Get the number of threads to use, or default to one
- try
- {
- //UPGRADE_ISSUE: Method 'java.lang.System.getProperty' was not converted. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1000_javalangSystem'"
- nt = System.Int32.Parse(System_Renamed.getProperty(THREADS_PROP_NAME, DEF_THREADS_NUM));
- if (nt < 0)
- throw new System.FormatException();
- }
- catch (System.FormatException e)
- {
- throw new System.ArgumentException("Invalid number of threads " + "for " + "entropy coding in property " + THREADS_PROP_NAME);
- }
- */
-
- // If we do timing create necessary structures
-#if DO_TIMING
- time = new long[src.NumComps];
- // If we are timing make sure that 'finalize' gets called.
- //UPGRADE_ISSUE: Method 'java.lang.System.runFinalizersOnExit' was not converted. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1000_javalangSystem'"
- // CONVERSION PROBLEM?
- //System_Renamed.runFinalizersOnExit(true);
-#endif
- // If using multithreaded implementation get necessasry objects
- if (nt > 0)
- {
- FacilityManager.getMsgLogger().printmsg(CSJ2K.j2k.util.MsgLogger_Fields.INFO, "Using multithreaded entropy coder " + "with " + nt + " compressor threads.");
- tsl = nt;
- tPool = new ThreadPool(nt, (System.Int32)SupportClass.ThreadClass.Current().Priority + THREADS_PRIORITY_INC, "StdEntropyCoder");
- idleComps = new System.Collections.ArrayList();
- completedComps = new System.Collections.ArrayList[src.NumComps];
- nBusyComps = new int[src.NumComps];
- finishedTileComponent = new bool[src.NumComps];
- for (i = src.NumComps - 1; i >= 0; i--)
- {
- completedComps[i] = new System.Collections.ArrayList();
- }
- for (i = 0; i < nt; i++)
- {
- idleComps.Add(new StdEntropyCoder.Compressor(this, i));
- }
- }
- else
- {
- tsl = 1;
- tPool = null;
- idleComps = null;
- completedComps = null;
- nBusyComps = null;
- finishedTileComponent = null;
- }
-
- // Allocate data structures
- outT = new ByteOutputBuffer[tsl];
- mqT = new MQCoder[tsl];
- boutT = new BitToByteOutput[tsl];
- stateT = new int[tsl][];
- for (int i2 = 0; i2 < tsl; i2++)
- {
- stateT[i2] = new int[(maxCBlkWidth + 2) * ((maxCBlkHeight + 1) / 2 + 2)];
- }
- symbufT = new int[tsl][];
- for (int i3 = 0; i3 < tsl; i3++)
- {
- symbufT[i3] = new int[maxCBlkWidth * (CSJ2K.j2k.entropy.StdEntropyCoderOptions.STRIPE_HEIGHT * 2 + 2)];
- }
- ctxtbufT = new int[tsl][];
- for (int i4 = 0; i4 < tsl; i4++)
- {
- ctxtbufT[i4] = new int[maxCBlkWidth * (CSJ2K.j2k.entropy.StdEntropyCoderOptions.STRIPE_HEIGHT * 2 + 2)];
- }
- distbufT = new double[tsl][];
- for (int i5 = 0; i5 < tsl; i5++)
- {
- distbufT[i5] = new double[32 * CSJ2K.j2k.entropy.StdEntropyCoderOptions.NUM_PASSES];
- }
- ratebufT = new int[tsl][];
- for (int i6 = 0; i6 < tsl; i6++)
- {
- ratebufT[i6] = new int[32 * CSJ2K.j2k.entropy.StdEntropyCoderOptions.NUM_PASSES];
- }
- istermbufT = new bool[tsl][];
- for (int i7 = 0; i7 < tsl; i7++)
- {
- istermbufT[i7] = new bool[32 * CSJ2K.j2k.entropy.StdEntropyCoderOptions.NUM_PASSES];
- }
- srcblkT = new CBlkWTData[tsl];
- for (i = 0; i < tsl; i++)
- {
- outT[i] = new ByteOutputBuffer();
- mqT[i] = new MQCoder(outT[i], NUM_CTXTS, MQ_INIT);
- }
- precinctPartition = new bool[src.NumComps][];
- for (int i8 = 0; i8 < src.NumComps; i8++)
- {
- precinctPartition[i8] = new bool[src.getNumTiles()];
- }
-
- // Create the subband description for each component and each tile
- //Subband sb = null;
- Coord numTiles = null;
- int nc = NumComps;
- numTiles = src.getNumTiles(numTiles);
- initTileComp(getNumTiles(), nc);
-
- for (int c = 0; c < nc; c++)
- {
- for (int tY = 0; tY < numTiles.y; tY++)
- {
- for (int tX = 0; tX < numTiles.x; tX++)
- {
- precinctPartition[c][tIdx] = false;
- }
- }
- }
- }
-
-#if DO_TIMING
- /// Prints the timing information, if collected, and calls 'finalize' on
- /// the super class.
- ///
- ///
- ~StdEntropyCoder()
- {
-
- int c;
- System.Text.StringBuilder sb;
-
- if (tPool == null)
- {
- // Single threaded implementation
- sb = new System.Text.StringBuilder("StdEntropyCoder compression wall " + "clock time:");
- for (c = 0; c < time.Length; c++)
- {
- sb.Append("\n component ");
- sb.Append(c);
- sb.Append(": ");
- sb.Append(time[c]);
- sb.Append(" ms");
- }
- FacilityManager.getMsgLogger().printmsg(CSJ2K.j2k.util.MsgLogger_Fields.INFO, sb.ToString());
- }
- else
- {
- // Multithreaded implementation
- Compressor compr;
- MsgLogger msglog = FacilityManager.getMsgLogger();
-
- sb = new System.Text.StringBuilder("StdEntropyCoder manager thread " + "wall clock time:");
- for (c = 0; c < time.Length; c++)
- {
- sb.Append("\n component ");
- sb.Append(c);
- sb.Append(": ");
- sb.Append(time[c]);
- sb.Append(" ms");
- }
- System.Collections.IEnumerator Enum = idleComps.GetEnumerator();
- sb.Append("\nStdEntropyCoder compressor threads wall clock " + "time:");
- //UPGRADE_TODO: Method 'java.util.Enumeration.hasMoreElements' was converted to 'System.Collections.IEnumerator.MoveNext' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilEnumerationhasMoreElements'"
- while (Enum.MoveNext())
- {
- //UPGRADE_TODO: Method 'java.util.Enumeration.nextElement' was converted to 'System.Collections.IEnumerator.Current' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilEnumerationnextElement'"
- compr = (Compressor)(Enum.Current);
- for (c = 0; c < time.Length; c++)
- {
- sb.Append("\n compressor ");
- sb.Append(compr.Idx);
- sb.Append(", component ");
- sb.Append(c);
- sb.Append(": ");
- sb.Append(compr.getTiming(c));
- sb.Append(" ms");
- }
- }
- FacilityManager.getMsgLogger().printmsg(CSJ2K.j2k.util.MsgLogger_Fields.INFO, sb.ToString());
- }
-
- //UPGRADE_NOTE: Call to 'super.finalize()' was removed. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1124'"
- }
-#endif
-
- /// Returns the code-block width for the specified tile and component.
- ///
- ///
- /// The tile index
- ///
- ///
- /// the component index
- ///
- ///
- /// The code-block width for the specified tile and component
- ///
- ///
- public override int getCBlkWidth(int t, int c)
- {
- return cblks.getCBlkWidth(ModuleSpec.SPEC_TILE_COMP, t, c);
- }
-
- /// Returns the code-block height for the specified tile and component.
- ///
- ///
- /// The tile index
- ///
- ///
- /// The component index
- ///
- ///
- /// The code-block height for the specified tile and component.
- ///
- ///
- public override int getCBlkHeight(int t, int c)
- {
- return cblks.getCBlkHeight(ModuleSpec.SPEC_TILE_COMP, t, c);
- }
-
- /// Returns the next coded code-block in the current tile for the specified
- /// component, as a copy (see below). The order in which code-blocks are
- /// returned is not specified. However each code-block is returned only
- /// once and all code-blocks will be returned if the method is called 'N'
- /// times, where 'N' is the number of code-blocks in the tile. After all
- /// the code-blocks have been returned for the current tile calls to this
- /// method will return 'null'.
- ///
- /// When changing the current tile (through 'setTile()' or 'nextTile()')
- /// this method will always return the first code-block, as if this method
- /// was never called before for the new current tile.
- ///
- /// The data returned by this method is always a copy of the internal
- /// data of this object, if any, and it can be modified "in place" without
- /// any problems after being returned.
- ///
- ///
- /// The component for which to return the next code-block.
- ///
- ///
- /// If non-null this object might be used in returning the coded
- /// code-block in this or any subsequent call to this method. If null a new
- /// one is created and returned. If the 'data' array of 'cbb' is not null
- /// it may be reused to return the compressed data.
- ///
- ///
- /// The next coded code-block in the current tile for component
- /// 'n', or null if all code-blocks for the current tile have been
- /// returned.
- ///
- ///
- ///
- ///
- ///
- public override CBlkRateDistStats getNextCodeBlock(int c, CBlkRateDistStats ccb)
- {
-#if DO_TIMING
- long stime = 0L; // Start time for timed sections
-#endif
- if (tPool == null)
- {
- // Use single threaded implementation
- // Get code-block data from source
- srcblkT[0] = src.getNextInternCodeBlock(c, srcblkT[0]);
-
-#if DO_TIMING
- stime = (System.DateTime.Now.Ticks - 621355968000000000) / 10000;
-#endif
-
- if (srcblkT[0] == null)
- {
- // We got all code-blocks
- return null;
- }
- // Initialize thread local variables
- if ((opts[tIdx][c] & CSJ2K.j2k.entropy.StdEntropyCoderOptions.OPT_BYPASS) != 0 && boutT[0] == null)
- {
- boutT[0] = new BitToByteOutput(outT[0]);
- }
- // Initialize output code-block
- if (ccb == null)
- {
- ccb = new CBlkRateDistStats();
- }
- // Compress code-block
- compressCodeBlock(c, ccb, srcblkT[0], mqT[0], boutT[0], outT[0], stateT[0], distbufT[0], ratebufT[0], istermbufT[0], symbufT[0], ctxtbufT[0], opts[tIdx][c], isReversible(tIdx, c), lenCalc[tIdx][c], tType[tIdx][c]);
-
-#if DO_TIMING
- time[c] += (System.DateTime.Now.Ticks - 621355968000000000) / 10000 - stime;
-#endif
-
- // Return result
- return ccb;
- }
- else
- {
- // Use multiple threaded implementation
- int cIdx; // Compressor idx
- Compressor compr; // Compressor
-
-#if DO_TIMING
- stime = (System.DateTime.Now.Ticks - 621355968000000000) / 10000;
-#endif
- // Give data to all free compressors, using the current component
- while (!finishedTileComponent[c] && !(idleComps.Count == 0))
- {
- // Get an idle compressor
- compr = (Compressor)SupportClass.StackSupport.Pop(idleComps);
- cIdx = compr.Idx;
- // Get data for the compressor and wake it up
-#if DO_TIMING
- time[c] += (System.DateTime.Now.Ticks - 621355968000000000) / 10000 - stime;
-#endif
- srcblkT[cIdx] = src.getNextInternCodeBlock(c, srcblkT[cIdx]);
-#if DO_TIMING
- stime = (System.DateTime.Now.Ticks - 621355968000000000) / 10000;
-#endif
- if (srcblkT[cIdx] != null)
- {
- // Initialize thread local variables
- if ((opts[tIdx][c] & CSJ2K.j2k.entropy.StdEntropyCoderOptions.OPT_BYPASS) != 0 && boutT[cIdx] == null)
- {
- boutT[cIdx] = new BitToByteOutput(outT[cIdx]);
- }
- // Initialize output code-block and compressor thread
- if (ccb == null)
- ccb = new CBlkRateDistStats();
- compr.ccb = ccb;
- compr.c = c;
- compr.options = opts[tIdx][c];
- compr.rev = isReversible(tIdx, c);
- compr.lcType = lenCalc[tIdx][c];
- compr.tType = tType[tIdx][c];
- nBusyComps[c]++;
- ccb = null;
- // Send compressor to execution in thread pool
- tPool.runTarget(compr, completedComps[c]);
- }
- else
- {
- // We finished with all the code-blocks in the current
- // tile component
- idleComps.Add(compr);
- finishedTileComponent[c] = true;
- }
- }
- // If there are threads for this component which result has not
- // been returned yet, get it
- if (nBusyComps[c] > 0)
- {
- lock (completedComps[c])
- {
- // If no compressor is done, wait until one is
- if ((completedComps[c].Count == 0))
- {
- try
- {
-#if DO_TIMING
- time[c] += (System.DateTime.Now.Ticks - 621355968000000000) / 10000 - stime;
-#endif
- System.Threading.Monitor.Wait(completedComps[c]);
-#if DO_TIMING
- stime = (System.DateTime.Now.Ticks - 621355968000000000) / 10000;
-#endif
- }
- catch (System.Threading.ThreadInterruptedException)
- {
- }
- }
- // Remove the thread from the completed queue and put it
- // on the idle queue
- compr = (Compressor)SupportClass.StackSupport.Pop(completedComps[c]);
- cIdx = compr.Idx;
- nBusyComps[c]--;
- idleComps.Add(compr);
- // Check targets error condition
- tPool.checkTargetErrors();
- // Get the result of compression and return that.
-#if DO_TIMING
- time[c] += (System.DateTime.Now.Ticks - 621355968000000000) / 10000 - stime;
-#endif
- return compr.ccb;
- }
- }
- else
- {
- // Check targets error condition
- tPool.checkTargetErrors();
- // Printing timing info if necessary
-#if DO_TIMING
- time[c] += (System.DateTime.Now.Ticks - 621355968000000000) / 10000 - stime;
-#endif
- // Nothing is running => no more code-blocks
- return null;
- }
- }
- }
-
- /// Changes the current tile, given the new indexes. An
- /// IllegalArgumentException is thrown if the indexes do not correspond to
- /// a valid tile.
- ///
- /// This default implementation just changes the tile in the source.
- ///
- ///
- /// The horizontal index of the tile.
- ///
- ///
- /// The vertical index of the new tile.
- ///
- ///
- public override void setTile(int x, int y)
- {
- base.setTile(x, y);
- // Reset the tile specific variables
- if (finishedTileComponent != null)
- {
- for (int c = src.NumComps - 1; c >= 0; c--)
- {
- finishedTileComponent[c] = false;
- }
- }
- }
-
- /// Advances to the next tile, in standard scan-line order (by rows then
- /// columns). An NoNextElementException is thrown if the current tile is
- /// the last one (i.e. there is no next tile).
- ///
- /// This default implementation just advances to the next tile in the
- /// source.
- ///
- ///
- public override void nextTile()
- {
- // Reset the tilespecific variables
- if (finishedTileComponent != null)
- {
- for (int c = src.NumComps - 1; c >= 0; c--)
- {
- finishedTileComponent[c] = false;
- }
- }
- base.nextTile();
- }
-
-
- /// Compresses the code-block in 'srcblk' and puts the results in 'ccb',
- /// using the specified options and temporary storage.
- ///
- ///
- /// The component for which to return the next code-block.
- ///
- ///
- /// The object where the compressed data will be stored. If the
- /// 'data' array of 'cbb' is not null it may be reused to return the
- /// compressed data.
- ///
- ///
- /// The code-block data to code
- ///
- ///
- /// The MQ-coder to use
- ///
- ///
- /// The bit level output to use. Used only if 'OPT_BYPASS' is
- /// turned on in the 'options' argument.
- ///
- ///
- /// The byte buffer trough which the compressed data is stored.
- ///
- ///
- /// The state information for the code-block
- ///
- ///
- /// The buffer where to store the distortion at
- /// the end of each coding pass.
- ///
- ///
- /// The buffer where to store the rate (i.e. coded lenth) at
- /// the end of each coding pass.
- ///
- ///
- /// The buffer where to store the terminated flag for each
- /// coding pass.
- ///
- ///
- /// The buffer to hold symbols to send to the MQ coder
- ///
- ///
- /// A buffer to hold the contexts to use in sending the
- /// buffered symbols to the MQ coder.
- ///
- ///
- /// The options to use when coding this code-block
- ///
- ///
- /// The reversible flag. Should be true if the source of this
- /// code-block's data is reversible.
- ///
- ///
- /// The type of length calculation to use with the MQ coder.
- ///
- ///
- /// The type of termination to use with the MQ coder.
- ///
- ///
- ///
- ///
- ///
- static private void compressCodeBlock(int c, CBlkRateDistStats ccb, CBlkWTData srcblk, MQCoder mq, BitToByteOutput bout, ByteOutputBuffer out_Renamed, int[] state, double[] distbuf, int[] ratebuf, bool[] istermbuf, int[] symbuf, int[] ctxtbuf, int options, bool rev, int lcType, int tType)
- {
- // NOTE: This method should not access any non-final instance or
- // static variables, either directly or indirectly through other
- // methods in order to be sure that the method is thread safe.
-
- int[] zc_lut; // The ZC lookup table to use
- int skipbp; // The number of non-significant bit-planes to skip
- int curbp; // The current magnitude bit-plane (starts at 30)
- int[] fm; // The distortion estimation lookup table for MR
- int[] fs; // The distortion estimation lookup table for SC
- int lmb; // The least significant magnitude bit
- int npass; // The number of coding passes, for R-D statistics
- double msew; // The distortion (MSE weight) for the current bit-plane
- double totdist; // The total cumulative distortion decrease
- int ltpidx; // The index of the last pass which is terminated
-
- // Check error-resilient termination
- if ((options & CSJ2K.j2k.entropy.StdEntropyCoderOptions.OPT_PRED_TERM) != 0 && tType != MQCoder.TERM_PRED_ER)
- {
- throw new System.ArgumentException("Embedded error-resilient info " + "in MQ termination option " + "specified but incorrect MQ " + "termination " + "policy specified");
- }
- // Set MQ flags
- mq.LenCalcType = lcType;
- mq.TermType = tType;
-
- lmb = 30 - srcblk.magbits + 1;
- // If there are more bit-planes to code than the implementation
- // bit-depth set lmb to 0
- lmb = (lmb < 0) ? 0 : lmb;
-
- // Reset state
- ArrayUtil.intArraySet(state, 0);
-
- // Find the most significant bit-plane
- skipbp = calcSkipMSBP(srcblk, lmb);
-
- // Initialize output code-block
- ccb.m = srcblk.m;
- ccb.n = srcblk.n;
- ccb.sb = srcblk.sb;
- ccb.nROIcoeff = srcblk.nROIcoeff;
- ccb.skipMSBP = skipbp;
- if (ccb.nROIcoeff != 0)
- {
- ccb.nROIcp = 3 * (srcblk.nROIbp - skipbp - 1) + 1;
- }
- else
- {
- ccb.nROIcp = 0;
- }
-
- // Choose correct ZC lookup table for global orientation
- switch (srcblk.sb.orientation)
- {
-
- case Subband.WT_ORIENT_HL:
- zc_lut = ZC_LUT_HL;
- break;
-
- case Subband.WT_ORIENT_LL:
- case Subband.WT_ORIENT_LH:
- zc_lut = ZC_LUT_LH;
- break;
-
- case Subband.WT_ORIENT_HH:
- zc_lut = ZC_LUT_HH;
- break;
-
- default:
- throw new System.ApplicationException("JJ2000 internal error");
-
- }
-
- // Loop on significant magnitude bit-planes doing the 3 passes
- curbp = 30 - skipbp;
- fs = FS_LOSSY;
- fm = FM_LOSSY;
- msew = System.Math.Pow(2, ((curbp - lmb) << 1) - MSE_LKP_FRAC_BITS) * srcblk.sb.stepWMSE * srcblk.wmseScaling;
- totdist = 0f;
- npass = 0;
- ltpidx = -1;
-
- // First significant bit-plane has only the pass pass
- if (curbp >= lmb)
- {
- // Do we need the "lossless" 'fs' table ?
- if (rev && curbp == lmb)
- {
- fs = FM_LOSSLESS;
- }
- // We terminate if regular termination, last bit-plane, or next
- // bit-plane is "raw".
- istermbuf[npass] = (options & CSJ2K.j2k.entropy.StdEntropyCoderOptions.OPT_TERM_PASS) != 0 || curbp == lmb || ((options & CSJ2K.j2k.entropy.StdEntropyCoderOptions.OPT_BYPASS) != 0 && (31 - CSJ2K.j2k.entropy.StdEntropyCoderOptions.NUM_NON_BYPASS_MS_BP - skipbp) >= curbp);
- totdist += cleanuppass(srcblk, mq, istermbuf[npass], curbp, state, fs, zc_lut, symbuf, ctxtbuf, ratebuf, npass, ltpidx, options) * msew;
- distbuf[npass] = totdist;
- if (istermbuf[npass])
- ltpidx = npass;
- npass++;
- msew *= 0.25;
- curbp--;
- }
- // Other bit-planes have all passes
- while (curbp >= lmb)
- {
- // Do we need the "lossless" 'fs' and 'fm' tables ?
- if (rev && curbp == lmb)
- {
- fs = FS_LOSSLESS;
- fm = FM_LOSSLESS;
- }
-
- // Do the significance propagation pass
- // We terminate if regular termination only
- istermbuf[npass] = (options & CSJ2K.j2k.entropy.StdEntropyCoderOptions.OPT_TERM_PASS) != 0;
- if ((options & CSJ2K.j2k.entropy.StdEntropyCoderOptions.OPT_BYPASS) == 0 || (31 - CSJ2K.j2k.entropy.StdEntropyCoderOptions.NUM_NON_BYPASS_MS_BP - skipbp <= curbp))
- {
- // No bypass coding
- totdist += sigProgPass(srcblk, mq, istermbuf[npass], curbp, state, fs, zc_lut, symbuf, ctxtbuf, ratebuf, npass, ltpidx, options) * msew;
- }
- else
- {
- // Bypass ("raw") coding
- bout.PredTerm = (options & CSJ2K.j2k.entropy.StdEntropyCoderOptions.OPT_PRED_TERM) != 0;
- totdist += rawSigProgPass(srcblk, bout, istermbuf[npass], curbp, state, fs, ratebuf, npass, ltpidx, options) * msew;
- }
- distbuf[npass] = totdist;
- if (istermbuf[npass])
- ltpidx = npass;
- npass++;
-
- // Do the magnitude refinement pass
- // We terminate if regular termination or bypass ("raw") coding
- istermbuf[npass] = (options & CSJ2K.j2k.entropy.StdEntropyCoderOptions.OPT_TERM_PASS) != 0 || ((options & CSJ2K.j2k.entropy.StdEntropyCoderOptions.OPT_BYPASS) != 0 && (31 - CSJ2K.j2k.entropy.StdEntropyCoderOptions.NUM_NON_BYPASS_MS_BP - skipbp > curbp));
- if ((options & CSJ2K.j2k.entropy.StdEntropyCoderOptions.OPT_BYPASS) == 0 || (31 - CSJ2K.j2k.entropy.StdEntropyCoderOptions.NUM_NON_BYPASS_MS_BP - skipbp <= curbp))
- {
- // No bypass coding
- totdist += magRefPass(srcblk, mq, istermbuf[npass], curbp, state, fm, symbuf, ctxtbuf, ratebuf, npass, ltpidx, options) * msew;
- }
- else
- {
- // Bypass ("raw") coding
- bout.PredTerm = (options & CSJ2K.j2k.entropy.StdEntropyCoderOptions.OPT_PRED_TERM) != 0;
- totdist += rawMagRefPass(srcblk, bout, istermbuf[npass], curbp, state, fm, ratebuf, npass, ltpidx, options) * msew;
- }
- distbuf[npass] = totdist;
- if (istermbuf[npass])
- ltpidx = npass;
- npass++;
-
- // Do the clenup pass
- // We terminate if regular termination, last bit-plane, or next
- // bit-plane is "raw".
- istermbuf[npass] = (options & CSJ2K.j2k.entropy.StdEntropyCoderOptions.OPT_TERM_PASS) != 0 || curbp == lmb || ((options & CSJ2K.j2k.entropy.StdEntropyCoderOptions.OPT_BYPASS) != 0 && (31 - CSJ2K.j2k.entropy.StdEntropyCoderOptions.NUM_NON_BYPASS_MS_BP - skipbp) >= curbp);
- totdist += cleanuppass(srcblk, mq, istermbuf[npass], curbp, state, fs, zc_lut, symbuf, ctxtbuf, ratebuf, npass, ltpidx, options) * msew;
- distbuf[npass] = totdist;
-
- if (istermbuf[npass])
- ltpidx = npass;
- npass++;
-
- // Goto next bit-plane
- msew *= 0.25;
- curbp--;
- }
-
- // Copy compressed data and rate-distortion statistics to output
- ccb.data = new byte[out_Renamed.size()];
- out_Renamed.toByteArray(0, out_Renamed.size(), ccb.data, 0);
- checkEndOfPassFF(ccb.data, ratebuf, istermbuf, npass);
- ccb.selectConvexHull(ratebuf, distbuf, (options & (CSJ2K.j2k.entropy.StdEntropyCoderOptions.OPT_BYPASS | CSJ2K.j2k.entropy.StdEntropyCoderOptions.OPT_TERM_PASS)) != 0 ? istermbuf : null, npass, rev);
-
- // Reset MQ coder and bit output for next code-block
- mq.reset();
- if (bout != null)
- bout.reset();
- }
-
- /// Calculates the number of magnitude bit-planes that are to be skipped,
- /// because they are non-significant. The algorithm looks for the largest
- /// magnitude and calculates the most significant bit-plane of it.
- ///
- ///
- /// The code-block of data to scan
- ///
- ///
- /// The least significant magnitude bit in the data
- ///
- ///
- /// The number of magnitude bit-planes to skip (i.e. all zero most
- /// significant bit-planes).
- ///
- ///
- static private int calcSkipMSBP(CBlkWTData cblk, int lmb)
- {
- int k, kmax, mask;
- int[] data;
- int maxmag;
- int mag;
- int w, h;
- int msbp;
- int l;
-
- data = (int[])cblk.Data;
- w = cblk.w;
- h = cblk.h;
-
- // First look for the maximum magnitude in the code-block
- maxmag = 0;
- // Consider only magnitude bits that are in non-fractional bit-planes.
- mask = 0x7FFFFFFF & (~((1 << lmb) - 1));
- for (l = h - 1, k = cblk.offset; l >= 0; l--)
- {
- for (kmax = k + w; k < kmax; k++)
- {
- mag = data[k] & mask;
- if (mag > maxmag)
- maxmag = mag;
- }
- k += cblk.scanw - w;
- }
- // Now calculate the number of all zero most significant
- // bit-planes for the maximum magnitude.
- msbp = 30;
- do
- {
- if (((1 << msbp) & maxmag) != 0)
- break;
- msbp--;
- }
- while (msbp >= lmb);
-
- // Return the number of non-significant bit-planes to skip
- return 30 - msbp;
- }
-
- /// Performs the significance propagation pass on the specified data and
- /// bit-plane. It codes all insignificant samples which have, at least, one
- /// of its immediate eight neighbors already significant, using the ZC and
- /// SC primitives as needed. It toggles the "visited" state bit to 1 for
- /// all those samples.
- ///
- ///
- /// The code-block data to code
- ///
- ///
- /// The MQ-coder to use
- ///
- ///
- /// If true it performs an MQ-coder termination after the end
- /// of the pass
- ///
- ///
- /// The bit-plane to code
- ///
- ///
- /// The state information for the code-block
- ///
- ///
- /// The distortion estimation lookup table for SC
- ///
- ///
- /// The ZC lookup table to use in ZC.
- ///
- ///
- /// The buffer to hold symbols to send to the MQ coder
- ///
- ///
- /// A buffer to hold the contexts to use in sending the
- /// buffered symbols to the MQ coder.
- ///
- ///
- /// The buffer where to store the rate (i.e. coded lenth) at
- /// the end of this coding pass.
- ///
- ///
- /// The coding pass index. Is the index in the 'ratebuf' array
- /// where to store the coded length after this coding pass.
- ///
- ///
- /// The index of the last pass that was terminated, or
- /// negative if none.
- ///
- ///
- /// The bitmask of entropy coding options to apply to the
- /// code-block
- ///
- ///
- /// The decrease in distortion for this pass, in the fixed-point
- /// normalized representation of the 'FS_LOSSY' and 'FS_LOSSLESS' tables.
- ///
- ///
- static private int sigProgPass(CBlkWTData srcblk, MQCoder mq, bool doterm, int bp, int[] state, int[] fs, int[] zc_lut, int[] symbuf, int[] ctxtbuf, int[] ratebuf, int pidx, int ltpidx, int options)
- {
- int j, sj; // The state index for line and stripe
- int k, sk; // The data index for line and stripe
- int nsym = 0; // Symbol counter for symbol and context buffers
- int dscanw; // The data scan-width
- int sscanw; // The state and packed state scan-width
- int jstep; // Stripe to stripe step for 'sj'
- int kstep; // Stripe to stripe step for 'sk'
- int stopsk; // The loop limit on the variable sk
- int csj; // Local copy (i.e. cached) of 'state[j]'
- int mask; // The mask for the current bit-plane
- int sym; // The symbol to code
- int ctxt; // The context to use
- int[] data; // The data buffer
- int dist; // The distortion reduction for this pass
- int shift; // Shift amount for distortion
- int upshift; // Shift left amount for distortion
- int downshift; // Shift right amount for distortion
- int normval; // The normalized sample magnitude value
- int s; // The stripe index
- bool causal; // Flag to indicate if stripe-causal context
- // formation is to be used
- int nstripes; // The number of stripes in the code-block
- int sheight; // Height of the current stripe
- int off_ul, off_ur, off_dr, off_dl; // offsets
-
- // Initialize local variables
- dscanw = srcblk.scanw;
- sscanw = srcblk.w + 2;
- jstep = sscanw * CSJ2K.j2k.entropy.StdEntropyCoderOptions.STRIPE_HEIGHT / 2 - srcblk.w;
- kstep = dscanw * CSJ2K.j2k.entropy.StdEntropyCoderOptions.STRIPE_HEIGHT - srcblk.w;
- mask = 1 << bp;
- data = (int[])srcblk.Data;
- nstripes = (srcblk.h + CSJ2K.j2k.entropy.StdEntropyCoderOptions.STRIPE_HEIGHT - 1) / CSJ2K.j2k.entropy.StdEntropyCoderOptions.STRIPE_HEIGHT;
- dist = 0;
- // We use the MSE_LKP_BITS-1 bits below the bit just coded for
- // distortion estimation.
- shift = bp - MSE_LKP_BITS_M1;
- upshift = (shift >= 0) ? 0 : -shift;
- downshift = (shift <= 0) ? 0 : shift;
- causal = (options & CSJ2K.j2k.entropy.StdEntropyCoderOptions.OPT_VERT_STR_CAUSAL) != 0;
-
- // Pre-calculate offsets in 'state' for diagonal neighbors
- off_ul = -sscanw - 1; // up-left
- off_ur = -sscanw + 1; // up-right
- off_dr = sscanw + 1; // down-right
- off_dl = sscanw - 1; // down-left
-
- // Code stripe by stripe
- sk = srcblk.offset;
- sj = sscanw + 1;
- for (s = nstripes - 1; s >= 0; s--, sk += kstep, sj += jstep)
- {
- sheight = (s != 0) ? CSJ2K.j2k.entropy.StdEntropyCoderOptions.STRIPE_HEIGHT : srcblk.h - (nstripes - 1) * CSJ2K.j2k.entropy.StdEntropyCoderOptions.STRIPE_HEIGHT;
- stopsk = sk + srcblk.w;
- // Scan by set of 1 stripe column at a time
- for (nsym = 0; sk < stopsk; sk++, sj++)
- {
- // Do half top of column
- j = sj;
- csj = state[j];
- // If any of the two samples is not significant and has a
- // non-zero context (i.e. some neighbor is significant) we can
- // not skip them
- if ((((~csj) & (csj << 2)) & SIG_MASK_R1R2) != 0)
- {
- k = sk;
- // Scan first row
- if ((csj & (STATE_SIG_R1 | STATE_NZ_CTXT_R1)) == STATE_NZ_CTXT_R1)
- {
- // Apply zero coding
- ctxtbuf[nsym] = zc_lut[csj & ZC_MASK];
- if ((symbuf[nsym++] = SupportClass.URShift((data[k] & mask), bp)) != 0)
- {
- // Became significant
- // Apply sign coding
- sym = SupportClass.URShift(data[k], 31);
- ctxt = SC_LUT[(SupportClass.URShift(csj, SC_SHIFT_R1)) & SC_MASK];
- symbuf[nsym] = sym ^ (SupportClass.URShift(ctxt, SC_SPRED_SHIFT));
- ctxtbuf[nsym++] = ctxt & SC_LUT_MASK;
- // Update state information (significant bit,
- // visited bit, neighbor significant bit of
- // neighbors, non zero context of neighbors, sign
- // of neighbors)
- if (!causal)
- {
- // If in causal mode do not change contexts of
- // previous stripe.
- state[j + off_ul] |= STATE_NZ_CTXT_R2 | STATE_D_DR_R2;
- state[j + off_ur] |= STATE_NZ_CTXT_R2 | STATE_D_DL_R2;
- }
- // Update sign state information of neighbors
- if (sym != 0)
- {
- csj |= STATE_SIG_R1 | STATE_VISITED_R1 | STATE_NZ_CTXT_R2 | STATE_V_U_R2 | STATE_V_U_SIGN_R2;
- if (!causal)
- {
- // If in causal mode do not change
- // contexts of previous stripe.
- state[j - sscanw] |= STATE_NZ_CTXT_R2 | STATE_V_D_R2 | STATE_V_D_SIGN_R2;
- }
- state[j + 1] |= STATE_NZ_CTXT_R1 | STATE_NZ_CTXT_R2 | STATE_H_L_R1 | STATE_H_L_SIGN_R1 | STATE_D_UL_R2;
- state[j - 1] |= STATE_NZ_CTXT_R1 | STATE_NZ_CTXT_R2 | STATE_H_R_R1 | STATE_H_R_SIGN_R1 | STATE_D_UR_R2;
- }
- else
- {
- csj |= STATE_SIG_R1 | STATE_VISITED_R1 | STATE_NZ_CTXT_R2 | STATE_V_U_R2;
- if (!causal)
- {
- // If in causal mode do not change
- // contexts of previous stripe.
- state[j - sscanw] |= STATE_NZ_CTXT_R2 | STATE_V_D_R2;
- }
- state[j + 1] |= STATE_NZ_CTXT_R1 | STATE_NZ_CTXT_R2 | STATE_H_L_R1 | STATE_D_UL_R2;
- state[j - 1] |= STATE_NZ_CTXT_R1 | STATE_NZ_CTXT_R2 | STATE_H_R_R1 | STATE_D_UR_R2;
- }
- // Update distortion
- normval = (data[k] >> downshift) << upshift;
- dist += fs[normval & ((1 << MSE_LKP_BITS_M1) - 1)];
- }
- else
- {
- csj |= STATE_VISITED_R1;
- }
- }
- if (sheight < 2)
- {
- state[j] = csj;
- continue;
- }
- // Scan second row
- if ((csj & (STATE_SIG_R2 | STATE_NZ_CTXT_R2)) == STATE_NZ_CTXT_R2)
- {
- k += dscanw;
- // Apply zero coding
- ctxtbuf[nsym] = zc_lut[(SupportClass.URShift(csj, STATE_SEP)) & ZC_MASK];
- if ((symbuf[nsym++] = SupportClass.URShift((data[k] & mask), bp)) != 0)
- {
- // Became significant
- // Apply sign coding
- sym = SupportClass.URShift(data[k], 31);
- ctxt = SC_LUT[(SupportClass.URShift(csj, SC_SHIFT_R2)) & SC_MASK];
- symbuf[nsym] = sym ^ (SupportClass.URShift(ctxt, SC_SPRED_SHIFT));
- ctxtbuf[nsym++] = ctxt & SC_LUT_MASK;
- // Update state information (significant bit,
- // visited bit, neighbor significant bit of
- // neighbors, non zero context of neighbors, sign
- // of neighbors)
- state[j + off_dl] |= STATE_NZ_CTXT_R1 | STATE_D_UR_R1;
- state[j + off_dr] |= STATE_NZ_CTXT_R1 | STATE_D_UL_R1;
- // Update sign state information of neighbors
- if (sym != 0)
- {
- csj |= STATE_SIG_R2 | STATE_VISITED_R2 | STATE_NZ_CTXT_R1 | STATE_V_D_R1 | STATE_V_D_SIGN_R1;
- state[j + sscanw] |= STATE_NZ_CTXT_R1 | STATE_V_U_R1 | STATE_V_U_SIGN_R1;
- state[j + 1] |= STATE_NZ_CTXT_R1 | STATE_NZ_CTXT_R2 | STATE_D_DL_R1 | STATE_H_L_R2 | STATE_H_L_SIGN_R2;
- state[j - 1] |= STATE_NZ_CTXT_R1 | STATE_NZ_CTXT_R2 | STATE_D_DR_R1 | STATE_H_R_R2 | STATE_H_R_SIGN_R2;
- }
- else
- {
- csj |= STATE_SIG_R2 | STATE_VISITED_R2 | STATE_NZ_CTXT_R1 | STATE_V_D_R1;
- state[j + sscanw] |= STATE_NZ_CTXT_R1 | STATE_V_U_R1;
- state[j + 1] |= STATE_NZ_CTXT_R1 | STATE_NZ_CTXT_R2 | STATE_D_DL_R1 | STATE_H_L_R2;
- state[j - 1] |= STATE_NZ_CTXT_R1 | STATE_NZ_CTXT_R2 | STATE_D_DR_R1 | STATE_H_R_R2;
- }
- // Update distortion
- normval = (data[k] >> downshift) << upshift;
- dist += fs[normval & ((1 << MSE_LKP_BITS_M1) - 1)];
- }
- else
- {
- csj |= STATE_VISITED_R2;
- }
- }
- state[j] = csj;
- }
- // Do half bottom of column
- if (sheight < 3)
- continue;
- j += sscanw;
- csj = state[j];
- // If any of the two samples is not significant and has a
- // non-zero context (i.e. some neighbor is significant) we can
- // not skip them
- if ((((~csj) & (csj << 2)) & SIG_MASK_R1R2) != 0)
- {
- k = sk + (dscanw << 1);
- // Scan first row
- if ((csj & (STATE_SIG_R1 | STATE_NZ_CTXT_R1)) == STATE_NZ_CTXT_R1)
- {
- // Apply zero coding
- ctxtbuf[nsym] = zc_lut[csj & ZC_MASK];
- if ((symbuf[nsym++] = SupportClass.URShift((data[k] & mask), bp)) != 0)
- {
- // Became significant
- // Apply sign coding
- sym = SupportClass.URShift(data[k], 31);
- ctxt = SC_LUT[(SupportClass.URShift(csj, SC_SHIFT_R1)) & SC_MASK];
- symbuf[nsym] = sym ^ (SupportClass.URShift(ctxt, SC_SPRED_SHIFT));
- ctxtbuf[nsym++] = ctxt & SC_LUT_MASK;
- // Update state information (significant bit,
- // visited bit, neighbor significant bit of
- // neighbors, non zero context of neighbors, sign
- // of neighbors)
- state[j + off_ul] |= STATE_NZ_CTXT_R2 | STATE_D_DR_R2;
- state[j + off_ur] |= STATE_NZ_CTXT_R2 | STATE_D_DL_R2;
- // Update sign state information of neighbors
- if (sym != 0)
- {
- csj |= STATE_SIG_R1 | STATE_VISITED_R1 | STATE_NZ_CTXT_R2 | STATE_V_U_R2 | STATE_V_U_SIGN_R2;
- state[j - sscanw] |= STATE_NZ_CTXT_R2 | STATE_V_D_R2 | STATE_V_D_SIGN_R2;
- state[j + 1] |= STATE_NZ_CTXT_R1 | STATE_NZ_CTXT_R2 | STATE_H_L_R1 | STATE_H_L_SIGN_R1 | STATE_D_UL_R2;
- state[j - 1] |= STATE_NZ_CTXT_R1 | STATE_NZ_CTXT_R2 | STATE_H_R_R1 | STATE_H_R_SIGN_R1 | STATE_D_UR_R2;
- }
- else
- {
- csj |= STATE_SIG_R1 | STATE_VISITED_R1 | STATE_NZ_CTXT_R2 | STATE_V_U_R2;
- state[j - sscanw] |= STATE_NZ_CTXT_R2 | STATE_V_D_R2;
- state[j + 1] |= STATE_NZ_CTXT_R1 | STATE_NZ_CTXT_R2 | STATE_H_L_R1 | STATE_D_UL_R2;
- state[j - 1] |= STATE_NZ_CTXT_R1 | STATE_NZ_CTXT_R2 | STATE_H_R_R1 | STATE_D_UR_R2;
- }
- // Update distortion
- normval = (data[k] >> downshift) << upshift;
- dist += fs[normval & ((1 << MSE_LKP_BITS_M1) - 1)];
- }
- else
- {
- csj |= STATE_VISITED_R1;
- }
- }
- if (sheight < 4)
- {
- state[j] = csj;
- continue;
- }
- // Scan second row
- if ((csj & (STATE_SIG_R2 | STATE_NZ_CTXT_R2)) == STATE_NZ_CTXT_R2)
- {
- k += dscanw;
- // Apply zero coding
- ctxtbuf[nsym] = zc_lut[(SupportClass.URShift(csj, STATE_SEP)) & ZC_MASK];
- if ((symbuf[nsym++] = SupportClass.URShift((data[k] & mask), bp)) != 0)
- {
- // Became significant
- // Apply sign coding
- sym = SupportClass.URShift(data[k], 31);
- ctxt = SC_LUT[(SupportClass.URShift(csj, SC_SHIFT_R2)) & SC_MASK];
- symbuf[nsym] = sym ^ (SupportClass.URShift(ctxt, SC_SPRED_SHIFT));
- ctxtbuf[nsym++] = ctxt & SC_LUT_MASK;
- // Update state information (significant bit,
- // visited bit, neighbor significant bit of
- // neighbors, non zero context of neighbors, sign
- // of neighbors)
- state[j + off_dl] |= STATE_NZ_CTXT_R1 | STATE_D_UR_R1;
- state[j + off_dr] |= STATE_NZ_CTXT_R1 | STATE_D_UL_R1;
- // Update sign state information of neighbors
- if (sym != 0)
- {
- csj |= STATE_SIG_R2 | STATE_VISITED_R2 | STATE_NZ_CTXT_R1 | STATE_V_D_R1 | STATE_V_D_SIGN_R1;
- state[j + sscanw] |= STATE_NZ_CTXT_R1 | STATE_V_U_R1 | STATE_V_U_SIGN_R1;
- state[j + 1] |= STATE_NZ_CTXT_R1 | STATE_NZ_CTXT_R2 | STATE_D_DL_R1 | STATE_H_L_R2 | STATE_H_L_SIGN_R2;
- state[j - 1] |= STATE_NZ_CTXT_R1 | STATE_NZ_CTXT_R2 | STATE_D_DR_R1 | STATE_H_R_R2 | STATE_H_R_SIGN_R2;
- }
- else
- {
- csj |= STATE_SIG_R2 | STATE_VISITED_R2 | STATE_NZ_CTXT_R1 | STATE_V_D_R1;
- state[j + sscanw] |= STATE_NZ_CTXT_R1 | STATE_V_U_R1;
- state[j + 1] |= STATE_NZ_CTXT_R1 | STATE_NZ_CTXT_R2 | STATE_D_DL_R1 | STATE_H_L_R2;
- state[j - 1] |= STATE_NZ_CTXT_R1 | STATE_NZ_CTXT_R2 | STATE_D_DR_R1 | STATE_H_R_R2;
- }
- // Update distortion
- normval = (data[k] >> downshift) << upshift;
- dist += fs[normval & ((1 << MSE_LKP_BITS_M1) - 1)];
- }
- else
- {
- csj |= STATE_VISITED_R2;
- }
- }
- state[j] = csj;
- }
- }
- // Code all buffered symbols
- mq.codeSymbols(symbuf, ctxtbuf, nsym);
- }
- // Reset the MQ context states if we need to
- if ((options & CSJ2K.j2k.entropy.StdEntropyCoderOptions.OPT_RESET_MQ) != 0)
- {
- mq.resetCtxts();
- }
-
- // Terminate the MQ bit stream if we need to
- if (doterm)
- {
- ratebuf[pidx] = mq.terminate(); // Termination has special length
- }
- else
- {
- // Use normal length calculation
- ratebuf[pidx] = mq.NumCodedBytes;
- }
- // Add length of previous segments, if any
- if (ltpidx >= 0)
- {
- ratebuf[pidx] += ratebuf[ltpidx];
- }
- // Finish length calculation if needed
- if (doterm)
- {
- mq.finishLengthCalculation(ratebuf, pidx);
- }
-
- // Return the reduction in distortion
- return dist;
- }
-
- /// Performs the significance propagation pass on the specified data and
- /// bit-plane, without using the arithmetic coder. It codes all
- /// insignificant samples which have, at least, one of its immediate eight
- /// neighbors already significant, using the ZC and SC primitives as
- /// needed. It toggles the "visited" state bit to 1 for all those samples.
- ///
- /// In this method, the arithmetic coder is bypassed, and raw bits are
- /// directly written in the bit stream (useful when distribution are close
- /// to uniform, for intance, at high bit-rates and at lossless
- /// compression).
- ///
- ///
- /// The code-block data to code
- ///
- ///
- /// The bit based output
- ///
- ///
- /// If true the bit based output is byte aligned after the
- /// end of the pass.
- ///
- ///
- /// The bit-plane to code
- ///
- ///
- /// The state information for the code-block
- ///
- ///
- /// The distortion estimation lookup table for SC
- ///
- ///
- /// The buffer where to store the rate (i.e. coded lenth) at
- /// the end of this coding pass.
- ///
- ///
- /// The coding pass index. Is the index in the 'ratebuf' array
- /// where to store the coded length after this coding pass.
- ///
- ///
- /// The index of the last pass that was terminated, or
- /// negative if none.
- ///
- ///
- /// The bitmask of entropy coding options to apply to the
- /// code-block
- ///
- ///
- /// The decrease in distortion for this pass, in the fixed-point
- /// normalized representation of the 'FS_LOSSY' and 'FS_LOSSLESS' tables.
- ///
- ///
- static private int rawSigProgPass(CBlkWTData srcblk, BitToByteOutput bout, bool doterm, int bp, int[] state, int[] fs, int[] ratebuf, int pidx, int ltpidx, int options)
- {
- int j, sj; // The state index for line and stripe
- int k, sk; // The data index for line and stripe
- int dscanw; // The data scan-width
- int sscanw; // The state scan-width
- int jstep; // Stripe to stripe step for 'sj'
- int kstep; // Stripe to stripe step for 'sk'
- int stopsk; // The loop limit on the variable sk
- int csj; // Local copy (i.e. cached) of 'state[j]'
- int mask; // The mask for the current bit-plane
- int nsym = 0; // Number of symbol
- int sym; // The symbol to code
- int[] data; // The data buffer
- int dist; // The distortion reduction for this pass
- int shift; // Shift amount for distortion
- int upshift; // Shift left amount for distortion
- int downshift; // Shift right amount for distortion
- int normval; // The normalized sample magnitude value
- int s; // The stripe index
- bool causal; // Flag to indicate if stripe-causal context
- // formation is to be used
- int nstripes; // The number of stripes in the code-block
- int sheight; // Height of the current stripe
- int off_ul, off_ur, off_dr, off_dl; // offsets
-
- // Initialize local variables
- dscanw = srcblk.scanw;
- sscanw = srcblk.w + 2;
- jstep = sscanw * CSJ2K.j2k.entropy.StdEntropyCoderOptions.STRIPE_HEIGHT / 2 - srcblk.w;
- kstep = dscanw * CSJ2K.j2k.entropy.StdEntropyCoderOptions.STRIPE_HEIGHT - srcblk.w;
- mask = 1 << bp;
- data = (int[])srcblk.Data;
- nstripes = (srcblk.h + CSJ2K.j2k.entropy.StdEntropyCoderOptions.STRIPE_HEIGHT - 1) / CSJ2K.j2k.entropy.StdEntropyCoderOptions.STRIPE_HEIGHT;
- dist = 0;
- // We use the MSE_LKP_BITS-1 bits below the bit just coded for
- // distortion estimation.
- shift = bp - MSE_LKP_BITS_M1;
- upshift = (shift >= 0) ? 0 : -shift;
- downshift = (shift <= 0) ? 0 : shift;
- causal = (options & CSJ2K.j2k.entropy.StdEntropyCoderOptions.OPT_VERT_STR_CAUSAL) != 0;
-
- // Pre-calculate offsets in 'state' for neighbors
- off_ul = -sscanw - 1; // up-left
- off_ur = -sscanw + 1; // up-right
- off_dr = sscanw + 1; // down-right
- off_dl = sscanw - 1; // down-left
-
- // Code stripe by stripe
- sk = srcblk.offset;
- sj = sscanw + 1;
- for (s = nstripes - 1; s >= 0; s--, sk += kstep, sj += jstep)
- {
- sheight = (s != 0) ? CSJ2K.j2k.entropy.StdEntropyCoderOptions.STRIPE_HEIGHT : srcblk.h - (nstripes - 1) * CSJ2K.j2k.entropy.StdEntropyCoderOptions.STRIPE_HEIGHT;
- stopsk = sk + srcblk.w;
- // Scan by set of 1 stripe column at a time
- for (; sk < stopsk; sk++, sj++)
- {
- // Do half top of column
- j = sj;
- csj = state[j];
- // If any of the two samples is not significant and has a
- // non-zero context (i.e. some neighbor is significant) we can
- // not skip them
- if ((((~csj) & (csj << 2)) & SIG_MASK_R1R2) != 0)
- {
- k = sk;
- // Scan first row
- if ((csj & (STATE_SIG_R1 | STATE_NZ_CTXT_R1)) == STATE_NZ_CTXT_R1)
- {
- // Apply zero coding
- sym = SupportClass.URShift((data[k] & mask), bp);
- bout.writeBit(sym);
- nsym++;
- if (sym != 0)
- {
- // Became significant
- // Apply sign coding
- sym = SupportClass.URShift(data[k], 31);
- bout.writeBit(sym);
- nsym++;
- // Update state information (significant bit,
- // visited bit, neighbor significant bit of
- // neighbors, non zero context of neighbors, sign
- // of neighbors)
- if (!causal)
- {
- // If in causal mode do not change contexts of
- // previous stripe.
- state[j + off_ul] |= STATE_NZ_CTXT_R2 | STATE_D_DR_R2;
- state[j + off_ur] |= STATE_NZ_CTXT_R2 | STATE_D_DL_R2;
- }
- // Update sign state information of neighbors
- if (sym != 0)
- {
- csj |= STATE_SIG_R1 | STATE_VISITED_R1 | STATE_NZ_CTXT_R2 | STATE_V_U_R2 | STATE_V_U_SIGN_R2;
- if (!causal)
- {
- // If in causal mode do not change
- // contexts of previous stripe.
- state[j - sscanw] |= STATE_NZ_CTXT_R2 | STATE_V_D_R2 | STATE_V_D_SIGN_R2;
- }
- state[j + 1] |= STATE_NZ_CTXT_R1 | STATE_NZ_CTXT_R2 | STATE_H_L_R1 | STATE_H_L_SIGN_R1 | STATE_D_UL_R2;
- state[j - 1] |= STATE_NZ_CTXT_R1 | STATE_NZ_CTXT_R2 | STATE_H_R_R1 | STATE_H_R_SIGN_R1 | STATE_D_UR_R2;
- }
- else
- {
- csj |= STATE_SIG_R1 | STATE_VISITED_R1 | STATE_NZ_CTXT_R2 | STATE_V_U_R2;
- if (!causal)
- {
- // If in causal mode do not change
- // contexts of previous stripe.
- state[j - sscanw] |= STATE_NZ_CTXT_R2 | STATE_V_D_R2;
- }
- state[j + 1] |= STATE_NZ_CTXT_R1 | STATE_NZ_CTXT_R2 | STATE_H_L_R1 | STATE_D_UL_R2;
- state[j - 1] |= STATE_NZ_CTXT_R1 | STATE_NZ_CTXT_R2 | STATE_H_R_R1 | STATE_D_UR_R2;
- }
- // Update distortion
- normval = (data[k] >> downshift) << upshift;
- dist += fs[normval & ((1 << MSE_LKP_BITS_M1) - 1)];
- }
- else
- {
- csj |= STATE_VISITED_R1;
- }
- }
- if (sheight < 2)
- {
- state[j] = csj;
- continue;
- }
- // Scan second row
- if ((csj & (STATE_SIG_R2 | STATE_NZ_CTXT_R2)) == STATE_NZ_CTXT_R2)
- {
- k += dscanw;
- // Apply zero coding
- sym = SupportClass.URShift((data[k] & mask), bp);
- bout.writeBit(sym);
- nsym++;
- if (sym != 0)
- {
- // Became significant
- // Apply sign coding
- sym = SupportClass.URShift(data[k], 31);
- bout.writeBit(sym);
- nsym++;
- // Update state information (significant bit,
- // visited bit, neighbor significant bit of
- // neighbors, non zero context of neighbors, sign
- // of neighbors)
- state[j + off_dl] |= STATE_NZ_CTXT_R1 | STATE_D_UR_R1;
- state[j + off_dr] |= STATE_NZ_CTXT_R1 | STATE_D_UL_R1;
- // Update sign state information of neighbors
- if (sym != 0)
- {
- csj |= STATE_SIG_R2 | STATE_VISITED_R2 | STATE_NZ_CTXT_R1 | STATE_V_D_R1 | STATE_V_D_SIGN_R1;
- state[j + sscanw] |= STATE_NZ_CTXT_R1 | STATE_V_U_R1 | STATE_V_U_SIGN_R1;
- state[j + 1] |= STATE_NZ_CTXT_R1 | STATE_NZ_CTXT_R2 | STATE_D_DL_R1 | STATE_H_L_R2 | STATE_H_L_SIGN_R2;
- state[j - 1] |= STATE_NZ_CTXT_R1 | STATE_NZ_CTXT_R2 | STATE_D_DR_R1 | STATE_H_R_R2 | STATE_H_R_SIGN_R2;
- }
- else
- {
- csj |= STATE_SIG_R2 | STATE_VISITED_R2 | STATE_NZ_CTXT_R1 | STATE_V_D_R1;
- state[j + sscanw] |= STATE_NZ_CTXT_R1 | STATE_V_U_R1;
- state[j + 1] |= STATE_NZ_CTXT_R1 | STATE_NZ_CTXT_R2 | STATE_D_DL_R1 | STATE_H_L_R2;
- state[j - 1] |= STATE_NZ_CTXT_R1 | STATE_NZ_CTXT_R2 | STATE_D_DR_R1 | STATE_H_R_R2;
- }
- // Update distortion
- normval = (data[k] >> downshift) << upshift;
- dist += fs[normval & ((1 << MSE_LKP_BITS_M1) - 1)];
- }
- else
- {
- csj |= STATE_VISITED_R2;
- }
- }
- state[j] = csj;
- }
- // Do half bottom of column
- if (sheight < 3)
- continue;
- j += sscanw;
- csj = state[j];
- // If any of the two samples is not significant and has a
- // non-zero context (i.e. some neighbor is significant) we can
- // not skip them
- if ((((~csj) & (csj << 2)) & SIG_MASK_R1R2) != 0)
- {
- k = sk + (dscanw << 1);
- // Scan first row
- if ((csj & (STATE_SIG_R1 | STATE_NZ_CTXT_R1)) == STATE_NZ_CTXT_R1)
- {
- sym = SupportClass.URShift((data[k] & mask), bp);
- bout.writeBit(sym);
- nsym++;
- if (sym != 0)
- {
- // Became significant
- // Apply sign coding
- sym = SupportClass.URShift(data[k], 31);
- bout.writeBit(sym);
- nsym++;
- // Update state information (significant bit,
- // visited bit, neighbor significant bit of
- // neighbors, non zero context of neighbors, sign
- // of neighbors)
- state[j + off_ul] |= STATE_NZ_CTXT_R2 | STATE_D_DR_R2;
- state[j + off_ur] |= STATE_NZ_CTXT_R2 | STATE_D_DL_R2;
- // Update sign state information of neighbors
- if (sym != 0)
- {
- csj |= STATE_SIG_R1 | STATE_VISITED_R1 | STATE_NZ_CTXT_R2 | STATE_V_U_R2 | STATE_V_U_SIGN_R2;
- state[j - sscanw] |= STATE_NZ_CTXT_R2 | STATE_V_D_R2 | STATE_V_D_SIGN_R2;
- state[j + 1] |= STATE_NZ_CTXT_R1 | STATE_NZ_CTXT_R2 | STATE_H_L_R1 | STATE_H_L_SIGN_R1 | STATE_D_UL_R2;
- state[j - 1] |= STATE_NZ_CTXT_R1 | STATE_NZ_CTXT_R2 | STATE_H_R_R1 | STATE_H_R_SIGN_R1 | STATE_D_UR_R2;
- }
- else
- {
- csj |= STATE_SIG_R1 | STATE_VISITED_R1 | STATE_NZ_CTXT_R2 | STATE_V_U_R2;
- state[j - sscanw] |= STATE_NZ_CTXT_R2 | STATE_V_D_R2;
- state[j + 1] |= STATE_NZ_CTXT_R1 | STATE_NZ_CTXT_R2 | STATE_H_L_R1 | STATE_D_UL_R2;
- state[j - 1] |= STATE_NZ_CTXT_R1 | STATE_NZ_CTXT_R2 | STATE_H_R_R1 | STATE_D_UR_R2;
- }
- // Update distortion
- normval = (data[k] >> downshift) << upshift;
- dist += fs[normval & ((1 << MSE_LKP_BITS_M1) - 1)];
- }
- else
- {
- csj |= STATE_VISITED_R1;
- }
- }
- if (sheight < 4)
- {
- state[j] = csj;
- continue;
- }
- if ((csj & (STATE_SIG_R2 | STATE_NZ_CTXT_R2)) == STATE_NZ_CTXT_R2)
- {
- k += dscanw;
- // Apply zero coding
- sym = SupportClass.URShift((data[k] & mask), bp);
- bout.writeBit(sym);
- nsym++;
- if (sym != 0)
- {
- // Became significant
- // Apply sign coding
- sym = SupportClass.URShift(data[k], 31);
- bout.writeBit(sym);
- nsym++;
- // Update state information (significant bit,
- // visited bit, neighbor significant bit of
- // neighbors, non zero context of neighbors, sign
- // of neighbors)
- state[j + off_dl] |= STATE_NZ_CTXT_R1 | STATE_D_UR_R1;
- state[j + off_dr] |= STATE_NZ_CTXT_R1 | STATE_D_UL_R1;
- // Update sign state information of neighbors
- if (sym != 0)
- {
- csj |= STATE_SIG_R2 | STATE_VISITED_R2 | STATE_NZ_CTXT_R1 | STATE_V_D_R1 | STATE_V_D_SIGN_R1;
- state[j + sscanw] |= STATE_NZ_CTXT_R1 | STATE_V_U_R1 | STATE_V_U_SIGN_R1;
- state[j + 1] |= STATE_NZ_CTXT_R1 | STATE_NZ_CTXT_R2 | STATE_D_DL_R1 | STATE_H_L_R2 | STATE_H_L_SIGN_R2;
- state[j - 1] |= STATE_NZ_CTXT_R1 | STATE_NZ_CTXT_R2 | STATE_D_DR_R1 | STATE_H_R_R2 | STATE_H_R_SIGN_R2;
- }
- else
- {
- csj |= STATE_SIG_R2 | STATE_VISITED_R2 | STATE_NZ_CTXT_R1 | STATE_V_D_R1;
- state[j + sscanw] |= STATE_NZ_CTXT_R1 | STATE_V_U_R1;
- state[j + 1] |= STATE_NZ_CTXT_R1 | STATE_NZ_CTXT_R2 | STATE_D_DL_R1 | STATE_H_L_R2;
- state[j - 1] |= STATE_NZ_CTXT_R1 | STATE_NZ_CTXT_R2 | STATE_D_DR_R1 | STATE_H_R_R2;
- }
- // Update distortion
- normval = (data[k] >> downshift) << upshift;
- dist += fs[normval & ((1 << MSE_LKP_BITS_M1) - 1)];
- }
- else
- {
- csj |= STATE_VISITED_R2;
- }
- }
- state[j] = csj;
- }
- }
- }
-
- // Get length and terminate if needed
- if (doterm)
- {
- ratebuf[pidx] = bout.terminate();
- }
- else
- {
- ratebuf[pidx] = bout.length();
- }
- // Add length of previous segments, if any
- if (ltpidx >= 0)
- {
- ratebuf[pidx] += ratebuf[ltpidx];
- }
-
- // Return the reduction in distortion
- return dist;
- }
-
- /// Performs the magnitude refinement pass on the specified data and
- /// bit-plane. It codes the samples which are significant and which do not
- /// have the "visited" state bit turned on, using the MR primitive. The
- /// "visited" state bit is not mofified for any samples.
- ///
- ///
- /// The code-block data to code
- ///
- ///
- /// The MQ-coder to use
- ///
- ///
- /// If true it performs an MQ-coder termination after the end
- /// of the pass
- ///
- ///
- /// The bit-plane to code
- ///
- ///
- /// The state information for the code-block
- ///
- ///
- /// The distortion estimation lookup table for MR
- ///
- ///
- /// The buffer to hold symbols to send to the MQ coder
- ///
- ///
- /// A buffer to hold the contexts to use in sending the
- /// buffered symbols to the MQ coder.
- ///
- ///
- /// The buffer where to store the rate (i.e. coded lenth) at
- /// the end of this coding pass.
- ///
- ///
- /// The coding pass index. Is the index in the 'ratebuf' array
- /// where to store the coded length after this coding pass.
- ///
- ///
- /// The index of the last pass that was terminated, or
- /// negative if none.
- ///
- ///
- /// The bitmask of entropy coding options to apply to the
- /// code-block
- ///
- ///
- /// The decrease in distortion for this pass, in the fixed-point
- /// normalized representation of the 'FS_LOSSY' and 'FS_LOSSLESS' tables.
- ///
- ///
- static private int magRefPass(CBlkWTData srcblk, MQCoder mq, bool doterm, int bp, int[] state, int[] fm, int[] symbuf, int[] ctxtbuf, int[] ratebuf, int pidx, int ltpidx, int options)
- {
- int j, sj; // The state index for line and stripe
- int k, sk; // The data index for line and stripe
- int nsym = 0; // Symbol counter for symbol and context buffers
- int dscanw; // The data scan-width
- int sscanw; // The state scan-width
- int jstep; // Stripe to stripe step for 'sj'
- int kstep; // Stripe to stripe step for 'sk'
- int stopsk; // The loop limit on the variable sk
- int csj; // Local copy (i.e. cached) of 'state[j]'
- int mask; // The mask for the current bit-plane
- int[] data; // The data buffer
- int dist; // The distortion reduction for this pass
- int shift; // Shift amount for distortion
- int upshift; // Shift left amount for distortion
- int downshift; // Shift right amount for distortion
- int normval; // The normalized sample magnitude value
- int s; // The stripe index
- int nstripes; // The number of stripes in the code-block
- int sheight; // Height of the current stripe
-
- // Initialize local variables
- dscanw = srcblk.scanw;
- sscanw = srcblk.w + 2;
- jstep = sscanw * CSJ2K.j2k.entropy.StdEntropyCoderOptions.STRIPE_HEIGHT / 2 - srcblk.w;
- kstep = dscanw * CSJ2K.j2k.entropy.StdEntropyCoderOptions.STRIPE_HEIGHT - srcblk.w;
- mask = 1 << bp;
- data = (int[])srcblk.Data;
- nstripes = (srcblk.h + CSJ2K.j2k.entropy.StdEntropyCoderOptions.STRIPE_HEIGHT - 1) / CSJ2K.j2k.entropy.StdEntropyCoderOptions.STRIPE_HEIGHT;
- dist = 0;
- // We use the bit just coded plus MSE_LKP_BITS-1 bits below the bit
- // just coded for distortion estimation.
- shift = bp - MSE_LKP_BITS_M1;
- upshift = (shift >= 0) ? 0 : -shift;
- downshift = (shift <= 0) ? 0 : shift;
-
- // Code stripe by stripe
- sk = srcblk.offset;
- sj = sscanw + 1;
- for (s = nstripes - 1; s >= 0; s--, sk += kstep, sj += jstep)
- {
- sheight = (s != 0) ? CSJ2K.j2k.entropy.StdEntropyCoderOptions.STRIPE_HEIGHT : srcblk.h - (nstripes - 1) * CSJ2K.j2k.entropy.StdEntropyCoderOptions.STRIPE_HEIGHT;
- stopsk = sk + srcblk.w;
- // Scan by set of 1 stripe column at a time
- for (nsym = 0; sk < stopsk; sk++, sj++)
- {
- // Do half top of column
- j = sj;
- csj = state[j];
- // If any of the two samples is significant and not yet
- // visited in the current bit-plane we can not skip them
- if ((((SupportClass.URShift(csj, 1)) & (~csj)) & VSTD_MASK_R1R2) != 0)
- {
- k = sk;
- // Scan first row
- if ((csj & (STATE_SIG_R1 | STATE_VISITED_R1)) == STATE_SIG_R1)
- {
- // Apply MR primitive
- symbuf[nsym] = SupportClass.URShift((data[k] & mask), bp);
- ctxtbuf[nsym++] = MR_LUT[csj & MR_MASK];
- // Update the STATE_PREV_MR bit
- csj |= STATE_PREV_MR_R1;
- // Update distortion
- normval = (data[k] >> downshift) << upshift;
- dist += fm[normval & ((1 << MSE_LKP_BITS) - 1)];
- }
- if (sheight < 2)
- {
- state[j] = csj;
- continue;
- }
- // Scan second row
- if ((csj & (STATE_SIG_R2 | STATE_VISITED_R2)) == STATE_SIG_R2)
- {
- k += dscanw;
- // Apply MR primitive
- symbuf[nsym] = SupportClass.URShift((data[k] & mask), bp);
- ctxtbuf[nsym++] = MR_LUT[(SupportClass.URShift(csj, STATE_SEP)) & MR_MASK];
- // Update the STATE_PREV_MR bit
- csj |= STATE_PREV_MR_R2;
- // Update distortion
- normval = (data[k] >> downshift) << upshift;
- dist += fm[normval & ((1 << MSE_LKP_BITS) - 1)];
- }
- state[j] = csj;
- }
- // Do half bottom of column
- if (sheight < 3)
- continue;
- j += sscanw;
- csj = state[j];
- // If any of the two samples is significant and not yet
- // visited in the current bit-plane we can not skip them
- if ((((SupportClass.URShift(csj, 1)) & (~csj)) & VSTD_MASK_R1R2) != 0)
- {
- k = sk + (dscanw << 1);
- // Scan first row
- if ((csj & (STATE_SIG_R1 | STATE_VISITED_R1)) == STATE_SIG_R1)
- {
- // Apply MR primitive
- symbuf[nsym] = SupportClass.URShift((data[k] & mask), bp);
- ctxtbuf[nsym++] = MR_LUT[csj & MR_MASK];
- // Update the STATE_PREV_MR bit
- csj |= STATE_PREV_MR_R1;
- // Update distortion
- normval = (data[k] >> downshift) << upshift;
- dist += fm[normval & ((1 << MSE_LKP_BITS) - 1)];
- }
- if (sheight < 4)
- {
- state[j] = csj;
- continue;
- }
- // Scan second row
- if ((state[j] & (STATE_SIG_R2 | STATE_VISITED_R2)) == STATE_SIG_R2)
- {
- k += dscanw;
- // Apply MR primitive
- symbuf[nsym] = SupportClass.URShift((data[k] & mask), bp);
- ctxtbuf[nsym++] = MR_LUT[(SupportClass.URShift(csj, STATE_SEP)) & MR_MASK];
- // Update the STATE_PREV_MR bit
- csj |= STATE_PREV_MR_R2;
- // Update distortion
- normval = (data[k] >> downshift) << upshift;
- dist += fm[normval & ((1 << MSE_LKP_BITS) - 1)];
- }
- state[j] = csj;
- }
- }
- // Code all buffered symbols, if any
- if (nsym > 0)
- mq.codeSymbols(symbuf, ctxtbuf, nsym);
- }
-
- // Reset the MQ context states if we need to
- if ((options & CSJ2K.j2k.entropy.StdEntropyCoderOptions.OPT_RESET_MQ) != 0)
- {
- mq.resetCtxts();
- }
-
- // Terminate the MQ bit stream if we need to
- if (doterm)
- {
- ratebuf[pidx] = mq.terminate(); // Termination has special length
- }
- else
- {
- // Use normal length calculation
- ratebuf[pidx] = mq.NumCodedBytes;
- }
- // Add length of previous segments, if any
- if (ltpidx >= 0)
- {
- ratebuf[pidx] += ratebuf[ltpidx];
- }
- // Finish length calculation if needed
- if (doterm)
- {
- mq.finishLengthCalculation(ratebuf, pidx);
- }
-
- // Return the reduction in distortion
- return dist;
- }
-
- /// Performs the magnitude refinement pass on the specified data and
- /// bit-plane, without using the arithmetic coder. It codes the samples
- /// which are significant and which do not have the "visited" state bit
- /// turned on, using the MR primitive. The "visited" state bit is not
- /// mofified for any samples.
- ///
- /// In this method, the arithmetic coder is bypassed, and raw bits are
- /// directly written in the bit stream (useful when distribution are close
- /// to uniform, for intance, at high bit-rates and at lossless
- /// compression). The 'STATE_PREV_MR_R1' and 'STATE_PREV_MR_R2' bits are
- /// not set because they are used only when the arithmetic coder is not
- /// bypassed.
- ///
- ///
- /// The code-block data to code
- ///
- ///
- /// The bit based output
- ///
- ///
- /// If true the bit based output is byte aligned after the
- /// end of the pass.
- ///
- ///
- /// The bit-plane to code
- ///
- ///
- /// The state information for the code-block
- ///
- ///
- /// The distortion estimation lookup table for MR
- ///
- ///
- /// The buffer where to store the rate (i.e. coded lenth) at
- /// the end of this coding pass.
- ///
- ///
- /// The coding pass index. Is the index in the 'ratebuf' array
- /// where to store the coded length after this coding pass.
- ///
- ///
- /// The index of the last pass that was terminated, or
- /// negative if none.
- ///
- ///
- /// The bitmask of entropy coding options to apply to the
- /// code-block
- ///
- ///
- /// The decrease in distortion for this pass, in the fixed-point
- /// normalized representation of the 'FS_LOSSY' and 'FS_LOSSLESS' tables.
- ///
- ///
- static private int rawMagRefPass(CBlkWTData srcblk, BitToByteOutput bout, bool doterm, int bp, int[] state, int[] fm, int[] ratebuf, int pidx, int ltpidx, int options)
- {
- int j, sj; // The state index for line and stripe
- int k, sk; // The data index for line and stripe
- int dscanw; // The data scan-width
- int sscanw; // The state scan-width
- int jstep; // Stripe to stripe step for 'sj'
- int kstep; // Stripe to stripe step for 'sk'
- int stopsk; // The loop limit on the variable sk
- int csj; // Local copy (i.e. cached) of 'state[j]'
- int mask; // The mask for the current bit-plane
- int[] data; // The data buffer
- int dist; // The distortion reduction for this pass
- int shift; // Shift amount for distortion
- int upshift; // Shift left amount for distortion
- int downshift; // Shift right amount for distortion
- int normval; // The normalized sample magnitude value
- int s; // The stripe index
- int nstripes; // The number of stripes in the code-block
- int sheight; // Height of the current stripe
- int nsym = 0;
-
- // Initialize local variables
- dscanw = srcblk.scanw;
- sscanw = srcblk.w + 2;
- jstep = sscanw * CSJ2K.j2k.entropy.StdEntropyCoderOptions.STRIPE_HEIGHT / 2 - srcblk.w;
- kstep = dscanw * CSJ2K.j2k.entropy.StdEntropyCoderOptions.STRIPE_HEIGHT - srcblk.w;
- mask = 1 << bp;
- data = (int[])srcblk.Data;
- nstripes = (srcblk.h + CSJ2K.j2k.entropy.StdEntropyCoderOptions.STRIPE_HEIGHT - 1) / CSJ2K.j2k.entropy.StdEntropyCoderOptions.STRIPE_HEIGHT;
- dist = 0;
- // We use the bit just coded plus MSE_LKP_BITS-1 bits below the bit
- // just coded for distortion estimation.
- shift = bp - MSE_LKP_BITS_M1;
- upshift = (shift >= 0) ? 0 : -shift;
- downshift = (shift <= 0) ? 0 : shift;
-
- // Code stripe by stripe
- sk = srcblk.offset;
- sj = sscanw + 1;
- for (s = nstripes - 1; s >= 0; s--, sk += kstep, sj += jstep)
- {
- sheight = (s != 0) ? CSJ2K.j2k.entropy.StdEntropyCoderOptions.STRIPE_HEIGHT : srcblk.h - (nstripes - 1) * CSJ2K.j2k.entropy.StdEntropyCoderOptions.STRIPE_HEIGHT;
- stopsk = sk + srcblk.w;
- // Scan by set of 1 stripe column at a time
- for (; sk < stopsk; sk++, sj++)
- {
- // Do half top of column
- j = sj;
- csj = state[j];
- // If any of the two samples is significant and not yet
- // visited in the current bit-plane we can not skip them
- if ((((SupportClass.URShift(csj, 1)) & (~csj)) & VSTD_MASK_R1R2) != 0)
- {
- k = sk;
- // Scan first row
- if ((csj & (STATE_SIG_R1 | STATE_VISITED_R1)) == STATE_SIG_R1)
- {
- // Code bit "raw"
- bout.writeBit(SupportClass.URShift((data[k] & mask), bp));
- nsym++;
- // No need to set STATE_PREV_MR_R1 since all magnitude
- // refinement passes to follow are "raw"
- // Update distortion
- normval = (data[k] >> downshift) << upshift;
- dist += fm[normval & ((1 << MSE_LKP_BITS) - 1)];
- }
- if (sheight < 2)
- continue;
- // Scan second row
- if ((csj & (STATE_SIG_R2 | STATE_VISITED_R2)) == STATE_SIG_R2)
- {
- k += dscanw;
- // Code bit "raw"
- bout.writeBit(SupportClass.URShift((data[k] & mask), bp));
- nsym++;
- // No need to set STATE_PREV_MR_R2 since all magnitude
- // refinement passes to follow are "raw"
- // Update distortion
- normval = (data[k] >> downshift) << upshift;
- dist += fm[normval & ((1 << MSE_LKP_BITS) - 1)];
- }
- }
- // Do half bottom of column
- if (sheight < 3)
- continue;
- j += sscanw;
- csj = state[j];
- // If any of the two samples is significant and not yet
- // visited in the current bit-plane we can not skip them
- if ((((SupportClass.URShift(csj, 1)) & (~csj)) & VSTD_MASK_R1R2) != 0)
- {
- k = sk + (dscanw << 1);
- // Scan first row
- if ((csj & (STATE_SIG_R1 | STATE_VISITED_R1)) == STATE_SIG_R1)
- {
- // Code bit "raw"
- bout.writeBit(SupportClass.URShift((data[k] & mask), bp));
- nsym++;
- // No need to set STATE_PREV_MR_R1 since all magnitude
- // refinement passes to follow are "raw"
- // Update distortion
- normval = (data[k] >> downshift) << upshift;
- dist += fm[normval & ((1 << MSE_LKP_BITS) - 1)];
- }
- if (sheight < 4)
- continue;
- // Scan second row
- if ((state[j] & (STATE_SIG_R2 | STATE_VISITED_R2)) == STATE_SIG_R2)
- {
- k += dscanw;
- // Code bit "raw"
- bout.writeBit(SupportClass.URShift((data[k] & mask), bp));
- nsym++;
- // No need to set STATE_PREV_MR_R2 since all magnitude
- // refinement passes to follow are "raw"
- // Update distortion
- normval = (data[k] >> downshift) << upshift;
- dist += fm[normval & ((1 << MSE_LKP_BITS) - 1)];
- }
- }
- }
- }
-
- // Get length and terminate if needed
- if (doterm)
- {
- ratebuf[pidx] = bout.terminate();
- }
- else
- {
- ratebuf[pidx] = bout.length();
- }
-
- // Add length of previous segments, if any
- if (ltpidx >= 0)
- {
- ratebuf[pidx] += ratebuf[ltpidx];
- }
-
- // Return the reduction in distortion
- return dist;
- }
-
- /// Performs the cleanup pass on the specified data and bit-plane. It codes
- /// all insignificant samples which have its "visited" state bit off, using
- /// the ZC, SC, and RLC primitives. It toggles the "visited" state bit to 0
- /// (off) for all samples in the code-block.
- ///
- ///
- /// The code-block data to code
- ///
- ///
- /// The MQ-coder to use
- ///
- ///
- /// If true it performs an MQ-coder termination after the end
- /// of the pass
- ///
- ///
- /// The bit-plane to code
- ///
- ///
- /// The state information for the code-block
- ///
- ///
- /// The distortion estimation lookup table for SC
- ///
- ///
- /// The ZC lookup table to use in ZC.
- ///
- ///
- /// The buffer to hold symbols to send to the MQ coder
- ///
- ///
- /// A buffer to hold the contexts to use in sending the
- /// buffered symbols to the MQ coder.
- ///
- ///
- /// The buffer where to store the rate (i.e. coded lenth) at
- /// the end of this coding pass.
- ///
- ///
- /// The coding pass index. Is the index in the 'ratebuf' array
- /// where to store the coded length after this coding pass.
- ///
- ///
- /// The index of the last pass that was terminated, or
- /// negative if none.
- ///
- ///
- /// The bitmask of entropy coding options to apply to the
- /// code-block
- ///
- ///
- /// The decrease in distortion for this pass, in the fixed-point
- /// normalized representation of the 'FS_LOSSY' and 'FS_LOSSLESS' tables.
- ///
- ///
- static private int cleanuppass(CBlkWTData srcblk, MQCoder mq, bool doterm, int bp, int[] state, int[] fs, int[] zc_lut, int[] symbuf, int[] ctxtbuf, int[] ratebuf, int pidx, int ltpidx, int options)
- {
- // NOTE: The speedup mode of the MQ coder has been briefly tried to
- // speed up the coding of insignificants RLCs, without any success
- // (i.e. no speedup whatsoever). The use of the speedup mode should be
- // revisisted more in depth and the implementationn of it in MQCoder
- // should be reviewed for optimization opportunities.
- int j, sj; // The state index for line and stripe
- int k, sk; // The data index for line and stripe
- int nsym = 0; // Symbol counter for symbol and context buffers
- int dscanw; // The data scan-width
- int sscanw; // The state scan-width
- int jstep; // Stripe to stripe step for 'sj'
- int kstep; // Stripe to stripe step for 'sk'
- int stopsk; // The loop limit on the variable sk
- int csj; // Local copy (i.e. cached) of 'state[j]'
- int mask; // The mask for the current bit-plane
- int sym; // The symbol to code
- int rlclen; // Length of RLC
- int ctxt; // The context to use
- int[] data; // The data buffer
- int dist; // The distortion reduction for this pass
- int shift; // Shift amount for distortion
- int upshift; // Shift left amount for distortion
- int downshift; // Shift right amount for distortion
- int normval; // The normalized sample magnitude value
- int s; // The stripe index
- bool causal; // Flag to indicate if stripe-causal context
- // formation is to be used
- int nstripes; // The number of stripes in the code-block
- int sheight; // Height of the current stripe
- int off_ul, off_ur, off_dr, off_dl; // offsets
-
- // Initialize local variables
- dscanw = srcblk.scanw;
- sscanw = srcblk.w + 2;
- jstep = sscanw * CSJ2K.j2k.entropy.StdEntropyCoderOptions.STRIPE_HEIGHT / 2 - srcblk.w;
- kstep = dscanw * CSJ2K.j2k.entropy.StdEntropyCoderOptions.STRIPE_HEIGHT - srcblk.w;
- mask = 1 << bp;
- data = (int[])srcblk.Data;
- nstripes = (srcblk.h + CSJ2K.j2k.entropy.StdEntropyCoderOptions.STRIPE_HEIGHT - 1) / CSJ2K.j2k.entropy.StdEntropyCoderOptions.STRIPE_HEIGHT;
- dist = 0;
- // We use the MSE_LKP_BITS-1 bits below the bit just coded for
- // distortion estimation.
- shift = bp - MSE_LKP_BITS_M1;
- upshift = (shift >= 0) ? 0 : -shift;
- downshift = (shift <= 0) ? 0 : shift;
- causal = (options & CSJ2K.j2k.entropy.StdEntropyCoderOptions.OPT_VERT_STR_CAUSAL) != 0;
-
- // Pre-calculate offsets in 'state' for diagonal neighbors
- off_ul = -sscanw - 1; // up-left
- off_ur = -sscanw + 1; // up-right
- off_dr = sscanw + 1; // down-right
- off_dl = sscanw - 1; // down-left
-
- // Code stripe by stripe
- sk = srcblk.offset;
- sj = sscanw + 1;
- for (s = nstripes - 1; s >= 0; s--, sk += kstep, sj += jstep)
- {
- sheight = (s != 0) ? CSJ2K.j2k.entropy.StdEntropyCoderOptions.STRIPE_HEIGHT : srcblk.h - (nstripes - 1) * CSJ2K.j2k.entropy.StdEntropyCoderOptions.STRIPE_HEIGHT;
- stopsk = sk + srcblk.w;
- // Scan by set of 1 stripe column at a time
- for (nsym = 0; sk < stopsk; sk++, sj++)
- {
- // Start column
- j = sj;
- csj = state[j];
- {
- // Check for RLC: if all samples are not significant, not
- // visited and do not have a non-zero context, and column
- // is full height, we do RLC.
- if (csj == 0 && state[j + sscanw] == 0 && sheight == CSJ2K.j2k.entropy.StdEntropyCoderOptions.STRIPE_HEIGHT)
- {
- k = sk;
- if ((data[k] & mask) != 0)
- {
- rlclen = 0;
- }
- else if ((data[k += dscanw] & mask) != 0)
- {
- rlclen = 1;
- }
- else if ((data[k += dscanw] & mask) != 0)
- {
- rlclen = 2;
- j += sscanw;
- csj = state[j];
- }
- else if ((data[k += dscanw] & mask) != 0)
- {
- rlclen = 3;
- j += sscanw;
- csj = state[j];
- }
- else
- {
- // Code insignificant RLC
- symbuf[nsym] = 0;
- ctxtbuf[nsym++] = RLC_CTXT;
- // Goto next column
- continue;
- }
- // Code significant RLC
- symbuf[nsym] = 1;
- ctxtbuf[nsym++] = RLC_CTXT;
- // Send MSB bit index
- symbuf[nsym] = rlclen >> 1;
- ctxtbuf[nsym++] = UNIF_CTXT;
- // Send LSB bit index
- symbuf[nsym] = rlclen & 0x01;
- ctxtbuf[nsym++] = UNIF_CTXT;
- // Code sign of sample that became significant
- // Update distortion
- normval = (data[k] >> downshift) << upshift;
- dist += fs[normval & ((1 << MSE_LKP_BITS_M1) - 1)];
- // Apply sign coding
- sym = SupportClass.URShift(data[k], 31);
- if ((rlclen & 0x01) == 0)
- {
- // Sample that became significant is first row of
- // its column half
- ctxt = SC_LUT[(SupportClass.URShift(csj, SC_SHIFT_R1)) & SC_MASK];
- symbuf[nsym] = sym ^ (SupportClass.URShift(ctxt, SC_SPRED_SHIFT));
- ctxtbuf[nsym++] = ctxt & SC_LUT_MASK;
- // Update state information (significant bit,
- // visited bit, neighbor significant bit of
- // neighbors, non zero context of neighbors, sign
- // of neighbors)
- if (rlclen != 0 || !causal)
- {
- // If in causal mode do not change contexts of
- // previous stripe.
- state[j + off_ul] |= STATE_NZ_CTXT_R2 | STATE_D_DR_R2;
- state[j + off_ur] |= STATE_NZ_CTXT_R2 | STATE_D_DL_R2;
- }
- // Update sign state information of neighbors
- if (sym != 0)
- {
- csj |= STATE_SIG_R1 | STATE_VISITED_R1 | STATE_NZ_CTXT_R2 | STATE_V_U_R2 | STATE_V_U_SIGN_R2;
- if (rlclen != 0 || !causal)
- {
- // If in causal mode do not change
- // contexts of previous stripe.
- state[j - sscanw] |= STATE_NZ_CTXT_R2 | STATE_V_D_R2 | STATE_V_D_SIGN_R2;
- }
- state[j + 1] |= STATE_NZ_CTXT_R1 | STATE_NZ_CTXT_R2 | STATE_H_L_R1 | STATE_H_L_SIGN_R1 | STATE_D_UL_R2;
- state[j - 1] |= STATE_NZ_CTXT_R1 | STATE_NZ_CTXT_R2 | STATE_H_R_R1 | STATE_H_R_SIGN_R1 | STATE_D_UR_R2;
- }
- else
- {
- csj |= STATE_SIG_R1 | STATE_VISITED_R1 | STATE_NZ_CTXT_R2 | STATE_V_U_R2;
- if (rlclen != 0 || !causal)
- {
- // If in causal mode do not change
- // contexts of previous stripe.
- state[j - sscanw] |= STATE_NZ_CTXT_R2 | STATE_V_D_R2;
- }
- state[j + 1] |= STATE_NZ_CTXT_R1 | STATE_NZ_CTXT_R2 | STATE_H_L_R1 | STATE_D_UL_R2;
- state[j - 1] |= STATE_NZ_CTXT_R1 | STATE_NZ_CTXT_R2 | STATE_H_R_R1 | STATE_D_UR_R2;
- }
- // Changes to csj are saved later
- if ((rlclen >> 1) != 0)
- {
- // Sample that became significant is in bottom
- // half of column => jump to bottom half
- //UPGRADE_NOTE: Labeled break statement was changed to a goto statement. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1012'"
- goto top_half_brk;
- }
- // Otherwise sample that became significant is in
- // top half of column => continue on top half
- }
- else
- {
- // Sample that became significant is second row of
- // its column half
- ctxt = SC_LUT[(SupportClass.URShift(csj, SC_SHIFT_R2)) & SC_MASK];
- symbuf[nsym] = sym ^ (SupportClass.URShift(ctxt, SC_SPRED_SHIFT));
- ctxtbuf[nsym++] = ctxt & SC_LUT_MASK;
- // Update state information (significant bit,
- // neighbor significant bit of neighbors, non zero
- // context of neighbors, sign of neighbors)
- state[j + off_dl] |= STATE_NZ_CTXT_R1 | STATE_D_UR_R1;
- state[j + off_dr] |= STATE_NZ_CTXT_R1 | STATE_D_UL_R1;
- // Update sign state information of neighbors
- if (sym != 0)
- {
- csj |= STATE_SIG_R2 | STATE_NZ_CTXT_R1 | STATE_V_D_R1 | STATE_V_D_SIGN_R1;
- state[j + sscanw] |= STATE_NZ_CTXT_R1 | STATE_V_U_R1 | STATE_V_U_SIGN_R1;
- state[j + 1] |= STATE_NZ_CTXT_R1 | STATE_NZ_CTXT_R2 | STATE_D_DL_R1 | STATE_H_L_R2 | STATE_H_L_SIGN_R2;
- state[j - 1] |= STATE_NZ_CTXT_R1 | STATE_NZ_CTXT_R2 | STATE_D_DR_R1 | STATE_H_R_R2 | STATE_H_R_SIGN_R2;
- }
- else
- {
- csj |= STATE_SIG_R2 | STATE_NZ_CTXT_R1 | STATE_V_D_R1;
- state[j + sscanw] |= STATE_NZ_CTXT_R1 | STATE_V_U_R1;
- state[j + 1] |= STATE_NZ_CTXT_R1 | STATE_NZ_CTXT_R2 | STATE_D_DL_R1 | STATE_H_L_R2;
- state[j - 1] |= STATE_NZ_CTXT_R1 | STATE_NZ_CTXT_R2 | STATE_D_DR_R1 | STATE_H_R_R2;
- }
- // Save changes to csj
- state[j] = csj;
- if ((rlclen >> 1) != 0)
- {
- // Sample that became significant is in bottom
- // half of column => we're done with this
- // column
- continue;
- }
- // Otherwise sample that became significant is in
- // top half of column => we're done with top
- // column
- j += sscanw;
- csj = state[j];
- //UPGRADE_NOTE: Labeled break statement was changed to a goto statement. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1012'"
- goto top_half_brk;
- }
- }
- // Do half top of column
- // If any of the two samples is not significant and has
- // not been visited in the current bit-plane we can not
- // skip them
- if ((((csj >> 1) | csj) & VSTD_MASK_R1R2) != VSTD_MASK_R1R2)
- {
- k = sk;
- // Scan first row
- if ((csj & (STATE_SIG_R1 | STATE_VISITED_R1)) == 0)
- {
- // Apply zero coding
- ctxtbuf[nsym] = zc_lut[csj & ZC_MASK];
- if ((symbuf[nsym++] = SupportClass.URShift((data[k] & mask), bp)) != 0)
- {
- // Became significant
- // Apply sign coding
- sym = SupportClass.URShift(data[k], 31);
- ctxt = SC_LUT[(SupportClass.URShift(csj, SC_SHIFT_R1)) & SC_MASK];
- symbuf[nsym] = sym ^ (SupportClass.URShift(ctxt, SC_SPRED_SHIFT));
- ctxtbuf[nsym++] = ctxt & SC_LUT_MASK;
- // Update state information (significant bit,
- // visited bit, neighbor significant bit of
- // neighbors, non zero context of neighbors,
- // sign of neighbors)
- if (!causal)
- {
- // If in causal mode do not change
- // contexts of previous stripe.
- state[j + off_ul] |= STATE_NZ_CTXT_R2 | STATE_D_DR_R2;
- state[j + off_ur] |= STATE_NZ_CTXT_R2 | STATE_D_DL_R2;
- }
- // Update sign state information of neighbors
- if (sym != 0)
- {
- csj |= STATE_SIG_R1 | STATE_VISITED_R1 | STATE_NZ_CTXT_R2 | STATE_V_U_R2 | STATE_V_U_SIGN_R2;
- if (!causal)
- {
- // If in causal mode do not change
- // contexts of previous stripe.
- state[j - sscanw] |= STATE_NZ_CTXT_R2 | STATE_V_D_R2 | STATE_V_D_SIGN_R2;
- }
- state[j + 1] |= STATE_NZ_CTXT_R1 | STATE_NZ_CTXT_R2 | STATE_H_L_R1 | STATE_H_L_SIGN_R1 | STATE_D_UL_R2;
- state[j - 1] |= STATE_NZ_CTXT_R1 | STATE_NZ_CTXT_R2 | STATE_H_R_R1 | STATE_H_R_SIGN_R1 | STATE_D_UR_R2;
- }
- else
- {
- csj |= STATE_SIG_R1 | STATE_VISITED_R1 | STATE_NZ_CTXT_R2 | STATE_V_U_R2;
- if (!causal)
- {
- // If in causal mode do not change
- // contexts of previous stripe.
- state[j - sscanw] |= STATE_NZ_CTXT_R2 | STATE_V_D_R2;
- }
- state[j + 1] |= STATE_NZ_CTXT_R1 | STATE_NZ_CTXT_R2 | STATE_H_L_R1 | STATE_D_UL_R2;
- state[j - 1] |= STATE_NZ_CTXT_R1 | STATE_NZ_CTXT_R2 | STATE_H_R_R1 | STATE_D_UR_R2;
- }
- // Update distortion
- normval = (data[k] >> downshift) << upshift;
- dist += fs[normval & ((1 << MSE_LKP_BITS_M1) - 1)];
- }
- }
- if (sheight < 2)
- {
- csj &= ~(STATE_VISITED_R1 | STATE_VISITED_R2);
- state[j] = csj;
- continue;
- }
- // Scan second row
- if ((csj & (STATE_SIG_R2 | STATE_VISITED_R2)) == 0)
- {
- k += dscanw;
- // Apply zero coding
- ctxtbuf[nsym] = zc_lut[(SupportClass.URShift(csj, STATE_SEP)) & ZC_MASK];
- if ((symbuf[nsym++] = SupportClass.URShift((data[k] & mask), bp)) != 0)
- {
- // Became significant
- // Apply sign coding
- sym = SupportClass.URShift(data[k], 31);
- ctxt = SC_LUT[(SupportClass.URShift(csj, SC_SHIFT_R2)) & SC_MASK];
- symbuf[nsym] = sym ^ (SupportClass.URShift(ctxt, SC_SPRED_SHIFT));
- ctxtbuf[nsym++] = ctxt & SC_LUT_MASK;
- // Update state information (significant bit,
- // visited bit, neighbor significant bit of
- // neighbors, non zero context of neighbors,
- // sign of neighbors)
- state[j + off_dl] |= STATE_NZ_CTXT_R1 | STATE_D_UR_R1;
- state[j + off_dr] |= STATE_NZ_CTXT_R1 | STATE_D_UL_R1;
- // Update sign state information of neighbors
- if (sym != 0)
- {
- csj |= STATE_SIG_R2 | STATE_VISITED_R2 | STATE_NZ_CTXT_R1 | STATE_V_D_R1 | STATE_V_D_SIGN_R1;
- state[j + sscanw] |= STATE_NZ_CTXT_R1 | STATE_V_U_R1 | STATE_V_U_SIGN_R1;
- state[j + 1] |= STATE_NZ_CTXT_R1 | STATE_NZ_CTXT_R2 | STATE_D_DL_R1 | STATE_H_L_R2 | STATE_H_L_SIGN_R2;
- state[j - 1] |= STATE_NZ_CTXT_R1 | STATE_NZ_CTXT_R2 | STATE_D_DR_R1 | STATE_H_R_R2 | STATE_H_R_SIGN_R2;
- }
- else
- {
- csj |= STATE_SIG_R2 | STATE_VISITED_R2 | STATE_NZ_CTXT_R1 | STATE_V_D_R1;
- state[j + sscanw] |= STATE_NZ_CTXT_R1 | STATE_V_U_R1;
- state[j + 1] |= STATE_NZ_CTXT_R1 | STATE_NZ_CTXT_R2 | STATE_D_DL_R1 | STATE_H_L_R2;
- state[j - 1] |= STATE_NZ_CTXT_R1 | STATE_NZ_CTXT_R2 | STATE_D_DR_R1 | STATE_H_R_R2;
- }
- // Update distortion
- normval = (data[k] >> downshift) << upshift;
- dist += fs[normval & ((1 << MSE_LKP_BITS_M1) - 1)];
- }
- }
- }
- csj &= ~(STATE_VISITED_R1 | STATE_VISITED_R2);
- state[j] = csj;
- // Do half bottom of column
- if (sheight < 3)
- continue;
- j += sscanw;
- csj = state[j];
- }
- //UPGRADE_NOTE: Label 'top_half_brk' was added. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1011'"
-
- top_half_brk:;
- // end of 'top_half' block
- // If any of the two samples is not significant and has
- // not been visited in the current bit-plane we can not
- // skip them
- if ((((csj >> 1) | csj) & VSTD_MASK_R1R2) != VSTD_MASK_R1R2)
- {
- k = sk + (dscanw << 1);
- // Scan first row
- if ((csj & (STATE_SIG_R1 | STATE_VISITED_R1)) == 0)
- {
- // Apply zero coding
- ctxtbuf[nsym] = zc_lut[csj & ZC_MASK];
- if ((symbuf[nsym++] = SupportClass.URShift((data[k] & mask), bp)) != 0)
- {
- // Became significant
- // Apply sign coding
- sym = SupportClass.URShift(data[k], 31);
- ctxt = SC_LUT[(SupportClass.URShift(csj, SC_SHIFT_R1)) & SC_MASK];
- symbuf[nsym] = sym ^ (SupportClass.URShift(ctxt, SC_SPRED_SHIFT));
- ctxtbuf[nsym++] = ctxt & SC_LUT_MASK;
- // Update state information (significant bit,
- // visited bit, neighbor significant bit of
- // neighbors, non zero context of neighbors,
- // sign of neighbors)
- state[j + off_ul] |= STATE_NZ_CTXT_R2 | STATE_D_DR_R2;
- state[j + off_ur] |= STATE_NZ_CTXT_R2 | STATE_D_DL_R2;
- // Update sign state information of neighbors
- if (sym != 0)
- {
- csj |= STATE_SIG_R1 | STATE_VISITED_R1 | STATE_NZ_CTXT_R2 | STATE_V_U_R2 | STATE_V_U_SIGN_R2;
- state[j - sscanw] |= STATE_NZ_CTXT_R2 | STATE_V_D_R2 | STATE_V_D_SIGN_R2;
- state[j + 1] |= STATE_NZ_CTXT_R1 | STATE_NZ_CTXT_R2 | STATE_H_L_R1 | STATE_H_L_SIGN_R1 | STATE_D_UL_R2;
- state[j - 1] |= STATE_NZ_CTXT_R1 | STATE_NZ_CTXT_R2 | STATE_H_R_R1 | STATE_H_R_SIGN_R1 | STATE_D_UR_R2;
- }
- else
- {
- csj |= STATE_SIG_R1 | STATE_VISITED_R1 | STATE_NZ_CTXT_R2 | STATE_V_U_R2;
- state[j - sscanw] |= STATE_NZ_CTXT_R2 | STATE_V_D_R2;
- state[j + 1] |= STATE_NZ_CTXT_R1 | STATE_NZ_CTXT_R2 | STATE_H_L_R1 | STATE_D_UL_R2;
- state[j - 1] |= STATE_NZ_CTXT_R1 | STATE_NZ_CTXT_R2 | STATE_H_R_R1 | STATE_D_UR_R2;
- }
- // Update distortion
- normval = (data[k] >> downshift) << upshift;
- dist += fs[normval & ((1 << MSE_LKP_BITS_M1) - 1)];
- }
- }
- if (sheight < 4)
- {
- csj &= ~(STATE_VISITED_R1 | STATE_VISITED_R2);
- state[j] = csj;
- continue;
- }
- // Scan second row
- if ((csj & (STATE_SIG_R2 | STATE_VISITED_R2)) == 0)
- {
- k += dscanw;
- // Apply zero coding
- ctxtbuf[nsym] = zc_lut[(SupportClass.URShift(csj, STATE_SEP)) & ZC_MASK];
- if ((symbuf[nsym++] = SupportClass.URShift((data[k] & mask), bp)) != 0)
- {
- // Became significant
- // Apply sign coding
- sym = SupportClass.URShift(data[k], 31);
- ctxt = SC_LUT[(SupportClass.URShift(csj, SC_SHIFT_R2)) & SC_MASK];
- symbuf[nsym] = sym ^ (SupportClass.URShift(ctxt, SC_SPRED_SHIFT));
- ctxtbuf[nsym++] = ctxt & SC_LUT_MASK;
- // Update state information (significant bit,
- // visited bit, neighbor significant bit of
- // neighbors, non zero context of neighbors,
- // sign of neighbors)
- state[j + off_dl] |= STATE_NZ_CTXT_R1 | STATE_D_UR_R1;
- state[j + off_dr] |= STATE_NZ_CTXT_R1 | STATE_D_UL_R1;
- // Update sign state information of neighbors
- if (sym != 0)
- {
- csj |= STATE_SIG_R2 | STATE_VISITED_R2 | STATE_NZ_CTXT_R1 | STATE_V_D_R1 | STATE_V_D_SIGN_R1;
- state[j + sscanw] |= STATE_NZ_CTXT_R1 | STATE_V_U_R1 | STATE_V_U_SIGN_R1;
- state[j + 1] |= STATE_NZ_CTXT_R1 | STATE_NZ_CTXT_R2 | STATE_D_DL_R1 | STATE_H_L_R2 | STATE_H_L_SIGN_R2;
- state[j - 1] |= STATE_NZ_CTXT_R1 | STATE_NZ_CTXT_R2 | STATE_D_DR_R1 | STATE_H_R_R2 | STATE_H_R_SIGN_R2;
- }
- else
- {
- csj |= STATE_SIG_R2 | STATE_VISITED_R2 | STATE_NZ_CTXT_R1 | STATE_V_D_R1;
- state[j + sscanw] |= STATE_NZ_CTXT_R1 | STATE_V_U_R1;
- state[j + 1] |= STATE_NZ_CTXT_R1 | STATE_NZ_CTXT_R2 | STATE_D_DL_R1 | STATE_H_L_R2;
- state[j - 1] |= STATE_NZ_CTXT_R1 | STATE_NZ_CTXT_R2 | STATE_D_DR_R1 | STATE_H_R_R2;
- }
- // Update distortion
- normval = (data[k] >> downshift) << upshift;
- dist += fs[normval & ((1 << MSE_LKP_BITS_M1) - 1)];
- }
- }
- }
- csj &= ~(STATE_VISITED_R1 | STATE_VISITED_R2);
- state[j] = csj;
- }
- // Code all buffered symbols, if any
- if (nsym > 0)
- mq.codeSymbols(symbuf, ctxtbuf, nsym);
- }
-
- // Insert a segment marker if we need to
- if ((options & CSJ2K.j2k.entropy.StdEntropyCoderOptions.OPT_SEG_SYMBOLS) != 0)
- {
- mq.codeSymbols(SEG_SYMBOLS, SEG_SYMB_CTXTS, SEG_SYMBOLS.Length);
- }
-
- // Reset the MQ context states if we need to
- if ((options & CSJ2K.j2k.entropy.StdEntropyCoderOptions.OPT_RESET_MQ) != 0)
- {
- mq.resetCtxts();
- }
-
- // Terminate the MQ bit stream if we need to
- if (doterm)
- {
- ratebuf[pidx] = mq.terminate(); // Termination has special length
- }
- else
- {
- // Use normal length calculation
- ratebuf[pidx] = mq.NumCodedBytes;
- }
- // Add length of previous segments, if any
- if (ltpidx >= 0)
- {
- ratebuf[pidx] += ratebuf[ltpidx];
- }
- // Finish length calculation if needed
- if (doterm)
- {
- mq.finishLengthCalculation(ratebuf, pidx);
- }
- // Return the reduction in distortion
- return dist;
- }
-
- /// Ensures that at the end of a non-terminated coding pass there is not a
- /// 0xFF byte, modifying the stored rates if necessary.
- ///
- /// Due to error resiliance reasons, a coding pass should never have its
- /// last byte be a 0xFF, since that can lead to the emulation of a resync
- /// marker. This method checks if that is the case, and reduces the rate
- /// for a given pass if necessary. The ommitted 0xFF will be synthetized by
- /// the decoder if necessary, as required by JPEG 2000. This method should
- /// only be called once that the entire code-block is coded.
- ///
- /// Passes that are terminated are not checked for the 0xFF byte, since
- /// it is assumed that the termination procedure does not output any
- /// trailing 0xFF. Checking the terminated segments would involve much more
- /// than just modifying the stored rates.
- ///
- /// NOTE: It is assumed by this method that the coded data does not
- /// contain consecutive 0xFF bytes, as is the case with the MQ and
- /// 'arithemetic coding bypass' bit stuffing policy. However, the
- /// termination policies used should also respect this requirement.
- ///
- ///
- /// The coded data for the code-block
- ///
- ///
- /// The rate (i.e. accumulated number of bytes) for each
- /// coding pass
- ///
- ///
- /// An array of flags indicating, for each pass, if it is
- /// terminated or not. If null it is assumed that no pass is terminated,
- /// except the last one.
- ///
- ///
- /// The number of coding passes
- ///
- ///
- static private void checkEndOfPassFF(byte[] data, int[] rates, bool[] isterm, int n)
- {
- int dp; // the position to test in 'data'
-
- // If a pass ends in 0xFF we need to reduce the number of bytes in it,
- // so that it does not end in 0xFF. We only need to go back one byte
- // since there can be no consecutive 0xFF bytes.
-
- // If there are no terminated passes avoid the test on 'isterm'
- if (isterm == null)
- {
- for (n--; n >= 0; n--)
- {
- dp = rates[n] - 1;
- if (dp >= 0 && (data[dp] == (byte)0xFF))
- {
- rates[n]--;
- }
- }
- }
- else
- {
- for (n--; n >= 0; n--)
- {
- if (!isterm[n])
- {
- dp = rates[n] - 1;
- if (dp >= 0 && (data[dp] == (byte)0xFF))
- {
- rates[n]--;
- }
- }
- }
- }
- }
-
- /// Load options, length calculation type and termination type for each
- /// tile-component.
- ///
- ///
- /// The number of tiles
- ///
- ///
- /// The number of components
- ///
- ///
- public virtual void initTileComp(int nt, int nc)
- {
-
- opts = new int[nt][];
- for (int i2 = 0; i2 < nt; i2++)
- {
- opts[i2] = new int[nc];
- }
- lenCalc = new int[nt][];
- for (int i3 = 0; i3 < nt; i3++)
- {
- lenCalc[i3] = new int[nc];
- }
- tType = new int[nt][];
- for (int i4 = 0; i4 < nt; i4++)
- {
- tType[i4] = new int[nc];
- }
-
- for (int t = 0; t < nt; t++)
- {
- for (int c = 0; c < nc; c++)
- {
- opts[t][c] = 0;
-
- // Bypass coding mode ?
- if (((System.String)bms.getTileCompVal(t, c)).ToUpper().Equals("on".ToUpper()))
- {
- opts[t][c] |= CSJ2K.j2k.entropy.StdEntropyCoderOptions.OPT_BYPASS;
- }
- // MQ reset after each coding pass ?
- if (((System.String)mqrs.getTileCompVal(t, c)).ToUpper().Equals("on".ToUpper()))
- {
- opts[t][c] |= CSJ2K.j2k.entropy.StdEntropyCoderOptions.OPT_RESET_MQ;
- }
- // MQ termination after each arithmetically coded coding pass ?
- if (((System.String)rts.getTileCompVal(t, c)).ToUpper().Equals("on".ToUpper()))
- {
- opts[t][c] |= CSJ2K.j2k.entropy.StdEntropyCoderOptions.OPT_TERM_PASS;
- }
- // Vertically stripe-causal context mode ?
- if (((System.String)css.getTileCompVal(t, c)).ToUpper().Equals("on".ToUpper()))
- {
- opts[t][c] |= CSJ2K.j2k.entropy.StdEntropyCoderOptions.OPT_VERT_STR_CAUSAL;
- }
- // Error resilience segmentation symbol insertion ?
- if (((System.String)sss.getTileCompVal(t, c)).ToUpper().Equals("on".ToUpper()))
- {
- opts[t][c] |= CSJ2K.j2k.entropy.StdEntropyCoderOptions.OPT_SEG_SYMBOLS;
- }
-
- // Set length calculation type of the MQ coder
- System.String lCalcType = (System.String)lcs.getTileCompVal(t, c);
- if (lCalcType.Equals("near_opt"))
- {
- lenCalc[t][c] = MQCoder.LENGTH_NEAR_OPT;
- }
- else if (lCalcType.Equals("lazy_good"))
- {
- lenCalc[t][c] = MQCoder.LENGTH_LAZY_GOOD;
- }
- else if (lCalcType.Equals("lazy"))
- {
- lenCalc[t][c] = MQCoder.LENGTH_LAZY;
- }
- else
- {
- throw new System.ArgumentException("Unrecognized or " + "unsupported MQ " + "length calculation.");
- }
-
- // Set termination type of MQ coder
- System.String termType = (System.String)tts.getTileCompVal(t, c);
- if (termType.ToUpper().Equals("easy".ToUpper()))
- {
- tType[t][c] = MQCoder.TERM_EASY;
- }
- else if (termType.ToUpper().Equals("full".ToUpper()))
- {
- tType[t][c] = MQCoder.TERM_FULL;
- }
- else if (termType.ToUpper().Equals("near_opt".ToUpper()))
- {
- tType[t][c] = MQCoder.TERM_NEAR_OPT;
- }
- else if (termType.ToUpper().Equals("predict".ToUpper()))
- {
- tType[t][c] = MQCoder.TERM_PRED_ER;
- opts[t][c] |= CSJ2K.j2k.entropy.StdEntropyCoderOptions.OPT_PRED_TERM;
- if ((opts[t][c] & (CSJ2K.j2k.entropy.StdEntropyCoderOptions.OPT_TERM_PASS | CSJ2K.j2k.entropy.StdEntropyCoderOptions.OPT_BYPASS)) == 0)
- {
- FacilityManager.getMsgLogger().printmsg(CSJ2K.j2k.util.MsgLogger_Fields.INFO, "Using error resilient MQ" + " termination, but terminating only at " + "the end of code-blocks. The error " + "protection offered by this option will" + " be very weak. Specify the " + "'Cterminate' " + "and/or 'Cbypass' option for " + "increased error resilience.");
- }
- }
- else
- {
- throw new System.ArgumentException("Unrecognized or " + "unsupported " + "MQ coder " + "termination.");
- }
- } // End loop on components
- } // End loop on tiles
- }
-
- /// Returns the precinct partition width for the specified component, tile
- /// and resolution level.
- ///
- ///
- /// the tile index
- ///
- ///
- /// the component
- ///
- ///
- /// the resolution level
- ///
- ///
- /// The precinct partition width for the specified component, tile
- /// and resolution level
- ///
- ///
- public override int getPPX(int t, int c, int rl)
- {
- return pss.getPPX(t, c, rl);
- }
-
- /// Returns the precinct partition height for the specified component, tile
- /// and resolution level.
- ///
- ///
- /// the tile index
- ///
- ///
- /// the component
- ///
- ///
- /// the resolution level
- ///
- ///
- /// The precinct partition height for the specified component, tile
- /// and resolution level
- ///
- ///
- public override int getPPY(int t, int c, int rl)
- {
- return pss.getPPY(t, c, rl);
- }
-
- /// Returns true if precinct partition is used for the specified component
- /// and tile, returns false otherwise.
- ///
- ///
- /// The component
- ///
- ///
- /// The tile
- ///
- ///
- /// True if precinct partition is used for the specified component
- /// and tile, returns false otherwise.
- ///
- ///
- public override bool precinctPartitionUsed(int c, int t)
- {
- return precinctPartition[c][t];
- }
- /// Static initializer: initializes all the lookup tables.
- static StdEntropyCoder()
- {
- {
- int i, j;
- double val, deltaMSE;
- int[] inter_sc_lut;
- int ds, us, rs, ls;
- int dsgn, usgn, rsgn, lsgn;
- int h, v;
-
- // Initialize the zero coding lookup tables
-
- // LH
-
- // - No neighbors significant
- ZC_LUT_LH[0] = 2;
-
- // - No horizontal or vertical neighbors significant
- for (i = 1; i < 16; i++)
- {
- // Two or more diagonal coeffs significant
- ZC_LUT_LH[i] = 4;
- }
- for (i = 0; i < 4; i++)
- {
- // Only one diagonal coeff significant
- ZC_LUT_LH[1 << i] = 3;
- }
- // - No horizontal neighbors significant, diagonal irrelevant
- for (i = 0; i < 16; i++)
- {
- // Only one vertical coeff significant
- ZC_LUT_LH[STATE_V_U_R1 | i] = 5;
- ZC_LUT_LH[STATE_V_D_R1 | i] = 5;
- // The two vertical coeffs significant
- ZC_LUT_LH[STATE_V_U_R1 | STATE_V_D_R1 | i] = 6;
- }
- // - One horiz. neighbor significant, diagonal/vertical non-significant
- ZC_LUT_LH[STATE_H_L_R1] = 7;
- ZC_LUT_LH[STATE_H_R_R1] = 7;
- // - One horiz. significant, no vertical significant, one or more
- // diagonal significant
- for (i = 1; i < 16; i++)
- {
- ZC_LUT_LH[STATE_H_L_R1 | i] = 8;
- ZC_LUT_LH[STATE_H_R_R1 | i] = 8;
- }
- // - One horiz. significant, one or more vertical significant,
- // diagonal irrelevant
- for (i = 1; i < 4; i++)
- {
- for (j = 0; j < 16; j++)
- {
- ZC_LUT_LH[STATE_H_L_R1 | (i << 4) | j] = 9;
- ZC_LUT_LH[STATE_H_R_R1 | (i << 4) | j] = 9;
- }
- }
- // - Two horiz. significant, others irrelevant
- for (i = 0; i < 64; i++)
- {
- ZC_LUT_LH[STATE_H_L_R1 | STATE_H_R_R1 | i] = 10;
- }
-
- // HL
-
- // - No neighbors significant
- ZC_LUT_HL[0] = 2;
- // - No horizontal or vertical neighbors significant
- for (i = 1; i < 16; i++)
- {
- // Two or more diagonal coeffs significant
- ZC_LUT_HL[i] = 4;
- }
- for (i = 0; i < 4; i++)
- {
- // Only one diagonal coeff significant
- ZC_LUT_HL[1 << i] = 3;
- }
- // - No vertical significant, diagonal irrelevant
- for (i = 0; i < 16; i++)
- {
- // One horiz. significant
- ZC_LUT_HL[STATE_H_L_R1 | i] = 5;
- ZC_LUT_HL[STATE_H_R_R1 | i] = 5;
- // Two horiz. significant
- ZC_LUT_HL[STATE_H_L_R1 | STATE_H_R_R1 | i] = 6;
- }
- // - One vert. significant, diagonal/horizontal non-significant
- ZC_LUT_HL[STATE_V_U_R1] = 7;
- ZC_LUT_HL[STATE_V_D_R1] = 7;
- // - One vert. significant, horizontal non-significant, one or more
- // diag. significant
- for (i = 1; i < 16; i++)
- {
- ZC_LUT_HL[STATE_V_U_R1 | i] = 8;
- ZC_LUT_HL[STATE_V_D_R1 | i] = 8;
- }
- // - One vertical significant, one or more horizontal significant,
- // diagonal irrelevant
- for (i = 1; i < 4; i++)
- {
- for (j = 0; j < 16; j++)
- {
- ZC_LUT_HL[(i << 6) | STATE_V_U_R1 | j] = 9;
- ZC_LUT_HL[(i << 6) | STATE_V_D_R1 | j] = 9;
- }
- }
- // - Two vertical significant, others irrelevant
- for (i = 0; i < 4; i++)
- {
- for (j = 0; j < 16; j++)
- {
- ZC_LUT_HL[(i << 6) | STATE_V_U_R1 | STATE_V_D_R1 | j] = 10;
- }
- }
-
- // HH
- int[] twoBits = new int[] { 3, 5, 6, 9, 10, 12 }; // Figures (between 0 and 15)
- // countaning 2 and only 2 bits on in its binary representation.
-
- int[] oneBit = new int[] { 1, 2, 4, 8 }; // Figures (between 0 and 15)
- // countaning 1 and only 1 bit on in its binary representation.
-
- int[] twoLeast = new int[] { 3, 5, 6, 7, 9, 10, 11, 12, 13, 14, 15 }; // Figures
- // (between 0 and 15) countaining, at least, 2 bits on in its
- // binary representation.
-
- int[] threeLeast = new int[] { 7, 11, 13, 14, 15 }; // Figures
- // (between 0 and 15) countaining, at least, 3 bits on in its
- // binary representation.
-
- // - None significant
- ZC_LUT_HH[0] = 2;
-
- // - One horizontal+vertical significant, none diagonal
- for (i = 0; i < oneBit.Length; i++)
- ZC_LUT_HH[oneBit[i] << 4] = 3;
-
- // - Two or more horizontal+vertical significant, diagonal non-signif
- for (i = 0; i < twoLeast.Length; i++)
- ZC_LUT_HH[twoLeast[i] << 4] = 4;
-
- // - One diagonal significant, horiz./vert. non-significant
- for (i = 0; i < oneBit.Length; i++)
- ZC_LUT_HH[oneBit[i]] = 5;
-
- // - One diagonal significant, one horiz.+vert. significant
- for (i = 0; i < oneBit.Length; i++)
- for (j = 0; j < oneBit.Length; j++)
- ZC_LUT_HH[(oneBit[i] << 4) | oneBit[j]] = 6;
-
- // - One diag signif, two or more horiz+vert signif
- for (i = 0; i < twoLeast.Length; i++)
- for (j = 0; j < oneBit.Length; j++)
- ZC_LUT_HH[(twoLeast[i] << 4) | oneBit[j]] = 7;
-
- // - Two diagonal significant, none horiz+vert significant
- for (i = 0; i < twoBits.Length; i++)
- ZC_LUT_HH[twoBits[i]] = 8;
-
- // - Two diagonal significant, one or more horiz+vert significant
- for (j = 0; j < twoBits.Length; j++)
- for (i = 1; i < 16; i++)
- ZC_LUT_HH[(i << 4) | twoBits[j]] = 9;
-
- // - Three or more diagonal significant, horiz+vert irrelevant
- for (i = 0; i < 16; i++)
- for (j = 0; j < threeLeast.Length; j++)
- ZC_LUT_HH[(i << 4) | threeLeast[j]] = 10;
-
- // Initialize the SC lookup tables
-
- // Use an intermediate sign code lookup table that is similar to the
- // one in the VM text, in that it depends on the 'h' and 'v'
- // quantities. The index into this table is a 6 bit index, the top 3
- // bits are (h+1) and the low 3 bits (v+1).
- inter_sc_lut = new int[36];
- inter_sc_lut[(2 << 3) | 2] = 15;
- inter_sc_lut[(2 << 3) | 1] = 14;
- inter_sc_lut[(2 << 3) | 0] = 13;
- inter_sc_lut[(1 << 3) | 2] = 12;
- inter_sc_lut[(1 << 3) | 1] = 11;
- inter_sc_lut[(1 << 3) | 0] = 12 | INT_SIGN_BIT;
- inter_sc_lut[(0 << 3) | 2] = 13 | INT_SIGN_BIT;
- inter_sc_lut[(0 << 3) | 1] = 14 | INT_SIGN_BIT;
- inter_sc_lut[(0 << 3) | 0] = 15 | INT_SIGN_BIT;
-
- // Using the intermediate sign code lookup table create the final
- // one. The index into this table is a 9 bit index, the low 4 bits are
- // the significance of the 4 horizontal/vertical neighbors, while the
- // top 4 bits are the signs of those neighbors. The bit in the middle
- // is ignored. This index arrangement matches the state bits in the
- // 'state' array, thus direct addressing of the table can be done from
- // the sate information.
- for (i = 0; i < (1 << SC_LUT_BITS) - 1; i++)
- {
- ds = i & 0x01; // significance of down neighbor
- us = (i >> 1) & 0x01; // significance of up neighbor
- rs = (i >> 2) & 0x01; // significance of right neighbor
- ls = (i >> 3) & 0x01; // significance of left neighbor
- dsgn = (i >> 5) & 0x01; // sign of down neighbor
- usgn = (i >> 6) & 0x01; // sign of up neighbor
- rsgn = (i >> 7) & 0x01; // sign of right neighbor
- lsgn = (i >> 8) & 0x01; // sign of left neighbor
- // Calculate 'h' and 'v' as in VM text
- h = ls * (1 - 2 * lsgn) + rs * (1 - 2 * rsgn);
- h = (h >= -1) ? h : -1;
- h = (h <= 1) ? h : 1;
- v = us * (1 - 2 * usgn) + ds * (1 - 2 * dsgn);
- v = (v >= -1) ? v : -1;
- v = (v <= 1) ? v : 1;
- // Get context and sign predictor from 'inter_sc_lut'
- SC_LUT[i] = inter_sc_lut[(h + 1) << 3 | (v + 1)];
- }
- inter_sc_lut = null;
-
- // Initialize the MR lookup tables
-
- // None significant, prev MR off
- MR_LUT[0] = 16;
- // One or more significant, prev MR off
- for (i = 1; i < (1 << (MR_LUT_BITS - 1)); i++)
- {
- MR_LUT[i] = 17;
- }
- // Previous MR on, significance irrelevant
- for (; i < (1 << MR_LUT_BITS); i++)
- {
- MR_LUT[i] = 18;
- }
-
- // Initialize the distortion estimation lookup tables
-
- // fs tables
- for (i = 0; i < (1 << MSE_LKP_BITS_M1); i++)
- {
- // In fs we index by val-1, since val is really: 1 <= val < 2
- val = (double)i / (1 << MSE_LKP_BITS_M1) + 1.0;
- deltaMSE = val * val;
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- FS_LOSSLESS[i] = (int)System.Math.Floor(deltaMSE * ((double)(1 << MSE_LKP_FRAC_BITS)) + 0.5);
- val -= 1.5;
- deltaMSE -= val * val;
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- FS_LOSSY[i] = (int)System.Math.Floor(deltaMSE * ((double)(1 << MSE_LKP_FRAC_BITS)) + 0.5);
- }
-
- // fm tables
- for (i = 0; i < (1 << MSE_LKP_BITS); i++)
- {
- val = (double)i / (1 << MSE_LKP_BITS_M1);
- deltaMSE = (val - 1.0) * (val - 1.0);
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- FM_LOSSLESS[i] = (int)System.Math.Floor(deltaMSE * ((double)(1 << MSE_LKP_FRAC_BITS)) + 0.5);
- val -= ((i < (1 << MSE_LKP_BITS_M1)) ? 0.5 : 1.5);
- deltaMSE -= val * val;
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- FM_LOSSY[i] = (int)System.Math.Floor(deltaMSE * ((double)(1 << MSE_LKP_FRAC_BITS)) + 0.5);
- }
- }
- }
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/fileformat/FileFormatBoxes.cs b/CSJ2K/j2k/fileformat/FileFormatBoxes.cs
deleted file mode 100644
index a8f64248..00000000
--- a/CSJ2K/j2k/fileformat/FileFormatBoxes.cs
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
-* cvs identifier:
-*
-* $Id: FileFormatBoxes.java,v 1.10 2001/02/14 12:22:20 qtxjoas Exp $
-*
-* Class: FileFormatMarkers
-*
-* Description: Contains definitions of boxes used in jp2 files
-*
-*
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-*
-*
-*
-*/
-namespace CSJ2K.j2k.fileformat
-{
-
-
- /// This class contains all the markers used in the JPEG 2000 Part I file format
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- public struct FileFormatBoxes
- {
- /// * Main boxes ***
-
- public const int READER_REQUIREMENTS_BOX = 0x72726571;
- public const int JP2_SIGNATURE_BOX = 0x6a502020;
- public const int FILE_TYPE_BOX = 0x66747970;
- public const int JP2_HEADER_BOX = 0x6a703268;
- public const int CONTIGUOUS_CODESTREAM_BOX = 0x6a703263;
- public const int INTELLECTUAL_PROPERTY_BOX = 0x64703269;
- public const int XML_BOX = 0x786d6c20;
- public const int UUID_BOX = 0x75756964;
- public const int UUID_INFO_BOX = 0x75696e66;
- /// JP2 Header boxes
- public const int IMAGE_HEADER_BOX = 0x69686472;
- public const int BITS_PER_COMPONENT_BOX = 0x62706363;
- public const int COLOUR_SPECIFICATION_BOX = 0x636f6c72;
- public const int PALETTE_BOX = 0x70636c72;
- public const int COMPONENT_MAPPING_BOX = 0x636d6170;
- public const int CHANNEL_DEFINITION_BOX = 0x63646566;
- public const int RESOLUTION_BOX = 0x72657320;
- public const int CAPTURE_RESOLUTION_BOX = 0x72657363;
- public const int DEFAULT_DISPLAY_RESOLUTION_BOX = 0x72657364;
- /// UUID Info Boxes
- public const int UUID_LIST_BOX = 0x75637374;
- public const int URL_BOX = 0x75726c20;
- /// end of UUID Info boxes
- /// Image Header Box Fields
- public const int IMB_VERS = 0x0100;
- public const int IMB_C = 7;
- public const int IMB_UnkC = 1;
- public const int IMB_IPR = 0;
- /// end of Image Header Box Fields
- /// Colour Specification Box Fields
- public const int CSB_METH = 1;
- public const int CSB_PREC = 0;
- public const int CSB_APPROX = 0;
- public const int CSB_ENUM_SRGB = 16;
- public const int CSB_ENUM_GREY = 17;
- /// en of Colour Specification Box Fields
- /// File Type Fields
- public const int FT_BR = 0x6a703220;
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/fileformat/reader/FileFormatReader.cs b/CSJ2K/j2k/fileformat/reader/FileFormatReader.cs
deleted file mode 100644
index 5fbaa475..00000000
--- a/CSJ2K/j2k/fileformat/reader/FileFormatReader.cs
+++ /dev/null
@@ -1,451 +0,0 @@
-/*
-* cvs identifier:
-*
-* $Id: FileFormatReader.java,v 1.16 2002/07/25 14:04:08 grosbois Exp $
-*
-* Class: FileFormatReader
-*
-* Description: Reads the file format
-*
-*
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-* */
-using CSJ2K.j2k.io;
-using CSJ2K.j2k.util;
-namespace CSJ2K.j2k.fileformat.reader
-{
-
- /// This class reads the file format wrapper that may or may not exist around a
- /// valid JPEG 2000 codestream. Since no information from the file format is
- /// used in the actual decoding, this class simply goes through the file and
- /// finds the first valid codestream.
- ///
- ///
- ///
- ///
- ///
- public class FileFormatReader
- {
- /// This method creates and returns an array of positions to contiguous
- /// codestreams in the file
- ///
- ///
- /// The positions of the contiguous codestreams in the file
- ///
- ///
- virtual public long[] CodeStreamPos
- {
- get
- {
- int size = codeStreamPos.Count;
- long[] pos = new long[size];
- for (int i = 0; i < size; i++)
- pos[i] = (long)((System.Int32)(codeStreamPos[i]));
- return pos;
- }
-
- }
- /// This method returns the position of the first contiguous codestreams in
- /// the file
- ///
- ///
- /// The position of the first contiguous codestream in the file
- ///
- ///
- virtual public int FirstCodeStreamPos
- {
- get
- {
- return ((System.Int32)(codeStreamPos[0]));
- }
-
- }
- /// This method returns the length of the first contiguous codestreams in
- /// the file
- ///
- ///
- /// The length of the first contiguous codestream in the file
- ///
- ///
- virtual public int FirstCodeStreamLength
- {
- get
- {
- return ((System.Int32)(codeStreamLength[0]));
- }
-
- }
-
- /// The random access from which the file format boxes are read
- private RandomAccessIO in_Renamed;
-
- /// The positions of the codestreams in the fileformat
- private System.Collections.ArrayList codeStreamPos;
-
- /// The lengths of the codestreams in the fileformat
- private System.Collections.ArrayList codeStreamLength;
-
- /// Flag indicating whether or not the JP2 file format is used
- public bool JP2FFUsed;
-
- /// The constructor of the FileFormatReader
- ///
- ///
- /// The RandomAccessIO from which to read the file format
- ///
- ///
- public FileFormatReader(RandomAccessIO in_Renamed)
- {
- this.in_Renamed = in_Renamed;
- }
-
- /// This method checks whether the given RandomAccessIO is a valid JP2 file
- /// and if so finds the first codestream in the file. Currently, the
- /// information in the codestream is not used
- ///
- ///
- /// The RandomAccessIO from which to read the file format
- ///
- ///
- /// If an I/O error ocurred.
- ///
- ///
- /// If end of file is reached
- ///
- ///
- public virtual void readFileFormat()
- {
-
- //int foundCodeStreamBoxes = 0;
- int box;
- int length;
- long longLength = 0;
- int pos;
- short marker;
- bool jp2HeaderBoxFound = false;
- bool lastBoxFound = false;
-
- try
- {
-
- // Go through the randomaccessio and find the first contiguous
- // codestream box. Check also that the File Format is correct
-
- // Make sure that the first 12 bytes is the JP2_SIGNATURE_BOX or
- // if not that the first 2 bytes is the SOC marker
- if (in_Renamed.readInt() != 0x0000000c || in_Renamed.readInt() != CSJ2K.j2k.fileformat.FileFormatBoxes.JP2_SIGNATURE_BOX || in_Renamed.readInt() != 0x0d0a870a)
- {
- // Not a JP2 file
- in_Renamed.seek(0);
-
- marker = (short)in_Renamed.readShort();
- if (marker != CSJ2K.j2k.codestream.Markers.SOC)
- //Standard syntax marker found
- throw new System.ApplicationException("File is neither valid JP2 file nor " + "valid JPEG 2000 codestream");
- JP2FFUsed = false;
- in_Renamed.seek(0);
- return;
- }
-
- // The JP2 File format is being used
- JP2FFUsed = true;
-
- // Read File Type box
- if (!readFileTypeBox())
- {
- // Not a valid JP2 file or codestream
- throw new System.ApplicationException("Invalid JP2 file: File Type box missing");
- }
-
- // Read all remaining boxes
- while (!lastBoxFound)
- {
- pos = in_Renamed.Pos;
- length = in_Renamed.readInt();
- if ((pos + length) == in_Renamed.length())
- lastBoxFound = true;
-
- box = in_Renamed.readInt();
- if (length == 0)
- {
- lastBoxFound = true;
- length = in_Renamed.length() - in_Renamed.Pos;
- }
- else if (length == 1)
- {
- longLength = in_Renamed.readLong();
- throw new System.IO.IOException("File too long.");
- }
- else
- longLength = (long)0;
-
- switch (box)
- {
-
- case CSJ2K.j2k.fileformat.FileFormatBoxes.CONTIGUOUS_CODESTREAM_BOX:
- if (!jp2HeaderBoxFound)
- {
- throw new System.ApplicationException("Invalid JP2 file: JP2Header box not " + "found before Contiguous codestream " + "box ");
- }
- readContiguousCodeStreamBox(pos, length, longLength);
- break;
-
- case CSJ2K.j2k.fileformat.FileFormatBoxes.JP2_HEADER_BOX:
- if (jp2HeaderBoxFound)
- throw new System.ApplicationException("Invalid JP2 file: Multiple " + "JP2Header boxes found");
- readJP2HeaderBox(pos, length, longLength);
- jp2HeaderBoxFound = true;
- break;
-
- case CSJ2K.j2k.fileformat.FileFormatBoxes.INTELLECTUAL_PROPERTY_BOX:
- readIntPropertyBox(length);
- break;
-
- case CSJ2K.j2k.fileformat.FileFormatBoxes.XML_BOX:
- readXMLBox(length);
- break;
-
- case CSJ2K.j2k.fileformat.FileFormatBoxes.UUID_BOX:
- readUUIDBox(length);
- break;
-
- case CSJ2K.j2k.fileformat.FileFormatBoxes.UUID_INFO_BOX:
- readUUIDInfoBox(length);
- break;
-
- case CSJ2K.j2k.fileformat.FileFormatBoxes.READER_REQUIREMENTS_BOX:
- readReaderRequirementsBox(length);
- break;
-
- default:
- FacilityManager.getMsgLogger().printmsg(CSJ2K.j2k.util.MsgLogger_Fields.WARNING, "Unknown box-type: 0x" + System.Convert.ToString(box, 16));
- break;
-
- }
- if (!lastBoxFound)
- in_Renamed.seek(pos + length);
- }
- }
- catch (System.IO.EndOfStreamException)
- {
- throw new System.ApplicationException("EOF reached before finding Contiguous " + "Codestream Box");
- }
-
- if (codeStreamPos.Count == 0)
- {
- // Not a valid JP2 file or codestream
- throw new System.ApplicationException("Invalid JP2 file: Contiguous codestream box " + "missing");
- }
-
- return;
- }
-
- /// This method reads the File Type box.
- ///
- ///
- /// false if the File Type box was not found or invalid else true
- ///
- ///
- /// If an I/O error ocurred.
- ///
- /// If the end of file was reached
- ///
- ///
- public virtual bool readFileTypeBox()
- {
- int length;
- long longLength = 0;
- int pos;
- int nComp;
- bool foundComp = false;
-
- // Get current position in file
- pos = in_Renamed.Pos;
-
- // Read box length (LBox)
- length = in_Renamed.readInt();
- if (length == 0)
- {
- // This can not be last box
- throw new System.ApplicationException("Zero-length of Profile Box");
- }
-
- // Check that this is a File Type box (TBox)
- if (in_Renamed.readInt() != CSJ2K.j2k.fileformat.FileFormatBoxes.FILE_TYPE_BOX)
- {
- return false;
- }
-
- // Check for XLBox
- if (length == 1)
- {
- // Box has 8 byte length;
- longLength = in_Renamed.readLong();
- throw new System.IO.IOException("File too long.");
- }
-
- // Read Brand field
- in_Renamed.readInt();
-
- // Read MinV field
- in_Renamed.readInt();
-
- // Check that there is at least one FT_BR entry in in
- // compatibility list
- nComp = (length - 16) / 4; // Number of compatibilities.
- for (int i = nComp; i > 0; i--)
- {
- if (in_Renamed.readInt() == CSJ2K.j2k.fileformat.FileFormatBoxes.FT_BR)
- foundComp = true;
- }
- if (!foundComp)
- {
- return false;
- }
-
- return true;
- }
-
- /// This method reads the JP2Header box
- ///
- ///
- /// The position in the file
- ///
- ///
- /// The length of the JP2Header box
- ///
- ///
- /// length The length of the JP2Header box if greater than
- /// 1<<32
- ///
- ///
- /// false if the JP2Header box was not found or invalid else true
- ///
- ///
- /// If an I/O error ocurred.
- ///
- ///
- /// If the end of file was reached
- ///
- ///
- public virtual bool readJP2HeaderBox(long pos, int length, long longLength)
- {
-
- if (length == 0)
- {
- // This can not be last box
- throw new System.ApplicationException("Zero-length of JP2Header Box");
- }
-
- // Here the JP2Header data (DBox) would be read if we were to use it
-
- return true;
- }
-
- /// This method skips the Contiguous codestream box and adds position
- /// of contiguous codestream to a vector
- ///
- ///
- /// The position in the file
- ///
- ///
- /// The length of the JP2Header box
- ///
- ///
- /// length The length of the JP2Header box if greater than 1<<32
- ///
- ///
- /// false if the Contiguous codestream box was not found or invalid
- /// else true
- ///
- ///
- /// If an I/O error ocurred.
- ///
- ///
- /// If the end of file was reached
- ///
- ///
- public virtual bool readContiguousCodeStreamBox(long pos, int length, long longLength)
- {
-
- // Add new codestream position to position vector
- int ccpos = in_Renamed.Pos;
-
- if (codeStreamPos == null)
- codeStreamPos = System.Collections.ArrayList.Synchronized(new System.Collections.ArrayList(10));
- codeStreamPos.Add((System.Int32)ccpos);
-
- // Add new codestream length to length vector
- if (codeStreamLength == null)
- codeStreamLength = System.Collections.ArrayList.Synchronized(new System.Collections.ArrayList(10));
- codeStreamLength.Add((System.Int32)length);
-
- return true;
- }
-
- /// This method reads the contents of the Intellectual property box
- ///
- ///
- public virtual void readIntPropertyBox(int length)
- {
- }
-
- /// This method reads the contents of the XML box
- ///
- ///
- public virtual void readXMLBox(int length)
- {
- }
-
- /// This method reads the contents of the Intellectual property box
- ///
- ///
- public virtual void readUUIDBox(int length)
- {
- }
-
- /// This method reads the contents of the Intellectual property box
- ///
- ///
- public virtual void readUUIDInfoBox(int length)
- {
- }
-
- /// This method reads the contents of the Reader requirements box
- ///
- ///
- public virtual void readReaderRequirementsBox(int length)
- {
- }
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/fileformat/writer/FileFormatWriter.cs b/CSJ2K/j2k/fileformat/writer/FileFormatWriter.cs
deleted file mode 100644
index b79f7d13..00000000
--- a/CSJ2K/j2k/fileformat/writer/FileFormatWriter.cs
+++ /dev/null
@@ -1,364 +0,0 @@
-/*
-* cvs identifier:
-*
-* $Id: FileFormatWriter.java,v 1.13 2001/02/16 11:53:54 qtxjoas Exp $
-*
-* Class: FileFormatWriter
-*
-* Description: Writes the file format
-*
-*
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-* */
-using CSJ2K.j2k.io;
-namespace CSJ2K.j2k.fileformat.writer
-{
-
- /// This class writes the file format wrapper that may or may not exist around
- /// a valid JPEG 2000 codestream. This class writes the simple possible legal
- /// fileformat
- ///
- ///
- ///
- ///
- ///
- public class FileFormatWriter
- {
-
- /// The file from which to read the codestream and write file
- private BEBufferedRandomAccessFile fi;
-
- /// The name of the file from which to read the codestream and to write
- /// the JP2 file
- ///
- private System.String filename;
-
- /// Image height
- private int height;
-
- /// Image width
- private int width;
-
- /// Number of components
- private int nc;
-
- /// Bits per component
- private int[] bpc;
-
- /// Flag indicating whether number of bits per component varies
- private bool bpcVaries;
-
- /// Length of codestream
- private int clength;
-
- /// Length of Colour Specification Box
- private const int CSB_LENGTH = 15;
-
- /// Length of File Type Box
- private const int FTB_LENGTH = 20;
-
- /// Length of Image Header Box
- private const int IHB_LENGTH = 22;
-
- /// base length of Bits Per Component box
- private const int BPC_LENGTH = 8;
-
-
-
- /// The constructor of the FileFormatWriter. It receives all the
- /// information necessary about a codestream to generate a legal JP2 file
- ///
- ///
- /// The name of the file that is to be made a JP2 file
- ///
- ///
- /// The height of the image
- ///
- ///
- /// The width of the image
- ///
- ///
- /// The number of components
- ///
- ///
- /// The number of bits per component
- ///
- ///
- /// Length of codestream
- ///
- ///
- public FileFormatWriter(System.String filename, int height, int width, int nc, int[] bpc, int clength)
- {
- this.height = height;
- this.width = width;
- this.nc = nc;
- this.bpc = bpc;
- this.filename = filename;
- this.clength = clength;
-
- bpcVaries = false;
- int fixbpc = bpc[0];
- for (int i = nc - 1; i > 0; i--)
- {
- if (bpc[i] != fixbpc)
- bpcVaries = true;
- }
- }
-
-
-
- /// This method reads the codestream and writes the file format wrapper and
- /// the codestream to the same file
- ///
- ///
- /// The number of bytes increases because of the file format
- ///
- ///
- /// If an I/O error ocurred.
- ///
- ///
- public virtual int writeFileFormat()
- {
- byte[] codestream;
-
- try
- {
- // Read and buffer the codestream
- fi = new BEBufferedRandomAccessFile(filename, "rw+");
- codestream = new byte[clength];
- fi.readFully(codestream, 0, clength);
-
- // Write the JP2_SINATURE_BOX
- fi.seek(0);
- fi.writeInt(0x0000000c);
- fi.writeInt(CSJ2K.j2k.fileformat.FileFormatBoxes.JP2_SIGNATURE_BOX);
- fi.writeInt(0x0d0a870a);
-
- // Write File Type box
- writeFileTypeBox();
-
- // Write JP2 Header box
- writeJP2HeaderBox();
-
- // Write the Codestream box
- writeContiguousCodeStreamBox(codestream);
-
- fi.close();
- }
- catch (System.Exception e)
- {
- throw new System.ApplicationException("Error while writing JP2 file format(2): " + e.Message + "\n" + e.StackTrace);
- }
- if (bpcVaries)
- return 12 + FTB_LENGTH + 8 + IHB_LENGTH + CSB_LENGTH + BPC_LENGTH + nc + 8;
- else
- return 12 + FTB_LENGTH + 8 + IHB_LENGTH + CSB_LENGTH + 8;
- }
-
- /// This method writes the File Type box
- ///
- ///
- /// If an I/O error ocurred.
- ///
- ///
- public virtual void writeFileTypeBox()
- {
- // Write box length (LBox)
- // LBox(4) + TBox (4) + BR(4) + MinV(4) + CL(4) = 20
- fi.writeInt(FTB_LENGTH);
-
- // Write File Type box (TBox)
- fi.writeInt(CSJ2K.j2k.fileformat.FileFormatBoxes.FILE_TYPE_BOX);
-
- // Write File Type data (DBox)
- // Write Brand box (BR)
- fi.writeInt(CSJ2K.j2k.fileformat.FileFormatBoxes.FT_BR);
-
- // Write Minor Version
- fi.writeInt(0);
-
- // Write Compatibility list
- fi.writeInt(CSJ2K.j2k.fileformat.FileFormatBoxes.FT_BR);
- }
-
- /// This method writes the JP2Header box
- ///
- ///
- /// If an I/O error ocurred.
- ///
- ///
- public virtual void writeJP2HeaderBox()
- {
-
- // Write box length (LBox)
- // if the number of bits per components varies, a bpcc box is written
- if (bpcVaries)
- fi.writeInt(8 + IHB_LENGTH + CSB_LENGTH + BPC_LENGTH + nc);
- else
- fi.writeInt(8 + IHB_LENGTH + CSB_LENGTH);
-
- // Write a JP2Header (TBox)
- fi.writeInt(CSJ2K.j2k.fileformat.FileFormatBoxes.JP2_HEADER_BOX);
-
- // Write image header box
- writeImageHeaderBox();
-
- // Write Colour Bpecification Box
- writeColourSpecificationBox();
-
- // if the number of bits per components varies write bpcc box
- if (bpcVaries)
- writeBitsPerComponentBox();
- }
-
- /// This method writes the Bits Per Component box
- ///
- ///
- /// If an I/O error ocurred.
- ///
- ///
- public virtual void writeBitsPerComponentBox()
- {
-
- // Write box length (LBox)
- fi.writeInt(BPC_LENGTH + nc);
-
- // Write a Bits Per Component box (TBox)
- fi.writeInt(CSJ2K.j2k.fileformat.FileFormatBoxes.BITS_PER_COMPONENT_BOX);
-
- // Write bpc fields
- for (int i = 0; i < nc; i++)
- {
- fi.writeByte(bpc[i] - 1);
- }
- }
-
- /// This method writes the Colour Specification box
- ///
- ///
- /// If an I/O error ocurred.
- ///
- ///
- public virtual void writeColourSpecificationBox()
- {
-
- // Write box length (LBox)
- fi.writeInt(CSB_LENGTH);
-
- // Write a Bits Per Component box (TBox)
- fi.writeInt(CSJ2K.j2k.fileformat.FileFormatBoxes.COLOUR_SPECIFICATION_BOX);
-
- // Write METH field
- fi.writeByte(CSJ2K.j2k.fileformat.FileFormatBoxes.CSB_METH);
-
- // Write PREC field
- fi.writeByte(CSJ2K.j2k.fileformat.FileFormatBoxes.CSB_PREC);
-
- // Write APPROX field
- fi.writeByte(CSJ2K.j2k.fileformat.FileFormatBoxes.CSB_APPROX);
-
- // Write EnumCS field
- if (nc > 1)
- fi.writeInt(CSJ2K.j2k.fileformat.FileFormatBoxes.CSB_ENUM_SRGB);
- else
- fi.writeInt(CSJ2K.j2k.fileformat.FileFormatBoxes.CSB_ENUM_GREY);
- }
-
- /// This method writes the Image Header box
- ///
- ///
- /// If an I/O error ocurred.
- ///
- ///
- public virtual void writeImageHeaderBox()
- {
-
- // Write box length
- fi.writeInt(IHB_LENGTH);
-
- // Write ihdr box name
- fi.writeInt(CSJ2K.j2k.fileformat.FileFormatBoxes.IMAGE_HEADER_BOX);
-
- // Write HEIGHT field
- fi.writeInt(height);
-
- // Write WIDTH field
- fi.writeInt(width);
-
- // Write NC field
- fi.writeShort(nc);
-
- // Write BPC field
- // if the number of bits per component varies write 0xff else write
- // number of bits per components
- if (bpcVaries)
- fi.writeByte(0xff);
- else
- fi.writeByte(bpc[0] - 1);
-
- // Write C field
- fi.writeByte(CSJ2K.j2k.fileformat.FileFormatBoxes.IMB_C);
-
- // Write UnkC field
- fi.writeByte(CSJ2K.j2k.fileformat.FileFormatBoxes.IMB_UnkC);
-
- // Write IPR field
- fi.writeByte(CSJ2K.j2k.fileformat.FileFormatBoxes.IMB_IPR);
- }
-
- /// This method writes the Contiguous codestream box
- ///
- ///
- /// The contiguous codestream
- ///
- ///
- /// If an I/O error ocurred.
- ///
- ///
- public virtual void writeContiguousCodeStreamBox(byte[] cs)
- {
-
- // Write box length (LBox)
- // This value is set to 0 since in this implementation, this box is
- // always last
- fi.writeInt(clength + 8);
-
- // Write contiguous codestream box name (TBox)
- fi.writeInt(CSJ2K.j2k.fileformat.FileFormatBoxes.CONTIGUOUS_CODESTREAM_BOX);
-
- // Write codestream
- for (int i = 0; i < clength; i++)
- fi.writeByte(cs[i]);
- }
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/image/BlkImgDataSrc.cs b/CSJ2K/j2k/image/BlkImgDataSrc.cs
deleted file mode 100644
index 47e5b4e1..00000000
--- a/CSJ2K/j2k/image/BlkImgDataSrc.cs
+++ /dev/null
@@ -1,178 +0,0 @@
-/*
-* CVS identifier:
-*
-* $Id: BlkImgDataSrc.java,v 1.9 2001/01/24 14:58:12 grosbois Exp $
-*
-* Class: BlkImgDataSrc
-*
-* Description: Defines methods to transfer image data in blocks.
-*
-*
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-* */
-namespace CSJ2K.j2k.image
-{
-
- /// This interface defines the methods to transfer image data in blocks,
- /// without following any particular order (random access). This interface does
- /// not define the methods to access the image characteristics, such as width,
- /// height, number of components, tiles, etc., or to change the current
- /// tile. That is provided by other interfaces such as ImgData.
- ///
- /// This interface has the notion of a current tile. All data, coordinates
- /// and dimensions are always relative to the current tile. If there is only
- /// one tile then it is equivalent as having no tiles.
- ///
- ///
A block of requested data may never cross tile boundaries. This should
- /// be enforced by the implementing class, or the source of image data.
- ///
- ///
This interface defines the methods that can be used to retrieve image
- /// data. Implementing classes need not buffer all the image data, they can ask
- /// their source to load the data they need.
- ///
- ///
- ///
- ///
- ///
- public interface BlkImgDataSrc : ImgData
- {
-
- /// Returns the position of the fixed point in the specified component, or
- /// equivalently the number of fractional bits. This is the position of the
- /// least significant integral (i.e. non-fractional) bit, which is
- /// equivalent to the number of fractional bits. For instance, for
- /// fixed-point values with 2 fractional bits, 2 is returned. For
- /// floating-point data this value does not apply and 0 should be
- /// returned. Position 0 is the position of the least significant bit in
- /// the data.
- ///
- ///
- /// The index of the component.
- ///
- ///
- /// The position of the fixed-point, which is the same as the
- /// number of fractional bits. For floating-point data 0 is returned.
- ///
- ///
- int getFixedPoint(int c);
-
- /// Returns, in the blk argument, a block of image data containing the
- /// specifed rectangular area, in the specified component. The data is
- /// returned, as a reference to the internal data, if any, instead of as a
- /// copy, therefore the returned data should not be modified.
- ///
- /// The rectangular area to return is specified by the 'ulx', 'uly', 'w'
- /// and 'h' members of the 'blk' argument, relative to the current
- /// tile. These members are not modified by this method. The 'offset' and
- /// 'scanw' of the returned data can be arbitrary. See the 'DataBlk' class.
- ///
- ///
This method, in general, is more efficient than the 'getCompData()'
- /// method since it may not copy the data. However if the array of returned
- /// data is to be modified by the caller then the other method is probably
- /// preferable.
- ///
- ///
If possible, the data in the returned 'DataBlk' should be the
- /// internal data itself, instead of a copy, in order to increase the data
- /// transfer efficiency. However, this depends on the particular
- /// implementation (it may be more convenient to just return a copy of the
- /// data). This is the reason why the returned data should not be modified.
- ///
- ///
If the data array in blk is null, then a new one
- /// is created if necessary. The implementation of this interface may
- /// choose to return the same array or a new one, depending on what is more
- /// efficient. Therefore, the data array in blk prior to the
- /// method call should not be considered to contain the returned data, a
- /// new array may have been created. Instead, get the array from
- /// blk after the method has returned.
- ///
- ///
The returned data may have its 'progressive' attribute set. In this
- /// case the returned data is only an approximation of the "final" data.
- ///
- ///
- /// Its coordinates and dimensions specify the area to return,
- /// relative to the current tile. Some fields in this object are modified
- /// to return the data.
- ///
- ///
- /// The index of the component from which to get the data.
- ///
- ///
- /// The requested DataBlk
- ///
- ///
- ///
- ///
- ///
- DataBlk getInternCompData(DataBlk blk, int c);
-
- /// Returns, in the blk argument, a block of image data containing the
- /// specifed rectangular area, in the specified component. The data is
- /// returned, as a copy of the internal data, therefore the returned data
- /// can be modified "in place".
- ///
- /// The rectangular area to return is specified by the 'ulx', 'uly', 'w'
- /// and 'h' members of the 'blk' argument, relative to the current
- /// tile. These members are not modified by this method. The 'offset' of
- /// the returned data is 0, and the 'scanw' is the same as the block's
- /// width. See the 'DataBlk' class.
- ///
- ///
This method, in general, is less efficient than the
- /// 'getInternCompData()' method since, in general, it copies the
- /// data. However if the array of returned data is to be modified by the
- /// caller then this method is preferable.
- ///
- ///
If the data array in 'blk' is 'null', then a new one is created. If
- /// the data array is not 'null' then it is reused, and it must be large
- /// enough to contain the block's data. Otherwise an 'ArrayStoreException'
- /// or an 'IndexOutOfBoundsException' is thrown by the Java system.
- ///
- ///
The returned data may have its 'progressive' attribute set. In this
- /// case the returned data is only an approximation of the "final" data.
- ///
- ///
- /// Its coordinates and dimensions specify the area to return,
- /// relative to the current tile. If it contains a non-null data array,
- /// then it must be large enough. If it contains a null data array a new
- /// one is created. Some fields in this object are modified to return the
- /// data.
- ///
- ///
- /// The index of the component from which to get the data.
- ///
- ///
- ///
- ///
- ///
- DataBlk getCompData(DataBlk blk, int c);
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/image/CompTransfSpec.cs b/CSJ2K/j2k/image/CompTransfSpec.cs
deleted file mode 100644
index 7c2c64cd..00000000
--- a/CSJ2K/j2k/image/CompTransfSpec.cs
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
-* CVS identifier:
-*
-* $Id: CompTransfSpec.java,v 1.18 2001/04/10 14:23:26 grosbois Exp $
-*
-* Class: CompTransfSpec
-*
-* Description: Component Transformation specification
-*
-*
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-* */
-using CSJ2K.j2k.image.invcomptransf;
-namespace CSJ2K.j2k.image
-{
-
- /// This class extends the ModuleSpec class in order to hold tile
- /// specifications for multiple component transformation
- ///
- ///
- ///
- ///
- ///
- public class CompTransfSpec : ModuleSpec
- {
- /// Check if component transformation is used in any of the tiles. This
- /// method must not be used by the encoder.
- ///
- ///
- /// True if a component transformation is used in at least on
- /// tile.
- ///
- ///
- virtual public bool CompTransfUsed
- {
- get
- {
- if (((System.Int32)def) != InvCompTransf.NONE)
- {
- return true;
- }
-
- if (tileDef != null)
- {
- for (int t = nTiles - 1; t >= 0; t--)
- {
- if (tileDef[t] != null && (((System.Int32)tileDef[t]) != InvCompTransf.NONE))
- {
- return true;
- }
- }
- }
- return false;
- }
-
- }
-
- /// Constructs an empty 'CompTransfSpec' with the specified number of tiles
- /// and components. This constructor is called by the decoder. Note: The
- /// number of component is here for symmetry purpose. It is useless since
- /// only tile specifications are meaningful.
- ///
- ///
- /// Number of tiles
- ///
- ///
- /// Number of components
- ///
- ///
- /// the type of the specification module i.e. tile specific,
- /// component specific or both.
- ///
- ///
- public CompTransfSpec(int nt, int nc, byte type) : base(nt, nc, type)
- {
- }
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/image/Coord.cs b/CSJ2K/j2k/image/Coord.cs
deleted file mode 100644
index 2f8ff35e..00000000
--- a/CSJ2K/j2k/image/Coord.cs
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
-* CVS identifier:
-*
-* $Id: Coord.java,v 1.14 2002/04/30 13:18:24 grosbois Exp $
-*
-* Class: Coord
-*
-* Description: Class for storage of 2-D coordinates
-*
-*
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-* */
-namespace CSJ2K.j2k.image
-{
-
- /// This class represents 2-D coordinates.
- ///
- ///
- public class Coord
- {
- /// The horizontal coordinate
- public int x;
-
- /// The vertical coordinate
- public int y;
-
- /// Creates a new coordinate object given with the (0,0) coordinates
- ///
- ///
- public Coord()
- {
- }
-
- /// Creates a new coordinate object given the two coordinates.
- ///
- ///
- /// The horizontal coordinate.
- ///
- ///
- /// The vertical coordinate.
- ///
- ///
- public Coord(int x, int y)
- {
- this.x = x;
- this.y = y;
- }
-
- /// Creates a new coordinate object given another Coord object i.e. copy
- /// constructor
- ///
- ///
- /// The Coord object to be copied.
- ///
- ///
- public Coord(Coord c)
- {
- this.x = c.x;
- this.y = c.y;
- }
-
- /// Returns a string representation of the object coordinates
- ///
- ///
- /// The vertical and the horizontal coordinates
- ///
- ///
- public override System.String ToString()
- {
- return "(" + x + "," + y + ")";
- }
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/image/DataBlk.cs b/CSJ2K/j2k/image/DataBlk.cs
deleted file mode 100644
index 4998b919..00000000
--- a/CSJ2K/j2k/image/DataBlk.cs
+++ /dev/null
@@ -1,233 +0,0 @@
-/*
-* CVS Identifier:
-*
-* $Id: DataBlk.java,v 1.7 2001/04/15 14:32:05 grosbois Exp $
-*
-* Interface: DataBlk
-*
-* Description: A generic interface to hold 2D blocks of data.
-*
-*
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-* */
-namespace CSJ2K.j2k.image
-{
-
- /// This is a generic abstract class to store data from a block of an
- /// image. This class does not have the notion of components. Therefore, it
- /// should be used for data from a single component. Subclasses should
- /// implement the different types of storage (int, float,
- /// etc.).
- ///
- /// The data is always stored in one array, of the type matching the data
- /// type (i.e. for 'int' it's an 'int[]'). The data should be stored in the
- /// array in standard scan-line order. That is the samples go from the top-left
- /// corner of the code-block to the lower-right corner by line and then
- /// column.
- ///
- /// The member variable 'offset' gives the index in the array of the first
- /// data element (i.e. the top-left coefficient (ulx,uly)). The member variable
- /// 'scanw' gives the width of the scan that is used to store the data, that
- /// can be different from the width of the block. Element '(x,y)' of the
- /// code-block (i.e. '(ulx,uly)' is the top-left coefficient), will appear at
- /// position 'offset+(y-uly)*scanw+(x-ulx)' in the array of data.
- ///
- /// A block of data can have the progressive attribute set. Data is
- /// progressive when it is obtained by successive refinement and the values in
- /// this block are approximations of the "final" values. When the final values
- /// are returned the progressive attribute must be turned off.
- ///
- /// The classes DataBlkInt and DataBlkFloat provide
- /// implementations for int and float types respectively.
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- public abstract class DataBlk
- {
- /// Returns the data type of the DataBlk object, as defined in
- /// this class.
- ///
- ///
- /// The data type of the object, as defined in thsi class.
- ///
- ///
- public abstract int DataType { get; }
- //UPGRADE_NOTE: Respective javadoc comments were merged. It should be changed in order to comply with .NET documentation conventions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1199'"
- /// Returns the array containing the data, or null if there is no data. The
- /// returned array is of the type returned by getDataType() (e.g.,
- /// for TYPE_INT, it is a int[]).
- ///
- /// Each implementing class should provide a type specific equivalent
- /// method (e.g., getDataInt() in DataBlkInt) which
- /// returns an array of the correct type explicetely and not through an
- /// Object.
- ///
- ///
- /// The array containing the data, or null if there is no
- /// data.
- ///
- ///
- ///
- ///
- ///
- /// Sets the data array to the specified one. The type of the specified
- /// data array must match the one returned by getDataType() (e.g.,
- /// for TYPE_INT, it should be a int[]). If the wrong
- /// type of array is given a ClassCastException will be thrown.
- ///
- /// The size of the array is not necessarily checked for consistency
- /// with w and h or any other fields.
- ///
- /// Each implementing class should provide a type specific equivalent
- /// method (e.g., setDataInt() in DataBlkInt) which takes
- /// an array of the correct type explicetely and not through an
- /// Object.
- ///
- ///
- /// The new data array to use
- ///
- ///
- ///
- ///
- ///
- public abstract System.Object Data { get; set; }
-
- /// The identifier for the byte data type, as signed 8 bits.
- public const int TYPE_BYTE = 0;
-
- /// The identifier for the short data type, as signed 16 bits.
- public const int TYPE_SHORT = 1;
-
- /// The identifier for the int data type, as signed 32 bits.
- public const int TYPE_INT = 3;
-
- /// The identifier for the float data type
- public const int TYPE_FLOAT = 4;
-
- /// The horizontal coordinate (in pixels) of the upper-left corner of the
- /// block of data. This is relative to the component of the image from
- /// where this block was filled or is to be filled.
- ///
- public int ulx;
-
- /// The vertical coordinate of the upper-left corner of the block of
- /// data. This is relative to the component of the image from where this
- /// block was filled or is to be filled.
- ///
- public int uly;
-
- /// The width of the block, in pixels.
- public int w;
-
- /// The height of the block, in pixels.
- public int h;
-
- /// The offset in the array of the top-left coefficient
- public int offset;
-
- /// The width of the scanlines used to store the data in the array
- public int scanw;
-
- /// The progressive attribute (false by default)
- public bool progressive;
-
- /// Returns the size in bits, given the data type. The data type must be
- /// one defined in this class. An IllegalArgumentException is
- /// thrown if type is not defined in this class.
- ///
- ///
- /// The data type.
- ///
- ///
- /// The size in bits of the data type.
- ///
- ///
- public static int getSize(int type)
- {
- switch (type)
- {
-
- case TYPE_BYTE:
- return 8;
-
- case TYPE_SHORT:
- return 16;
-
- case TYPE_INT:
- case TYPE_FLOAT:
- return 32;
-
- default:
- throw new System.ArgumentException();
-
- }
- }
-
- /// Returns a string of informations about the DataBlk
- ///
- ///
- /// Block dimensions and progressiveness in a string
- ///
- ///
- public override System.String ToString()
- {
- System.String typeString = "";
- switch (DataType)
- {
-
- case TYPE_BYTE:
- typeString = "Unsigned Byte";
- break;
-
- case TYPE_SHORT:
- typeString = "Short";
- break;
-
- case TYPE_INT:
- typeString = "Integer";
- break;
-
- case TYPE_FLOAT:
- typeString = "Float";
- break;
- }
-
- return "DataBlk: " + "upper-left(" + ulx + "," + uly + "), width=" + w + ", height=" + h + ", progressive=" + progressive + ", offset=" + offset + ", scanw=" + scanw + ", type=" + typeString;
- }
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/image/DataBlkFloat.cs b/CSJ2K/j2k/image/DataBlkFloat.cs
deleted file mode 100644
index f78b3201..00000000
--- a/CSJ2K/j2k/image/DataBlkFloat.cs
+++ /dev/null
@@ -1,207 +0,0 @@
-/*
-* CVS Identifier:
-*
-* $Id: DataBlkFloat.java,v 1.7 2001/10/09 12:52:01 grosbois Exp $
-*
-* Interface: DataBlkFloat
-*
-* Description: A float implementation of DataBlk
-*
-*
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-* */
-using System;
-namespace CSJ2K.j2k.image
-{
-
- /// This is an implementation of the DataBlk interface for 32 bit
- /// floating point data (float).
- ///
- /// The methods in this class are declared final, so that they can be
- /// inlined by inlining compilers.
- ///
- ///
- ///
- ///
- ///
- public class DataBlkFloat : DataBlk
- {
- /// Returns the identifier of this data type, TYPE_FLOAT, as
- /// defined in DataBlk.
- ///
- ///
- /// The type of data stored. Always DataBlk.TYPE_FLOAT
- ///
- ///
- ///
- ///
- ///
- override public int DataType
- {
- get
- {
- return TYPE_FLOAT;
- }
-
- }
- //UPGRADE_NOTE: Respective javadoc comments were merged. It should be changed in order to comply with .NET documentation conventions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1199'"
- /// Returns the array containing the data, or null if there is no data
- /// array. The returned array is a float array.
- ///
- ///
- /// The array of data (a float[]) or null if there is no data.
- ///
- ///
- /// Sets the data array to the specified one. The provided array must be a
- /// float array, otherwise a ClassCastException is thrown. The size of the
- /// array is not checked for consistency with the block's dimensions.
- ///
- ///
- /// The data array to use. Must be a float array.
- ///
- ///
- override public System.Object Data
- {
- get
- {
- return data;
- }
-
- set
- {
- data = (float[])value;
- }
-
- }
- //UPGRADE_NOTE: Respective javadoc comments were merged. It should be changed in order to comply with .NET documentation conventions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1199'"
- /// Returns the array containing the data, or null if there is no data
- /// array.
- ///
- ///
- /// The array of data or null if there is no data.
- ///
- ///
- /// Sets the data array to the specified one. The size of the array is not
- /// checked for consistency with the block's dimensions.
- ///
- ///
- /// The data array to use.
- ///
- ///
- virtual public float[] DataFloat
- {
- get
- {
- return data;
- }
-
- set
- {
- data = value;
- }
-
- }
- /// The array where the data is stored
- private float[] data;
-
- /// Creates a DataBlkFloat with 0 dimensions and no data array
- /// (i.e. data is null).
- ///
- ///
- public DataBlkFloat()
- {
- }
-
- /// Creates a DataBlkFloat with the specified dimensions and position. The
- /// data array is initialized to an array of size w*h.
- ///
- ///
- /// The horizontal coordinate of the upper-left corner of the
- /// block
- ///
- ///
- /// The vertical coordinate of the upper-left corner of the
- /// block
- ///
- ///
- /// The width of the block (in pixels)
- ///
- ///
- /// The height of the block (in pixels)
- ///
- ///
- public DataBlkFloat(int ulx, int uly, int w, int h)
- {
- this.ulx = ulx;
- this.uly = uly;
- this.w = w;
- this.h = h;
- offset = 0;
- scanw = w;
- data = new float[w * h];
- }
-
- /// Copy constructor. Creates a DataBlkFloat which is the copy of the
- /// DataBlkFloat given as paramter.
- ///
- ///
- /// the object to be copied.
- ///
- ///
- public DataBlkFloat(DataBlkFloat src)
- {
- this.ulx = src.ulx;
- this.uly = src.uly;
- this.w = src.w;
- this.h = src.h;
- this.offset = 0;
- this.scanw = this.w;
- this.data = new float[this.w * this.h];
- for (int i = 0; i < this.h; i++)
- Array.Copy(src.data, i * src.scanw, this.data, i * this.scanw, this.w);
- }
-
- /// Returns a string of informations about the DataBlkInt.
- ///
- ///
- public override System.String ToString()
- {
- System.String str = base.ToString();
- if (data != null)
- {
- str += (",data=" + data.Length + " bytes");
- }
- return str;
- }
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/image/DataBlkInt.cs b/CSJ2K/j2k/image/DataBlkInt.cs
deleted file mode 100644
index ba74bc4e..00000000
--- a/CSJ2K/j2k/image/DataBlkInt.cs
+++ /dev/null
@@ -1,208 +0,0 @@
-/*
-* CVS Identifier:
-*
-* $Id: DataBlkInt.java,v 1.7 2001/10/09 12:51:54 grosbois Exp $
-*
-* Interface: DataBlkInt
-*
-* Description: A signed int implementation of DataBlk
-*
-*
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-* */
-using System;
-namespace CSJ2K.j2k.image
-{
-
- /// This is an implementation of the DataBlk interface for signed 32
- /// bit integral data.
- ///
- /// The methods in this class are declared final, so that they can be
- /// inlined by inlining compilers.
- ///
- ///
- ///
- ///
- ///
- public class DataBlkInt : DataBlk
- {
- /// Returns the identifier of this data type, TYPE_INT, as defined
- /// in DataBlk.
- ///
- ///
- /// The type of data stored. Always DataBlk.TYPE_INT
- ///
- ///
- ///
- ///
- ///
- override public int DataType
- {
- get
- {
- return TYPE_INT;
- }
-
- }
- //UPGRADE_NOTE: Respective javadoc comments were merged. It should be changed in order to comply with .NET documentation conventions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1199'"
- /// Returns the array containing the data, or null if there is no data
- /// array. The returned array is a int array.
- ///
- ///
- /// The array of data (a int[]) or null if there is no data.
- ///
- ///
- /// Sets the data array to the specified one. The provided array must be a
- /// int array, otherwise a ClassCastException is thrown. The size of the
- /// array is not checked for consistency with the block's dimensions.
- ///
- ///
- /// The data array to use. Must be a int array.
- ///
- ///
- override public System.Object Data
- {
- get
- {
- return data_array;
- }
-
- set
- {
- data_array = (int[])value;
- }
-
- }
- //UPGRADE_NOTE: Respective javadoc comments were merged. It should be changed in order to comply with .NET documentation conventions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1199'"
- /// Returns the array containing the data, or null if there is no data
- /// array.
- ///
- ///
- /// The array of data or null if there is no data.
- ///
- ///
- /// Sets the data array to the specified one. The size of the array is not
- /// checked for consistency with the block's dimensions. This method is
- /// more efficient than setData
- ///
- ///
- /// The data array to use.
- ///
- ///
- virtual public int[] DataInt
- {
- get
- {
- return data_array;
- }
-
- set
- {
- data_array = value;
- }
-
- }
- /// The array where the data is stored
- public int[] data_array;
-
- /// Creates a DataBlkInt with 0 dimensions and no data array (i.e. data is
- /// null).
- ///
- ///
- public DataBlkInt()
- {
- }
-
- /// Creates a DataBlkInt with the specified dimensions and position. The
- /// data array is initialized to an array of size w*h.
- ///
- ///
- /// The horizontal coordinate of the upper-left corner of the
- /// block
- ///
- ///
- /// The vertical coordinate of the upper-left corner of the
- /// block
- ///
- ///
- /// The width of the block (in pixels)
- ///
- ///
- /// The height of the block (in pixels)
- ///
- ///
- public DataBlkInt(int ulx, int uly, int w, int h)
- {
- this.ulx = ulx;
- this.uly = uly;
- this.w = w;
- this.h = h;
- offset = 0;
- scanw = w;
- data_array = new int[w * h];
- }
-
- /// Copy constructor. Creates a DataBlkInt which is the copy of the
- /// DataBlkInt given as paramter.
- ///
- ///
- /// the object to be copied.
- ///
- ///
- public DataBlkInt(DataBlkInt src)
- {
- this.ulx = src.ulx;
- this.uly = src.uly;
- this.w = src.w;
- this.h = src.h;
- this.offset = 0;
- this.scanw = this.w;
- this.data_array = new int[this.w * this.h];
- for (int i = 0; i < this.h; i++)
- Array.Copy(src.data_array, i * src.scanw, this.data_array, i * this.scanw, this.w);
- }
-
- /// Returns a string of informations about the DataBlkInt.
- ///
- ///
- public override System.String ToString()
- {
- System.String str = base.ToString();
- if (data_array != null)
- {
- str += (",data=" + data_array.Length + " bytes");
- }
- return str;
- }
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/image/ImgData.cs b/CSJ2K/j2k/image/ImgData.cs
deleted file mode 100644
index 99529f68..00000000
--- a/CSJ2K/j2k/image/ImgData.cs
+++ /dev/null
@@ -1,364 +0,0 @@
-/*
-* CVS Identifier:
-*
-* $Id: ImgData.java,v 1.10 2001/09/14 09:17:46 grosbois Exp $
-*
-* Interface: ImgData
-*
-* Description: The interface for classes that provide image
-* data.
-*
-*
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-* */
-namespace CSJ2K.j2k.image
-{
-
- /// This interface defines methods to access image attributes (width, height,
- /// number of components, etc.). The image can be tiled or not (i.e. if the
- /// image is not tiled then there is only 1 tile). It should be implemented by
- /// all classes that provide image data, such as image file readers, color
- /// transforms, wavelet transforms, etc. This interface, however, does not
- /// define methods to transfer image data (i.e. pixel data), that is defined by
- /// other interfaces, such as 'BlkImgDataSrc'.
- ///
- ///
- ///
- ///
- ///
- public interface ImgData
- {
- /// Returns the overall width of the current tile in pixels. This is the
- /// tile's width without accounting for any component subsampling. This is
- /// also referred as the reference grid width in the current tile.
- ///
- ///
- /// The total current tile's width in pixels.
- ///
- ///
- int TileWidth
- {
- get;
-
- }
- /// Returns the overall height of the current tile in pixels. This is the
- /// tile's height without accounting for any component subsampling. This is
- /// also referred as the reference grid height in the current tile.
- ///
- ///
- /// The total current tile's height in pixels.
- ///
- ///
- int TileHeight
- {
- get;
-
- }
- /// Returns the nominal tiles width
- int NomTileWidth
- {
- get;
-
- }
- /// Returns the nominal tiles height
- int NomTileHeight
- {
- get;
-
- }
- /// Returns the overall width of the image in pixels. This is the image's
- /// width without accounting for any component subsampling or tiling.
- ///
- ///
- /// The total image's width in pixels.
- ///
- ///
- int ImgWidth
- {
- get;
-
- }
- /// Returns the overall height of the image in pixels. This is the image's
- /// height without accounting for any component subsampling or tiling.
- ///
- ///
- /// The total image's height in pixels.
- ///
- ///
- int ImgHeight
- {
- get;
-
- }
- /// Returns the number of components in the image.
- ///
- ///
- /// The number of components in the image.
- ///
- ///
- int NumComps
- {
- get;
-
- }
- /// Returns the index of the current tile, relative to a standard scan-line
- /// order.
- ///
- ///
- /// The current tile's index (starts at 0).
- ///
- ///
- int TileIdx
- {
- get;
-
- }
- /// Returns the horizontal tile partition offset in the reference grid
- int TilePartULX
- {
- get;
-
- }
- /// Returns the vertical tile partition offset in the reference grid
- int TilePartULY
- {
- get;
-
- }
- /// Returns the horizontal coordinate of the image origin, the top-left
- /// corner, in the canvas system, on the reference grid.
- ///
- ///
- /// The horizontal coordinate of the image origin in the canvas
- /// system, on the reference grid.
- ///
- ///
- int ImgULX
- {
- get;
-
- }
- /// Returns the vertical coordinate of the image origin, the top-left
- /// corner, in the canvas system, on the reference grid.
- ///
- ///
- /// The vertical coordinate of the image origin in the canvas
- /// system, on the reference grid.
- ///
- ///
- int ImgULY
- {
- get;
-
- }
-
- /// Returns the component subsampling factor in the horizontal direction,
- /// for the specified component. This is, approximately, the ratio of
- /// dimensions between the reference grid and the component itself, see the
- /// 'ImgData' interface desription for details.
- ///
- ///
- /// The index of the component (between 0 and N-1)
- ///
- ///
- /// The horizontal subsampling factor of component 'c'
- ///
- ///
- ///
- ///
- ///
- int getCompSubsX(int c);
-
- /// Returns the component subsampling factor in the vertical direction, for
- /// the specified component. This is, approximately, the ratio of
- /// dimensions between the reference grid and the component itself, see the
- /// 'ImgData' interface desription for details.
- ///
- ///
- /// The index of the component (between 0 and N-1)
- ///
- ///
- /// The vertical subsampling factor of component 'c'
- ///
- ///
- ///
- ///
- ///
- int getCompSubsY(int c);
-
- /// Returns the width in pixels of the specified tile-component
- ///
- ///
- /// Tile index
- ///
- ///
- /// The index of the component, from 0 to N-1.
- ///
- ///
- /// The width in pixels of component c in tilet.
- ///
- ///
- int getTileCompWidth(int t, int c);
-
- /// Returns the height in pixels of the specified tile-component.
- ///
- ///
- /// The tile index.
- ///
- ///
- /// The index of the component, from 0 to N-1.
- ///
- ///
- /// The height in pixels of component c in tile
- /// t.
- ///
- ///
- int getTileCompHeight(int t, int c);
-
- /// Returns the width in pixels of the specified component in the overall
- /// image.
- ///
- ///
- /// The index of the component, from 0 to N-1.
- ///
- ///
- /// The width in pixels of component c in the overall
- /// image.
- ///
- ///
- int getCompImgWidth(int c);
-
- /// Returns the height in pixels of the specified component in the overall
- /// image.
- ///
- ///
- /// The index of the component, from 0 to N-1.
- ///
- ///
- /// The height in pixels of component n in the overall
- /// image.
- ///
- ///
- int getCompImgHeight(int c);
-
- /// Returns the number of bits, referred to as the "range bits",
- /// corresponding to the nominal range of the image data in the specified
- /// component. If this number is n then for unsigned data the
- /// nominal range is between 0 and 2^b-1, and for signed data it is between
- /// -2^(b-1) and 2^(b-1)-1. In the case of transformed data which is not in
- /// the image domain (e.g., wavelet coefficients), this method returns the
- /// "range bits" of the image data that generated the coefficients.
- ///
- ///
- /// The index of the component.
- ///
- ///
- /// The number of bits corresponding to the nominal range of the
- /// image data (in the image domain).
- ///
- ///
- int getNomRangeBits(int c);
-
- /// Changes the current tile, given the new indices. An
- /// IllegalArgumentException is thrown if the coordinates do not correspond
- /// to a valid tile.
- ///
- ///
- /// The horizontal index of the tile.
- ///
- ///
- /// The vertical index of the new tile.
- ///
- ///
- void setTile(int x, int y);
-
- /// Advances to the next tile, in standard scan-line order (by rows then
- /// columns). An NoNextElementException is thrown if the current tile is
- /// the last one (i.e. there is no next tile).
- ///
- ///
- void nextTile();
-
- /// Returns the indixes of the current tile. These are the horizontal and
- /// vertical indexes of the current tile.
- ///
- ///
- /// If not null this object is used to return the information. If
- /// null a new one is created and returned.
- ///
- ///
- /// The current tile's indices (vertical and horizontal indexes).
- ///
- ///
- Coord getTile(Coord co);
-
- /// Returns the horizontal coordinate of the upper-left corner of the
- /// specified component in the current tile.
- ///
- ///
- /// The index of the component.
- ///
- ///
- int getCompULX(int c);
-
- /// Returns the vertical coordinate of the upper-left corner of the
- /// specified component in the current tile.
- ///
- ///
- /// The index of the component.
- ///
- ///
- int getCompULY(int c);
-
- /// Returns the number of tiles in the horizontal and vertical directions.
- ///
- ///
- /// If not null this object is used to return the information. If
- /// null a new one is created and returned.
- ///
- ///
- /// The number of tiles in the horizontal (Coord.x) and vertical
- /// (Coord.y) directions.
- ///
- ///
- Coord getNumTiles(Coord co);
-
- /// Returns the total number of tiles in the image.
- ///
- ///
- /// The total number of tiles in the image.
- ///
- ///
- int getNumTiles();
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/image/ImgDataAdapter.cs b/CSJ2K/j2k/image/ImgDataAdapter.cs
deleted file mode 100644
index 32e0500f..00000000
--- a/CSJ2K/j2k/image/ImgDataAdapter.cs
+++ /dev/null
@@ -1,513 +0,0 @@
-/*
-* CVS identifier:
-*
-* $Id: ImgDataAdapter.java,v 1.8 2001/09/14 09:17:23 grosbois Exp $
-*
-* Class: ImgDataAdapter
-*
-* Description: A default implementation of the ImgData
-* interface that has an ImgData source and just
-* returns the values of the source.
-*
-*
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-* */
-namespace CSJ2K.j2k.image
-{
-
- /// This class provides a default implementation of the methods in the
- /// 'ImgData' interface. The default implementation is just to return the value
- /// of the source, where the source is another 'ImgData' object.
- ///
- /// This abstract class can be used to facilitate the development of other
- /// classes that implement 'ImgData'. For example a YCbCr color transform can
- /// inherit from this class and all the trivial methods do not have to be
- /// re-implemented.
- ///
- /// If the default implementation of a method provided in this class does
- /// not suit a particular implementation of the 'ImgData' interface, the method
- /// can be overridden to implement the proper behavior.
- ///
- ///
- ///
- ///
- ///
- public abstract class ImgDataAdapter : ImgData
- {
- /// Returns the overall width of the current tile in pixels. This is the
- /// tile's width without accounting for any component subsampling. This is
- /// also referred as the reference grid width in the current tile.
- ///
- /// This default implementation returns the value of the source.
- ///
- ///
- /// The total current tile's width in pixels.
- ///
- ///
- virtual public int TileWidth
- {
- get
- {
- return imgdatasrc.TileWidth;
- }
-
- }
- /// Returns the overall height of the current tile in pixels. This is the
- /// tile's height without accounting for any component subsampling. This is
- /// also referred as the reference grid height in the current tile.
- ///
- /// This default implementation returns the value of the source.
- ///
- ///
- /// The total current tile's height in pixels.
- ///
- ///
- virtual public int TileHeight
- {
- get
- {
- return imgdatasrc.TileHeight;
- }
-
- }
- /// Returns the nominal tiles width
- virtual public int NomTileWidth
- {
- get
- {
- return imgdatasrc.NomTileWidth;
- }
-
- }
- /// Returns the nominal tiles height
- virtual public int NomTileHeight
- {
- get
- {
- return imgdatasrc.NomTileHeight;
- }
-
- }
- /// Returns the overall width of the image in pixels. This is the image's
- /// width without accounting for any component subsampling or tiling.
- ///
- /// This default implementation returns the value of the source.
- ///
- ///
- /// The total image's width in pixels.
- ///
- ///
- virtual public int ImgWidth
- {
- get
- {
- return imgdatasrc.ImgWidth;
- }
-
- }
- /// Returns the overall height of the image in pixels. This is the image's
- /// height without accounting for any component subsampling or tiling.
- ///
- /// This default implementation returns the value of the source.
- ///
- ///
- /// The total image's height in pixels.
- ///
- ///
- virtual public int ImgHeight
- {
- get
- {
- return imgdatasrc.ImgHeight;
- }
-
- }
- /// Returns the number of components in the image.
- ///
- /// This default implementation returns the value of the source.
- ///
- ///
- /// The number of components in the image.
- ///
- ///
- virtual public int NumComps
- {
- get
- {
- return imgdatasrc.NumComps;
- }
-
- }
- /// Returns the index of the current tile, relative to a standard scan-line
- /// order.
- ///
- /// This default implementation returns the value of the source.
- ///
- ///
- /// The current tile's index (starts at 0).
- ///
- ///
- virtual public int TileIdx
- {
- get
- {
- return imgdatasrc.TileIdx;
- }
-
- }
- /// Returns the horizontal tile partition offset in the reference grid
- virtual public int TilePartULX
- {
- get
- {
- return imgdatasrc.TilePartULX;
- }
-
- }
- /// Returns the vertical tile offset in the reference grid
- virtual public int TilePartULY
- {
- get
- {
- return imgdatasrc.TilePartULY;
- }
-
- }
- /// Returns the horizontal coordinate of the image origin, the top-left
- /// corner, in the canvas system, on the reference grid.
- ///
- /// This default implementation returns the value of the source.
- ///
- ///
- /// The horizontal coordinate of the image origin in the canvas
- /// system, on the reference grid.
- ///
- ///
- virtual public int ImgULX
- {
- get
- {
- return imgdatasrc.ImgULX;
- }
-
- }
- /// Returns the vertical coordinate of the image origin, the top-left
- /// corner, in the canvas system, on the reference grid.
- ///
- /// This default implementation returns the value of the source.
- ///
- ///
- /// The vertical coordinate of the image origin in the canvas
- /// system, on the reference grid.
- ///
- ///
- virtual public int ImgULY
- {
- get
- {
- return imgdatasrc.ImgULY;
- }
-
- }
-
- /// Index of the current tile
- protected internal int tIdx = 0;
-
- /// The ImgData source
- protected internal ImgData imgdatasrc;
-
- /// Instantiates the ImgDataAdapter object specifying the ImgData source.
- ///
- ///
- /// From where to obtain all the ImgData values.
- ///
- ///
- protected internal ImgDataAdapter(ImgData src)
- {
- imgdatasrc = src;
- }
-
- /// Returns the component subsampling factor in the horizontal direction,
- /// for the specified component. This is, approximately, the ratio of
- /// dimensions between the reference grid and the component itself, see the
- /// 'ImgData' interface desription for details.
- ///
- /// This default implementation returns the value of the source.
- ///
- ///
- /// The index of the component (between 0 and N-1)
- ///
- ///
- /// The horizontal subsampling factor of component 'c'
- ///
- ///
- ///
- ///
- ///
- public virtual int getCompSubsX(int c)
- {
- return imgdatasrc.getCompSubsX(c);
- }
-
- /// Returns the component subsampling factor in the vertical direction, for
- /// the specified component. This is, approximately, the ratio of
- /// dimensions between the reference grid and the component itself, see the
- /// 'ImgData' interface desription for details.
- ///
- /// This default implementation returns the value of the source.
- ///
- ///
- /// The index of the component (between 0 and N-1)
- ///
- ///
- /// The vertical subsampling factor of component 'c'
- ///
- ///
- ///
- ///
- ///
- public virtual int getCompSubsY(int c)
- {
- return imgdatasrc.getCompSubsY(c);
- }
-
- /// Returns the width in pixels of the specified tile-component
- /// tile.
- ///
- /// This default implementation returns the value of the source.
- ///
- ///
- /// Tile index
- ///
- ///
- /// The index of the component, from 0 to N-1.
- ///
- ///
- /// The width in pixels of component c in tilet.
- ///
- ///
- public virtual int getTileCompWidth(int t, int c)
- {
- return imgdatasrc.getTileCompWidth(t, c);
- }
-
- /// Returns the height in pixels of the specified tile-component.
- ///
- /// This default implementation returns the value of the source.
- ///
- ///
- /// The tile index.
- ///
- ///
- /// The index of the component, from 0 to N-1.
- ///
- ///
- /// The height in pixels of component c in tile
- /// t.
- ///
- ///
- public virtual int getTileCompHeight(int t, int c)
- {
- return imgdatasrc.getTileCompHeight(t, c);
- }
-
- /// Returns the width in pixels of the specified component in the overall
- /// image.
- ///
- /// This default implementation returns the value of the source.
- ///
- ///
- /// The index of the component, from 0 to N-1.
- ///
- ///
- /// The width in pixels of component c in the overall
- /// image.
- ///
- ///
- public virtual int getCompImgWidth(int c)
- {
- return imgdatasrc.getCompImgWidth(c);
- }
-
- /// Returns the height in pixels of the specified component in the overall
- /// image.
- ///
- /// This default implementation returns the value of the source.
- ///
- ///
- /// The index of the component, from 0 to N-1.
- ///
- ///
- /// The height in pixels of component c in the overall
- /// image.
- ///
- ///
- public virtual int getCompImgHeight(int c)
- {
- return imgdatasrc.getCompImgHeight(c);
- }
-
- /// Returns the number of bits, referred to as the "range bits",
- /// corresponding to the nominal range of the image data in the specified
- /// component. If this number is n then for unsigned data the
- /// nominal range is between 0 and 2^b-1, and for signed data it is between
- /// -2^(b-1) and 2^(b-1)-1. In the case of transformed data which is not in
- /// the image domain (e.g., wavelet coefficients), this method returns the
- /// "range bits" of the image data that generated the coefficients.
- ///
- /// This default implementation returns the value of the source.
- ///
- ///
- /// The index of the component.
- ///
- ///
- /// The number of bits corresponding to the nominal range of the
- /// image data (in the image domain).
- ///
- ///
- public virtual int getNomRangeBits(int c)
- {
- return imgdatasrc.getNomRangeBits(c);
- }
-
- /// Changes the current tile, given the new indexes. An
- /// IllegalArgumentException is thrown if the indexes do not correspond to
- /// a valid tile.
- ///
- /// This default implementation just changes the tile in the source.
- ///
- ///
- /// The horizontal index of the tile.
- ///
- ///
- /// The vertical index of the new tile.
- ///
- ///
- public virtual void setTile(int x, int y)
- {
- imgdatasrc.setTile(x, y);
- tIdx = TileIdx;
- }
-
- /// Advances to the next tile, in standard scan-line order (by rows then
- /// columns). An NoNextElementException is thrown if the current tile is
- /// the last one (i.e. there is no next tile).
- ///
- /// This default implementation just advances to the next tile in the
- /// source.
- ///
- ///
- public virtual void nextTile()
- {
- imgdatasrc.nextTile();
- tIdx = TileIdx;
- }
-
- /// Returns the indexes of the current tile. These are the horizontal and
- /// vertical indexes of the current tile.
- ///
- /// This default implementation returns the value of the source.
- ///
- ///
- /// If not null this object is used to return the information. If
- /// null a new one is created and returned.
- ///
- ///
- /// The current tile's indexes (vertical and horizontal indexes).
- ///
- ///
- public virtual Coord getTile(Coord co)
- {
- return imgdatasrc.getTile(co);
- }
-
- /// Returns the horizontal coordinate of the upper-left corner of the
- /// specified component in the current tile.
- ///
- /// This default implementation returns the value of the source.
- ///
- ///
- /// The component index.
- ///
- ///
- public virtual int getCompULX(int c)
- {
- return imgdatasrc.getCompULX(c);
- }
-
- /// Returns the vertical coordinate of the upper-left corner of the
- /// specified component in the current tile.
- ///
- /// This default implementation returns the value of the source.
- ///
- ///
- /// The component index.
- ///
- ///
- public virtual int getCompULY(int c)
- {
- return imgdatasrc.getCompULY(c);
- }
-
- /// Returns the number of tiles in the horizontal and vertical directions.
- ///
- /// This default implementation returns the value of the source.
- ///
- ///
- /// If not null this object is used to return the information. If
- /// null a new one is created and returned.
- ///
- ///
- /// The number of tiles in the horizontal (Coord.x) and vertical
- /// (Coord.y) directions.
- ///
- ///
- public virtual Coord getNumTiles(Coord co)
- {
- return imgdatasrc.getNumTiles(co);
- }
-
- /// Returns the total number of tiles in the image.
- ///
- /// This default implementation returns the value of the source.
- ///
- ///
- /// The total number of tiles in the image.
- ///
- ///
- public virtual int getNumTiles()
- {
- return imgdatasrc.getNumTiles();
- }
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/image/ImgDataConverter.cs b/CSJ2K/j2k/image/ImgDataConverter.cs
deleted file mode 100644
index 72683b4d..00000000
--- a/CSJ2K/j2k/image/ImgDataConverter.cs
+++ /dev/null
@@ -1,420 +0,0 @@
-/*
-* CVS Identifier:
-*
-* $Id: ImgDataConverter.java,v 1.13 2001/02/27 19:16:03 grosbois Exp $
-*
-* Interface: ImgDataConverter
-*
-* Description: The abstract class for classes that provide
-* Image Data Convertres (int -> float, float->int).
-*
-*
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-* */
-namespace CSJ2K.j2k.image
-{
-
- /// This class is responsible of all data type conversions. It should be used,
- /// at encoder side, between Tiler and ForwardWT modules and, at decoder side,
- /// between InverseWT/CompDemixer and ImgWriter modules. The conversion is
- /// realized when a block of data is requested: if source and destination data
- /// type are the same one, it does nothing, else appropriate cast is done. All
- /// the methods of the 'ImgData' interface are implemented by the
- /// 'ImgDataAdapter' class that is the superclass of this one, so they don't
- /// need to be reimplemented by subclasses.
- ///
- ///
- public class ImgDataConverter : ImgDataAdapter, BlkImgDataSrc
- {
-
- /// The block used to request data from the source in the case that a
- /// conversion seems necessary. It can be either int or float at
- /// initialization time. It will be checked (and corrected if necessary) by
- /// the source whenever necessary
- ///
- private DataBlk srcBlk = new DataBlkInt();
-
- /// The source of image data
- private BlkImgDataSrc src;
-
- /// The number of fraction bits in the casted ints
- private int fp;
-
- /// Constructs a new ImgDataConverter object that operates on the specified
- /// source of image data.
- ///
- ///
- /// The source from where to get the data to be transformed
- ///
- ///
- /// The number of fraction bits in the casted ints
- ///
- ///
- ///
- ///
- ///
- public ImgDataConverter(BlkImgDataSrc imgSrc, int fp) : base(imgSrc)
- {
- src = imgSrc;
- this.fp = fp;
- }
-
- /// Constructs a new ImgDataConverter object that operates on the specified
- /// source of image data.
- ///
- ///
- /// The source from where to get the data to be transformed
- ///
- ///
- ///
- ///
- ///
- public ImgDataConverter(BlkImgDataSrc imgSrc) : base(imgSrc)
- {
- src = imgSrc;
- fp = 0;
- }
-
- /// Returns the position of the fixed point in the specified
- /// component. This is the position of the least significant integral
- /// (i.e. non-fractional) bit, which is equivalent to the number of
- /// fractional bits. For instance, for fixed-point values with 2 fractional
- /// bits, 2 is returned. For floating-point data this value does not apply
- /// and 0 should be returned. Position 0 is the position of the least
- /// significant bit in the data.
- ///
- ///
- /// The index of the component.
- ///
- ///
- /// The position of the fixed-point, which is the same as the
- /// number of fractional bits.
- ///
- ///
- public virtual int getFixedPoint(int c)
- {
- return fp;
- }
-
- /// Returns, in the blk argument, a block of image data containing the
- /// specifed rectangular area, in the specified component, using the
- /// 'transfer type' specified in the block given as argument. The data is
- /// returned, as a copy of the internal data, therefore the returned data
- /// can be modified "in place".
- ///
- /// The rectangular area to return is specified by the 'ulx', 'uly', 'w'
- /// and 'h' members of the 'blk' argument, relative to the current
- /// tile. These members are not modified by this method. The 'offset' of
- /// the returned data is 0, and the 'scanw' is the same as the block's
- /// width. See the 'DataBlk' class.
- ///
- ///
This method, in general, is less efficient than the
- /// 'getInternCompData()' method since, in general, it copies the
- /// data. However if the array of returned data is to be modified by the
- /// caller then this method is preferable.
- ///
- ///
If the data array in 'blk' is 'null', then a new one is created. If
- /// the data array is not 'null' then it is reused, and it must be large
- /// enough to contain the block's data. Otherwise an 'ArrayStoreException'
- /// or an 'IndexOutOfBoundsException' is thrown by the Java system.
- ///
- ///
The returned data may have its 'progressive' attribute set. In this
- /// case the returned data is only an approximation of the "final" data.
- ///
- ///
- /// Its coordinates and dimensions specify the area to return,
- /// relative to the current tile. If it contains a non-null data array,
- /// then it must be large enough. If it contains a null data array a new
- /// one is created. Some fields in this object are modified to return the
- /// data.
- ///
- ///
- /// The index of the component from which to get the data.
- ///
- ///
- ///
- ///
- ///
- public virtual DataBlk getCompData(DataBlk blk, int c)
- {
- return getData(blk, c, false);
- }
-
- /// Returns, in the blk argument, a block of image data containing the
- /// specifed rectangular area, in the specified component, using the
- /// 'transfer type' defined in the block given as argument. The data is
- /// returned, as a reference to the internal data, if any, instead of as a
- /// copy, therefore the returned data should not be modified.
- ///
- /// The rectangular area to return is specified by the 'ulx', 'uly', 'w'
- /// and 'h' members of the 'blk' argument, relative to the current
- /// tile. These members are not modified by this method. The 'offset' and
- /// 'scanw' of the returned data can be arbitrary. See the 'DataBlk' class.
- ///
- ///
If source data and expected data (blk) are using the same type,
- /// block returned without any modification. If not appropriate cast is
- /// used.
- ///
- ///
This method, in general, is more efficient than the 'getCompData()'
- /// method since it may not copy the data. However if the array of returned
- /// data is to be modified by the caller then the other method is probably
- /// preferable.
- ///
- ///
If the data array in blk is null, then a new one
- /// is created if necessary. The implementation of this interface may
- /// choose to return the same array or a new one, depending on what is more
- /// efficient. Therefore, the data array in blk prior to the
- /// method call should not be considered to contain the returned data, a
- /// new array may have been created. Instead, get the array from
- /// blk after the method has returned.
- ///
- ///
The returned data may have its 'progressive' attribute set. In this
- /// case the returned data is only an approximation of the "final" data.
- ///
- ///
- /// Its coordinates and dimensions specify the area to return,
- /// relative to the current tile. Some fields in this object are modified
- /// to return the data.
- ///
- ///
- /// The index of the component from which to get the data.
- ///
- ///
- /// The requested DataBlk
- ///
- ///
- ///
- ///
- ///
- public DataBlk getInternCompData(DataBlk blk, int c)
- {
- return getData(blk, c, true);
- }
-
- /// Implements the 'getInternCompData()' and the 'getCompData()'
- /// methods. The 'intern' flag signals which of the two methods should run
- /// as.
- ///
- ///
- /// The data block to get.
- ///
- ///
- /// The index of the component from which to get the data.
- ///
- ///
- /// If true behave as 'getInternCompData(). Otherwise behave
- /// as 'getCompData()'
- ///
- ///
- /// The requested data block
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- private DataBlk getData(DataBlk blk, int c, bool intern)
- {
- DataBlk reqBlk; // Reference to block used in request to source
-
- // Keep request data type
- int otype = blk.DataType;
-
- if (otype == srcBlk.DataType)
- {
- // Probably requested type is same as source type
- reqBlk = blk;
- }
- else
- {
- // Probably requested type is not the same as source type
- reqBlk = srcBlk;
- // We need to copy requested coordinates and size
- reqBlk.ulx = blk.ulx;
- reqBlk.uly = blk.uly;
- reqBlk.w = blk.w;
- reqBlk.h = blk.h;
- }
-
- // Get source data block
- if (intern)
- {
- // We can use the intern variant
- srcBlk = src.getInternCompData(reqBlk, c);
- }
- else
- {
- // Do not use the intern variant. Note that this is not optimal
- // since if we are going to convert below then we could have used
- // the intern variant. But there is currently no way to know if we
- // will need to do conversion or not before getting the data.
- srcBlk = src.getCompData(reqBlk, c);
- }
-
- // Check if casting is needed
- if (srcBlk.DataType == otype)
- {
- return srcBlk;
- }
-
- int i;
- int k, kSrc, kmin;
- float mult;
- int w = srcBlk.w;
- int h = srcBlk.h;
-
- switch (otype)
- {
-
- case DataBlk.TYPE_FLOAT: // Cast INT -> FLOAT
-
- float[] farr;
- int[] srcIArr;
-
- // Get data array from resulting blk
- farr = (float[])blk.Data;
- if (farr == null || farr.Length < w * h)
- {
- farr = new float[w * h];
- blk.Data = farr;
- }
-
- blk.scanw = srcBlk.w;
- blk.offset = 0;
- blk.progressive = srcBlk.progressive;
- srcIArr = (int[])srcBlk.Data;
-
- // Cast data from source to blk
- fp = src.getFixedPoint(c);
- if (fp != 0)
- {
- mult = 1.0f / (1 << fp);
- for (i = h - 1, k = w * h - 1, kSrc = srcBlk.offset + (h - 1) * srcBlk.scanw + w - 1; i >= 0; i--)
- {
- for (kmin = k - w; k > kmin; k--, kSrc--)
- {
- farr[k] = ((srcIArr[kSrc] * mult));
- }
- // Jump to geggining of next line in source
- kSrc -= (srcBlk.scanw - w);
- }
- }
- else
- {
- for (i = h - 1, k = w * h - 1, kSrc = srcBlk.offset + (h - 1) * srcBlk.scanw + w - 1; i >= 0; i--)
- {
- for (kmin = k - w; k > kmin; k--, kSrc--)
- {
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- farr[k] = ((float)(srcIArr[kSrc]));
- }
- // Jump to geggining of next line in source
- kSrc -= (srcBlk.scanw - w);
- }
- }
- break; // End of cast INT-> FLOAT
-
-
- case DataBlk.TYPE_INT: // cast FLOAT -> INT
- int[] iarr;
- float[] srcFArr;
-
- // Get data array from resulting blk
- iarr = (int[])blk.Data;
- if (iarr == null || iarr.Length < w * h)
- {
- iarr = new int[w * h];
- blk.Data = iarr;
- }
- blk.scanw = srcBlk.w;
- blk.offset = 0;
- blk.progressive = srcBlk.progressive;
- srcFArr = (float[])srcBlk.Data;
-
- // Cast data from source to blk
- if (fp != 0)
- {
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- mult = (float)(1 << fp);
- for (i = h - 1, k = w * h - 1, kSrc = srcBlk.offset + (h - 1) * srcBlk.scanw + w - 1; i >= 0; i--)
- {
- for (kmin = k - w; k > kmin; k--, kSrc--)
- {
- if (srcFArr[kSrc] > 0.0f)
- {
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- iarr[k] = (int)(srcFArr[kSrc] * mult + 0.5f);
- }
- else
- {
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- iarr[k] = (int)(srcFArr[kSrc] * mult - 0.5f);
- }
- }
- // Jump to geggining of next line in source
- kSrc -= (srcBlk.scanw - w);
- }
- }
- else
- {
- for (i = h - 1, k = w * h - 1, kSrc = srcBlk.offset + (h - 1) * srcBlk.scanw + w - 1; i >= 0; i--)
- {
- for (kmin = k - w; k > kmin; k--, kSrc--)
- {
- if (srcFArr[kSrc] > 0.0f)
- {
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- iarr[k] = (int)(srcFArr[kSrc] + 0.5f);
- }
- else
- {
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- iarr[k] = (int)(srcFArr[kSrc] - 0.5f);
- }
- }
- // Jump to geggining of next line in source
- kSrc -= (srcBlk.scanw - w);
- }
- }
- break; // End cast FLOAT -> INT
-
- default:
- throw new System.ArgumentException("Only integer and float data " + "are " + "supported by JJ2000");
-
- }
- return blk;
- }
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/image/ImgDataJoiner.cs b/CSJ2K/j2k/image/ImgDataJoiner.cs
deleted file mode 100644
index 2b3ff780..00000000
--- a/CSJ2K/j2k/image/ImgDataJoiner.cs
+++ /dev/null
@@ -1,724 +0,0 @@
-/*
-* CVS identifier:
-*
-* $Id: ImgDataJoiner.java,v 1.12 2001/09/14 09:17:00 grosbois Exp $
-*
-* Class: ImgDataJoiner
-*
-* Description: Get ImgData from different sources
-*
-*
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-* */
-namespace CSJ2K.j2k.image
-{
-
- /// This class implements the ImgData interface and allows to obtain data from
- /// different sources. Here, one source is represented by an ImgData and a
- /// component index. The typical use of this class is when the encoder needs
- /// different components (Red, Green, Blue, alpha, ...) from different input
- /// files (i.e. from different ImgReader objects).
- ///
- /// All input ImgData must not be tiled (i.e. must have only 1 tile) and the
- /// image origin must be the canvas origin. The different inputs can have
- /// different dimensions though (this will lead to different subsampling
- /// factors for each component).
- ///
- /// The input ImgData and component index list must be defined when
- /// constructing this class and can not be modified later.
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- public class ImgDataJoiner : BlkImgDataSrc
- {
- /// Returns the overall width of the current tile in pixels. This is the
- /// tile's width without accounting for any component subsampling.
- ///
- ///
- /// The total current tile's width in pixels.
- ///
- ///
- virtual public int TileWidth
- {
- get
- {
- return w;
- }
-
- }
- /// Returns the overall height of the current tile in pixels. This is the
- /// tile's height without accounting for any component subsampling.
- ///
- ///
- /// The total current tile's height in pixels.
- ///
- ///
- virtual public int TileHeight
- {
- get
- {
- return h;
- }
-
- }
- /// Returns the nominal tiles width
- virtual public int NomTileWidth
- {
- get
- {
- return w;
- }
-
- }
- /// Returns the nominal tiles height
- virtual public int NomTileHeight
- {
- get
- {
- return h;
- }
-
- }
- /// Returns the overall width of the image in pixels. This is the image's
- /// width without accounting for any component subsampling or tiling.
- ///
- ///
- /// The total image's width in pixels.
- ///
- ///
- virtual public int ImgWidth
- {
- get
- {
- return w;
- }
-
- }
- /// Returns the overall height of the image in pixels. This is the image's
- /// height without accounting for any component subsampling or tiling.
- ///
- ///
- /// The total image's height in pixels.
- ///
- ///
- virtual public int ImgHeight
- {
- get
- {
- return h;
- }
-
- }
- /// Returns the number of components in the image.
- ///
- ///
- /// The number of components in the image.
- ///
- ///
- virtual public int NumComps
- {
- get
- {
- return nc;
- }
-
- }
- /// Returns the index of the current tile, relative to a standard scan-line
- /// order. This default implementations assumes no tiling, so 0 is always
- /// returned.
- ///
- ///
- /// The current tile's index (starts at 0).
- ///
- ///
- virtual public int TileIdx
- {
- get
- {
- return 0;
- }
-
- }
- /// Returns the horizontal tile partition offset in the reference grid
- virtual public int TilePartULX
- {
- get
- {
- return 0;
- }
-
- }
- /// Returns the vertical tile partition offset in the reference grid
- virtual public int TilePartULY
- {
- get
- {
- return 0;
- }
-
- }
- /// Returns the horizontal coordinate of the image origin, the top-left
- /// corner, in the canvas system, on the reference grid.
- ///
- ///
- /// The horizontal coordinate of the image origin in the canvas
- /// system, on the reference grid.
- ///
- ///
- virtual public int ImgULX
- {
- get
- {
- return 0;
- }
-
- }
- /// Returns the vertical coordinate of the image origin, the top-left
- /// corner, in the canvas system, on the reference grid.
- ///
- ///
- /// The vertical coordinate of the image origin in the canvas
- /// system, on the reference grid.
- ///
- ///
- virtual public int ImgULY
- {
- get
- {
- return 0;
- }
-
- }
-
- /// The width of the image
- private int w;
-
- /// The height of the image
- private int h;
-
- /// The number of components in the image
- private int nc;
-
- /// The list of input ImgData
- private BlkImgDataSrc[] imageData;
-
- /// The component index associated with each ImgData
- private int[] compIdx;
-
- /// The subsampling factor along the horizontal direction, for every
- /// component
- ///
- private int[] subsX;
-
- /// The subsampling factor along the vertical direction, for every
- /// component
- ///
- private int[] subsY;
-
- /// Class constructor. Each input BlkImgDataSrc and its component index
- /// must appear in the order wanted for the output components.
- ///
- /// Example: Reading R,G,B components from 3 PGM files.
- ///
- /// BlkImgDataSrc[] idList =
- /// {
- /// new ImgReaderPGM(new BEBufferedRandomAccessFile("R.pgm", "r")),
- /// new ImgReaderPGM(new BEBufferedRandomAccessFile("G.pgm", "r")),
- /// new ImgReaderPGM(new BEBufferedRandomAccessFile("B.pgm", "r"))
- /// };
- /// int[] compIdx = {0,0,0};
- /// ImgDataJoiner idj = new ImgDataJoiner(idList, compIdx);
- ///
- ///
- /// Of course, the 2 arrays must have the same length (This length is
- /// the number of output components). The image width and height are
- /// definded to be the maximum values of all the input ImgData.
- ///
- ///
- /// The list of input BlkImgDataSrc in an array.
- ///
- ///
- /// The component index associated with each ImgData.
- ///
- ///
- public ImgDataJoiner(BlkImgDataSrc[] imD, int[] cIdx)
- {
- int i;
- int maxW, maxH;
-
- // Initializes
- imageData = imD;
- compIdx = cIdx;
- if (imageData.Length != compIdx.Length)
- throw new System.ArgumentException("imD and cIdx must have the" + " same length");
-
- nc = imD.Length;
-
- subsX = new int[nc];
- subsY = new int[nc];
-
- // Check that no source is tiled and that the image origin is at the
- // canvas origin.
- for (i = 0; i < nc; i++)
- {
- if (imD[i].getNumTiles() != 1 || imD[i].getCompULX(cIdx[i]) != 0 || imD[i].getCompULY(cIdx[i]) != 0)
- {
- throw new System.ArgumentException("All input components must, " + "not use tiles and must " + "have " + "the origin at the canvas " + "origin");
- }
- }
-
- // Guess component subsampling factors based on the fact that the
- // ceil() operation relates the reference grid size to the component's
- // size, through the subsampling factor.
-
- // Mhhh, difficult problem. For now just assume that one of the
- // subsampling factors is always 1 and that the component width is
- // always larger than its subsampling factor, which covers most of the
- // cases. We check the correctness of the solution once found to chek
- // out hypothesis.
-
- // Look for max width and height.
- maxW = 0;
- maxH = 0;
- for (i = 0; i < nc; i++)
- {
- if (imD[i].getCompImgWidth(cIdx[i]) > maxW)
- maxW = imD[i].getCompImgWidth(cIdx[i]);
- if (imD[i].getCompImgHeight(cIdx[i]) > maxH)
- maxH = imD[i].getCompImgHeight(cIdx[i]);
- }
- // Set the image width and height as the maximum ones
- w = maxW;
- h = maxH;
-
- // Now get the sumsampling factors and check the subsampling factors,
- // just to see if above hypothesis were correct.
- for (i = 0; i < nc; i++)
- {
- // This calculation only holds if the subsampling factor is less
- // than the component width
- subsX[i] = (maxW + imD[i].getCompImgWidth(cIdx[i]) - 1) / imD[i].getCompImgWidth(cIdx[i]);
- subsY[i] = (maxH + imD[i].getCompImgHeight(cIdx[i]) - 1) / imD[i].getCompImgHeight(cIdx[i]);
- if ((maxW + subsX[i] - 1) / subsX[i] != imD[i].getCompImgWidth(cIdx[i]) || (maxH + subsY[i] - 1) / subsY[i] != imD[i].getCompImgHeight(cIdx[i]))
- {
- throw new System.ApplicationException("Can not compute component subsampling " + "factors: strange subsampling.");
- }
- }
- }
-
- /// Returns the component subsampling factor in the horizontal direction,
- /// for the specified component. This is, approximately, the ratio of
- /// dimensions between the reference grid and the component itself, see the
- /// 'ImgData' interface desription for details.
- ///
- ///
- /// The index of the component (between 0 and N-1)
- ///
- ///
- /// The horizontal subsampling factor of component 'c'
- ///
- ///
- ///
- ///
- ///
- public virtual int getCompSubsX(int c)
- {
- return subsX[c];
- }
-
- /// Returns the component subsampling factor in the vertical direction, for
- /// the specified component. This is, approximately, the ratio of
- /// dimensions between the reference grid and the component itself, see the
- /// 'ImgData' interface desription for details.
- ///
- ///
- /// The index of the component (between 0 and N-1)
- ///
- ///
- /// The vertical subsampling factor of component 'c'
- ///
- ///
- ///
- ///
- ///
- public virtual int getCompSubsY(int c)
- {
- return subsY[c];
- }
-
-
- /// Returns the width in pixels of the specified tile-component
- ///
- ///
- /// Tile index
- ///
- ///
- /// The index of the component, from 0 to N-1.
- ///
- ///
- /// The width in pixels of component c in tilet.
- ///
- ///
- public virtual int getTileCompWidth(int t, int c)
- {
- return imageData[c].getTileCompWidth(t, compIdx[c]);
- }
-
- /// Returns the height in pixels of the specified tile-component.
- ///
- ///
- /// The tile index.
- ///
- ///
- /// The index of the component, from 0 to N-1.
- ///
- ///
- /// The height in pixels of component c in the current
- /// tile.
- ///
- ///
- public virtual int getTileCompHeight(int t, int c)
- {
- return imageData[c].getTileCompHeight(t, compIdx[c]);
- }
-
- /// Returns the width in pixels of the specified component in the overall
- /// image.
- ///
- ///
- /// The index of the component, from 0 to N-1.
- ///
- ///
- /// The width in pixels of component c in the overall
- /// image.
- ///
- ///
- public virtual int getCompImgWidth(int c)
- {
- return imageData[c].getCompImgWidth(compIdx[c]);
- }
-
- /// Returns the height in pixels of the specified component in the
- /// overall image.
- ///
- ///
- /// The index of the component, from 0 to N-1.
- ///
- ///
- /// The height in pixels of component n in the overall
- /// image.
- ///
- ///
- ///
- ///
- public virtual int getCompImgHeight(int n)
- {
- return imageData[n].getCompImgHeight(compIdx[n]);
- }
-
- /// Returns the number of bits, referred to as the "range bits",
- /// corresponding to the nominal range of the data in the specified
- /// component. If this number is b then for unsigned data the
- /// nominal range is between 0 and 2^b-1, and for signed data it is between
- /// -2^(b-1) and 2^(b-1)-1. For floating point data this value is not
- /// applicable.
- ///
- ///
- /// The index of the component.
- ///
- ///
- /// The number of bits corresponding to the nominal range of the
- /// data. Fro floating-point data this value is not applicable and the
- /// return value is undefined.
- ///
- ///
- public virtual int getNomRangeBits(int c)
- {
- return imageData[c].getNomRangeBits(compIdx[c]);
- }
-
- /// Returns the position of the fixed point in the specified
- /// component. This is the position of the least significant integral
- /// (i.e. non-fractional) bit, which is equivalent to the number of
- /// fractional bits. For instance, for fixed-point values with 2 fractional
- /// bits, 2 is returned. For floating-point data this value does not apply
- /// and 0 should be returned. Position 0 is the position of the least
- /// significant bit in the data.
- ///
- ///
- /// The index of the component.
- ///
- ///
- /// The position of the fixed-point, which is the same as the
- /// number of fractional bits. For floating-point data 0 is returned.
- ///
- ///
- public virtual int getFixedPoint(int c)
- {
- return imageData[c].getFixedPoint(compIdx[c]);
- }
-
- /// Returns, in the blk argument, a block of image data containing the
- /// specifed rectangular area, in the specified component. The data is
- /// returned, as a reference to the internal data, if any, instead of as a
- /// copy, therefore the returned data should not be modified.
- ///
- /// The rectangular area to return is specified by the 'ulx', 'uly', 'w'
- /// and 'h' members of the 'blk' argument, relative to the current
- /// tile. These members are not modified by this method. The 'offset' and
- /// 'scanw' of the returned data can be arbitrary. See the 'DataBlk' class.
- ///
- ///
This method, in general, is more efficient than the 'getCompData()'
- /// method since it may not copy the data. However if the array of returned
- /// data is to be modified by the caller then the other method is probably
- /// preferable.
- ///
- ///
If the data array in blk is null, then a new one
- /// is created if necessary. The implementation of this interface may
- /// choose to return the same array or a new one, depending on what is more
- /// efficient. Therefore, the data array in blk prior to the
- /// method call should not be considered to contain the returned data, a
- /// new array may have been created. Instead, get the array from
- /// blk after the method has returned.
- ///
- ///
The returned data may have its 'progressive' attribute set. In this
- /// case the returned data is only an approximation of the "final" data.
- ///
- ///
- /// Its coordinates and dimensions specify the area to return,
- /// relative to the current tile. Some fields in this object are modified
- /// to return the data.
- ///
- ///
- /// The index of the component from which to get the data.
- ///
- ///
- /// The requested DataBlk
- ///
- ///
- ///
- ///
- ///
- public virtual DataBlk getInternCompData(DataBlk blk, int c)
- {
- return imageData[c].getInternCompData(blk, compIdx[c]);
- }
-
- /// Returns, in the blk argument, a block of image data containing the
- /// specifed rectangular area, in the specified component. The data is
- /// returned, as a copy of the internal data, therefore the returned data
- /// can be modified "in place".
- ///
- /// The rectangular area to return is specified by the 'ulx', 'uly', 'w'
- /// and 'h' members of the 'blk' argument, relative to the current
- /// tile. These members are not modified by this method. The 'offset' of
- /// the returned data is 0, and the 'scanw' is the same as the block's
- /// width. See the 'DataBlk' class.
- ///
- ///
This method, in general, is less efficient than the
- /// 'getInternCompData()' method since, in general, it copies the
- /// data. However if the array of returned data is to be modified by the
- /// caller then this method is preferable.
- ///
- ///
If the data array in 'blk' is 'null', then a new one is created. If
- /// the data array is not 'null' then it is reused, and it must be large
- /// enough to contain the block's data. Otherwise an 'ArrayStoreException'
- /// or an 'IndexOutOfBoundsException' is thrown by the Java system.
- ///
- ///
The returned data may have its 'progressive' attribute set. In this
- /// case the returned data is only an approximation of the "final" data.
- ///
- ///
- /// Its coordinates and dimensions specify the area to return,
- /// relative to the current tile. If it contains a non-null data array,
- /// then it must be large enough. If it contains a null data array a new
- /// one is created. Some fields in this object are modified to return the
- /// data.
- ///
- ///
- /// The index of the component from which to get the data.
- ///
- ///
- /// The requested DataBlk
- ///
- ///
- ///
- ///
- ///
- public virtual DataBlk getCompData(DataBlk blk, int c)
- {
- return imageData[c].getCompData(blk, compIdx[c]);
- }
-
- /// Changes the current tile, given the new coordinates. An
- /// IllegalArgumentException is thrown if the coordinates do not correspond
- /// to a valid tile.
- ///
- ///
- /// The horizontal coordinate of the tile.
- ///
- ///
- /// The vertical coordinate of the new tile.
- ///
- ///
- public virtual void setTile(int x, int y)
- {
- if (x != 0 || y != 0)
- {
- throw new System.ArgumentException();
- }
- }
-
- /// Advances to the next tile, in standard scan-line order (by rows then
- /// columns). A NoNextElementException is thrown if the current tile is the
- /// last one (i.e. there is no next tile). This default implementation
- /// assumes no tiling, so NoNextElementException() is always thrown.
- ///
- ///
- public virtual void nextTile()
- {
- throw new NoNextElementException();
- }
-
- /// Returns the coordinates of the current tile. This default
- /// implementation assumes no-tiling, so (0,0) is returned.
- ///
- ///
- /// If not null this object is used to return the information. If
- /// null a new one is created and returned.
- ///
- ///
- /// The current tile's coordinates.
- ///
- ///
- public virtual Coord getTile(Coord co)
- {
- if (co != null)
- {
- co.x = 0;
- co.y = 0;
- return co;
- }
- else
- {
- return new Coord(0, 0);
- }
- }
-
- /// Returns the horizontal coordinate of the upper-left corner of the
- /// specified component in the current tile.
- ///
- ///
- /// The component index.
- ///
- ///
- public virtual int getCompULX(int c)
- {
- return 0;
- }
-
- /// Returns the vertical coordinate of the upper-left corner of the
- /// specified component in the current tile.
- ///
- ///
- /// The component index.
- ///
- ///
- public virtual int getCompULY(int c)
- {
- return 0;
- }
-
- /// Returns the number of tiles in the horizontal and vertical
- /// directions. This default implementation assumes no tiling, so (1,1) is
- /// always returned.
- ///
- ///
- /// If not null this object is used to return the information. If
- /// null a new one is created and returned.
- ///
- ///
- /// The number of tiles in the horizontal (Coord.x) and vertical
- /// (Coord.y) directions.
- ///
- ///
- public virtual Coord getNumTiles(Coord co)
- {
- if (co != null)
- {
- co.x = 1;
- co.y = 1;
- return co;
- }
- else
- {
- return new Coord(1, 1);
- }
- }
-
- /// Returns the total number of tiles in the image. This default
- /// implementation assumes no tiling, so 1 is always returned.
- ///
- ///
- /// The total number of tiles in the image.
- ///
- ///
- public virtual int getNumTiles()
- {
- return 1;
- }
-
- /// Returns a string of information about the object, more than 1 line
- /// long. The information string includes information from the several
- /// input ImgData (their toString() method are called one after the other).
- ///
- ///
- /// A string of information about the object.
- ///
- ///
- public override System.String ToString()
- {
- System.String string_Renamed = "ImgDataJoiner: WxH = " + w + "x" + h;
- for (int i = 0; i < nc; i++)
- {
- //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Object.toString' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'"
- string_Renamed += ("\n- Component " + i + " " + imageData[i]);
- }
- return string_Renamed;
- }
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/image/Tiler.cs b/CSJ2K/j2k/image/Tiler.cs
deleted file mode 100644
index 9d23770a..00000000
--- a/CSJ2K/j2k/image/Tiler.cs
+++ /dev/null
@@ -1,748 +0,0 @@
-/*
-* CVS identifier:
-*
-* $Id: Tiler.java,v 1.34 2001/09/14 09:16:09 grosbois Exp $
-*
-* Class: Tiler
-*
-* Description: An object to create TiledImgData from
-* ImgData
-*
-*
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-* */
-using CSJ2K.j2k.util;
-namespace CSJ2K.j2k.image
-{
-
- /// This class places an image in the canvas coordinate system, tiles it, if so
- /// specified, and performs the coordinate conversions transparently. The
- /// source must be a 'BlkImgDataSrc' which is not tiled and has a the image
- /// origin at the canvas origin (i.e. it is not "canvased"), or an exception is
- /// thrown by the constructor. A tiled and "canvased" output is given through
- /// the 'BlkImgDataSrc' interface. See the 'ImgData' interface for a
- /// description of the canvas and tiling.
- ///
- /// All tiles produced are rectangular, non-overlapping and their union
- /// covers all the image. However, the tiling may not be uniform, depending on
- /// the nominal tile size, tiling origin, component subsampling and other
- /// factors. Therefore it might not be assumed that all tiles are of the same
- /// width and height.
- ///
- /// The nominal dimension of the tiles is the maximal one, in the reference
- /// grid. All the components of the image have the same number of tiles.
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- public class Tiler : ImgDataAdapter, BlkImgDataSrc
- {
- /// Returns the overall width of the current tile in pixels. This is the
- /// tile's width without accounting for any component subsampling.
- ///
- ///
- /// The total current tile width in pixels.
- ///
- ///
- override public int TileWidth
- {
- get
- {
- return tileW;
- }
-
- }
- /// Returns the overall height of the current tile in pixels. This is the
- /// tile's width without accounting for any component subsampling.
- ///
- ///
- /// The total current tile height in pixels.
- ///
- ///
- override public int TileHeight
- {
- get
- {
- return tileH;
- }
-
- }
- /// Returns the index of the current tile, relative to a standard scan-line
- /// order.
- ///
- ///
- /// The current tile's index (starts at 0).
- ///
- ///
- override public int TileIdx
- {
- get
- {
- return ty * ntX + tx;
- }
-
- }
- /// Returns the horizontal tile partition offset in the reference grid
- override public int TilePartULX
- {
- get
- {
- return xt0siz;
- }
-
- }
- /// Returns the vertical tile partition offset in the reference grid
- override public int TilePartULY
- {
- get
- {
- return yt0siz;
- }
-
- }
- /// Returns the horizontal coordinate of the image origin, the top-left
- /// corner, in the canvas system, on the reference grid.
- ///
- ///
- /// The horizontal coordinate of the image origin in the canvas
- /// system, on the reference grid.
- ///
- ///
- override public int ImgULX
- {
- get
- {
- return x0siz;
- }
-
- }
- /// Returns the vertical coordinate of the image origin, the top-left
- /// corner, in the canvas system, on the reference grid.
- ///
- ///
- /// The vertical coordinate of the image origin in the canvas
- /// system, on the reference grid.
- ///
- ///
- override public int ImgULY
- {
- get
- {
- return y0siz;
- }
-
- }
- /// Returns the nominal width of the tiles in the reference grid.
- ///
- ///
- /// The nominal tile width, in the reference grid.
- ///
- ///
- override public int NomTileWidth
- {
- get
- {
- return xtsiz;
- }
-
- }
- /// Returns the nominal width of the tiles in the reference grid.
- ///
- ///
- /// The nominal tile width, in the reference grid.
- ///
- ///
- override public int NomTileHeight
- {
- get
- {
- return ytsiz;
- }
-
- }
-
- /// The source of image data
- private BlkImgDataSrc src = null;
-
- /// Horizontal coordinate of the upper left hand reference grid point.
- private int x0siz;
-
- /// Vertical coordinate of the upper left hand reference grid point.
- private int y0siz;
-
- /// The horizontal coordinate of the tiling origin in the canvas system,
- /// on the reference grid.
- ///
- private int xt0siz;
-
- /// The vertical coordinate of the tiling origin in the canvas system, on
- /// the reference grid.
- ///
- private int yt0siz;
-
- /// The nominal width of the tiles, on the reference grid. If 0 then there
- /// is no tiling in that direction.
- ///
- private int xtsiz;
-
- /// The nominal height of the tiles, on the reference grid. If 0 then
- /// there is no tiling in that direction.
- ///
- private int ytsiz;
-
- /// The number of tiles in the horizontal direction.
- private int ntX;
-
- /// The number of tiles in the vertical direction.
- private int ntY;
-
- /// The component width in the current active tile, for each component
- private int[] compW = null;
-
- /// The component height in the current active tile, for each component
- private int[] compH = null;
-
- /// The horizontal coordinates of the upper-left corner of the components
- /// in the current tile
- ///
- private int[] tcx0 = null;
-
- /// The vertical coordinates of the upper-left corner of the components in
- /// the current tile.
- ///
- private int[] tcy0 = null;
-
- /// The horizontal index of the current tile
- private int tx;
-
- /// The vertical index of the current tile
- private int ty;
-
- /// The width of the current tile, on the reference grid.
- private int tileW;
-
- /// The height of the current tile, on the reference grid.
- private int tileH;
-
- /// Constructs a new tiler with the specified 'BlkImgDataSrc' source,
- /// image origin, tiling origin and nominal tile size.
- ///
- ///
- /// The 'BlkImgDataSrc' source from where to get the image
- /// data. It must not be tiled and the image origin must be at '(0,0)' on
- /// its canvas.
- ///
- ///
- /// The horizontal coordinate of the image origin in the canvas
- /// system, on the reference grid (i.e. the image's top-left corner in the
- /// reference grid).
- ///
- ///
- /// The vertical coordinate of the image origin in the canvas
- /// system, on the reference grid (i.e. the image's top-left corner in the
- /// reference grid).
- ///
- ///
- /// The horizontal tiling origin, in the canvas system, on the
- /// reference grid. It must satisfy 'px<=ax'.
- ///
- ///
- /// The vertical tiling origin, in the canvas system, on the
- /// reference grid. It must satisfy 'py<=ay'.
- ///
- ///
- /// The nominal tile width, on the reference grid. If 0 then
- /// there is no tiling in that direction.
- ///
- ///
- /// The nominal tile height, on the reference grid. If 0 then
- /// there is no tiling in that direction.
- ///
- ///
- /// If src is tiled or "canvased", or
- /// if the arguments do not satisfy the specified constraints.
- ///
- ///
- public Tiler(BlkImgDataSrc src, int ax, int ay, int px, int py, int nw, int nh) : base(src)
- {
-
- // Initialize
- this.src = src;
- this.x0siz = ax;
- this.y0siz = ay;
- this.xt0siz = px;
- this.yt0siz = py;
- this.xtsiz = nw;
- this.ytsiz = nh;
-
- // Verify that input is not tiled
- if (src.getNumTiles() != 1)
- {
- throw new System.ArgumentException("Source is tiled");
- }
- // Verify that source is not "canvased"
- if (src.ImgULX != 0 || src.ImgULY != 0)
- {
- throw new System.ArgumentException("Source is \"canvased\"");
- }
- // Verify that arguments satisfy trivial requirements
- if (x0siz < 0 || y0siz < 0 || xt0siz < 0 || yt0siz < 0 || xtsiz < 0 || ytsiz < 0 || xt0siz > x0siz || yt0siz > y0siz)
- {
- throw new System.ArgumentException("Invalid image origin, " + "tiling origin or nominal " + "tile size");
- }
-
- // If no tiling has been specified, creates a unique tile with maximum
- // dimension.
- if (xtsiz == 0)
- xtsiz = x0siz + src.ImgWidth - xt0siz;
- if (ytsiz == 0)
- ytsiz = y0siz + src.ImgHeight - yt0siz;
-
- // Automatically adjusts xt0siz,yt0siz so that tile (0,0) always
- // overlaps with the image.
- if (x0siz - xt0siz >= xtsiz)
- {
- xt0siz += ((x0siz - xt0siz) / xtsiz) * xtsiz;
- }
- if (y0siz - yt0siz >= ytsiz)
- {
- yt0siz += ((y0siz - yt0siz) / ytsiz) * ytsiz;
- }
- if (x0siz - xt0siz >= xtsiz || y0siz - yt0siz >= ytsiz)
- {
- FacilityManager.getMsgLogger().printmsg(CSJ2K.j2k.util.MsgLogger_Fields.INFO, "Automatically adjusted tiling " + "origin to equivalent one (" + xt0siz + "," + yt0siz + ") so that " + "first tile overlaps the image");
- }
-
- // Calculate the number of tiles
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- ntX = (int)System.Math.Ceiling((x0siz + src.ImgWidth) / (double)xtsiz);
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- ntY = (int)System.Math.Ceiling((y0siz + src.ImgHeight) / (double)ytsiz);
- }
-
- /// Returns the width in pixels of the specified tile-component.
- ///
- ///
- /// Tile index
- ///
- ///
- /// The index of the component, from 0 to N-1.
- ///
- ///
- /// The width of specified tile-component.
- ///
- ///
- public override int getTileCompWidth(int t, int c)
- {
- if (t != TileIdx)
- {
- throw new System.ApplicationException("Asking the width of a tile-component which is " + "not in the current tile (call setTile() or " + "nextTile() methods before).");
- }
- return compW[c];
- }
-
- /// Returns the height in pixels of the specified tile-component.
- ///
- ///
- /// The tile index.
- ///
- ///
- /// The index of the component, from 0 to N-1.
- ///
- ///
- /// The height of specified tile-component.
- ///
- ///
- public override int getTileCompHeight(int t, int c)
- {
- if (t != TileIdx)
- {
- throw new System.ApplicationException("Asking the width of a tile-component which is " + "not in the current tile (call setTile() or " + "nextTile() methods before).");
- }
- return compH[c];
- }
-
- /// Returns the position of the fixed point in the specified
- /// component. This is the position of the least significant integral
- /// (i.e. non-fractional) bit, which is equivalent to the number of
- /// fractional bits. For instance, for fixed-point values with 2 fractional
- /// bits, 2 is returned. For floating-point data this value does not apply
- /// and 0 should be returned. Position 0 is the position of the least
- /// significant bit in the data.
- ///
- ///
- /// The index of the component.
- ///
- ///
- /// The position of the fixed-point, which is the same as the
- /// number of fractional bits. For floating-point data 0 is returned.
- ///
- ///
- public virtual int getFixedPoint(int c)
- {
- return src.getFixedPoint(c);
- }
-
- /// Returns, in the blk argument, a block of image data containing the
- /// specifed rectangular area, in the specified component. The data is
- /// returned, as a reference to the internal data, if any, instead of as a
- /// copy, therefore the returned data should not be modified.
- ///
- /// The rectangular area to return is specified by the 'ulx', 'uly', 'w'
- /// and 'h' members of the 'blk' argument, relative to the current
- /// tile. These members are not modified by this method. The 'offset' and
- /// 'scanw' of the returned data can be arbitrary. See the 'DataBlk'
- /// class.
- ///
- /// This method, in general, is more efficient than the 'getCompData()'
- /// method since it may not copy the data. However if the array of returned
- /// data is to be modified by the caller then the other method is probably
- /// preferable.
- ///
- /// If the data array in blk is null, then a new one
- /// is created if necessary. The implementation of this interface may
- /// choose to return the same array or a new one, depending on what is more
- /// efficient. Therefore, the data array in blk prior to the
- /// method call should not be considered to contain the returned data, a
- /// new array may have been created. Instead, get the array from
- /// blk after the method has returned.
- ///
- /// The returned data may have its 'progressive' attribute set. In this
- /// case the returned data is only an approximation of the "final"
- /// data.
- ///
- ///
- /// Its coordinates and dimensions specify the area to return,
- /// relative to the current tile. Some fields in this object are modified
- /// to return the data.
- ///
- ///
- /// The index of the component from which to get the data.
- ///
- ///
- /// The requested DataBlk
- ///
- ///
- ///
- ///
- ///
- public DataBlk getInternCompData(DataBlk blk, int c)
- {
- // Check that block is inside tile
- if (blk.ulx < 0 || blk.uly < 0 || blk.w > compW[c] || blk.h > compH[c])
- {
- throw new System.ArgumentException("Block is outside the tile");
- }
- // Translate to the sources coordinates
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- int incx = (int)System.Math.Ceiling(x0siz / (double)src.getCompSubsX(c));
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- int incy = (int)System.Math.Ceiling(y0siz / (double)src.getCompSubsY(c));
- blk.ulx -= incx;
- blk.uly -= incy;
- blk = src.getInternCompData(blk, c);
- // Translate back to the tiled coordinates
- blk.ulx += incx;
- blk.uly += incy;
- return blk;
- }
-
- /// Returns, in the blk argument, a block of image data containing the
- /// specifed rectangular area, in the specified component. The data is
- /// returned, as a copy of the internal data, therefore the returned data
- /// can be modified "in place".
- ///
- /// The rectangular area to return is specified by the 'ulx', 'uly', 'w'
- /// and 'h' members of the 'blk' argument, relative to the current
- /// tile. These members are not modified by this method. The 'offset' of
- /// the returned data is 0, and the 'scanw' is the same as the block's
- /// width. See the 'DataBlk' class.
- ///
- /// This method, in general, is less efficient than the
- /// 'getInternCompData()' method since, in general, it copies the
- /// data. However if the array of returned data is to be modified by the
- /// caller then this method is preferable.
- ///
- /// If the data array in 'blk' is 'null', then a new one is created. If
- /// the data array is not 'null' then it is reused, and it must be large
- /// enough to contain the block's data. Otherwise an 'ArrayStoreException'
- /// or an 'IndexOutOfBoundsException' is thrown by the Java system.
- ///
- /// The returned data may have its 'progressive' attribute set. In this
- /// case the returned data is only an approximation of the "final"
- /// data.
- ///
- ///
- /// Its coordinates and dimensions specify the area to return,
- /// relative to the current tile. If it contains a non-null data array,
- /// then it must be large enough. If it contains a null data array a new
- /// one is created. Some fields in this object are modified to return the
- /// data.
- ///
- ///
- /// The index of the component from which to get the data.
- ///
- ///
- /// The requested DataBlk
- ///
- ///
- ///
- ///
- ///
- public DataBlk getCompData(DataBlk blk, int c)
- {
- // Check that block is inside tile
- if (blk.ulx < 0 || blk.uly < 0 || blk.w > compW[c] || blk.h > compH[c])
- {
- throw new System.ArgumentException("Block is outside the tile");
- }
- // Translate to the source's coordinates
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- int incx = (int)System.Math.Ceiling(x0siz / (double)src.getCompSubsX(c));
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- int incy = (int)System.Math.Ceiling(y0siz / (double)src.getCompSubsY(c));
- blk.ulx -= incx;
- blk.uly -= incy;
- blk = src.getCompData(blk, c);
- // Translate back to the tiled coordinates
- blk.ulx += incx;
- blk.uly += incy;
- return blk;
- }
-
- /// Changes the current tile, given the new tile indexes. An
- /// IllegalArgumentException is thrown if the coordinates do not correspond
- /// to a valid tile.
- ///
- ///
- /// The horizontal index of the tile.
- ///
- ///
- /// The vertical index of the new tile.
- ///
- ///
- public override void setTile(int x, int y)
- {
- // Check tile indexes
- if (x < 0 || y < 0 || x >= ntX || y >= ntY)
- {
- throw new System.ArgumentException("Tile's indexes out of bounds");
- }
-
- // Set new current tile
- tx = x;
- ty = y;
- // Calculate tile origins
- int tx0 = (x != 0) ? xt0siz + x * xtsiz : x0siz;
- int ty0 = (y != 0) ? yt0siz + y * ytsiz : y0siz;
- int tx1 = (x != ntX - 1) ? (xt0siz + (x + 1) * xtsiz) : (x0siz + src.ImgWidth);
- int ty1 = (y != ntY - 1) ? (yt0siz + (y + 1) * ytsiz) : (y0siz + src.ImgHeight);
- // Set general variables
- tileW = tx1 - tx0;
- tileH = ty1 - ty0;
- // Set component specific variables
- int nc = src.NumComps;
- if (compW == null)
- compW = new int[nc];
- if (compH == null)
- compH = new int[nc];
- if (tcx0 == null)
- tcx0 = new int[nc];
- if (tcy0 == null)
- tcy0 = new int[nc];
- for (int i = 0; i < nc; i++)
- {
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- tcx0[i] = (int)System.Math.Ceiling(tx0 / (double)src.getCompSubsX(i));
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- tcy0[i] = (int)System.Math.Ceiling(ty0 / (double)src.getCompSubsY(i));
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- compW[i] = (int)System.Math.Ceiling(tx1 / (double)src.getCompSubsX(i)) - tcx0[i];
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- compH[i] = (int)System.Math.Ceiling(ty1 / (double)src.getCompSubsY(i)) - tcy0[i];
- }
- }
-
- /// Advances to the next tile, in standard scan-line order (by rows then
- /// columns). An NoNextElementException is thrown if the current tile is
- /// the last one (i.e. there is no next tile).
- ///
- ///
- public override void nextTile()
- {
- if (tx == ntX - 1 && ty == ntY - 1)
- {
- // Already at last tile
- throw new NoNextElementException();
- }
- else if (tx < ntX - 1)
- {
- // If not at end of current tile line
- setTile(tx + 1, ty);
- }
- else
- {
- // First tile at next line
- setTile(0, ty + 1);
- }
- }
-
- /// Returns the horizontal and vertical indexes of the current tile.
- ///
- ///
- /// If not null this object is used to return the
- /// information. If null a new one is created and returned.
- ///
- ///
- /// The current tile's horizontal and vertical indexes..
- ///
- ///
- public override Coord getTile(Coord co)
- {
- if (co != null)
- {
- co.x = tx;
- co.y = ty;
- return co;
- }
- else
- {
- return new Coord(tx, ty);
- }
- }
-
- /// Returns the horizontal coordinate of the upper-left corner of the
- /// specified component in the current tile.
- ///
- ///
- /// The component index.
- ///
- ///
- public override int getCompULX(int c)
- {
- return tcx0[c];
- }
-
- /// Returns the vertical coordinate of the upper-left corner of the
- /// specified component in the current tile.
- ///
- ///
- /// The component index.
- ///
- ///
- public override int getCompULY(int c)
- {
- return tcy0[c];
- }
-
- /// Returns the number of tiles in the horizontal and vertical directions.
- ///
- ///
- /// If not null this object is used to return the information. If
- /// null a new one is created and returned.
- ///
- ///
- /// The number of tiles in the horizontal (Coord.x) and vertical
- /// (Coord.y) directions.
- ///
- ///
- public override Coord getNumTiles(Coord co)
- {
- if (co != null)
- {
- co.x = ntX;
- co.y = ntY;
- return co;
- }
- else
- {
- return new Coord(ntX, ntY);
- }
- }
-
- /// Returns the total number of tiles in the image.
- ///
- ///
- /// The total number of tiles in the image.
- ///
- ///
- public override int getNumTiles()
- {
- return ntX * ntY;
- }
-
- /// Returns the tiling origin, referred to as '(xt0siz,yt0siz)' in the
- /// codestream header (SIZ marker segment).
- ///
- ///
- /// If not null this object is used to return the information. If
- /// null a new one is created and returned.
- ///
- ///
- /// The coordinate of the tiling origin, in the canvas system, on
- /// the reference grid.
- ///
- ///
- ///
- ///
- ///
- public Coord getTilingOrigin(Coord co)
- {
- if (co != null)
- {
- co.x = xt0siz;
- co.y = yt0siz;
- return co;
- }
- else
- {
- return new Coord(xt0siz, yt0siz);
- }
- }
-
- /// Returns a String object representing Tiler's informations
- ///
- ///
- /// Tiler's infos in a string
- ///
- ///
- public override System.String ToString()
- {
- //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Object.toString' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'"
- return "Tiler: source= " + src + "\n" + getNumTiles() + " tile(s), nominal width=" + xtsiz + ", nominal height=" + ytsiz;
- }
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/image/forwcomptransf/ForwCompTransf.cs b/CSJ2K/j2k/image/forwcomptransf/ForwCompTransf.cs
deleted file mode 100644
index 7ec78b24..00000000
--- a/CSJ2K/j2k/image/forwcomptransf/ForwCompTransf.cs
+++ /dev/null
@@ -1,890 +0,0 @@
-/*
-* CVS Identifier:
-*
-* $Id: ForwCompTransf.java,v 1.20 2001/09/14 09:14:57 grosbois Exp $
-*
-* Class: ForwCompTransf
-*
-* Description: Component transformations applied to tiles
-*
-*
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-* */
-using CSJ2K.j2k.encoder;
-using CSJ2K.j2k.util;
-using CSJ2K.j2k.wavelet.analysis;
-using System;
-namespace CSJ2K.j2k.image.forwcomptransf
-{
-
- /// This class apply component transformations to the tiles depending on user
- /// specifications. These transformations can be used to improve compression
- /// efficiency but are not related to colour transforms used to map colour
- /// values for display purposes. JPEG 2000 part I defines 2 component
- /// transformations: RCT (Reversible Component Transformation) and ICT
- /// (Irreversible Component Transformation).
- ///
- ///
- ///
- ///
- ///
- public class ForwCompTransf : ImgDataAdapter, BlkImgDataSrc
- {
- /// Returns the parameters that are used in this class and implementing
- /// classes. It returns a 2D String array. Each of the 1D arrays is for a
- /// different option, and they have 4 elements. The first element is the
- /// option name, the second one is the synopsis, the third one is a long
- /// description of what the parameter is and the fourth is its default
- /// value. The synopsis or description may be 'null', in which case it is
- /// assumed that there is no synopsis or description of the option,
- /// respectively. Null may be returned if no options are supported.
- ///
- ///
- /// the options name, their synopsis and their explanation, or null
- /// if no options are supported.
- ///
- ///
- public static System.String[][] ParameterInfo
- {
- get
- {
- return pinfo;
- }
-
- }
- /// Returns true if this transform is reversible in current
- /// tile. Reversible component transformations are those which operation
- /// can be completely reversed without any loss of information (not even
- /// due to rounding).
- ///
- ///
- /// Reversibility of component transformation in current tile
- ///
- ///
- virtual public bool Reversible
- {
- get
- {
- switch (transfType)
- {
-
- case NONE:
- case FORW_RCT:
- return true;
-
- case FORW_ICT:
- return false;
-
- default:
- throw new System.ArgumentException("Non JPEG 2000 part I" + " component transformation");
-
- }
- }
-
- }
- /// Identifier for no component transformation. Value is 0.
- public const int NONE = 0;
-
- /// Identifier for the Forward Reversible Component Transformation
- /// (FORW_RCT). Value is 1.
- ///
- public const int FORW_RCT = 1;
-
- /// Identifier for the Forward Irreversible Component Transformation
- /// (FORW_ICT). Value is 2
- ///
- public const int FORW_ICT = 2;
-
- /// The source of image data
- private BlkImgDataSrc src;
-
- /// The component transformations specifications
- private CompTransfSpec cts;
-
- /// The wavelet filter specifications
- private AnWTFilterSpec wfs;
-
- /// The type of the current component transformation. JPEG 2000 part 1
- /// supports only NONE, FORW_RCT and FORW_ICT types
- ///
- private int transfType = NONE;
-
- /// The bit-depths of transformed components
- private int[] tdepth;
-
- /// Output block used instead of the one provided as an argument if the
- /// later is DataBlkFloat.
- ///
- private DataBlk outBlk;
-
- /// Block used to request component with index 0
- private DataBlkInt block0;
-
- /// Block used to request component with index 1
- private DataBlkInt block1;
-
- /// Block used to request component with index 2
- private DataBlkInt block2;
-
- /// Constructs a new ForwCompTransf object that operates on the specified
- /// source of image data.
- ///
- ///
- /// The source from where to get the data to be transformed
- ///
- ///
- /// The encoder specifications
- ///
- ///
- ///
- ///
- ///
- public ForwCompTransf(BlkImgDataSrc imgSrc, EncoderSpecs encSpec) : base(imgSrc)
- {
- this.cts = encSpec.cts;
- this.wfs = encSpec.wfs;
- src = imgSrc;
- }
-
- /// The prefix for component transformation type: 'M'
- public const char OPT_PREFIX = 'M';
-
- /// The list of parameters that is accepted by the forward component
- /// transformation module. Options start with an 'M'.
- ///
- //UPGRADE_NOTE: Final was removed from the declaration of 'pinfo'. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- private static readonly System.String[][] pinfo = new System.String[][] { new System.String[] { "Mct", "[] [on|off] ...", "Specifies in which tiles to use a multiple component transform. " + "Note that this multiple component transform can only be applied " + "in tiles that contain at least three components and whose " + "components are processed with the same wavelet filters and " + "quantization type. " + "If the wavelet transform is reversible (w5x3 filter), the " + "Reversible Component Transformation (RCT) is applied. If not " + "(w9x7 filter), the Irreversible Component Transformation (ICT)" + " is used.", null } };
-
- /// Returns the position of the fixed point in the specified
- /// component. This is the position of the least significant integral
- /// (i.e. non-fractional) bit, which is equivalent to the number of
- /// fractional bits. For instance, for fixed-point values with 2 fractional
- /// bits, 2 is returned. For floating-point data this value does not apply
- /// and 0 should be returned. Position 0 is the position of the least
- /// significant bit in the data.
- ///
- /// This default implementation assumes that the number of fractional
- /// bits is not modified by the component mixer.
- ///
- ///
- /// The index of the component.
- ///
- ///
- /// The value of the fixed point position of the source since the
- /// color transform does not affect it.
- ///
- ///
- public virtual int getFixedPoint(int c)
- {
- return src.getFixedPoint(c);
- }
-
- /// Calculates the bitdepths of the transformed components, given the
- /// bitdepth of the un-transformed components and the component
- /// transformation type.
- ///
- ///
- /// The bitdepth of each non-transformed components.
- ///
- ///
- /// The type ID of the component transformation.
- ///
- ///
- /// If not null the results are stored in this array,
- /// otherwise a new array is allocated and returned.
- ///
- ///
- /// The bitdepth of each transformed component.
- ///
- ///
- public static int[] calcMixedBitDepths(int[] ntdepth, int ttype, int[] tdepth)
- {
-
- if (ntdepth.Length < 3 && ttype != NONE)
- {
- throw new System.ArgumentException();
- }
-
- if (tdepth == null)
- {
- tdepth = new int[ntdepth.Length];
- }
-
- switch (ttype)
- {
-
- case NONE:
- Array.Copy(ntdepth, 0, tdepth, 0, ntdepth.Length);
- break;
-
- case FORW_RCT:
- if (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]+
- // 2^(ntdepth[2])))-2+1
- // tdepth[1] = ceil(log2(2^(ntdepth[1])+2^(ntdepth[2])-1))+1
- // tdepth[2] = ceil(log2(2^(ntdepth[0])+2^(ntdepth[1])-1))+1
- // The MathUtil.log2(x) function calculates floor(log2(x)), so we
- // use 'MathUtil.log2(2*x-1)+1', which calculates ceil(log2(x))
- // for any x>=1, x integer.
- tdepth[0] = MathUtil.log2((1 << ntdepth[0]) + (2 << ntdepth[1]) + (1 << ntdepth[2]) - 1) - 2 + 1;
- tdepth[1] = MathUtil.log2((1 << ntdepth[2]) + (1 << ntdepth[1]) - 1) + 1;
- tdepth[2] = MathUtil.log2((1 << ntdepth[0]) + (1 << ntdepth[1]) - 1) + 1;
- break;
-
- case FORW_ICT:
- if (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))
- // for any x>=1, x integer.
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- tdepth[0] = MathUtil.log2((int)System.Math.Floor((1 << ntdepth[0]) * 0.299072 + (1 << ntdepth[1]) * 0.586914 + (1 << ntdepth[2]) * 0.114014) - 1) + 1;
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- tdepth[1] = MathUtil.log2((int)System.Math.Floor((1 << ntdepth[0]) * 0.168701 + (1 << ntdepth[1]) * 0.331299 + (1 << ntdepth[2]) * 0.5) - 1) + 1;
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- tdepth[2] = MathUtil.log2((int)System.Math.Floor((1 << ntdepth[0]) * 0.5 + (1 << ntdepth[1]) * 0.418701 + (1 << ntdepth[2]) * 0.081299) - 1) + 1;
- break;
- }
-
- return tdepth;
- }
-
- /// Initialize some variables used with RCT. It must be called, at least,
- /// at the beginning of each new tile.
- ///
- ///
- private void initForwRCT()
- {
- int i;
- int tIdx = TileIdx;
-
- if (src.NumComps < 3)
- {
- throw new System.ArgumentException();
- }
- // Check that the 3 components have the same dimensions
- if (src.getTileCompWidth(tIdx, 0) != src.getTileCompWidth(tIdx, 1) || src.getTileCompWidth(tIdx, 0) != src.getTileCompWidth(tIdx, 2) || src.getTileCompHeight(tIdx, 0) != src.getTileCompHeight(tIdx, 1) || src.getTileCompHeight(tIdx, 0) != src.getTileCompHeight(tIdx, 2))
- {
- throw new System.ArgumentException("Can not use RCT " + "on components with different " + "dimensions");
- }
- // Initialize bitdepths
- int[] utd; // Premix bitdepths
- utd = new int[src.NumComps];
- for (i = utd.Length - 1; i >= 0; i--)
- {
- utd[i] = src.getNomRangeBits(i);
- }
- tdepth = calcMixedBitDepths(utd, FORW_RCT, null);
- }
-
- /// Initialize some variables used with ICT. It must be called, at least,
- /// at the beginning of a new tile.
- ///
- ///
- private void initForwICT()
- {
- int i;
- int tIdx = TileIdx;
-
- if (src.NumComps < 3)
- {
- throw new System.ArgumentException();
- }
- // Check that the 3 components have the same dimensions
- if (src.getTileCompWidth(tIdx, 0) != src.getTileCompWidth(tIdx, 1) || src.getTileCompWidth(tIdx, 0) != src.getTileCompWidth(tIdx, 2) || src.getTileCompHeight(tIdx, 0) != src.getTileCompHeight(tIdx, 1) || src.getTileCompHeight(tIdx, 0) != src.getTileCompHeight(tIdx, 2))
- {
- throw new System.ArgumentException("Can not use ICT " + "on components with different " + "dimensions");
- }
- // Initialize bitdepths
- int[] utd; // Premix bitdepths
- utd = new int[src.NumComps];
- for (i = utd.Length - 1; i >= 0; i--)
- {
- utd[i] = src.getNomRangeBits(i);
- }
- tdepth = calcMixedBitDepths(utd, FORW_ICT, null);
- }
-
- /// Returns a string with a descriptive text of which forward component
- /// transformation is used. This can be either "Forward RCT" or "Forward
- /// ICT" or "No component transformation" depending on the current tile.
- ///
- ///
- /// A descriptive string
- ///
- ///
- public override System.String ToString()
- {
- switch (transfType)
- {
-
- case FORW_RCT:
- return "Forward RCT";
-
- case FORW_ICT:
- return "Forward ICT";
-
- case NONE:
- return "No component transformation";
-
- default:
- throw new System.ArgumentException("Non JPEG 2000 part I" + " component transformation");
-
- }
- }
-
- /// Returns the number of bits, referred to as the "range bits",
- /// corresponding to the nominal range of the data in the specified
- /// component and in the current tile. If this number is b then for
- /// unsigned data the nominal range is between 0 and 2^b-1, and for signed
- /// data it is between -2^(b-1) and 2^(b-1)-1. Note that this value can be
- /// affected by the multiple component transform.
- ///
- ///
- /// The index of the component.
- ///
- ///
- /// The bitdepth of component 'c' after mixing.
- ///
- ///
- public override int getNomRangeBits(int c)
- {
- switch (transfType)
- {
-
- case FORW_RCT:
- case FORW_ICT:
- return tdepth[c];
-
- case NONE:
- return src.getNomRangeBits(c);
-
- default:
- throw new System.ArgumentException("Non JPEG 2000 part I" + " component transformation");
-
- }
- }
-
- /// Apply forward component transformation associated with the current
- /// tile. If no component transformation has been requested by the user,
- /// data are not modified.
- ///
- /// This method calls the getInternCompData() method, but respects the
- /// definitions of the getCompData() method defined in the BlkImgDataSrc
- /// interface.
- ///
- ///
- /// Determines the rectangular area to return, and the data is
- /// returned in this object.
- ///
- ///
- /// Index of the output component.
- ///
- ///
- /// The requested DataBlk
- ///
- ///
- ///
- ///
- ///
- public virtual DataBlk getCompData(DataBlk blk, int c)
- {
- // If requesting a component whose index is greater than 3 or there is
- // no transform return a copy of data (getInternCompData returns the
- // actual data in those cases)
- if (c >= 3 || transfType == NONE)
- {
- return src.getCompData(blk, c);
- }
- else
- {
- // We can use getInternCompData (since data is a copy anyways)
- return getInternCompData(blk, c);
- }
- }
-
- /// Apply the component transformation associated with the current tile. If
- /// no component transformation has been requested by the user, data are
- /// not modified. Else, appropriate method is called (forwRCT or forwICT).
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- /// Determines the rectangular area to return.
- ///
- ///
- /// Index of the output component.
- ///
- ///
- /// The requested DataBlk
- ///
- ///
- public virtual DataBlk getInternCompData(DataBlk blk, int c)
- {
- switch (transfType)
- {
-
- case NONE:
- return src.getInternCompData(blk, c);
-
- case FORW_RCT:
- return forwRCT(blk, c);
-
- case FORW_ICT:
- return forwICT(blk, c);
-
- default:
- throw new System.ArgumentException("Non JPEG 2000 part 1 " + "component" + " transformation for tile: " + tIdx);
-
- }
- }
-
- /// Apply forward component transformation to obtain requested component
- /// from specified block of data. Whatever the type of requested DataBlk,
- /// it always returns a DataBlkInt.
- ///
- ///
- /// Determine the rectangular area to return
- ///
- ///
- /// The index of the requested component
- ///
- ///
- /// Data of requested component
- ///
- ///
- private DataBlk forwRCT(DataBlk blk, int c)
- {
- int k, k0, k1, k2, mink, i;
- int w = blk.w; //width of output block
- int h = blk.h; //height of ouput block
- int[] outdata; //array of output data
-
- //If asking for Yr, Ur or Vr do transform
- if (c >= 0 && c <= 2)
- {
- // Check that request data type is int
- if (blk.DataType != DataBlk.TYPE_INT)
- {
- if (outBlk == null || outBlk.DataType != DataBlk.TYPE_INT)
- {
- outBlk = new DataBlkInt();
- }
- outBlk.w = w;
- outBlk.h = h;
- outBlk.ulx = blk.ulx;
- outBlk.uly = blk.uly;
- blk = outBlk;
- }
-
- //Reference to output block data array
- outdata = (int[])blk.Data;
-
- //Create data array of blk if necessary
- if (outdata == null || outdata.Length < h * w)
- {
- outdata = new int[h * w];
- blk.Data = outdata;
- }
-
- // Block buffers for input RGB data
- int[] data0, data1, bdata; // input data arrays
-
- if (block0 == null)
- block0 = new DataBlkInt();
- if (block1 == null)
- block1 = new DataBlkInt();
- if (block2 == null)
- block2 = new DataBlkInt();
- block0.w = block1.w = block2.w = blk.w;
- block0.h = block1.h = block2.h = blk.h;
- block0.ulx = block1.ulx = block2.ulx = blk.ulx;
- block0.uly = block1.uly = block2.uly = blk.uly;
-
- //Fill in buffer blocks (to be read only)
- // Returned blocks may have different size and position
- block0 = (DataBlkInt)src.getInternCompData(block0, 0);
- data0 = (int[])block0.Data;
- block1 = (DataBlkInt)src.getInternCompData(block1, 1);
- data1 = (int[])block1.Data;
- block2 = (DataBlkInt)src.getInternCompData(block2, 2);
- bdata = (int[])block2.Data;
-
- // Set the progressiveness of the output data
- blk.progressive = block0.progressive || block1.progressive || block2.progressive;
- blk.offset = 0;
- blk.scanw = w;
-
- //Perform conversion
-
- // Initialize general indexes
- k = w * h - 1;
- k0 = block0.offset + (h - 1) * block0.scanw + w - 1;
- k1 = block1.offset + (h - 1) * block1.scanw + w - 1;
- k2 = block2.offset + (h - 1) * block2.scanw + w - 1;
-
- switch (c)
- {
-
- case 0: //RGB to Yr conversion
- for (i = h - 1; i >= 0; i--)
- {
- for (mink = k - w; k > mink; k--, k0--, k1--, k2--)
- {
- // Use int arithmetic with 12 fractional bits
- // and rounding
- outdata[k] = (data0[k] + 2 * data1[k] + bdata[k]) >> 2; // Same as / 4
- }
- // Jump to beggining of previous line in input
- k0 -= (block0.scanw - w);
- k1 -= (block1.scanw - w);
- k2 -= (block2.scanw - w);
- }
- break;
-
-
- case 1: //RGB to Ur conversion
- for (i = h - 1; i >= 0; i--)
- {
- for (mink = k - w; k > mink; k--, k1--, k2--)
- {
- // Use int arithmetic with 12 fractional bits
- // and rounding
- outdata[k] = bdata[k2] - data1[k1];
- }
- // Jump to beggining of previous line in input
- k1 -= (block1.scanw - w);
- k2 -= (block2.scanw - w);
- }
- break;
-
-
- case 2: //RGB to Vr conversion
- for (i = h - 1; i >= 0; i--)
- {
- for (mink = k - w; k > mink; k--, k0--, k1--)
- {
- // Use int arithmetic with 12 fractional bits
- // and rounding
- outdata[k] = data0[k0] - data1[k1];
- }
- // Jump to beggining of previous line in input
- k0 -= (block0.scanw - w);
- k1 -= (block1.scanw - w);
- }
- break;
- }
- }
- else if (c >= 3)
- {
- // Requesting a component which is not Y, Ur or Vr =>
- // just pass the data
- return src.getInternCompData(blk, c);
- }
- else
- {
- // Requesting a non valid component index
- throw new System.ArgumentException();
- }
- return blk;
- }
-
- /// Apply forward irreversible component transformation to obtain requested
- /// component from specified block of data. Whatever the type of requested
- /// DataBlk, it always returns a DataBlkFloat.
- ///
- ///
- /// Determine the rectangular area to return
- ///
- ///
- /// The index of the requested component
- ///
- ///
- /// Data of requested component
- ///
- ///
- private DataBlk forwICT(DataBlk blk, int c)
- {
- int k, k0, k1, k2, mink, i;
- int w = blk.w; //width of output block
- int h = blk.h; //height of ouput block
- float[] outdata; //array of output data
-
- if (blk.DataType != DataBlk.TYPE_FLOAT)
- {
- if (outBlk == null || outBlk.DataType != DataBlk.TYPE_FLOAT)
- {
- outBlk = new DataBlkFloat();
- }
- outBlk.w = w;
- outBlk.h = h;
- outBlk.ulx = blk.ulx;
- outBlk.uly = blk.uly;
- blk = outBlk;
- }
-
- //Reference to output block data array
- outdata = (float[])blk.Data;
-
- //Create data array of blk if necessary
- if (outdata == null || outdata.Length < w * h)
- {
- outdata = new float[h * w];
- blk.Data = outdata;
- }
-
- //If asking for Y, Cb or Cr do transform
- if (c >= 0 && c <= 2)
- {
-
- int[] data0, data1, data2; // input data arrays
-
- if (block0 == null)
- {
- block0 = new DataBlkInt();
- }
- if (block1 == null)
- {
- block1 = new DataBlkInt();
- }
- if (block2 == null)
- {
- block2 = new DataBlkInt();
- }
- block0.w = block1.w = block2.w = blk.w;
- block0.h = block1.h = block2.h = blk.h;
- block0.ulx = block1.ulx = block2.ulx = blk.ulx;
- block0.uly = block1.uly = block2.uly = blk.uly;
-
- // Returned blocks may have different size and position
- block0 = (DataBlkInt)src.getInternCompData(block0, 0);
- data0 = (int[])block0.Data;
- block1 = (DataBlkInt)src.getInternCompData(block1, 1);
- data1 = (int[])block1.Data;
- block2 = (DataBlkInt)src.getInternCompData(block2, 2);
- data2 = (int[])block2.Data;
-
- // Set the progressiveness of the output data
- blk.progressive = block0.progressive || block1.progressive || block2.progressive;
- blk.offset = 0;
- blk.scanw = w;
-
- //Perform conversion
-
- // Initialize general indexes
- k = w * h - 1;
- k0 = block0.offset + (h - 1) * block0.scanw + w - 1;
- k1 = block1.offset + (h - 1) * block1.scanw + w - 1;
- k2 = block2.offset + (h - 1) * block2.scanw + w - 1;
-
- switch (c)
- {
-
- case 0:
- //RGB to Y conversion
- for (i = h - 1; i >= 0; i--)
- {
- for (mink = k - w; k > mink; k--, k0--, k1--, k2--)
- {
- outdata[k] = 0.299f * data0[k0] + 0.587f * data1[k1] + 0.114f * data2[k2];
- }
- // Jump to beggining of previous line in input
- k0 -= (block0.scanw - w);
- k1 -= (block1.scanw - w);
- k2 -= (block2.scanw - w);
- }
- break;
-
-
- case 1:
- //RGB to Cb conversion
- for (i = h - 1; i >= 0; i--)
- {
- for (mink = k - w; k > mink; k--, k0--, k1--, k2--)
- {
- outdata[k] = (-0.16875f) * data0[k0] - 0.33126f * data1[k1] + 0.5f * data2[k2];
- }
- // Jump to beggining of previous line in input
- k0 -= (block0.scanw - w);
- k1 -= (block1.scanw - w);
- k2 -= (block2.scanw - w);
- }
- break;
-
-
- case 2:
- //RGB to Cr conversion
- for (i = h - 1; i >= 0; i--)
- {
- for (mink = k - w; k > mink; k--, k0--, k1--, k2--)
- {
- outdata[k] = 0.5f * data0[k0] - 0.41869f * data1[k1] - 0.08131f * data2[k2];
- }
- // Jump to beggining of previous line in input
- k0 -= (block0.scanw - w);
- k1 -= (block1.scanw - w);
- k2 -= (block2.scanw - w);
- }
- break;
- }
- }
- else if (c >= 3)
- {
- // Requesting a component which is not Y, Cb or Cr =>
- // just pass the data
-
- // Variables
- DataBlkInt indb = new DataBlkInt(blk.ulx, blk.uly, w, h);
- int[] indata; // input data array
-
- // Get the input data
- // (returned block may be larger than requested one)
- src.getInternCompData(indb, c);
- indata = (int[])indb.Data;
-
- // Copy the data converting from int to float
- k = w * h - 1;
- k0 = indb.offset + (h - 1) * indb.scanw + w - 1;
- for (i = h - 1; i >= 0; i--)
- {
- for (mink = k - w; k > mink; k--, k0--)
- {
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- outdata[k] = (float)indata[k0];
- }
- // Jump to beggining of next line in input
- k0 += indb.w - w;
- }
-
- // Set the progressivity
- blk.progressive = indb.progressive;
- blk.offset = 0;
- blk.scanw = w;
- return blk;
- }
- else
- {
- // Requesting a non valid component index
- throw new System.ArgumentException();
- }
- return blk;
- }
-
- /// Changes the current tile, given the new indexes. An
- /// IllegalArgumentException is thrown if the indexes do not correspond to
- /// a valid tile.
- ///
- /// This default implementation changes the tile in the source and
- /// re-initializes properly component transformation variables..
- ///
- ///
- /// The horizontal index of the tile.
- ///
- ///
- /// The vertical index of the new tile.
- ///
- ///
- public override void setTile(int x, int y)
- {
- src.setTile(x, y);
- tIdx = TileIdx; // index of the current tile
-
- // initializations
- System.String str = (System.String)cts.getTileDef(tIdx);
- if (str.Equals("none"))
- {
- transfType = NONE;
- }
- else if (str.Equals("rct"))
- {
- transfType = FORW_RCT;
- initForwRCT();
- }
- else if (str.Equals("ict"))
- {
- transfType = FORW_ICT;
- initForwICT();
- }
- else
- {
- throw new System.ArgumentException("Component transformation" + " not recognized");
- }
- }
-
- /// Goes to the next tile, in standard scan-line order (by rows then by
- /// columns). An NoNextElementException is thrown if the current tile is
- /// the last one (i.e. there is no next tile).
- ///
- /// This default implementation just advances to the next tile in the
- /// source and re-initializes properly component transformation
- /// variables.
- ///
- ///
- public override void nextTile()
- {
- src.nextTile();
- tIdx = TileIdx; // index of the current tile
-
- // initializations
- System.String str = (System.String)cts.getTileDef(tIdx);
- if (str.Equals("none"))
- {
- transfType = NONE;
- }
- else if (str.Equals("rct"))
- {
- transfType = FORW_RCT;
- initForwRCT();
- }
- else if (str.Equals("ict"))
- {
- transfType = FORW_ICT;
- initForwICT();
- }
- else
- {
- throw new System.ArgumentException("Component transformation" + " not recognized");
- }
- }
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/image/forwcomptransf/ForwCompTransfSpec.cs b/CSJ2K/j2k/image/forwcomptransf/ForwCompTransfSpec.cs
deleted file mode 100644
index 882a15e0..00000000
--- a/CSJ2K/j2k/image/forwcomptransf/ForwCompTransfSpec.cs
+++ /dev/null
@@ -1,438 +0,0 @@
-/*
-* CVS identifier:
-*
-* $Id: ForwCompTransfSpec.java,v 1.7 2001/05/08 16:10:18 grosbois Exp $
-*
-* Class: ForwCompTransfSpec
-*
-* Description: Component Transformation specification for encoder
-*
-*
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-* */
-using CSJ2K.j2k.util;
-using CSJ2K.j2k.wavelet;
-using CSJ2K.j2k.wavelet.analysis;
-namespace CSJ2K.j2k.image.forwcomptransf
-{
-
- /// This class extends CompTransfSpec class in order to hold encoder specific
- /// aspects of CompTransfSpec.
- ///
- ///
- ///
- ///
- ///
- public class ForwCompTransfSpec : CompTransfSpec, FilterTypes
- {
- /// Constructs a new 'ForwCompTransfSpec' for the specified number of
- /// components and tiles, the wavelet filters type and the parameter of the
- /// option 'Mct'. This constructor is called by the encoder. It also checks
- /// that the arguments belong to the recognized arguments list.
- ///
- /// This constructor chose the component transformation type depending
- /// on the wavelet filters : RCT with w5x3 filter and ICT with w9x7
- /// filter. Note: All filters must use the same data type.
- ///
- ///
- /// The number of tiles
- ///
- ///
- /// The number of components
- ///
- ///
- /// the type of the specification module i.e. tile specific,
- /// component specific or both.
- ///
- ///
- /// The wavelet filter specifications
- ///
- ///
- /// The ParameterList
- ///
- ///
- public ForwCompTransfSpec(int nt, int nc, byte type, AnWTFilterSpec wfs, ParameterList pl) : base(nt, nc, type)
- {
-
- System.String param = pl.getParameter("Mct");
-
- if (param == null)
- {
- // The option has not been specified
-
- // If less than three component, do not use any component
- // transformation
- if (nc < 3)
- {
- setDefault("none");
- return;
- }
- // If the compression is lossless, uses RCT
- else if (pl.getBooleanParameter("lossless"))
- {
- setDefault("rct");
- return;
- }
- else
- {
- AnWTFilter[][] anfilt;
- int[] filtType = new int[nComp];
- for (int c = 0; c < 3; c++)
- {
- anfilt = (AnWTFilter[][])wfs.getCompDef(c);
- filtType[c] = anfilt[0][0].FilterType;
- }
-
- // Check that the three first components use the same filters
- bool reject = false;
- for (int c = 1; c < 3; c++)
- {
- if (filtType[c] != filtType[0])
- reject = true;
- }
-
- if (reject)
- {
- setDefault("none");
- }
- else
- {
- anfilt = (AnWTFilter[][])wfs.getCompDef(0);
- if (anfilt[0][0].FilterType == CSJ2K.j2k.wavelet.FilterTypes_Fields.W9X7)
- {
- setDefault("ict");
- }
- else
- {
- setDefault("rct");
- }
- }
- }
-
- // Each tile receives a component transform specification
- // according the type of wavelet filters that are used by the
- // three first components
- for (int t = 0; t < nt; t++)
- {
- AnWTFilter[][] anfilt;
- int[] filtType = new int[nComp];
- for (int c = 0; c < 3; c++)
- {
- anfilt = (AnWTFilter[][])wfs.getTileCompVal(t, c);
- filtType[c] = anfilt[0][0].FilterType;
- }
-
- // Check that the three components use the same filters
- bool reject = false;
- for (int c = 1; c < nComp; c++)
- {
- if (filtType[c] != filtType[0])
- reject = true;
- }
-
- if (reject)
- {
- setTileDef(t, "none");
- }
- else
- {
- anfilt = (AnWTFilter[][])wfs.getTileCompVal(t, 0);
- if (anfilt[0][0].FilterType == CSJ2K.j2k.wavelet.FilterTypes_Fields.W9X7)
- {
- setTileDef(t, "ict");
- }
- else
- {
- setTileDef(t, "rct");
- }
- }
- }
- return;
- }
-
- // Parse argument
- SupportClass.Tokenizer stk = new SupportClass.Tokenizer(param);
- System.String word; // current word
- byte curSpecType = SPEC_DEF; // Specification type of the
- // current parameter
- bool[] tileSpec = null; // Tiles concerned by the
- // specification
- //System.Boolean value_Renamed;
-
- while (stk.HasMoreTokens())
- {
- word = stk.NextToken();
-
- switch (word[0])
- {
-
- case 't': // Tiles specification
- tileSpec = parseIdx(word, nTiles);
- if (curSpecType == SPEC_COMP_DEF)
- {
- curSpecType = SPEC_TILE_COMP;
- }
- else
- {
- curSpecType = SPEC_TILE_DEF;
- }
- break;
-
- case 'c': // Components specification
- throw new System.ArgumentException("Component specific " + " parameters" + " not allowed with " + "'-Mct' option");
-
- default:
- if (word.Equals("off"))
- {
- if (curSpecType == SPEC_DEF)
- {
- setDefault("none");
- }
- else if (curSpecType == SPEC_TILE_DEF)
- {
- for (int i = tileSpec.Length - 1; i >= 0; i--)
- if (tileSpec[i])
- {
- setTileDef(i, "none");
- }
- }
- }
- else if (word.Equals("on"))
- {
- if (nc < 3)
- {
- throw new System.ArgumentException("Cannot use component" + " transformation on a " + "image with less than " + "three components");
- }
-
- if (curSpecType == SPEC_DEF)
- {
- // Set arbitrarily the default
- // value to RCT (later will be found the suitable
- // component transform for each tile)
- setDefault("rct");
- }
- else if (curSpecType == SPEC_TILE_DEF)
- {
- for (int i = tileSpec.Length - 1; i >= 0; i--)
- {
- if (tileSpec[i])
- {
- if (getFilterType(i, wfs) == CSJ2K.j2k.wavelet.FilterTypes_Fields.W5X3)
- {
- setTileDef(i, "rct");
- }
- else
- {
- setTileDef(i, "ict");
- }
- }
- }
- }
- }
- else
- {
- throw new System.ArgumentException("Default parameter of " + "option Mct not" + " recognized: " + param);
- }
-
- // Re-initialize
- curSpecType = SPEC_DEF;
- tileSpec = null;
- break;
-
- }
- }
-
- // Check that default value has been specified
- if (getDefault() == null)
- {
- // If not, set arbitrarily the default value to 'none' but
- // specifies explicitely a default value for each tile depending
- // on the wavelet transform that is used
- setDefault("none");
-
- for (int t = 0; t < nt; t++)
- {
- if (isTileSpecified(t))
- {
- continue;
- }
-
- AnWTFilter[][] anfilt;
- int[] filtType = new int[nComp];
- for (int c = 0; c < 3; c++)
- {
- anfilt = (AnWTFilter[][])wfs.getTileCompVal(t, c);
- filtType[c] = anfilt[0][0].FilterType;
- }
-
- // Check that the three components use the same filters
- bool reject = false;
- for (int c = 1; c < nComp; c++)
- {
- if (filtType[c] != filtType[0])
- reject = true;
- }
-
- if (reject)
- {
- setTileDef(t, "none");
- }
- else
- {
- anfilt = (AnWTFilter[][])wfs.getTileCompVal(t, 0);
- if (anfilt[0][0].FilterType == CSJ2K.j2k.wavelet.FilterTypes_Fields.W9X7)
- {
- setTileDef(t, "ict");
- }
- else
- {
- setTileDef(t, "rct");
- }
- }
- }
- }
-
- // Check validity of component transformation of each tile compared to
- // the filter used.
- for (int t = nt - 1; t >= 0; t--)
- {
-
- if (((System.String)getTileDef(t)).Equals("none"))
- {
- // No comp. transf is used. No check is needed
- continue;
- }
- else if (((System.String)getTileDef(t)).Equals("rct"))
- {
- // Tile is using Reversible component transform
- int filterType = getFilterType(t, wfs);
- switch (filterType)
- {
-
- case CSJ2K.j2k.wavelet.FilterTypes_Fields.W5X3: // OK
- break;
-
- case CSJ2K.j2k.wavelet.FilterTypes_Fields.W9X7: // Must use ICT
- if (isTileSpecified(t))
- {
- // User has requested RCT -> Error
- throw new System.ArgumentException("Cannot use RCT " + "with 9x7 filter " + "in tile " + t);
- }
- else
- {
- // Specify ICT for this tile
- setTileDef(t, "ict");
- }
- break;
-
- default:
- throw new System.ArgumentException("Default filter is " + "not JPEG 2000 part" + " I compliant");
-
- }
- }
- else
- {
- // ICT
- int filterType = getFilterType(t, wfs);
- switch (filterType)
- {
-
- case CSJ2K.j2k.wavelet.FilterTypes_Fields.W5X3: // Must use RCT
- if (isTileSpecified(t))
- {
- // User has requested ICT -> Error
- throw new System.ArgumentException("Cannot use ICT " + "with filter 5x3 " + "in tile " + t);
- }
- else
- {
- setTileDef(t, "rct");
- }
- break;
-
- case CSJ2K.j2k.wavelet.FilterTypes_Fields.W9X7: // OK
- break;
-
- default:
- throw new System.ArgumentException("Default filter is " + "not JPEG 2000 part" + " I compliant");
-
- }
- }
- }
- }
-
- /// Get the filter type common to all component of a given tile. If the
- /// tile index is -1, it searches common filter type of default
- /// specifications.
- ///
- ///
- /// The tile index
- ///
- ///
- /// The analysis filters specifications
- ///
- ///
- /// The filter type common to all the components
- ///
- ///
- private int getFilterType(int t, AnWTFilterSpec wfs)
- {
- AnWTFilter[][] anfilt;
- int[] filtType = new int[nComp];
- for (int c = 0; c < nComp; c++)
- {
- if (t == -1)
- {
- anfilt = (AnWTFilter[][])wfs.getCompDef(c);
- }
- else
- {
- anfilt = (AnWTFilter[][])wfs.getTileCompVal(t, c);
- }
- filtType[c] = anfilt[0][0].FilterType;
- }
-
- // Check that all filters are the same one
- bool reject = false;
- for (int c = 1; c < nComp; c++)
- {
- if (filtType[c] != filtType[0])
- reject = true;
- }
- if (reject)
- {
- throw new System.ArgumentException("Can not use component" + " transformation when " + "components do not use " + "the same filters");
- }
- return filtType[0];
- }
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/image/input/ImgReader.cs b/CSJ2K/j2k/image/input/ImgReader.cs
deleted file mode 100644
index d6e27c98..00000000
--- a/CSJ2K/j2k/image/input/ImgReader.cs
+++ /dev/null
@@ -1,507 +0,0 @@
-/// CVS identifier:
-///
-/// $Id: ImgReader.java,v 1.10 2002/07/25 15:07:44 grosbois Exp $
-///
-/// Class: ImgReader
-///
-/// Description: Generic interface for image readers (from
-/// file or other resource)
-///
-///
-///
-/// COPYRIGHT:
-///
-/// This software module was originally developed by Raphaël Grosbois and
-/// Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-/// Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-/// Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-/// Centre France S.A) in the course of development of the JPEG2000
-/// standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-/// software module is an implementation of a part of the JPEG 2000
-/// Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-/// Systems AB and Canon Research Centre France S.A (collectively JJ2000
-/// Partners) agree not to assert against ISO/IEC and users of the JPEG
-/// 2000 Standard (Users) any of their rights under the copyright, not
-/// including other intellectual property rights, for this software module
-/// with respect to the usage by ISO/IEC and Users of this software module
-/// or modifications thereof for use in hardware or software products
-/// claiming conformance to the JPEG 2000 Standard. Those intending to use
-/// this software module in hardware or software products are advised that
-/// their use may infringe existing patents. The original developers of
-/// this software module, JJ2000 Partners and ISO/IEC assume no liability
-/// for use of this software module or modifications thereof. No license
-/// or right to this software module is granted for non JPEG 2000 Standard
-/// conforming products. JJ2000 Partners have full right to use this
-/// software module for his/her own purpose, assign or donate this
-/// software module to any third party and to inhibit third parties from
-/// using this software module for non JPEG 2000 Standard conforming
-/// products. This copyright notice must be included in all copies or
-/// derivative works of this software module.
-///
-/// Copyright (c) 1999/2000 JJ2000 Partners.
-///
-///
-namespace CSJ2K.j2k.image.input
-{
-
- /// This is the generic interface to be implemented by all image file (or other
- /// resource) readers for different image file formats.
- ///
- /// An ImgReader behaves as an ImgData object. Whenever image data is
- /// requested through the getInternCompData() or getCompData() methods, the
- /// image data will be read (if it is not buffered) and returned. Implementing
- /// classes should not buffer large amounts of data, so as to reduce memory
- /// usage.
- ///
- /// This class sets the image origin to (0,0). All default implementations
- /// of the methods assume this.
- ///
- /// This class provides default implementations of many methods. These
- /// default implementations assume that there is no tiling (i.e., the only tile
- /// is the entire image), that the image origin is (0,0) in the canvas system
- /// and that there is no component subsampling (all components are the same
- /// size), but they can be overloaded by the implementating class if need
- /// be.
- ///
- ///
- public abstract class ImgReader : BlkImgDataSrc
- {
- /// Returns the width of the current tile in pixels, assuming there is
- /// no-tiling. Since no-tiling is assumed this is the same as the width of
- /// the image. The value of w is returned.
- ///
- ///
- /// The total image width in pixels.
- ///
- ///
- virtual public int TileWidth
- {
- get
- {
- return w;
- }
-
- }
- /// Returns the overall height of the current tile in pixels, assuming
- /// there is no-tiling. Since no-tiling is assumed this is the same as the
- /// width of the image. The value of h is returned.
- ///
- ///
- /// The total image height in pixels.
- ///
- virtual public int TileHeight
- {
- get
- {
- return h;
- }
-
- }
- /// Returns the nominal tiles width
- virtual public int NomTileWidth
- {
- get
- {
- return w;
- }
-
- }
- /// Returns the nominal tiles height
- virtual public int NomTileHeight
- {
- get
- {
- return h;
- }
-
- }
- /// Returns the overall width of the image in pixels. This is the image's
- /// width without accounting for any component subsampling or tiling. The
- /// value of w is returned.
- ///
- ///
- /// The total image's width in pixels.
- ///
- ///
- virtual public int ImgWidth
- {
- get
- {
- return w;
- }
-
- }
- /// Returns the overall height of the image in pixels. This is the image's
- /// height without accounting for any component subsampling or tiling. The
- /// value of h is returned.
- ///
- ///
- /// The total image's height in pixels.
- ///
- ///
- virtual public int ImgHeight
- {
- get
- {
- return h;
- }
-
- }
- /// Returns the number of components in the image. The value of nc
- /// is returned.
- ///
- ///
- /// The number of components in the image.
- ///
- ///
- virtual public int NumComps
- {
- get
- {
- return nc;
- }
-
- }
- /// Returns the index of the current tile, relative to a standard scan-line
- /// order. This default implementations assumes no tiling, so 0 is always
- /// returned.
- ///
- ///
- /// The current tile's index (starts at 0).
- ///
- ///
- virtual public int TileIdx
- {
- get
- {
- return 0;
- }
-
- }
- /// Returns the horizontal tile partition offset in the reference grid
- virtual public int TilePartULX
- {
- get
- {
- return 0;
- }
-
- }
- /// Returns the vertical tile partition offset in the reference grid
- virtual public int TilePartULY
- {
- get
- {
- return 0;
- }
-
- }
- /// Returns the horizontal coordinate of the image origin, the top-left
- /// corner, in the canvas system, on the reference grid.
- ///
- ///
- /// The horizontal coordinate of the image origin in the canvas
- /// system, on the reference grid.
- ///
- ///
- virtual public int ImgULX
- {
- get
- {
- return 0;
- }
-
- }
- /// Returns the vertical coordinate of the image origin, the top-left
- /// corner, in the canvas system, on the reference grid.
- ///
- ///
- /// The vertical coordinate of the image origin in the canvas
- /// system, on the reference grid.
- ///
- ///
- virtual public int ImgULY
- {
- get
- {
- return 0;
- }
-
- }
-
- /// The width of the image
- protected internal int w;
-
- /// The height of the image
- protected internal int h;
-
- /// The number of components in the image
- protected internal int nc;
-
- /// Closes the underlying file or network connection from where the
- /// image data is being read.
- ///
- ///
- /// If an I/O error occurs.
- ///
- public abstract void close();
-
- /// Returns the component subsampling factor in the horizontal direction,
- /// for the specified component. This is, approximately, the ratio of
- /// dimensions between the reference grid and the component itself, see the
- /// 'ImgData' interface desription for details.
- ///
- ///
- /// The index of the component (between 0 and C-1)
- ///
- ///
- /// The horizontal subsampling factor of component 'c'
- ///
- ///
- ///
- ///
- ///
- public virtual int getCompSubsX(int c)
- {
- return 1;
- }
-
- /// Returns the component subsampling factor in the vertical direction, for
- /// the specified component. This is, approximately, the ratio of
- /// dimensions between the reference grid and the component itself, see the
- /// 'ImgData' interface desription for details.
- ///
- ///
- /// The index of the component (between 0 and C-1)
- ///
- ///
- /// The vertical subsampling factor of component 'c'
- ///
- ///
- ///
- ///
- ///
- public virtual int getCompSubsY(int c)
- {
- return 1;
- }
-
- /// Returns the width in pixels of the specified tile-component. This
- /// default implementation assumes no tiling and no component subsampling
- /// (i.e., all components, or components, have the same dimensions in
- /// pixels).
- ///
- ///
- /// Tile index
- ///
- ///
- /// The index of the component, from 0 to C-1.
- ///
- ///
- /// The width in pixels of component c in tilet.
- ///
- ///
- public virtual int getTileCompWidth(int t, int c)
- {
- if (t != 0)
- {
- throw new System.ApplicationException("Asking a tile-component width for a tile index" + " greater than 0 whereas there is only one tile");
- }
- return w;
- }
-
- /// Returns the height in pixels of the specified tile-component. This
- /// default implementation assumes no tiling and no component subsampling
- /// (i.e., all components, or components, have the same dimensions in
- /// pixels).
- ///
- ///
- /// The tile index
- ///
- ///
- /// The index of the component, from 0 to C-1.
- ///
- ///
- /// The height in pixels of component c in tile
- /// t.
- ///
- ///
- public virtual int getTileCompHeight(int t, int c)
- {
- if (t != 0)
- {
- throw new System.ApplicationException("Asking a tile-component width for a tile index" + " greater than 0 whereas there is only one tile");
- }
- return h;
- }
-
- /// Returns the width in pixels of the specified component in the overall
- /// image. This default implementation assumes no component, or component,
- /// subsampling (i.e. all components have the same dimensions in pixels).
- ///
- ///
- /// The index of the component, from 0 to C-1.
- ///
- ///
- /// The width in pixels of component c in the overall
- /// image.
- ///
- ///
- public virtual int getCompImgWidth(int c)
- {
- return w;
- }
-
- /// Returns the height in pixels of the specified component in the overall
- /// image. This default implementation assumes no component, or component,
- /// subsampling (i.e. all components have the same dimensions in pixels).
- ///
- ///
- /// The index of the component, from 0 to C-1.
- ///
- ///
- /// The height in pixels of component c in the overall
- /// image.
- ///
- ///
- public virtual int getCompImgHeight(int c)
- {
- return h;
- }
-
- /// Changes the current tile, given the new coordinates. An
- /// IllegalArgumentException is thrown if the coordinates do not correspond
- /// to a valid tile. This default implementation assumes no tiling so the
- /// only valid arguments are x=0, y=0.
- ///
- ///
- /// The horizontal coordinate of the tile.
- ///
- ///
- /// The vertical coordinate of the new tile.
- ///
- ///
- public virtual void setTile(int x, int y)
- {
- if (x != 0 || y != 0)
- {
- throw new System.ArgumentException();
- }
- }
-
- /// Advances to the next tile, in standard scan-line order (by rows then
- /// columns). A NoNextElementException is thrown if the current tile is the
- /// last one (i.e. there is no next tile). This default implementation
- /// assumes no tiling, so NoNextElementException() is always thrown.
- ///
- ///
- public virtual void nextTile()
- {
- throw new NoNextElementException();
- }
-
- /// Returns the coordinates of the current tile. This default
- /// implementation assumes no-tiling, so (0,0) is returned.
- ///
- ///
- /// If not null this object is used to return the information. If
- /// null a new one is created and returned.
- ///
- ///
- /// The current tile's coordinates.
- ///
- ///
- public virtual Coord getTile(Coord co)
- {
- if (co != null)
- {
- co.x = 0;
- co.y = 0;
- return co;
- }
- else
- {
- return new Coord(0, 0);
- }
- }
-
- /// Returns the horizontal coordinate of the upper-left corner of the
- /// specified component in the current tile.
- ///
- ///
- /// The component index.
- ///
- ///
- public virtual int getCompULX(int c)
- {
- return 0;
- }
-
- /// Returns the vertical coordinate of the upper-left corner of the
- /// specified component in the current tile.
- ///
- ///
- /// The component index.
- ///
- ///
- public virtual int getCompULY(int c)
- {
- return 0;
- }
-
- /// Returns the number of tiles in the horizontal and vertical
- /// directions. This default implementation assumes no tiling, so (1,1) is
- /// always returned.
- ///
- ///
- /// If not null this object is used to return the information. If
- /// null a new one is created and returned.
- ///
- ///
- /// The number of tiles in the horizontal (Coord.x) and vertical
- /// (Coord.y) directions.
- ///
- ///
- public virtual Coord getNumTiles(Coord co)
- {
- if (co != null)
- {
- co.x = 1;
- co.y = 1;
- return co;
- }
- else
- {
- return new Coord(1, 1);
- }
- }
-
- /// Returns the total number of tiles in the image. This default
- /// implementation assumes no tiling, so 1 is always returned.
- ///
- ///
- /// The total number of tiles in the image.
- ///
- ///
- public virtual int getNumTiles()
- {
- return 1;
- }
-
- /// Returns true if the data read was originally signed in the specified
- /// component, false if not.
- ///
- ///
- /// The index of the component, from 0 to C-1.
- ///
- ///
- /// true if the data was originally signed, false if not.
- ///
- ///
- public abstract bool isOrigSigned(int c);
- public abstract int getFixedPoint(int param1);
- public abstract CSJ2K.j2k.image.DataBlk getInternCompData(CSJ2K.j2k.image.DataBlk param1, int param2);
- public abstract int getNomRangeBits(int param1);
- public abstract CSJ2K.j2k.image.DataBlk getCompData(CSJ2K.j2k.image.DataBlk param1, int param2);
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/image/input/ImgReaderGDI.cs b/CSJ2K/j2k/image/input/ImgReaderGDI.cs
deleted file mode 100644
index 124898af..00000000
--- a/CSJ2K/j2k/image/input/ImgReaderGDI.cs
+++ /dev/null
@@ -1,400 +0,0 @@
-/*
-*
-* Class: ImgWriterGDI
-*
-* Description: Image writer for System.Drawing.GDI streams
-*
-* */
-
-using System;
-using System.Drawing;
-using System.Drawing.Imaging;
-using System.IO;
-
-namespace CSJ2K.j2k.image.input
-{
- public class ImgReaderGDI : ImgReader
- {
- /// The number of bits that determine the nominal dynamic range
- private int rb;
-
- /// Buffer for the components of each pixel(in the current block)
- private int[][] barr;
-
- /// Data block used only to store coordinates of the buffered blocks
- private DataBlkInt dbi = new DataBlkInt();
-
- /// Temporary DataBlkInt object (needed when encoder uses floating-point
- /// filters). This avoid allocating new DataBlk at each time
- ///
- private DataBlkInt intBlk;
-
- private Image image;
-
- public ImgReaderGDI(Image image)
- {
- if (image.PixelFormat != PixelFormat.Format24bppRgb)
- throw new ArgumentException("Only 24bpp RGB images are currently supported");
-
- this.image = image;
-
- w = image.Width;
- h = image.Height;
-
- nc = 3;
- rb = 8;
- }
-
- /// Closes the underlying file from where the image data is being read. No
- /// operations are possible after a call to this method.
- ///
- ///
- /// If an I/O error occurs.
- ///
- ///
- public override void close()
- {
- image.Dispose();
- image = null;
-
- barr = null;
- }
-
- /// Returns the number of bits corresponding to the nominal range of the
- /// data in the specified component. This is the value rb (range bits) that
- /// was specified in the constructor, which normally is 8 for non bilevel
- /// data, and 1 for bilevel data.
- ///
- /// If this number is b then the nominal range is between
- /// -2^(b-1) and 2^(b-1)-1, since unsigned data is level shifted to have a
- /// nominal avergae of 0.
- ///
- ///
- /// The index of the component.
- ///
- ///
- /// The number of bits corresponding to the nominal range of the
- /// data. For floating-point data this value is not applicable and the
- /// return value is undefined.
- ///
- ///
- public override int getNomRangeBits(int c)
- {
- // Check component index
- if (c < 0 || c > 2)
- throw new System.ArgumentException();
-
- return rb;
- }
-
- /// Returns the position of the fixed point in the specified component
- /// (i.e. the number of fractional bits), which is always 0 for this
- /// ImgReader.
- ///
- ///
- /// The index of the component.
- ///
- ///
- /// The position of the fixed-point (i.e. the number of fractional
- /// bits). Always 0 for this ImgReader.
- ///
- ///
- public override int getFixedPoint(int c)
- {
- // Check component index
- if (c < 0 || c > 2)
- throw new System.ArgumentException();
- return 0;
- }
-
- /// Returns, in the blk argument, the block of image data containing the
- /// specifed rectangular area, in the specified component. The data is
- /// returned, as a reference to the internal data, if any, instead of as a
- /// copy, therefore the returned data should not be modified.
- ///
- /// After being read the coefficients are level shifted by subtracting
- /// 2^(nominal bit range - 1)
- ///
- ///
The rectangular area to return is specified by the 'ulx', 'uly', 'w'
- /// and 'h' members of the 'blk' argument, relative to the current
- /// tile. These members are not modified by this method. The 'offset' and
- /// 'scanw' of the returned data can be arbitrary. See the 'DataBlk' class.
- ///
- ///
If the data array in blk is null, then a new one
- /// is created if necessary. The implementation of this interface may
- /// choose to return the same array or a new one, depending on what is more
- /// efficient. Therefore, the data array in blk prior to the
- /// method call should not be considered to contain the returned data, a
- /// new array may have been created. Instead, get the array from
- /// blk after the method has returned.
- ///
- ///
The returned data always has its 'progressive' attribute unset
- /// (i.e. false).
- ///
- ///
When an I/O exception is encountered the JJ2KExceptionHandler is
- /// used. The exception is passed to its handleException method. The action
- /// that is taken depends on the action that has been registered in
- /// JJ2KExceptionHandler. See JJ2KExceptionHandler for details.
- ///
- ///
This method implements buffering for the 3 components: When the
- /// first one is asked, all the 3 components are read and stored until they
- /// are needed.
- ///
- ///
- /// Its coordinates and dimensions specify the area to
- /// return. Some fields in this object are modified to return the data.
- ///
- ///
- /// The index of the component from which to get the data. Only 0,
- /// 1 and 3 are valid.
- ///
- ///
- /// The requested DataBlk
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- public override DataBlk getInternCompData(DataBlk blk, int c)
- {
- // Check component index
- if (c < 0 || c > 2)
- throw new System.ArgumentException();
-
- // Check type of block provided as an argument
- if (blk.DataType != DataBlk.TYPE_INT)
- {
- if (intBlk == null)
- intBlk = new DataBlkInt(blk.ulx, blk.uly, blk.w, blk.h);
- else
- {
- intBlk.ulx = blk.ulx;
- intBlk.uly = blk.uly;
- intBlk.w = blk.w;
- intBlk.h = blk.h;
- }
- blk = intBlk;
- }
-
- // If asking a component for the first time for this block, read all of the components
- if ((barr == null) || (dbi.ulx > blk.ulx) || (dbi.uly > blk.uly) || (dbi.ulx + dbi.w < blk.ulx + blk.w) || (dbi.uly + dbi.h < blk.uly + blk.h))
- {
- int i;
- int[] red, green, blue, alpha;
- int componentCount = (image.PixelFormat == PixelFormat.Format32bppArgb) ? 4 : 3;
-
- barr = new int[componentCount][];
-
- // Reset data arrays if needed
- if (barr[c] == null || barr[c].Length < blk.w * blk.h)
- {
- barr[c] = new int[blk.w * blk.h];
- }
- blk.Data = barr[c];
-
- i = (c + 1) % 3;
- if (barr[i] == null || barr[i].Length < blk.w * blk.h)
- {
- barr[i] = new int[blk.w * blk.h];
- }
- i = (c + 2) % 3;
- if (barr[i] == null || barr[i].Length < blk.w * blk.h)
- {
- barr[i] = new int[blk.w * blk.h];
- }
-
- if (componentCount == 4)
- {
- if (barr[3] == null || barr[3].Length < blk.w * blk.h)
- barr[3] = new int[blk.w * blk.h];
- }
-
- // set attributes of the DataBlk used for buffering
- dbi.ulx = blk.ulx;
- dbi.uly = blk.uly;
- dbi.w = blk.w;
- dbi.h = blk.h;
-
- red = barr[0];
- green = barr[1];
- blue = barr[2];
- alpha = (componentCount == 4) ? barr[3] : null;
-
- Bitmap bitmap = (Bitmap)image;
- BitmapData data = bitmap.LockBits(new Rectangle(blk.ulx, blk.uly, blk.w, blk.h), ImageLockMode.ReadOnly,
- (componentCount == 3) ? PixelFormat.Format24bppRgb : PixelFormat.Format32bppArgb);
- unsafe
- {
- byte* ptr = (byte*)data.Scan0.ToPointer();
-
- int k = 0;
- for (int j = 0; j < blk.w * blk.h; j++)
- {
- blue[k] = ((byte)*(ptr + 0) & 0xFF) - 128;
- green[k] = ((byte)*(ptr + 1) & 0xFF) - 128;
- red[k] = ((byte)*(ptr + 2) & 0xFF) - 128;
- if (componentCount == 4)
- alpha[k] = ((byte)*(ptr + 3) & 0xFF) - 128;
-
- ++k;
- ptr += 3;
- }
- }
- bitmap.UnlockBits(data);
-
- barr[0] = red;
- barr[1] = green;
- barr[2] = blue;
- if (componentCount == 4)
- barr[3] = alpha;
-
- // Set buffer attributes
- blk.Data = barr[c];
- blk.offset = 0;
- blk.scanw = blk.w;
- }
- else
- {
- //Asking for the 2nd or 3rd (or 4th) block component
- blk.Data = barr[c];
- blk.offset = (blk.ulx - dbi.ulx) * dbi.w + blk.ulx - dbi.ulx;
- blk.scanw = dbi.scanw;
- }
-
- // Turn off the progressive attribute
- blk.progressive = false;
- return blk;
- }
-
- /// Returns, in the blk argument, a block of image data containing the
- /// specifed rectangular area, in the specified component. The data is
- /// returned, as a copy of the internal data, therefore the returned data
- /// can be modified "in place".
- ///
- /// After being read the coefficients are level shifted by subtracting
- /// 2^(nominal bit range - 1)
- ///
- ///
The rectangular area to return is specified by the 'ulx', 'uly', 'w'
- /// and 'h' members of the 'blk' argument, relative to the current
- /// tile. These members are not modified by this method. The 'offset' of
- /// the returned data is 0, and the 'scanw' is the same as the block's
- /// width. See the 'DataBlk' class.
- ///
- ///
If the data array in 'blk' is 'null', then a new one is created. If
- /// the data array is not 'null' then it is reused, and it must be large
- /// enough to contain the block's data. Otherwise an 'ArrayStoreException'
- /// or an 'IndexOutOfBoundsException' is thrown by the Java system.
- ///
- ///
The returned data has its 'progressive' attribute unset
- /// (i.e. false).
- ///
- ///
When an I/O exception is encountered the JJ2KExceptionHandler is
- /// used. The exception is passed to its handleException method. The action
- /// that is taken depends on the action that has been registered in
- /// JJ2KExceptionHandler. See JJ2KExceptionHandler for details.
- ///
- ///
- /// Its coordinates and dimensions specify the area to
- /// return. If it contains a non-null data array, then it must have the
- /// correct dimensions. If it contains a null data array a new one is
- /// created. The fields in this object are modified to return the data.
- ///
- ///
- /// The index of the component from which to get the data. Only
- /// 0,1 and 2 are valid.
- ///
- ///
- /// The requested DataBlk
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- public override DataBlk getCompData(DataBlk blk, int c)
- {
- // NOTE: can not directly call getInterCompData since that returns
- // internally buffered data.
- int ulx, uly, w, h;
-
- // Check type of block provided as an argument
- if (blk.DataType != DataBlk.TYPE_INT)
- {
- DataBlkInt tmp = new DataBlkInt(blk.ulx, blk.uly, blk.w, blk.h);
- blk = tmp;
- }
-
- int[] bakarr = (int[])blk.Data;
- // Save requested block size
- ulx = blk.ulx;
- uly = blk.uly;
- w = blk.w;
- h = blk.h;
- // Force internal data buffer to be different from external
- blk.Data = null;
- getInternCompData(blk, c);
- // Copy the data
- if (bakarr == null)
- {
- bakarr = new int[w * h];
- }
- if (blk.offset == 0 && blk.scanw == w)
- {
- // Requested and returned block buffer are the same size
- // CONVERSION PROBLEM?
- Array.Copy((System.Array)blk.Data, 0, (System.Array)bakarr, 0, w * h);
- }
- else
- {
- // Requested and returned block are different
- for (int i = h - 1; i >= 0; i--)
- {
- // copy line by line
- // CONVERSION PROBLEM?
- Array.Copy((System.Array)blk.Data, blk.offset + i * blk.scanw, (System.Array)bakarr, i * w, w);
- }
- }
- blk.Data = bakarr;
- blk.offset = 0;
- blk.scanw = blk.w;
- return blk;
- }
-
- /// Returns true if the data read was originally signed in the specified
- /// component, false if not. This method always returns false since PPM
- /// data is always unsigned.
- ///
- ///
- /// The index of the component, from 0 to N-1.
- ///
- ///
- /// always false, since PPM data is always unsigned.
- ///
- ///
- public override bool isOrigSigned(int c)
- {
- // Check component index
- if (c < 0 || c > 2)
- throw new System.ArgumentException();
- return false;
- }
-
- /// Returns a string of information about the object, more than 1 line
- /// long. The information string includes information from the underlying
- /// RandomAccessFile (its toString() method is called in turn).
- ///
- ///
- /// A string of information about the object.
- ///
- ///
- public override System.String ToString()
- {
- return "ImgReaderGDI: WxH = " + w + "x" + h + ", Component = 0,1,2";
- }
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/image/input/ImgReaderPGM.cs b/CSJ2K/j2k/image/input/ImgReaderPGM.cs
deleted file mode 100644
index a7fec8ac..00000000
--- a/CSJ2K/j2k/image/input/ImgReaderPGM.cs
+++ /dev/null
@@ -1,519 +0,0 @@
-/*
-*
-* Class: ImageWriterRawPGM
-*
-* Description: Image writer for unsigned 8 bit data in
-* PGM files.
-*
-*
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-* */
-namespace CSJ2K.j2k.image.input
-{
-
- /// This class implements the ImgData interface for reading 8 bit unsigned data
- /// from a binary PGM file.
- ///
- /// After being read the coefficients are level shifted by subtracting
- /// 2^(nominal bit range-1)
- ///
- /// The TransferType (see ImgData) of this class is TYPE_INT.
- ///
- /// NOTE: This class is not thread safe, for reasons of internal buffering.
- ///
- ///
- ///
- ///
- ///
- public class ImgReaderPGM : ImgReader
- {
-
- /// DC offset value used when reading image
- public static int DC_OFFSET = 128;
-
- /// Where to read the data from
- //UPGRADE_TODO: Class 'java.io.RandomAccessFile' was converted to 'System.IO.FileStream' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaioRandomAccessFile'"
- private System.IO.FileStream in_Renamed;
-
- /// The offset of the raw pixel data in the PGM file
- private int offset;
-
- /// The number of bits that determine the nominal dynamic range
- private int rb;
-
- /// The line buffer.
- // This makes the class not thrad safe
- // (but it is not the only one making it so)
- private byte[] buf;
-
- /// Temporary DataBlkInt object (needed when encoder uses floating-point
- /// filters). This avoid allocating new DataBlk at each time
- ///
- private DataBlkInt intBlk;
-
- /// Creates a new PGM file reader from the specified file.
- ///
- ///
- /// The input file.
- ///
- ///
- /// If an error occurs while opening the file.
- ///
- ///
- public ImgReaderPGM(System.IO.FileInfo file) : this(SupportClass.RandomAccessFileSupport.CreateRandomAccessFile(file, "r"))
- {
- }
-
- /// Creates a new PGM file reader from the specified file name.
- ///
- ///
- /// The input file name.
- ///
- ///
- /// If an error occurs while opening the file.
- ///
- ///
- public ImgReaderPGM(System.String fname) : this(SupportClass.RandomAccessFileSupport.CreateRandomAccessFile(fname, "r"))
- {
- }
-
- /// Creates a new PGM file reader from the specified RandomAccessFile
- /// object. The file header is read to acquire the image size.
- ///
- ///
- /// From where to read the data
- ///
- ///
- /// if an EOF is read
- ///
- /// if an error occurs when opening the file
- ///
- ///
- //UPGRADE_TODO: Class 'java.io.RandomAccessFile' was converted to 'System.IO.FileStream' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaioRandomAccessFile'"
- public ImgReaderPGM(System.IO.FileStream in_Renamed)
- {
- this.in_Renamed = in_Renamed;
-
- confirmFileType();
- skipCommentAndWhiteSpace();
- this.w = readHeaderInt();
- skipCommentAndWhiteSpace();
- this.h = readHeaderInt();
- skipCommentAndWhiteSpace();
- /*Read the highest pixel value from header (not used)*/
- readHeaderInt();
- this.nc = 1;
- this.rb = 8;
- }
-
-
- /// Closes the underlying RandomAccessFile from where the image data is
- /// being read. No operations are possible after a call to this method.
- ///
- ///
- /// If an I/O error occurs.
- ///
- ///
- public override void close()
- {
- in_Renamed.Close();
- in_Renamed = null;
- }
-
- /// Returns the number of bits corresponding to the nominal range of the
- /// data in the specified component. This is the value rb (range bits) that
- /// was specified in the constructor, which normally is 8 for non bilevel
- /// data, and 1 for bilevel data.
- ///
- /// If this number is b then the nominal range is between
- /// -2^(b-1) and 2^(b-1)-1, since unsigned data is level shifted to have a
- /// nominal average of 0.
- ///
- ///
- /// The index of the component.
- ///
- ///
- /// The number of bits corresponding to the nominal range of the
- /// data. Fro floating-point data this value is not applicable and the
- /// return value is undefined.
- ///
- ///
- public override int getNomRangeBits(int c)
- {
- // Check component index
- if (c != 0)
- throw new System.ArgumentException();
-
- return rb;
- }
-
-
- /// Returns the position of the fixed point in the specified component
- /// (i.e. the number of fractional bits), which is always 0 for this
- /// ImgReader.
- ///
- ///
- /// The index of the component.
- ///
- ///
- /// The position of the fixed-point (i.e. the number of fractional
- /// bits). Always 0 for this ImgReader.
- ///
- ///
- public override int getFixedPoint(int c)
- {
- // Check component index
- if (c != 0)
- throw new System.ArgumentException();
- return 0;
- }
-
-
- /// Returns, in the blk argument, the block of image data containing the
- /// specifed rectangular area, in the specified component. The data is
- /// returned, as a reference to the internal data, if any, instead of as a
- /// copy, therefore the returned data should not be modified.
- ///
- /// After being read the coefficients are level shifted by subtracting
- /// 2^(nominal bit range - 1)
- ///
- ///
The rectangular area to return is specified by the 'ulx', 'uly', 'w'
- /// and 'h' members of the 'blk' argument, relative to the current
- /// tile. These members are not modified by this method. The 'offset' and
- /// 'scanw' of the returned data can be arbitrary. See the 'DataBlk' class.
- ///
- ///
If the data array in blk is null, then a new one
- /// is created if necessary. The implementation of this interface may
- /// choose to return the same array or a new one, depending on what is more
- /// efficient. Therefore, the data array in blk prior to the
- /// method call should not be considered to contain the returned data, a
- /// new array may have been created. Instead, get the array from
- /// blk after the method has returned.
- ///
- ///
The returned data always has its 'progressive' attribute unset
- /// (i.e. false).
- ///
- ///
When an I/O exception is encountered the JJ2KExceptionHandler is
- /// used. The exception is passed to its handleException method. The action
- /// that is taken depends on the action that has been registered in
- /// JJ2KExceptionHandler. See JJ2KExceptionHandler for details.
- ///
- ///
- /// Its coordinates and dimensions specify the area to
- /// return. Some fields in this object are modified to return the data.
- ///
- ///
- /// The index of the component from which to get the data. Only 0
- /// is valid.
- ///
- ///
- /// The requested DataBlk
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- public override DataBlk getInternCompData(DataBlk blk, int c)
- {
- int k, j, i, mi;
- int[] barr;
-
- // Check component index
- if (c != 0)
- throw new System.ArgumentException();
-
- // Check type of block provided as an argument
- if (blk.DataType != DataBlk.TYPE_INT)
- {
- if (intBlk == null)
- intBlk = new DataBlkInt(blk.ulx, blk.uly, blk.w, blk.h);
- else
- {
- intBlk.ulx = blk.ulx;
- intBlk.uly = blk.uly;
- intBlk.w = blk.w;
- intBlk.h = blk.h;
- }
- blk = intBlk;
- }
-
- // Get data array
- barr = (int[])blk.Data;
- if (barr == null || barr.Length < blk.w * blk.h)
- {
- barr = new int[blk.w * blk.h];
- blk.Data = barr;
- }
-
- // Check line buffer
- if (buf == null || buf.Length < blk.w)
- {
- buf = new byte[blk.w];
- }
-
- try
- {
- // Read line by line
- mi = blk.uly + blk.h;
- for (i = blk.uly; i < mi; i++)
- {
- // Reposition in input
- in_Renamed.Seek(offset + i * w + blk.ulx, System.IO.SeekOrigin.Begin);
- in_Renamed.Read(buf, 0, blk.w);
- for (k = (i - blk.uly) * blk.w + blk.w - 1, j = blk.w - 1; j >= 0; j--, k--)
- {
- barr[k] = (((int)buf[j]) & 0xFF) - DC_OFFSET;
- }
- }
- }
- catch (System.IO.IOException e)
- {
- JJ2KExceptionHandler.handleException(e);
- }
-
- // Turn off the progressive attribute
- blk.progressive = false;
- // Set buffer attributes
- blk.offset = 0;
- blk.scanw = blk.w;
- return blk;
- }
-
- /// Returns, in the blk argument, a block of image data containing the
- /// specifed rectangular area, in the specified component. The data is
- /// returned, as a copy of the internal data, therefore the returned data
- /// can be modified "in place".
- ///
- /// After being read the coefficients are level shifted by subtracting
- /// 2^(nominal bit range - 1)
- ///
- ///
The rectangular area to return is specified by the 'ulx', 'uly', 'w'
- /// and 'h' members of the 'blk' argument, relative to the current
- /// tile. These members are not modified by this method. The 'offset' of
- /// the returned data is 0, and the 'scanw' is the same as the block's
- /// width. See the 'DataBlk' class.
- ///
- ///
If the data array in 'blk' is 'null', then a new one is created. If
- /// the data array is not 'null' then it is reused, and it must be large
- /// enough to contain the block's data. Otherwise an 'ArrayStoreException'
- /// or an 'IndexOutOfBoundsException' is thrown by the Java system.
- ///
- ///
The returned data has its 'progressive' attribute unset
- /// (i.e. false).
- ///
- ///
This method just calls 'getInternCompData(blk, n)'.
- ///
- ///
When an I/O exception is encountered the JJ2KExceptionHandler is
- /// used. The exception is passed to its handleException method. The action
- /// that is taken depends on the action that has been registered in
- /// JJ2KExceptionHandler. See JJ2KExceptionHandler for details.
- ///
- ///
- /// Its coordinates and dimensions specify the area to
- /// return. If it contains a non-null data array, then it must have the
- /// correct dimensions. If it contains a null data array a new one is
- /// created. The fields in this object are modified to return the data.
- ///
- ///
- /// The index of the component from which to get the data. Only 0
- /// is valid.
- ///
- ///
- /// The requested DataBlk
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- public override DataBlk getCompData(DataBlk blk, int c)
- {
- return getInternCompData(blk, c);
- }
-
- /// Returns a byte read from the RandomAccessIO. The number of read byted
- /// are counted to keep track of the offset of the pixel data in the PGM
- /// file
- ///
- ///
- /// One byte read from the header of the PGM file.
- ///
- ///
- /// If an I/O error occurs.
- ///
- ///
- /// If an EOF is read
- ///
- ///
- private byte countedByteRead()
- {
- offset++;
- return (byte)in_Renamed.ReadByte();
- }
-
- /// Checks that the RandomAccessIO begins with 'P5'
- ///
- ///
- /// If an I/O error occurs.
- ///
- /// If an EOF is read
- ///
- ///
- private void confirmFileType()
- {
- byte[] type = new byte[] { 80, 53 }; // 'P5'
- int i;
- byte b;
-
- for (i = 0; i < 2; i++)
- {
- b = countedByteRead();
- if (b != type[i])
- {
- if (i == 1 && b == 50)
- {
- //i.e 'P2'
- throw new System.ArgumentException("JJ2000 does not support" + " ascii-PGM files. Use " + " raw-PGM file instead. ");
- }
- else
- {
- throw new System.ArgumentException("Not a raw-PGM file");
- }
- }
- }
- }
-
- /// Skips any line in the header starting with '#' and any space, tab, line
- /// feed or carriage return.
- ///
- ///
- /// If an I/O error occurs.
- ///
- /// if an EOF is read
- ///
- ///
- private void skipCommentAndWhiteSpace()
- {
-
- bool done = false;
- byte b;
-
- while (!done)
- {
- b = countedByteRead();
- if (b == 35)
- {
- // Comment start
- while (b != 10 && b != 13)
- {
- // Comment ends in end of line
- b = countedByteRead();
- }
- }
- else if (!(b == 9 || b == 10 || b == 13 || b == 32))
- {
- // If not whitespace
- done = true;
- }
- }
- // Put last valid byte in
- offset--;
- in_Renamed.Seek(offset, System.IO.SeekOrigin.Begin);
- }
-
-
- /// Returns an int read from the header of the PGM file.
- ///
- ///
- /// One int read from the header of the PGM file.
- ///
- ///
- /// If an I/O error occurs.
- ///
- /// If an EOF is read
- ///
- ///
- private int readHeaderInt()
- {
- int res = 0;
- byte b = 0;
-
- b = countedByteRead();
- while (b != 32 && b != 10 && b != 9 && b != 13)
- {
- // While not whitespace
- res = res * 10 + b - 48; // Covert ASCII to numerical value
- b = countedByteRead();
- }
- return res;
- }
-
- /// Returns true if the data read was originally signed in the specified
- /// component, false if not. This method returns always false since PGM
- /// data is always unsigned.
- ///
- ///
- /// The index of the component, from 0 to N-1.
- ///
- ///
- /// always false, since PGM data is always unsigned.
- ///
- ///
- public override bool isOrigSigned(int c)
- {
- // Check component index
- if (c != 0)
- throw new System.ArgumentException();
- return false;
- }
-
- /// Returns a string of information about the object, more than 1 line
- /// long. The information string includes information from the underlying
- /// RandomAccessIO (its toString() method is called in turn).
- ///
- ///
- /// A string of information about the object.
- ///
- ///
- public override System.String ToString()
- {
- //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Object.toString' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'"
- return "ImgReaderPGM: WxH = " + w + "x" + h + ", Component = 0" + "\nUnderlying RandomAccessIO:\n" + in_Renamed.ToString();
- }
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/image/input/ImgReaderPGX.cs b/CSJ2K/j2k/image/input/ImgReaderPGX.cs
deleted file mode 100644
index 0b209366..00000000
--- a/CSJ2K/j2k/image/input/ImgReaderPGX.cs
+++ /dev/null
@@ -1,667 +0,0 @@
-/*
-* CVS identifier:
-*
-* $Id: ImgReaderPGX.java,v 1.13 2002/07/25 15:08:13 grosbois Exp $
-*
-* Class: ImgReaderPGX
-*
-* Description: Image Reader for PGX files (custom file format
-* for VM3A)
-*
-*
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-* */
-using CSJ2K.j2k.io;
-namespace CSJ2K.j2k.image.input
-{
-
- /// This class extends the ImgReader abstract class for reading PGX files. PGX
- /// is a custom monochrome file format invented specifically to simplify the
- /// use of JPEG 2000 with images of different bit-depths in the range 1 to 31
- /// bits per pixel.
- ///
- /// The file consists of a one line text header followed by the data.
- ///
- ///
- /// Header: "PG"+ ws +<endianess>+ ws
- /// +[sign]+ws + <bit-depth>+"
- /// "+<width>+" "+<height>+'\n'
- ///
- /// where:
- ///
- /// - ws (white-spaces) is any combination of characters ' ' and
- /// '\t'.
- /// - endianess equals "LM" or "ML"(resp. little-endian or
- /// big-endian)
- /// - sign equals "+" or "-" (resp. unsigned or signed). If omited,
- /// values are supposed to be unsigned.
- /// - bit-depth that can be any number between 1 and 31.
- /// - width and height are the image dimensions (in
- /// pixels).
- ///
- ///
- /// Data: The image binary values appear one after the other (in raster
- /// order) immediately after the last header character ('\n') and are
- /// byte-aligned (they are packed into 1,2 or 4 bytes per sample, depending
- /// upon the bit-depth value).
- ///
- ///
- /// If the data is unisigned, level shifting is applied subtracting
- /// 2^(bitdepth - 1)
- ///
- /// Since it is not possible to know the input file byte-ordering before
- /// reading its header, this class can not be construct from a
- /// RandomAccessIO. So, the constructor has to open first the input file, to
- /// read only its header, and then it can create the appropriate
- /// BufferedRandomAccessFile (Big-Endian or Little-Endian byte-ordering).
- ///
- /// NOTE: This class is not thread safe, for reasons of internal
- /// buffering.
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- public class ImgReaderPGX : ImgReader, EndianType
- {
-
- /// The offset of the raw pixel data in the PGX file
- private int offset;
-
- /// The RandomAccessIO where to get datas from
- //UPGRADE_TODO: Class 'java.io.RandomAccessFile' was converted to 'System.IO.FileStream' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaioRandomAccessFile'"
- private System.IO.FileStream in_Renamed;
-
- /// The bit-depth of the input file (must be between 1 and 31)
- private int bitDepth;
-
- /// Whether the input datas are signed or not
- private bool isSigned;
-
-
- /// The pack length of one sample (in bytes, according to the output
- /// bit-depth
- ///
- private int packBytes;
-
- /// The byte ordering to use, as defined in EndianType
- private int byteOrder;
-
- /// The line buffer.
- // This makes the class not thrad safe
- // (but it is not the only one making it so)
- private byte[] buf;
-
- /// Temporary DataBlkInt object (needed when encoder uses floating-point
- /// filters). This avoid allocating new DataBlk at each time
- ///
- private DataBlkInt intBlk;
-
- /// Creates a new PGX file reader from the specified File object.
- ///
- ///
- /// The input file as File object.
- ///
- ///
- /// If an I/O error occurs.
- ///
- ///
- public ImgReaderPGX(System.IO.FileInfo in_Renamed)
- {
- System.String header;
-
- // Check if specified file exists
- bool tmpBool;
- if (System.IO.File.Exists(in_Renamed.FullName))
- tmpBool = true;
- else
- tmpBool = System.IO.Directory.Exists(in_Renamed.FullName);
- if (!tmpBool)
- {
- throw new System.ArgumentException("PGX file " + in_Renamed.Name + " does not exist");
- }
-
- //Opens the given file
- this.in_Renamed = SupportClass.RandomAccessFileSupport.CreateRandomAccessFile(in_Renamed, "r");
- try
- {
- System.IO.StreamReader in_reader = new System.IO.StreamReader(this.in_Renamed);
- //UPGRADE_ISSUE: Method 'java.io.RandomAccessFile.readLine' was not converted. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1000_javaioRandomAccessFilereadLine'"
- header = in_reader.ReadLine();
- }
- catch (System.IO.IOException)
- {
- throw new System.IO.IOException(in_Renamed.Name + " is not a PGX file");
- }
- if (header == null)
- {
- throw new System.IO.IOException(in_Renamed.Name + " is an empty file");
- }
- offset = (header.Length + 1);
-
- //Get informations from header
- SupportClass.Tokenizer st = new SupportClass.Tokenizer(header);
- try
- {
- int nTokens = st.Count;
-
- // Magic Number
- if (!(st.NextToken()).Equals("PG"))
- throw new System.IO.IOException(in_Renamed.Name + " is not a PGX file");
-
- // Endianess
- System.String tmp = st.NextToken();
- if (tmp.Equals("LM"))
- byteOrder = CSJ2K.j2k.io.EndianType_Fields.LITTLE_ENDIAN;
- else if (tmp.Equals("ML"))
- byteOrder = CSJ2K.j2k.io.EndianType_Fields.BIG_ENDIAN;
- else
- throw new System.IO.IOException(in_Renamed.Name + " is not a PGX file");
-
- // Unsigned/signed if present in the header
- if (nTokens == 6)
- {
- tmp = st.NextToken();
- if (tmp.Equals("+"))
- isSigned = false;
- else if (tmp.Equals("-"))
- isSigned = true;
- else
- throw new System.IO.IOException(in_Renamed.Name + " is not a PGX file");
- }
-
- // bit-depth, width, height
- try
- {
- bitDepth = (System.Int32.Parse(st.NextToken()));
- // bitDepth must be between 1 and 31
- if ((bitDepth <= 0) || (bitDepth > 31))
- throw new System.IO.IOException(in_Renamed.Name + " is not a valid PGX file");
-
- w = (System.Int32.Parse(st.NextToken()));
- h = (System.Int32.Parse(st.NextToken()));
- }
- catch (System.FormatException)
- {
- throw new System.IO.IOException(in_Renamed.Name + " is not a PGX file");
- }
- }
- catch (System.ArgumentOutOfRangeException)
- {
- throw new System.IO.IOException(in_Renamed.Name + " is not a PGX file");
- }
-
- // Number of component
- nc = 1;
-
- // Number of bytes per data
- if (bitDepth <= 8)
- packBytes = 1;
- else if (bitDepth <= 16)
- packBytes = 2;
- // <= 31
- else
- packBytes = 4;
- }
-
- /// Creates a new PGX file reader from the specified file name.
- ///
- ///
- /// The input file name.
- ///
- ///
- public ImgReaderPGX(System.String inName) : this(new System.IO.FileInfo(inName))
- {
- }
-
- /// Closes the underlying RandomAccessIO from where the image data is being
- /// read. No operations are possible after a call to this method.
- ///
- ///
- /// If an I/O error occurs.
- ///
- ///
- public override void close()
- {
- in_Renamed.Close();
- in_Renamed = null;
- buf = null;
- }
-
- /// Returns the number of bits corresponding to the nominal range of the
- /// data in the specified component. This is the value of bitDepth which is
- /// read in the PGX file header.
- ///
- /// If this number is b then the nominal range is between
- /// -2^(b-1) and 2^(b-1)-1, for originally signed or unsigned data
- /// (unsigned data is level shifted to have a nominal average of 0).
- ///
- ///
- /// The index of the component.
- ///
- ///
- /// The number of bits corresponding to the nominal range of the
- /// data.
- ///
- ///
- public override int getNomRangeBits(int c)
- {
- // Check component index
- if (c != 0)
- throw new System.ArgumentException();
-
- return bitDepth;
- }
-
- /// Returns the position of the fixed point in the specified component
- /// (i.e. the number of fractional bits), which is always 0 for this
- /// ImgReader.
- ///
- ///
- /// The index of the component.
- ///
- ///
- /// The position of the fixed-point (i.e. the number of fractional
- /// bits). Always 0 for this ImgReader.
- ///
- ///
- public override int getFixedPoint(int c)
- {
- // Check component index
- if (c != 0)
- throw new System.ArgumentException();
- return 0;
- }
-
- /// Returns, in the blk argument, the block of image data containing the
- /// specifed rectangular area, in the specified component. The data is
- /// returned, as a reference to the internal data, if any, instead of as a
- /// copy, therefore the returned data should not be modified.
- ///
- /// After being read the coefficients are level shifted by subtracting
- /// 2^(nominal bit range - 1)
- ///
- ///
The rectangular area to return is specified by the 'ulx', 'uly', 'w'
- /// and 'h' members of the 'blk' argument, relative to the current
- /// tile. These members are not modified by this method. The 'offset' and
- /// 'scanw' of the returned data can be arbitrary. See the 'DataBlk'
- /// class.
- ///
- /// If the data array in blk is null, then a new one
- /// is created if necessary. The implementation of this interface may
- /// choose to return the same array or a new one, depending on what is more
- /// efficient. Therefore, the data array in blk prior to the
- /// method call should not be considered to contain the returned data, a
- /// new array may have been created. Instead, get the array from
- /// blk after the method has returned.
- ///
- /// The returned data always has its 'progressive' attribute unset
- /// (i.e. false).
- ///
- /// When an I/O exception is encountered the JJ2KExceptionHandler is
- /// used. The exception is passed to its handleException method. The action
- /// that is taken depends on the action that has been registered in
- /// JJ2KExceptionHandler. See JJ2KExceptionHandler for details.
- ///
- ///
- /// Its coordinates and dimensions specify the area to
- /// return. Some fields in this object are modified to return the data.
- ///
- ///
- /// The index of the component from which to get the data. Only 0
- /// is valid.
- ///
- ///
- /// The requested DataBlk
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- public override DataBlk getInternCompData(DataBlk blk, int c)
- {
- int k, j, i, mi; // counters
- int levShift = 1 << (bitDepth - 1);
-
- // Check component index
- if (c != 0)
- throw new System.ArgumentException();
-
- // Check type of block provided as an argument
- if (blk.DataType != DataBlk.TYPE_INT)
- {
- if (intBlk == null)
- intBlk = new DataBlkInt(blk.ulx, blk.uly, blk.w, blk.h);
- else
- {
- intBlk.ulx = blk.ulx;
- intBlk.uly = blk.uly;
- intBlk.w = blk.w;
- intBlk.h = blk.h;
- }
- blk = intBlk;
- }
-
- // Get data array
- int[] barr = (int[])blk.Data;
- if (barr == null || barr.Length < blk.w * blk.h * packBytes)
- {
- barr = new int[blk.w * blk.h];
- blk.Data = barr;
- }
-
- int paddingLength = (32 - bitDepth);
- if (buf == null || buf.Length < packBytes * blk.w)
- {
- buf = new byte[packBytes * blk.w];
- }
- try
- {
- switch (packBytes)
- {
-
- // Switch between one of the 3 byte packet type
- case 1: // Samples packed into 1 byte
- // Read line by line
- mi = blk.uly + blk.h;
- if (isSigned)
- {
- for (i = blk.uly; i < mi; i++)
- {
- // Reposition in input
- in_Renamed.Seek(offset + i * w + blk.ulx, System.IO.SeekOrigin.Begin);
- in_Renamed.Read(buf, 0, blk.w);
- for (k = (i - blk.uly) * blk.w + blk.w - 1, j = blk.w - 1; j >= 0; k--)
- barr[k] = (((buf[j--] & 0xFF) << paddingLength) >> paddingLength);
- }
- }
- else
- {
- // Not signed
- for (i = blk.uly; i < mi; i++)
- {
- // Reposition in input
- in_Renamed.Seek(offset + i * w + blk.ulx, System.IO.SeekOrigin.Begin);
- in_Renamed.Read(buf, 0, blk.w);
- for (k = (i - blk.uly) * blk.w + blk.w - 1, j = blk.w - 1; j >= 0; k--)
- barr[k] = (SupportClass.URShift(((buf[j--] & 0xFF) << paddingLength), paddingLength)) - levShift;
- }
- }
- break;
-
-
- case 2: // Samples packed into 2 bytes
- // Read line by line
- mi = blk.uly + blk.h;
- if (isSigned)
- {
- for (i = blk.uly; i < mi; i++)
- {
- // Reposition in input
- in_Renamed.Seek(offset + 2 * (i * w + blk.ulx), System.IO.SeekOrigin.Begin);
- in_Renamed.Read(buf, 0, blk.w << 1);
- switch (byteOrder)
- {
-
- case CSJ2K.j2k.io.EndianType_Fields.LITTLE_ENDIAN:
- for (k = (i - blk.uly) * blk.w + blk.w - 1, j = (blk.w << 1) - 1; j >= 0; k--)
- {
- barr[k] = ((((buf[j--] & 0xFF) << 8) | (buf[j--] & 0xFF)) << paddingLength) >> paddingLength;
- }
- break;
-
- case CSJ2K.j2k.io.EndianType_Fields.BIG_ENDIAN:
- for (k = (i - blk.uly) * blk.w + blk.w - 1, j = (blk.w << 1) - 1; j >= 0; k--)
- {
- barr[k] = (((buf[j--] & 0xFF) | ((buf[j--] & 0xFF) << 8)) << paddingLength) >> paddingLength;
- }
- break;
-
- default:
- throw new System.ApplicationException("Internal JJ2000 bug");
-
- }
- }
- }
- else
- {
- // If not signed
- for (i = blk.uly; i < mi; i++)
- {
- // Reposition in input
- in_Renamed.Seek(offset + 2 * (i * w + blk.ulx), System.IO.SeekOrigin.Begin);
- in_Renamed.Read(buf, 0, blk.w << 1);
- switch (byteOrder)
- {
-
- case CSJ2K.j2k.io.EndianType_Fields.LITTLE_ENDIAN:
- for (k = (i - blk.uly) * blk.w + blk.w - 1, j = (blk.w << 1) - 1; j >= 0; k--)
- {
- barr[k] = (SupportClass.URShift(((((buf[j--] & 0xFF) << 8) | (buf[j--] & 0xFF)) << paddingLength), paddingLength)) - levShift;
- }
- break;
-
- case CSJ2K.j2k.io.EndianType_Fields.BIG_ENDIAN:
- for (k = (i - blk.uly) * blk.w + blk.w - 1, j = (blk.w << 1) - 1; j >= 0; k--)
- {
- barr[k] = (SupportClass.URShift((((buf[j--] & 0xFF) | ((buf[j--] & 0xFF) << 8)) << paddingLength), paddingLength)) - levShift;
- }
- break;
-
- default:
- throw new System.ApplicationException("Internal JJ2000 bug");
-
- }
- }
- }
- break;
-
-
- case 4: // Samples packed into 4 bytes
- // Read line by line
- mi = blk.uly + blk.h;
- if (isSigned)
- {
- for (i = blk.uly; i < mi; i++)
- {
- // Reposition in input
- in_Renamed.Seek(offset + 4 * (i * w + blk.ulx), System.IO.SeekOrigin.Begin);
- in_Renamed.Read(buf, 0, blk.w << 2);
- switch (byteOrder)
- {
-
- case CSJ2K.j2k.io.EndianType_Fields.LITTLE_ENDIAN:
- for (k = (i - blk.uly) * blk.w + blk.w - 1, j = (blk.w << 2) - 1; j >= 0; k--)
- {
- barr[k] = ((((buf[j--] & 0xFF) << 24) | ((buf[j--] & 0xFF) << 16) | ((buf[j--] & 0xFF) << 8) | (buf[j--] & 0xFF)) << paddingLength) >> paddingLength;
- }
- break;
-
- case CSJ2K.j2k.io.EndianType_Fields.BIG_ENDIAN:
- for (k = (i - blk.uly) * blk.w + blk.w - 1, j = (blk.w << 2) - 1; j >= 0; k--)
- {
- barr[k] = (((buf[j--] & 0xFF) | ((buf[j--] & 0xFF) << 8) | ((buf[j--] & 0xFF) << 16) | ((buf[j--] & 0xFF) << 24)) << paddingLength) >> paddingLength;
- }
- break;
-
- default:
- throw new System.ApplicationException("Internal JJ2000 bug");
-
- }
- }
- }
- else
- {
- for (i = blk.uly; i < mi; i++)
- {
- // Reposition in input
- in_Renamed.Seek(offset + 4 * (i * w + blk.ulx), System.IO.SeekOrigin.Begin);
- in_Renamed.Read(buf, 0, blk.w << 2);
- switch (byteOrder)
- {
-
- case CSJ2K.j2k.io.EndianType_Fields.LITTLE_ENDIAN:
- for (k = (i - blk.uly) * blk.w + blk.w - 1, j = (blk.w << 2) - 1; j >= 0; k--)
- {
- barr[k] = (SupportClass.URShift(((((buf[j--] & 0xFF) << 24) | ((buf[j--] & 0xFF) << 16) | ((buf[j--] & 0xFF) << 8) | (buf[j--] & 0xFF)) << paddingLength), paddingLength)) - levShift;
- }
- break;
-
- case CSJ2K.j2k.io.EndianType_Fields.BIG_ENDIAN:
- for (k = (i - blk.uly) * blk.w + blk.w - 1, j = (blk.w << 2) - 1; j >= 0; k--)
- {
- barr[k] = (SupportClass.URShift((((buf[j--] & 0xFF) | ((buf[j--] & 0xFF) << 8) | ((buf[j--] & 0xFF) << 16) | ((buf[j--] & 0xFF) << 24)) << paddingLength), paddingLength)) - levShift;
- }
- break;
-
- default:
- throw new System.ApplicationException("Internal JJ2000 bug");
-
- }
- }
- }
- break;
-
-
- default:
- throw new System.IO.IOException("PGX supports only bit-depth between" + " 1 and 31");
-
- }
- }
- catch (System.IO.IOException e)
- {
- JJ2KExceptionHandler.handleException(e);
- }
-
- // Turn off the progressive attribute
- blk.progressive = false;
- // Set buffer attributes
- blk.offset = 0;
- blk.scanw = blk.w;
- return blk;
- }
-
- /// Returns, in the blk argument, a block of image data containing the
- /// specifed rectangular area, in the specified component. The data is
- /// returned, as a copy of the internal data, therefore the returned data
- /// can be modified "in place".
- ///
- /// After being read the coefficients are level shifted by subtracting
- /// 2^(nominal bit range - 1)
- ///
- ///
The rectangular area to return is specified by the 'ulx', 'uly', 'w'
- /// and 'h' members of the 'blk' argument, relative to the current
- /// tile. These members are not modified by this method. The 'offset' of
- /// the returned data is 0, and the 'scanw' is the same as the block's
- /// width. See the 'DataBlk' class.
- ///
- /// If the data array in 'blk' is 'null', then a new one is created. If
- /// the data array is not 'null' then it is reused, and it must be large
- /// enough to contain the block's data. Otherwise an 'ArrayStoreException'
- /// or an 'IndexOutOfBoundsException' is thrown by the Java system.
- ///
- /// The returned data has its 'progressive' attribute unset
- /// (i.e. false).
- ///
- /// This method just calls 'getInternCompData(blk,c)'.
- ///
- /// When an I/O exception is encountered the JJ2KExceptionHandler is
- /// used. The exception is passed to its handleException method. The action
- /// that is taken depends on the action that has been registered in
- /// JJ2KExceptionHandler. See JJ2KExceptionHandler for details.
- ///
- ///
- /// Its coordinates and dimensions specify the area to
- /// return. If it contains a non-null data array, then it must have the
- /// correct dimensions. If it contains a null data array a new one is
- /// created. The fields in this object are modified to return the data.
- ///
- ///
- /// The index of the component from which to get the data. Only 0
- /// is valid.
- ///
- ///
- /// The requested DataBlk
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- public override DataBlk getCompData(DataBlk blk, int c)
- {
- return getInternCompData(blk, c);
- }
-
- /// Returns true if the data read was originally signed in the specified
- /// component, false if not.
- ///
- ///
- /// The index of the component, from 0 to N-1.
- ///
- ///
- /// true if the data was originally signed, false if not.
- ///
- ///
- public override bool isOrigSigned(int c)
- {
- // Check component index
- if (c != 0)
- throw new System.ArgumentException();
- return isSigned;
- }
-
- /// Returns a string of information about the object, more than 1 line
- /// long. The information string includes information from the underlying
- /// RandomAccessIO (its toString() method is called in turn).
- ///
- ///
- /// A string of information about the object.
- ///
- ///
- public override System.String ToString()
- {
- //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Object.toString' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'"
- return "ImgReaderPGX: WxH = " + w + "x" + h + ", Component = 0" + ", Bit-depth = " + bitDepth + ", signed = " + isSigned + "\nUnderlying RandomAccessIO:\n" + in_Renamed.ToString();
- }
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/image/input/ImgReaderPPM.cs b/CSJ2K/j2k/image/input/ImgReaderPPM.cs
deleted file mode 100644
index e3487b9e..00000000
--- a/CSJ2K/j2k/image/input/ImgReaderPPM.cs
+++ /dev/null
@@ -1,600 +0,0 @@
-/*
-*
-* Class: ImgWriterPPM
-*
-* Description: Image writer for unsigned 8 bit data in
-* PPM files.
-*
-*
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-* */
-using System;
-namespace CSJ2K.j2k.image.input
-{
-
- /// This class implements the ImgData interface for reading 8 bits unsigned
- /// data from a binary PPM file
- ///
- /// After being read the coefficients are level shifted by subtracting
- /// 2^(nominal bit range - 1)
- ///
- ///
The transfer type (see ImgData) of this class is TYPE_INT.
- ///
- ///
This class is buffered: the 3 input components(R,G,B) are read
- /// when the first one (R) is asked. The 2 others are stored until they are
- /// needed.
- ///
- ///
NOTE: This class is not thread safe, for reasons of internal buffering.
- ///
- ///
- ///
- ///
- ///
- public class ImgReaderPPM : ImgReader
- {
-
- /// DC offset value used when reading image
- public static int DC_OFFSET = 128;
-
- /// Where to read the data from
- //UPGRADE_TODO: Class 'java.io.RandomAccessFile' was converted to 'System.IO.FileStream' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaioRandomAccessFile'"
- private System.IO.FileStream in_Renamed;
-
- /// The offset of the raw pixel data in the PPM file
- private int offset;
-
- /// The number of bits that determine the nominal dynamic range
- private int rb;
-
- /// Buffer for the 3 components of each pixel(in the current block)
- private int[][] barr = new int[3][];
-
- /// Data block used only to store coordinates of the buffered blocks
- private DataBlkInt dbi = new DataBlkInt();
-
- /// The line buffer.
- // This makes the class not thread safe (but it is not the only one making
- // it so)
- private byte[] buf;
-
- /// Temporary DataBlkInt object (needed when encoder uses floating-point
- /// filters). This avoid allocating new DataBlk at each time
- ///
- private DataBlkInt intBlk;
-
- /// Creates a new PPM file reader from the specified file.
- ///
- ///
- /// The input file.
- ///
- ///
- /// If an error occurs while opening the file.
- ///
- ///
- public ImgReaderPPM(System.IO.FileInfo file) : this(SupportClass.RandomAccessFileSupport.CreateRandomAccessFile(file, "r"))
- {
- }
-
- /// Creates a new PPM file reader from the specified file name.
- ///
- ///
- /// The input file name.
- ///
- ///
- /// If an error occurs while opening the file.
- ///
- ///
- public ImgReaderPPM(System.String fname) : this(SupportClass.RandomAccessFileSupport.CreateRandomAccessFile(fname, "r"))
- {
- }
-
- /// Creates a new PPM file reader from the specified RandomAccessFile
- /// object. The file header is read to acquire the image size.
- ///
- ///
- /// From where to read the data
- ///
- ///
- /// if an EOF is read
- ///
- /// if an error occurs when opening the file
- ///
- ///
- //UPGRADE_TODO: Class 'java.io.RandomAccessFile' was converted to 'System.IO.FileStream' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaioRandomAccessFile'"
- private ImgReaderPPM(System.IO.FileStream in_Renamed)
- {
- this.in_Renamed = in_Renamed;
-
- confirmFileType();
- skipCommentAndWhiteSpace();
- w = readHeaderInt();
- skipCommentAndWhiteSpace();
- h = readHeaderInt();
- skipCommentAndWhiteSpace();
- /*Read the highest pixel value from header (not used)*/
- readHeaderInt();
- nc = 3;
- rb = 8;
- }
-
- /// Closes the underlying file from where the image data is being read. No
- /// operations are possible after a call to this method.
- ///
- ///
- /// If an I/O error occurs.
- ///
- ///
- public override void close()
- {
- in_Renamed.Close();
- in_Renamed = null;
- // Free memory
- barr[0] = null;
- barr[1] = null;
- barr[2] = null;
- buf = null;
- }
-
-
- /// Returns the number of bits corresponding to the nominal range of the
- /// data in the specified component. This is the value rb (range bits) that
- /// was specified in the constructor, which normally is 8 for non bilevel
- /// data, and 1 for bilevel data.
- ///
- /// If this number is b then the nominal range is between
- /// -2^(b-1) and 2^(b-1)-1, since unsigned data is level shifted to have a
- /// nominal avergae of 0.
- ///
- ///
- /// The index of the component.
- ///
- ///
- /// The number of bits corresponding to the nominal range of the
- /// data. For floating-point data this value is not applicable and the
- /// return value is undefined.
- ///
- ///
- public override int getNomRangeBits(int c)
- {
- // Check component index
- if (c < 0 || c > 2)
- throw new System.ArgumentException();
-
- return rb;
- }
-
- /// Returns the position of the fixed point in the specified component
- /// (i.e. the number of fractional bits), which is always 0 for this
- /// ImgReader.
- ///
- ///
- /// The index of the component.
- ///
- ///
- /// The position of the fixed-point (i.e. the number of fractional
- /// bits). Always 0 for this ImgReader.
- ///
- ///
- public override int getFixedPoint(int c)
- {
- // Check component index
- if (c < 0 || c > 2)
- throw new System.ArgumentException();
- return 0;
- }
-
-
- /// Returns, in the blk argument, the block of image data containing the
- /// specifed rectangular area, in the specified component. The data is
- /// returned, as a reference to the internal data, if any, instead of as a
- /// copy, therefore the returned data should not be modified.
- ///
- /// After being read the coefficients are level shifted by subtracting
- /// 2^(nominal bit range - 1)
- ///
- ///
The rectangular area to return is specified by the 'ulx', 'uly', 'w'
- /// and 'h' members of the 'blk' argument, relative to the current
- /// tile. These members are not modified by this method. The 'offset' and
- /// 'scanw' of the returned data can be arbitrary. See the 'DataBlk' class.
- ///
- ///
If the data array in blk is null, then a new one
- /// is created if necessary. The implementation of this interface may
- /// choose to return the same array or a new one, depending on what is more
- /// efficient. Therefore, the data array in blk prior to the
- /// method call should not be considered to contain the returned data, a
- /// new array may have been created. Instead, get the array from
- /// blk after the method has returned.
- ///
- ///
The returned data always has its 'progressive' attribute unset
- /// (i.e. false).
- ///
- ///
When an I/O exception is encountered the JJ2KExceptionHandler is
- /// used. The exception is passed to its handleException method. The action
- /// that is taken depends on the action that has been registered in
- /// JJ2KExceptionHandler. See JJ2KExceptionHandler for details.
- ///
- ///
This method implements buffering for the 3 components: When the
- /// first one is asked, all the 3 components are read and stored until they
- /// are needed.
- ///
- ///
- /// Its coordinates and dimensions specify the area to
- /// return. Some fields in this object are modified to return the data.
- ///
- ///
- /// The index of the component from which to get the data. Only 0,
- /// 1 and 3 are valid.
- ///
- ///
- /// The requested DataBlk
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- public override DataBlk getInternCompData(DataBlk blk, int c)
- {
- // Check component index
- if (c < 0 || c > 2)
- throw new System.ArgumentException();
-
- // Check type of block provided as an argument
- if (blk.DataType != DataBlk.TYPE_INT)
- {
- if (intBlk == null)
- intBlk = new DataBlkInt(blk.ulx, blk.uly, blk.w, blk.h);
- else
- {
- intBlk.ulx = blk.ulx;
- intBlk.uly = blk.uly;
- intBlk.w = blk.w;
- intBlk.h = blk.h;
- }
- blk = intBlk;
- }
-
- // If asking a component for the first time for this block, read the 3
- // components
- if ((barr[c] == null) || (dbi.ulx > blk.ulx) || (dbi.uly > blk.uly) || (dbi.ulx + dbi.w < blk.ulx + blk.w) || (dbi.uly + dbi.h < blk.uly + blk.h))
- {
- int k, j, i, mi;
- int[] red, green, blue;
-
- // Reset data arrays if needed
- if (barr[c] == null || barr[c].Length < blk.w * blk.h)
- {
- barr[c] = new int[blk.w * blk.h];
- }
- blk.Data = barr[c];
-
- i = (c + 1) % 3;
- if (barr[i] == null || barr[i].Length < blk.w * blk.h)
- {
- barr[i] = new int[blk.w * blk.h];
- }
- i = (c + 2) % 3;
- if (barr[i] == null || barr[i].Length < blk.w * blk.h)
- {
- barr[i] = new int[blk.w * blk.h];
- }
-
- // set attributes of the DataBlk used for buffering
- dbi.ulx = blk.ulx;
- dbi.uly = blk.uly;
- dbi.w = blk.w;
- dbi.h = blk.h;
-
- // Check line buffer
- if (buf == null || buf.Length < 3 * blk.w)
- {
- buf = new byte[3 * blk.w];
- }
-
- red = barr[0];
- green = barr[1];
- blue = barr[2];
-
- try
- {
- // Read line by line
- mi = blk.uly + blk.h;
- for (i = blk.uly; i < mi; i++)
- {
- // Reposition in input offset takes care of
- // header offset
- in_Renamed.Seek(offset + i * 3 * w + 3 * blk.ulx, System.IO.SeekOrigin.Begin);
- in_Renamed.Read(buf, 0, 3 * blk.w);
-
- for (k = (i - blk.uly) * blk.w + blk.w - 1, j = 3 * blk.w - 1; j >= 0; k--)
- {
- // Read every third sample
- blue[k] = (((byte)buf[j--]) & 0xFF) - DC_OFFSET;
- green[k] = (((byte)buf[j--]) & 0xFF) - DC_OFFSET;
- red[k] = (((byte)buf[j--]) & 0xFF) - DC_OFFSET;
- }
- }
- }
- catch (System.IO.IOException e)
- {
- JJ2KExceptionHandler.handleException(e);
- }
- barr[0] = red;
- barr[1] = green;
- barr[2] = blue;
-
- // Set buffer attributes
- blk.Data = barr[c];
- blk.offset = 0;
- blk.scanw = blk.w;
- }
- else
- {
- //Asking for the 2nd or 3rd block component
- blk.Data = barr[c];
- blk.offset = (blk.ulx - dbi.ulx) * dbi.w + blk.ulx - dbi.ulx;
- blk.scanw = dbi.scanw;
- }
-
- // Turn off the progressive attribute
- blk.progressive = false;
- return blk;
- }
-
- /// Returns, in the blk argument, a block of image data containing the
- /// specifed rectangular area, in the specified component. The data is
- /// returned, as a copy of the internal data, therefore the returned data
- /// can be modified "in place".
- ///
- /// After being read the coefficients are level shifted by subtracting
- /// 2^(nominal bit range - 1)
- ///
- ///
The rectangular area to return is specified by the 'ulx', 'uly', 'w'
- /// and 'h' members of the 'blk' argument, relative to the current
- /// tile. These members are not modified by this method. The 'offset' of
- /// the returned data is 0, and the 'scanw' is the same as the block's
- /// width. See the 'DataBlk' class.
- ///
- ///
If the data array in 'blk' is 'null', then a new one is created. If
- /// the data array is not 'null' then it is reused, and it must be large
- /// enough to contain the block's data. Otherwise an 'ArrayStoreException'
- /// or an 'IndexOutOfBoundsException' is thrown by the Java system.
- ///
- ///
The returned data has its 'progressive' attribute unset
- /// (i.e. false).
- ///
- ///
When an I/O exception is encountered the JJ2KExceptionHandler is
- /// used. The exception is passed to its handleException method. The action
- /// that is taken depends on the action that has been registered in
- /// JJ2KExceptionHandler. See JJ2KExceptionHandler for details.
- ///
- ///
- /// Its coordinates and dimensions specify the area to
- /// return. If it contains a non-null data array, then it must have the
- /// correct dimensions. If it contains a null data array a new one is
- /// created. The fields in this object are modified to return the data.
- ///
- ///
- /// The index of the component from which to get the data. Only
- /// 0,1 and 2 are valid.
- ///
- ///
- /// The requested DataBlk
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- public override DataBlk getCompData(DataBlk blk, int c)
- {
- // NOTE: can not directly call getInterCompData since that returns
- // internally buffered data.
- int ulx, uly, w, h;
-
- // Check type of block provided as an argument
- if (blk.DataType != DataBlk.TYPE_INT)
- {
- DataBlkInt tmp = new DataBlkInt(blk.ulx, blk.uly, blk.w, blk.h);
- blk = tmp;
- }
-
- int[] bakarr = (int[])blk.Data;
- // Save requested block size
- ulx = blk.ulx;
- uly = blk.uly;
- w = blk.w;
- h = blk.h;
- // Force internal data buffer to be different from external
- blk.Data = null;
- getInternCompData(blk, c);
- // Copy the data
- if (bakarr == null)
- {
- bakarr = new int[w * h];
- }
- if (blk.offset == 0 && blk.scanw == w)
- {
- // Requested and returned block buffer are the same size
- // CONVERSION PROBLEM?
- Array.Copy((System.Array)blk.Data, 0, (System.Array)bakarr, 0, w * h);
- }
- else
- {
- // Requested and returned block are different
- for (int i = h - 1; i >= 0; i--)
- {
- // copy line by line
- // CONVERSION PROBLEM?
- Array.Copy((System.Array)blk.Data, blk.offset + i * blk.scanw, (System.Array)bakarr, i * w, w);
- }
- }
- blk.Data = bakarr;
- blk.offset = 0;
- blk.scanw = blk.w;
- return blk;
- }
-
- /// Returns a byte read from the RandomAccessFile. The number of read byted
- /// are counted to keep track of the offset of the pixel data in the PPM
- /// file
- ///
- ///
- /// One byte read from the header of the PPM file.
- ///
- ///
- private byte countedByteRead()
- {
- offset++;
- return (byte)in_Renamed.ReadByte();
- }
-
- /// Checks that the file begins with 'P6'
- ///
- ///
- private void confirmFileType()
- {
- byte[] type = new byte[] { 80, 54 };
- int i;
- byte b;
-
- for (i = 0; i < 2; i++)
- {
- b = countedByteRead();
- if (b != type[i])
- {
- if (i == 1 && b == 51)
- {
- // i.e 'P3'
- throw new System.ArgumentException("JJ2000 does not support" + " ascii-PPM files. Use " + " raw-PPM file instead. ");
- }
- else
- {
- throw new System.ArgumentException("Not a raw-PPM file");
- }
- }
- }
- }
-
- /// Skips any line in the header starting with '#' and any space, tab, line
- /// feed or carriage return.
- ///
- ///
- private void skipCommentAndWhiteSpace()
- {
-
- bool done = false;
- byte b;
-
- while (!done)
- {
- b = countedByteRead();
- if (b == 35)
- {
- // Comment start
- while (b != 10 && b != 13)
- {
- // While not comment end (end-of-line)
- b = countedByteRead();
- }
- }
- else if (!(b == 9 || b == 10 || b == 13 || b == 32))
- {
- // If not whitespace
- done = true;
- }
- }
- // Put back last valid byte
- offset--;
- in_Renamed.Seek(offset, System.IO.SeekOrigin.Begin);
- }
-
- /// Returns an int read from the header of the PPM file.
- ///
- ///
- /// One int read from the header of the PPM file.
- ///
- ///
- private int readHeaderInt()
- {
- int res = 0;
- byte b = 0;
-
- b = countedByteRead();
- while (b != 32 && b != 10 && b != 9 && b != 13)
- {
- // While not whitespace
- res = res * 10 + b - 48; // Convert from ASCII to decimal
- b = countedByteRead();
- }
- return res;
- }
-
- /// Returns true if the data read was originally signed in the specified
- /// component, false if not. This method always returns false since PPM
- /// data is always unsigned.
- ///
- ///
- /// The index of the component, from 0 to N-1.
- ///
- ///
- /// always false, since PPM data is always unsigned.
- ///
- ///
- public override bool isOrigSigned(int c)
- {
- // Check component index
- if (c < 0 || c > 2)
- throw new System.ArgumentException();
- return false;
- }
-
- /// Returns a string of information about the object, more than 1 line
- /// long. The information string includes information from the underlying
- /// RandomAccessFile (its toString() method is called in turn).
- ///
- ///
- /// A string of information about the object.
- ///
- ///
- public override System.String ToString()
- {
- //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Object.toString' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'"
- return "ImgReaderPPM: WxH = " + w + "x" + h + ", Component = 0,1,2" + "\nUnderlying RandomAccessFile:\n" + in_Renamed.ToString();
- }
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/image/invcomptransf/InvCompTransf.cs b/CSJ2K/j2k/image/invcomptransf/InvCompTransf.cs
deleted file mode 100644
index 2a2bca98..00000000
--- a/CSJ2K/j2k/image/invcomptransf/InvCompTransf.cs
+++ /dev/null
@@ -1,809 +0,0 @@
-/*
-* CVS Identifier:
-*
-* $Id: InvCompTransf.java,v 1.19 2001/10/29 20:06:35 qtxjoas Exp $
-*
-* Class: InvCompTransf
-*
-* Description: Inverse Component transformations applied to tiles
-*
-*
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-* */
-using CSJ2K.j2k.decoder;
-using CSJ2K.j2k.util;
-using CSJ2K.j2k.wavelet.synthesis;
-using System;
-namespace CSJ2K.j2k.image.invcomptransf
-{
-
- /// This class apply inverse component transformations to the tiles depending
- /// on specification read from the codestream header. These transformations can
- /// be used to improve compression efficiency but are not related to colour
- /// transforms used to map colour values for display purposes. JPEG 2000 part I
- /// defines 2 component transformations: RCT (Reversible Component
- /// Transformation) and ICT (Irreversible Component Transformation).
- ///
- ///
- ///
- ///
- ///
- public class InvCompTransf : ImgDataAdapter, BlkImgDataSrc
- {
- /// Returns the parameters that are used in this class and implementing
- /// classes. It returns a 2D String array. Each of the 1D arrays is for a
- /// different option, and they have 4 elements. The first element is the
- /// option name, the second one is the synopsis, the third one is a long
- /// description of what the parameter is and the fourth is its default
- /// value. The synopsis or description may be 'null', in which case it is
- /// assumed that there is no synopsis or description of the option,
- /// respectively. Null may be returned if no options are supported.
- ///
- ///
- /// the options name, their synopsis and their explanation,
- /// or null if no options are supported.
- ///
- ///
- public static System.String[][] ParameterInfo
- {
- get
- {
- return pinfo;
- }
-
- }
- /// Returns true if this transform is reversible in current
- /// tile. Reversible component transformations are those which operation
- /// can be completely reversed without any loss of information (not even
- /// due to rounding).
- ///
- ///
- /// Reversibility of component transformation in current
- /// tile
- ///
- ///
- virtual public bool Reversible
- {
- get
- {
- switch (transfType)
- {
-
- case NONE:
- case INV_RCT:
- return true;
-
- case INV_ICT:
- return false;
-
- default:
- throw new System.ArgumentException("Non JPEG 2000 part I" + " component transformation");
-
- }
- }
-
- }
-
- /// Identifier for no component transformation. Value is 0.
- public const int NONE = 0;
-
- /// The prefix for inverse component transformation options: 'M'
- public const char OPT_PREFIX = 'M';
-
- /// The list of parameters that is accepted by the inverse
- /// component transformation module. They start with 'M'.
- ///
- //UPGRADE_NOTE: Final was removed from the declaration of 'pinfo'. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- private static readonly System.String[][] pinfo = null;
-
- /// Identifier for the Inverse Reversible Component Transformation
- /// (INV_RCT). Value is 1.
- ///
- public const int INV_RCT = 1;
-
- /// Identifier for the Inverse Irreversible Component
- /// Transformation (INV_ICT). Value is 2
- ///
- public const int INV_ICT = 2;
-
- /// The source of image data
- private BlkImgDataSrc src;
-
- /// The component transformations specifications
- private CompTransfSpec cts;
-
- /// The wavelet filter specifications
- private SynWTFilterSpec wfs;
-
- /// The type of the current component transformation JPEG 2000
- /// part I only support NONE, FORW_RCT and FORW_ICT types
- ///
- private int transfType = NONE;
-
- /// Buffer for each component of output data
- private int[][] outdata = new int[3][];
-
- /// Block used to request component 0
- private DataBlk block0;
-
- /// Block used to request component 1
- private DataBlk block1;
-
- /// Block used to request component 2
- private DataBlk block2;
-
- /// Data block used only to store coordinates and progressiveness
- /// of the buffered blocks
- ///
- private DataBlkInt dbi = new DataBlkInt();
-
- /// The bit-depths of un-transformed components
- private int[] utdepth;
-
- /// Flag indicating whether the decoder should skip the component
- /// transform
- ///
- private bool noCompTransf = false;
-
- /// Constructs a new ForwCompTransf object that operates on the
- /// specified source of image data.
- ///
- ///
- /// The source from where to get the data to be
- /// transformed
- ///
- ///
- /// The decoder specifications
- ///
- ///
- /// The bit depth of the un-transformed components
- ///
- ///
- /// The command line optinons of the decoder
- ///
- ///
- ///
- ///
- ///
- public InvCompTransf(BlkImgDataSrc imgSrc, DecoderSpecs decSpec, int[] utdepth, ParameterList pl) : base(imgSrc)
- {
- this.cts = decSpec.cts;
- this.wfs = decSpec.wfs;
- src = imgSrc;
- this.utdepth = utdepth;
- noCompTransf = !(pl.getBooleanParameter("comp_transf"));
- }
-
- /// Returns a string with a descriptive text of which inverse component
- /// transformation is used. This can be either "Inverse RCT" or "Inverse
- /// ICT" or "No component transformation" depending on the current tile.
- ///
- ///
- /// A descriptive string
- ///
- ///
- public override System.String ToString()
- {
- switch (transfType)
- {
-
- case INV_RCT:
- return "Inverse RCT";
-
- case INV_ICT:
- return "Inverse ICT";
-
- case NONE:
- return "No component transformation";
-
- default:
- throw new System.ArgumentException("Non JPEG 2000 part I" + " component transformation");
-
- }
- }
-
- /// Returns the position of the fixed point in the specified
- /// component. This is the position of the least significant integral
- /// (i.e. non-fractional) bit, which is equivalent to the number of
- /// fractional bits. For instance, for fixed-point values with 2 fractional
- /// bits, 2 is returned. For floating-point data this value does not apply
- /// and 0 should be returned. Position 0 is the position of the least
- /// significant bit in the data.
- ///
- /// This default implementation assumes that the number of fractional
- /// bits is not modified by the component mixer.
- ///
- ///
- /// The index of the component.
- ///
- ///
- /// The value of the fixed point position of the source since the
- /// color transform does not affect it.
- ///
- ///
- public virtual int getFixedPoint(int c)
- {
- return src.getFixedPoint(c);
- }
-
- /// Calculates the bitdepths of the transformed components, given the
- /// bitdepth of the un-transformed components and the component
- /// tranformation type.
- ///
- ///
- /// The bitdepth of each un-transformed component
- ///
- ///
- /// The type ID of the inverse component tranformation
- ///
- ///
- /// If not null the results are stored in this
- /// array, otherwise a new array is allocated and returned.
- ///
- ///
- /// The bitdepth of each transformed component.
- ///
- ///
- public static int[] calcMixedBitDepths(int[] utdepth, int ttype, int[] tdepth)
- {
-
- if (utdepth.Length < 3 && ttype != NONE)
- {
- throw new System.ArgumentException();
- }
-
- if (tdepth == null)
- {
- tdepth = new int[utdepth.Length];
- }
-
- switch (ttype)
- {
-
- case NONE:
- Array.Copy(utdepth, 0, tdepth, 0, utdepth.Length);
- break;
-
- case INV_RCT:
- if (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]+
- // 2^(utdepth[2])))-2+1
- // tdepth[1] = ceil(log2(2^(utdepth[0])+2^(utdepth[1])-1))+1
- // tdepth[2] = ceil(log2(2^(utdepth[1])+2^(utdepth[2])-1))+1
- // The MathUtil.log2(x) function calculates floor(log2(x)), so we
- // use 'MathUtil.log2(2*x-1)+1', which calculates ceil(log2(x))
- // for any x>=1, x integer.
- tdepth[0] = MathUtil.log2((1 << utdepth[0]) + (2 << utdepth[1]) + (1 << utdepth[2]) - 1) - 2 + 1;
- tdepth[1] = MathUtil.log2((1 << utdepth[2]) + (1 << utdepth[1]) - 1) + 1;
- tdepth[2] = MathUtil.log2((1 << utdepth[0]) + (1 << utdepth[1]) - 1) + 1;
- break;
-
- case INV_ICT:
- if (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))
- // for any x>=1, x integer.
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- tdepth[0] = MathUtil.log2((int)System.Math.Floor((1 << utdepth[0]) * 0.299072 + (1 << utdepth[1]) * 0.586914 + (1 << utdepth[2]) * 0.114014) - 1) + 1;
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- tdepth[1] = MathUtil.log2((int)System.Math.Floor((1 << utdepth[0]) * 0.168701 + (1 << utdepth[1]) * 0.331299 + (1 << utdepth[2]) * 0.5) - 1) + 1;
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- tdepth[2] = MathUtil.log2((int)System.Math.Floor((1 << utdepth[0]) * 0.5 + (1 << utdepth[1]) * 0.418701 + (1 << utdepth[2]) * 0.081299) - 1) + 1;
- break;
- }
-
- return tdepth;
- }
-
- /// Returns the number of bits, referred to as the "range bits",
- /// corresponding to the nominal range of the data in the specified
- /// component. If this number is b then for unsigned data the
- /// nominal range is between 0 and 2^b-1, and for signed data it is between
- /// -2^(b-1) and 2^(b-1)-1.
- ///
- ///
- /// The index of the component.
- ///
- ///
- /// The bitdepth of un-transformed component 'c'.
- ///
- ///
- public override int getNomRangeBits(int c)
- {
- return utdepth[c];
- }
-
- /// Apply inverse component transformation associated with the current
- /// tile. If no component transformation has been requested by the user,
- /// data are not modified.
- ///
- /// This method calls the getInternCompData() method, but respects the
- /// definitions of the getCompData() method defined in the BlkImgDataSrc
- /// interface.
- ///
- ///
- /// Determines the rectangular area to return, and the
- /// data is returned in this object.
- ///
- ///
- /// Index of the output component.
- ///
- ///
- /// The requested DataBlk
- ///
- ///
- ///
- ///
- ///
- public virtual DataBlk getCompData(DataBlk blk, int c)
- {
- // If requesting a component whose index is greater than 3 or there is
- // no transform return a copy of data (getInternCompData returns the
- // actual data in those cases)
- if (c >= 3 || transfType == NONE || noCompTransf)
- {
- return src.getCompData(blk, c);
- }
- else
- {
- // We can use getInternCompData (since data is a copy anyways)
- return getInternCompData(blk, c);
- }
- }
-
- /// Apply the inverse component transformation associated with the current
- /// tile. If no component transformation has been requested by the user,
- /// data are not modified. Else, appropriate method is called (invRCT or
- /// invICT).
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- /// Determines the rectangular area to return.
- ///
- ///
- /// Index of the output component.
- ///
- ///
- /// The requested DataBlk
- ///
- ///
- public virtual DataBlk getInternCompData(DataBlk blk, int c)
- {
- // if specified in the command line that no component transform should
- // be made, return original data
- if (noCompTransf)
- return src.getInternCompData(blk, c);
-
- switch (transfType)
- {
-
- case NONE:
- return src.getInternCompData(blk, c);
-
-
- case INV_RCT:
- return invRCT(blk, c);
-
- case INV_ICT:
- return invICT(blk, c);
-
- default:
- throw new System.ArgumentException("Non JPEG 2000 part I" + " component transformation");
-
- }
- }
-
- /// Apply inverse component transformation to obtain requested component
- /// from specified block of data. Whatever the type of requested DataBlk,
- /// it always returns a DataBlkInt.
- ///
- ///
- /// Determine the rectangular area to return
- ///
- ///
- /// The index of the requested component
- ///
- ///
- /// Data of requested component
- ///
- ///
- private DataBlk invRCT(DataBlk blk, int c)
- {
- // If the component number is three or greater, return original data
- if (c >= 3 && c < NumComps)
- {
- // Requesting a component whose index is greater than 3
- return src.getInternCompData(blk, c);
- }
- // If asking a component for the first time for this block,
- // do transform for the 3 components
- else if ((outdata[c] == null) || (dbi.ulx > blk.ulx) || (dbi.uly > blk.uly) || (dbi.ulx + dbi.w < blk.ulx + blk.w) || (dbi.uly + dbi.h < blk.uly + blk.h))
- {
- int k, k0, k1, k2, mink, i;
- int w = blk.w; //width of output block
- int h = blk.h; //height of ouput block
-
- //Reference to output block data array
- outdata[c] = (int[])blk.Data;
-
- //Create data array of blk if necessary
- if (outdata[c] == null || outdata[c].Length != h * w)
- {
- outdata[c] = new int[h * w];
- blk.Data = outdata[c];
- }
-
- outdata[(c + 1) % 3] = new int[outdata[c].Length];
- outdata[(c + 2) % 3] = new int[outdata[c].Length];
-
- if (block0 == null || block0.DataType != DataBlk.TYPE_INT)
- block0 = new DataBlkInt();
- if (block1 == null || block1.DataType != DataBlk.TYPE_INT)
- block1 = new DataBlkInt();
- if (block2 == null || block2.DataType != DataBlk.TYPE_INT)
- block2 = new DataBlkInt();
- block0.w = block1.w = block2.w = blk.w;
- block0.h = block1.h = block2.h = blk.h;
- block0.ulx = block1.ulx = block2.ulx = blk.ulx;
- block0.uly = block1.uly = block2.uly = blk.uly;
-
- int[] data0, data1, data2; // input data arrays
-
- // Fill in buffer blocks (to be read only)
- // Returned blocks may have different size and position
- block0 = (DataBlkInt)src.getInternCompData(block0, 0);
- data0 = (int[])block0.Data;
- block1 = (DataBlkInt)src.getInternCompData(block1, 1);
- data1 = (int[])block1.Data;
- block2 = (DataBlkInt)src.getInternCompData(block2, 2);
- data2 = (int[])block2.Data;
-
- // Set the progressiveness of the output data
- blk.progressive = block0.progressive || block1.progressive || block2.progressive;
- blk.offset = 0;
- blk.scanw = w;
-
- // set attributes of the DataBlk used for buffering
- dbi.progressive = blk.progressive;
- dbi.ulx = blk.ulx;
- dbi.uly = blk.uly;
- dbi.w = blk.w;
- dbi.h = blk.h;
-
- // Perform conversion
-
- // Initialize general indexes
- k = w * h - 1;
- k0 = block0.offset + (h - 1) * block0.scanw + w - 1;
- k1 = block1.offset + (h - 1) * block1.scanw + w - 1;
- k2 = block2.offset + (h - 1) * block2.scanw + w - 1;
-
- for (i = h - 1; i >= 0; i--)
- {
- for (mink = k - w; k > mink; k--, k0--, k1--, k2--)
- {
- outdata[1][k] = (data0[k0] - ((data1[k1] + data2[k2]) >> 2));
- outdata[0][k] = data2[k2] + outdata[1][k];
- outdata[2][k] = data1[k1] + outdata[1][k];
- }
- // Jump to beggining of previous line in input
- k0 -= (block0.scanw - w);
- k1 -= (block1.scanw - w);
- k2 -= (block2.scanw - w);
- }
- outdata[c] = null;
- }
- else if ((c >= 0) && (c < 3))
- {
- //Asking for the 2nd or 3rd block component
- blk.Data = outdata[c];
- blk.progressive = dbi.progressive;
- blk.offset = (blk.uly - dbi.uly) * dbi.w + blk.ulx - dbi.ulx;
- blk.scanw = dbi.w;
- outdata[c] = null;
- }
- else
- {
- // Requesting a non valid component index
- throw new System.ArgumentException();
- }
- return blk;
- }
-
- /// Apply inverse irreversible component transformation to obtain requested
- /// component from specified block of data. Whatever the type of requested
- /// DataBlk, it always returns a DataBlkFloat.
- ///
- ///
- /// Determine the rectangular area to return
- ///
- ///
- /// The index of the requested component
- ///
- ///
- /// Data of requested component
- ///
- ///
- private DataBlk invICT(DataBlk blk, int c)
- {
- if (c >= 3 && c < NumComps)
- {
- // Requesting a component whose index is greater than 3
- int k, k0, mink, i; // k1, k2 removed
- int w = blk.w; //width of output block
- int h = blk.h; //height of ouput block
-
- int[] out_data; // array of output data
-
- //Reference to output block data array
- out_data = (int[])blk.Data;
-
- //Create data array of blk if necessary
- if (out_data == null)
- {
- out_data = new int[h * w];
- blk.Data = out_data;
- }
-
- // Variables
- DataBlkFloat indb = new DataBlkFloat(blk.ulx, blk.uly, w, h);
- float[] indata; // input data array
-
- // Get the input data
- // (returned block may be larger than requested one)
- src.getInternCompData(indb, c);
- indata = (float[])indb.Data;
-
- // Copy the data converting from int to int
- k = w * h - 1;
- k0 = indb.offset + (h - 1) * indb.scanw + w - 1;
- for (i = h - 1; i >= 0; i--)
- {
- for (mink = k - w; k > mink; k--, k0--)
- {
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- out_data[k] = (int)(indata[k0]);
- }
- // Jump to beggining of previous line in input
- k0 -= (indb.scanw - w);
- }
-
- // Set the progressivity and offset
- blk.progressive = indb.progressive;
- blk.offset = 0;
- blk.scanw = w;
- }
- // If asking a component for the first time for this block,
- // do transform for the 3 components
- else if ((outdata[c] == null) || (dbi.ulx > blk.ulx) || (dbi.uly > blk.uly) || (dbi.ulx + dbi.w < blk.ulx + blk.w) || (dbi.uly + dbi.h < blk.uly + blk.h))
- {
- int k, k0, k1, k2, mink, i;
- int w = blk.w; //width of output block
- int h = blk.h; //height of ouput block
-
- //Reference to output block data array
- outdata[c] = (int[])blk.Data;
-
- //Create data array of blk if necessary
- if (outdata[c] == null || outdata[c].Length != w * h)
- {
- outdata[c] = new int[h * w];
- blk.Data = outdata[c];
- }
-
- outdata[(c + 1) % 3] = new int[outdata[c].Length];
- outdata[(c + 2) % 3] = new int[outdata[c].Length];
-
- if (block0 == null || block0.DataType != DataBlk.TYPE_FLOAT)
- block0 = new DataBlkFloat();
- if (block2 == null || block2.DataType != DataBlk.TYPE_FLOAT)
- block2 = new DataBlkFloat();
- if (block1 == null || block1.DataType != DataBlk.TYPE_FLOAT)
- block1 = new DataBlkFloat();
- block0.w = block2.w = block1.w = blk.w;
- block0.h = block2.h = block1.h = blk.h;
- block0.ulx = block2.ulx = block1.ulx = blk.ulx;
- block0.uly = block2.uly = block1.uly = blk.uly;
-
- float[] data0, data1, data2; // input data arrays
-
- // Fill in buffer blocks (to be read only)
- // Returned blocks may have different size and position
- block0 = (DataBlkFloat)src.getInternCompData(block0, 0);
- data0 = (float[])block0.Data;
- block2 = (DataBlkFloat)src.getInternCompData(block2, 1);
- data2 = (float[])block2.Data;
- block1 = (DataBlkFloat)src.getInternCompData(block1, 2);
- data1 = (float[])block1.Data;
-
- // Set the progressiveness of the output data
- blk.progressive = block0.progressive || block1.progressive || block2.progressive;
- blk.offset = 0;
- blk.scanw = w;
-
- // set attributes of the DataBlk used for buffering
- dbi.progressive = blk.progressive;
- dbi.ulx = blk.ulx;
- dbi.uly = blk.uly;
- dbi.w = blk.w;
- dbi.h = blk.h;
-
- //Perform conversion
-
- // Initialize general indexes
- k = w * h - 1;
- k0 = block0.offset + (h - 1) * block0.scanw + w - 1;
- k2 = block2.offset + (h - 1) * block2.scanw + w - 1;
- k1 = block1.offset + (h - 1) * block1.scanw + w - 1;
-
- for (i = h - 1; i >= 0; i--)
- {
- for (mink = k - w; k > mink; k--, k0--, k2--, k1--)
- {
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- outdata[0][k] = (int)(data0[k0] + 1.402f * data1[k1] + 0.5f);
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- outdata[1][k] = (int)(data0[k0] - 0.34413f * data2[k2] - 0.71414f * data1[k1] + 0.5f);
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- outdata[2][k] = (int)(data0[k0] + 1.772f * data2[k2] + 0.5f);
- }
- // Jump to beggining of previous line in input
- k0 -= (block0.scanw - w);
- k2 -= (block2.scanw - w);
- k1 -= (block1.scanw - w);
- }
- outdata[c] = null;
- }
- else if ((c >= 0) && (c <= 3))
- {
- //Asking for the 2nd or 3rd block component
- blk.Data = outdata[c];
- blk.progressive = dbi.progressive;
- blk.offset = (blk.uly - dbi.uly) * dbi.w + blk.ulx - dbi.ulx;
- blk.scanw = dbi.w;
- outdata[c] = null;
- }
- else
- {
- // Requesting a non valid component index
- throw new System.ArgumentException();
- }
- return blk;
- }
-
- /// Changes the current tile, given the new indexes. An
- /// IllegalArgumentException is thrown if the indexes do not
- /// correspond to a valid tile.
- ///
- /// This default implementation changes the tile in the source
- /// and re-initializes properly component transformation variables..
- ///
- ///
- /// The horizontal index of the tile.
- ///
- ///
- /// The vertical index of the new tile.
- ///
- ///
- ///
- public override void setTile(int x, int y)
- {
- src.setTile(x, y);
- tIdx = TileIdx; // index of the current tile
-
- // initializations
- if (((System.Int32)cts.getTileDef(tIdx)) == NONE)
- transfType = NONE;
- else
- {
- int nc = src.NumComps > 3 ? 3 : src.NumComps;
- int rev = 0;
- for (int c = 0; c < nc; c++)
- {
- rev += (wfs.isReversible(tIdx, c) ? 1 : 0);
- }
- if (rev == 3)
- {
- // All WT are reversible
- transfType = INV_RCT;
- }
- else if (rev == 0)
- {
- // All WT irreversible
- transfType = INV_ICT;
- }
- else
- {
- // Error
- throw new System.ArgumentException("Wavelet transformation and " + "component transformation" + " not coherent in tile" + tIdx);
- }
- }
- }
-
- /// Advances to the next tile, in standard scan-line order (by rows
- /// then columns). An NoNextElementException is thrown if the
- /// current tile is the last one (i.e. there is no next tile).
- ///
- /// This default implementation just advances to the next tile
- /// in the source and re-initializes properly component
- /// transformation variables.
- ///
- ///
- ///
- public override void nextTile()
- {
- src.nextTile();
- tIdx = TileIdx; // index of the current tile
-
- // initializations
- if (((System.Int32)cts.getTileDef(tIdx)) == NONE)
- transfType = NONE;
- else
- {
- int nc = src.NumComps > 3 ? 3 : src.NumComps;
- int rev = 0;
- for (int c = 0; c < nc; c++)
- {
- rev += (wfs.isReversible(tIdx, c) ? 1 : 0);
- }
- if (rev == 3)
- {
- // All WT are reversible
- transfType = INV_RCT;
- }
- else if (rev == 0)
- {
- // All WT irreversible
- transfType = INV_ICT;
- }
- else
- {
- // Error
- throw new System.ArgumentException("Wavelet transformation and " + "component transformation" + " not coherent in tile" + tIdx);
- }
- }
- }
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/image/output/ImgWriter.cs b/CSJ2K/j2k/image/output/ImgWriter.cs
deleted file mode 100644
index d79a7bd5..00000000
--- a/CSJ2K/j2k/image/output/ImgWriter.cs
+++ /dev/null
@@ -1,190 +0,0 @@
-/*
-* CVS identifier:
-*
-* $Id: ImgWriter.java,v 1.12 2001/09/14 09:13:11 grosbois Exp $
-*
-* Class: ImgWriter
-*
-* Description: Generic interface for all image writer
-* classes (to file or other resource)
-*
-*
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-* */
-using System;
-namespace CSJ2K.j2k.image.output
-{
-
- /// This is the generic interface to be implemented by all image file (or other
- /// resource) writers for different formats.
- ///
- /// Each object inheriting from this class should have a source ImgData
- /// object associated with it. The image data to write to the file is obtained
- /// from the associated ImgData object. In general this object would be
- /// specified at construction time.
- ///
- /// Depending on the actual type of file that is written a call to any
- /// write() or writeAll() method will write data from one component, several
- /// components or all components. For example, a PGM writer will write data
- /// from only one component (defined in the constructor) while a PPM writer
- /// will write 3 components (normally R,G,B).
- ///
- ///
- public abstract class ImgWriter
- {
-
- /// The defaukt height used when writing strip by strip in the 'write()'
- /// method. It is 64.
- ///
- public const int DEF_STRIP_HEIGHT = 64;
-
- /// The source ImagaData object, from where to get the image data
- protected internal BlkImgDataSrc src;
-
- /// The width of the image
- protected internal int w;
-
- /// The height of the image
- protected internal int h;
-
- /// Closes the underlying file or netwrok connection to where the data is
- /// written. The implementing class must write all buffered data before
- /// closing the file or resource. Any call to other methods of the class
- /// become illegal after a call to this one.
- ///
- ///
- /// If an I/O error occurs.
- ///
- ///
- public abstract void close();
-
- /// Writes all buffered data to the file or resource. If the implementing
- /// class does onot use buffering nothing should be done.
- ///
- ///
- /// If an I/O error occurs.
- ///
- ///
- public abstract void flush();
-
- /// Flushes the buffered data before the object is garbage collected. If an
- /// exception is thrown the object finalization is halted, but is otherwise
- /// ignored.
- ///
- ///
- /// If an I/O error occurs. It halts the
- /// finalization of the object, but is otherwise ignored.
- ///
- ///
- ///
- ///
- ///
- ~ImgWriter()
- {
- flush();
- }
-
- /// Writes the source's current tile to the output. The requests of data
- /// issued by the implementing class to the source ImgData object should be
- /// done by blocks or strips, in order to reduce memory usage.
- ///
- /// The implementing class should only write data that is not
- /// "progressive" (in other words that it is final), see DataBlk for
- /// details.
- ///
- ///
- /// If an I/O error occurs.
- ///
- ///
- ///
- ///
- ///
- public abstract void write();
-
- /// Writes the entire image or only specified tiles to the output. The
- /// implementation in this class calls the write() method for each tile
- /// starting with the upper-left one and proceding in standard scanline
- /// order. It changes the current tile of the source data.
- ///
- ///
- /// If an I/O error occurs.
- ///
- ///
- ///
- ///
- ///
- public virtual void writeAll()
- {
- // Find the list of tile to decode.
- Coord nT = src.getNumTiles(null);
-
- // Loop on vertical tiles
- for (int y = 0; y < nT.y; y++)
- {
- // Loop on horizontal tiles
- for (int x = 0; x < nT.x; x++)
- {
- src.setTile(x, y);
- write();
- } // End loop on horizontal tiles
- } // End loop on vertical tiles
- }
-
- /// Writes the data of the specified area to the file, coordinates are
- /// relative to the current tile of the source.
- ///
- /// The implementing class should only write data that is not
- /// "progressive" (in other words that is final), see DataBlk for
- /// details.
- ///
- ///
- /// The horizontal coordinate of the upper-left corner of the
- /// area to write, relative to the current tile.
- ///
- ///
- /// The vertical coordinate of the upper-left corner of the area
- /// to write, relative to the current tile.
- ///
- ///
- /// The width of the area to write.
- ///
- ///
- /// The height of the area to write.
- ///
- ///
- /// If an I/O error occurs.
- ///
- ///
- public abstract void write(int ulx, int uly, int w, int h);
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/image/output/ImgWriterPGM.cs b/CSJ2K/j2k/image/output/ImgWriterPGM.cs
deleted file mode 100644
index c30d7ff6..00000000
--- a/CSJ2K/j2k/image/output/ImgWriterPGM.cs
+++ /dev/null
@@ -1,415 +0,0 @@
-/*
-* CVS identifier:
-*
-* $Id: ImgWriterPGM.java,v 1.14 2002/07/19 14:13:38 grosbois Exp $
-*
-* Class: ImgWriterRawPGM
-*
-* Description: Image writer for unsigned 8 bit data in
-* PGM file format.
-*
-*
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-* */
-using CSJ2K.j2k.util;
-namespace CSJ2K.j2k.image.output
-{
-
- /// This class writes a component from an image in 8 bit unsigned data to a
- /// binary PGM file. The size of the image that is written to the file is the
- /// size of the component from which to get the data, not the size of the
- /// source image (they differ if there is some sub-sampling).
- ///
- /// Before writing, all coefficients are inversly level shifted and then
- /// "saturated" (they are limited to the nominal dynamic range).
Ex:
- /// if the nominal range is 0-255, the following algorithm is applied:
- /// if coeff<0, output=0
if coeff>255, output=255
else
- /// output=coeff
- ///
- /// The write() methods of an object of this class may not be called
- /// concurrently from different threads.
- ///
- /// NOTE: This class is not thread safe, for reasons of internal
- /// buffering.
- ///
- ///
- public class ImgWriterPGM : ImgWriter
- {
-
- /// Value used to inverse level shift
- private int levShift;
-
- /// Where to write the data
- //UPGRADE_TODO: Class 'java.io.RandomAccessFile' was converted to 'System.IO.FileStream' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaioRandomAccessFile'"
- private System.IO.FileStream out_Renamed;
-
- /// The index of the component from where to get the data
- private int c;
-
- /// The number of fractional bits in the source data
- private int fb;
-
- /// A DataBlk, just used to avoid allocating a new one each time
- /// it is needed
- ///
- private DataBlkInt db = new DataBlkInt();
-
- /// The offset of the raw pixel data in the PGM file
- private int offset;
-
- /// The line buffer.
- // This makes the class not thrad safe
- // (but it is not the only one making it so)
- private byte[] buf;
-
- /// Creates a new writer to the specified File object, to write data from
- /// the specified component.
- ///
- /// The size of the image that is written to the file is the size of the
- /// component from which to get the data, specified by b, not the size of
- /// the source image (they differ if there is some sub-sampling).
- ///
- ///
- /// The file where to write the data
- ///
- ///
- /// The source from where to get the image data to write.
- ///
- ///
- /// The index of the component from where to get the data.
- ///
- ///
- public ImgWriterPGM(System.IO.FileInfo out_Renamed, BlkImgDataSrc imgSrc, int c)
- {
- // Check that imgSrc is of the correct type
- // Check that the component index is valid
- if (c < 0 || c >= imgSrc.NumComps)
- {
- throw new System.ArgumentException("Invalid number of components");
- }
-
- // Check that imgSrc is of the correct type
- if (imgSrc.getNomRangeBits(c) > 8)
- {
- FacilityManager.getMsgLogger().println("Warning: Component " + c + " has nominal bitdepth " + imgSrc.getNomRangeBits(c) + ". Pixel values will be " + "down-shifted to fit bitdepth of 8 for PGM file", 8, 8);
- }
-
- // Initialize
- bool tmpBool;
- if (System.IO.File.Exists(out_Renamed.FullName))
- tmpBool = true;
- else
- tmpBool = System.IO.Directory.Exists(out_Renamed.FullName);
- bool tmpBool2;
- if (System.IO.File.Exists(out_Renamed.FullName))
- {
- System.IO.File.Delete(out_Renamed.FullName);
- tmpBool2 = true;
- }
- else if (System.IO.Directory.Exists(out_Renamed.FullName))
- {
- System.IO.Directory.Delete(out_Renamed.FullName);
- tmpBool2 = true;
- }
- else
- tmpBool2 = false;
- if (tmpBool && !tmpBool2)
- {
- throw new System.IO.IOException("Could not reset file");
- }
- this.out_Renamed = SupportClass.RandomAccessFileSupport.CreateRandomAccessFile(out_Renamed, "rw");
- src = imgSrc;
- this.c = c;
- w = imgSrc.ImgWidth;
- h = imgSrc.ImgHeight;
- fb = imgSrc.getFixedPoint(c);
- levShift = 1 << (imgSrc.getNomRangeBits(c) - 1);
-
- writeHeaderInfo();
- }
-
- /// Creates a new writer to the specified file, to write data from the
- /// specified component.
- ///
- /// The size of the image that is written to the file is the size of the
- /// component from which to get the data, specified by b, not the size of
- /// the source image (they differ if there is some sub-sampling).
- ///
- ///
- /// The name of the file where to write the data
- ///
- ///
- /// The source from where to get the image data to write.
- ///
- ///
- /// The index of the component from where to get the data.
- ///
- ///
- public ImgWriterPGM(System.String fname, BlkImgDataSrc imgSrc, int c) : this(new System.IO.FileInfo(fname), imgSrc, c)
- {
- }
-
- /// Closes the underlying file or netwrok connection to where the data is
- /// written. Any call to other methods of the class become illegal after a
- /// call to this one.
- ///
- ///
- /// If an I/O error occurs.
- ///
- ///
- public override void close()
- {
- int i;
- // Finish writing the file, writing 0s at the end if the data at end
- // has not been written.
- if (out_Renamed.Length != w * h + offset)
- {
- // Goto end of file
- out_Renamed.Seek(out_Renamed.Length, System.IO.SeekOrigin.Begin);
- // Fill with 0s
- for (i = offset + w * h - (int)out_Renamed.Length; i > 0; i--)
- {
- out_Renamed.WriteByte((System.Byte)0);
- }
- }
- out_Renamed.Close();
- src = null;
- out_Renamed = null;
- db = null;
- }
-
- /// Writes all buffered data to the file or resource.
- ///
- ///
- /// If an I/O error occurs.
- ///
- ///
- public override void flush()
- {
- // No flush needed here since we are using a RandomAccessFile Get rid
- // of line buffer (is this a good choice?)
- buf = null;
- }
-
- /// Writes the data of the specified area to the file, coordinates are
- /// relative to the current tile of the source. Before writing, the
- /// coefficients are limited to the nominal range.
- ///
- /// This method may not be called concurrently from different
- /// threads.
- ///
- /// If the data returned from the BlkImgDataSrc source is progressive,
- /// then it is requested over and over until it is not progressive
- /// anymore.
- ///
- ///
- /// The horizontal coordinate of the upper-left corner of the
- /// area to write, relative to the current tile.
- ///
- ///
- /// The vertical coordinate of the upper-left corner of the area
- /// to write, relative to the current tile.
- ///
- ///
- /// The width of the area to write.
- ///
- ///
- /// The height of the area to write.
- ///
- ///
- /// If an I/O error occurs.
- ///
- ///
- public override void write(int ulx, int uly, int w, int h)
- {
- int k, i, j;
- int fracbits = fb; // In local variable for faster access
- int tOffx, tOffy; // Active tile offset in the X and Y direction
-
- // Initialize db
- db.ulx = ulx;
- db.uly = uly;
- db.w = w;
- db.h = h;
- // Get the current active tile offset
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- tOffx = src.getCompULX(c) - (int)System.Math.Ceiling(src.ImgULX / (double)src.getCompSubsX(c));
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- tOffy = src.getCompULY(c) - (int)System.Math.Ceiling(src.ImgULY / (double)src.getCompSubsY(c));
- // Check the array size
- if (db.data_array != null && db.data_array.Length < w * h)
- {
- // A new one will be allocated by getInternCompData()
- db.data_array = null;
- }
- // Request the data and make sure it is not
- // progressive
- do
- {
- db = (DataBlkInt)src.getInternCompData(db, c);
- }
- while (db.progressive);
-
- // variables used during coeff saturation
- int tmp, maxVal = (1 << src.getNomRangeBits(c)) - 1;
-
- // If nominal bitdepth greater than 8, calculate down shift
- int downShift = src.getNomRangeBits(c) - 8;
- if (downShift < 0)
- {
- downShift = 0;
- }
-
- // Check line buffer
- if (buf == null || buf.Length < w)
- {
- buf = new byte[w]; // Expand buffer
- }
-
- // Write line by line
- for (i = 0; i < h; i++)
- {
- // Skip to beggining of line in file
- out_Renamed.Seek(this.offset + this.w * (uly + tOffy + i) + ulx + tOffx, System.IO.SeekOrigin.Begin);
- // Write all bytes in the line
- if (fracbits == 0)
- {
- for (k = db.offset + i * db.scanw + w - 1, j = w - 1; j >= 0; j--, k--)
- {
- tmp = db.data_array[k] + levShift;
- buf[j] = (byte)(((tmp < 0) ? 0 : ((tmp > maxVal) ? maxVal : tmp)) >> downShift);
- }
- }
- else
- {
- for (k = db.offset + i * db.scanw + w - 1, j = w - 1; j >= 0; j--, k--)
- {
- tmp = (db.data_array[k] >> fracbits) + levShift;
- buf[j] = (byte)(((tmp < 0) ? 0 : ((tmp > maxVal) ? maxVal : tmp)) >> downShift);
- }
- }
- out_Renamed.Write(buf, 0, w);
- }
- }
-
- /// Writes the source's current tile to the output. The requests of data
- /// issued to the source BlkImgDataSrc object are done by strips, in order
- /// to reduce memory usage.
- ///
- /// If the data returned from the BlkImgDataSrc source is progressive,
- /// then it is requested over and over until it is not progressive
- /// anymore.
- ///
- ///
- /// If an I/O error occurs.
- ///
- ///
- ///
- ///
- ///
- public override void write()
- {
- int i;
- int tIdx = src.TileIdx;
- int tw = src.getTileCompWidth(tIdx, c); // Tile width
- int th = src.getTileCompHeight(tIdx, c); // Tile height
- // Write in strips
- for (i = 0; i < th; i += DEF_STRIP_HEIGHT)
- {
- write(0, i, tw, (th - i < DEF_STRIP_HEIGHT) ? th - i : DEF_STRIP_HEIGHT);
- }
- }
-
- /// Writes the header info of the PGM file :
- ///
- /// P5
- /// width height
- /// 255
- ///
- ///
- /// If there is an IOException
- ///
- ///
- private void writeHeaderInfo()
- {
- byte[] byteVals;
- int i;
- System.String val;
-
- // write 'P5' to file
- out_Renamed.WriteByte((System.Byte)'P'); // 'P'
- out_Renamed.WriteByte((System.Byte)'5'); // '5'
- out_Renamed.WriteByte((System.Byte)'\n'); // newline
- offset = 3;
- // Write width in ASCII
- val = System.Convert.ToString(w);
- byteVals = System.Text.ASCIIEncoding.ASCII.GetBytes(val);
- for (i = 0; i < byteVals.Length; i++)
- {
- out_Renamed.WriteByte((byte)byteVals[i]);
- offset++;
- }
- out_Renamed.WriteByte((System.Byte)' '); // blank
- offset++;
- // Write height in ASCII
- val = System.Convert.ToString(h);
- byteVals = System.Text.ASCIIEncoding.ASCII.GetBytes(val);
- for (i = 0; i < byteVals.Length; i++)
- {
- out_Renamed.WriteByte((byte)byteVals[i]);
- offset++;
- }
- // Write maxval
- out_Renamed.WriteByte((System.Byte)'\n'); // newline
- out_Renamed.WriteByte((System.Byte)'2'); // '2'
- out_Renamed.WriteByte((System.Byte)'5'); // '5'
- out_Renamed.WriteByte((System.Byte)'5'); // '5'
- out_Renamed.WriteByte((System.Byte)'\n'); // newline
- offset += 5;
- }
-
- /// Returns a string of information about the object, more than 1 line
- /// long. The information string includes information from the underlying
- /// RandomAccessFile (its toString() method is called in turn).
- ///
- ///
- /// A string of information about the object.
- ///
- ///
- public override System.String ToString()
- {
- //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Object.toString' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'"
- return "ImgWriterPGM: WxH = " + w + "x" + h + ", Component=" + c + "\nUnderlying RandomAccessFile:\n" + out_Renamed.ToString();
- }
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/image/output/ImgWriterPGX.cs b/CSJ2K/j2k/image/output/ImgWriterPGX.cs
deleted file mode 100644
index 8423f122..00000000
--- a/CSJ2K/j2k/image/output/ImgWriterPGX.cs
+++ /dev/null
@@ -1,536 +0,0 @@
-/*
-* CVS identifier:
-*
-* $Id: ImgWriterPGX.java,v 1.14 2002/07/19 14:10:46 grosbois Exp $
-*
-* Class: ImgWriterPGX
-*
-* Description: Image Writer for PGX files (custom file format
-* for VM3A)
-*
-*
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-* */
-namespace CSJ2K.j2k.image.output
-{
-
- /// This class extends the ImgWriter abstract class for writing PGX files. PGX
- /// is a custom monochrome file format invented specifically to simplify the
- /// use of VM3A with images of different bit-depths in the range 1 to 31 bits
- /// per pixel.
- ///
- /// The file consists of a one line text header followed by the data.
- ///
- ///
- /// Header: "PG"+ ws +<endianess>+ ws
- /// +[sign]+ws + <bit-depth>+"
- /// "+<width>+" "+<height>+'\n'
- ///
- /// where:
- ///
- /// - ws (white-spaces) is any combination of characters ' ' and
- /// '\t'.
- /// - endianess equals "LM" or "ML"(resp. little-endian or
- /// big-endian)
- /// - sign equals "+" or "-" (resp. unsigned or signed). If omited,
- /// values are supposed to be unsigned.
- /// - bit-depth that can be any number between 1 and 31.
- /// - width and height are the image dimensions (in
- /// pixels).
- ///
- ///
- /// Data: The image binary values appear one after the other (in raster
- /// order) immediately after the last header character ('\n') and are
- /// byte-aligned (they are packed into 1,2 or 4 bytes per sample, depending
- /// upon the bit-depth value).
- ///
- ///
- /// If the data is unsigned, level shifting is applied adding 2^(bit depth
- /// - 1)
- ///
- /// NOTE: This class is not thread safe, for reasons of internal
- /// buffering.
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- public class ImgWriterPGX : ImgWriter
- {
-
- /// Used during saturation (2^bitdepth-1 if unsigned, 2^(bitdepth-1)-1 if
- /// signed)
- ///
- internal int maxVal;
-
- /// Used during saturation (0 if unsigned, -2^(bitdepth-1) if signed)
- internal int minVal;
-
- /// Used with level-shiting
- internal int levShift;
-
- /// Whether the data must be signed when writing or not. In the latter
- /// case inverse level shifting must be applied
- ///
- internal bool isSigned;
-
- /// The bit-depth of the input file (must be between 1 and 31)
- private int bitDepth;
-
- /// Where to write the data
- //UPGRADE_TODO: Class 'java.io.RandomAccessFile' was converted to 'System.IO.FileStream' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaioRandomAccessFile'"
- private System.IO.FileStream out_Renamed;
-
- /// The offset of the raw pixel data in the PGX file
- private int offset;
-
- /// A DataBlk, just used to avoid allocating a new one each time it is
- /// needed
- ///
- private DataBlkInt db = new DataBlkInt();
-
- /// The number of fractional bits in the source data
- private int fb;
-
- /// The index of the component from where to get the data
- private int c;
-
- /// The pack length of one sample (in bytes, according to the output
- /// bit-depth
- ///
- private int packBytes;
-
- /// The line buffer.
- // This makes the class not thrad safe
- // (but it is not the only one making it so)
- private byte[] buf;
-
- /// Creates a new writer to the specified File object, to write data from
- /// the specified component.
- ///
- /// The size of the image that is written to the file is the size of the
- /// component from which to get the data, specified by b, not the size of
- /// the source image (they differ if there is some sub-sampling).
- ///
- /// All the header informations are given by the BlkImgDataSrc source
- /// (component width, component height, bit-depth) and sign flag, which are
- /// provided to the constructor. The endianness is always big-endian (MSB
- /// first).
- ///
- ///
- /// The file where to write the data
- ///
- ///
- /// The source from where to get the image data to write.
- ///
- ///
- /// The index of the component from where to get the data.
- ///
- ///
- /// Whether the datas are signed or not (needed only when
- /// writing header).
- ///
- ///
- ///
- ///
- ///
- public ImgWriterPGX(System.IO.FileInfo out_Renamed, BlkImgDataSrc imgSrc, int c, bool isSigned)
- {
- //Initialize
- this.c = c;
- bool tmpBool;
- if (System.IO.File.Exists(out_Renamed.FullName))
- tmpBool = true;
- else
- tmpBool = System.IO.Directory.Exists(out_Renamed.FullName);
- bool tmpBool2;
- if (System.IO.File.Exists(out_Renamed.FullName))
- {
- System.IO.File.Delete(out_Renamed.FullName);
- tmpBool2 = true;
- }
- else if (System.IO.Directory.Exists(out_Renamed.FullName))
- {
- System.IO.Directory.Delete(out_Renamed.FullName);
- tmpBool2 = true;
- }
- else
- tmpBool2 = false;
- if (tmpBool && !tmpBool2)
- {
- throw new System.IO.IOException("Could not reset file");
- }
- this.out_Renamed = SupportClass.RandomAccessFileSupport.CreateRandomAccessFile(out_Renamed, "rw");
- this.isSigned = isSigned;
- src = imgSrc;
- w = src.ImgWidth;
- h = src.ImgHeight;
- fb = imgSrc.getFixedPoint(c);
-
- bitDepth = src.getNomRangeBits(this.c);
- if ((bitDepth <= 0) || (bitDepth > 31))
- {
- throw new System.IO.IOException("PGX supports only bit-depth between " + "1 and 31");
- }
- if (bitDepth <= 8)
- {
- packBytes = 1;
- }
- else if (bitDepth <= 16)
- {
- packBytes = 2;
- }
- else
- {
- // <= 31
- packBytes = 4;
- }
-
- // Writes PGX header
- System.String tmpString = "PG " + "ML " + ((this.isSigned) ? "- " : "+ ") + bitDepth + " " + w + " " + h + "\n"; // component height
-
- byte[] tmpByte = System.Text.ASCIIEncoding.ASCII.GetBytes(tmpString);
- for (int i = 0; i < tmpByte.Length; i++)
- {
- this.out_Renamed.WriteByte((byte)tmpByte[i]);
- }
-
- offset = tmpByte.Length;
- maxVal = this.isSigned ? ((1 << (src.getNomRangeBits(c) - 1)) - 1) : ((1 << src.getNomRangeBits(c)) - 1);
- minVal = this.isSigned ? ((-1) * (1 << (src.getNomRangeBits(c) - 1))) : 0;
-
- levShift = (this.isSigned) ? 0 : 1 << (src.getNomRangeBits(c) - 1);
- }
-
- /// Creates a new writer to the specified file, to write data from the
- /// specified component.
- ///
- /// The size of the image that is written to the file is the size of the
- /// component from which to get the data, specified by b, not the size of
- /// the source image (they differ if there is some sub-sampling).
- ///
- /// All header information is given by the BlkImgDataSrc source
- /// (component width, component height, bit-depth) and sign flag, which are
- /// provided to the constructor. The endianness is always big-endian (MSB
- /// first).
- ///
- ///
- /// The name of the file where to write the data
- ///
- ///
- /// The source from where to get the image data to write.
- ///
- ///
- /// The index of the component from where to get the data.
- ///
- ///
- /// Whether the datas are signed or not (needed only when
- /// writing header).
- ///
- ///
- ///
- ///
- ///
- public ImgWriterPGX(System.String fname, BlkImgDataSrc imgSrc, int c, bool isSigned) : this(new System.IO.FileInfo(fname), imgSrc, c, isSigned)
- {
- }
-
- /// Closes the underlying file or netwrok connection to where the data is
- /// written. Any call to other methods of the class become illegal after a
- /// call to this one.
- ///
- ///
- /// If an I/O error occurs.
- ///
- ///
- public override void close()
- {
- int i;
- // Finish writing the file, writing 0s at the end if the data at end
- // has not been written.
- if (out_Renamed.Length != w * h * packBytes + offset)
- {
- // Goto end of file
- out_Renamed.Seek(out_Renamed.Length, System.IO.SeekOrigin.Begin);
- // Fill with 0s
- for (i = offset + w * h * packBytes - (int)out_Renamed.Length; i > 0; i--)
- {
- out_Renamed.WriteByte((System.Byte)0);
- }
- }
- out_Renamed.Close();
- src = null;
- out_Renamed = null;
- db = null;
- }
-
- /// Writes all buffered data to the file or resource.
- ///
- ///
- /// If an I/O error occurs.
- ///
- ///
- public override void flush()
- {
- // No flush is needed since we use RandomAccessFile
- // Get rid of line buffer (is this a good choice?)
- buf = null;
- }
-
- /// Writes the data of the specified area to the file, coordinates are
- /// relative to the current tile of the source. Before writing, the
- /// coefficients are limited to the nominal range and packed into 1,2 or 4
- /// bytes (according to the bit-depth).
- ///
- /// If the data is unisigned, level shifting is applied adding 2^(bit
- /// depth - 1)
- ///
- /// This method may not be called concurrently from different
- /// threads.
- ///
- /// If the data returned from the BlkImgDataSrc source is progressive,
- /// then it is requested over and over until it is not progressive
- /// anymore.
- ///
- ///
- /// The horizontal coordinate of the upper-left corner of the
- /// area to write, relative to the current tile.
- ///
- ///
- /// The vertical coordinate of the upper-left corner of the area
- /// to write, relative to the current tile.
- ///
- ///
- /// The width of the area to write.
- ///
- ///
- /// The height of the area to write.
- ///
- ///
- /// If an I/O error occurs.
- ///
- ///
- public override void write(int ulx, int uly, int w, int h)
- {
- int k, i, j;
- int fracbits = fb; // In local variable for faster access
- int tOffx, tOffy; // Active tile offset in the X and Y direction
-
- // Initialize db
- db.ulx = ulx;
- db.uly = uly;
- db.w = w;
- db.h = h;
- // Get the current active tile offset
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- tOffx = src.getCompULX(c) - (int)System.Math.Ceiling(src.ImgULX / (double)src.getCompSubsX(c));
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- tOffy = src.getCompULY(c) - (int)System.Math.Ceiling(src.ImgULY / (double)src.getCompSubsY(c));
- // Check the array size
- if (db.data_array != null && db.data_array.Length < w * h)
- {
- // A new one will be allocated by getInternCompData()
- db.data_array = null;
- }
- // Request the data and make sure it is not
- // progressive
- do
- {
- db = (DataBlkInt)src.getInternCompData(db, c);
- }
- while (db.progressive);
-
- int tmp;
-
-
- // Check line buffer
- if (buf == null || buf.Length < packBytes * w)
- {
- buf = new byte[packBytes * w]; // Expand buffer
- }
-
- switch (packBytes)
- {
-
-
- case 1: // Samples packed into 1 byte
- // Write line by line
- for (i = 0; i < h; i++)
- {
- // Skip to beggining of line in file
- out_Renamed.Seek(offset + this.w * (uly + tOffy + i) + ulx + tOffx, System.IO.SeekOrigin.Begin);
- // Write all bytes in the line
- if (fracbits == 0)
- {
- for (k = db.offset + i * db.scanw + w - 1, j = w - 1; j >= 0; k--)
- {
- tmp = db.data_array[k] + levShift;
- buf[j--] = (byte)((tmp < minVal) ? minVal : ((tmp > maxVal) ? maxVal : tmp));
- }
- }
- else
- {
- for (k = db.offset + i * db.scanw + w - 1, j = w - 1; j >= 0; k--)
- {
- tmp = (SupportClass.URShift(db.data_array[k], fracbits)) + levShift;
- buf[j--] = (byte)((tmp < minVal) ? minVal : ((tmp > maxVal) ? maxVal : tmp));
- }
- }
- out_Renamed.Write(buf, 0, w);
- }
- break;
-
-
- case 2: // Samples packed in to 2 bytes (short)
- // Write line by line
- for (i = 0; i < h; i++)
- {
-
- // Skip to beggining of line in file
- out_Renamed.Seek(offset + 2 * (this.w * (uly + tOffy + i) + ulx + tOffx), System.IO.SeekOrigin.Begin);
- // Write all bytes in the line
- if (fracbits == 0)
- {
- for (k = db.offset + i * db.scanw + w - 1, j = (w << 1) - 1; j >= 0; k--)
- {
- tmp = db.data_array[k] + levShift;
- tmp = (tmp < minVal) ? minVal : ((tmp > maxVal) ? maxVal : tmp);
- buf[j--] = (byte)tmp; // no need for 0xFF mask since
- // truncation will do it already
- buf[j--] = (byte)(SupportClass.URShift(tmp, 8));
- }
- }
- else
- {
- for (k = db.offset + i * db.scanw + w - 1, j = (w << 1) - 1; j >= 0; k--)
- {
- tmp = (SupportClass.URShift(db.data_array[k], fracbits)) + levShift;
- tmp = (tmp < minVal) ? minVal : ((tmp > maxVal) ? maxVal : tmp);
- buf[j--] = (byte)tmp; // no need for 0xFF mask since
- // truncation will do it already
- buf[j--] = (byte)(SupportClass.URShift(tmp, 8));
- }
- }
- out_Renamed.Write(buf, 0, w << 1);
- }
- break;
-
-
- case 4:
- // Write line by line
- for (i = 0; i < h; i++)
- {
- // Skip to beggining of line in file
- out_Renamed.Seek(offset + 4 * (this.w * (uly + tOffy + i) + ulx + tOffx), System.IO.SeekOrigin.Begin);
- // Write all bytes in the line
- if (fracbits == 0)
- {
- for (k = db.offset + i * db.scanw + w - 1, j = (w << 2) - 1; j >= 0; k--)
- {
- tmp = db.data_array[k] + levShift;
- tmp = (tmp < minVal) ? minVal : ((tmp > maxVal) ? maxVal : tmp);
- buf[j--] = (byte)tmp; // No need to use 0xFF
- buf[j--] = (byte)(SupportClass.URShift(tmp, 8)); // masks since truncation
- buf[j--] = (byte)(SupportClass.URShift(tmp, 16)); // will have already the
- buf[j--] = (byte)(SupportClass.URShift(tmp, 24)); // same effect
- }
- }
- else
- {
- for (k = db.offset + i * db.scanw + w - 1, j = (w << 2) - 1; j >= 0; k--)
- {
- tmp = (SupportClass.URShift(db.data_array[k], fracbits)) + levShift;
- tmp = (tmp < minVal) ? minVal : ((tmp > maxVal) ? maxVal : tmp);
- buf[j--] = (byte)tmp; // No need to use 0xFF
- buf[j--] = (byte)(SupportClass.URShift(tmp, 8)); // masks since truncation
- buf[j--] = (byte)(SupportClass.URShift(tmp, 16)); // will have already the
- buf[j--] = (byte)(SupportClass.URShift(tmp, 24)); // same effect
- }
- }
- out_Renamed.Write(buf, 0, w << 2);
- }
- break;
-
-
- default:
- throw new System.IO.IOException("PGX supports only bit-depth between " + "1 and 31");
-
- }
- }
-
- /// Writes the source's current tile to the output. The requests of data
- /// issued to the source BlkImgDataSrc object are done by strips, in order
- /// to reduce memory usage.
- ///
- /// If the data returned from the BlkImgDataSrc source is progressive,
- /// then it is requested over and over until it is not progressive
- /// anymore.
- ///
- ///
- /// If an I/O error occurs.
- ///
- ///
- ///
- ///
- ///
- public override void write()
- {
- int i;
- int tIdx = src.TileIdx;
- int tw = src.getTileCompWidth(tIdx, c); // Tile width
- int th = src.getTileCompHeight(tIdx, c); // Tile height
- // Write in strips
- for (i = 0; i < th; i += DEF_STRIP_HEIGHT)
- {
- write(0, i, tw, (th - i < DEF_STRIP_HEIGHT) ? th - i : DEF_STRIP_HEIGHT);
- }
- }
-
- /// Returns a string of information about the object, more than 1 line
- /// long. The information string includes information from the underlying
- /// RandomAccessFile (its toString() method is called in turn).
- ///
- ///
- /// A string of information about the object.
- ///
- ///
- public override System.String ToString()
- {
- //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Object.toString' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'"
- return "ImgWriterPGX: WxH = " + w + "x" + h + ", Component = " + c + ", Bit-depth = " + bitDepth + ", signed = " + isSigned + "\nUnderlying RandomAccessFile:\n" + out_Renamed.ToString();
- }
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/image/output/ImgWriterPPM.cs b/CSJ2K/j2k/image/output/ImgWriterPPM.cs
deleted file mode 100644
index 3c926e1d..00000000
--- a/CSJ2K/j2k/image/output/ImgWriterPPM.cs
+++ /dev/null
@@ -1,463 +0,0 @@
-/*
-* CVS identifier:
-*
-* $Id: ImgWriterPPM.java,v 1.16 2002/07/25 15:10:14 grosbois Exp $
-*
-* Class: ImgWriterRawPPM
-*
-* Description: Image writer for unsigned 8 bit data in
-* PPM file format.
-*
-*
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-* */
-namespace CSJ2K.j2k.image.output
-{
-
- /// This class writes 3 components from an image in 8 bit unsigned data to a
- /// binary PPM file.
- ///
- /// The size of the image that is written is the size of the source
- /// image. No component subsampling is allowed in any of the components that
- /// are written to the file.
- ///
- ///
Before writing, all coefficients are inversly level-shifted and then
- /// "saturated" (they are limited * to the nominal dynamic range).
- ///
- /// Ex: if the nominal range is 0-255, the following algorithm is
- /// applied:
- ///
- /// if coeff<0, output=0
- ///
- /// if coeff>255, output=255
- ///
- /// else output=coeff
- ///
- /// The write() methods of an object of this class may not be called
- /// concurrently from different threads.
- ///
- ///
NOTE: This class is not thread safe, for reasons of internal buffering.
- ///
- ///
- public class ImgWriterPPM : ImgWriter
- {
-
- /// Value used to inverse level shift. One for each component
- private int[] levShift = new int[3];
-
- /// Where to write the data
- //UPGRADE_TODO: Class 'java.io.RandomAccessFile' was converted to 'System.IO.FileStream' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaioRandomAccessFile'"
- private System.IO.FileStream out_Renamed;
-
- /// The array of indexes of the components from where to get the data
- private int[] cps = new int[3];
-
- /// The array of the number of fractional bits in the components of the
- /// source data
- ///
- private int[] fb = new int[3];
-
- /// A DataBlk, just used to avoid allocating a new one each time
- /// it is needed
- ///
- private DataBlkInt db = new DataBlkInt();
-
- /// The offset of the raw pixel data in the PPM file
- private int offset;
-
- /// The line buffer.
- // This makes the class not thrad safe
- // (but it is not the only one making it so)
- private byte[] buf;
-
- /// Creates a new writer to the specified File object, to write data from
- /// the specified component.
- ///
- /// The three components that will be written as R, G and B must be
- /// specified through the b1, b2 and b3 arguments.
- ///
- ///
- /// The file where to write the data
- ///
- ///
- /// The source from where to get the image data to write.
- ///
- ///
- /// The index of the first component from where to get the data,
- /// that will be written as the red channel.
- ///
- ///
- /// The index of the second component from where to get the data,
- /// that will be written as the green channel.
- ///
- ///
- /// The index of the third component from where to get the data,
- /// that will be written as the green channel.
- ///
- ///
- ///
- ///
- ///
- public ImgWriterPPM(System.IO.FileInfo out_Renamed, BlkImgDataSrc imgSrc, int n1, int n2, int n3)
- {
- // Check that imgSrc is of the correct type
- // Check that the component index is valid
- if ((n1 < 0) || (n1 >= imgSrc.NumComps) || (n2 < 0) || (n2 >= imgSrc.NumComps) || (n3 < 0) || (n3 >= imgSrc.NumComps) || (imgSrc.getNomRangeBits(n1) > 8) || (imgSrc.getNomRangeBits(n2) > 8) || (imgSrc.getNomRangeBits(n3) > 8))
- {
- throw new System.ArgumentException("Invalid component indexes");
- }
- // Initialize
- w = imgSrc.getCompImgWidth(n1);
- h = imgSrc.getCompImgHeight(n1);
- // Check that all components have same width and height
- if (w != imgSrc.getCompImgWidth(n2) || w != imgSrc.getCompImgWidth(n3) || h != imgSrc.getCompImgHeight(n2) || h != imgSrc.getCompImgHeight(n3))
- {
- throw new System.ArgumentException("All components must have the" + " same dimensions and no" + " subsampling");
- }
- w = imgSrc.ImgWidth;
- h = imgSrc.ImgHeight;
-
- // Continue initialization
- bool tmpBool;
- if (System.IO.File.Exists(out_Renamed.FullName))
- tmpBool = true;
- else
- tmpBool = System.IO.Directory.Exists(out_Renamed.FullName);
- bool tmpBool2;
- if (System.IO.File.Exists(out_Renamed.FullName))
- {
- System.IO.File.Delete(out_Renamed.FullName);
- tmpBool2 = true;
- }
- else if (System.IO.Directory.Exists(out_Renamed.FullName))
- {
- System.IO.Directory.Delete(out_Renamed.FullName);
- tmpBool2 = true;
- }
- else
- tmpBool2 = false;
- if (tmpBool && !tmpBool2)
- {
- throw new System.IO.IOException("Could not reset file");
- }
- this.out_Renamed = SupportClass.RandomAccessFileSupport.CreateRandomAccessFile(out_Renamed, "rw");
- src = imgSrc;
- cps[0] = n1;
- cps[1] = n2;
- cps[2] = n3;
- fb[0] = imgSrc.getFixedPoint(n1);
- fb[1] = imgSrc.getFixedPoint(n2);
- fb[2] = imgSrc.getFixedPoint(n3);
-
- levShift[0] = 1 << (imgSrc.getNomRangeBits(n1) - 1);
- levShift[1] = 1 << (imgSrc.getNomRangeBits(n2) - 1);
- levShift[2] = 1 << (imgSrc.getNomRangeBits(n3) - 1);
-
- writeHeaderInfo();
- }
-
- /// Creates a new writer to the specified file, to write data from the
- /// specified component.
- ///
- /// The three components that will be written as R, G and B must be
- /// specified through the b1, b2 and b3 arguments.
- ///
- ///
- /// The name of the file where to write the data
- ///
- ///
- /// The source from where to get the image data to write.
- ///
- ///
- /// The index of the first component from where to get the data,
- /// that will be written as the red channel.
- ///
- ///
- /// The index of the second component from where to get the data,
- /// that will be written as the green channel.
- ///
- ///
- /// The index of the third component from where to get the data,
- /// that will be written as the green channel.
- ///
- ///
- ///
- ///
- ///
- public ImgWriterPPM(System.String fname, BlkImgDataSrc imgSrc, int n1, int n2, int n3) : this(new System.IO.FileInfo(fname), imgSrc, n1, n2, n3)
- {
- }
-
- /// Closes the underlying file or netwrok connection to where the data is
- /// written. Any call to other methods of the class become illegal after a
- /// call to this one.
- ///
- ///
- /// If an I/O error occurs.
- ///
- ///
- public override void close()
- {
- int i;
- // Finish writing the file, writing 0s at the end if the data at end
- // has not been written.
- if (out_Renamed.Length != 3 * w * h + offset)
- {
- // Goto end of file
- out_Renamed.Seek(out_Renamed.Length, System.IO.SeekOrigin.Begin);
- // Fill with 0s n all the components
- for (i = 3 * w * h + offset - (int)out_Renamed.Length; i > 0; i--)
- {
- out_Renamed.WriteByte((System.Byte)0);
- }
- }
- out_Renamed.Close();
- src = null;
- out_Renamed = null;
- db = null;
- }
-
- /// Writes all buffered data to the file or resource.
- ///
- ///
- /// If an I/O error occurs.
- ///
- ///
- public override void flush()
- {
- // No flush needed here since we are using a RandomAccessFile Get rid
- // of line buffer (is this a good choice?)
- buf = null;
- }
-
- /// Writes the data of the specified area to the file, coordinates are
- /// relative to the current tile of the source. Before writing, the
- /// coefficients are limited to the nominal range.
- ///
- /// This method may not be called concurrently from different
- /// threads.
- ///
- /// If the data returned from the BlkImgDataSrc source is progressive,
- /// then it is requested over and over until it is not progressive
- /// anymore.
- ///
- ///
- /// The horizontal coordinate of the upper-left corner of the
- /// area to write, relative to the current tile.
- ///
- ///
- /// The vertical coordinate of the upper-left corner of the area
- /// to write, relative to the current tile.
- ///
- ///
- /// The width of the area to write.
- ///
- ///
- /// The height of the area to write.
- ///
- ///
- /// If an I/O error occurs.
- ///
- ///
- public override void write(int ulx, int uly, int w, int h)
- {
- int k, j, i, c;
- // In local variables for faster access
- int fracbits;
- // variables used during coeff saturation
- int shift, tmp, maxVal;
- int tOffx, tOffy; // Active tile offset in the X and Y direction
-
- // Active tiles in all components have same offset since they are at
- // same resolution (PPM does not support anything else)
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- tOffx = src.getCompULX(cps[0]) - (int)System.Math.Ceiling(src.ImgULX / (double)src.getCompSubsX(cps[0]));
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- tOffy = src.getCompULY(cps[0]) - (int)System.Math.Ceiling(src.ImgULY / (double)src.getCompSubsY(cps[0]));
-
- // Check the array size
- if (db.data_array != null && db.data_array.Length < w)
- {
- // A new one will be allocated by getInternCompData()
- db.data_array = null;
- }
-
- // Check the line buffer
- if (buf == null || buf.Length < 3 * w)
- {
- buf = new byte[3 * w];
- }
-
- // Write the data to the file
- // Write line by line
- for (i = 0; i < h; i++)
- {
- // Write into buffer first loop over the three components and
- // write for each
- for (c = 0; c < 3; c++)
- {
- maxVal = (1 << src.getNomRangeBits(cps[c])) - 1;
- shift = levShift[c];
-
- // Initialize db
- db.ulx = ulx;
- db.uly = uly + i;
- db.w = w;
- db.h = 1;
-
- // Request the data and make sure it is not progressive
- do
- {
- db = (DataBlkInt)src.getInternCompData(db, cps[c]);
- }
- while (db.progressive);
- // Get the fracbits value
- fracbits = fb[c];
- // Write all bytes in the line
- if (fracbits == 0)
- {
- for (k = db.offset + w - 1, j = 3 * w - 1 + c - 2; j >= 0; k--)
- {
- tmp = db.data_array[k] + shift;
- buf[j] = (byte)((tmp < 0) ? 0 : ((tmp > maxVal) ? maxVal : tmp));
- j -= 3;
- }
- }
- else
- {
- for (k = db.offset + w - 1, j = 3 * w - 1 + c - 2; j >= 0; k--)
- {
- tmp = (SupportClass.URShift(db.data_array[k], fracbits)) + shift;
- buf[j] = (byte)((tmp < 0) ? 0 : ((tmp > maxVal) ? maxVal : tmp));
- j -= 3;
- }
- }
- }
- // Write buffer into file
- out_Renamed.Seek(offset + 3 * (this.w * (uly + tOffy + i) + ulx + tOffx), System.IO.SeekOrigin.Begin);
- out_Renamed.Write(buf, 0, 3 * w);
- }
- }
-
- /// Writes the source's current tile to the output. The requests of data
- /// issued to the source BlkImgDataSrc object are done by strips, in order
- /// to reduce memory usage.
- ///
- /// If the data returned from the BlkImgDataSrc source is progressive,
- /// then it is requested over and over until it is not progressive any
- /// more.
- ///
- ///
- /// If an I/O error occurs.
- ///
- ///
- public override void write()
- {
- int i;
- int tIdx = src.TileIdx;
- int tw = src.getTileCompWidth(tIdx, 0); // Tile width
- int th = src.getTileCompHeight(tIdx, 0); // Tile height
- // Write in strips
- for (i = 0; i < th; i += DEF_STRIP_HEIGHT)
- {
- write(0, i, tw, ((th - i) < DEF_STRIP_HEIGHT) ? th - i : DEF_STRIP_HEIGHT);
- }
- }
-
- /// Writes the header info of the PPM file :
- ///
- /// P6
- ///
- /// width height
- ///
- /// 255
- ///
- ///
- /// If there is an I/O Error
- ///
- ///
- private void writeHeaderInfo()
- {
- byte[] byteVals;
- int i;
- System.String val;
-
- // write 'P6' to file
- out_Renamed.Seek(0, System.IO.SeekOrigin.Begin);
- out_Renamed.WriteByte((System.Byte)80);
- out_Renamed.WriteByte((System.Byte)54);
- out_Renamed.WriteByte((System.Byte)10); // new line
- offset = 3;
- // Write width in ASCII
- val = System.Convert.ToString(w);
- byteVals = System.Text.ASCIIEncoding.ASCII.GetBytes(val);
- for (i = 0; i < byteVals.Length; i++)
- {
- out_Renamed.WriteByte((byte)byteVals[i]);
- offset++;
- }
- out_Renamed.WriteByte((System.Byte)32); // blank
- offset++;
- // Write height in ASCII
- val = System.Convert.ToString(h);
- byteVals = System.Text.ASCIIEncoding.ASCII.GetBytes(val);
- for (i = 0; i < byteVals.Length; i++)
- {
- out_Renamed.WriteByte((byte)byteVals[i]);
- offset++;
- }
-
- out_Renamed.WriteByte((System.Byte)10); // newline
- out_Renamed.WriteByte((System.Byte)50); // '2'
- out_Renamed.WriteByte((System.Byte)53); // '5'
- out_Renamed.WriteByte((System.Byte)53); // '5'
- out_Renamed.WriteByte((System.Byte)10); // newline
- offset += 5;
- }
-
-
- /// Returns a string of information about the object, more than 1 line
- /// long. The information string includes information from the underlying
- /// RandomAccessFile (its toString() method is called in turn).
- ///
- ///
- /// A string of information about the object.
- ///
- ///
- public override System.String ToString()
- {
- //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Object.toString' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'"
- return "ImgWriterPPM: WxH = " + w + "x" + h + ", Components = " + cps[0] + "," + cps[1] + "," + cps[2] + "\nUnderlying RandomAccessFile:\n" + out_Renamed.ToString();
- }
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/io/BEBufferedRandomAccessFile.cs b/CSJ2K/j2k/io/BEBufferedRandomAccessFile.cs
deleted file mode 100644
index 9dbda311..00000000
--- a/CSJ2K/j2k/io/BEBufferedRandomAccessFile.cs
+++ /dev/null
@@ -1,440 +0,0 @@
-/*
-* CVS Identifier:
-*
-* $Id: BEBufferedRandomAccessFile.java,v 1.18 2001/07/17 13:13:35 grosbois Exp $
-*
-* Interface: RandomAccessIO.java
-*
-* Description: Class for random access I/O (big-endian ordering).
-*
-*
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-* */
-using System;
-namespace CSJ2K.j2k.io
-{
-
- /// This class defines a Buffered Random Access File, where all I/O is
- /// considered to be big-endian. It extends the
- /// BufferedRandomAccessFile class.
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- public class BEBufferedRandomAccessFile : BufferedRandomAccessFile, RandomAccessIO, EndianType
- {
-
- /// Constructor. Always needs a size for the buffer.
- ///
- ///
- /// The file associated with the buffer
- ///
- ///
- /// "r" for read, "rw" or "rw+" for read and write mode ("rw+"
- /// opens the file for update whereas "rw" removes it
- /// before. So the 2 modes are different only if the file
- /// already exists).
- ///
- ///
- /// The number of bytes to buffer
- ///
- ///
- /// If an I/O error ocurred.
- ///
- ///
- public BEBufferedRandomAccessFile(System.IO.FileInfo file, System.String mode, int bufferSize) : base(file, mode, bufferSize)
- {
- byte_Ordering = CSJ2K.j2k.io.EndianType_Fields.BIG_ENDIAN;
- }
-
- /// Constructor. Uses the default value for the byte-buffer size (512
- /// bytes).
- ///
- ///
- /// The file associated with the buffer
- ///
- ///
- /// "r" for read, "rw" or "rw+" for read and write mode ("rw+"
- /// opens the file for update whereas "rw" removes it
- /// before. So the 2 modes are different only if the file
- /// already exists).
- ///
- ///
- /// If an I/O error ocurred.
- ///
- ///
- public BEBufferedRandomAccessFile(System.IO.FileInfo file, System.String mode) : base(file, mode)
- {
- byte_Ordering = CSJ2K.j2k.io.EndianType_Fields.BIG_ENDIAN;
- }
-
- /// Constructor. Always needs a size for the buffer.
- ///
- ///
- /// The name of the file associated with the buffer
- ///
- ///
- /// "r" for read, "rw" or "rw+" for read and write mode ("rw+"
- /// opens the file for update whereas "rw" removes it
- /// before. So the 2 modes are different only if the file
- /// already exists).
- ///
- ///
- /// The number of bytes to buffer
- ///
- ///
- /// If an I/O error ocurred.
- ///
- ///
- public BEBufferedRandomAccessFile(System.String name, System.String mode, int bufferSize) : base(name, mode, bufferSize)
- {
- byte_Ordering = CSJ2K.j2k.io.EndianType_Fields.BIG_ENDIAN;
- }
-
- /// Constructor. Uses the default value for the byte-buffer size (512
- /// bytes).
- ///
- ///
- /// The name of the file associated with the buffer
- ///
- ///
- /// "r" for read, "rw" or "rw+" for read and write mode ("rw+"
- /// opens the file for update whereas "rw" removes it
- /// before. So the 2 modes are different only if the file
- /// already exists).
- ///
- ///
- /// If an I/O error ocurred.
- ///
- ///
- public BEBufferedRandomAccessFile(System.String name, System.String mode) : base(name, mode)
- {
- byte_Ordering = CSJ2K.j2k.io.EndianType_Fields.BIG_ENDIAN;
- }
-
- /// Writes the short value of v (i.e., 16 least significant bits)
- /// to the output. Prior to writing, the output should be realigned at the
- /// byte level.
- ///
- /// Signed or unsigned data can be written. To write a signed value just
- /// pass the short value as an argument. To write unsigned data
- /// pass the int value as an argument (it will be automatically
- /// casted, and only the 16 least significant bits will be written).
- ///
- ///
- /// The value to write to the output
- ///
- ///
- /// If an I/O error ocurred.
- ///
- ///
- public override void writeShort(int v)
- {
- write(SupportClass.URShift(v, 8));
- write(v);
- }
-
- /// Writes the int value of v (i.e., the 32 bits) to the
- /// output. Prior to writing, the output should be realigned at the byte
- /// level.
- ///
- ///
- /// The value to write to the output
- ///
- ///
- /// If an I/O error ocurred.
- ///
- ///
- public override void writeInt(int v)
- {
- write(SupportClass.URShift(v, 24));
- write(SupportClass.URShift(v, 16));
- write(SupportClass.URShift(v, 8));
- write(v);
- }
-
- /// Writes the long value of v (i.e., the 64 bits) to the
- /// output. Prior to writing, the output should be realigned at the byte
- /// level.
- ///
- ///
- /// The value to write to the output
- ///
- ///
- /// If an I/O error ocurred.
- ///
- ///
- public override void writeLong(long v)
- {
- write((int)(SupportClass.URShift(v, 56)));
- write((int)(SupportClass.URShift(v, 48)));
- write((int)(SupportClass.URShift(v, 40)));
- write((int)(SupportClass.URShift(v, 32)));
- write((int)(SupportClass.URShift(v, 24)));
- write((int)(SupportClass.URShift(v, 16)));
- write((int)(SupportClass.URShift(v, 8)));
- write((int)v);
- }
-
- /// Writes the IEEE float value v (i.e., 32 bits) to the
- /// output. Prior to writing, the output should be realigned at the byte
- /// level.
- ///
- ///
- /// The value to write to the output
- ///
- ///
- /// If an I/O error ocurred.
- ///
- ///
- public override void writeFloat(float v)
- {
- // CONVERSION PROBLEM? OPTIMIZE!!!
- //byte[] floatbytes = BitConverter.GetBytes(v);
- //for (int i = floatbytes.Length-1; i >= 0 ; i--) write(floatbytes[i]);
-
- //UPGRADE_ISSUE: Method 'java.lang.Float.floatToIntBits' was not converted. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1000_javalangFloatfloatToIntBits_float'"
- //int intV = Float.floatToIntBits(v);
- int intV = BitConverter.ToInt32(BitConverter.GetBytes(v), 0);
- write(SupportClass.URShift(intV, 24));
- write(SupportClass.URShift(intV, 16));
- write(SupportClass.URShift(intV, 8));
- write(intV);
- }
-
- /// Writes the IEEE double value v (i.e., 64 bits) to the
- /// output. Prior to writing, the output should be realigned at the byte
- /// level.
- ///
- ///
- /// The value to write to the output
- ///
- ///
- /// If an I/O error ocurred.
- ///
- ///
- public override void writeDouble(double v)
- {
- //byte[] doublebytes = BitConverter.GetBytes(v);
- //for (int i = doublebytes.Length-1; i >= 0 ; i--) write(doublebytes[i]);
-
- //UPGRADE_ISSUE: Method 'java.lang.Double.doubleToLongBits' was not converted. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1000_javalangDoubledoubleToLongBits_double'"
- //long longV = Double.doubleToLongBits(v);
- long longV = BitConverter.ToInt64(BitConverter.GetBytes(v), 0);
- write((int)(SupportClass.URShift(longV, 56)));
- write((int)(SupportClass.URShift(longV, 48)));
- write((int)(SupportClass.URShift(longV, 40)));
- write((int)(SupportClass.URShift(longV, 32)));
- write((int)(SupportClass.URShift(longV, 24)));
- write((int)(SupportClass.URShift(longV, 16)));
- write((int)(SupportClass.URShift(longV, 8)));
- write((int)(longV));
-
- }
-
- /// Reads a signed short (i.e. 16 bit) from the input. Prior to reading,
- /// the input should be realigned at the byte level.
- ///
- ///
- /// The next byte-aligned signed short (16 bit) from the input.
- ///
- ///
- /// If the end-of file was reached before
- /// getting all the necessary data.
- ///
- ///
- /// If an I/O error ocurred.
- ///
- ///
- public override short readShort()
- {
- return (short)((read() << 8) | (read()));
- }
-
- /// Reads an unsigned short (i.e., 16 bit) from the input. It is returned
- /// as an int since Java does not have an unsigned short
- /// type. Prior to reading, the input should be realigned at the byte
- /// level.
- ///
- ///
- /// The next byte-aligned unsigned short (16 bit) from the input,
- /// as an int.
- ///
- ///
- /// If the end-of file was reached before
- /// getting all the necessary data.
- ///
- ///
- /// If an I/O error ocurred.
- ///
- ///
- public override int readUnsignedShort()
- {
- return ((read() << 8) | read());
- }
-
- /// Reads a signed int (i.e., 32 bit) from the input. Prior to reading, the
- /// input should be realigned at the byte level.
- ///
- ///
- /// The next byte-aligned signed int (32 bit) from the input.
- ///
- ///
- /// If the end-of file was reached before
- /// getting all the necessary data.
- ///
- ///
- /// If an I/O error ocurred.
- ///
- ///
- public override int readInt()
- {
- return ((read() << 24) | (read() << 16) | (read() << 8) | read());
- }
-
- /// Reads an unsigned int (i.e., 32 bit) from the input. It is returned as
- /// a long since Java does not have an unsigned short type. Prior
- /// to reading, the input should be realigned at the byte level.
- ///
- ///
- /// The next byte-aligned unsigned int (32 bit) from the input, as
- /// a long.
- ///
- ///
- /// If the end-of file was reached before
- /// getting all the necessary data.
- ///
- ///
- /// If an I/O error ocurred.
- ///
- ///
- public override long readUnsignedInt()
- {
- return (long)((read() << 24) | (read() << 16) | (read() << 8) | read());
- }
-
- /// Reads a signed long (i.e., 64 bit) from the input. Prior to reading,
- /// the input should be realigned at the byte level.
- ///
- ///
- /// The next byte-aligned signed long (64 bit) from the input.
- ///
- ///
- /// If the end-of file was reached before
- /// getting all the necessary data.
- ///
- ///
- /// If an I/O error ocurred.
- ///
- ///
- public override long readLong()
- {
- //byte[] longbytes = new byte[8];
- //for (int i = longbytes.Length-1; i >= 0; i--) longbytes[i] = read();
- //return BitConverter.ToInt64(longbytes, 0);
- return ((long)(((ulong)read() << 56) | ((ulong)read() << 48) | ((ulong)read() << 40) | ((ulong)read() << 32) | ((ulong)read() << 24) | ((ulong)read() << 16) | ((ulong)read() << 8) | ((ulong)read())));
- }
-
- /// Reads an IEEE single precision (i.e., 32 bit) floating-point number
- /// from the input. Prior to reading, the input should be realigned at the
- /// byte level.
- ///
- ///
- /// The next byte-aligned IEEE float (32 bit) from the input.
- ///
- ///
- /// If the end-of file was reached before
- /// getting all the necessary data.
- ///
- ///
- /// If an I/O error ocurred.
- ///
- ///
- public override float readFloat()
- {
- // CONVERSION PROBLEM? OPTIMIZE!!!
- //byte[] floatbytes = new byte[4];
- //for (int i = floatbytes.Length-1; i >= 0 ; i--) floatbytes[i] = (byte)read();
- //return BitConverter.ToSingle(floatbytes, 0);
-
- //UPGRADE_ISSUE: Method 'java.lang.Float.intBitsToFloat' was not converted. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1000_javalangFloatintBitsToFloat_int'"
- //return Float.intBitsToFloat((read() << 24) | (read() << 16) | (read() << 8) | (read()));
- return BitConverter.ToSingle(BitConverter.GetBytes((read() << 24) | (read() << 16) | (read() << 8) | (read())), 0);
-
- }
-
- /// Reads an IEEE double precision (i.e., 64 bit) floating-point number
- /// from the input. Prior to reading, the input should be realigned at the
- /// byte level.
- ///
- ///
- /// The next byte-aligned IEEE double (64 bit) from the input.
- ///
- ///
- /// If the end-of file was reached before
- /// getting all the necessary data.
- ///
- ///
- /// If an I/O error ocurred.
- ///
- ///
- public override double readDouble()
- {
- // CONVERSION PROBLEM? OPTIMIZE!!!
- //byte[] doublebytes = new byte[8];
- //for (int i = doublebytes.Length-1; i >=0 ; i--) doublebytes[i] = (byte)read();
- //return BitConverter.ToDouble(doublebytes, 0);
-
- //UPGRADE_ISSUE: Method 'java.lang.Double.longBitsToDouble' was not converted. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1000_javalangDoublelongBitsToDouble_long'"
- //return Double.longBitsToDouble(((long) read() << 56) | ((long) read() << 48) | ((long) read() << 40) | ((long) read() << 32) | ((long) read() << 24) | ((long) read() << 16) | ((long) read() << 8) | ((long) read()));
-
- return BitConverter.ToDouble(BitConverter.GetBytes(((long)read() << 56) | ((long)read() << 48) | ((long)read() << 40) | ((long)read() << 32) | ((long)read() << 24) | ((long)read() << 16) | ((long)read() << 8) | ((long)read())), 0);
-
- }
-
- /// Returns a string of information about the file and the endianess
- ///
- ///
- public override System.String ToString()
- {
- return base.ToString() + "\nBig-Endian ordering";
- }
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/io/BinaryDataInput.cs b/CSJ2K/j2k/io/BinaryDataInput.cs
deleted file mode 100644
index d4e24035..00000000
--- a/CSJ2K/j2k/io/BinaryDataInput.cs
+++ /dev/null
@@ -1,252 +0,0 @@
-/*
-* CVS Identifier:
-*
-* $Id: BinaryDataInput.java,v 1.12 2001/07/23 09:27:26 grosbois Exp $
-*
-* Interface: BinaryDataInput
-*
-* Description: Stream like interface for binary
-* input from a stream or file.
-*
-*
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-* */
-namespace CSJ2K.j2k.io
-{
-
- /// This interface defines the input of binary data from streams and/or files.
- ///
- /// Byte level input (i.e., for byte, int, long, float, etc.) should always
- /// be byte aligned. For example, a request to read an int should
- /// always realign the input at the byte level.
- ///
- /// The implementation of this interface should clearly define if multi-byte
- /// input data is read in little- or big-endian byte ordering (least
- /// significant byte first or most significant byte first, respectively).
- ///
- ///
- ///
- ///
- ///
- public interface BinaryDataInput
- {
- /// Returns the endianess (i.e., byte ordering) of the implementing
- /// class. Note that an implementing class may implement only one type of
- /// endianness or both, which would be decided at creatiuon time.
- ///
- ///
- /// Either EndianType.BIG_ENDIAN or
- /// EndianType.LITTLE_ENDIAN
- ///
- ///
- ///
- ///
- ///
- int ByteOrdering
- {
- get;
-
- }
-
- /// Should read a signed byte (i.e., 8 bit) from the input. reading, the
- /// input should be realigned at the byte level.
- ///
- ///
- /// The next byte-aligned signed byte (8 bit) from the input.
- ///
- ///
- /// If the end-of file was reached before getting
- /// all the necessary data.
- ///
- ///
- /// If an I/O error ocurred.
- ///
- ///
- byte readByte();
-
- /// Should read an unsigned byte (i.e., 8 bit) from the input. It is
- /// returned as an int since Java does not have an unsigned byte
- /// type. Prior to reading, the input should be realigned at the byte
- /// level.
- ///
- ///
- /// The next byte-aligned unsigned byte (8 bit) from the input, as
- /// an int.
- ///
- ///
- /// If the end-of file was reached before getting
- /// all the necessary data.
- ///
- ///
- /// If an I/O error ocurred.
- ///
- ///
- byte readUnsignedByte();
-
- /// Should read a signed short (i.e., 16 bit) from the input. Prior to
- /// reading, the input should be realigned at the byte level.
- ///
- ///
- /// The next byte-aligned signed short (16 bit) from the input.
- ///
- ///
- /// If the end-of file was reached before getting
- /// all the necessary data.
- ///
- ///
- /// If an I/O error ocurred.
- ///
- ///
- short readShort();
-
- /// Should read an unsigned short (i.e., 16 bit) from the input. It is
- /// returned as an int since Java does not have an unsigned short
- /// type. Prior to reading, the input should be realigned at the byte
- /// level.
- ///
- ///
- /// The next byte-aligned unsigned short (16 bit) from the input,
- /// as an int.
- ///
- ///
- /// If the end-of file was reached before getting
- /// all the necessary data.
- ///
- ///
- /// If an I/O error ocurred.
- ///
- ///
- int readUnsignedShort();
-
- /// Should read a signed int (i.e., 32 bit) from the input. Prior to
- /// reading, the input should be realigned at the byte level.
- ///
- ///
- /// The next byte-aligned signed int (32 bit) from the input.
- ///
- ///
- /// If the end-of file was reached before getting
- /// all the necessary data.
- ///
- ///
- /// If an I/O error ocurred.
- ///
- ///
- int readInt();
-
- /// Should read an unsigned int (i.e., 32 bit) from the input. It is
- /// returned as a long since Java does not have an unsigned short
- /// type. Prior to reading, the input should be realigned at the byte
- /// level.
- ///
- ///
- /// The next byte-aligned unsigned int (32 bit) from the input, as
- /// a long.
- ///
- ///
- /// If the end-of file was reached before getting
- /// all the necessary data.
- ///
- ///
- /// If an I/O error ocurred.
- ///
- ///
- long readUnsignedInt();
-
- /// Should read a signed long (i.e., 64 bit) from the input. Prior to
- /// reading, the input should be realigned at the byte level.
- ///
- ///
- /// The next byte-aligned signed long (64 bit) from the input.
- ///
- ///
- /// If the end-of file was reached before getting
- /// all the necessary data.
- ///
- ///
- /// If an I/O error ocurred.
- ///
- ///
- long readLong();
-
- /// Should read an IEEE single precision (i.e., 32 bit) floating-point
- /// number from the input. Prior to reading, the input should be realigned
- /// at the byte level.
- ///
- ///
- /// The next byte-aligned IEEE float (32 bit) from the input.
- ///
- ///
- /// If the end-of file was reached before getting
- /// all the necessary data.
- ///
- ///
- /// If an I/O error ocurred.
- ///
- ///
- float readFloat();
-
- /// Should read an IEEE double precision (i.e., 64 bit) floating-point
- /// number from the input. Prior to reading, the input should be realigned
- /// at the byte level.
- ///
- ///
- /// The next byte-aligned IEEE double (64 bit) from the input.
- ///
- ///
- /// If the end-of file was reached before getting
- /// all the necessary data.
- ///
- ///
- /// If an I/O error ocurred.
- ///
- ///
- double readDouble();
-
- /// Skips n bytes from the input. Prior to skipping, the input
- /// should be realigned at the byte level.
- ///
- ///
- /// The number of bytes to skip
- ///
- ///
- /// If the end-of file was reached before all the
- /// bytes could be skipped.
- ///
- ///
- /// If an I/O error ocurred.
- ///
- ///
- int skipBytes(int n);
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/io/BinaryDataOutput.cs b/CSJ2K/j2k/io/BinaryDataOutput.cs
deleted file mode 100644
index dd5b6273..00000000
--- a/CSJ2K/j2k/io/BinaryDataOutput.cs
+++ /dev/null
@@ -1,201 +0,0 @@
-/*
-* CVS Identifier:
-*
-* $Id: BinaryDataOutput.java,v 1.11 2000/09/05 09:24:33 grosbois Exp $
-*
-* Interface: BinaryDataOutput
-*
-* Description: Stream like interface for bit as well as byte
-* level output to a stream or file.
-*
-*
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-*
-*
-*
-*/
-namespace CSJ2K.j2k.io
-{
-
- /// This interface defines the output of binary data to streams and/or files.
- ///
- /// Byte level output (i.e., for byte, int, long, float, etc.) should
- /// always be byte aligned. For example, a request to write an
- /// int should always realign the output at the byte level.
- ///
- ///
The implementation of this interface should clearly define if
- /// multi-byte output data is written in little- or big-endian byte
- /// ordering (least significant byte first or most significant byte
- /// first, respectively).
- ///
- ///
- ///
- ///
- ///
- public interface BinaryDataOutput
- {
- /// Returns the endianness (i.e., byte ordering) of the implementing
- /// class. Note that an implementing class may implement only one
- /// type of endianness or both, which would be decided at creatiuon
- /// time.
- ///
- ///
- /// Either EndianType.BIG_ENDIAN or
- /// EndianType.LITTLE_ENDIAN
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- int ByteOrdering
- {
- get;
-
- }
-
- /// Should write the byte value of v (i.e., 8 least
- /// significant bits) to the output. Prior to writing, the output
- /// should be realigned at the byte level.
- ///
- /// Signed or unsigned data can be written. To write a signed
- /// value just pass the byte value as an argument. To
- /// write unsigned data pass the int value as an argument
- /// (it will be automatically casted, and only the 8 least
- /// significant bits will be written).
- ///
- ///
- /// The value to write to the output
- ///
- ///
- /// If an I/O error ocurred.
- ///
- ///
- ///
- ///
- void writeByte(int v);
-
- /// Should write the short value of v (i.e., 16 least
- /// significant bits) to the output. Prior to writing, the output
- /// should be realigned at the byte level.
- ///
- /// Signed or unsigned data can be written. To write a signed
- /// value just pass the short value as an argument. To
- /// write unsigned data pass the int value as an argument
- /// (it will be automatically casted, and only the 16 least
- /// significant bits will be written).
- ///
- ///
- /// The value to write to the output
- ///
- ///
- /// If an I/O error ocurred.
- ///
- ///
- ///
- ///
- void writeShort(int v);
-
- /// Should write the int value of v (i.e., the 32 bits) to
- /// the output. Prior to writing, the output should be realigned at
- /// the byte level.
- ///
- ///
- /// The value to write to the output
- ///
- ///
- /// If an I/O error ocurred.
- ///
- ///
- ///
- ///
- void writeInt(int v);
-
- /// Should write the long value of v (i.e., the 64 bits)
- /// to the output. Prior to writing, the output should be realigned
- /// at the byte level.
- ///
- ///
- /// The value to write to the output
- ///
- ///
- /// If an I/O error ocurred.
- ///
- ///
- ///
- ///
- void writeLong(long v);
-
- /// Should write the IEEE float value v (i.e., 32 bits) to
- /// the output. Prior to writing, the output should be realigned at
- /// the byte level.
- ///
- ///
- /// The value to write to the output
- ///
- ///
- /// If an I/O error ocurred.
- ///
- ///
- ///
- ///
- void writeFloat(float v);
-
- /// Should write the IEEE double value v (i.e., 64 bits)
- /// to the output. Prior to writing, the output should be realigned
- /// at the byte level.
- ///
- ///
- /// The value to write to the output
- ///
- ///
- /// If an I/O error ocurred.
- ///
- ///
- ///
- ///
- void writeDouble(double v);
-
- /// Any data that has been buffered must be written, and the stream should
- /// be realigned at the byte level.
- ///
- ///
- /// If an I/O error ocurred.
- ///
- ///
- ///
- ///
- void flush();
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/io/BufferedRandomAccessFile.cs b/CSJ2K/j2k/io/BufferedRandomAccessFile.cs
deleted file mode 100644
index 2a5cf0c3..00000000
--- a/CSJ2K/j2k/io/BufferedRandomAccessFile.cs
+++ /dev/null
@@ -1,742 +0,0 @@
-/*
-* CVS Identifier:
-*
-* $Id: BufferedRandomAccessFile.java,v 1.21 2001/04/15 14:34:29 grosbois Exp $
-*
-* Interface: RandomAccessIO.java
-*
-* Description: Abstract class for buffered random access I/O.
-*
-*
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-* */
-using System;
-namespace CSJ2K.j2k.io
-{
-
- /// This class defines a Buffered Random Access File. It implements the
- /// BinaryDataInput and BinaryDataOutput interfaces so that
- /// binary data input/output can be performed. This class is abstract since no
- /// assumption is done about the byte ordering type (little Endian, big
- /// Endian). So subclasses will have to implement methods like
- /// readShort(), writeShort(), readFloat(), ...
- ///
- /// BufferedRandomAccessFile (BRAF for short) is a
- /// RandomAccessFile containing an extra buffer. When the BRAF is
- /// accessed, it checks if the requested part of the file is in the buffer or
- /// not. If that is the case, the read/write is done on the buffer. If not, the
- /// file is uppdated to reflect the current status of the buffer and the file
- /// is then accessed for a new buffer containing the requested byte/bit.
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- public abstract class BufferedRandomAccessFile : RandomAccessIO, EndianType
- {
- /// Returns the current offset in the file
- ///
- ///
- virtual public int Pos
- {
- get
- {
- return (offset + position);
- }
-
- }
- /// Returns the endianess (i.e., byte ordering) of the implementing
- /// class. Note that an implementing class may implement only one
- /// type of endianness or both, which would be decided at creation
- /// time.
- ///
- ///
- /// Either EndianType.BIG_ENDIAN or
- /// EndianType.LITTLE_ENDIAN
- ///
- ///
- ///
- ///
- ///
- virtual public int ByteOrdering
- {
- get
- {
- return byte_Ordering;
- }
-
- }
-
- /// The name of the current file
- private System.String fileName;
-
- /// Whether the opened file is read only or not (defined by the constructor
- /// arguments)
- ///
- ///
- private bool isReadOnly = true;
-
- /// The RandomAccessFile associated with the buffer
- ///
- ///
- //UPGRADE_TODO: Class 'java.io.RandomAccessFile' was converted to 'System.IO.FileStream' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaioRandomAccessFile'"
- private System.IO.FileStream theFile;
-
- /// Buffer of bytes containing the part of the file that is currently being
- /// accessed
- ///
- ///
- protected internal byte[] byteBuffer;
-
- /// Boolean keeping track of whether the byte buffer has been changed since
- /// it was read.
- ///
- ///
- protected internal bool byteBufferChanged;
-
- /// The current offset of the buffer (which will differ from the offset of
- /// the file)
- ///
- ///
- protected internal int offset;
-
- /// The current position in the byte-buffer
- ///
- ///
- protected internal int position;
-
- /// The maximum number of bytes that can be read from the buffer
- ///
- ///
- protected internal int maxByte;
-
- /// Whether the end of the file is in the current buffer or not
- ///
- ///
- protected internal bool isEOFInBuffer;
-
- /* The endianess of the class */
- protected internal int byte_Ordering;
-
- /// Constructor. Always needs a size for the buffer.
- ///
- ///
- /// The file associated with the buffer
- ///
- ///
- /// "r" for read, "rw" or "rw+" for read and write mode ("rw+"
- /// opens the file for update whereas "rw" removes it
- /// before. So the 2 modes are different only if the file
- /// already exists).
- ///
- ///
- /// The number of bytes to buffer
- ///
- ///
- /// If an I/O error ocurred.
- ///
- ///
- protected internal BufferedRandomAccessFile(System.IO.FileInfo file, System.String mode, int bufferSize)
- {
-
- fileName = file.Name;
- if (mode.Equals("rw") || mode.Equals("rw+"))
- {
- // mode read / write
- isReadOnly = false;
- if (mode.Equals("rw"))
- {
- // mode read / (over)write
- bool tmpBool;
- if (System.IO.File.Exists(file.FullName))
- tmpBool = true;
- else
- tmpBool = System.IO.Directory.Exists(file.FullName);
- if (tmpBool)
- // Output file already exists
- {
- bool tmpBool2;
- if (System.IO.File.Exists(file.FullName))
- {
- System.IO.File.Delete(file.FullName);
- tmpBool2 = true;
- }
- else if (System.IO.Directory.Exists(file.FullName))
- {
- System.IO.Directory.Delete(file.FullName);
- tmpBool2 = true;
- }
- else
- tmpBool2 = false;
- bool generatedAux = tmpBool2;
- }
- }
- mode = "rw";
- }
- theFile = SupportClass.RandomAccessFileSupport.CreateRandomAccessFile(file, mode);
- byteBuffer = new byte[bufferSize];
- readNewBuffer(0);
- }
-
- /// Constructor. Uses the default value for the byte-buffer
- /// size (512 bytes).
- ///
- ///
- /// The file associated with the buffer
- ///
- ///
- /// "r" for read, "rw" or "rw+" for read and write mode
- /// ("rw+" opens the file for update whereas "rw" removes
- /// it before. So the 2 modes are different only if the
- /// file already exists).
- ///
- ///
- /// If an I/O error ocurred.
- ///
- ///
- protected internal BufferedRandomAccessFile(System.IO.FileInfo file, System.String mode) : this(file, mode, 512)
- {
- }
-
- /// Constructor. Always needs a size for the buffer.
- ///
- ///
- /// The name of the file associated with the buffer
- ///
- ///
- /// "r" for read, "rw" or "rw+" for read and write mode
- /// ("rw+" opens the file for update whereas "rw" removes
- /// it before. So the 2 modes are different only if the
- /// file already exists).
- ///
- ///
- /// The number of bytes to buffer
- ///
- ///
- /// If an I/O error ocurred.
- ///
- ///
- protected internal BufferedRandomAccessFile(System.String name, System.String mode, int bufferSize) : this(new System.IO.FileInfo(name), mode, bufferSize)
- {
- }
-
- /// Constructor. Uses the default value for the byte-buffer
- /// size (512 bytes).
- ///
- ///
- /// The name of the file associated with the buffer
- ///
- ///
- /// "r" for read, "rw" or "rw+" for read and write mode
- /// ("rw+" opens the file for update whereas "rw" removes
- /// it before. So the 2 modes are different only if the
- /// file already exists).
- ///
- ///
- /// If an I/O error ocurred.
- ///
- ///
- protected internal BufferedRandomAccessFile(System.String name, System.String mode) : this(name, mode, 512)
- {
- }
-
- /// Reads a new buffer from the file. If there has been any
- /// changes made since the buffer was read, the buffer is
- /// first written to the file.
- ///
- ///
- /// The offset where to move to.
- ///
- ///
- /// If an I/O error ocurred.
- ///
- ///
- protected internal void readNewBuffer(int off)
- {
-
- /* If the buffer have changed. We need to write it to
- * the file before reading a new buffer.
- */
- if (byteBufferChanged)
- {
- flush();
- }
- // Don't allow to seek beyond end of file if reading only
- if (isReadOnly && off >= theFile.Length)
- {
- throw new System.IO.EndOfStreamException();
- }
- // Set new offset
- offset = off;
-
- theFile.Seek(offset, System.IO.SeekOrigin.Begin);
-
- maxByte = theFile.Read(byteBuffer, 0, byteBuffer.Length);
- position = 0;
-
- if (maxByte < byteBuffer.Length)
- {
- // Not enough data in input file.
- isEOFInBuffer = true;
- if (maxByte == -1)
- {
- maxByte++;
- }
- }
- else
- {
- isEOFInBuffer = false;
- }
- }
-
- /// Closes the buffered random access file
- ///
- ///
- /// If an I/O error ocurred.
- ///
- ///
- public virtual void close()
- {
- /* If the buffer has been changed, it need to be saved before
- * closing
- */
- flush();
- byteBuffer = null; // Release the byte-buffer reference
- theFile.Close();
- }
-
- /// Returns the current length of the stream, in bytes, taking into
- /// account any buffering.
- ///
- ///
- /// The length of the stream, in bytes.
- ///
- ///
- /// If an I/O error ocurred.
- ///
- ///
- public virtual int length()
- {
- int len;
-
- len = (int)theFile.Length;
-
- // If the position in the buffer is not past the end of the file,
- // the length of theFile is the length of the stream
- if ((offset + maxByte) <= len)
- {
- return (len);
- }
- else
- {
- // If not, the file is extended due to the buffering
- return (offset + maxByte);
- }
- }
-
- /// Moves the current position to the given offset at which the
- /// next read or write occurs. The offset is measured from the
- /// beginning of the stream.
- ///
- ///
- /// The offset where to move to.
- ///
- ///
- /// If in read-only and seeking beyond EOF.
- ///
- ///
- /// If an I/O error ocurred.
- ///
- ///
- public virtual void seek(int off)
- {
- /* If the new offset is within the buffer, only the pos value needs
- * to be modified. Else, the buffer must be moved. */
- if ((off >= offset) && (off < (offset + byteBuffer.Length)))
- {
- if (isReadOnly && isEOFInBuffer && off > offset + maxByte)
- {
- // We are seeking beyond EOF in read-only mode!
- throw new System.IO.EndOfStreamException();
- }
- position = off - offset;
- }
- else
- {
- readNewBuffer(off);
- }
- }
-
- /// Reads an unsigned byte of data from the stream. Prior to reading, the
- /// stream is realigned at the byte level.
- ///
- ///
- /// The byte read.
- ///
- ///
- /// If an I/O error ocurred.
- ///
- ///
- /// If the end of file was reached
- ///
- ///
- public byte readByte() { return read(); }
- public byte readUnsignedByte() { return read(); }
- public byte read()
- {
- if (position < maxByte)
- {
- // The byte can be read from the buffer
- // In Java, the bytes are always signed.
- return (byteBuffer[position++]);
- }
- else if (isEOFInBuffer)
- {
- // EOF is reached
- position = maxByte + 1; // Set position to EOF
- throw new System.IO.EndOfStreamException();
- }
- else
- {
- // End of the buffer is reached
- readNewBuffer(offset + position);
- return read();
- }
- }
-
- /// Reads up to len bytes of data from this file into an array of
- /// bytes. This method reads repeatedly from the stream until all the bytes
- /// are read. This method blocks until all the bytes are read, the end of
- /// the stream is detected, or an exception is thrown.
- ///
- ///
- /// The buffer into which the data is to be read. It must be long
- /// enough.
- ///
- ///
- /// The index in 'b' where to place the first byte read.
- ///
- ///
- /// The number of bytes to read.
- ///
- ///
- /// If the end-of file was reached before
- /// getting all the necessary data.
- ///
- ///
- /// If an I/O error ocurred.
- ///
- ///
- public void readFully(byte[] b, int off, int len)
- {
- int clen; // current length to read
- while (len > 0)
- {
- // There still is some data to read
- if (position < maxByte)
- {
- // We can read some data from buffer
- clen = maxByte - position;
- if (clen > len)
- clen = len;
- Array.Copy(byteBuffer, position, b, off, clen);
- position += clen;
- off += clen;
- len -= clen;
- }
- else if (isEOFInBuffer)
- {
- position = maxByte + 1; // Set position to EOF
- throw new System.IO.EndOfStreamException();
- }
- else
- {
- // Buffer empty => get more data
- readNewBuffer(offset + position);
- }
- }
- }
-
- /// Writes a byte to the stream. Prior to writing, the stream is
- /// realigned at the byte level.
- ///
- ///
- /// The byte to write. The lower 8 bits of b are
- /// written.
- ///
- ///
- /// If an I/O error ocurred.
- ///
- ///
- public void write(int b)
- {
- // As long as pos is less than the length of the buffer we can write
- // to the buffer. If the position is after the buffer a new buffer is
- // needed
- if (position < byteBuffer.Length)
- {
- if (isReadOnly)
- throw new System.IO.IOException("File is read only");
- byteBuffer[position] = (byte)b;
- if (position >= maxByte)
- {
- maxByte = position + 1;
- }
- position++;
- byteBufferChanged = true;
- }
- else
- {
- readNewBuffer(offset + position);
- write(b);
- }
- }
-
- /// Writes a byte to the stream. Prior to writing, the stream is
- /// realigned at the byte level.
- ///
- ///
- /// The byte to write.
- ///
- ///
- /// If an I/O error ocurred.
- ///
- ///
- public void write(byte b)
- {
- // As long as pos is less than the length of the buffer we can write
- // to the buffer. If the position is after the buffer a new buffer is
- // needed
- if (position < byteBuffer.Length)
- {
- if (isReadOnly)
- throw new System.IO.IOException("File is read only");
- byteBuffer[position] = b;
- if (position >= maxByte)
- {
- maxByte = position + 1;
- }
- position++;
- byteBufferChanged = true;
- }
- else
- {
- readNewBuffer(offset + position);
- write(b);
- }
- }
-
- /// Writes aan array of bytes to the stream. Prior to writing, the stream is
- /// realigned at the byte level.
- ///
- ///
- /// The array of bytes to write.
- ///
- ///
- /// The first byte in b to write
- ///
- ///
- /// The number of bytes from b to write
- ///
- ///
- /// If an I/O error ocurred.
- ///
- ///
- public void write(byte[] b, int offset, int length)
- {
- int i, stop;
- stop = offset + length;
- if (stop > b.Length)
- throw new System.IndexOutOfRangeException("Index of bound " + b.Length);
- for (i = offset; i < stop; i++)
- {
- write(b[i]);
- }
- }
-
- /// Writes the byte value of v (i.e., 8 least
- /// significant bits) to the output. Prior to writing, the output
- /// should be realigned at the byte level.
- ///
- /// Signed or unsigned data can be written. To write a signed
- /// value just pass the byte value as an argument. To
- /// write unsigned data pass the int value as an argument
- /// (it will be automatically casted, and only the 8 least
- /// significant bits will be written).
- ///
- ///
- /// The value to write to the output
- ///
- ///
- /// If an I/O error ocurred.
- ///
- ///
- public void writeByte(int v)
- {
- write(v);
- }
-
- /// Any data that has been buffered must be written (including
- /// buffering at the bit level), and the stream should be realigned
- /// at the byte level.
- ///
- ///
- /// If an I/O error ocurred.
- ///
- ///
- public void flush()
- {
- if (byteBufferChanged)
- {
- theFile.Seek(offset, System.IO.SeekOrigin.Begin);
- theFile.Write(byteBuffer, 0, maxByte);
- byteBufferChanged = false;
- }
- }
- /*
- /// Reads a signed byte (i.e., 8 bit) from the input. Prior to
- /// reading, the input should be realigned at the byte level.
- ///
- ///
- /// The next byte-aligned signed byte (8 bit) from the
- /// input.
- ///
- ///
- /// If the end-of file was reached before
- /// getting all the necessary data.
- ///
- ///
- /// If an I/O error ocurred.
- ///
- ///
- public byte readByte()
- {
- if (pos < maxByte)
- {
- // The byte can be read from the buffer
- // In Java, the bytes are always signed.
- return byteBuffer[pos++];
- }
- else if (isEOFInBuffer)
- {
- // EOF is reached
- pos = maxByte + 1; // Set position to EOF
- throw new System.IO.EndOfStreamException();
- }
- else
- {
- // End of the buffer is reached
- readNewBuffer(offset + pos);
- return readByte();
- }
- }
-
- /// Reads an unsigned byte (i.e., 8 bit) from the input. It is
- /// returned as an int since Java does not have an
- /// unsigned byte type. Prior to reading, the input should be
- /// realigned at the byte level.
- ///
- ///
- /// The next byte-aligned unsigned byte (8 bit) from the
- /// input, as an int.
- ///
- ///
- /// If the end-of file was reached before
- /// getting all the necessary data.
- ///
- ///
- /// If an I/O error ocurred.
- ///
- ///
- public int readUnsignedByte()
- {
- return read();
- }
- */
- /// Skips n bytes from the input. Prior to skipping, the
- /// input should be realigned at the byte level.
- ///
- ///
- /// The number of bytes to skip
- ///
- ///
- /// If the end-of file was reached before
- /// all the bytes could be skipped.
- ///
- ///
- /// If an I/O error ocurred.
- ///
- ///
- public virtual int skipBytes(int n)
- {
- if (n < 0)
- throw new System.ArgumentException("Can not skip negative number " + "of bytes");
- if (n <= (maxByte - position))
- {
- position += n;
- return n;
- }
- else
- {
- seek(offset + position + n);
- return n;
- }
- }
-
- /// Returns a string of information about the file
- ///
- ///
- public override System.String ToString()
- {
- return "BufferedRandomAccessFile: " + fileName + " (" + ((isReadOnly) ? "read only" : "read/write") + ")";
- }
- public abstract int readUnsignedShort();
- public abstract void writeLong(long param1);
- public abstract void writeShort(int param1);
- public abstract float readFloat();
- public abstract short readShort();
- public abstract double readDouble();
- public abstract int readInt();
- public abstract long readLong();
- public abstract long readUnsignedInt();
- public abstract void writeDouble(double param1);
- public abstract void writeFloat(float param1);
- public abstract void writeInt(int param1);
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/io/EndianType.cs b/CSJ2K/j2k/io/EndianType.cs
deleted file mode 100644
index 8d06f719..00000000
--- a/CSJ2K/j2k/io/EndianType.cs
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
-* CVS Identifier:
-*
-* $Id: EndianType.java,v 1.10 2000/09/05 09:24:36 grosbois Exp $
-*
-* Interface: EndianType
-*
-* Description: Defines the two types of endianess (i.e. byte
-* ordering).
-*
-*
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-*
-*
-*
-*/
-namespace CSJ2K.j2k.io
-{
-
- /// This interface defines constants for the two types of byte
- /// ordering: little- and big-endian.
- ///
- /// Little-endian is least significant byte first.
- ///
- ///
Big-endian is most significant byte first.
- ///
- ///
This interface defines the constants only. In order to use the
- /// constants in any other class you can either use the fully qualified
- /// name (e.g., EndianType.LITTLE_ENDIAN) or declare this
- /// interface in the implements clause of the class and then access the
- /// identifier directly.
- ///
- ///
- public struct EndianType_Fields
- {
- /// Identifier for big-endian byte ordering (i.e. most significant
- /// byte first)
- ///
- public const int BIG_ENDIAN = 0;
- /// Identifier for little-endian byte ordering (i.e. least
- /// significant byte first)
- ///
- public const int LITTLE_ENDIAN = 1;
- }
- public interface EndianType
- {
- //UPGRADE_NOTE: Members of interface 'EndianType' were extracted into structure 'EndianType_Fields'. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1045'"
-
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/io/RandomAccessIO.cs b/CSJ2K/j2k/io/RandomAccessIO.cs
deleted file mode 100644
index bbefedc4..00000000
--- a/CSJ2K/j2k/io/RandomAccessIO.cs
+++ /dev/null
@@ -1,170 +0,0 @@
-/*
-* CVS Identifier:
-*
-* $Id: RandomAccessIO.java,v 1.15 2001/10/24 12:07:02 grosbois Exp $
-*
-* Interface: RandomAccessIO.java
-*
-* Description: Interface definition for random access I/O.
-*
-*
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-* */
-namespace CSJ2K.j2k.io
-{
-
- /// This abstract class defines the interface to perform random access I/O. It
- /// implements the BinaryDataInput and BinaryDataOutput
- /// interfaces so that binary data input/output can be performed.
- ///
- /// This interface supports streams of up to 2 GB in length.
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- public interface RandomAccessIO : BinaryDataInput, BinaryDataOutput
- {
- /// Returns the current position in the stream, which is the position from
- /// where the next byte of data would be read. The first byte in the stream
- /// is in position 0.
- ///
- ///
- /// The offset of the current position, in bytes.
- ///
- ///
- /// If an I/O error ocurred.
- ///
- ///
- int Pos
- {
- get;
-
- }
-
- /// Closes the I/O stream. Prior to closing the stream, any buffered data
- /// (at the bit and byte level) should be written.
- ///
- ///
- /// If an I/O error ocurred.
- ///
- ///
- void close();
-
- /// Returns the current length of the stream, in bytes, taking into account
- /// any buffering.
- ///
- ///
- /// The length of the stream, in bytes.
- ///
- ///
- /// If an I/O error ocurred.
- ///
- ///
- int length();
-
- /// Moves the current position for the next read or write operation to
- /// offset. The offset is measured from the beginning of the stream. The
- /// offset may be set beyond the end of the file, if in write mode. Setting
- /// the offset beyond the end of the file does not change the file
- /// length. The file length will change only by writing after the offset
- /// has been set beyond the end of the file.
- ///
- ///
- /// The offset where to move to.
- ///
- ///
- /// If in read-only and seeking beyond EOF.
- ///
- ///
- /// If an I/O error ocurred.
- ///
- ///
- void seek(int off);
-
- /// Reads a byte of data from the stream. Prior to reading, the stream is
- /// realigned at the byte level.
- ///
- ///
- /// The byte read, as an int.
- ///
- ///
- /// If the end-of file was reached.
- ///
- ///
- /// If an I/O error ocurred.
- ///
- ///
- byte read();
-
- /// Reads up to len bytes of data from this file into an array of
- /// bytes. This method reads repeatedly from the stream until all the bytes
- /// are read. This method blocks until all the bytes are read, the end of
- /// the stream is detected, or an exception is thrown.
- ///
- ///
- /// The buffer into which the data is to be read. It must be long
- /// enough.
- ///
- ///
- /// The index in 'b' where to place the first byte read.
- ///
- ///
- /// The number of bytes to read.
- ///
- ///
- /// If the end-of file was reached before
- /// getting all the necessary data.
- ///
- ///
- /// If an I/O error ocurred.
- ///
- ///
- void readFully(byte[] b, int off, int len);
-
- /// Writes a byte to the stream. Prior to writing, the stream is realigned
- /// at the byte level.
- ///
- ///
- /// The byte to write. The lower 8 bits of b are
- /// written.
- ///
- ///
- /// If an I/O error ocurred.
- ///
- ///
- void write(byte b);
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/quantization/GuardBitsSpec.cs b/CSJ2K/j2k/quantization/GuardBitsSpec.cs
deleted file mode 100644
index d2fe55a0..00000000
--- a/CSJ2K/j2k/quantization/GuardBitsSpec.cs
+++ /dev/null
@@ -1,249 +0,0 @@
-/*
-* CVS identifier:
-*
-* $Id: GuardBitsSpec.java,v 1.13 2000/09/19 14:11:01 grosbois Exp $
-*
-* Class: GuardBitsSpec
-*
-* Description: Guard bits specifications
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-*
-*
-*
-*/
-using CSJ2K.j2k.util;
-namespace CSJ2K.j2k.quantization
-{
-
- /// This class extends ModuleSpec class in order to hold specifications about
- /// number of guard bits in each tile-component.
- ///
- ///
- ///
- ///
- ///
- public class GuardBitsSpec : ModuleSpec
- {
-
- /// Constructs an empty 'GuardBitsSpec' with specified number of tile and
- /// components. This constructor is called by the decoder.
- ///
- ///
- /// Number of tiles
- ///
- ///
- /// Number of components
- ///
- ///
- /// the type of the specification module i.e. tile specific,
- /// component specific or both.
- ///
- ///
- public GuardBitsSpec(int nt, int nc, byte type) : base(nt, nc, type)
- {
- }
-
- /// Constructs a new 'GuardBitsSpec' for the specified number of components
- /// and tiles and the arguments of "-Qguard_bits" option.
- ///
- ///
- /// The number of tiles
- ///
- ///
- /// The number of components
- ///
- ///
- /// the type of the specification module i.e. tile specific,
- /// component specific or both.
- ///
- ///
- /// The ParameterList
- ///
- ///
- public GuardBitsSpec(int nt, int nc, byte type, ParameterList pl) : base(nt, nc, type)
- {
-
- System.String param = pl.getParameter("Qguard_bits");
- if (param == null)
- {
- throw new System.ArgumentException("Qguard_bits option not " + "specified");
- }
-
- // Parse argument
- SupportClass.Tokenizer stk = new SupportClass.Tokenizer(param);
- System.String word; // current word
- byte curSpecType = SPEC_DEF; // Specification type of the
- // current parameter
- bool[] tileSpec = null; // Tiles concerned by the specification
- bool[] compSpec = null; // Components concerned by the specification
- System.Int32 value_Renamed; // value of the guard bits
-
- while (stk.HasMoreTokens())
- {
- word = stk.NextToken().ToLower();
-
- switch (word[0])
- {
-
- case 't': // Tiles specification
- tileSpec = parseIdx(word, nTiles);
- if (curSpecType == SPEC_COMP_DEF)
- curSpecType = SPEC_TILE_COMP;
- else
- curSpecType = SPEC_TILE_DEF;
- break;
-
- case 'c': // Components specification
- compSpec = parseIdx(word, nComp);
- if (curSpecType == SPEC_TILE_DEF)
- curSpecType = SPEC_TILE_COMP;
- else
- curSpecType = SPEC_COMP_DEF;
- break;
-
- default: // Step size value
- try
- {
- value_Renamed = System.Int32.Parse(word);
- }
- catch (System.FormatException)
- {
- throw new System.ArgumentException("Bad parameter for " + "-Qguard_bits option" + " : " + word);
- }
-
- if ((float)value_Renamed <= 0.0f)
- {
- throw new System.ArgumentException("Guard bits value " + "must be positive : " + value_Renamed);
- }
-
-
- if (curSpecType == SPEC_DEF)
- {
- setDefault((System.Object)value_Renamed);
- }
- else if (curSpecType == SPEC_TILE_DEF)
- {
- for (int i = tileSpec.Length - 1; i >= 0; i--)
- if (tileSpec[i])
- {
- setTileDef(i, (System.Object)value_Renamed);
- }
- }
- else if (curSpecType == SPEC_COMP_DEF)
- {
- for (int i = compSpec.Length - 1; i >= 0; i--)
- if (compSpec[i])
- {
- setCompDef(i, (System.Object)value_Renamed);
- }
- }
- else
- {
- for (int i = tileSpec.Length - 1; i >= 0; i--)
- {
- for (int j = compSpec.Length - 1; j >= 0; j--)
- {
- if (tileSpec[i] && compSpec[j])
- {
- setTileCompVal(i, j, (System.Object)value_Renamed);
- }
- }
- }
- }
-
- // Re-initialize
- curSpecType = SPEC_DEF;
- tileSpec = null;
- compSpec = null;
- break;
-
- }
- }
-
- // Check that default value has been specified
- if (getDefault() == null)
- {
- int ndefspec = 0;
- for (int t = nt - 1; t >= 0; t--)
- {
- for (int c = nc - 1; c >= 0; c--)
- {
- if (specValType[t][c] == SPEC_DEF)
- {
- ndefspec++;
- }
- }
- }
-
- // If some tile-component have received no specification, it takes
- // the default value defined in ParameterList
- if (ndefspec != 0)
- {
- setDefault((System.Object)System.Int32.Parse(pl.DefaultParameterList.getParameter("Qguard_bits")));
- }
- else
- {
- // All tile-component have been specified, takes the first
- // tile-component value as default.
- setDefault(getTileCompVal(0, 0));
- switch (specValType[0][0])
- {
-
- case SPEC_TILE_DEF:
- for (int c = nc - 1; c >= 0; c--)
- {
- if (specValType[0][c] == SPEC_TILE_DEF)
- specValType[0][c] = SPEC_DEF;
- }
- tileDef[0] = null;
- break;
-
- case SPEC_COMP_DEF:
- for (int t = nt - 1; t >= 0; t--)
- {
- if (specValType[t][0] == SPEC_COMP_DEF)
- specValType[t][0] = SPEC_DEF;
- }
- compDef[0] = null;
- break;
-
- case SPEC_TILE_COMP:
- specValType[0][0] = SPEC_DEF;
- tileCompVal["t0c0"] = null;
- break;
- }
- }
- }
- }
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/quantization/QuantStepSizeSpec.cs b/CSJ2K/j2k/quantization/QuantStepSizeSpec.cs
deleted file mode 100644
index 31dd3c8d..00000000
--- a/CSJ2K/j2k/quantization/QuantStepSizeSpec.cs
+++ /dev/null
@@ -1,252 +0,0 @@
-/*
-* CVS identifier:
-*
-* $Id: QuantStepSizeSpec.java,v 1.12 2001/10/24 12:05:04 grosbois Exp $
-*
-* Class: QuantStepSizeSpec
-*
-* Description: Quantization base normalized step size specifications
-*
-*
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-* */
-using CSJ2K.j2k.util;
-namespace CSJ2K.j2k.quantization
-{
-
- /// This class extends ModuleSpec class in order to hold specifications about
- /// the quantization base normalized step size to use in each tile-component.
- ///
- ///
- ///
- ///
- ///
- public class QuantStepSizeSpec : ModuleSpec
- {
-
- /// Constructs an empty 'QuantStepSizeSpec' with specified number of
- /// tile and components. This constructor is called by the decoder.
- ///
- ///
- /// Number of tiles
- ///
- ///
- /// Number of components
- ///
- ///
- /// the type of the specification module i.e. tile specific,
- /// component specific or both.
- ///
- ///
- public QuantStepSizeSpec(int nt, int nc, byte type) : base(nt, nc, type)
- {
- }
-
- /// Constructs a new 'QuantStepSizeSpec' for the specified number of
- /// components and tiles and the arguments of "-Qstep" option.
- ///
- ///
- /// The number of tiles
- ///
- ///
- /// The number of components
- ///
- ///
- /// the type of the specification module i.e. tile specific,
- /// component specific or both.
- ///
- ///
- /// The ParameterList
- ///
- ///
- public QuantStepSizeSpec(int nt, int nc, byte type, ParameterList pl) : base(nt, nc, type)
- {
-
- System.String param = pl.getParameter("Qstep");
- if (param == null)
- {
- throw new System.ArgumentException("Qstep option not specified");
- }
-
- // Parse argument
- SupportClass.Tokenizer stk = new SupportClass.Tokenizer(param);
- System.String word; // current word
- byte curSpecType = SPEC_DEF; // Specification type of the
- // current parameter
- bool[] tileSpec = null; // Tiles concerned by the specification
- bool[] compSpec = null; // Components concerned by the specification
- System.Single value_Renamed; // value of the current step size
-
- while (stk.HasMoreTokens())
- {
- word = stk.NextToken().ToLower();
-
- switch (word[0])
- {
-
- case 't': // Tiles specification
- tileSpec = parseIdx(word, nTiles);
- if (curSpecType == SPEC_COMP_DEF)
- curSpecType = SPEC_TILE_COMP;
- else
- curSpecType = SPEC_TILE_DEF;
- break;
-
- case 'c': // Components specification
- compSpec = parseIdx(word, nComp);
- if (curSpecType == SPEC_TILE_DEF)
- curSpecType = SPEC_TILE_COMP;
- else
- curSpecType = SPEC_COMP_DEF;
- break;
-
- default: // Step size value
- try
- {
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- value_Renamed = System.Single.Parse(word);
- }
- catch (System.FormatException)
- {
- throw new System.ArgumentException("Bad parameter for " + "-Qstep option : " + word);
- }
-
- //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Float.floatValue' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'"
- if ((float)value_Renamed <= 0.0f)
- {
- //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Float.toString' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'"
- throw new System.ArgumentException("Normalized base step " + "must be positive : " + value_Renamed);
- }
-
-
- if (curSpecType == SPEC_DEF)
- {
- setDefault((System.Object)value_Renamed);
- }
- else if (curSpecType == SPEC_TILE_DEF)
- {
- for (int i = tileSpec.Length - 1; i >= 0; i--)
- if (tileSpec[i])
- {
- setTileDef(i, (System.Object)value_Renamed);
- }
- }
- else if (curSpecType == SPEC_COMP_DEF)
- {
- for (int i = compSpec.Length - 1; i >= 0; i--)
- if (compSpec[i])
- {
- setCompDef(i, (System.Object)value_Renamed);
- }
- }
- else
- {
- for (int i = tileSpec.Length - 1; i >= 0; i--)
- {
- for (int j = compSpec.Length - 1; j >= 0; j--)
- {
- if (tileSpec[i] && compSpec[j])
- {
- setTileCompVal(i, j, (System.Object)value_Renamed);
- }
- }
- }
- }
-
- // Re-initialize
- curSpecType = SPEC_DEF;
- tileSpec = null;
- compSpec = null;
- break;
-
- }
- }
-
- // Check that default value has been specified
- if (getDefault() == null)
- {
- int ndefspec = 0;
- for (int t = nt - 1; t >= 0; t--)
- {
- for (int c = nc - 1; c >= 0; c--)
- {
- if (specValType[t][c] == SPEC_DEF)
- {
- ndefspec++;
- }
- }
- }
-
- // If some tile-component have received no specification, it takes
- // the default value defined in ParameterList
- if (ndefspec != 0)
- {
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- setDefault((System.Object)System.Single.Parse(pl.DefaultParameterList.getParameter("Qstep")));
- }
- else
- {
- // All tile-component have been specified, takes the first
- // tile-component value as default.
- setDefault(getTileCompVal(0, 0));
- switch (specValType[0][0])
- {
-
- case SPEC_TILE_DEF:
- for (int c = nc - 1; c >= 0; c--)
- {
- if (specValType[0][c] == SPEC_TILE_DEF)
- specValType[0][c] = SPEC_DEF;
- }
- tileDef[0] = null;
- break;
-
- case SPEC_COMP_DEF:
- for (int t = nt - 1; t >= 0; t--)
- {
- if (specValType[t][0] == SPEC_COMP_DEF)
- specValType[t][0] = SPEC_DEF;
- }
- compDef[0] = null;
- break;
-
- case SPEC_TILE_COMP:
- specValType[0][0] = SPEC_DEF;
- tileCompVal["t0c0"] = null;
- break;
- }
- }
- }
- }
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/quantization/QuantTypeSpec.cs b/CSJ2K/j2k/quantization/QuantTypeSpec.cs
deleted file mode 100644
index 142bf208..00000000
--- a/CSJ2K/j2k/quantization/QuantTypeSpec.cs
+++ /dev/null
@@ -1,390 +0,0 @@
-/*
-* CVS identifier:
-*
-* $Id: QuantTypeSpec.java,v 1.18 2001/10/24 12:05:18 grosbois Exp $
-*
-* Class: QuantTypeSpec
-*
-* Description: Quantization type specifications
-*
-*
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-* */
-using CSJ2K.j2k.util;
-namespace CSJ2K.j2k.quantization
-{
-
- /// This class extends ModuleSpec class in order to hold specifications about
- /// the quantization type to use in each tile-component. Supported quantization
- /// type are:
- ///
- ///
- /// - Reversible (no quantization)
- /// - Derived (the quantization step size is derived from the one of the
- /// LL-subband)
- /// - Expounded (the quantization step size of each subband is signalled in
- /// the codestream headers)
- ///
- ///
- ///
- ///
- ///
- ///
- public class QuantTypeSpec : ModuleSpec
- {
- /// Check the reversibility of the whole image.
- ///
- ///
- /// Whether or not the whole image is reversible
- ///
- ///
- virtual public bool FullyReversible
- {
- get
- {
- // The whole image is reversible if default specification is
- // rev and no tile default, component default and
- // tile-component value has been specificied
- if (((System.String)getDefault()).Equals("reversible"))
- {
- for (int t = nTiles - 1; t >= 0; t--)
- for (int c = nComp - 1; c >= 0; c--)
- if (specValType[t][c] != SPEC_DEF)
- return false;
- return true;
- }
-
- return false;
- }
-
- }
- /// Check the irreversibility of the whole image.
- ///
- ///
- /// Whether or not the whole image is reversible
- ///
- ///
- virtual public bool FullyNonReversible
- {
- get
- {
- // The whole image is irreversible no tile-component is reversible
- for (int t = nTiles - 1; t >= 0; t--)
- for (int c = nComp - 1; c >= 0; c--)
- if (((System.String)getSpec(t, c)).Equals("reversible"))
- return false;
- return true;
- }
-
- }
-
- /// Constructs an empty 'QuantTypeSpec' with the specified number of tiles
- /// and components. This constructor is called by the decoder.
- ///
- ///
- /// Number of tiles
- ///
- ///
- /// Number of components
- ///
- ///
- /// the type of the allowed specifications for this module
- /// i.e. tile specific, component specific or both.
- ///
- ///
- public QuantTypeSpec(int nt, int nc, byte type) : base(nt, nc, type)
- {
- }
-
-
- /// Constructs a new 'QuantTypeSpec' for the specified number of components
- /// and tiles and the arguments of "-Qtype" option. This constructor is
- /// called by the encoder.
- ///
- ///
- /// The number of tiles
- ///
- ///
- /// The number of components
- ///
- ///
- /// the type of the specification module i.e. tile specific,
- /// component specific or both.
- ///
- ///
- /// The ParameterList
- ///
- ///
- public QuantTypeSpec(int nt, int nc, byte type, ParameterList pl) : base(nt, nc, type)
- {
-
- System.String param = pl.getParameter("Qtype");
- if (param == null)
- {
- if (pl.getBooleanParameter("lossless"))
- {
- setDefault("reversible");
- }
- else
- {
- setDefault("expounded");
- }
- return;
- }
-
- // Parse argument
- SupportClass.Tokenizer stk = new SupportClass.Tokenizer(param);
- System.String word; // current word
- byte curSpecValType = SPEC_DEF; // Specification type of the
- // current parameter
- bool[] tileSpec = null; // Tiles concerned by the specification
- bool[] compSpec = null; // Components concerned by the specification
-
- while (stk.HasMoreTokens())
- {
- word = stk.NextToken().ToLower();
-
- switch (word[0])
- {
-
- case 't': // Tiles specification
- tileSpec = parseIdx(word, nTiles);
-
- if (curSpecValType == SPEC_COMP_DEF)
- {
- curSpecValType = SPEC_TILE_COMP;
- }
- else
- {
- curSpecValType = SPEC_TILE_DEF;
- }
- break;
-
- case 'c': // Components specification
- compSpec = parseIdx(word, nComp);
-
- if (curSpecValType == SPEC_TILE_DEF)
- {
- curSpecValType = SPEC_TILE_COMP;
- }
- else
- {
- curSpecValType = SPEC_COMP_DEF;
- }
- break;
-
- case 'r':
- // reversible specification
- case 'd':
- // derived quantization step size specification
- case 'e': // expounded quantization step size specification
- if (!word.ToUpper().Equals("reversible".ToUpper()) && !word.ToUpper().Equals("derived".ToUpper()) && !word.ToUpper().Equals("expounded".ToUpper()))
- {
- throw new System.ArgumentException("Unknown parameter " + "for " + "'-Qtype' option: " + word);
- }
-
- if (pl.getBooleanParameter("lossless") && (word.ToUpper().Equals("derived".ToUpper()) || word.ToUpper().Equals("expounded".ToUpper())))
- {
- throw new System.ArgumentException("Cannot use non " + "reversible " + "quantization with " + "'-lossless' option");
- }
-
- if (curSpecValType == SPEC_DEF)
- {
- // Default specification
- setDefault(word);
- }
- else if (curSpecValType == SPEC_TILE_DEF)
- {
- // Tile default specification
- for (int i = tileSpec.Length - 1; i >= 0; i--)
- {
- if (tileSpec[i])
- {
- setTileDef(i, word);
- }
- }
- }
- else if (curSpecValType == SPEC_COMP_DEF)
- {
- // Component default specification
- for (int i = compSpec.Length - 1; i >= 0; i--)
- if (compSpec[i])
- {
- setCompDef(i, word);
- }
- }
- else
- {
- // Tile-component specification
- for (int i = tileSpec.Length - 1; i >= 0; i--)
- {
- for (int j = compSpec.Length - 1; j >= 0; j--)
- {
- if (tileSpec[i] && compSpec[j])
- {
- setTileCompVal(i, j, word);
- }
- }
- }
- }
-
- // Re-initialize
- curSpecValType = SPEC_DEF;
- tileSpec = null;
- compSpec = null;
- break;
-
-
- default:
- throw new System.ArgumentException("Unknown parameter for " + "'-Qtype' option: " + word);
-
- }
- }
-
- // Check that default value has been specified
- if (getDefault() == null)
- {
- int ndefspec = 0;
- for (int t = nt - 1; t >= 0; t--)
- {
- for (int c = nc - 1; c >= 0; c--)
- {
- if (specValType[t][c] == SPEC_DEF)
- {
- ndefspec++;
- }
- }
- }
-
- // If some tile-component have received no specification, the
- // quantization type is 'reversible' (if '-lossless' is specified)
- // or 'expounded' (if not).
- if (ndefspec != 0)
- {
- if (pl.getBooleanParameter("lossless"))
- {
- setDefault("reversible");
- }
- else
- {
- setDefault("expounded");
- }
- }
- else
- {
- // All tile-component have been specified, takes arbitrarily
- // the first tile-component value as default and modifies the
- // specification type of all tile-component sharing this
- // value.
- setDefault(getTileCompVal(0, 0));
-
- switch (specValType[0][0])
- {
-
- case SPEC_TILE_DEF:
- for (int c = nc - 1; c >= 0; c--)
- {
- if (specValType[0][c] == SPEC_TILE_DEF)
- specValType[0][c] = SPEC_DEF;
- }
- tileDef[0] = null;
- break;
-
- case SPEC_COMP_DEF:
- for (int t = nt - 1; t >= 0; t--)
- {
- if (specValType[t][0] == SPEC_COMP_DEF)
- specValType[t][0] = SPEC_DEF;
- }
- compDef[0] = null;
- break;
-
- case SPEC_TILE_COMP:
- specValType[0][0] = SPEC_DEF;
- tileCompVal["t0c0"] = null;
- break;
- }
- }
- }
- }
-
- /// Returns true if given tile-component uses derived quantization step
- /// size.
- ///
- ///
- /// Tile index
- ///
- ///
- /// Component index
- ///
- ///
- /// True if derived quantization step size
- ///
- ///
- public virtual bool isDerived(int t, int c)
- {
- if (((System.String)getTileCompVal(t, c)).Equals("derived"))
- {
- return true;
- }
- else
- {
- return false;
- }
- }
-
- /// Check the reversibility of the given tile-component.
- ///
- ///
- /// The index of the tile
- ///
- ///
- /// The index of the component
- ///
- ///
- /// Whether or not the tile-component is reversible
- ///
- ///
- public virtual bool isReversible(int t, int c)
- {
- if (((System.String)getTileCompVal(t, c)).Equals("reversible"))
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/quantization/QuantizationType.cs b/CSJ2K/j2k/quantization/QuantizationType.cs
deleted file mode 100644
index 255d692d..00000000
--- a/CSJ2K/j2k/quantization/QuantizationType.cs
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
-* CVS identifier:
-*
-* $Id: QuantizationType.java,v 1.10 2000/09/19 14:11:30 grosbois Exp $
-*
-* Class: QuantizationType
-*
-* Description: This interface defines the possible
-* quantization types.
-*
-*
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-*
-*
-*
-*/
-namespace CSJ2K.j2k.quantization
-{
-
- /// This interface defines the IDs of the possible quantization types. JPEG
- /// 2000 part I support only the scalar quantization with dead zone. However
- /// other quantization type may be defined in JPEG 2000 extensions (for
- /// instance Trellis Coded Quantization).
- ///
- /// This interface defines the constants only. In order to use the
- /// constants in any other class you can either use the fully qualified
- /// name (e.g., QuantizationType.Q_TYPE_SCALAR_DZ) or declare
- /// this interface in the implements clause of the class and then
- /// access the identifier directly.
- ///
- ///
- public struct QuantizationType_Fields
- {
- /// The ID of the scalar deadzone dequantizer
- public readonly static int Q_TYPE_SCALAR_DZ = 0;
- }
- public interface QuantizationType
- {
- //UPGRADE_NOTE: Members of interface 'QuantizationType' were extracted into structure 'QuantizationType_Fields'. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1045'"
-
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/quantization/dequantizer/CBlkQuantDataSrcDec.cs b/CSJ2K/j2k/quantization/dequantizer/CBlkQuantDataSrcDec.cs
deleted file mode 100644
index 70348fda..00000000
--- a/CSJ2K/j2k/quantization/dequantizer/CBlkQuantDataSrcDec.cs
+++ /dev/null
@@ -1,185 +0,0 @@
-/*
-* CVS identifier:
-*
-* $Id: CBlkQuantDataSrcDec.java,v 1.9 2001/09/14 08:58:36 grosbois Exp $
-*
-* Class: CBlkQuantDataSrcDec
-*
-* Description: Interface that defines a source of
-* quantized wavelet data to be transferred in a
-* code-block by code-block basis (decoder side).
-*
-*
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-* */
-using CSJ2K.j2k.entropy.decoder;
-using CSJ2K.j2k.image;
-using CSJ2K.j2k.wavelet.synthesis;
-namespace CSJ2K.j2k.quantization.dequantizer
-{
-
- /// This interface defines a source of quantized wavelet coefficients and
- /// methods to transfer them in a code-block by code-block basis, fro the
- /// decoder side. In each call to 'getCodeBlock()' or 'getInternCodeBlock()' a
- /// new code-block is returned.
- ///
- /// This class is the source of data for the dequantizer. See the
- /// 'Dequantizer' class.
- ///
- ///
Code-block data is returned in sign-magnitude representation, instead of
- /// the normal two's complement one. Only integral types are used. The sign
- /// magnitude representation is more adequate for entropy coding. In sign
- /// magnitude representation, the most significant bit is used for the sign (0
- /// if positive, 1 if negative) and the magnitude of the coefficient is stored
- /// in the next M most significant bits. The rest of the bits (least
- /// significant bits) can contain a fractional value of the quantized
- /// coefficient. The number 'M' of magnitude bits is communicated in the
- /// 'magbits' member variable of the 'CBlkWTData'.
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- public interface CBlkQuantDataSrcDec : InvWTData
- {
-
- /// Returns the specified code-block in the current tile for the specified
- /// component, as a copy (see below).
- ///
- /// The returned code-block may be progressive, which is indicated by
- /// the 'progressive' variable of the returned 'DataBlk' object. If a
- /// code-block is progressive it means that in a later request to this
- /// method for the same code-block it is possible to retrieve data which is
- /// a better approximation, since meanwhile more data to decode for the
- /// code-block could have been received. If the code-block is not
- /// progressive then later calls to this method for the same code-block
- /// will return the exact same data values.
- ///
- /// The data returned by this method is always a copy of the internal
- /// data of this object, if any, and it can be modified "in place" without
- /// any problems after being returned. The 'offset' of the returned data is
- /// 0, and the 'scanw' is the same as the code-block width. See the
- /// 'DataBlk' class.
- ///
- /// The 'ulx' and 'uly' members of the returned 'DataBlk' object contain
- /// the coordinates of the top-left corner of the block, with respect to
- /// the tile, not the subband.
- ///
- ///
- /// The component for which to return the next code-block.
- ///
- ///
- /// The vertical index of the code-block to return, in the
- /// specified subband.
- ///
- ///
- /// The horizontal index of the code-block to return, in the
- /// specified subband.
- ///
- ///
- /// The subband in which the code-block to return is.
- ///
- ///
- /// If non-null this object will be used to return the new
- /// code-block. If null a new one will be allocated and returned. If the
- /// "data" array of the object is non-null it will be reused, if possible,
- /// to return the data.
- ///
- ///
- /// The next code-block in the current tile for component 'n', or
- /// null if all code-blocks for the current tile have been returned.
- ///
- ///
- ///
- ///
- ///
- DataBlk getCodeBlock(int c, int m, int n, SubbandSyn sb, DataBlk cblk);
-
- /// Returns the specified code-block in the current tile for the specified
- /// component (as a reference or copy).
- ///
- /// The returned code-block may be progressive, which is indicated by
- /// the 'progressive' variable of the returned 'DataBlk' object. If a
- /// code-block is progressive it means that in a later request to this
- /// method for the same code-block it is possible to retrieve data which is
- /// a better approximation, since meanwhile more data to decode for the
- /// code-block could have been received. If the code-block is not
- /// progressive then later calls to this method for the same code-block
- /// will return the exact same data values.
- ///
- /// The data returned by this method can be the data in the internal
- /// buffer of this object, if any, and thus can not be modified by the
- /// caller. The 'offset' and 'scanw' of the returned data can be
- /// arbitrary. See the 'DataBlk' class.
- ///
- /// The 'ulx' and 'uly' members of the returned 'DataBlk' object contain
- /// the coordinates of the top-left corner of the block, with respect to
- /// the tile, not the subband.
- ///
- ///
- /// The component for which to return the next code-block.
- ///
- ///
- /// The vertical index of the code-block to return, in the
- /// specified subband.
- ///
- ///
- /// The horizontal index of the code-block to return, in the
- /// specified subband.
- ///
- ///
- /// The subband in which the code-block to return is.
- ///
- ///
- /// If non-null this object will be used to return the new
- /// code-block. If null a new one will be allocated and returned. If the
- /// "data" array of the object is non-null it will be reused, if possible,
- /// to return the data.
- ///
- ///
- /// The next code-block in the current tile for component 'n', or
- /// null if all code-blocks for the current tile have been returned.
- ///
- ///
- ///
- ///
- ///
- DataBlk getInternCodeBlock(int c, int m, int n, SubbandSyn sb, DataBlk cblk);
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/quantization/dequantizer/Dequantizer.cs b/CSJ2K/j2k/quantization/dequantizer/Dequantizer.cs
deleted file mode 100644
index 64f5c5e5..00000000
--- a/CSJ2K/j2k/quantization/dequantizer/Dequantizer.cs
+++ /dev/null
@@ -1,339 +0,0 @@
-/*
-* CVS identifier:
-*
-* $Id: Dequantizer.java,v 1.37 2001/10/29 20:07:28 qtxjoas Exp $
-*
-* Class: Dequantizer
-*
-* Description: The abstract class for all dequantizers.
-*
-*
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-* */
-using CSJ2K.j2k.decoder;
-using CSJ2K.j2k.image;
-using CSJ2K.j2k.image.invcomptransf;
-using CSJ2K.j2k.wavelet;
-using CSJ2K.j2k.wavelet.synthesis;
-namespace CSJ2K.j2k.quantization.dequantizer
-{
-
- /// This is the abstract class from which all dequantizers must inherit. This
- /// class has the concept of a current tile and all operations are performed on
- /// the current tile.
- ///
- /// This class provides default implemenations for most of the methods
- /// (wherever it makes sense), under the assumption that the image and
- /// component dimensions, and the tiles, are not modifed by the dequantizer. If
- /// that is not the case for a particular implementation then the methods
- /// should be overriden.
- ///
- /// Sign magnitude representation is used (instead of two's complement) for
- /// the input data. The most significant bit is used for the sign (0 if
- /// positive, 1 if negative). Then the magnitude of the quantized coefficient
- /// is stored in the next most significat bits. The most significant magnitude
- /// bit corresponds to the most significant bit-plane and so on.
- ///
- /// The output data is either in floating-point, or in fixed-point two's
- /// complement. In case of floating-point data the the value returned by
- /// getFixedPoint() must be 0. If the case of fixed-point data the number of
- /// fractional bits must be defined at the constructor of the implementing
- /// class and all operations must be performed accordingly. Each component may
- /// have a different number of fractional bits.
- ///
- ///
- public abstract class Dequantizer : MultiResImgDataAdapter, CBlkWTDataSrcDec
- {
- /// Returns the horizontal code-block partition origin. Allowable values
- /// are 0 and 1, nothing else.
- ///
- ///
- virtual public int CbULX
- {
- get
- {
- return src.CbULX;
- }
-
- }
- /// Returns the vertical code-block partition origin. Allowable values are
- /// 0 and 1, nothing else.
- ///
- ///
- virtual public int CbULY
- {
- get
- {
- return src.CbULY;
- }
-
- }
- /// Returns the parameters that are used in this class and
- /// implementing classes. It returns a 2D String array. Each of the
- /// 1D arrays is for a different option, and they have 3
- /// elements. The first element is the option name, the second one
- /// is the synopsis and the third one is a long description of what
- /// the parameter is. The synopsis or description may be 'null', in
- /// which case it is assumed that there is no synopsis or
- /// description of the option, respectively. Null may be returned
- /// if no options are supported.
- ///
- ///
- /// the options name, their synopsis and their explanation,
- /// or null if no options are supported.
- ///
- ///
- public static System.String[][] ParameterInfo
- {
- get
- {
- return pinfo;
- }
-
- }
-
- /// The prefix for dequantizer options: 'Q'
- public const char OPT_PREFIX = 'Q';
-
- /// The list of parameters that is accepted by the bit stream
- /// readers. They start with 'Q'
- ///
- //UPGRADE_NOTE: Final was removed from the declaration of 'pinfo'. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- private static readonly System.String[][] pinfo = null;
-
- /// The entropy decoder from where to get the quantized data (the
- /// source).
- ///
- protected internal CBlkQuantDataSrcDec src;
-
- /// The "range bits" for each transformed component
- protected internal int[] rb = null;
-
- /// The "range bits" for each un-transformed component
- protected internal int[] utrb = null;
-
- /// The inverse component transformation specifications
- private CompTransfSpec cts;
-
- /// Reference to the wavelet filter specifications
- private SynWTFilterSpec wfs;
-
- /// Initializes the source of compressed data.
- ///
- ///
- /// From where to obtain the quantized data.
- ///
- ///
- /// The number of "range bits" for each component (must be the
- /// "range bits" of the un-transformed components. For a definition of
- /// "range bits" see the getNomRangeBits() method.
- ///
- ///
- ///
- ///
- ///
- public Dequantizer(CBlkQuantDataSrcDec src, int[] utrb, DecoderSpecs decSpec) : base(src)
- {
- if (utrb.Length != src.NumComps)
- {
- throw new System.ArgumentException();
- }
- this.src = src;
- this.utrb = utrb;
- this.cts = decSpec.cts;
- this.wfs = decSpec.wfs;
- }
-
- /// Returns the number of bits, referred to as the "range bits",
- /// corresponding to the nominal range of the data in the specified
- /// component.
- ///
- /// The returned value corresponds to the nominal dynamic range of the
- /// reconstructed image data, not of the wavelet coefficients
- /// themselves. This is because different subbands have different gains and
- /// thus different nominal ranges. To have an idea of the nominal range in
- /// each subband the subband analysis gain value from the subband tree
- /// structure, returned by the getSynSubbandTree() method, can be used. See
- /// the Subband class for more details.
- ///
- /// If this number is b then for unsigned data the nominal range
- /// is between 0 and 2^b-1, and for signed data it is between -2^(b-1) and
- /// 2^(b-1)-1.
- ///
- ///
- /// The index of the component
- ///
- ///
- /// The number of bits corresponding to the nominal range of the
- /// data.
- ///
- ///
- ///
- ///
- ///
- public virtual int getNomRangeBits(int c)
- {
- return rb[c];
- }
-
- /// Returns the subband tree, for the specified tile-component. This method
- /// returns the root element of the subband tree structure, see Subband and
- /// SubbandSyn. The tree comprises all the available resolution levels.
- ///
- /// The number of magnitude bits ('magBits' member variable) for each
- /// subband may have not been not initialized (it depends on the actual
- /// dequantizer and its implementation). However, they are not necessary
- /// for the subsequent steps in the decoder chain.
- ///
- ///
- /// The index of the tile, from 0 to T-1.
- ///
- ///
- /// The index of the component, from 0 to C-1.
- ///
- ///
- /// The root of the tree structure.
- ///
- ///
- public override SubbandSyn getSynSubbandTree(int t, int c)
- {
- return src.getSynSubbandTree(t, c);
- }
-
- /// Changes the current tile, given the new indexes. An
- /// IllegalArgumentException is thrown if the indexes do not
- /// correspond to a valid tile.
- ///
- /// This default implementation changes the tile in the source
- /// and re-initializes properly component transformation variables..
- ///
- ///
- /// The horizontal index of the tile.
- ///
- ///
- /// The vertical index of the new tile.
- ///
- ///
- public override void setTile(int x, int y)
- {
- src.setTile(x, y);
- tIdx = TileIdx; // index of the current tile
-
- // initializations
- int cttype = 0;
- if (((System.Int32)cts.getTileDef(tIdx)) == InvCompTransf.NONE)
- cttype = InvCompTransf.NONE;
- else
- {
- int nc = src.NumComps > 3 ? 3 : src.NumComps;
- int rev = 0;
- for (int c = 0; c < nc; c++)
- rev += (wfs.isReversible(tIdx, c) ? 1 : 0);
- if (rev == 3)
- {
- // All WT are reversible
- cttype = InvCompTransf.INV_RCT;
- }
- else if (rev == 0)
- {
- // All WT irreversible
- cttype = InvCompTransf.INV_ICT;
- }
- else
- {
- // Error
- throw new System.ArgumentException("Wavelet transformation " + "and " + "component transformation" + " not coherent in tile" + tIdx);
- }
- }
-
- switch (cttype)
- {
-
- case InvCompTransf.NONE:
- rb = utrb;
- break;
-
- case InvCompTransf.INV_RCT:
- rb = InvCompTransf.calcMixedBitDepths(utrb, InvCompTransf.INV_RCT, null);
- break;
-
- case InvCompTransf.INV_ICT:
- rb = InvCompTransf.calcMixedBitDepths(utrb, InvCompTransf.INV_ICT, null);
- break;
-
- default:
- throw new System.ArgumentException("Non JPEG 2000 part I " + "component" + " transformation for tile: " + tIdx);
-
- }
- }
-
- /// Advances to the next tile, in standard scan-line order (by rows then
- /// columns). An NoNextElementException is thrown if the current tile is
- /// the last one (i.e. there is no next tile).
- ///
- /// This default implementation just advances to the next tile in the
- /// source and re-initializes properly component transformation variables.
- ///
- ///
- public override void nextTile()
- {
- src.nextTile();
- tIdx = TileIdx; // index of the current tile
-
- // initializations
- int cttype = ((System.Int32)cts.getTileDef(tIdx));
- switch (cttype)
- {
-
- case InvCompTransf.NONE:
- rb = utrb;
- break;
-
- case InvCompTransf.INV_RCT:
- rb = InvCompTransf.calcMixedBitDepths(utrb, InvCompTransf.INV_RCT, null);
- break;
-
- case InvCompTransf.INV_ICT:
- rb = InvCompTransf.calcMixedBitDepths(utrb, InvCompTransf.INV_ICT, null);
- break;
-
- default:
- throw new System.ArgumentException("Non JPEG 2000 part I " + "component" + " transformation for tile: " + tIdx);
-
- }
- }
- public abstract CSJ2K.j2k.image.DataBlk getCodeBlock(int param1, int param2, int param3, CSJ2K.j2k.wavelet.synthesis.SubbandSyn param4, CSJ2K.j2k.image.DataBlk param5);
- public abstract int getFixedPoint(int param1);
- public abstract CSJ2K.j2k.image.DataBlk getInternCodeBlock(int param1, int param2, int param3, CSJ2K.j2k.wavelet.synthesis.SubbandSyn param4, CSJ2K.j2k.image.DataBlk param5);
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/quantization/dequantizer/DequantizerParams.cs b/CSJ2K/j2k/quantization/dequantizer/DequantizerParams.cs
deleted file mode 100644
index b4e7b485..00000000
--- a/CSJ2K/j2k/quantization/dequantizer/DequantizerParams.cs
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
-* CVS identifier:
-*
-* $Id: DequantizerParams.java,v 1.16 2000/09/19 14:11:54 grosbois Exp $
-*
-* Class: DequantizerParams
-*
-* Description: Generic class to hold dequantizer
-* parameters.
-*
-*
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-*/
-namespace CSJ2K.j2k.quantization.dequantizer
-{
-
- /// This is the generic ineterface for dequantization parameters. Generally,
- /// for each type of dequantizer, there should be a corresponding class to
- /// store its parameters. The parameters are those that come from the bit
- /// stream header, that concern dequantization.
- ///
- ///
- public abstract class DequantizerParams
- {
- /// Returns the type of the dequantizer for which the parameters are. The
- /// types are defined in the Dequantizer class.
- ///
- ///
- /// The type of the dequantizer for which the parameters
- /// are.
- ///
- ///
- ///
- ///
- ///
- public abstract int DequantizerType { get; }
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/quantization/dequantizer/StdDequantizer.cs b/CSJ2K/j2k/quantization/dequantizer/StdDequantizer.cs
deleted file mode 100644
index 9255b1f7..00000000
--- a/CSJ2K/j2k/quantization/dequantizer/StdDequantizer.cs
+++ /dev/null
@@ -1,404 +0,0 @@
-/*
-* CVS identifier:
-*
-* $Id: StdDequantizer.java,v 1.15 2002/07/19 12:50:23 grosbois Exp $
-*
-* Class: StdDequantizer
-*
-* Description: Scalar deadzone dequantizer that returns integers
-* or floats.
-* This is a merger of the ScalarDZDeqInt and
-* ScalarDZDeqFloat classes by Joel Askelof and Diego
-* Santa Cruz.
-*
-*
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-* */
-using CSJ2K.j2k.decoder;
-using CSJ2K.j2k.image;
-using CSJ2K.j2k.wavelet.synthesis;
-namespace CSJ2K.j2k.quantization.dequantizer
-{
-
- /// This class implements a scalar dequantizer with deadzone. The output can be
- /// either integer ('int') or floating-point ('float') data. The dequantization
- /// step sizes and other parameters are taken from a StdDequantizerParams
- /// class, which inherits from DequantizerParams.
- ///
- /// Sign magnitude representation is used (instead of two's complement) for
- /// the input data. The most significant bit is used for the sign (0 if
- /// positive, 1 if negative). Then the magnitude of the quantized coefficient
- /// is stored in the next most significat bits. The most significant magnitude
- /// bit corresponds to the most significant bit-plane and so on.
- ///
- /// When reversible quantization is used, this class only converts between
- /// the sign-magnitude representation and the integer (or eventually
- /// fixed-point) output, since there is no true quantization.
- ///
- /// The output data is fixed-point two's complement for 'int' output and
- /// floating-point for 'float' output. The type of output and the number number
- /// of fractional bits for 'int' output are defined at the constructor. Each
- /// component may have a different number of fractional bits.
- ///
- /// The reconstruction levels used by the dequantizer are exactly what is
- /// received from the entropy decoder. It is assumed that the entropy decoder
- /// always returns codewords that are midways in the decoded intervals. In this
- /// way the dequantized values will always lie midways in the quantization
- /// intervals.
- ///
- ///
- public class StdDequantizer : Dequantizer
- {
-
- /// The quantizer type spec
- private QuantTypeSpec qts;
-
- /// The quantizer step sizes spec
- private QuantStepSizeSpec qsss;
-
- /// The number of guard bits spec
- private GuardBitsSpec gbs;
-
- /// The decoding parameters of the dequantizer
- //private StdDequantizerParams params_Renamed;
-
- /// The 'DataBlkInt' object used to request data, used when output data is
- /// not int
- ///
- private DataBlkInt inblk;
-
- /// Type of the current output data
- private int outdtype;
-
- /// Initializes the source of compressed data. And sets the number of range
- /// bits and fraction bits and receives the parameters for the dequantizer.
- ///
- ///
- /// From where to obtain the quantized data.
- ///
- ///
- /// The number of "range bits" (bitdepth) for each component
- /// (must be the "range bits" of the un-transformed components). For a
- /// definition of "range bits" see the getNomRangeBits() method.
- ///
- ///
- /// The quantizer type spec
- ///
- ///
- /// The dequantizer step sizes spec
- ///
- ///
- ///
- ///
- ///
- /// Thrown if 'outdt' is neither
- /// TYPE_FLOAT nor TYPE_INT, or if 'param' specify reversible quantization
- /// and 'outdt' is not TYPE_INT or 'fp' has non-zero values, or if 'outdt'
- /// is TYPE_FLOAT and 'fp' has non-zero values.
- ///
- ///
- public StdDequantizer(CBlkQuantDataSrcDec src, int[] utrb, DecoderSpecs decSpec) : base(src, utrb, decSpec)
- {
-
- if (utrb.Length != src.NumComps)
- {
- throw new System.ArgumentException("Invalid rb argument");
- }
- this.qsss = decSpec.qsss;
- this.qts = decSpec.qts;
- this.gbs = decSpec.gbs;
- }
-
- /// Returns the position of the fixed point in the output data for the
- /// specified component. This is the position of the least significant
- /// integral (i.e. non-fractional) bit, which is equivalent to the number
- /// of fractional bits. For instance, for fixed-point values with 2
- /// fractional bits, 2 is returned. For floating-point data this value does
- /// not apply and 0 should be returned. Position 0 is the position of the
- /// least significant bit in the data. If the output data is 'float' then 0
- /// is always returned.
- ///
- /// Note: Fractional bits are no more supported by JJ2000.
- ///
- ///
- /// The index of the component.
- ///
- ///
- /// The position of the fixed-point, which is the same as the
- /// number of fractional bits. For floating-point data 0 is returned.
- ///
- ///
- public override int getFixedPoint(int c)
- {
- return 0;
- }
-
- /// Returns the specified code-block in the current tile for the specified
- /// component, as a copy (see below).
- ///
- /// The returned code-block may be progressive, which is indicated by
- /// the 'progressive' variable of the returned 'DataBlk' object. If a
- /// code-block is progressive it means that in a later request to this
- /// method for the same code-block it is possible to retrieve data which is
- /// a better approximation, since meanwhile more data to decode for the
- /// code-block could have been received. If the code-block is not
- /// progressive then later calls to this method for the same code-block
- /// will return the exact same data values.
- ///
- /// The data returned by this method is always a copy of the internal
- /// data of this object, if any, and it can be modified "in place" without
- /// any problems after being returned. The 'offset' of the returned data is
- /// 0, and the 'scanw' is the same as the code-block width. See the
- /// 'DataBlk' class.
- ///
- ///
- /// The component for which to return the next code-block.
- ///
- ///
- /// The vertical index of the code-block to return, in the
- /// specified subband.
- ///
- ///
- /// The horizontal index of the code-block to return, in the
- /// specified subband.
- ///
- ///
- /// The subband in which the code-block to return is.
- ///
- ///
- /// If non-null this object will be used to return the new
- /// code-block. If null a new one will be allocated and returned. If the
- /// "data" array of the object is non-null it will be reused, if possible,
- /// to return the data.
- ///
- ///
- /// The next code-block in the current tile for component 'n', or
- /// null if all code-blocks for the current tile have been returned.
- ///
- ///
- ///
- ///
- ///
- public override DataBlk getCodeBlock(int c, int m, int n, SubbandSyn sb, DataBlk cblk)
- {
- return getInternCodeBlock(c, m, n, sb, cblk);
- }
-
- /// Returns the specified code-block in the current tile for the specified
- /// component (as a reference or copy).
- ///
- /// The returned code-block may be progressive, which is indicated by
- /// the 'progressive' variable of the returned 'DataBlk'
- /// object. If a code-block is progressive it means that in a later request
- /// to this method for the same code-block it is possible to retrieve data
- /// which is a better approximation, since meanwhile more data to decode
- /// for the code-block could have been received. If the code-block is not
- /// progressive then later calls to this method for the same code-block
- /// will return the exact same data values.
- ///
- /// The data returned by this method can be the data in the internal
- /// buffer of this object, if any, and thus can not be modified by the
- /// caller. The 'offset' and 'scanw' of the returned data can be
- /// arbitrary. See the 'DataBlk' class.
- ///
- ///
- /// The component for which to return the next code-block.
- ///
- ///
- /// The vertical index of the code-block to return, in the
- /// specified subband.
- ///
- ///
- /// The horizontal index of the code-block to return, in the
- /// specified subband.
- ///
- ///
- /// The subband in which the code-block to return is.
- ///
- ///
- /// If non-null this object will be used to return the new
- /// code-block. If null a new one will be allocated and returned. If the
- /// "data" array of the object is non-null it will be reused, if possible,
- /// to return the data.
- ///
- ///
- /// The next code-block in the current tile for component 'n', or
- /// null if all code-blocks for the current tile have been returned.
- ///
- ///
- ///
- ///
- ///
- public override DataBlk getInternCodeBlock(int c, int m, int n, SubbandSyn sb, DataBlk cblk)
- {
- // This method is declared final since getNextCodeBlock() relies on
- // the actual implementation of this method.
- int j, jmin, k;
- int temp;
- float step;
- int shiftBits;
- int magBits;
- int[] outiarr, inarr;
- float[] outfarr;
- int w, h;
- bool reversible = qts.isReversible(tIdx, c);
- bool derived = qts.isDerived(tIdx, c);
- StdDequantizerParams params_Renamed = (StdDequantizerParams)qsss.getTileCompVal(tIdx, c);
- int G = ((System.Int32)gbs.getTileCompVal(tIdx, c));
-
- outdtype = cblk.DataType;
-
- if (reversible && outdtype != DataBlk.TYPE_INT)
- {
- throw new System.ArgumentException("Reversible quantizations " + "must use int data");
- }
-
- // To get compiler happy
- outiarr = null;
- outfarr = null;
- inarr = null;
-
- // Get source data and initialize output DataBlk object.
- switch (outdtype)
- {
-
- case DataBlk.TYPE_INT:
- // With int data we can use the same DataBlk object to get the
- // data from the source and return the dequantized data, and we
- // can also work "in place" (i.e. same buffer).
- cblk = src.getCodeBlock(c, m, n, sb, cblk);
- // Input and output arrays are the same
- outiarr = (int[])cblk.Data;
- break;
-
- case DataBlk.TYPE_FLOAT:
- // With float data we must use a different DataBlk objects to get
- // the data from the source and to return the dequantized data.
- inblk = (DataBlkInt)src.getInternCodeBlock(c, m, n, sb, inblk);
- inarr = inblk.DataInt;
- if (cblk == null)
- {
- cblk = new DataBlkFloat();
- }
- // Copy the attributes of the CodeBlock object
- cblk.ulx = inblk.ulx;
- cblk.uly = inblk.uly;
- cblk.w = inblk.w;
- cblk.h = inblk.h;
- cblk.offset = 0;
- cblk.scanw = cblk.w;
- cblk.progressive = inblk.progressive;
- // Get output data array and check its size
- outfarr = (float[])cblk.Data;
- if (outfarr == null || outfarr.Length < cblk.w * cblk.h)
- {
- outfarr = new float[cblk.w * cblk.h];
- cblk.Data = outfarr;
- }
- break;
- }
-
- magBits = sb.magbits;
-
- // Calculate quantization step and number of magnitude bits
- // depending on reversibility and derivedness and perform
- // inverse quantization
- if (reversible)
- {
- shiftBits = 31 - magBits;
- // For int data Inverse quantization happens "in-place". The input
- // array has an offset of 0 and scan width equal to the code-block
- // width.
- for (j = outiarr.Length - 1; j >= 0; j--)
- {
- temp = outiarr[j]; // input array is same as output one
- outiarr[j] = (temp >= 0) ? (temp >> shiftBits) : -((temp & 0x7FFFFFFF) >> shiftBits);
- }
- }
- else
- {
- // Not reversible
- if (derived)
- {
- // Max resolution level
- int mrl = src.getSynSubbandTree(TileIdx, c).resLvl;
- step = params_Renamed.nStep[0][0] * (1L << (rb[c] + sb.anGainExp + mrl - sb.level));
- }
- else
- {
- step = params_Renamed.nStep[sb.resLvl][sb.sbandIdx] * (1L << (rb[c] + sb.anGainExp));
- }
- shiftBits = 31 - magBits;
-
- // Adjust step to the number of shiftBits
- step /= (1 << shiftBits);
-
- switch (outdtype)
- {
-
- case DataBlk.TYPE_INT:
- // For int data Inverse quantization happens "in-place". The
- // input array has an offset of 0 and scan width equal to the
- // code-block width.
- for (j = outiarr.Length - 1; j >= 0; j--)
- {
- temp = outiarr[j]; // input array is same as output one
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- outiarr[j] = (int)(((float)((temp >= 0) ? temp : -(temp & 0x7FFFFFFF))) * step);
- }
- break;
-
- case DataBlk.TYPE_FLOAT:
- // For float data the inverse quantization can not happen
- // "in-place".
- w = cblk.w;
- h = cblk.h;
- for (j = w * h - 1, k = inblk.offset + (h - 1) * inblk.scanw + w - 1, jmin = w * (h - 1); j >= 0; jmin -= w)
- {
- for (; j >= jmin; k--, j--)
- {
- temp = inarr[k];
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- outfarr[j] = ((float)((temp >= 0) ? temp : -(temp & 0x7FFFFFFF))) * step;
- }
- // Jump to beggining of previous line in input
- k -= (inblk.scanw - w);
- }
- break;
- }
- }
- // Return the output code-block
- return cblk;
- }
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/quantization/dequantizer/StdDequantizerParams.cs b/CSJ2K/j2k/quantization/dequantizer/StdDequantizerParams.cs
deleted file mode 100644
index ec58235a..00000000
--- a/CSJ2K/j2k/quantization/dequantizer/StdDequantizerParams.cs
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
-* CVS identifier:
-*
-* $Id: StdDequantizerParams.java,v 1.9 2000/09/19 14:12:09 grosbois Exp $
-*
-* Class: StdDequantizerParams
-*
-* Description: Parameters for the scalar deadzone dequantizers
-*
-*
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-*/
-using CSJ2K.j2k.wavelet;
-namespace CSJ2K.j2k.quantization.dequantizer
-{
-
- /// This class holds the parameters for the scalar deadzone dequantizer
- /// (StdDequantizer class) for the current tile. Its constructor decodes the
- /// parameters from the main header and tile headers.
- ///
- ///
- ///
- ///
- ///
- public class StdDequantizerParams : DequantizerParams
- {
- /// Returns the type of the dequantizer for which the parameters are. The
- /// types are defined in the Dequantizer class.
- ///
- ///
- /// The type of the dequantizer for which the parameters
- /// are. Always Q_TYPE_SCALAR_DZ.
- ///
- ///
- ///
- ///
- ///
- override public int DequantizerType
- {
- get
- {
- return CSJ2K.j2k.quantization.QuantizationType_Fields.Q_TYPE_SCALAR_DZ;
- }
-
- }
-
- /// The quantization step "exponent" value, for each resolution level and
- /// subband, as it appears in the codestream. The first index is the
- /// resolution level, and the second the subband index (within the
- /// resolution level), as specified in the Subband class. When in derived
- /// quantization mode only the first resolution level (level 0) appears.
- ///
- /// For non-reversible systems this value corresponds to ceil(log2(D')),
- /// where D' is the quantization step size normalized to data of a dynamic
- /// range of 1. The true quantization step size is (2^R)*D', where R is
- /// ceil(log2(dr)), where 'dr' is the dynamic range of the subband samples,
- /// in the corresponding subband.
- ///
- ///
For reversible systems the exponent value in 'exp' is used to
- /// determine the number of magnitude bits in the quantized
- /// coefficients. It is, in fact, the dynamic range of the subband data.
- ///
- ///
In general the index of the first subband in a resolution level is
- /// not 0. The exponents appear, within each resolution level, at their
- /// subband index, and not in the subband order starting from 0. For
- /// instance, resolution level 3, the first subband has the index 16, then
- /// the exponent of the subband is exp[3][16], not exp[3][0].
- ///
- ///
- ///
- ///
- ///
- public int[][] exp;
-
- /// The quantization step for non-reversible systems, normalized to a
- /// dynamic range of 1, for each resolution level and subband, as derived
- /// from the exponent-mantissa representation in the codestream. The first
- /// index is the resolution level, and the second the subband index (within
- /// the resolution level), as specified in the Subband class. When in
- /// derived quantization mode only the first resolution level (level 0)
- /// appears.
- ///
- /// The true step size D is obtained as follows: D=(2^R)*D', where
- /// 'R=ceil(log2(dr))' and 'dr' is the dynamic range of the subband
- /// samples, in the corresponding subband.
- ///
- ///
This value is 'null' for reversible systems (i.e. there is no true
- /// quantization, 'D' is always 1).
- ///
- ///
In general the index of the first subband in a resolution level is
- /// not 0. The steps appear, within each resolution level, at their subband
- /// index, and not in the subband order starting from 0. For instance, if
- /// resolution level 3, the first subband has the index 16, then the step
- /// of the subband is nStep[3][16], not nStep[3][0].
- ///
- ///
- ///
- ///
- ///
- public float[][] nStep;
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/quantization/quantizer/CBlkQuantDataSrcEnc.cs b/CSJ2K/j2k/quantization/quantizer/CBlkQuantDataSrcEnc.cs
deleted file mode 100644
index dfffec2b..00000000
--- a/CSJ2K/j2k/quantization/quantizer/CBlkQuantDataSrcEnc.cs
+++ /dev/null
@@ -1,166 +0,0 @@
-/*
-* CVS identifier:
-*
-* $Id: CBlkQuantDataSrcEnc.java,v 1.10 2001/09/14 08:51:46 grosbois Exp $
-*
-* Class: CBlkQuantDataSrcEnc
-*
-* Description: Interface that defines a source of
-* quantized wavelet data to be transferred in a
-* code-block by code-block basis.
-*
-*
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-* */
-using CSJ2K.j2k.entropy.encoder;
-using CSJ2K.j2k.wavelet.analysis;
-namespace CSJ2K.j2k.quantization.quantizer
-{
-
- /// This interface defines a source of quantized wavelet coefficients and
- /// methods to transfer them in a code-block by code-block basis. In each call
- /// to 'getNextCodeBlock()' or 'getNextInternCodeBlock()' a new code-block is
- /// returned. The code-blocks are returned in no specific order.
- ///
- /// This class is the source of data for the entropy coder. See the
- /// 'EntropyCoder' class.
- ///
- /// Code-block data is returned in sign-magnitude representation, instead of
- /// the normal two's complement one. Only integral types are used. The sign
- /// magnitude representation is more adequate for entropy coding. In sign
- /// magnitude representation, the most significant bit is used for the sign (0
- /// if positive, 1 if negative) and the magnitude of the coefficient is stored
- /// in the next M most significant bits. The rest of the bits (least
- /// significant bits) can contain a fractional value of the quantized
- /// coefficient. The number 'M' of magnitude bits is communicated in the
- /// 'magbits' member variable of the 'CBlkWTData'.
- ///
- /// Note that no more of one object may request data, otherwise one object
- /// would get some of the data and another one another part, in no defined
- /// manner.
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- public interface CBlkQuantDataSrcEnc : ForwWTDataProps
- {
-
- /// Returns the next code-block in the current tile for the specified
- /// component, as a copy (see below). The order in which code-blocks are
- /// returned is not specified. However each code-block is returned only
- /// once and all code-blocks will be returned if the method is called 'N'
- /// times, where 'N' is the number of code-blocks in the tile. After all
- /// the code-blocks have been returned for the current tile calls to this
- /// method will return 'null'.
- ///
- /// When changing the current tile (through 'setTile()' or 'nextTile()')
- /// this method will always return the first code-block, as if this method
- /// was never called before for the new current tile.
- ///
- /// The data returned by this method is always a copy of the internal
- /// data of this object, if any, and it can be modified "in place" without
- /// any problems after being returned. The 'offset' of the returned data is
- /// 0, and the 'scanw' is the same as the code-block width. See the
- /// 'CBlkWTData' class.
- ///
- /// The 'ulx' and 'uly' members of the returned 'CBlkWTData' object
- /// contain the coordinates of the top-left corner of the block, with
- /// respect to the tile, not the subband.
- ///
- ///
- /// The component for which to return the next code-block.
- ///
- ///
- /// If non-null this object will be used to return the new
- /// code-block. If null a new one will be allocated and returned. If the
- /// "data" array of the object is non-null it will be reused, if possible,
- /// to return the data.
- ///
- ///
- /// The next code-block in the current tile for component 'c', or
- /// null if all code-blocks for the current tile have been returned.
- ///
- ///
- ///
- ///
- ///
- CBlkWTData getNextCodeBlock(int c, CBlkWTData cblk);
-
- /// Returns the next code-block in the current tile for the specified
- /// component. The order in which code-blocks are returned is not
- /// specified. However each code-block is returned only once and all
- /// code-blocks will be returned if the method is called 'N' times, where
- /// 'N' is the number of code-blocks in the tile. After all the code-blocks
- /// have been returned for the current tile calls to this method will
- /// return 'null'.
- ///
- /// When changing the current tile (through 'setTile()' or 'nextTile()')
- /// this method will always return the first code-block, as if this method
- /// was never called before for the new current tile.
- ///
- /// The data returned by this method can be the data in the internal
- /// buffer of this object, if any, and thus can not be modified by the
- /// caller. The 'offset' and 'scanw' of the returned data can be
- /// arbitrary. See the 'CBlkWTData' class.
- ///
- /// The 'ulx' and 'uly' members of the returned 'CBlkWTData' object
- /// contain the coordinates of the top-left corner of the block, with
- /// respect to the tile, not the subband.
- ///
- ///
- /// The component for which to return the next code-block.
- ///
- ///
- /// If non-null this object will be used to return the new
- /// code-block. If null a new one will be allocated and returned. If the
- /// "data" array of the object is non-null it will be reused, if possible,
- /// to return the data.
- ///
- ///
- /// The next code-block in the current tile for component 'n', or
- /// null if all code-blocks for the current tile have been returned.
- ///
- ///
- ///
- ///
- ///
- CBlkWTData getNextInternCodeBlock(int c, CBlkWTData cblk);
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/quantization/quantizer/Quantizer.cs b/CSJ2K/j2k/quantization/quantizer/Quantizer.cs
deleted file mode 100644
index 1c361725..00000000
--- a/CSJ2K/j2k/quantization/quantizer/Quantizer.cs
+++ /dev/null
@@ -1,288 +0,0 @@
-/*
-* CVS identifier:
-*
-* $Id: Quantizer.java,v 1.38 2002/01/09 13:24:14 grosbois Exp $
-*
-* Class: Quantizer
-*
-* Description: An abstract class for quantizers
-*
-*
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-* */
-using CSJ2K.j2k.encoder;
-using CSJ2K.j2k.image;
-using CSJ2K.j2k.wavelet;
-using CSJ2K.j2k.wavelet.analysis;
-namespace CSJ2K.j2k.quantization.quantizer
-{
-
- /// This abstract class provides the general interface for quantizers. The
- /// input of a quantizer is the output of a wavelet transform. The output of
- /// the quantizer is the set of quantized wavelet coefficients represented in
- /// sign-magnitude notation (see below).
- ///
- /// This class provides default implementation for most of the methods
- /// (wherever it makes sense), under the assumption that the image, component
- /// dimensions, and the tiles, are not modifed by the quantizer. If it is not
- /// the case for a particular implementation, then the methods should be
- /// overriden.
- ///
- /// Sign magnitude representation is used (instead of two's complement) for
- /// the output data. The most significant bit is used for the sign (0 if
- /// positive, 1 if negative). Then the magnitude of the quantized coefficient
- /// is stored in the next M most significat bits. The rest of the bits (least
- /// significant bits) can contain a fractional value of the quantized
- /// coefficient. This fractional value is not to be coded by the entropy
- /// coder. However, it can be used to compute rate-distortion measures with
- /// greater precision.
- ///
- /// The value of M is determined for each subband as the sum of the number
- /// of guard bits G and the nominal range of quantized wavelet coefficients in
- /// the corresponding subband (Rq), minus 1:
- ///
- /// M = G + Rq -1
- ///
- /// The value of G should be the same for all subbands. The value of Rq
- /// depends on the quantization step size, the nominal range of the component
- /// before the wavelet transform and the analysis gain of the subband (see
- /// Subband).
- ///
- /// The blocks of data that are requested should not cross subband
- /// boundaries.
- ///
- /// NOTE: At the moment only quantizers that implement the
- /// 'CBlkQuantDataSrcEnc' interface are supported.
- ///
- ///
- ///
- ///
- ///
- public abstract class Quantizer : ImgDataAdapter, CBlkQuantDataSrcEnc
- {
- /// Returns the horizontal offset of the code-block partition. Allowable
- /// values are 0 and 1, nothing else.
- ///
- ///
- virtual public int CbULX
- {
- get
- {
- return src.CbULX;
- }
-
- }
- /// Returns the vertical offset of the code-block partition. Allowable
- /// values are 0 and 1, nothing else.
- ///
- ///
- virtual public int CbULY
- {
- get
- {
- return src.CbULY;
- }
-
- }
- /// Returns the parameters that are used in this class and implementing
- /// classes. It returns a 2D String array. Each of the 1D arrays is for a
- /// different option, and they have 3 elements. The first element is the
- /// option name, the second one is the synopsis, the third one is a long
- /// description of what the parameter is and the fourth is its default
- /// value. The synopsis or description may be 'null', in which case it is
- /// assumed that there is no synopsis or description of the option,
- /// respectively. Null may be returned if no options are supported.
- ///
- ///
- /// the options name, their synopsis and their explanation,
- /// or null if no options are supported.
- ///
- ///
- public static System.String[][] ParameterInfo
- {
- get
- {
- return pinfo;
- }
-
- }
-
- /// The prefix for quantizer options: 'Q'
- public const char OPT_PREFIX = 'Q';
-
- /// The list of parameters that is accepted for quantization. Options
- /// for quantization start with 'Q'.
- ///
- //UPGRADE_NOTE: Final was removed from the declaration of 'pinfo'. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- private static readonly System.String[][] pinfo = new System.String[][] { new System.String[] { "Qtype", "[] " + "[ [] ...]", "Specifies which quantization type to use for specified " + "tile-component. The default type is either 'reversible' or " + "'expounded' depending on whether or not the '-lossless' option " + " is specified.\n" + " : see general note.\n" + ": Supported quantization types specification are : " + "'reversible' " + "(no quantization), 'derived' (derived quantization step size) and " + "'expounded'.\n" + "Example: -Qtype reversible or -Qtype t2,4-8 c2 reversible t9 " + "derived.", null }, new System.String[] { "Qstep", "[] " + "[ [] ...]", "This option specifies the base normalized quantization step " + "size (bnss) for tile-components. It is normalized to a " + "dynamic range of 1 in the image domain. This parameter is " + "ignored in reversible coding. The default value is '1/128'" + " (i.e. 0.0078125).", "0.0078125" }, new System.String[] { "Qguard_bits", "[] " + "[ [] ...]", "The number of bits used for each tile-component in the quantizer" + " to avoid overflow (gb).", "2" } };
-
- /// The source of wavelet transform coefficients
- protected internal CBlkWTDataSrc src;
-
- /// Initializes the source of wavelet transform coefficients.
- ///
- ///
- /// The source of wavelet transform coefficients.
- ///
- ///
- public Quantizer(CBlkWTDataSrc src) : base(src)
- {
- this.src = src;
- }
-
- /// Returns the number of guard bits used by this quantizer in the
- /// given tile-component.
- ///
- ///
- /// Tile index
- ///
- ///
- /// Component index
- ///
- ///
- /// The number of guard bits
- ///
- ///
- public abstract int getNumGuardBits(int t, int c);
-
- /// Returns true if the quantizer of given tile-component uses derived
- /// quantization step sizes.
- ///
- ///
- /// Tile index
- ///
- ///
- /// Component index
- ///
- ///
- /// True if derived quantization is used.
- ///
- ///
- public abstract bool isDerived(int t, int c);
-
- /// Calculates the parameters of the SubbandAn objects that depend on the
- /// Quantizer. The 'stepWMSE' field is calculated for each subband which is
- /// a leaf in the tree rooted at 'sb', for the specified component. The
- /// subband tree 'sb' must be the one for the component 'n'.
- ///
- ///
- /// The root of the subband tree.
- ///
- ///
- /// The component index.
- ///
- ///
- ///
- ///
- ///
- protected internal abstract void calcSbParams(SubbandAn sb, int n);
-
- /// Returns a reference to the subband tree structure representing the
- /// subband decomposition for the specified tile-component.
- ///
- /// This method gets the subband tree from the source and then
- /// calculates the magnitude bits for each leaf using the method
- /// calcSbParams().
- ///
- ///
- /// The index of the tile.
- ///
- ///
- /// The index of the component.
- ///
- ///
- /// The subband tree structure, see SubbandAn.
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- public virtual SubbandAn getAnSubbandTree(int t, int c)
- {
- SubbandAn sbba;
-
- // Ask for the wavelet tree of the source
- sbba = src.getAnSubbandTree(t, c);
- // Calculate the stepWMSE
- calcSbParams(sbba, c);
- return sbba;
- }
-
- /// Creates a Quantizer object for the appropriate type of quantization
- /// specified in the options in the parameter list 'pl', and having 'src'
- /// as the source of data to be quantized. The 'rev' flag indicates if the
- /// quantization should be reversible.
- ///
- /// NOTE: At the moment only sources of wavelet data that implement the
- /// 'CBlkWTDataSrc' interface are supported.
- ///
- ///
- /// The source of data to be quantized
- ///
- ///
- /// Encoder specifications
- ///
- ///
- /// If an error occurs while parsing
- /// the options in 'pl'
- ///
- ///
- public static Quantizer createInstance(CBlkWTDataSrc src, EncoderSpecs encSpec)
- {
- // Instantiate quantizer
- return new StdQuantizer(src, encSpec);
- }
-
- /// Returns the maximum number of magnitude bits in any subband in the
- /// current tile.
- ///
- ///
- /// the component number
- ///
- ///
- /// The maximum number of magnitude bits in all subbands of the
- /// current tile.
- ///
- ///
- public abstract int getMaxMagBits(int c);
- public abstract CSJ2K.j2k.wavelet.analysis.CBlkWTData getNextInternCodeBlock(int param1, CSJ2K.j2k.wavelet.analysis.CBlkWTData param2);
- public abstract CSJ2K.j2k.wavelet.analysis.CBlkWTData getNextCodeBlock(int param1, CSJ2K.j2k.wavelet.analysis.CBlkWTData param2);
- public abstract bool isReversible(int param1, int param2);
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/quantization/quantizer/StdQuantizer.cs b/CSJ2K/j2k/quantization/quantizer/StdQuantizer.cs
deleted file mode 100644
index 8a0a8c2a..00000000
--- a/CSJ2K/j2k/quantization/quantizer/StdQuantizer.cs
+++ /dev/null
@@ -1,725 +0,0 @@
-/*
-* CVS identifier:
-*
-* $Id: StdQuantizer.java,v 1.14 2001/09/20 12:41:52 grosbois Exp $
-*
-* Class: StdQuantizer
-*
-* Description: Scalar deadzone quantizer of integer or float
-* data.
-*
-* Mergerd from StdQuantizerInt and
-* StdQuantizerFloat from Joel Askelof.
-*
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-* */
-using CSJ2K.j2k.encoder;
-using CSJ2K.j2k.image;
-using CSJ2K.j2k.wavelet;
-using CSJ2K.j2k.wavelet.analysis;
-namespace CSJ2K.j2k.quantization.quantizer
-{
-
- /// This class implements scalar quantization of integer or floating-point
- /// valued source data. The source data is the wavelet transformed image data
- /// and the output is the quantized wavelet coefficients represented in
- /// sign-magnitude (see below).
- ///
- /// Sign magnitude representation is used (instead of two's complement) for
- /// the output data. The most significant bit is used for the sign (0 if
- /// positive, 1 if negative). Then the magnitude of the quantized coefficient
- /// is stored in the next M most significat bits. The rest of the bits (least
- /// significant bits) can contain a fractional value of the quantized
- /// coefficient. This fractional value is not to be coded by the entropy
- /// coder. However, it can be used to compute rate-distortion measures with
- /// greater precision.
- ///
- /// The value of M is determined for each subband as the sum of the number
- /// of guard bits G and the nominal range of quantized wavelet coefficients in
- /// the corresponding subband (Rq), minus 1:
- ///
- /// M = G + Rq -1
- ///
- /// The value of G should be the same for all subbands. The value of Rq
- /// depends on the quantization step size, the nominal range of the component
- /// before the wavelet transform and the analysis gain of the subband (see
- /// Subband).
- ///
- /// The blocks of data that are requested should not cross subband
- /// boundaries.
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- public class StdQuantizer : Quantizer
- {
- /// Returns the quantization type spec object associated to the quantizer.
- ///
- ///
- /// The quantization type spec
- ///
- ///
- virtual public QuantTypeSpec QuantTypeSpec
- {
- get
- {
- return qts;
- }
-
- }
-
- /// The number of mantissa bits for the quantization steps
- public const int QSTEP_MANTISSA_BITS = 11;
-
- /// The number of exponent bits for the quantization steps
- // NOTE: formulas in 'convertFromExpMantissa()' and
- // 'convertToExpMantissa()' methods do not support more than 5 bits.
- public const int QSTEP_EXPONENT_BITS = 5;
-
- /// The maximum value of the mantissa for the quantization steps
- //UPGRADE_NOTE: Final was removed from the declaration of 'QSTEP_MAX_MANTISSA '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- public static readonly int QSTEP_MAX_MANTISSA = (1 << QSTEP_MANTISSA_BITS) - 1;
-
- /// The maximum value of the exponent for the quantization steps
- //UPGRADE_NOTE: Final was removed from the declaration of 'QSTEP_MAX_EXPONENT '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- public static readonly int QSTEP_MAX_EXPONENT = (1 << QSTEP_EXPONENT_BITS) - 1;
-
- /// Natural log of 2, used as a convenience variable
- private static double log2 = System.Math.Log(2);
-
- /// The quantization type specifications
- private QuantTypeSpec qts;
-
- /// The quantization step size specifications
- private QuantStepSizeSpec qsss;
-
- /// The guard bits specifications
- private GuardBitsSpec gbs;
-
- /// The 'CBlkWTDataFloat' object used to request data, used when
- /// quantizing floating-point data.
- ///
- // This variable makes the class thread unsafe, but it avoids allocating
- // new objects for code-block that is quantized.
- private CBlkWTDataFloat infblk;
-
- /// Initializes the source of wavelet transform coefficients. The
- /// constructor takes information on whether the quantizer is in
- /// reversible, derived or expounded mode. If the quantizer is reversible
- /// the value of 'derived' is ignored. If the source data is not integer
- /// (int) then the quantizer can not be reversible.
- ///
- /// After initializing member attributes, getAnSubbandTree is called for
- /// all components setting the 'stepWMSE' for all subbands in the current
- /// tile.
- ///
- ///
- /// The source of wavelet transform coefficients.
- ///
- ///
- /// The encoder specifications
- ///
- ///
- public StdQuantizer(CBlkWTDataSrc src, EncoderSpecs encSpec) : base(src)
- {
- qts = encSpec.qts;
- qsss = encSpec.qsss;
- gbs = encSpec.gbs;
- }
-
- /// Returns the number of guard bits used by this quantizer in the given
- /// tile-component.
- ///
- ///
- /// Tile index
- ///
- ///
- /// Component index
- ///
- ///
- /// The number of guard bits
- ///
- ///
- public override int getNumGuardBits(int t, int c)
- {
- return ((System.Int32)gbs.getTileCompVal(t, c));
- }
-
- /// Returns true if the quantized data is reversible, for the specified
- /// tile-component. For the quantized data to be reversible it is necessary
- /// and sufficient that the quantization is reversible.
- ///
- ///
- /// The tile to test for reversibility
- ///
- ///
- /// The component to test for reversibility
- ///
- ///
- /// True if the quantized data is reversible, false if not.
- ///
- ///
- public override bool isReversible(int t, int c)
- {
- return qts.isReversible(t, c);
- }
-
- /// Returns true if given tile-component uses derived quantization step
- /// sizes.
- ///
- ///
- /// Tile index
- ///
- ///
- /// Component index
- ///
- ///
- /// True if derived
- ///
- ///
- public override bool isDerived(int t, int c)
- {
- return qts.isDerived(t, c);
- }
-
- /// Returns the next code-block in the current tile for the specified
- /// component, as a copy (see below). The order in which code-blocks are
- /// returned is not specified. However each code-block is returned only
- /// once and all code-blocks will be returned if the method is called 'N'
- /// times, where 'N' is the number of code-blocks in the tile. After all
- /// the code-blocks have been returned for the current tile calls to this
- /// method will return 'null'.
- ///
- /// When changing the current tile (through 'setTile()' or 'nextTile()')
- /// this method will always return the first code-block, as if this method
- /// was never called before for the new current tile.
- ///
- /// The data returned by this method is always a copy of the
- /// data. Therfore it can be modified "in place" without any problems after
- /// being returned. The 'offset' of the returned data is 0, and the 'scanw'
- /// is the same as the code-block width. See the 'CBlkWTData' class.
- ///
- /// The 'ulx' and 'uly' members of the returned 'CBlkWTData' object
- /// contain the coordinates of the top-left corner of the block, with
- /// respect to the tile, not the subband.
- ///
- ///
- /// The component for which to return the next code-block.
- ///
- ///
- /// If non-null this object will be used to return the new
- /// code-block. If null a new one will be allocated and returned. If the
- /// "data" array of the object is non-null it will be reused, if possible,
- /// to return the data.
- ///
- ///
- /// The next code-block in the current tile for component 'n', or
- /// null if all code-blocks for the current tile have been returned.
- ///
- ///
- ///
- ///
- ///
- public override CBlkWTData getNextCodeBlock(int c, CBlkWTData cblk)
- {
- return getNextInternCodeBlock(c, cblk);
- }
-
- /// Returns the next code-block in the current tile for the specified
- /// component. The order in which code-blocks are returned is not
- /// specified. However each code-block is returned only once and all
- /// code-blocks will be returned if the method is called 'N' times, where
- /// 'N' is the number of code-blocks in the tile. After all the code-blocks
- /// have been returned for the current tile calls to this method will
- /// return 'null'.
- ///
- /// When changing the current tile (through 'setTile()' or 'nextTile()')
- /// this method will always return the first code-block, as if this method
- /// was never called before for the new current tile.
- ///
- /// The data returned by this method can be the data in the internal
- /// buffer of this object, if any, and thus can not be modified by the
- /// caller. The 'offset' and 'scanw' of the returned data can be
- /// arbitrary. See the 'CBlkWTData' class.
- ///
- /// The 'ulx' and 'uly' members of the returned 'CBlkWTData' object
- /// contain the coordinates of the top-left corner of the block, with
- /// respect to the tile, not the subband.
- ///
- ///
- /// The component for which to return the next code-block.
- ///
- ///
- /// If non-null this object will be used to return the new
- /// code-block. If null a new one will be allocated and returned. If the
- /// "data" array of the object is non-null it will be reused, if possible,
- /// to return the data.
- ///
- ///
- /// The next code-block in the current tile for component 'n', or
- /// null if all code-blocks for the current tile have been returned.
- ///
- ///
- ///
- ///
- ///
- public override CBlkWTData getNextInternCodeBlock(int c, CBlkWTData cblk)
- {
- // NOTE: this method is declared final since getNextCodeBlock() relies
- // on this particular implementation
- int k, j;
- int tmp, shiftBits, jmin;
- int w, h;
- int[] outarr;
- float[] infarr = null;
- CBlkWTDataFloat infblk;
- float invstep; // The inverse of the quantization step size
- bool intq; // flag for quantizig ints
- SubbandAn sb;
- float stepUDR; // The quantization step size (for a dynamic
- // range of 1, or unit)
- int g = ((System.Int32)gbs.getTileCompVal(tIdx, c));
-
- // Are we quantizing ints or floats?
- intq = (src.getDataType(tIdx, c) == DataBlk.TYPE_INT);
-
- // Check that we have an output object
- if (cblk == null)
- {
- cblk = new CBlkWTDataInt();
- }
-
- // Cache input float code-block
- infblk = this.infblk;
-
- // Get data to quantize. When quantizing int data 'cblk' is used to
- // get the data to quantize and to return the quantized data as well,
- // that's why 'getNextCodeBlock()' is used. This can not be done when
- // quantizing float data because of the different data types, that's
- // why 'getNextInternCodeBlock()' is used in that case.
- if (intq)
- {
- // Source data is int
- cblk = src.getNextCodeBlock(c, cblk);
- if (cblk == null)
- {
- return null; // No more code-blocks in current tile for comp.
- }
- // Input and output arrays are the same (for "in place" quant.)
- outarr = (int[])cblk.Data;
- }
- else
- {
- // Source data is float
- // Can not use 'cblk' to get float data, use 'infblk'
- infblk = (CBlkWTDataFloat)src.getNextInternCodeBlock(c, infblk);
- if (infblk == null)
- {
- // Release buffer from infblk: this enables to garbage collect
- // the big buffer when we are done with last code-block of
- // component.
- this.infblk.Data = null;
- return null; // No more code-blocks in current tile for comp.
- }
- this.infblk = infblk; // Save local cache
- infarr = (float[])infblk.Data;
- // Get output data array and check that there is memory to put the
- // quantized coeffs in
- outarr = (int[])cblk.Data;
- if (outarr == null || outarr.Length < infblk.w * infblk.h)
- {
- outarr = new int[infblk.w * infblk.h];
- cblk.Data = outarr;
- }
- cblk.m = infblk.m;
- cblk.n = infblk.n;
- cblk.sb = infblk.sb;
- cblk.ulx = infblk.ulx;
- cblk.uly = infblk.uly;
- cblk.w = infblk.w;
- cblk.h = infblk.h;
- cblk.wmseScaling = infblk.wmseScaling;
- cblk.offset = 0;
- cblk.scanw = cblk.w;
- }
-
- // Cache width, height and subband of code-block
- w = cblk.w;
- h = cblk.h;
- sb = cblk.sb;
-
- if (isReversible(tIdx, c))
- {
- // Reversible only for int data
- cblk.magbits = g - 1 + src.getNomRangeBits(c) + sb.anGainExp;
- shiftBits = 31 - cblk.magbits;
-
- // Update the convertFactor field
- cblk.convertFactor = (1 << shiftBits);
-
- // Since we used getNextCodeBlock() to get the int data then
- // 'offset' is 0 and 'scanw' is the width of the code-block The
- // input and output arrays are the same (i.e. "in place")
- for (j = w * h - 1; j >= 0; j--)
- {
- tmp = (outarr[j] << shiftBits);
- outarr[j] = ((tmp < 0) ? (1 << 31) | (-tmp) : tmp);
- }
- }
- else
- {
- // Non-reversible, use step size
- //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Float.floatValue' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'"
- float baseStep = (float)((System.Single)qsss.getTileCompVal(tIdx, c));
-
- // Calculate magnitude bits and quantization step size
- if (isDerived(tIdx, c))
- {
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- cblk.magbits = g - 1 + sb.level - (int)System.Math.Floor(System.Math.Log(baseStep) / log2);
- stepUDR = baseStep / (1 << sb.level);
- }
- else
- {
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- cblk.magbits = g - 1 - (int)System.Math.Floor(System.Math.Log(baseStep / (sb.l2Norm * (1 << sb.anGainExp))) / log2);
- stepUDR = baseStep / (sb.l2Norm * (1 << sb.anGainExp));
- }
- shiftBits = 31 - cblk.magbits;
- // Calculate step that decoder will get and use that one.
- stepUDR = convertFromExpMantissa(convertToExpMantissa(stepUDR));
- invstep = 1.0f / ((1L << (src.getNomRangeBits(c) + sb.anGainExp)) * stepUDR);
- // Normalize to magnitude bits (output fractional point)
- invstep *= (1 << (shiftBits - src.getFixedPoint(c)));
-
- // Update convertFactor and stepSize fields
- cblk.convertFactor = invstep;
- cblk.stepSize = ((1L << (src.getNomRangeBits(c) + sb.anGainExp)) * stepUDR);
-
- if (intq)
- {
- // Quantizing int data
- // Since we used getNextCodeBlock() to get the int data then
- // 'offset' is 0 and 'scanw' is the width of the code-block
- // The input and output arrays are the same (i.e. "in place")
- for (j = w * h - 1; j >= 0; j--)
- {
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- tmp = (int)(outarr[j] * invstep);
- outarr[j] = ((tmp < 0) ? (1 << 31) | (-tmp) : tmp);
- }
- }
- else
- {
- // Quantizing float data
- for (j = w * h - 1, k = infblk.offset + (h - 1) * infblk.scanw + w - 1, jmin = w * (h - 1); j >= 0; jmin -= w)
- {
- for (; j >= jmin; k--, j--)
- {
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- tmp = (int)(infarr[k] * invstep);
- outarr[j] = ((tmp < 0) ? (1 << 31) | (-tmp) : tmp);
- }
- // Jump to beggining of previous line in input
- k -= (infblk.scanw - w);
- }
- }
- }
- // Return the quantized code-block
- return cblk;
- }
-
- /// Calculates the parameters of the SubbandAn objects that depend on the
- /// Quantizer. The 'stepWMSE' field is calculated for each subband which is
- /// a leaf in the tree rooted at 'sb', for the specified component. The
- /// subband tree 'sb' must be the one for the component 'n'.
- ///
- ///
- /// The root of the subband tree.
- ///
- ///
- /// The component index
- ///
- ///
- ///
- ///
- ///
- protected internal override void calcSbParams(SubbandAn sb, int c)
- {
- float baseStep;
-
- if (sb.stepWMSE > 0f)
- // parameters already calculated
- return;
- if (!sb.isNode)
- {
- if (isReversible(tIdx, c))
- {
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- sb.stepWMSE = (float)System.Math.Pow(2, -(src.getNomRangeBits(c) << 1)) * sb.l2Norm * sb.l2Norm;
- }
- else
- {
- //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Float.floatValue' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'"
- baseStep = (float)((System.Single)qsss.getTileCompVal(tIdx, c));
- if (isDerived(tIdx, c))
- {
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- sb.stepWMSE = baseStep * baseStep * (float)System.Math.Pow(2, (sb.anGainExp - sb.level) << 1) * sb.l2Norm * sb.l2Norm;
- }
- else
- {
- sb.stepWMSE = baseStep * baseStep;
- }
- }
- }
- else
- {
- calcSbParams((SubbandAn)sb.LL, c);
- calcSbParams((SubbandAn)sb.HL, c);
- calcSbParams((SubbandAn)sb.LH, c);
- calcSbParams((SubbandAn)sb.HH, c);
- sb.stepWMSE = 1f; // Signal that we already calculated this branch
- }
- }
-
- /// Converts the floating point value to its exponent-mantissa
- /// representation. The mantissa occupies the 11 least significant bits
- /// (bits 10-0), and the exponent the previous 5 bits (bits 15-11).
- ///
- ///
- /// The quantization step, normalized to a dynamic range of 1.
- ///
- ///
- /// The exponent mantissa representation of the step.
- ///
- ///
- public static int convertToExpMantissa(float step)
- {
- int exp;
-
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- exp = (int)System.Math.Ceiling((-System.Math.Log(step)) / log2);
- if (exp > QSTEP_MAX_EXPONENT)
- {
- // If step size is too small for exponent representation, use the
- // minimum, which is exponent QSTEP_MAX_EXPONENT and mantissa 0.
- return (QSTEP_MAX_EXPONENT << QSTEP_MANTISSA_BITS);
- }
- // NOTE: this formula does not support more than 5 bits for the
- // exponent, otherwise (-1< Converts the exponent-mantissa representation to its floating-point
- /// value. The mantissa occupies the 11 least significant bits (bits 10-0),
- /// and the exponent the previous 5 bits (bits 15-11).
- ///
- ///
- /// The exponent-mantissa representation of the step.
- ///
- ///
- /// The floating point representation of the step, normalized to a
- /// dynamic range of 1.
- ///
- ///
- private static float convertFromExpMantissa(int ems)
- {
- // NOTE: this formula does not support more than 5 bits for the
- // exponent, otherwise (-1<> QSTEP_MANTISSA_BITS) & QSTEP_MAX_EXPONENT));
- }
-
- /// Returns the maximum number of magnitude bits in any subband of the
- /// current tile.
- ///
- ///
- /// the component number
- ///
- ///
- /// The maximum number of magnitude bits in all subbands of the
- /// current tile.
- ///
- ///
- public override int getMaxMagBits(int c)
- {
- Subband sb = getAnSubbandTree(tIdx, c);
- if (isReversible(tIdx, c))
- {
- return getMaxMagBitsRev(sb, c);
- }
- else
- {
- if (isDerived(tIdx, c))
- {
- return getMaxMagBitsDerived(sb, tIdx, c);
- }
- else
- {
- return getMaxMagBitsExpounded(sb, tIdx, c);
- }
- }
- }
-
-
- /// Returns the maximum number of magnitude bits in any subband of the
- /// current tile if reversible quantization is used
- ///
- ///
- /// The root of the subband tree of the current tile
- ///
- ///
- /// the component number
- ///
- ///
- /// The highest number of magnitude bit-planes
- ///
- ///
- private int getMaxMagBitsRev(Subband sb, int c)
- {
- int tmp, max = 0;
- int g = ((System.Int32)gbs.getTileCompVal(tIdx, c));
-
- if (!sb.isNode)
- return g - 1 + src.getNomRangeBits(c) + sb.anGainExp;
-
- max = getMaxMagBitsRev(sb.LL, c);
- tmp = getMaxMagBitsRev(sb.LH, c);
- if (tmp > max)
- max = tmp;
- tmp = getMaxMagBitsRev(sb.HL, c);
- if (tmp > max)
- max = tmp;
- tmp = getMaxMagBitsRev(sb.HH, c);
- if (tmp > max)
- max = tmp;
-
- return max;
- }
-
- /// Returns the maximum number of magnitude bits in any subband in the
- /// given tile-component if derived quantization is used
- ///
- ///
- /// The root of the subband tree of the tile-component
- ///
- ///
- /// Tile index
- ///
- ///
- /// Component index
- ///
- ///
- /// The highest number of magnitude bit-planes
- ///
- ///
- private int getMaxMagBitsDerived(Subband sb, int t, int c)
- {
- int tmp, max = 0;
- int g = ((System.Int32)gbs.getTileCompVal(t, c));
-
- if (!sb.isNode)
- {
- //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Float.floatValue' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'"
- float baseStep = (float)((System.Single)qsss.getTileCompVal(t, c));
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- return g - 1 + sb.level - (int)System.Math.Floor(System.Math.Log(baseStep) / log2);
- }
-
- max = getMaxMagBitsDerived(sb.LL, t, c);
- tmp = getMaxMagBitsDerived(sb.LH, t, c);
- if (tmp > max)
- max = tmp;
- tmp = getMaxMagBitsDerived(sb.HL, t, c);
- if (tmp > max)
- max = tmp;
- tmp = getMaxMagBitsDerived(sb.HH, t, c);
- if (tmp > max)
- max = tmp;
-
- return max;
- }
-
-
- /// Returns the maximum number of magnitude bits in any subband in the
- /// given tile-component if expounded quantization is used
- ///
- ///
- /// The root of the subband tree of the tile-component
- ///
- ///
- /// Tile index
- ///
- ///
- /// Component index
- ///
- ///
- /// The highest number of magnitude bit-planes
- ///
- ///
- private int getMaxMagBitsExpounded(Subband sb, int t, int c)
- {
- int tmp, max = 0;
- int g = ((System.Int32)gbs.getTileCompVal(t, c));
-
- if (!sb.isNode)
- {
- //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Float.floatValue' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'"
- float baseStep = (float)((System.Single)qsss.getTileCompVal(t, c));
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- return g - 1 - (int)System.Math.Floor(System.Math.Log(baseStep / (((SubbandAn)sb).l2Norm * (1 << sb.anGainExp))) / log2);
- }
-
- max = getMaxMagBitsExpounded(sb.LL, t, c);
- tmp = getMaxMagBitsExpounded(sb.LH, t, c);
- if (tmp > max)
- max = tmp;
- tmp = getMaxMagBitsExpounded(sb.HL, t, c);
- if (tmp > max)
- max = tmp;
- tmp = getMaxMagBitsExpounded(sb.HH, t, c);
- if (tmp > max)
- max = tmp;
-
- return max;
- }
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/roi/MaxShiftSpec.cs b/CSJ2K/j2k/roi/MaxShiftSpec.cs
deleted file mode 100644
index 0f4ba01a..00000000
--- a/CSJ2K/j2k/roi/MaxShiftSpec.cs
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
-* CVS identifier:
-*
-* $Id: MaxShiftSpec.java,v 1.10 2000/11/27 15:00:45 grosbois Exp $
-*
-* Class: MaxShiftSpec
-*
-* Description: Generic class for storing module specs
-*
-*
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-*/
-namespace CSJ2K.j2k.roi
-{
-
- /// This class contains the maxshift scaling value for each tile-component.
- /// The scaling values used are calculated in the ROIScaler class
- ///
- ///
-
- public class MaxShiftSpec : ModuleSpec
- {
-
- /// Constructs a 'ModuleSpec' object, initializing all the components and
- /// tiles to the 'SPEC_DEF' spec type, for the specified number of
- /// components and tiles.
- ///
- ///
- /// The number of tiles
- ///
- ///
- /// The number of components
- ///
- ///
- /// the type of the specification module i.e. tile specific,
- /// component specific or both.
- ///
- ///
- public MaxShiftSpec(int nt, int nc, byte type) : base(nt, nc, type)
- {
- }
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/roi/ROIDeScaler.cs b/CSJ2K/j2k/roi/ROIDeScaler.cs
deleted file mode 100644
index 38bdd1cf..00000000
--- a/CSJ2K/j2k/roi/ROIDeScaler.cs
+++ /dev/null
@@ -1,375 +0,0 @@
-/*
-* CVS identifier:
-*
-* $Id: ROIDeScaler.java,v 1.39 2001/10/24 12:02:51 grosbois Exp $
-*
-*
-* Class: ROIDeScaler
-*
-* Description: The class taking care of de-scaling ROI coeffs.
-*
-*
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-* */
-using CSJ2K.j2k.decoder;
-using CSJ2K.j2k.image;
-using CSJ2K.j2k.quantization.dequantizer;
-using CSJ2K.j2k.util;
-using CSJ2K.j2k.wavelet.synthesis;
-namespace CSJ2K.j2k.roi
-{
-
- /// This class takes care of the de-scaling of ROI coefficients. The de-scaler
- /// works on a tile basis and any mask that is generated is for the current
- /// mask only
- ///
- /// Default implementations of the methods in 'MultiResImgData' are provided
- /// through the 'MultiResImgDataAdapter' abstract class.
- ///
- /// Sign-magnitude representation is used (instead of two's complement) for
- /// the output data. The most significant bit is used for the sign (0 if
- /// positive, 1 if negative). Then the magnitude of the quantized coefficient
- /// is stored in the next most significat bits. The most significant magnitude
- /// bit corresponds to the most significant bit-plane and so on.
- ///
- ///
- public class ROIDeScaler : MultiResImgDataAdapter, CBlkQuantDataSrcDec
- {
- /// Returns the horizontal code-block partition origin. Allowable values
- /// are 0 and 1, nothing else.
- ///
- ///
- virtual public int CbULX
- {
- get
- {
- return src.CbULX;
- }
-
- }
- /// Returns the vertical code-block partition origin. Allowable values are
- /// 0 and 1, nothing else.
- ///
- ///
- virtual public int CbULY
- {
- get
- {
- return src.CbULY;
- }
-
- }
- /// Returns the parameters that are used in this class and implementing
- /// classes. It returns a 2D String array. Each of the 1D arrays is for a
- /// different option, and they have 3 elements. The first element is the
- /// option name, the second one is the synopsis and the third one is a long
- /// description of what the parameter is. The synopsis or description may
- /// be 'null', in which case it is assumed that there is no synopsis or
- /// description of the option, respectively. Null may be returned if no
- /// options are supported.
- ///
- ///
- /// the options name, their synopsis and their explanation, or null
- /// if no options are supported.
- ///
- ///
- public static System.String[][] ParameterInfo
- {
- get
- {
- return pinfo;
- }
-
- }
-
- /// The MaxShiftSpec containing the scaling values for all tile-components
- ///
- ///
- private MaxShiftSpec mss;
-
- /// The prefix for ROI decoder options: 'R'
- public const char OPT_PREFIX = 'R';
-
- /// The list of parameters that is accepted by the entropy decoders. They
- /// start with 'R'.
- ///
- //UPGRADE_NOTE: Final was removed from the declaration of 'pinfo'. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- private static readonly System.String[][] pinfo = new System.String[][] { new System.String[] { "Rno_roi", null, "This argument makes sure that the no ROI de-scaling is performed. " + "Decompression is done like there is no ROI in the image", null } };
-
- /// The entropy decoder from where to get the compressed data (the source)
- ///
- ///
- private CBlkQuantDataSrcDec src;
-
- /// Constructor of the ROI descaler, takes EntropyDEcoder as source of data
- /// to de-scale.
- ///
- ///
- /// The EntropyDecoder that is the source of data.
- ///
- ///
- /// The MaxShiftSpec containing the scaling values for all
- /// tile-components
- ///
- ///
- public ROIDeScaler(CBlkQuantDataSrcDec src, MaxShiftSpec mss) : base(src)
- {
- this.src = src;
- this.mss = mss;
- }
-
- /// Returns the subband tree, for the specified tile-component. This method
- /// returns the root element of the subband tree structure, see Subband and
- /// SubbandSyn. The tree comprises all the available resolution levels.
- ///
- /// The number of magnitude bits ('magBits' member variable) for each
- /// subband is not initialized.
- ///
- ///
- /// The index of the tile, from 0 to T-1.
- ///
- ///
- /// The index of the component, from 0 to C-1.
- ///
- ///
- /// The root of the tree structure.
- ///
- ///
- public override SubbandSyn getSynSubbandTree(int t, int c)
- {
- return src.getSynSubbandTree(t, c);
- }
-
- /// Returns the specified code-block in the current tile for the specified
- /// component, as a copy (see below).
- ///
- /// The returned code-block may be progressive, which is indicated by
- /// the 'progressive' variable of the returned 'DataBlk' object. If a
- /// code-block is progressive it means that in a later request to this
- /// method for the same code-block it is possible to retrieve data which is
- /// a better approximation, since meanwhile more data to decode for the
- /// code-block could have been received. If the code-block is not
- /// progressive then later calls to this method for the same code-block
- /// will return the exact same data values.
- ///
- /// The data returned by this method is always a copy of the internal
- /// data of this object, if any, and it can be modified "in place" without
- /// any problems after being returned. The 'offset' of the returned data is
- /// 0, and the 'scanw' is the same as the code-block width. See the
- /// 'DataBlk' class.
- ///
- /// The 'ulx' and 'uly' members of the returned 'DataBlk' object contain
- /// the coordinates of the top-left corner of the block, with respect to
- /// the tile, not the subband.
- ///
- ///
- /// The component for which to return the next code-block.
- ///
- ///
- /// The vertical index of the code-block to return, in the
- /// specified subband.
- ///
- ///
- /// The horizontal index of the code-block to return, in the
- /// specified subband.
- ///
- ///
- /// The subband in which the code-block to return is.
- ///
- ///
- /// If non-null this object will be used to return the new
- /// code-block. If null a new one will be allocated and returned. If the
- /// "data" array of the object is non-null it will be reused, if possible,
- /// to return the data.
- ///
- ///
- /// The next code-block in the current tile for component 'c', or
- /// null if all code-blocks for the current tile have been returned.
- ///
- ///
- ///
- ///
- ///
- public virtual DataBlk getCodeBlock(int c, int m, int n, SubbandSyn sb, DataBlk cblk)
- {
- return getInternCodeBlock(c, m, n, sb, cblk);
- }
-
- /// Returns the specified code-block in the current tile for the specified
- /// component (as a reference or copy).
- ///
- /// The returned code-block may be progressive, which is indicated by
- /// the 'progressive' variable of the returned 'DataBlk' object. If a
- /// code-block is progressive it means that in a later request to this
- /// method for the same code-block it is possible to retrieve data which is
- /// a better approximation, since meanwhile more data to decode for the
- /// code-block could have been received. If the code-block is not
- /// progressive then later calls to this method for the same code-block
- /// will return the exact same data values.
- ///
- /// The data returned by this method can be the data in the internal
- /// buffer of this object, if any, and thus can not be modified by the
- /// caller. The 'offset' and 'scanw' of the returned data can be
- /// arbitrary. See the 'DataBlk' class.
- ///
- /// The 'ulx' and 'uly' members of the returned 'DataBlk' object contain
- /// the coordinates of the top-left corner of the block, with respect to
- /// the tile, not the subband.
- ///
- ///
- /// The component for which to return the next code-block.
- ///
- ///
- /// The vertical index of the code-block to return, in the
- /// specified subband.
- ///
- ///
- /// The horizontal index of the code-block to return, in the
- /// specified subband.
- ///
- ///
- /// The subband in which the code-block to return is.
- ///
- ///
- /// If non-null this object will be used to return the new
- /// code-block. If null a new one will be allocated and returned. If the
- /// "data" array of the object is non-null it will be reused, if possible,
- /// to return the data.
- ///
- ///
- /// The requested code-block in the current tile for component 'c'.
- ///
- ///
- ///
- ///
- ///
- public virtual DataBlk getInternCodeBlock(int c, int m, int n, SubbandSyn sb, DataBlk cblk)
- {
- int i, j, k, wrap; // mi removed
- int ulx, uly, w, h;
- int[] data; // local copy of quantized data
- int tmp;
- //int limit;
-
- // Get data block from entropy decoder
- cblk = src.getInternCodeBlock(c, m, n, sb, cblk);
-
- // If there are no ROIs in the tile, Or if we already got all blocks
- bool noRoiInTile = false;
- if (mss == null || mss.getTileCompVal(TileIdx, c) == null)
- noRoiInTile = true;
-
- if (noRoiInTile || cblk == null)
- {
- return cblk;
- }
- data = (int[])cblk.Data;
- ulx = cblk.ulx;
- uly = cblk.uly;
- w = cblk.w;
- h = cblk.h;
-
- // Scale coefficients according to magnitude. If the magnitude of a
- // coefficient is lower than 2 pow 31-magbits then it is a background
- // coeff and should be up-scaled
- int boost = ((System.Int32)mss.getTileCompVal(TileIdx, c));
- int mask = ((1 << sb.magbits) - 1) << (31 - sb.magbits);
- int mask2 = (~mask) & 0x7FFFFFFF;
-
- wrap = cblk.scanw - w;
- i = cblk.offset + cblk.scanw * (h - 1) + w - 1;
- for (j = h; j > 0; j--)
- {
- for (k = w; k > 0; k--, i--)
- {
- tmp = data[i];
- if ((tmp & mask) == 0)
- {
- // BG
- data[i] = (tmp & unchecked((int)0x80000000)) | (tmp << boost);
- }
- else
- {
- // ROI
- if ((tmp & mask2) != 0)
- {
- // decoded more than magbits bit-planes, set
- // quantization mid-interval approx. bit just after
- // the magbits.
- data[i] = (tmp & (~mask2)) | (1 << (30 - sb.magbits));
- }
- }
- }
- i -= wrap;
- }
- return cblk;
- }
-
- /// Creates a ROIDeScaler object. The information needed to create the
- /// object is the Entropy decoder used and the parameters.
- ///
- ///
- /// The source of data that is to be descaled
- ///
- ///
- /// The parameter list (or options).
- ///
- ///
- /// The decoding specifications
- ///
- ///
- /// If an error occurs while parsing
- /// the options in 'pl'
- ///
- ///
- public static ROIDeScaler createInstance(CBlkQuantDataSrcDec src, ParameterList pl, DecoderSpecs decSpec)
- {
- System.String noRoi;
- //int i;
-
- // Check parameters
- pl.checkList(OPT_PREFIX, CSJ2K.j2k.util.ParameterList.toNameArray(pinfo));
-
- // Check if no_roi specified in command line or no roi signalled
- // in bit stream
- noRoi = pl.getParameter("Rno_roi");
- if (noRoi != null || decSpec.rois == null)
- {
- // no_roi specified in commandline!
- return new ROIDeScaler(src, null);
- }
-
- return new ROIDeScaler(src, decSpec.rois);
- }
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/roi/encoder/ArbROIMaskGenerator.cs b/CSJ2K/j2k/roi/encoder/ArbROIMaskGenerator.cs
deleted file mode 100644
index 7eef4d11..00000000
--- a/CSJ2K/j2k/roi/encoder/ArbROIMaskGenerator.cs
+++ /dev/null
@@ -1,619 +0,0 @@
-/*
-* CVS identifier:
-*
-* $Id: ArbROIMaskGenerator.java,v 1.4 2001/01/03 15:10:21 qtxjoas Exp $
-*
-* Class: ArbROIMaskGenerator
-*
-* Description: Generates masks when only rectangular ROIs exist
-*
-*
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-* */
-using CSJ2K.j2k.image;
-using CSJ2K.j2k.image.input;
-using CSJ2K.j2k.quantization.quantizer;
-using CSJ2K.j2k.wavelet;
-namespace CSJ2K.j2k.roi.encoder
-{
-
- /// This class generates the ROI bit-mask when, at least, one ROI is not
- /// rectangular. In this case, the fast ROI bit-mask algorithm generation can
- /// not be used.
- ///
- /// The values are calculated from the scaling factors of the ROIs. The
- /// values with which to scale are equal to u-umin where umin is the lowest
- /// scaling factor within the block. The umin value is sent to the entropy
- /// coder to be used for scaling the distortion values.
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- public class ArbROIMaskGenerator : ROIMaskGenerator
- {
-
- /// The source of quantized wavelet transform coefficients
- private Quantizer src;
-
- /// The ROI mask for the current tile for all components
- private int[][] roiMask;
-
- /// The low frequency part of a mask line
- private int[] maskLineLow;
-
- /// The High frequency part of a mask line
- private int[] maskLineHigh;
-
- /// A line or column of the mask with padding
- private int[] paddedMaskLine;
-
- /// Flag indicating if any ROI was found to be in this tile
- new private bool roiInTile;
-
- /// The constructor of the arbitrary mask generator
- ///
- ///
- /// The ROI info.
- ///
- ///
- /// The number of components
- ///
- ///
- /// The quantizer module
- ///
- ///
- public ArbROIMaskGenerator(ROI[] rois, int nrc, Quantizer src) : base(rois, nrc)
- {
- roiMask = new int[nrc][];
- this.src = src;
- }
-
- /// This functions gets a DataBlk the size of the current code-block an
- /// fills this block with the ROI mask.
- ///
- /// In order to get the mask for a particular Subband, the subband tree
- /// is traversed and at each decomposition, the ROI masks are computed.
- ///
- ///
The widths of the synthesis filters corresponding to the wavelet
- /// filters used in the wavelet transform are used to expand the ROI masks
- /// in the decompositions.
- ///
- ///
- /// The data block that is to be filled with the mask
- ///
- ///
- /// The root of the subband tree to which db belongs
- ///
- ///
- /// The max number of magnitude bits in any code-block
- ///
- ///
- /// The number of the component
- ///
- ///
- /// Whether or not a mask was needed for this tile
- ///
- ///
- public override bool getROIMask(DataBlkInt db, Subband sb, int magbits, int c)
- {
- int x = db.ulx;
- int y = db.uly;
- int w = db.w;
- int h = db.h;
- int tilew = sb.w;
- int tileh = sb.h;
- int[] maskData = (int[])db.Data;
- int i, j, k, bi, wrap;
-
- // If the ROI mask has not been calculated for this tile and
- // component, do so now.
- if (!tileMaskMade[c])
- {
- makeMask(sb, magbits, c);
- tileMaskMade[c] = true;
- }
- if (!roiInTile)
- return false;
-
- int[] mask = roiMask[c]; // local copy
-
- // Copy relevant part of the ROI mask to the datablock
- i = (y + h - 1) * tilew + x + w - 1;
- bi = w * h - 1;
- wrap = tilew - w;
- for (j = h; j > 0; j--)
- {
- for (k = w; k > 0; k--, i--, bi--)
- {
- maskData[bi] = mask[i];
- }
- i -= wrap;
- }
- return true;
- }
-
- /// This function returns the relevant data of the mask generator
- ///
- ///
- public override System.String ToString()
- {
- return ("Fast rectangular ROI mask generator");
- }
-
- /// This function generates the ROI mask for one tile-component.
- ///
- /// Once the mask is generated in the pixel domain. it is decomposed
- /// following the same decomposition scheme as the wavelet transform.
- ///
- ///
- /// The root of the subband tree used in the decomposition
- ///
- ///
- /// The max number of magnitude bits in any code-block
- ///
- ///
- /// component number
- ///
- public override void makeMask(Subband sb, int magbits, int c)
- {
- int[] mask; // local copy
- ROI[] rois = this.roi_array; // local copy
- int i, j, k, r, maxj; // mink, minj removed
- int lrx, lry;
- int x, y, w, h;
- int cx, cy, rad;
- int wrap;
- int curScalVal;
- int tileulx = sb.ulcx;
- int tileuly = sb.ulcy;
- int tilew = sb.w;
- int tileh = sb.h;
- int lineLen = (tilew > tileh) ? tilew : tileh;
-
- // Make sure there is a sufficiently large mask buffer
- if (roiMask[c] == null || (roiMask[c].Length < (tilew * tileh)))
- {
- roiMask[c] = new int[tilew * tileh];
- mask = roiMask[c];
- }
- else
- {
- mask = roiMask[c];
- for (i = tilew * tileh - 1; i >= 0; i--)
- mask[i] = 0;
- }
-
- // Make sure there are sufficiently large line buffers
- if (maskLineLow == null || (maskLineLow.Length < (lineLen + 1) / 2))
- maskLineLow = new int[(lineLen + 1) / 2];
- if (maskLineHigh == null || (maskLineHigh.Length < (lineLen + 1) / 2))
- maskLineHigh = new int[(lineLen + 1) / 2];
-
- roiInTile = false;
- // Generate ROIs in pixel domain:
- for (r = rois.Length - 1; r >= 0; r--)
- {
- if (rois[r].comp == c)
- {
- curScalVal = magbits;
-
- if (rois[r].arbShape)
- {
- ImgReaderPGM maskPGM = rois[r].maskPGM; // Local copy
-
- if ((src.ImgWidth != maskPGM.ImgWidth) || (src.ImgHeight != maskPGM.ImgHeight))
- throw new System.ArgumentException("Input image and" + " ROI mask must " + "have the same " + "size");
- x = src.ImgULX;
- y = src.ImgULY;
- lrx = x + src.ImgWidth - 1;
- lry = y + src.ImgHeight - 1;
- if ((x > tileulx + tilew) || (y > tileuly + tileh) || (lrx < tileulx) || (lry < tileuly))
- // Roi not in tile
- continue;
-
- // Check bounds
- x -= tileulx;
- lrx -= tileulx;
- y -= tileuly;
- lry -= tileuly;
-
- int offx = 0;
- int offy = 0;
- if (x < 0)
- {
- offx = -x;
- x = 0;
- }
- if (y < 0)
- {
- offy = -y;
- y = 0;
- }
- w = (lrx > (tilew - 1)) ? tilew - x : lrx + 1 - x;
- h = (lry > (tileh - 1)) ? tileh - y : lry + 1 - y;
-
-
- // Get shape line by line to reduce memory
- DataBlkInt srcblk = new DataBlkInt();
- int mDcOff = -ImgReaderPGM.DC_OFFSET;
- int nROIcoeff = 0;
- int[] src_data;
- srcblk.ulx = offx;
- srcblk.w = w;
- srcblk.h = 1;
-
- i = (y + h - 1) * tilew + x + w - 1;
- maxj = w;
- wrap = tilew - maxj;
- for (k = h; k > 0; k--)
- {
- srcblk.uly = offy + k - 1;
- srcblk = (DataBlkInt)maskPGM.getInternCompData(srcblk, 0);
- src_data = srcblk.DataInt;
-
- for (j = maxj; j > 0; j--, i--)
- {
- if (src_data[j - 1] != mDcOff)
- {
- mask[i] = curScalVal;
- nROIcoeff++;
- }
- }
- i -= wrap;
- }
-
- if (nROIcoeff != 0)
- {
- roiInTile = true;
- }
- }
- else if (rois[r].rect)
- {
- // Rectangular ROI
- x = rois[r].ulx;
- y = rois[r].uly;
- lrx = rois[r].w + x - 1;
- lry = rois[r].h + y - 1;
-
- if ((x > tileulx + tilew) || (y > tileuly + tileh) || (lrx < tileulx) || (lry < tileuly))
- // Roi not in tile
- continue;
-
- roiInTile = true;
-
- // Check bounds
- x -= tileulx;
- lrx -= tileulx;
- y -= tileuly;
- lry -= tileuly;
-
- x = (x < 0) ? 0 : x;
- y = (y < 0) ? 0 : y;
- w = (lrx > (tilew - 1)) ? tilew - x : lrx + 1 - x;
- h = (lry > (tileh - 1)) ? tileh - y : lry + 1 - y;
-
- i = (y + h - 1) * tilew + x + w - 1;
- maxj = w;
- wrap = tilew - maxj;
- for (k = h; k > 0; k--)
- {
- for (j = maxj; j > 0; j--, i--)
- {
- mask[i] = curScalVal;
- }
- i -= wrap;
- }
- }
- else
- {
- // Non-rectangular ROI. So far only circular case
- cx = rois[r].x - tileulx;
- cy = rois[r].y - tileuly;
- rad = rois[r].r;
- i = tileh * tilew - 1;
- for (k = tileh - 1; k >= 0; k--)
- {
- for (j = tilew - 1; j >= 0; j--, i--)
- {
- if (((j - cx) * (j - cx) + (k - cy) * (k - cy) < rad * rad))
- {
- mask[i] = curScalVal;
- roiInTile = true;
- }
- }
- }
- }
- }
- }
-
- // If wavelet transform is used
- if (sb.isNode)
- {
- // Decompose the mask according to the subband tree
- // Calculate size of padded line buffer
- WaveletFilter vFilter = sb.VerWFilter;
- WaveletFilter hFilter = sb.HorWFilter;
- int lvsup = vFilter.SynLowNegSupport + vFilter.SynLowPosSupport;
- int hvsup = vFilter.SynHighNegSupport + vFilter.SynHighPosSupport;
- int lhsup = hFilter.SynLowNegSupport + hFilter.SynLowPosSupport;
- int hhsup = hFilter.SynHighNegSupport + hFilter.SynHighPosSupport;
- lvsup = (lvsup > hvsup) ? lvsup : hvsup;
- lhsup = (lhsup > hhsup) ? lhsup : hhsup;
- lvsup = (lvsup > lhsup) ? lvsup : lhsup;
- paddedMaskLine = new int[lineLen + lvsup];
-
- if (roiInTile)
- decomp(sb, tilew, tileh, c);
- }
- }
-
- /// This function decomposes the mask for a node in the subband tree.
- /// after the mask is decomposed for a node, this function is called for
- /// the children of the subband. The decomposition is done line by line
- /// and column by column
- ///
- ///
- /// The subband that is to be used for the decomposition
- ///
- ///
- /// The width of the current tile
- ///
- ///
- /// The height of the current tile
- ///
- ///
- /// component number
- ///
- private void decomp(Subband sb, int tilew, int tileh, int c)
- {
- int ulx = sb.ulx;
- int uly = sb.uly;
- int w = sb.w;
- int h = sb.h;
- int scalVal, maxVal = 0;
- int j, k, s, mi = 0, pin; // i, hi, li removed
- int hmax, lmax; // smax removed
- int lineoffs; // wrap, lastlow removed
- int[] mask = roiMask[c]; // local copy
- int[] low = maskLineLow; // local copy
- int[] high = maskLineHigh; // local copy
- int[] padLine = paddedMaskLine; // local copy
- int highFirst = 0;
- int lastpin;
-
-
- if (!sb.isNode)
- return;
-
- // HORIZONTAL DECOMPOSITION
-
- // Calculate number of high and low samples after decomposition
- // and get support for low and high filters
- WaveletFilter filter = sb.HorWFilter;
- int lnSup = filter.SynLowNegSupport;
- int hnSup = filter.SynHighNegSupport;
- int lpSup = filter.SynLowPosSupport;
- int hpSup = filter.SynHighPosSupport;
- int lsup = lnSup + lpSup + 1;
- int hsup = hnSup + hpSup + 1;
-
- // Calculate number of high/low coeffis in subbands
- highFirst = sb.ulcx % 2;
- if (sb.w % 2 == 0)
- {
- lmax = w / 2 - 1;
- hmax = lmax;
- }
- else
- {
- if (highFirst == 0)
- {
- lmax = (w + 1) / 2 - 1;
- hmax = w / 2 - 1;
- }
- else
- {
- hmax = (w + 1) / 2 - 1;
- lmax = w / 2 - 1;
- }
- }
-
- int maxnSup = (lnSup > hnSup) ? lnSup : hnSup; // Maximum negative support
- int maxpSup = (lpSup > hpSup) ? lpSup : hpSup; // Maximum positive support
-
-
- // Set padding to 0
- for (pin = maxnSup - 1; pin >= 0; pin--)
- padLine[pin] = 0;
- for (pin = maxnSup + w - 1 + maxpSup; pin >= w; pin--)
- padLine[pin] = 0;
-
- // Do decomposition of all lines
- lineoffs = (uly + h) * tilew + ulx + w - 1;
- for (j = h - 1; j >= 0; j--)
- {
- lineoffs -= tilew;
- // Get the line to transform from the mask
- mi = lineoffs;
- for (k = w, pin = w - 1 + maxnSup; k > 0; k--, mi--, pin--)
- {
- padLine[pin] = mask[mi];
- }
-
- lastpin = maxnSup + highFirst + 2 * lmax + lpSup;
- for (k = lmax; k >= 0; k--, lastpin -= 2)
- {
- // Low frequency samples
- pin = lastpin;
- for (s = lsup; s > 0; s--, pin--)
- {
- scalVal = padLine[pin];
- if (scalVal > maxVal)
- maxVal = scalVal;
- }
- low[k] = maxVal;
- maxVal = 0;
- }
- lastpin = maxnSup - highFirst + 2 * hmax + 1 + hpSup;
- for (k = hmax; k >= 0; k--, lastpin -= 2)
- {
- // High frequency samples
- pin = lastpin;
- for (s = hsup; s > 0; s--, pin--)
- {
- scalVal = padLine[pin];
- if (scalVal > maxVal)
- maxVal = scalVal;
- }
- high[k] = maxVal;
- maxVal = 0;
- }
- // Put the lows and highs back
- mi = lineoffs;
- for (k = hmax; k >= 0; k--, mi--)
- {
- mask[mi] = high[k];
- }
- for (k = lmax; k >= 0; k--, mi--)
- {
- mask[mi] = low[k];
- }
- }
-
- // VERTICAL DECOMPOSITION
-
- // Calculate number of high and low samples after decomposition
- // and get support for low and high filters
- filter = sb.VerWFilter;
- lnSup = filter.SynLowNegSupport;
- hnSup = filter.SynHighNegSupport;
- lpSup = filter.SynLowPosSupport;
- hpSup = filter.SynHighPosSupport;
- lsup = lnSup + lpSup + 1;
- hsup = hnSup + hpSup + 1;
-
- // Calculate number of high/low coeffs in subbands
- highFirst = sb.ulcy % 2;
- if (sb.h % 2 == 0)
- {
- lmax = h / 2 - 1;
- hmax = lmax;
- }
- else
- {
- if (sb.ulcy % 2 == 0)
- {
- lmax = (h + 1) / 2 - 1;
- hmax = h / 2 - 1;
- }
- else
- {
- hmax = (h + 1) / 2 - 1;
- lmax = h / 2 - 1;
- }
- }
-
- maxnSup = (lnSup > hnSup) ? lnSup : hnSup; // Maximum negative support
- maxpSup = (lpSup > hpSup) ? lpSup : hpSup; // Maximum positive support
-
- // Set padding to 0
- for (pin = maxnSup - 1; pin >= 0; pin--)
- padLine[pin] = 0;
- for (pin = maxnSup + h - 1 + maxpSup; pin >= h; pin--)
- padLine[pin] = 0;
-
- // Do decomposition of all columns
- lineoffs = (uly + h - 1) * tilew + ulx + w;
- for (j = w - 1; j >= 0; j--)
- {
- lineoffs--;
- // Get the line to transform from the mask
- mi = lineoffs;
- for (k = h, pin = k - 1 + maxnSup; k > 0; k--, mi -= tilew, pin--)
- {
- padLine[pin] = mask[mi];
- }
- lastpin = maxnSup + highFirst + 2 * lmax + lpSup;
- for (k = lmax; k >= 0; k--, lastpin -= 2)
- {
- // Low frequency samples
- pin = lastpin;
- for (s = lsup; s > 0; s--, pin--)
- {
- scalVal = padLine[pin];
- if (scalVal > maxVal)
- maxVal = scalVal;
- }
- low[k] = maxVal;
- maxVal = 0;
- }
- lastpin = maxnSup - highFirst + 2 * hmax + 1 + hpSup;
- for (k = hmax; k >= 0; k--, lastpin -= 2)
- {
- // High frequency samples
- pin = lastpin;
- for (s = hsup; s > 0; s--, pin--)
- {
- scalVal = padLine[pin];
- if (scalVal > maxVal)
- maxVal = scalVal;
- }
- high[k] = maxVal;
- maxVal = 0;
- }
- // Put the lows and highs back
- mi = lineoffs;
- for (k = hmax; k >= 0; k--, mi -= tilew)
- {
- mask[mi] = high[k];
- }
- for (k = lmax; k >= 0; k--, mi -= tilew)
- {
- mask[mi] = low[k];
- }
- }
-
- if (sb.isNode)
- {
- decomp(sb.HH, tilew, tileh, c);
- decomp(sb.LH, tilew, tileh, c);
- decomp(sb.HL, tilew, tileh, c);
- decomp(sb.LL, tilew, tileh, c);
- }
- }
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/roi/encoder/ROI.cs b/CSJ2K/j2k/roi/encoder/ROI.cs
deleted file mode 100644
index ba61a1fb..00000000
--- a/CSJ2K/j2k/roi/encoder/ROI.cs
+++ /dev/null
@@ -1,170 +0,0 @@
-/*
-* CVS identifier:
-*
-* $Id: ROI.java,v 1.3 2001/01/03 15:08:15 qtxjoas Exp $
-*
-* Class: ROI
-*
-* Description: This class describes a single ROI
-*
-*
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-*/
-using CSJ2K.j2k.image.input;
-namespace CSJ2K.j2k.roi.encoder
-{
-
- /// This class contains the shape of a single ROI. In the current
- /// implementation only rectangles and circles are supported.
- ///
- ///
- ///
- ///
- public class ROI
- {
-
- /// ImgReaderPGM object with the arbrtrary ROI
- public ImgReaderPGM maskPGM = null;
-
- /// Where or not the ROI shape is arbitrary
- public bool arbShape;
-
- /// Flag indicating whether the ROI is rectangular or not
- public bool rect;
-
- /// The components for which the ROI is relevant
- public int comp;
-
- /// x coordinate of upper left corner of rectangular ROI
- public int ulx;
-
- /// y coordinate of upper left corner of rectangular ROI
- public int uly;
-
- /// width of rectangular ROI
- public int w;
-
- /// height of rectangular ROI
- public int h;
-
- /// x coordinate of center of circular ROI
- public int x;
-
- /// y coordinate of center of circular ROI
- public int y;
-
- /// radius of circular ROI
- public int r;
-
-
- /// Constructor for ROI with arbitrary shape
- ///
- ///
- /// The component the ROI belongs to
- ///
- ///
- /// ImgReaderPGM containing the ROI
- ///
- public ROI(int comp, ImgReaderPGM maskPGM)
- {
- arbShape = true;
- rect = false;
- this.comp = comp;
- this.maskPGM = maskPGM;
- }
-
- /// Constructor for rectangular ROIs
- ///
- ///
- /// The component the ROI belongs to
- ///
- ///
- /// x-coordinate of upper left corner of ROI
- ///
- ///
- /// y-coordinate of upper left corner of ROI
- ///
- ///
- /// width of ROI
- ///
- ///
- /// height of ROI
- ///
- public ROI(int comp, int ulx, int uly, int w, int h)
- {
- arbShape = false;
- this.comp = comp;
- this.ulx = ulx;
- this.uly = uly;
- this.w = w;
- this.h = h;
- rect = true;
- }
-
- /// Constructor for circular ROIs
- ///
- ///
- /// The component the ROI belongs to
- ///
- ///
- /// x-coordinate of center of ROI
- ///
- ///
- /// y-coordinate of center of ROI
- ///
- ///
- /// radius of ROI
- ///
- public ROI(int comp, int x, int y, int rad)
- {
- arbShape = false;
- this.comp = comp;
- this.x = x;
- this.y = y;
- this.r = rad;
- }
-
- /// This function prints all relevant data for the ROI
- public override System.String ToString()
- {
- if (arbShape)
- {
- return "ROI with arbitrary shape, PGM file= " + maskPGM;
- }
- else if (rect)
- return "Rectangular ROI, comp=" + comp + " ulx=" + ulx + " uly=" + uly + " w=" + w + " h=" + h;
- else
- return "Circular ROI, comp=" + comp + " x=" + x + " y=" + y + " radius=" + r;
- }
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/roi/encoder/ROIMaskGenerator.cs b/CSJ2K/j2k/roi/encoder/ROIMaskGenerator.cs
deleted file mode 100644
index 5519dd63..00000000
--- a/CSJ2K/j2k/roi/encoder/ROIMaskGenerator.cs
+++ /dev/null
@@ -1,152 +0,0 @@
-/*
-* CVS identifier:
-*
-* $Id: ROIMaskGenerator.java,v 1.2 2000/11/27 15:03:51 grosbois Exp $
-*
-* Class: ROIMaskGenerator
-*
-* Description: This class describes generators of ROI masks
-*
-*
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-*/
-using CSJ2K.j2k.image;
-using CSJ2K.j2k.wavelet;
-namespace CSJ2K.j2k.roi.encoder
-{
-
- /// This class generates the ROI masks for the ROIScaler.It gives the scaler
- /// the ROI mask for the current code-block.
- ///
- /// The values are calculated from the scaling factors of the ROIs. The
- /// values with which to scale are equal to u-umin where umin is the lowest
- /// scaling factor within the block. The umin value is sent to the entropy
- /// coder to be used for scaling the distortion values.
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- public abstract class ROIMaskGenerator
- {
- /// This function returns the ROIs in the image
- ///
- ///
- /// The ROIs in the image
- ///
- virtual public ROI[] ROIs
- {
- get
- {
- return roi_array;
- }
-
- }
-
- /// Array containing the ROIs
- protected internal ROI[] roi_array;
-
- /// Number of components
- protected internal int nrc;
-
- /// Flag indicating whether a mask has been made for the current tile
- protected internal bool[] tileMaskMade;
-
- /* Flag indicating whether there are any ROIs in this tile */
- protected internal bool roiInTile;
-
- /// The constructor of the mask generator
- ///
- ///
- /// The ROIs in the image
- ///
- ///
- /// The number of components
- ///
- public ROIMaskGenerator(ROI[] rois, int nrc)
- {
- this.roi_array = rois;
- this.nrc = nrc;
- tileMaskMade = new bool[nrc];
- }
-
- /// This functions gets a DataBlk with the size of the current code-block
- /// and fills it with the ROI mask. The lowest scaling value in the mask
- /// for this code-block is returned by the function to be used for
- /// modifying the rate distortion estimations.
- ///
- ///
- /// The data block that is to be filled with the mask
- ///
- ///
- /// The root of the current subband tree
- ///
- ///
- /// The number of magnitude bits in this code-block
- ///
- ///
- /// Component number
- ///
- ///
- /// Whether or not a mask was needed for this tile
- ///
- public abstract bool getROIMask(DataBlkInt db, Subband sb, int magbits, int c);
-
- /// This function generates the ROI mask for the entire tile. The mask is
- /// generated for one component. This method is called once for each tile
- /// and component.
- ///
- ///
- /// The root of the subband tree used in the decomposition
- ///
- ///
- /// The max number of magnitude bits in any code-block
- ///
- ///
- /// component number
- ///
- public abstract void makeMask(Subband sb, int magbits, int n);
-
- /// This function is called every time the tile is changed to indicate
- /// that there is need to make a new mask
- ///
- public virtual void tileChanged()
- {
- for (int i = 0; i < nrc; i++)
- tileMaskMade[i] = false;
- }
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/roi/encoder/ROIScaler.cs b/CSJ2K/j2k/roi/encoder/ROIScaler.cs
deleted file mode 100644
index 70ee3c99..00000000
--- a/CSJ2K/j2k/roi/encoder/ROIScaler.cs
+++ /dev/null
@@ -1,809 +0,0 @@
-/*
-* CVS identifier:
-*
-* $Id: ROIScaler.java,v 1.11 2001/09/20 12:42:20 grosbois Exp $
-*
-* Class: ROIScaler
-*
-* Description: This class takes care of the scaling of the
-* samples
-*
-*
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-* */
-using CSJ2K.j2k.encoder;
-using CSJ2K.j2k.image;
-using CSJ2K.j2k.image.input;
-using CSJ2K.j2k.quantization.quantizer;
-using CSJ2K.j2k.util;
-using CSJ2K.j2k.wavelet;
-using CSJ2K.j2k.wavelet.analysis;
-namespace CSJ2K.j2k.roi.encoder
-{
-
- /// This class deals with the ROI functionality.
- ///
- /// The ROI method is the Maxshift method. The ROIScaler works by scaling
- /// the quantized wavelet coefficients that do not affect the ROI (i.e
- /// background coefficients) so that these samples get a lower significance
- /// than the ROI ones. By scaling the coefficients sufficiently, the ROI
- /// coefficients can be recognized by their amplitude alone and no ROI mask
- /// needs to be generated at the decoder side.
- ///
- ///
The source module must be a quantizer and code-block's data is exchange
- /// with thanks to CBlkWTData instances.
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- public class ROIScaler : ImgDataAdapter, CBlkQuantDataSrcEnc
- {
- /// Returns the horizontal offset of the code-block partition. Allowable
- /// values are 0 and 1, nothing else.
- ///
- ///
- virtual public int CbULX
- {
- get
- {
- return src.CbULX;
- }
-
- }
- /// Returns the vertical offset of the code-block partition. Allowable
- /// values are 0 and 1, nothing else.
- ///
- ///
- virtual public int CbULY
- {
- get
- {
- return src.CbULY;
- }
-
- }
- /// This function returns the ROI mask generator.
- ///
- ///
- /// The roi mask generator
- ///
- virtual public ROIMaskGenerator ROIMaskGenerator
- {
- get
- {
- return mg;
- }
-
- }
- /// This function returns the blockAligned flag
- ///
- ///
- /// Flag indicating whether the ROIs were block aligned
- ///
- virtual public bool BlockAligned
- {
- get
- {
- return blockAligned;
- }
-
- }
- /// Returns the parameters that are used in this class and
- /// implementing classes. It returns a 2D String array. Each of the
- /// 1D arrays is for a different option, and they have 3
- /// elements. The first element is the option name, the second one
- /// is the synopsis, the third one is a long description of what
- /// the parameter is and the fourth is its default value. The
- /// synopsis or description may be 'null', in which case it is
- /// assumed that there is no synopsis or description of the option,
- /// respectively. Null may be returned if no options are supported.
- ///
- ///
- /// the options name, their synopsis and their explanation,
- /// or null if no options are supported.
- ///
- ///
- public static System.String[][] ParameterInfo
- {
- get
- {
- return pinfo;
- }
-
- }
-
- /// The prefix for ROI Scaler options: 'R'
- public const char OPT_PREFIX = 'R';
-
- /// The list of parameters that are accepted for ROI coding. Options
- /// for ROI Scaler start with 'R'.
- ///
- //UPGRADE_NOTE: Final was removed from the declaration of 'pinfo'. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- private static readonly System.String[][] pinfo = new System.String[][] { new System.String[] { "Rroi", "[] R " + " or [] C " + " or [] A ", "Specifies ROIs shape and location. The shape can be either " + "rectangular 'R', or circular 'C' or arbitrary 'A'. " + "Each new occurrence of an 'R', a 'C' or an 'A' is a new ROI. " + "For circular and rectangular ROIs, all values are " + "given as their pixel values relative to the canvas origin. " + "Arbitrary shapes must be included in a PGM file where non 0 " + "values correspond to ROI coefficients. The PGM file must have " + "the size as the image. " + "The component idx specifies which components " + "contain the ROI. The component index is specified as described " + "by points 3 and 4 in the general comment on tile-component idx. " + "If this option is used, the codestream is layer progressive by " + "default unless it is overridden by the 'Aptype' option.", null }, new System.String[] { "Ralign", "[on|off]", "By specifying this argument, the ROI mask will be " + "limited to covering only entire code-blocks. The ROI coding can " + "then be performed without any actual scaling of the coefficients " + "but by instead scaling the distortion estimates.", "off" }, new System.String[] { "Rstart_level", "", "This argument forces the lowest resolution levels to " + "belong to the ROI. By doing this, it is possible to avoid only " + "getting information for the ROI at an early stage of " + "transmission. = 0 means the lowest resolution level " + "belongs to the ROI, 1 means the two lowest etc. (-1 deactivates" + " the option)", "-1" }, new System.String[] { "Rno_rect", "[on|off]", "This argument makes sure that the ROI mask generation is not done " + "using the fast ROI mask generation for rectangular ROIs " + "regardless of whether the specified ROIs are rectangular or not", "off" } };
-
- /// The maximum number of magnitude bit-planes in any subband. One value
- /// for each tile-component
- ///
- private int[][] maxMagBits;
-
- /// Flag indicating the presence of ROIs
- private bool roi;
-
- /// Flag indicating if block aligned ROIs are used
- private bool blockAligned;
-
- /// Number of resolution levels to include in ROI mask
- private int useStartLevel;
-
- /// The class generating the ROI mask
- private ROIMaskGenerator mg;
-
- /// The ROI mask
- private DataBlkInt roiMask;
-
- /// The source of quantized wavelet transform coefficients
- private Quantizer src;
-
- /// Constructor of the ROI scaler, takes a Quantizer as source of data to
- /// scale.
- ///
- ///
- /// The quantizer that is the source of data.
- ///
- ///
- /// The mask generator that will be used for all components
- ///
- ///
- /// Flag indicating whether there are rois specified.
- ///
- ///
- /// The resolution levels that belong entirely to ROI
- ///
- ///
- /// Flag indicating whether block aligning is used.
- ///
- ///
- /// The encoder specifications for addition of roi specs
- ///
- ///
- public ROIScaler(Quantizer src, ROIMaskGenerator mg, bool roi, int sLev, bool uba, EncoderSpecs encSpec) : base(src)
- {
- this.src = src;
- this.roi = roi;
- this.useStartLevel = sLev;
- if (roi)
- {
- // If there is no ROI, no need to do this
- this.mg = mg;
- roiMask = new DataBlkInt();
- calcMaxMagBits(encSpec);
- blockAligned = uba;
- }
- }
-
- /// Since ROI scaling is always a reversible operation, it calls
- /// isReversible() method of it source (the quantizer module).
- ///
- ///
- /// The tile to test for reversibility
- ///
- ///
- /// The component to test for reversibility
- ///
- ///
- /// True if the quantized data is reversible, false if not.
- ///
- ///
- public virtual bool isReversible(int t, int c)
- {
- return src.isReversible(t, c);
- }
-
- /// Returns a reference to the subband tree structure representing the
- /// subband decomposition for the specified tile-component.
- ///
- ///
- /// The index of the tile.
- ///
- ///
- /// The index of the component.
- ///
- ///
- /// The subband tree structure, see SubbandAn.
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- public virtual SubbandAn getAnSubbandTree(int t, int c)
- {
- return src.getAnSubbandTree(t, c);
- }
-
- /// Creates a ROIScaler object. The Quantizer is the source of data to
- /// scale.
- ///
- /// The ROI Scaler creates a ROIMaskGenerator depending on what ROI
- /// information is in the ParameterList. If only rectangular ROI are used,
- /// the fast mask generator for rectangular ROI can be used.
- ///
- ///
- /// The source of data to scale
- ///
- ///
- /// The parameter list (or options).
- ///
- ///
- /// The encoder specifications for addition of roi specs
- ///
- ///
- /// If an error occurs while parsing
- /// the options in 'pl'
- ///
- ///
- public static ROIScaler createInstance(Quantizer src, ParameterList pl, EncoderSpecs encSpec)
- {
- System.Collections.ArrayList roiVector = System.Collections.ArrayList.Synchronized(new System.Collections.ArrayList(10));
- ROIMaskGenerator maskGen = null;
-
- // Check parameters
- pl.checkList(OPT_PREFIX, CSJ2K.j2k.util.ParameterList.toNameArray(pinfo));
-
- // Get parameters and check if there are and ROIs specified
- System.String roiopt = pl.getParameter("Rroi");
- if (roiopt == null)
- {
- // No ROIs specified! Create ROIScaler with no mask generator
- return new ROIScaler(src, null, false, -1, false, encSpec);
- }
-
- // Check if the lowest resolution levels should belong to the ROI
- int sLev = pl.getIntParameter("Rstart_level");
-
- // Check if the ROIs are block-aligned
- bool useBlockAligned = pl.getBooleanParameter("Ralign");
-
- // Check if generic mask generation is specified
- bool onlyRect = !pl.getBooleanParameter("Rno_rect");
-
- // Parse the ROIs
- parseROIs(roiopt, src.NumComps, roiVector);
- ROI[] roiArray = new ROI[roiVector.Count];
- roiVector.CopyTo(roiArray);
-
- // If onlyRect has been forced, check if there are any non-rectangular
- // ROIs specified. Currently, only the presence of circular ROIs will
- // make this false
- if (onlyRect)
- {
- for (int i = roiArray.Length - 1; i >= 0; i--)
- if (!roiArray[i].rect)
- {
- onlyRect = false;
- break;
- }
- }
-
- if (onlyRect)
- {
- // It's possible to use the fast ROI mask generation when only
- // rectangular ROIs are specified.
- maskGen = new RectROIMaskGenerator(roiArray, src.NumComps);
- }
- else
- {
- // It's necessary to use the generic mask generation
- maskGen = new ArbROIMaskGenerator(roiArray, src.NumComps, src);
- }
- return new ROIScaler(src, maskGen, true, sLev, useBlockAligned, encSpec);
- }
-
- /// This function parses the values given for the ROIs with the argument
- /// -Rroi. Currently only circular and rectangular ROIs are supported.
- ///
- /// A rectangular ROI is indicated by a 'R' followed the coordinates for
- /// the upper left corner of the ROI and then its width and height.
- ///
- /// A circular ROI is indicated by a 'C' followed by the coordinates of
- /// the circle center and then the radius.
- ///
- /// Before the R and C values, the component that are affected by the
- /// ROI are indicated.
- ///
- ///
- /// The info on the ROIs
- ///
- ///
- /// number of components
- ///
- ///
- /// The vcector containing the ROI parsed from the cmd line
- ///
- ///
- /// The ROIs specified in roiopt
- ///
- ///
- protected internal static System.Collections.ArrayList parseROIs(System.String roiopt, int nc, System.Collections.ArrayList roiVector)
- {
- //ROI[] ROIs;
- ROI roi;
- SupportClass.Tokenizer stok;
- //char tok;
- int nrOfROIs = 0;
- //char c;
- int ulx, uly, w, h, x, y, rad; // comp removed
- bool[] roiInComp = null;
-
- stok = new SupportClass.Tokenizer(roiopt);
-
- System.String word;
- while (stok.HasMoreTokens())
- {
- word = stok.NextToken();
-
- switch (word[0])
- {
-
- case 'c': // Components specification
- roiInComp = ModuleSpec.parseIdx(word, nc);
- break;
-
- case 'R': // Rectangular ROI to be read
- nrOfROIs++;
- try
- {
- word = stok.NextToken();
- ulx = (System.Int32.Parse(word));
- word = stok.NextToken();
- uly = (System.Int32.Parse(word));
- word = stok.NextToken();
- w = (System.Int32.Parse(word));
- word = stok.NextToken();
- h = (System.Int32.Parse(word));
- }
- catch (System.FormatException)
- {
- throw new System.ArgumentException("Bad parameter for " + "'-Rroi R' option : " + word);
- }
- catch (System.ArgumentOutOfRangeException)
- {
- throw new System.ArgumentException("Wrong number of " + "parameters for " + "h'-Rroi R' option.");
- }
-
- // If the ROI is component-specific, check which comps.
- if (roiInComp != null)
- for (int i = 0; i < nc; i++)
- {
- if (roiInComp[i])
- {
- roi = new ROI(i, ulx, uly, w, h);
- roiVector.Add(roi);
- }
- }
- else
- {
- // Otherwise add ROI for all components
- for (int i = 0; i < nc; i++)
- {
- roi = new ROI(i, ulx, uly, w, h);
- roiVector.Add(roi);
- }
- }
- break;
-
- case 'C': // Circular ROI to be read
- nrOfROIs++;
-
- try
- {
- word = stok.NextToken();
- x = (System.Int32.Parse(word));
- word = stok.NextToken();
- y = (System.Int32.Parse(word));
- word = stok.NextToken();
- rad = (System.Int32.Parse(word));
- }
- catch (System.FormatException)
- {
- throw new System.ArgumentException("Bad parameter for " + "'-Rroi C' option : " + word);
- }
- catch (System.ArgumentOutOfRangeException)
- {
- throw new System.ArgumentException("Wrong number of " + "parameters for " + "'-Rroi C' option.");
- }
-
- // If the ROI is component-specific, check which comps.
- if (roiInComp != null)
- for (int i = 0; i < nc; i++)
- {
- if (roiInComp[i])
- {
- roi = new ROI(i, x, y, rad);
- roiVector.Add(roi);
- }
- }
- else
- {
- // Otherwise add ROI for all components
- for (int i = 0; i < nc; i++)
- {
- roi = new ROI(i, x, y, rad);
- roiVector.Add(roi);
- }
- }
- break;
-
- case 'A': // ROI wth arbitrary shape
- nrOfROIs++;
-
- System.String filename;
- ImgReaderPGM maskPGM = null;
-
- try
- {
- filename = stok.NextToken();
- }
- catch (System.ArgumentOutOfRangeException)
- {
- throw new System.ArgumentException("Wrong number of " + "parameters for " + "'-Rroi A' option.");
- }
- try
- {
- maskPGM = new ImgReaderPGM(filename);
- }
- catch (System.IO.IOException)
- {
- throw new System.ApplicationException("Cannot read PGM file with ROI");
- }
-
- // If the ROI is component-specific, check which comps.
- if (roiInComp != null)
- for (int i = 0; i < nc; i++)
- {
- if (roiInComp[i])
- {
- roi = new ROI(i, maskPGM);
- roiVector.Add(roi);
- }
- }
- else
- {
- // Otherwise add ROI for all components
- for (int i = 0; i < nc; i++)
- {
- roi = new ROI(i, maskPGM);
- roiVector.Add(roi);
- }
- }
- break;
-
- default:
- throw new System.ApplicationException("Bad parameters for ROI nr " + roiVector.Count);
-
- }
- }
-
- return roiVector;
- }
-
- /// This function gets a datablk from the entropy coder. The sample sin the
- /// block, which consists of the quantized coefficients from the quantizer,
- /// are scaled by the values given for any ROIs specified.
- ///
- /// The function calls on a ROIMaskGenerator to get the mask for scaling
- /// the coefficients in the current block.
- ///
- /// The data returned by this method is a copy of the orignal
- /// data. Therfore it can be modified "in place" without any problems after
- /// being returned. The 'offset' of the returned data is 0, and the 'scanw'
- /// is the same as the code-block width. See the 'CBlkWTData' class.
- ///
- ///
- /// The component for which to return the next code-block.
- ///
- ///
- /// If non-null this object will be used to return the new
- /// code-block. If null a new one will be allocated and returned. If the
- /// "data" array of the object is non-null it will be reused, if possible,
- /// to return the data.
- ///
- ///
- /// The next code-block in the current tile for component 'n', or
- /// null if all code-blocks for the current tile have been returned.
- ///
- ///
- ///
- ///
- ///
- public virtual CBlkWTData getNextCodeBlock(int c, CBlkWTData cblk)
- {
- return getNextInternCodeBlock(c, cblk);
- }
-
- /// This function gets a datablk from the entropy coder. The sample sin the
- /// block, which consists of the quantized coefficients from the quantizer,
- /// are scaled by the values given for any ROIs specified.
- ///
- /// The function calls on a ROIMaskGenerator to get the mask for scaling
- /// the coefficients in the current block.
- ///
- ///
- /// The component for which to return the next code-block.
- ///
- ///
- /// If non-null this object will be used to return the new
- /// code-block. If null a new one will be allocated and returned. If the
- /// "data" array of the object is non-null it will be reused, if possible,
- /// to return the data.
- ///
- ///
- /// The next code-block in the current tile for component 'n', or
- /// null if all code-blocks for the current tile have been returned.
- ///
- ///
- ///
- ///
- ///
- public virtual CBlkWTData getNextInternCodeBlock(int c, CBlkWTData cblk)
- {
- int mi, i, j, k, wrap;
- int ulx, uly, w, h;
- DataBlkInt mask = roiMask; // local copy of mask
- int[] maskData; // local copy of mask data
- int[] data; // local copy of quantized data
- int tmp;
- int bitMask = 0x7FFFFFFF;
- SubbandAn root, sb;
- int maxBits = 0; // local copy
- bool roiInTile;
- bool sbInMask;
- int nROIcoeff = 0;
-
- // Get codeblock's data from quantizer
- cblk = src.getNextCodeBlock(c, cblk);
-
- // If there is no ROI in the image, or if we already got all
- // code-blocks
- if (!roi || cblk == null)
- {
- return cblk;
- }
-
- data = (int[])cblk.Data;
- sb = cblk.sb;
- ulx = cblk.ulx;
- uly = cblk.uly;
- w = cblk.w;
- h = cblk.h;
- sbInMask = (sb.resLvl <= useStartLevel);
-
- // Check that there is an array for the mask and set it to zero
- maskData = mask.DataInt; // local copy of mask data
- if (maskData == null || w * h > maskData.Length)
- {
- maskData = new int[w * h];
- mask.DataInt = maskData;
- }
- else
- {
- for (i = w * h - 1; i >= 0; i--)
- maskData[i] = 0;
- }
- mask.ulx = ulx;
- mask.uly = uly;
- mask.w = w;
- mask.h = h;
-
- // Get ROI mask from generator
- root = src.getAnSubbandTree(tIdx, c);
- maxBits = maxMagBits[tIdx][c];
- roiInTile = mg.getROIMask(mask, root, maxBits, c);
-
- // If there is no ROI in this tile, return the code-block untouched
- if (!roiInTile && (!sbInMask))
- {
- cblk.nROIbp = 0;
- return cblk;
- }
-
- // Update field containing the number of ROI magnitude bit-planes
- cblk.nROIbp = cblk.magbits;
-
- // If the entire subband belongs to the ROI mask, The code-block is
- // set to belong entirely to the ROI with the highest scaling value
- if (sbInMask)
- {
- // Scale the wmse so that instead of scaling the coefficients, the
- // wmse is scaled.
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- cblk.wmseScaling *= (float)(1 << (maxBits << 1));
- cblk.nROIcoeff = w * h;
- return cblk;
- }
-
- // In 'block aligned' mode, the code-block is set to belong entirely
- // to the ROI with the highest scaling value if one coefficient, at
- // least, belongs to the ROI
- if (blockAligned)
- {
- wrap = cblk.scanw - w;
- mi = h * w - 1;
- i = cblk.offset + cblk.scanw * (h - 1) + w - 1;
- int nroicoeff = 0;
- for (j = h; j > 0; j--)
- {
- for (k = w - 1; k >= 0; k--, i--, mi--)
- {
- if (maskData[mi] != 0)
- {
- nroicoeff++;
- }
- }
- i -= wrap;
- }
- if (nroicoeff != 0)
- {
- // Include the subband
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- cblk.wmseScaling *= (float)(1 << (maxBits << 1));
- cblk.nROIcoeff = w * h;
- }
- return cblk;
- }
-
- // Scale background coefficients
- bitMask = (((1 << cblk.magbits) - 1) << (31 - cblk.magbits));
- wrap = cblk.scanw - w;
- mi = h * w - 1;
- i = cblk.offset + cblk.scanw * (h - 1) + w - 1;
- for (j = h; j > 0; j--)
- {
- for (k = w; k > 0; k--, i--, mi--)
- {
- tmp = data[i];
- if (maskData[mi] != 0)
- {
- // ROI coeff. We need to erase fractional bits to ensure
- // that they do not conflict with BG coeffs. This is only
- // strictly necessary for ROI coeffs. which non-fractional
- // magnitude is zero, but much better BG quality can be
- // achieved if done if reset to zero since coding zeros is
- // much more efficient (the entropy coder knows nothing
- // about ROI and cannot avoid coding the ROI fractional
- // bits, otherwise this would not be necessary).
- data[i] = (unchecked((int)0x80000000) & tmp) | (tmp & bitMask);
- nROIcoeff++;
- }
- else
- {
- // BG coeff. it is not necessary to erase fractional bits
- data[i] = (unchecked((int)0x80000000) & tmp) | ((tmp & 0x7FFFFFFF) >> maxBits);
- }
- }
- i -= wrap;
- }
-
- // Modify the number of significant bit-planes in the code-block
- cblk.magbits += maxBits;
-
- // Store the number of ROI coefficients present in the code-block
- cblk.nROIcoeff = nROIcoeff;
-
- return cblk;
- }
-
- /// This function returns the flag indicating if any ROI functionality used
- ///
- ///
- /// Flag indicating whether there are ROIs in the image
- ///
- public virtual bool useRoi()
- {
- return roi;
- }
-
- /// Changes the current tile, given the new indexes. An
- /// IllegalArgumentException is thrown if the indexes do not
- /// correspond to a valid tile.
- ///
- ///
- /// The horizontal index of the tile.
- ///
- ///
- /// The vertical index of the new tile.
- ///
- ///
- public override void setTile(int x, int y)
- {
- base.setTile(x, y);
- if (roi)
- mg.tileChanged();
- }
-
- /// Advances to the next tile, in standard scan-line order (by rows then
- /// columns). An NoNextElementException is thrown if the current tile is
- /// the last one (i.e. there is no next tile).
- ///
- ///
- public override void nextTile()
- {
- base.nextTile();
- if (roi)
- mg.tileChanged();
- }
-
- /// Calculates the maximum amount of magnitude bits for each
- /// tile-component, and stores it in the 'maxMagBits' array. This is called
- /// by the constructor
- ///
- ///
- /// The encoder specifications for addition of roi specs
- ///
- ///
- private void calcMaxMagBits(EncoderSpecs encSpec)
- {
- int tmp;
- MaxShiftSpec rois = encSpec.rois;
-
- int nt = src.getNumTiles();
- int nc = src.NumComps;
-
- maxMagBits = new int[nt][];
- for (int i = 0; i < nt; i++)
- {
- maxMagBits[i] = new int[nc];
- }
-
- src.setTile(0, 0);
- for (int t = 0; t < nt; t++)
- {
- for (int c = nc - 1; c >= 0; c--)
- {
- tmp = src.getMaxMagBits(c);
- maxMagBits[t][c] = tmp;
- rois.setTileCompVal(t, c, (System.Object)tmp);
- }
- if (t < nt - 1)
- src.nextTile();
- }
- // Reset to current initial tile position
- src.setTile(0, 0);
- }
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/roi/encoder/RectROIMaskGenerator.cs b/CSJ2K/j2k/roi/encoder/RectROIMaskGenerator.cs
deleted file mode 100644
index 7e254113..00000000
--- a/CSJ2K/j2k/roi/encoder/RectROIMaskGenerator.cs
+++ /dev/null
@@ -1,325 +0,0 @@
-/*
-* CVS identifier:
-*
-* $Id: RectROIMaskGenerator.java,v 1.4 2001/02/28 15:33:44 grosbois Exp $
-*
-* Class: RectROIMaskGenerator
-*
-* Description: Generates masks when only rectangular ROIs exist
-*
-*
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-* */
-using CSJ2K.j2k.image;
-using CSJ2K.j2k.wavelet;
-namespace CSJ2K.j2k.roi.encoder
-{
-
- /// This class generates the ROI masks when there are only rectangular ROIs in
- /// the image. The ROI mask generation can then be simplified by only
- /// calculating the boundaries of the ROI mask in the particular subbands
- ///
- /// The values are calculated from the scaling factors of the ROIs. The
- /// values with which to scale are equal to u-umin where umin is the lowest
- /// scaling factor within the block. The umin value is sent to the entropy
- /// coder to be used for scaling the distortion values.
- ///
- ///
To generate and to store the boundaries of the ROIs, the class
- /// SubbandRectROIMask is used. There is one tree of SubbandMasks for each
- /// component.
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- public class RectROIMaskGenerator : ROIMaskGenerator
- {
-
- /// The upper left xs of the ROIs
- private int[] ulxs;
-
- /// The upper left ys of the ROIs
- private int[] ulys;
-
- /// The lower right xs of the ROIs
- private int[] lrxs;
-
- /// The lower right ys of the ROIs
- private int[] lrys;
-
- /// Number of ROIs
- private int[] nrROIs;
-
- /// The tree of subbandmask. One for each component
- private SubbandRectROIMask[] sMasks;
-
-
- /// The constructor of the mask generator. The constructor is called with
- /// the ROI data. This data is stored in arrays that are used to generate
- /// the SubbandRectROIMask trees for each component.
- ///
- ///
- /// The ROI info.
- ///
- ///
- /// The flag indicating use of Maxshift method.
- ///
- ///
- /// number of components.
- ///
- ///
- public RectROIMaskGenerator(ROI[] ROIs, int nrc) : base(ROIs, nrc)
- {
- int nr = ROIs.Length;
- int r; // c removed
- nrROIs = new int[nrc];
- sMasks = new SubbandRectROIMask[nrc];
-
- // Count number of ROIs per component
- for (r = nr - 1; r >= 0; r--)
- {
- nrROIs[ROIs[r].comp]++;
- }
- }
-
-
- /// This functions gets a DataBlk the size of the current code-block and
- /// fills this block with the ROI mask.
- ///
- /// In order to get the mask for a particular Subband, the subband tree
- /// is traversed and at each decomposition, the ROI masks are computed. The
- /// roi bondaries for each subband are stored in the SubbandRectROIMask
- /// tree.
- ///
- ///
- /// The data block that is to be filled with the mask
- ///
- ///
- /// The root of the subband tree to which db belongs
- ///
- ///
- /// The max number of magnitude bits in any code-block
- ///
- ///
- /// The component for which to get the mask
- ///
- ///
- /// Whether or not a mask was needed for this tile
- ///
- ///
- public override bool getROIMask(DataBlkInt db, Subband sb, int magbits, int c)
- {
- int x = db.ulx;
- int y = db.uly;
- int w = db.w;
- int h = db.h;
- int[] mask = db.DataInt;
- int i, j, k, r, maxk, maxj; // mink, minj removed
- int ulx = 0, uly = 0, lrx = 0, lry = 0;
- int wrap;
- int maxROI;
- int[] culxs;
- int[] culys;
- int[] clrxs;
- int[] clrys;
- SubbandRectROIMask srm;
-
- // If the ROI bounds have not been calculated for this tile and
- // component, do so now.
- if (!tileMaskMade[c])
- {
- makeMask(sb, magbits, c);
- tileMaskMade[c] = true;
- }
-
- if (!roiInTile)
- {
- return false;
- }
-
- // Find relevant subband mask and get ROI bounds
- srm = (SubbandRectROIMask)sMasks[c].getSubbandRectROIMask(x, y);
- culxs = srm.ulxs;
- culys = srm.ulys;
- clrxs = srm.lrxs;
- clrys = srm.lrys;
- maxROI = culxs.Length - 1;
- // Make sure that only parts of ROIs within the code-block are used
- // and make the bounds local to this block the LR bounds are counted
- // as the distance from the lower right corner of the block
- x -= srm.ulx;
- y -= srm.uly;
- for (r = maxROI; r >= 0; r--)
- {
- ulx = culxs[r] - x;
- if (ulx < 0)
- {
- ulx = 0;
- }
- else if (ulx >= w)
- {
- ulx = w;
- }
-
- uly = culys[r] - y;
- if (uly < 0)
- {
- uly = 0;
- }
- else if (uly >= h)
- {
- uly = h;
- }
-
- lrx = clrxs[r] - x;
- if (lrx < 0)
- {
- lrx = -1;
- }
- else if (lrx >= w)
- {
- lrx = w - 1;
- }
-
- lry = clrys[r] - y;
- if (lry < 0)
- {
- lry = -1;
- }
- else if (lry >= h)
- {
- lry = h - 1;
- }
-
- // Add the masks of the ROI
- i = w * lry + lrx;
- maxj = (lrx - ulx);
- wrap = w - maxj - 1;
- maxk = lry - uly;
-
- for (k = maxk; k >= 0; k--)
- {
- for (j = maxj; j >= 0; j--, i--)
- mask[i] = magbits;
- i -= wrap;
- }
- }
- return true;
- }
-
- /// This function returns the relevant data of the mask generator
- ///
- ///
- public override System.String ToString()
- {
- return ("Fast rectangular ROI mask generator");
- }
-
- /// This function generates the ROI mask for the entire tile. The mask is
- /// generated for one component. This method is called once for each tile
- /// and component.
- ///
- ///
- /// The root of the subband tree used in the decomposition
- ///
- ///
- /// component number
- ///
- ///
- public override void makeMask(Subband sb, int magbits, int n)
- {
- int nr = nrROIs[n];
- int r;
- int ulx, uly, lrx, lry;
- int tileulx = sb.ulcx;
- int tileuly = sb.ulcy;
- int tilew = sb.w;
- int tileh = sb.h;
- ROI[] ROIs = roi_array; // local copy
-
- ulxs = new int[nr];
- ulys = new int[nr];
- lrxs = new int[nr];
- lrys = new int[nr];
-
- nr = 0;
-
- for (r = ROIs.Length - 1; r >= 0; r--)
- {
- if (ROIs[r].comp == n)
- {
- ulx = ROIs[r].ulx;
- uly = ROIs[r].uly;
- lrx = ROIs[r].w + ulx - 1;
- lry = ROIs[r].h + uly - 1;
-
- if (ulx > (tileulx + tilew - 1) || uly > (tileuly + tileh - 1) || lrx < tileulx || lry < tileuly)
- // no part of ROI in tile
- continue;
-
- // Check bounds
- ulx -= tileulx;
- lrx -= tileulx;
- uly -= tileuly;
- lry -= tileuly;
-
- ulx = (ulx < 0) ? 0 : ulx;
- uly = (uly < 0) ? 0 : uly;
- lrx = (lrx > (tilew - 1)) ? tilew - 1 : lrx;
- lry = (lry > (tileh - 1)) ? tileh - 1 : lry;
-
- ulxs[nr] = ulx;
- ulys[nr] = uly;
- lrxs[nr] = lrx;
- lrys[nr] = lry;
- nr++;
- }
- }
- if (nr == 0)
- {
- roiInTile = false;
- }
- else
- {
- roiInTile = true;
- }
- sMasks[n] = new SubbandRectROIMask(sb, ulxs, ulys, lrxs, lrys, nr);
- }
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/roi/encoder/SubbandROIMask.cs b/CSJ2K/j2k/roi/encoder/SubbandROIMask.cs
deleted file mode 100644
index 619d1866..00000000
--- a/CSJ2K/j2k/roi/encoder/SubbandROIMask.cs
+++ /dev/null
@@ -1,164 +0,0 @@
-/*
-* CVS identifier:
-*
-* $Id: SubbandROIMask.java,v 1.2 2001/02/28 15:12:44 grosbois Exp $
-*
-* Class: ROI
-*
-* Description: This class describes the ROI mask for a subband
-*
-*
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-* */
-namespace CSJ2K.j2k.roi.encoder
-{
-
- /// This abstract class describes the ROI mask for a single subband. Each
- /// object of the class contains the mask for a particular subband and also has
- /// references to the masks of the children subbands of the subband
- /// corresponding to this mask.
- ///
- public abstract class SubbandROIMask
- {
-
- /// The subband masks of the child LL
- protected internal SubbandROIMask ll;
-
- /// The subband masks of the child LH
- protected internal SubbandROIMask lh;
-
- /// The subband masks of the child HL
- protected internal SubbandROIMask hl;
-
- /// The subband masks of the child HH
- protected internal SubbandROIMask hh;
-
- /// Flag indicating whether this subband mask is a node or not
- protected internal bool isNode;
-
- /// Horizontal uper-left coordinate of the subband mask
- public int ulx;
-
- /// Vertical uper-left coordinate of the subband mask
- public int uly;
-
- /// Width of the subband mask
- public int w;
-
- /// Height of the subband mask
- public int h;
-
- /// The constructor of the SubbandROIMask takes the dimensions of the
- /// subband as parameters
- ///
- ///
- /// The upper left x coordinate of corresponding subband
- ///
- ///
- /// The upper left y coordinate of corresponding subband
- ///
- ///
- /// The width of corresponding subband
- ///
- ///
- /// The height of corresponding subband
- ///
- ///
- public SubbandROIMask(int ulx, int uly, int w, int h)
- {
- this.ulx = ulx;
- this.uly = uly;
- this.w = w;
- this.h = h;
- }
-
- /// Returns a reference to the Subband mask element to which the specified
- /// point belongs. The specified point must be inside this (i.e. the one
- /// defined by this object) subband mask. This method searches through the
- /// tree.
- ///
- ///
- /// horizontal coordinate of the specified point.
- ///
- ///
- /// horizontal coordinate of the specified point.
- ///
- ///
- public virtual SubbandROIMask getSubbandRectROIMask(int x, int y)
- {
- SubbandROIMask cur, hhs;
-
- // Check that we are inside this subband
- if (x < ulx || y < uly || x >= ulx + w || y >= uly + h)
- {
- throw new System.ArgumentException();
- }
-
- cur = this;
- while (cur.isNode)
- {
- hhs = cur.hh;
- // While we are still at a node -> continue
- if (x < hhs.ulx)
- {
- // Is the result of horizontal low-pass
- if (y < hhs.uly)
- {
- // Vertical low-pass
- cur = cur.ll;
- }
- else
- {
- // Vertical high-pass
- cur = cur.lh;
- }
- }
- else
- {
- // Is the result of horizontal high-pass
- if (y < hhs.uly)
- {
- // Vertical low-pass
- cur = cur.hl;
- }
- else
- {
- // Vertical high-pass
- cur = cur.hh;
- }
- }
- }
- return cur;
- }
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/roi/encoder/SubbandRectROIMask.cs b/CSJ2K/j2k/roi/encoder/SubbandRectROIMask.cs
deleted file mode 100644
index 02f81f62..00000000
--- a/CSJ2K/j2k/roi/encoder/SubbandRectROIMask.cs
+++ /dev/null
@@ -1,192 +0,0 @@
-/*
-* CVS identifier:
-*
-* $Id: SubbandRectROIMask.java,v 1.3 2001/02/28 14:53:12 grosbois Exp $
-*
-* Class: ROI
-*
-* Description: This class describes the ROI mask for a subband
-*
-*
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-* */
-using CSJ2K.j2k.wavelet;
-namespace CSJ2K.j2k.roi.encoder
-{
-
- /// This class describes the ROI mask for a single subband. Each object of the
- /// class contains the mask for a particular subband and also has references to
- /// the masks of the children subbands of the subband corresponding to this
- /// mask. This class describes subband masks for images containing only
- /// rectangular ROIS
- ///
- ///
- public class SubbandRectROIMask : SubbandROIMask
- {
-
- /// The upper left x coordinates of the applicable ROIs
- public int[] ulxs;
-
- /// The upper left y coordinates of the applicable ROIs
- public int[] ulys;
-
- /// The lower right x coordinates of the applicable ROIs
- public int[] lrxs;
-
- /// The lower right y coordinates of the applicable ROIs
- public int[] lrys;
-
- /// The constructor of the SubbandROIMask takes the dimensions of the
- /// subband as parameters. A tree of masks is generated from the subband
- /// sb. Each Subband contains the boundaries of each ROI.
- ///
- ///
- /// The subband corresponding to this Subband Mask
- ///
- ///
- /// The upper left x coordinates of the ROIs
- ///
- ///
- /// The upper left y coordinates of the ROIs
- ///
- ///
- /// The lower right x coordinates of the ROIs
- ///
- ///
- /// The lower right y coordinates of the ROIs
- ///
- ///
- /// The lower right y coordinates of the ROIs
- ///
- ///
- /// Number of ROIs that affect this tile
- ///
- ///
- public SubbandRectROIMask(Subband sb, int[] ulxs, int[] ulys, int[] lrxs, int[] lrys, int nr) : base(sb.ulx, sb.uly, sb.w, sb.h)
- {
- this.ulxs = ulxs;
- this.ulys = ulys;
- this.lrxs = lrxs;
- this.lrys = lrys;
- int r;
-
- if (sb.isNode)
- {
- isNode = true;
- // determine odd/even - high/low filters
- int horEvenLow = sb.ulcx % 2;
- int verEvenLow = sb.ulcy % 2;
-
- // Get filter support lengths
- WaveletFilter hFilter = sb.HorWFilter;
- WaveletFilter vFilter = sb.VerWFilter;
- int hlnSup = hFilter.SynLowNegSupport;
- int hhnSup = hFilter.SynHighNegSupport;
- int hlpSup = hFilter.SynLowPosSupport;
- int hhpSup = hFilter.SynHighPosSupport;
- int vlnSup = vFilter.SynLowNegSupport;
- int vhnSup = vFilter.SynHighNegSupport;
- int vlpSup = vFilter.SynLowPosSupport;
- int vhpSup = vFilter.SynHighPosSupport;
-
- // Generate arrays for children
- int x, y;
- int[] lulxs = new int[nr];
- int[] lulys = new int[nr];
- int[] llrxs = new int[nr];
- int[] llrys = new int[nr];
- int[] hulxs = new int[nr];
- int[] hulys = new int[nr];
- int[] hlrxs = new int[nr];
- int[] hlrys = new int[nr];
- for (r = nr - 1; r >= 0; r--)
- {
- // For all ROI calculate ...
- // Upper left x for all children
- x = ulxs[r];
- if (horEvenLow == 0)
- {
- lulxs[r] = (x + 1 - hlnSup) / 2;
- hulxs[r] = (x - hhnSup) / 2;
- }
- else
- {
- lulxs[r] = (x - hlnSup) / 2;
- hulxs[r] = (x + 1 - hhnSup) / 2;
- }
- // Upper left y for all children
- y = ulys[r];
- if (verEvenLow == 0)
- {
- lulys[r] = (y + 1 - vlnSup) / 2;
- hulys[r] = (y - vhnSup) / 2;
- }
- else
- {
- lulys[r] = (y - vlnSup) / 2;
- hulys[r] = (y + 1 - vhnSup) / 2;
- }
- // lower right x for all children
- x = lrxs[r];
- if (horEvenLow == 0)
- {
- llrxs[r] = (x + hlpSup) / 2;
- hlrxs[r] = (x - 1 + hhpSup) / 2;
- }
- else
- {
- llrxs[r] = (x - 1 + hlpSup) / 2;
- hlrxs[r] = (x + hhpSup) / 2;
- }
- // lower right y for all children
- y = lrys[r];
- if (verEvenLow == 0)
- {
- llrys[r] = (y + vlpSup) / 2;
- hlrys[r] = (y - 1 + vhpSup) / 2;
- }
- else
- {
- llrys[r] = (y - 1 + vlpSup) / 2;
- hlrys[r] = (y + vhpSup) / 2;
- }
- }
- // Create children
- hh = new SubbandRectROIMask(sb.HH, hulxs, hulys, hlrxs, hlrys, nr);
- lh = new SubbandRectROIMask(sb.LH, lulxs, hulys, llrxs, hlrys, nr);
- hl = new SubbandRectROIMask(sb.HL, hulxs, lulys, hlrxs, llrys, nr);
- ll = new SubbandRectROIMask(sb.LL, lulxs, lulys, llrxs, llrys, nr);
- }
- }
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/util/ArrayUtil.cs b/CSJ2K/j2k/util/ArrayUtil.cs
deleted file mode 100644
index 1ce3cc59..00000000
--- a/CSJ2K/j2k/util/ArrayUtil.cs
+++ /dev/null
@@ -1,168 +0,0 @@
-/*
-* CVS identifier:
-*
-* $Id: ArrayUtil.java,v 1.10 2000/09/05 09:25:15 grosbois Exp $
-*
-* Class: ArrayUtil
-*
-* Description: Utillities for arrays.
-*
-*
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-*
-*
-*
-*/
-using System;
-namespace CSJ2K.j2k.util
-{
-
- /// This class contains a colleaction of utility static methods for arrays.
- ///
- ///
- public class ArrayUtil
- {
-
- /// The maximum array size to do element by element copying, larger
- /// arrays are copyied in a n optimized way.
- ///
- public const int MAX_EL_COPYING = 8;
-
- /// The number of elements to copy initially in an optimized array copy
- public const int INIT_EL_COPYING = 4;
-
- /// Reinitializes an int array to the given value in an optimized way. If
- /// the length of the array is less than MAX_EL_COPYING, then the array
- /// is set element by element in the normal way, otherwise the first
- /// INIT_EL_COPYING elements are set element by element and then
- /// System.arraycopy is used to set the other parts of the array.
- ///
- ///
- /// The array to set.
- ///
- ///
- /// The value to set the array to.
- ///
- ///
- ///
- ///
- public static void intArraySet(int[] arr, int val)
- {
- int i, len, len2;
-
- len = arr.Length;
- // Set array to 'val' in an optimized way
- if (len < MAX_EL_COPYING)
- {
- // Not worth doing optimized way
- for (i = len - 1; i >= 0; i--)
- {
- // Set elements
- arr[i] = val;
- }
- }
- else
- {
- // Do in optimized way
- len2 = len >> 1;
- for (i = 0; i < INIT_EL_COPYING; i++)
- {
- // Set first elements
- arr[i] = val;
- }
- for (; i <= len2; i <<= 1)
- {
- // Copy values doubling size each time
- Array.Copy(arr, 0, arr, i, i);
- }
- if (i < len)
- {
- // Copy values to end
- Array.Copy(arr, 0, arr, i, len - i);
- }
- }
- }
-
- /// Reinitializes a byte array to the given value in an optimized way. If
- /// the length of the array is less than MAX_EL_COPYING, then the array
- /// is set element by element in the normal way, otherwise the first
- /// INIT_EL_COPYING elements are set element by element and then
- /// System.arraycopy is used to set the other parts of the array.
- ///
- ///
- /// The array to set.
- ///
- ///
- /// The value to set the array to.
- ///
- ///
- ///
- ///
- public static void byteArraySet(byte[] arr, byte val)
- {
- int i, len, len2;
-
- len = arr.Length;
- // Set array to 'val' in an optimized way
- if (len < MAX_EL_COPYING)
- {
- // Not worth doing optimized way
- for (i = len - 1; i >= 0; i--)
- {
- // Set elements
- arr[i] = val;
- }
- }
- else
- {
- // Do in optimized way
- len2 = len >> 1;
- for (i = 0; i < INIT_EL_COPYING; i++)
- {
- // Set first elements
- arr[i] = val;
- }
- for (; i <= len2; i <<= 1)
- {
- // Copy values doubling size each time
- Array.Copy(arr, 0, arr, i, i);
- }
- if (i < len)
- {
- // Copy values to end
- Array.Copy(arr, 0, arr, i, len - i);
- }
- }
- }
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/util/CodestreamManipulator.cs b/CSJ2K/j2k/util/CodestreamManipulator.cs
deleted file mode 100644
index 358f7610..00000000
--- a/CSJ2K/j2k/util/CodestreamManipulator.cs
+++ /dev/null
@@ -1,763 +0,0 @@
-/*
-* CVS identifier:
-*
-* $Id: CodestreamManipulator.java,v 1.17 2001/05/16 13:58:09 qtxjoas Exp $
-*
-* Class: CodestreamManipulator
-*
-* Description: Manipulates codestream to create tile-parts etc
-*
-*
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-* */
-using CSJ2K.j2k.io;
-namespace CSJ2K.j2k.util
-{
-
- /// This class takes a legal JPEG 2000 codestream and performs some
- /// manipulation on it. Currently the manipulations supported are: Tile-parts
- ///
- ///
- public class CodestreamManipulator
- {
- private void InitBlock()
- {
- ppt = new int[nt];
- }
-
- /// Flag indicating whether packed packet headers in main header is used
- ///
- ///
- private bool ppmUsed;
-
- /// Flag indicating whether packed packet headers in tile headers is used
- ///
- ///
- private bool pptUsed;
-
- /// Flag indicating whether SOP marker was only intended for parsing in
- /// This class and should be removed
- ///
- private bool tempSop;
-
- /// Flag indicating whether EPH marker was only intended for parsing in
- /// This class and should be removed
- ///
- private bool tempEph;
-
- /// The number of tiles in the image
- private int nt;
-
- /// The number of packets per tile-part
- private int pptp;
-
- /// The name of the outfile
- private System.String outname;
-
- /// The length of a SOT plus a SOD marker
- private static int TP_HEAD_LEN = 14;
-
- /// The maximum number of a tile part index (TPsot)
- //private static int MAX_TPSOT = 16;
-
- /// The maximum number of tile parts in any tile
- private int maxtp;
-
- /// The number of packets per tile
- //UPGRADE_NOTE: The initialization of 'ppt' was moved to method 'InitBlock'. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1005'"
- private int[] ppt;
-
- /// The positions of the SOT, SOP and EPH markers
- private System.Int32[] positions;
-
- /// The main header
- private byte[] mainHeader;
-
- /// Buffers containing the tile parts
- private byte[][][] tileParts;
-
- /// Buffers containing the original tile headers
- private byte[][] tileHeaders;
-
- /// Buffers contaning the packet headers
- private byte[][][] packetHeaders;
-
- /// Buffers containing the packet data
- private byte[][][] packetData;
-
- /// Buffers containing the SOP marker segments
- private byte[][][] sopMarkSeg;
-
- /// Instantiates a codestream manipulator..
- ///
- ///
- /// The name of the original outfile
- ///
- ///
- /// The number of tiles in the image
- ///
- ///
- /// Packets per tile-part. If zero, no division into tileparts
- /// is performed
- ///
- ///
- /// Flag indicating that PPM marker is used
- ///
- ///
- /// Flag indicating that PPT marker is used
- ///
- ///
- /// Flag indicating whether SOP merker should be removed
- ///
- ///
- /// Flag indicating whether EPH merker should be removed
- ///
- ///
- public CodestreamManipulator(System.String outname, int nt, int pptp, bool ppm, bool ppt, bool tempSop, bool tempEph)
- {
- InitBlock();
- this.outname = outname;
- this.nt = nt;
- this.pptp = pptp;
- this.ppmUsed = ppm;
- this.pptUsed = ppt;
- this.tempSop = tempSop;
- this.tempEph = tempEph;
- }
-
- /// This method performs the actual manipulation of the codestream which is
- /// the reparsing for tile parts and packed packet headers
- ///
- ///
- /// The number of bytes that the file has increased by
- ///
- ///
- /// If an I/O error ocurred.
- ///
- ///
- public virtual int doCodestreamManipulation()
- {
- BEBufferedRandomAccessFile fi;
- int addedHeaderBytes = 0;
- ppt = new int[nt];
- tileParts = new byte[nt][][];
- tileHeaders = new byte[nt][];
- packetHeaders = new byte[nt][][];
- packetData = new byte[nt][][];
- sopMarkSeg = new byte[nt][][];
-
- // If neither packed packet header nor tile parts are used, return 0
- if (ppmUsed == false && pptUsed == false && pptp == 0)
- return 0;
-
- // Open file for reading and writing
- fi = new BEBufferedRandomAccessFile(outname, "rw+");
- addedHeaderBytes -= fi.length();
-
- // Parse the codestream for SOT, SOP and EPH markers
- parseAndFind(fi);
-
- // Read and buffer the tile headers, packet headers and packet data
- readAndBuffer(fi);
-
- // Close file and overwrite with new file
- fi.close();
- fi = new BEBufferedRandomAccessFile(outname, "rw");
-
- // Create tile-parts
- createTileParts();
-
- // Write new codestream
- writeNewCodestream(fi);
-
- // Close file
- fi.flush();
- addedHeaderBytes += fi.length();
- fi.close();
-
- return addedHeaderBytes;
- }
-
- /// This method parses the codestream for SOT, SOP and EPH markers and
- /// removes header header bits signalling SOP and EPH markers if packed
- /// packet headers are used
- ///
- ///
- /// The file to parse the markers from
- ///
- ///
- /// If an I/O error ocurred.
- ///
- ///
- private void parseAndFind(BufferedRandomAccessFile fi)
- {
- int length, pos, i, t, sop = 0, eph = 0;
- short marker;
- int halfMarker;
- int tileEnd;
- System.Collections.ArrayList markPos = System.Collections.ArrayList.Synchronized(new System.Collections.ArrayList(10));
-
- // Find position of first SOT marker
- marker = (short)fi.readUnsignedShort(); // read SOC marker
- marker = (short)fi.readUnsignedShort();
- while (marker != CSJ2K.j2k.codestream.Markers.SOT)
- {
- pos = fi.Pos;
- length = fi.readUnsignedShort();
-
- // If SOP and EPH markers were only used for parsing in this
- // class remove SOP and EPH markers from Scod field
- if (marker == CSJ2K.j2k.codestream.Markers.COD)
- {
- int scod = fi.readUnsignedByte();
- if (tempSop)
- scod &= 0xfd; // Remove bits indicating SOP
- if (tempEph)
- scod &= 0xfb; // Remove bits indicating SOP
- fi.seek(pos + 2);
- fi.write(scod);
- }
-
- fi.seek(pos + length);
- marker = (short)fi.readUnsignedShort();
- }
- pos = fi.Pos;
- fi.seek(pos - 2);
-
- // Find all packet headers, packed data and tile headers
- for (t = 0; t < nt; t++)
- {
- // Read SOT marker
- fi.readUnsignedShort(); // Skip SOT
- pos = fi.Pos;
- markPos.Add((System.Int32)fi.Pos);
- fi.readInt(); // Skip Lsot and Isot
- length = fi.readInt(); // Read Psot
- fi.readUnsignedShort(); // Skip TPsot & TNsot
- tileEnd = pos + length - 2; // Last byte of tile
-
- // Find position of SOD marker
- marker = (short)fi.readUnsignedShort();
- while (marker != CSJ2K.j2k.codestream.Markers.SOD)
- {
- pos = fi.Pos;
- length = fi.readUnsignedShort();
-
- // If SOP and EPH markers were only used for parsing in this
- // class remove SOP and EPH markers from Scod field
- if (marker == CSJ2K.j2k.codestream.Markers.COD)
- {
- int scod = fi.readUnsignedByte();
- if (tempSop)
- scod &= 0xfd; // Remove bits indicating SOP
- if (tempEph)
- scod &= 0xfb; // Remove bits indicating SOP
- fi.seek(pos + 2);
- fi.write(scod);
- }
- fi.seek(pos + length);
- marker = (short)fi.readUnsignedShort();
- }
-
- // Find all SOP and EPH markers in tile
- sop = 0;
- eph = 0;
-
- i = fi.Pos;
- while (i < tileEnd)
- {
- halfMarker = (short)fi.readUnsignedByte();
- if (halfMarker == (short)0xff)
- {
- marker = (short)((halfMarker << 8) + fi.readUnsignedByte());
- i++;
- if (marker == CSJ2K.j2k.codestream.Markers.SOP)
- {
- markPos.Add((System.Int32)fi.Pos);
- ppt[t]++;
- sop++;
- fi.skipBytes(4);
- i += 4;
- }
-
- if (marker == CSJ2K.j2k.codestream.Markers.EPH)
- {
- markPos.Add((System.Int32)fi.Pos);
- eph++;
- }
- }
- i++;
- }
- }
- markPos.Add((System.Int32)(fi.Pos + 2));
- positions = new System.Int32[markPos.Count];
- markPos.CopyTo(positions);
- }
-
- /// This method reads and buffers the tile headers, packet headers and
- /// packet data.
- ///
- ///
- /// The file to read the headers and data from
- ///
- ///
- /// If an I/O error ocurred.
- ///
- ///
- private void readAndBuffer(BufferedRandomAccessFile fi)
- {
- int p, prem, length, t, markIndex;
-
- // Buffer main header
- fi.seek(0);
- length = ((System.Int32)positions[0]) - 2;
- mainHeader = new byte[length];
- fi.readFully(mainHeader, 0, length);
- markIndex = 0;
-
- for (t = 0; t < nt; t++)
- {
- prem = ppt[t];
-
- packetHeaders[t] = new byte[prem][];
- packetData[t] = new byte[prem][];
- sopMarkSeg[t] = new byte[prem][];
-
- // Read tile header
- length = positions[markIndex + 1] - positions[markIndex];
- tileHeaders[t] = new byte[length];
- fi.readFully(tileHeaders[t], 0, length);
- markIndex++;
-
- for (p = 0; p < prem; p++)
- {
- // Read packet header
- length = positions[markIndex + 1] - positions[markIndex];
-
- if (tempSop)
- {
- // SOP marker is skipped
- length -= CSJ2K.j2k.codestream.Markers.SOP_LENGTH;
- fi.skipBytes(CSJ2K.j2k.codestream.Markers.SOP_LENGTH);
- }
- else
- {
- // SOP marker is read and buffered
- length -= CSJ2K.j2k.codestream.Markers.SOP_LENGTH;
- sopMarkSeg[t][p] = new byte[CSJ2K.j2k.codestream.Markers.SOP_LENGTH];
- fi.readFully(sopMarkSeg[t][p], 0, CSJ2K.j2k.codestream.Markers.SOP_LENGTH);
- }
-
- if (!tempEph)
- {
- // EPH marker is kept in header
- length += CSJ2K.j2k.codestream.Markers.EPH_LENGTH;
- }
- packetHeaders[t][p] = new byte[length];
- fi.readFully(packetHeaders[t][p], 0, length);
- markIndex++;
-
- // Read packet data
- length = positions[markIndex + 1] - positions[markIndex];
-
- length -= CSJ2K.j2k.codestream.Markers.EPH_LENGTH;
- if (tempEph)
- {
- // EPH marker is used and is skipped
- fi.skipBytes(CSJ2K.j2k.codestream.Markers.EPH_LENGTH);
- }
-
- packetData[t][p] = new byte[length];
- fi.readFully(packetData[t][p], 0, length);
- markIndex++;
- }
- }
- }
-
- /// This method creates the tileparts from the buffered tile headers,
- /// packet headers and packet data
- ///
- ///
- /// If an I/O error ocurred.
- ///
- ///
- private void createTileParts()
- {
- int i, prem, t, length;
- int pIndex; // phIndex removed
- int tppStart;
- int tilePart;
- int p, np, nomnp;
- int numTileParts;
- int numPackets;
- System.IO.MemoryStream temp = new System.IO.MemoryStream();
- byte[] tempByteArr;
-
- // Create tile parts
- tileParts = new byte[nt][][];
- maxtp = 0;
-
- for (t = 0; t < nt; t++)
- {
- // Calculate number of tile parts. If tileparts are not used,
- // put all packets in the first tilepart
- if (pptp == 0)
- pptp = ppt[t];
- prem = ppt[t];
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- numTileParts = (int)System.Math.Ceiling(((double)prem) / pptp);
- numPackets = packetHeaders[t].Length;
- maxtp = (numTileParts > maxtp) ? numTileParts : maxtp;
- tileParts[t] = new byte[numTileParts][];
-
- // Create all the tile parts for tile t
- tppStart = 0;
- pIndex = 0;
- p = 0;
- //phIndex = 0;
-
- for (tilePart = 0; tilePart < numTileParts; tilePart++)
- {
-
- // Calculate number of packets in this tilepart
- nomnp = (pptp > prem) ? prem : pptp;
- np = nomnp;
-
- // Write tile part header
- if (tilePart == 0)
- {
- // Write original tile part header up to SOD marker
- temp.Write(tileHeaders[t], 0, tileHeaders[t].Length - 2);
- }
- else
- {
- // Write empty header of length TP_HEAD_LEN-2
- temp.Write(new byte[TP_HEAD_LEN - 2], 0, TP_HEAD_LEN - 2);
- }
-
- // Write PPT marker segments if PPT used
- if (pptUsed)
- {
- int pptLength = 3; // Zppt and Lppt
- int pptIndex = 0;
- int phLength;
-
- p = pIndex;
- while (np > 0)
- {
- phLength = packetHeaders[t][p].Length;
-
- // If the total legth of the packet headers is greater
- // than MAX_LPPT, several PPT markers are needed
- if (pptLength + phLength > CSJ2K.j2k.codestream.Markers.MAX_LPPT)
- {
-
- temp.WriteByte((System.Byte)SupportClass.URShift(CSJ2K.j2k.codestream.Markers.PPT, 8));
- temp.WriteByte((System.Byte)(CSJ2K.j2k.codestream.Markers.PPT & 0x00FF));
- temp.WriteByte((System.Byte)SupportClass.URShift(pptLength, 8));
- temp.WriteByte((System.Byte)pptLength);
- temp.WriteByte((System.Byte)pptIndex++);
- for (i = pIndex; i < p; i++)
- {
- temp.Write(packetHeaders[t][i], 0, packetHeaders[t][i].Length);
- }
- pptLength = 3; // Zppt and Lppt
- pIndex = p;
- }
- pptLength += phLength;
- p++;
- np--;
- }
- // Write last PPT marker
- temp.WriteByte((System.Byte)SupportClass.URShift(CSJ2K.j2k.codestream.Markers.PPT, 8));
- temp.WriteByte((System.Byte)(CSJ2K.j2k.codestream.Markers.PPT & 0x00FF));
- temp.WriteByte((System.Byte)SupportClass.URShift(pptLength, 8));
- temp.WriteByte((System.Byte)pptLength);
- temp.WriteByte((System.Byte)pptIndex);
- for (i = pIndex; i < p; i++)
- {
-
- temp.Write(packetHeaders[t][i], 0, packetHeaders[t][i].Length);
- }
- }
- pIndex = p;
- np = nomnp;
-
- // Write SOD marker
- temp.WriteByte((System.Byte)SupportClass.URShift(CSJ2K.j2k.codestream.Markers.SOD, 8));
- temp.WriteByte((System.Byte)(CSJ2K.j2k.codestream.Markers.SOD & 0x00FF));
-
- // Write packet data and packet headers if PPT and PPM not used
- for (p = tppStart; p < tppStart + np; p++)
- {
- if (!tempSop)
- {
- temp.Write(sopMarkSeg[t][p], 0, CSJ2K.j2k.codestream.Markers.SOP_LENGTH);
- }
-
- if (!(ppmUsed || pptUsed))
- {
- temp.Write(packetHeaders[t][p], 0, packetHeaders[t][p].Length);
- }
-
- temp.Write(packetData[t][p], 0, packetData[t][p].Length);
- }
- tppStart += np;
-
- // Edit tile part header
- tempByteArr = temp.ToArray();
- tileParts[t][tilePart] = tempByteArr;
- length = (int)temp.Length;
-
- if (tilePart == 0)
- {
- // Edit first tile part header
- tempByteArr[6] = (byte)(SupportClass.URShift(length, 24)); // Psot
- tempByteArr[7] = (byte)(SupportClass.URShift(length, 16));
- tempByteArr[8] = (byte)(SupportClass.URShift(length, 8));
- tempByteArr[9] = (byte)(length);
- tempByteArr[10] = (byte)SupportClass.Identity((0)); // TPsot
- tempByteArr[11] = (byte)(numTileParts); // TNsot
- }
- else
- {
- // Edit tile part header
- tempByteArr[0] = (byte)(SupportClass.URShift(CSJ2K.j2k.codestream.Markers.SOT, 8)); // SOT
- tempByteArr[1] = (byte)(CSJ2K.j2k.codestream.Markers.SOT & 0x00FF);
- tempByteArr[2] = (byte)SupportClass.Identity((0)); // Lsot
- tempByteArr[3] = (byte)SupportClass.Identity((10));
- tempByteArr[4] = (byte)(SupportClass.URShift(t, 8)); // Isot
- tempByteArr[5] = (byte)(t); //
- tempByteArr[6] = (byte)(SupportClass.URShift(length, 24)); // Psot
- tempByteArr[7] = (byte)(SupportClass.URShift(length, 16));
- tempByteArr[8] = (byte)(SupportClass.URShift(length, 8));
- tempByteArr[9] = (byte)(length);
- tempByteArr[10] = (byte)(tilePart); //TPsot
- tempByteArr[11] = (byte)(numTileParts); // TNsot
- }
- //UPGRADE_ISSUE: Method 'java.io.ByteArrayOutputStream.reset' was not converted. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1000_javaioByteArrayOutputStreamreset'"
- //temp.reset();
- temp.SetLength(0);
- prem -= np;
- }
- }
- temp.Close();
- }
-
- /// This method writes the new codestream to the file.
- ///
- ///
- /// The file to write the new codestream to
- ///
- ///
- /// If an I/O error ocurred.
- ///
- ///
- private void writeNewCodestream(BufferedRandomAccessFile fi)
- {
- int t, p, tp; // i removed
- int numTiles = tileParts.Length;
- int[][] packetHeaderLengths = new int[numTiles][];
- for (int i2 = 0; i2 < numTiles; i2++)
- {
- packetHeaderLengths[i2] = new int[maxtp];
- }
- byte[] temp;
- int length;
-
- // Write main header up to SOT marker
- fi.write(mainHeader, 0, mainHeader.Length);
-
- // If PPM used write all packet headers in PPM markers
- if (ppmUsed)
- {
- System.IO.MemoryStream ppmMarkerSegment = new System.IO.MemoryStream();
- int numPackets;
- int totNumPackets;
- int ppmIndex = 0;
- int ppmLength;
- int pStart, pStop;
- int[] prem = new int[numTiles];
-
- // Set number of remaining packets
- for (t = 0; t < numTiles; t++)
- {
- prem[t] = packetHeaders[t].Length;
- }
-
- // Calculate Nppm values
- for (tp = 0; tp < maxtp; tp++)
- {
- for (t = 0; t < numTiles; t++)
- {
- if (tileParts[t].Length > tp)
- {
- totNumPackets = packetHeaders[t].Length;
- // Calculate number of packets in this tilepart
- numPackets = (tp == tileParts[t].Length - 1) ? prem[t] : pptp;
-
- pStart = totNumPackets - prem[t];
- pStop = pStart + numPackets;
-
- // Calculate number of packet header bytes for this
- // tile part
- for (p = pStart; p < pStop; p++)
- packetHeaderLengths[t][tp] += packetHeaders[t][p].Length;
-
- prem[t] -= numPackets;
- }
- }
- }
-
- // Write first PPM marker
- ppmMarkerSegment.WriteByte((System.Byte)SupportClass.URShift(CSJ2K.j2k.codestream.Markers.PPM, 8));
- ppmMarkerSegment.WriteByte((System.Byte)(CSJ2K.j2k.codestream.Markers.PPM & 0x00FF));
- ppmMarkerSegment.WriteByte((System.Byte)0); // Temporary Lppm value
- ppmMarkerSegment.WriteByte((System.Byte)0); // Temporary Lppm value
- ppmMarkerSegment.WriteByte((System.Byte)0); // zppm
- ppmLength = 3;
- ppmIndex++;
-
- // Set number of remaining packets
- for (t = 0; t < numTiles; t++)
- prem[t] = packetHeaders[t].Length;
-
- // Write all PPM markers and information
- for (tp = 0; tp < maxtp; tp++)
- {
- for (t = 0; t < numTiles; t++)
- {
-
- if (tileParts[t].Length > tp)
- {
- totNumPackets = packetHeaders[t].Length;
-
- // Calculate number of packets in this tilepart
- numPackets = (tp == tileParts[t].Length - 1) ? prem[t] : pptp;
-
- pStart = totNumPackets - prem[t];
- pStop = pStart + numPackets;
-
- // If Nppm value wont fit in current PPM marker segment
- // write current PPM marker segment and start new
- if (ppmLength + 4 > CSJ2K.j2k.codestream.Markers.MAX_LPPM)
- {
- // Write current PPM marker
- temp = ppmMarkerSegment.ToArray();
- length = temp.Length - 2;
- temp[2] = (byte)(SupportClass.URShift(length, 8));
- temp[3] = (byte)length;
- fi.write(temp, 0, length + 2);
-
- // Start new PPM marker segment
- //UPGRADE_ISSUE: Method 'java.io.ByteArrayOutputStream.reset' was not converted. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1000_javaioByteArrayOutputStreamreset'"
- //ppmMarkerSegment.reset();
- ppmMarkerSegment.SetLength(0);
- ppmMarkerSegment.WriteByte((System.Byte)SupportClass.URShift(CSJ2K.j2k.codestream.Markers.PPM, 8));
- ppmMarkerSegment.WriteByte((System.Byte)(CSJ2K.j2k.codestream.Markers.PPM & 0x00FF));
- ppmMarkerSegment.WriteByte((System.Byte)0); // Temporary Lppm value
- ppmMarkerSegment.WriteByte((System.Byte)0); // Temporary Lppm value
- ppmMarkerSegment.WriteByte((System.Byte)ppmIndex++); // zppm
- ppmLength = 3;
- }
-
- // Write Nppm value
- length = packetHeaderLengths[t][tp];
- ppmMarkerSegment.WriteByte((System.Byte)SupportClass.URShift(length, 24));
- ppmMarkerSegment.WriteByte((System.Byte)SupportClass.URShift(length, 16));
- ppmMarkerSegment.WriteByte((System.Byte)SupportClass.URShift(length, 8));
- ppmMarkerSegment.WriteByte((System.Byte)length);
- ppmLength += 4;
-
- // Write packet headers
- for (p = pStart; p < pStop; p++)
- {
- length = packetHeaders[t][p].Length;
-
- // If next packet header value wont fit in
- // current PPM marker segment write current PPM
- // marker segment and start new
- if (ppmLength + length > CSJ2K.j2k.codestream.Markers.MAX_LPPM)
- {
- // Write current PPM marker
- temp = ppmMarkerSegment.ToArray();
- length = temp.Length - 2;
- temp[2] = (byte)(SupportClass.URShift(length, 8));
- temp[3] = (byte)length;
- fi.write(temp, 0, length + 2);
-
- // Start new PPM marker segment
- //UPGRADE_ISSUE: Method 'java.io.ByteArrayOutputStream.reset' was not converted. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1000_javaioByteArrayOutputStreamreset'"
- //ppmMarkerSegment.reset();
- ppmMarkerSegment.SetLength(0);
- ppmMarkerSegment.WriteByte((System.Byte)SupportClass.URShift(CSJ2K.j2k.codestream.Markers.PPM, 8));
- ppmMarkerSegment.WriteByte((System.Byte)(CSJ2K.j2k.codestream.Markers.PPM & 0x00FF));
- ppmMarkerSegment.WriteByte((System.Byte)0); // Temp Lppm value
- ppmMarkerSegment.WriteByte((System.Byte)0); // Temp Lppm value
- ppmMarkerSegment.WriteByte((System.Byte)ppmIndex++); // zppm
- ppmLength = 3;
- }
-
- // write packet header
- ppmMarkerSegment.Write(packetHeaders[t][p], 0, packetHeaders[t][p].Length);
- ppmLength += packetHeaders[t][p].Length;
- }
- prem[t] -= numPackets;
- }
- }
- }
- // Write last PPM marker segment
- temp = ppmMarkerSegment.ToArray();
- length = temp.Length - 2;
- temp[2] = (byte)(SupportClass.URShift(length, 8));
- temp[3] = (byte)length;
- fi.write(temp, 0, length + 2);
- }
-
- // Write tile parts interleaved
- for (tp = 0; tp < maxtp; tp++)
- {
- for (t = 0; t < nt; t++)
- {
- if (tileParts[t].Length > tp)
- {
- temp = tileParts[t][tp];
- length = temp.Length;
- fi.write(temp, 0, length);
- }
- }
- }
- fi.writeShort(CSJ2K.j2k.codestream.Markers.EOC);
- }
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/util/FacilityManager.cs b/CSJ2K/j2k/util/FacilityManager.cs
deleted file mode 100644
index f90fcdff..00000000
--- a/CSJ2K/j2k/util/FacilityManager.cs
+++ /dev/null
@@ -1,183 +0,0 @@
-/*
-* CVS identifier:
-*
-* $Id: FacilityManager.java,v 1.12 2002/05/22 15:00:24 grosbois Exp $
-*
-* Class: MsgLoggerManager
-*
-* Description: Manages common facilities across threads
-*
-*
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-* */
-namespace CSJ2K.j2k.util
-{
-
- /// This class manages common facilities for multi-threaded
- /// environments, It can register different facilities for each thread,
- /// and also a default one, so that they can be referred by static
- /// methods, while possibly having different ones for different
- /// threads. Also a default facility exists that is used for threads
- /// for which no particular facility has been registerd registered.
- ///
- /// Currently the only kind of facilities managed is MsgLogger.
- ///
- /// An example use of this class is if 2 instances of a decoder are running
- /// in different threads and the messages of the 2 instances should be
- /// separated.
- ///
- ///
The default MsgLogger is a StreamMsgLogger that uses System.out as
- /// the 'out' stream and System.err as the 'err' stream, and a line width of
- /// 78. This can be changed using the registerMsgLogger() method.
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- 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());
-
- /// The default logger, for threads that have none associated with them
- private static MsgLogger defMsgLogger = new StreamMsgLogger(System.Console.OpenStandardOutput(), System.Console.OpenStandardError(), 78);
-
- /// The ProgressWatch instance associated to different threads
- //UPGRADE_NOTE: Final was removed from the declaration of 'watchProgList '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- private static readonly System.Collections.Hashtable watchProgList = System.Collections.Hashtable.Synchronized(new System.Collections.Hashtable());
-
- /// The default ProgressWatch for threads that have none
- /// associated with them.
- ///
- private static ProgressWatch defWatchProg = null;
-
-
- internal static void registerProgressWatch(SupportClass.ThreadClass t, ProgressWatch pw)
- {
- if (pw == null)
- {
- throw new System.NullReferenceException();
- }
- if (t == null)
- {
- defWatchProg = pw;
- }
- else
- {
- watchProgList[t] = pw;
- }
- }
-
- /// Registers the MsgLogger 'ml' as the logging facility of the
- /// thread 't'. If any other logging facility was registered with
- /// the thread 't' it is overriden by 'ml'. If 't' is null then
- /// 'ml' is taken as the default message logger that is used for
- /// threads that have no MsgLogger registered.
- ///
- ///
- /// The thread to associate with 'ml'
- ///
- ///
- /// The MsgLogger to associate with therad ml
- ///
- ///
- internal static void registerMsgLogger(SupportClass.ThreadClass t, MsgLogger ml)
- {
- if (ml == null)
- {
- throw new System.NullReferenceException();
- }
- if (t == null)
- {
- defMsgLogger = ml;
- }
- else
- {
- loggerList[t] = ml;
- }
- }
-
- /// Returns the MsgLogger registered with the current thread (the
- /// thread that calls this method). If the current thread has no
- /// registered MsgLogger then the default message logger is
- /// returned.
- ///
- ///
- /// The MsgLogger registerd for the current thread, or the
- /// default one if there is none registered for it.
- ///
- ///
- public static MsgLogger getMsgLogger()
- {
- MsgLogger ml = (MsgLogger)loggerList[SupportClass.ThreadClass.Current()];
- return (ml == null) ? defMsgLogger : ml;
- }
-
- /// Returns the MsgLogger registered with the thread 't' (the
- /// thread that calls this method). If the thread 't' has no
- /// registered MsgLogger then the default message logger is
- /// returned.
- ///
- ///
- /// The thread for which to return the MsgLogger
- ///
- ///
- /// The MsgLogger registerd for the current thread, or the
- /// default one if there is none registered for it.
- ///
- ///
- internal static MsgLogger getMsgLogger(SupportClass.ThreadClass t)
- {
- MsgLogger ml = (MsgLogger)loggerList[t];
- return (ml == null) ? defMsgLogger : ml;
- }
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/util/ISRandomAccessIO.cs b/CSJ2K/j2k/util/ISRandomAccessIO.cs
deleted file mode 100644
index c13665ef..00000000
--- a/CSJ2K/j2k/util/ISRandomAccessIO.cs
+++ /dev/null
@@ -1,743 +0,0 @@
-/*
-* CVS identifier:
-*
-* $Id: ISRandomAccessIO.java,v 1.2 2001/04/09 16:58:15 grosbois Exp $
-*
-* Class: ISRandomAccessIO
-*
-* Description: Turns an InsputStream into a read-only
-* RandomAccessIO, using buffering.
-*
-*
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-* */
-using CSJ2K.j2k.io;
-using System;
-namespace CSJ2K.j2k.util
-{
-
- /// This class implements a wrapper to turn an InputStream into a
- /// RandomAccessIO. To provide random access, the input data from the
- /// InputStream is cached in an in-memory buffer. The in-memory buffer size can
- /// be limited to a specified size. The data is read into the cache on a as
- /// needed basis, blocking only when necessary.
- ///
- /// The cache grows automatically as necessary. However, if the data length
- /// is known prior to the creation of a ISRandomAccessIO object, it is best to
- /// specify that as the initial in-memory buffer size. That will minimize data
- /// copying and multiple allocation.
- ///
- ///
Multi-byte data is read in big-endian order. The in-memory buffer
- /// storage is released when 'close()' is called. This class can only be used
- /// for data input, not output. The wrapped InputStream is closed when all the
- /// input data is cached or when 'close()' is called.
- ///
- /// If an out of memory condition is encountered when growing the in-memory
- /// buffer an IOException is thrown instead of an OutOfMemoryError. The
- /// exception message is "Out of memory to cache input data".
- ///
- /// This class is intended for use as a "quick and dirty" way to give
- /// network connectivity to RandomAccessIO based classes. It is not intended as
- /// an efficient means of implementing network connectivity. Doing such
- /// requires reimplementing the RandomAccessIO based classes to directly use
- /// network connections.
- ///
- /// This class does not use temporary files as buffers, because that would
- /// preclude the use in unsigned applets.
- ///
- ///
- public class ISRandomAccessIO : RandomAccessIO
- {
- /// Returns the current position in the stream, which is the position from
- /// where the next byte of data would be read. The first byte in the stream
- /// is in position 0.
- ///
- ///
- /// If an I/O error occurred.
- ///
- ///
- virtual public int Pos
- {
- get
- {
- return pos;
- }
-
- }
- /// Returns the endianess (i.e., byte ordering) of multi-byte I/O
- /// operations. Always EndianType.BIG_ENDIAN since this class implements
- /// only big-endian.
- ///
- ///
- /// Always EndianType.BIG_ENDIAN.
- ///
- ///
- ///
- ///
- ///
- virtual public int ByteOrdering
- {
- get
- {
- return CSJ2K.j2k.io.EndianType_Fields.BIG_ENDIAN;
- }
-
- }
-
- /// The InputStream that is wrapped
- private System.IO.Stream is_Renamed;
-
- /* Tha maximum size, in bytes, of the in memory buffer. The maximum size
- * includes the EOF. */
- private int maxsize;
-
- /* The increment, in bytes, for the in-memory buffer size */
- private int inc;
-
- /* The in-memory buffer to cache received data */
- private byte[] buf;
-
- /* The length of the already received data */
- private int len;
-
- /* The position of the next byte to be read from the in-memory buffer */
- private int pos;
-
- /* Flag to indicate if all the data has been received. That is, if the EOF
- * has been reached. */
- private bool complete;
-
- /// Creates a new RandomAccessIO wrapper for the given InputStream
- /// 'is'. The internal cache buffer will have size 'size' and will
- /// increment by 'inc' each time it is needed. The maximum buffer size is
- /// limited to 'maxsize'.
- ///
- ///
- /// The input from where to get the data.
- ///
- ///
- /// The initial size for the cache buffer, in bytes.
- ///
- ///
- /// The size increment for the cache buffer, in bytes.
- ///
- ///
- /// The maximum size for the cache buffer, in bytes.
- ///
- ///
- public ISRandomAccessIO(System.IO.Stream is_Renamed, int size, int inc, int maxsize)
- {
- if (size < 0 || inc <= 0 || maxsize <= 0 || is_Renamed == null)
- {
- throw new System.ArgumentException();
- }
- this.is_Renamed = is_Renamed;
- // Increase size by one to count in EOF
- if (size < System.Int32.MaxValue)
- size++;
- buf = new byte[size];
- this.inc = inc;
- // The maximum size is one byte more, to allow reading the EOF.
- if (maxsize < System.Int32.MaxValue)
- maxsize++;
- this.maxsize = maxsize;
- pos = 0;
- len = 0;
- complete = false;
- }
-
- /// Creates a new RandomAccessIO wrapper for the given InputStream
- /// 'is'. The internal cache buffer size and increment is to to 256 kB. The
- /// maximum buffer size is set to Integer.MAX_VALUE (2 GB).
- ///
- ///
- /// The input from where to get the data.
- ///
- ///
- public ISRandomAccessIO(System.IO.Stream is_Renamed) : this(is_Renamed, 1 << 18, 1 << 18, System.Int32.MaxValue)
- {
- }
-
- /// Grows the cache buffer by 'inc', upto a maximum of 'maxsize'. The
- /// buffer size will be increased by at least one byte, if no exception is
- /// thrown.
- ///
- ///
- /// If the maximum cache size is reached or if not
- /// enough memory is available to grow the buffer.
- ///
- ///
- private void growBuffer()
- {
- byte[] newbuf;
- int effinc; // effective increment
-
- effinc = inc;
- if (buf.Length + effinc > maxsize)
- effinc = maxsize - buf.Length;
- if (effinc <= 0)
- {
- throw new System.IO.IOException("Reached maximum cache size (" + maxsize + ")");
- }
- try
- {
- newbuf = new byte[buf.Length + inc];
- }
- catch (System.OutOfMemoryException)
- {
- throw new System.IO.IOException("Out of memory to cache input data");
- }
- Array.Copy(buf, 0, newbuf, 0, len);
- buf = newbuf;
- }
-
- /// Reads data from the wrapped InputStream and places it in the cache
- /// buffer. Reads all input data that will not cause it to block, but at
- /// least on byte is read (even if it blocks), unless EOF is reached. This
- /// method can not be called if EOF has been already reached
- /// (i.e. 'complete' is true). The wrapped InputStream is closed if the EOF
- /// is reached.
- ///
- ///
- /// An I/O error occurred, out of meory to grow
- /// cache or maximum cache size reached.
- ///
- ///
- private void readInput()
- {
- int n;
- //int b;
- int k;
-
- if (complete)
- {
- throw new System.ArgumentException("Already reached EOF");
- }
- long available;
- available = is_Renamed.Length - is_Renamed.Position;
- n = (int)available; /* how much can we read without blocking? */
- if (n == 0)
- n = 1; /* read at least one byte (even if it blocks) */
- while (len + n > buf.Length)
- {
- /* Ensure buffer size */
- growBuffer();
- }
- /* Read the data. Loop to be sure that we do read 'n' bytes */
- do
- {
- // CONVERSION PROBLEM? OPTIMIZE!!!
- k = is_Renamed.Read(buf, len, n);
- if (k > 0)
- {
- /* Some data was read */
- len += k;
- n -= k;
- }
- }
- while (n > 0 && k > 0);
- if (k <= 0)
- {
- /* we reached EOF */
- complete = true;
- is_Renamed.Close();
- is_Renamed = null;
- }
- }
-
- /// Closes this object for reading as well as the wrapped InputStream, if
- /// not already closed. The memory used by the cache is released.
- ///
- ///
- /// If an I/O error occurs while closing the
- /// underlying InputStream.
- ///
- ///
- public virtual void close()
- {
- buf = null;
- if (!complete)
- {
- is_Renamed.Close();
- is_Renamed = null;
- }
- }
-
- /// Moves the current position for the next read operation to offset. The
- /// offset is measured from the beginning of the stream. If the offset is
- /// set beyond the currently cached data, the missing data will be read
- /// only when a read operation is performed. Setting the offset beyond the
- /// end of the data will cause an EOFException only if the data length is
- /// currently known, otherwise an IOException will occur when a read
- /// operation is attempted at that position.
- ///
- ///
- /// The offset where to move to.
- ///
- ///
- /// If seeking beyond EOF and the data length is
- /// known.
- ///
- ///
- /// If an I/O error ocurred.
- ///
- ///
- public virtual void seek(int off)
- {
- if (complete)
- {
- /* we know the length, check seek is within length */
- if (off > len)
- {
- throw new System.IO.EndOfStreamException();
- }
- }
- pos = off;
- }
-
- /// Returns the length of the stream. This will cause all the data to be
- /// read. This method will block until all the data is read, which can be
- /// lengthy across the network.
- ///
- ///
- /// The length of the stream, in bytes.
- ///
- ///
- /// If an I/O error ocurred.
- ///
- ///
- public virtual int length()
- {
- while (!complete)
- {
- /* read until we reach EOF */
- readInput();
- }
- return len;
- }
-
- /// Reads a byte of data from the stream.
- ///
- ///
- /// The byte read, as an int in the range [0-255].
- ///
- ///
- /// If the end-of file was reached.
- ///
- ///
- /// If an I/O error ocurred.
- ///
- ///
- public virtual byte readByte() { return read(); }
- public virtual byte read()
- {
- if (pos < len)
- {
- // common, fast case
- return buf[pos++];
- }
- // general case
- while (!complete && pos >= len)
- {
- readInput();
- }
- if (pos == len)
- {
- throw new System.IO.EndOfStreamException();
- }
- else if (pos > len)
- {
- throw new System.IO.IOException("Position beyond EOF");
- }
- return buf[pos++];
- }
-
- /// Reads 'len' bytes of data from this file into an array of bytes. This
- /// method reads repeatedly from the stream until all the bytes are
- /// read. This method blocks until all the bytes are read, the end of the
- /// stream is detected, or an exception is thrown.
- ///
- ///
- /// The buffer into which the data is to be read. It must be long
- /// enough.
- ///
- ///
- /// The index in 'b' where to place the first byte read.
- ///
- ///
- /// The number of bytes to read.
- ///
- ///
- /// If the end-of file was reached before getting
- /// all the necessary data.
- ///
- ///
- /// If an I/O error ocurred.
- ///
- ///
- public virtual void readFully(byte[] b, int off, int n)
- {
- if (pos + n <= len)
- {
- // common, fast case
- Array.Copy(buf, pos, b, off, n);
- pos += n;
- return;
- }
- // general case
- while (!complete && pos + n > len)
- {
- readInput();
- }
- if (pos + n > len)
- {
- throw new System.IO.EndOfStreamException();
- }
- Array.Copy(buf, pos, b, off, n);
- pos += n;
- }
-
- /// Reads an unsigned byte (8 bit) from the input.
- ///
- ///
- /// The next byte-aligned unsigned byte (8 bit) from the input.
- ///
- ///
- /// If the end-of file was reached before getting
- /// all the necessary data.
- ///
- ///
- /// If an I/O error ocurred.
- ///
- ///
- public virtual byte readUnsignedByte()
- {
- if (pos < len)
- {
- // common, fast case
- return buf[pos++];
- }
- // general case
- return read();
- }
-
- /// Reads a signed short (16 bit) from the input.
- ///
- ///
- /// The next byte-aligned signed short (16 bit) from the input.
- ///
- ///
- /// If the end-of file was reached before getting
- /// all the necessary data.
- ///
- ///
- /// If an I/O error ocurred.
- ///
- ///
- public virtual short readShort()
- {
- if (pos + 1 < len)
- {
- // common, fast case
- return (short)((buf[pos++] << 8) | (0xFF & buf[pos++]));
- }
- // general case
- return (short)((read() << 8) | read());
- }
-
- /// Reads an unsigned short (16 bit) from the input.
- ///
- ///
- /// The next byte-aligned unsigned short (16 bit) from the input.
- ///
- ///
- /// If the end-of file was reached before getting
- /// all the necessary data.
- ///
- ///
- /// If an I/O error ocurred.
- ///
- ///
- public virtual int readUnsignedShort()
- {
- if (pos + 1 < len)
- {
- // common, fast case
- return ((0xFF & buf[pos++]) << 8) | (0xFF & buf[pos++]);
- }
- // general case
- return (read() << 8) | read();
- }
-
- /// Reads a signed int (32 bit) from the input.
- ///
- ///
- /// The next byte-aligned signed int (32 bit) from the
- /// input.
- ///
- ///
- /// If the end-of file was reached before getting
- /// all the necessary data.
- ///
- ///
- /// If an I/O error ocurred.
- ///
- ///
- public virtual int readInt()
- {
- if (pos + 3 < len)
- {
- // common, fast case
- return ((buf[pos++] << 24) | ((0xFF & buf[pos++]) << 16) | ((0xFF & buf[pos++]) << 8) | (0xFF & buf[pos++]));
- }
- // general case
- return (read() << 24) | (read() << 16) | (read() << 8) | read();
- }
-
- /// Reads a unsigned int (32 bit) from the input.
- ///
- ///
- /// The next byte-aligned unsigned int (32 bit) from the input.
- ///
- ///
- /// If the end-of file was reached before getting
- /// all the necessary data.
- ///
- ///
- /// If an I/O error ocurred.
- ///
- ///
- public virtual long readUnsignedInt()
- {
- if (pos + 3 < len)
- {
- // common, fast case
- return (unchecked((int)0xFFFFFFFFL) & (long)((buf[pos++] << 24) | ((0xFF & buf[pos++]) << 16) | ((0xFF & buf[pos++]) << 8) | (0xFF & buf[pos++])));
- }
- // general case
- return (unchecked((int)0xFFFFFFFFL) & (long)((read() << 24) | (read() << 16) | (read() << 8) | read()));
- }
-
- /// Reads a signed long (64 bit) from the input.
- ///
- ///
- /// The next byte-aligned signed long (64 bit) from the input.
- ///
- ///
- /// If the end-of file was reached before getting
- /// all the necessary data.
- ///
- ///
- /// If an I/O error ocurred.
- ///
- ///
- public virtual long readLong()
- {
- if (pos + 7 < len)
- {
- // common, fast case
- return (((long)buf[pos++] << 56) | ((long)buf[pos++] << 48) | ((long)buf[pos++] << 40) | ((long)buf[pos++] << 32) | ((long)buf[pos++] << 24) | ((long)buf[pos++] << 16) | ((long)buf[pos++] << 8) | (long)buf[pos++]);
- }
- // general case
- return (((long)read() << 56) | ((long)read() << 48) | ((long)read() << 40) | ((long)read() << 32) | ((long)read() << 24) | ((long)read() << 16) | ((long)read() << 8) | (long)read());
- }
-
- /// Reads an IEEE single precision (i.e., 32 bit) floating-point number
- /// from the input.
- ///
- ///
- /// The next byte-aligned IEEE float (32 bit) from the input.
- ///
- ///
- /// If the end-of file was reached before getting
- /// all the necessary data.
- ///
- ///
- /// If an I/O error ocurred.
- ///
- ///
- public virtual float readFloat()
- {
- // CONVERSION PROBLEM? BIGENDIAN
- int floatint;
- if (pos + 3 < len)
- floatint = (buf[pos++] << 24) | ((0xFF & buf[pos++]) << 16) | ((0xFF & buf[pos++]) << 8) | (0xFF & buf[pos++]);
- else
- floatint = (read() << 24) | (read() << 16) | (read() << 8) | read();
- return BitConverter.ToSingle(BitConverter.GetBytes(floatint), 0);
-
- /*
- if (pos + 3 < len)
- {
- // common, fast case
- //UPGRADE_ISSUE: Method 'java.lang.Float.intBitsToFloat' was not converted. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1000_javalangFloatintBitsToFloat_int'"
- return Float.intBitsToFloat((buf[pos++] << 24) | ((0xFF & buf[pos++]) << 16) | ((0xFF & buf[pos++]) << 8) | (0xFF & buf[pos++]));
- }
- // general case
- //UPGRADE_ISSUE: Method 'java.lang.Float.intBitsToFloat' was not converted. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1000_javalangFloatintBitsToFloat_int'"
- return Float.intBitsToFloat((read() << 24) | (read() << 16) | (read() << 8) | read());
- */
- }
-
- /// Reads an IEEE double precision (i.e., 64 bit) floating-point number
- /// from the input.
- ///
- ///
- /// The next byte-aligned IEEE double (64 bit) from the input.
- ///
- ///
- /// If the end-of file was reached before getting
- /// all the necessary data.
- ///
- ///
- /// If an I/O error ocurred.
- ///
- ///
- public virtual double readDouble()
- {
- // CONVERSION PROBLEM? BIGENDIAN
- long doublelong;
- if (pos + 7 < len)
- doublelong = ((long)buf[pos++] << 56) | ((long)buf[pos++] << 48) | ((long)buf[pos++] << 40) | ((long)buf[pos++] << 32) | ((long)buf[pos++] << 24) | ((long)buf[pos++] << 16) | ((long)buf[pos++] << 8) | (long)buf[pos++];
- else
- doublelong = ((long)read() << 56) | ((long)read() << 48) | ((long)read() << 40) | ((long)read() << 32) | ((long)read() << 24) | ((long)read() << 16) | ((long)read() << 8) | (long)read();
- return BitConverter.ToDouble(BitConverter.GetBytes(doublelong), 0);
-
- /*
- if (pos + 7 < len)
- {
- // common, fast case
- //UPGRADE_ISSUE: Method 'java.lang.Double.longBitsToDouble' was not converted. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1000_javalangDoublelongBitsToDouble_long'"
- return Double.longBitsToDouble(((long) buf[pos++] << 56) | ((long) (0xFF & buf[pos++]) << 48) | ((long) (0xFF & buf[pos++]) << 40) | ((long) (0xFF & buf[pos++]) << 32) | ((long) (0xFF & buf[pos++]) << 24) | ((long) (0xFF & buf[pos++]) << 16) | ((long) (0xFF & buf[pos++]) << 8) | (long) (0xFF & buf[pos++]));
- }
- // general case
- //UPGRADE_ISSUE: Method 'java.lang.Double.longBitsToDouble' was not converted. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1000_javalangDoublelongBitsToDouble_long'"
- return Double.longBitsToDouble(((long) read() << 56) | ((long) read() << 48) | ((long) read() << 40) | ((long) read() << 32) | ((long) read() << 24) | ((long) read() << 16) | ((long) read() << 8) | (long) read());
- */
- }
-
- /// Skips 'n' bytes from the input.
- ///
- ///
- /// The number of bytes to skip
- ///
- ///
- /// Always n.
- ///
- ///
- /// If the end-of file was reached before all the
- /// bytes could be skipped.
- ///
- ///
- /// If an I/O error ocurred.
- ///
- ///
- public virtual int skipBytes(int n)
- {
- if (complete)
- {
- /* we know the length, check skip is within length */
- if (pos + n > len)
- {
- throw new System.IO.EndOfStreamException();
- }
- }
- pos += n;
- return n;
- }
-
- /// Does nothing since this class does not implement data output.
- ///
- ///
- public virtual void flush()
- {
- /* no-op */
- }
-
- /// Throws an IOException since this class does not implement data output.
- ///
- ///
- public virtual void write(byte b)
- {
- throw new System.IO.IOException("read-only");
- }
-
- /// Throws an IOException since this class does not implement data output.
- ///
- ///
- public virtual void writeByte(int v)
- {
- throw new System.IO.IOException("read-only");
- }
-
- /// Throws an IOException since this class does not implement data output.
- ///
- ///
- public virtual void writeShort(int v)
- {
- throw new System.IO.IOException("read-only");
- }
-
- /// Throws an IOException since this class does not implement data output.
- ///
- ///
- public virtual void writeInt(int v)
- {
- throw new System.IO.IOException("read-only");
- }
-
- /// Throws an IOException since this class does not implement data output.
- ///
- ///
- public virtual void writeLong(long v)
- {
- throw new System.IO.IOException("read-only");
- }
-
- /// Throws an IOException since this class does not implement data output.
- ///
- ///
- public virtual void writeFloat(float v)
- {
- throw new System.IO.IOException("read-only");
- }
-
- /// Throws an IOException since this class does not implement data output.
- ///
- ///
- public virtual void writeDouble(double v)
- {
- throw new System.IO.IOException("read-only");
- }
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/util/MathUtil.cs b/CSJ2K/j2k/util/MathUtil.cs
deleted file mode 100644
index 85fd55b3..00000000
--- a/CSJ2K/j2k/util/MathUtil.cs
+++ /dev/null
@@ -1,206 +0,0 @@
-/*
-* CVS identifier:
-*
-* $Id: MathUtil.java,v 1.15 2001/09/14 08:48:51 grosbois Exp $
-*
-* Class: MathUtil
-*
-* Description: Utility mathematical methods
-*
-*
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-* */
-namespace CSJ2K.j2k.util
-{
-
- /// This class contains a collection of utility methods fro mathematical
- /// operations. All methods are static.
- ///
- ///
- public class MathUtil
- {
-
- /// Method that calculates the floor of the log, base 2, of 'x'. The
- /// calculation is performed in integer arithmetic, therefore, it is exact.
- ///
- ///
- /// The value to calculate log2 on.
- ///
- ///
- /// floor(log(x)/log(2)), calculated in an exact way.
- ///
- ///
- public static int log2(int x)
- {
- int y, v;
- // No log of 0 or negative
- if (x <= 0)
- {
- throw new System.ArgumentException("" + x + " <= 0");
- }
- // Calculate log2 (it's actually floor log2)
- v = x;
- y = -1;
- while (v > 0)
- {
- v >>= 1;
- y++;
- }
- return y;
- }
-
- /// Method that calculates the Least Common Multiple (LCM) of two strictly
- /// positive integer numbers.
- ///
- ///
- /// First number
- ///
- ///
- /// Second number
- ///
- ///
- public static int lcm(int x1, int x2)
- {
- if (x1 <= 0 || x2 <= 0)
- {
- throw new System.ArgumentException("Cannot compute the least " + "common multiple of two " + "numbers if one, at least," + "is negative.");
- }
- int max, min;
- if (x1 > x2)
- {
- max = x1;
- min = x2;
- }
- else
- {
- max = x2;
- min = x1;
- }
- for (int i = 1; i <= min; i++)
- {
- if ((max * i) % min == 0)
- {
- return i * max;
- }
- }
- throw new System.ApplicationException("Cannot find the least common multiple of numbers " + x1 + " and " + x2);
- }
-
- /// Method that calculates the Least Common Multiple (LCM) of several
- /// positive integer numbers.
- ///
- ///
- /// Array containing the numbers.
- ///
- ///
- public static int lcm(int[] x)
- {
- if (x.Length < 2)
- {
- throw new System.ApplicationException("Do not use this method if there are less than" + " two numbers.");
- }
- int tmp = lcm(x[x.Length - 1], x[x.Length - 2]);
- for (int i = x.Length - 3; i >= 0; i--)
- {
- if (x[i] <= 0)
- {
- throw new System.ArgumentException("Cannot compute the least " + "common multiple of " + "several numbers where " + "one, at least," + "is negative.");
- }
- tmp = lcm(tmp, x[i]);
- }
- return tmp;
- }
-
- /// Method that calculates the Greatest Common Divisor (GCD) of two
- /// positive integer numbers.
- ///
- ///
- public static int gcd(int x1, int x2)
- {
- if (x1 < 0 || x2 < 0)
- {
- throw new System.ArgumentException("Cannot compute the GCD " + "if one integer is negative.");
- }
- int a, b, g, z;
-
- if (x1 > x2)
- {
- a = x1;
- b = x2;
- }
- else
- {
- a = x2;
- b = x1;
- }
-
- if (b == 0)
- return 0;
-
- g = b;
-
- while (g != 0)
- {
- z = a % g;
- a = g;
- g = z;
- }
- return a;
- }
-
- /// Method that calculates the Greatest Common Divisor (GCD) of several
- /// positive integer numbers.
- ///
- ///
- /// Array containing the numbers.
- ///
- ///
- public static int gcd(int[] x)
- {
- if (x.Length < 2)
- {
- throw new System.ApplicationException("Do not use this method if there are less than" + " two numbers.");
- }
- int tmp = gcd(x[x.Length - 1], x[x.Length - 2]);
- for (int i = x.Length - 3; i >= 0; i--)
- {
- if (x[i] < 0)
- {
- throw new System.ArgumentException("Cannot compute the least " + "common multiple of " + "several numbers where " + "one, at least," + "is negative.");
- }
- tmp = gcd(tmp, x[i]);
- }
- return tmp;
- }
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/util/MsgLogger.cs b/CSJ2K/j2k/util/MsgLogger.cs
deleted file mode 100644
index 2e5b6ee8..00000000
--- a/CSJ2K/j2k/util/MsgLogger.cs
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
-* CVS identifier:
-*
-* $Id: MsgLogger.java,v 1.7 2001/08/17 16:24:51 grosbois Exp $
-*
-* Class: MsgLogger
-*
-* Description: Facility to log messages (abstract)
-*
-*
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-* */
-namespace CSJ2K.j2k.util
-{
-
- /// This class provides a simple common abstraction of a facility that logs
- /// and/or displays messages or simple strings. The underlying facility can be
- /// a terminal, text file, text area in a GUI display, dialog boxes in a GUI
- /// display, etc., or a combination of those.
- ///
- /// <>Messages are short strings (a couple of lines) that indicate some state
- /// of the program, and that have a severity code associated with them (see
- /// below). Simple strings is text (can be long) that has no severity code
- /// associated with it. Typical use of simple strings is to display help
- /// texts.
- ///
- /// Each message has a severity code, which can be one of the following:
- /// LOG, INFO, WARNING, ERROR. Each implementation should treat each severity
- /// code in a way which corresponds to the type of diplay used.
- ///
- /// Messages are printed via the 'printmsg()' method. Simple strings are
- /// printed via the 'print()', 'println()' and 'flush()' methods, each simple
- /// string is considered to be terminated once the 'flush()' method has been
- /// called. The 'printmsg()' method should never be called before a previous
- /// simple string has been terminated.
- ///
- ///
- public struct MsgLogger_Fields
- {
- /// Severity of message. LOG messages are just for bookkeeping and do not
- /// need to be displayed in the majority of cases
- ///
- public const int LOG = 0;
- /// Severity of message. INFO messages should be displayed just for user
- /// feedback.
- ///
- public const int INFO = 1;
- /// Severity of message. WARNING messages denote that an unexpected state
- /// has been reached and should be given as feedback to the user.
- ///
- public const int WARNING = 2;
- /// Severity of message. ERROR messages denote that something has gone
- /// wrong and probably that execution has ended. They should be definetely
- /// displayed to the user.
- ///
- public const int ERROR = 3;
- }
- public interface MsgLogger
- {
- //UPGRADE_NOTE: Members of interface 'MsgLogger' were extracted into structure 'MsgLogger_Fields'. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1045'"
-
- /// Prints the message 'msg' to the output device, appending a newline,
- /// with severity 'sev'. Some implementations where the appended newline is
- /// irrelevant may not append the newline. Depending on the implementation
- /// the severity of the message may be added to it. The message is
- /// reformatted as appropriate for the output devic, but any newline
- /// characters are respected.
- ///
- ///
- /// The message severity (LOG, INFO, etc.)
- ///
- ///
- /// The message to display
- ///
- ///
- void printmsg(int sev, System.String msg);
-
- /// Prints the string 'str' to the output device, appending a line
- /// return. The message is reformatted as appropriate to the particular
- /// diplaying device, where 'flind' and 'ind' are used as hints for
- /// performing that operation. However, any newlines appearing in 'str' are
- /// respected. The output device may not display the string until flush()
- /// is called. Some implementations may automatically flush when this
- /// method is called. This method just prints the string, the string does
- /// not make part of a "message" in the sense that no severity is
- /// associated to it.
- ///
- ///
- /// The string to print
- ///
- ///
- /// Indentation of the first line
- ///
- ///
- /// Indentation of any other lines.
- ///
- ///
- void println(System.String str, int flind, int ind);
-
- /// Writes any buffered data from the println() method to the device.
- ///
- ///
- void flush();
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/util/MsgPrinter.cs b/CSJ2K/j2k/util/MsgPrinter.cs
deleted file mode 100644
index b3ab3a18..00000000
--- a/CSJ2K/j2k/util/MsgPrinter.cs
+++ /dev/null
@@ -1,321 +0,0 @@
-/*
-* CVS identifier:
-*
-* $Id: MsgPrinter.java,v 1.6 2000/09/05 09:25:24 grosbois Exp $
-*
-* Class: MsgPrinter
-*
-* Description: Prints messages formatted for a specific
-* line width.
-*
-*
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-*
-*
-*
-*/
-namespace CSJ2K.j2k.util
-{
-
- /// This utility class formats messages to the specified line width, by
- /// inserting line-breaks between words, and printing the resulting
- /// lines.
- ///
- ///
- public class MsgPrinter
- {
- //UPGRADE_NOTE: Respective javadoc comments were merged. It should be changed in order to comply with .NET documentation conventions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1199'"
- /// Returns the line width that is used for formatting.
- ///
- ///
- /// The line width used for formatting
- ///
- ///
- ///
- ///
- /// Sets the line width to the specified value. This new value will
- /// be used in subsequent calls to the print() message.
- ///
- ///
- /// The new line width to use (in cahracters)
- ///
- ///
- ///
- ///
- virtual public int LineWidth
- {
- get
- {
- return lw;
- }
-
- set
- {
- if (value < 1)
- {
- throw new System.ArgumentException();
- }
- lw = value;
- }
-
- }
-
- /// The line width to use
- public int lw;
-
- /// Signals that a newline was found
- private const int IS_NEWLINE = -2;
-
- /// Signals that the end-of-string was reached
- private const int IS_EOS = -1;
-
- /// Creates a new message printer with the specified line width and
- /// with the default locale.
- ///
- ///
- /// The line width for which to format (in
- /// characters)
- ///
- ///
- ///
- ///
- public MsgPrinter(int linewidth)
- {
- lw = linewidth;
- }
-
- /// Formats the message to print in the current line width, by
- /// breaking the message into lines between words. The number of
- /// spaces to indent the first line is specified by 'flind' and the
- /// number of spaces to indent each of the following lines is
- /// specified by 'ind'. Newlines in 'msg' are respected. A newline is
- /// always printed at the end.
- ///
- ///
- /// Where to print the message.
- ///
- ///
- /// The indentation for the first line.
- ///
- ///
- /// The indentation for the other lines.
- ///
- ///
- /// The message to format and print.
- ///
- ///
- ///
- ///
- public virtual void print(System.IO.StreamWriter out_Renamed, int flind, int ind, System.String msg)
- {
- int start, end, pend, efflw, lind, i;
-
- start = 0;
- end = 0;
- pend = 0;
- efflw = lw - flind;
- lind = flind;
- while ((end = nextLineEnd(msg, pend)) != IS_EOS)
- {
- if (end == IS_NEWLINE)
- {
- // Forced line break
- for (i = 0; i < lind; i++)
- {
- out_Renamed.Write(" ");
- }
- //UPGRADE_TODO: Method 'java.io.PrintWriter.println' was converted to 'System.IO.TextWriter.WriteLine' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaioPrintWriterprintln_javalangString'"
- out_Renamed.WriteLine(msg.Substring(start, (pend) - (start)));
- if (nextWord(msg, pend) == msg.Length)
- {
- // Traling newline => print it and done
- //UPGRADE_TODO: Method 'java.io.PrintWriter.println' was converted to 'System.IO.TextWriter.WriteLine' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaioPrintWriterprintln_javalangString'"
- out_Renamed.WriteLine("");
- start = pend;
- break;
- }
- }
- else
- {
- if (efflw > end - pend)
- {
- // Room left on current line
- efflw -= (end - pend);
- pend = end;
- continue;
- }
- else
- {
- // Filled-up current line => print it
- for (i = 0; i < lind; i++)
- {
- out_Renamed.Write(" ");
- }
- if (start == pend)
- {
- // Word larger than line width
- // Print anyways
- //UPGRADE_TODO: Method 'java.io.PrintWriter.println' was converted to 'System.IO.TextWriter.WriteLine' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaioPrintWriterprintln_javalangString'"
- out_Renamed.WriteLine(msg.Substring(start, (end) - (start)));
- pend = end;
- }
- else
- {
- //UPGRADE_TODO: Method 'java.io.PrintWriter.println' was converted to 'System.IO.TextWriter.WriteLine' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaioPrintWriterprintln_javalangString'"
- out_Renamed.WriteLine(msg.Substring(start, (pend) - (start)));
- }
- }
- }
- // Initialize for next line
- lind = ind;
- efflw = lw - ind;
- start = nextWord(msg, pend);
- pend = start;
- if (start == IS_EOS)
- {
- break; // Did all the string
- }
- }
- if (pend != start)
- {
- // Part of a line left => print it
- for (i = 0; i < lind; i++)
- {
- out_Renamed.Write(" ");
- }
- //UPGRADE_TODO: Method 'java.io.PrintWriter.println' was converted to 'System.IO.TextWriter.WriteLine' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaioPrintWriterprintln_javalangString'"
- out_Renamed.WriteLine(msg.Substring(start, (pend) - (start)));
- }
- }
-
- /// Returns the index of the last character of the next word, plus 1, or
- /// IS_NEWLINE if a newline character is encountered before the next word,
- /// or IS_EOS if the end of the string is ecnounterd before the next
- /// word. The method first skips all whitespace characters at or after
- /// 'from', except newlines. If a newline is found IS_NEWLINE is
- /// returned. Then it skips all non-whitespace characters and returns the
- /// position of the last non-whitespace character, plus 1. The returned
- /// index may be greater than the last valid index in the tsring, but it is
- /// always suitable to be used in the String.substring() method.
- ///
- /// Non-whitespace characters are defined as in the
- /// Character.isWhitespace method (that method is used).
- ///
- ///
- /// The string to parse
- ///
- ///
- /// The index of the first position to search from
- ///
- ///
- /// The index of the last character in the next word, plus 1,
- /// IS_NEWLINE, or IS_EOS if there are no more words.
- ///
- ///
- ///
- ///
- private int nextLineEnd(System.String str, int from)
- {
- //UPGRADE_NOTE: Final was removed from the declaration of 'len '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- int len = str.Length;
- char c = '\x0000';
- // First skip all whitespace, except new line
- while (from < len && (c = str[from]) != '\n' && System.Char.IsWhiteSpace(c))
- {
- from++;
- }
- if (c == '\n')
- {
- return IS_NEWLINE;
- }
- if (from >= len)
- {
- return IS_EOS;
- }
- // Now skip word characters
- while (from < len && !System.Char.IsWhiteSpace(str[from]))
- {
- from++;
- }
- return from;
- }
-
- /// Returns the position of the first character in the next word, starting
- /// from 'from', if a newline is encountered first then the index of the
- /// newline character plus 1 is returned. If the end of the string is
- /// encountered then IS_EOS is returned. Words are defined as any
- /// concatenation of 1 or more characters which are not
- /// whitespace. Whitespace characters are those for which
- /// Character.isWhitespace() returns true (that method is used).
- ///
- /// Non-whitespace characters are defined as in the
- /// Character.isWhitespace method (that method is used).
- ///
- ///
- /// The string to parse
- ///
- ///
- /// The index where to start parsing
- ///
- ///
- /// The index of the first character of the next word, or the index
- /// of the newline plus 1, or IS_EOS.
- ///
- ///
- ///
- ///
- private int nextWord(System.String str, int from)
- {
- //UPGRADE_NOTE: Final was removed from the declaration of 'len '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- int len = str.Length;
- char c = '\x0000';
- // First skip all whitespace, but new lines
- while (from < len && (c = str[from]) != '\n' && System.Char.IsWhiteSpace(c))
- {
- from++;
- }
- if (from >= len)
- {
- return IS_EOS;
- }
- else if (c == '\n')
- {
- return from + 1;
- }
- else
- {
- return from;
- }
- }
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/util/ParameterList.cs b/CSJ2K/j2k/util/ParameterList.cs
deleted file mode 100644
index 03903829..00000000
--- a/CSJ2K/j2k/util/ParameterList.cs
+++ /dev/null
@@ -1,578 +0,0 @@
-/*
-* CVS identifier:
-*
-* $Id: ParameterList.java,v 1.18 2001/07/17 16:21:35 grosbois Exp $
-*
-* Class: ParameterList
-*
-* Description: Class to hold parameters.
-*
-*
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-* */
-using System;
-namespace CSJ2K.j2k.util
-{
-
- /// This class holds modules options and parameters as they are provided to the
- /// encoder or the decoder. Each option and its associated parameters are
- /// stored as strings.
- ///
- /// This class is built on the standard Java Properties class. Consequently,
- /// it offers facilities to load and write parameters from/to a file. In the
- /// meantime, a ParameterList object can also handle default parameters for
- /// each option.
- ///
- /// Each parameter can be retrieved as a string or as an specific primitive
- /// type (int, float, etc).
- ///
- /// For more details see the Properties class.
- ///
- /// Note that this class does not support multiple occurrences of parameters
- /// (for a parameter name, only one value is possible). Also there is no
- /// particular order of the parameters.
- ///
- ///
- ///
- ///
- ///
- //UPGRADE_ISSUE: Class hierarchy differences between 'java.util.Properties' and 'System.Collections.Specialized.NameValueCollection' may cause compilation errors. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1186'"
- [Serializable]
- public class ParameterList : System.Collections.Specialized.NameValueCollection
- {
- // COVNERSION PROBLEM?
- private ParameterList defaults;
-
- /// Returns the default ParameterList.
- ///
- ///
- /// Default ParameterList
- ///
- ///
- virtual public ParameterList DefaultParameterList
- {
- get
- {
- //UPGRADE_ISSUE: Field 'java.util.Properties.defaults' was not converted. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1000_javautilPropertiesdefaults_f'"
- return (ParameterList)defaults;
- }
-
- }
-
- /// Constructs an empty ParameterList object. It can be later completed by
- /// adding elements one by one, by loading them from a file, or by
- /// initializing them from an argument string.
- ///
- ///
- //UPGRADE_TODO: Format of property file may need to be changed. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1089'"
- //UPGRADE_ISSUE: Class hierarchy differences between 'java.util.Properties' and 'System.Collections.Specialized.NameValueCollection' may cause compilation errors. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1186'"
- public ParameterList() : base()
- {
- }
-
- /// Constructs an empty ParameterList object with the provided default
- /// parameters. The list can be later updated by adding elements one by
- /// one, by loading them from a file, or by initializing them from an
- /// argument string.
- ///
- ///
- /// The defaults parameters
- ///
- ///
- //UPGRADE_TODO: Format of property file may need to be changed. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1089'"
- //UPGRADE_ISSUE: Class hierarchy differences between 'java.util.Properties' and 'System.Collections.Specialized.NameValueCollection' may cause compilation errors. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1186'"
- public ParameterList(ParameterList def) : base()
- {
- defaults = def;
- }
-
- /// Parses the parameters from an argument list, such as as the one in the
- /// command line, and integrates them in this parameter list.
- ///
- /// All options must be preceded by '-' and then followed by one or more
- /// words, which constitues the values. The name of the options constitute
- /// the name of the parameters. The only exception is for boolean options,
- /// in which case if they are preceded by '-' they will be turned on, and
- /// if preceded by '+' they will be turned off. The string value of a
- /// boolean option is "on" or "off". Note that the '-' and '+' characters
- /// can not precede any word which would be a value for an option unless
- /// they are numeric values (otherwise it would be considered as a boolean
- /// option). Note also that the name of an option can not start with a
- /// number.
- ///
- /// No option can appear more than once. If so happens an exception is
- /// thrown.
- ///
- /// For instance the string:
- ///
- /// "-Ffilters w5x3 -Wlev 5 -Qtype reversible
- ///
- ///
will create the following parameter list:
- ///
- ///
- /// Ffilers w5x3
- /// Wlev 5
- /// Qtype reversible
- ///
- ///
- ///
- /// The argument list.
- ///
- ///
- /// if there are invalid arguments in
- /// 'argv'
- ///
- ///
- public virtual void parseArgs(System.String[] argv)
- {
- int k;
- char c, c2;
- System.String pname;
- System.Text.StringBuilder pvalue;
-
- // Read options
- k = -1;
- // Skip empty arguments
- do
- {
- k++;
- if (k >= argv.Length)
- {
- // Nothing to put in parameters
- return;
- }
- }
- while (argv[k].Length <= 0);
-
- // Check that we start with an option and that its is not a number
- c = argv[k][0];
- if (c != '-' && c != '+')
- {
- // It's not an option
- throw new StringFormatException("Argument list does not" + " start with an option: " + argv[k]);
- }
- if (argv[k].Length >= 2 && System.Char.IsDigit(argv[k][1]))
- {
- throw new StringFormatException("Numeric option name: " + argv[k]);
- }
- pvalue = new System.Text.StringBuilder();
- while (k < argv.Length)
- {
- // Read parameter name
- if (argv[k].Length <= 1)
- {
- throw new StringFormatException("Option \"" + argv[k] + "\" is too short.");
- }
- c = argv[k][0];
- pname = argv[k++];
- pvalue.Length = 0;
- // Are there any more arguments?
- if (k >= argv.Length)
- {
- // No more words in argument list => must be boolean
- pvalue.Append((c == '-') ? "on" : "off");
- }
- else
- {
- c2 = argv[k][0];
- // Is next word an option or a value?
- if (c2 == '-' || c2 == '+')
- {
- // Next word could be an option
- if (argv[k].Length <= 1)
- {
- throw new StringFormatException("Option or argument \"" + argv[k] + "\" too short");
- }
- if (!System.Char.IsDigit(argv[k][1]))
- {
- // Not a number => we have a boolean option in pname
- pvalue.Append((c == '-') ? "on" : "off");
- }
- }
- if (pvalue.Length == 0)
- {
- // No value yet
- // It should not a boolean option, read the values
- if (c == '+')
- {
- throw new StringFormatException("Boolean option \"" + pname + "\" has a value");
- }
- // We have at least one value
- pvalue.Append(argv[k++]);
- while (k < argv.Length)
- {
- // If empty string skip it
- if (argv[k].Length == 0)
- {
- k++;
- continue;
- }
- c = argv[k][0];
- if (c == '-' || c == '+')
- {
- // Next word could be an option
- if (argv[k].Length <= 1)
- {
- throw new StringFormatException("Option or " + "argument \"" + argv[k] + "\" too short");
- }
- if (!System.Char.IsDigit(argv[k][1]))
- {
- // It's an option => stop
- break;
- }
- }
- pvalue.Append(' '); // Add a space
- pvalue.Append(argv[k++]);
- }
- }
- }
- // Now put parameter and value in the list
- /*
- if (this[(System.String) pname.Substring(1)] != null)
- {
- // Option is repeated => ERROR
- throw new StringFormatException("Option \"" + pname + "\" appears more than once");
- }
- */
- System.Object tempObject;
- //UPGRADE_WARNING: At least one expression was used more than once in the target code. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1181'"
- tempObject = this[(System.String)pname.Substring(1)];
- this[(System.String)pname.Substring(1)] = (System.String)pvalue.ToString();
- System.Object generatedAux4 = tempObject;
- }
- }
-
- /// Returns the value of the named parameter, as a string. The value can
- /// come from teh defaults, if there are.
- ///
- ///
- /// The parameter name.
- ///
- ///
- /// the value of the parameter as a string, or null if there is no
- /// parameter with the name 'pname'.
- ///
- ///
- public virtual System.String getParameter(System.String pname)
- {
- System.String pval;
-
- pval = ((System.String)this[(System.String)pname]);
- //UPGRADE_ISSUE: Field 'java.util.Properties.defaults' was not converted. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1000_javautilPropertiesdefaults_f'"
- if (pval == null && defaults != null)
- {
- // if parameter is not there
- // Look in defaults
- //UPGRADE_ISSUE: Field 'java.util.Properties.defaults' was not converted. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1000_javautilPropertiesdefaults_f'"
- pval = defaults.Get(pname);
- }
- return pval;
- }
-
- /// Returns the value of the named parameter as a boolean. The value "on"
- /// is interpreted as 'true', while the value "off" is interpreted as
- /// 'false'. If the parameter has another value then an
- /// StringFormatException is thrown. If the parameter 'pname' is not in the
- /// parameter list, an IllegalArgumentException is thrown.
- ///
- ///
- /// The parameter name.
- ///
- ///
- /// the value of the parameter as a boolean.
- ///
- ///
- /// If the parameter has a value which is
- /// neither "on" nor "off".
- ///
- ///
- /// If there is no parameter with the
- /// name 'pname' in the parameter list.
- ///
- ///
- public virtual bool getBooleanParameter(System.String pname)
- {
- System.String s = (System.String)getParameter(pname);
-
- if (s == null)
- {
- throw new System.ArgumentException("No parameter with name " + pname);
- }
- else if (s.Equals("on"))
- {
- return true;
- }
- else if (s.Equals("off"))
- {
- return false;
- }
- else
- {
- throw new StringFormatException("Parameter \"" + pname + "\" is not boolean: " + s);
- }
- }
-
- /// Returns the value of the named parameter as an int. If the parameter
- /// has a non-numeric value a NumberFormatException is thrown. If the
- /// parameter has a multiple word value than the first word is returned as
- /// an int, others are ignored. If the parameter 'pname' is not in the
- /// parameter list, an IllegalArgumentException is thrown.
- ///
- ///
- /// The parameter name.
- ///
- ///
- /// the value of the parameter as an int.
- ///
- ///
- /// If the parameter has a non-numeric
- /// value.
- ///
- ///
- /// If there is no parameter with the
- /// name 'pname' in the parameter list.
- ///
- ///
- public virtual int getIntParameter(System.String pname)
- {
- System.String s = (System.String)getParameter(pname);
-
- if (s == null)
- {
- throw new System.ArgumentException("No parameter with name " + pname);
- }
- else
- {
- try
- {
- return System.Int32.Parse(s);
- }
- catch (System.FormatException e)
- {
- //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Throwable.getMessage' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'"
- throw new System.FormatException("Parameter \"" + pname + "\" is not integer: " + e.Message);
- }
- }
- }
-
- /// Returns the value of the named parameter as a float. If the parameter
- /// has a non-numeric value a NumberFormatException is thrown. If the
- /// parameter has a multiple word value than the first word is returned as
- /// an int, others are ignored. If the parameter 'pname' is not in the
- /// parameter list, an IllegalArgumentException is thrown.
- ///
- ///
- /// The parameter name.
- ///
- ///
- /// If the parameter has a non-numeric
- /// value.
- ///
- ///
- /// If there is no parameter with the
- /// name 'pname' in the parameter list.
- ///
- ///
- /// the value of the parameter as a float.
- ///
- ///
- public virtual float getFloatParameter(System.String pname)
- {
- System.String s = (System.String)getParameter(pname);
-
- if (s == null)
- {
- throw new System.ArgumentException("No parameter with name " + pname);
- }
- else
- {
- try
- {
- // Unfortunately there is no method to convert from a string
- // directly to a float
- //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Float.floatValue' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'"
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- return (float)(System.Single.Parse(s));
- }
- catch (System.FormatException e)
- {
- //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Throwable.getMessage' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'"
- throw new System.FormatException("Parameter \"" + pname + "\" is not floating-point: " + e.Message);
- }
- }
- }
-
- /// Checks if the parameters which name starts with the prefix 'prfx' in
- /// the parameter list are all in the list of valid parameter names
- /// 'plist'. If there is a parameter that is not in 'plist' an
- /// IllegalArgumentException is thrown with an explanation message. The
- /// default parameters are also included in the check.
- ///
- ///
- /// The prefix of parameters to check.
- ///
- ///
- /// The list of valid parameter names for the 'prfx'
- /// prefix. If null it is considered that no names are valid.
- ///
- ///
- /// If there's a parameter name
- /// starting with 'prfx' which is not in the valid list of parameter names.
- ///
- ///
- public virtual void checkList(char prfx, System.String[] plist)
- {
- System.Collections.IEnumerator args;
- System.String val;
- int i;
- bool isvalid;
-
- args = Keys.GetEnumerator();
-
- //UPGRADE_TODO: Method 'java.util.Enumeration.hasMoreElements' was converted to 'System.Collections.IEnumerator.MoveNext' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilEnumerationhasMoreElements'"
- while (args.MoveNext())
- {
- //UPGRADE_TODO: Method 'java.util.Enumeration.nextElement' was converted to 'System.Collections.IEnumerator.Current' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilEnumerationnextElement'"
- val = ((System.String)args.Current);
- if (val.Length > 0 && val[0] == prfx)
- {
- isvalid = false;
- if (plist != null)
- {
- for (i = plist.Length - 1; i >= 0; i--)
- {
- if (val.Equals(plist[i]))
- {
- isvalid = true;
- break;
- }
- }
- }
- if (!isvalid)
- {
- // Did not find valid flag
- throw new System.ArgumentException("Option '" + val + "' is " + "not a valid one.");
- }
- }
- }
- }
-
- /// Checks if the parameters which names do not start with any of the
- /// prefixes in 'prfxs' in this ParameterList are all in the list of valid
- /// parameter names 'plist'. If there is a parameter that is not in 'plist'
- /// an IllegalArgumentException is thrown with an explanation message. The
- /// default parameters are also included in the check.
- ///
- ///
- /// The prefixes of parameters to ignore.
- ///
- ///
- /// The list of valid parameter names. If null it is
- /// considered that no names are valid.
- ///
- ///
- /// If there's a parameter name not
- /// starting with 'prfx' which is not in the valid list of parameter names.
- ///
- ///
- public virtual void checkList(char[] prfxs, System.String[] plist)
- {
- System.Collections.IEnumerator args;
- System.String val, strprfxs;
- int i;
- bool isvalid;
-
- args = Keys.GetEnumerator();
- strprfxs = new System.String(prfxs);
-
- //UPGRADE_TODO: Method 'java.util.Enumeration.hasMoreElements' was converted to 'System.Collections.IEnumerator.MoveNext' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilEnumerationhasMoreElements'"
- while (args.MoveNext())
- {
- //UPGRADE_TODO: Method 'java.util.Enumeration.nextElement' was converted to 'System.Collections.IEnumerator.Current' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilEnumerationnextElement'"
- val = ((System.String)args.Current);
- if (val.Length > 0 && strprfxs.IndexOf((System.Char)val[0]) == -1)
- {
- isvalid = false;
- if (plist != null)
- {
- for (i = plist.Length - 1; i >= 0; i--)
- {
- if (val.Equals(plist[i]))
- {
- isvalid = true;
- break;
- }
- }
- }
- if (!isvalid)
- {
- throw new System.ArgumentException("Option '" + val + "' is " + "not a valid one.");
- }
- }
- }
- }
-
- /// Converts the usage information to a list of parameter names in a single
- /// array. The usage information appears in a 2D array of String. The first
- /// dimensions contains the different options, the second dimension
- /// contains the name of the option (first element), the synopsis and the
- /// explanation. This method takes the names of the different options in
- /// 'pinfo' and returns them in a single array of String.
- ///
- ///
- /// The list of options and their usage info (see above).
- ///
- ///
- /// An array with the names of the options in pinfo. If pinfo is
- /// null, null is returned.
- ///
- ///
- public static System.String[] toNameArray(System.String[][] pinfo)
- {
- System.String[] pnames;
-
- if (pinfo == null)
- {
- return null;
- }
-
- pnames = new System.String[pinfo.Length];
-
- for (int i = pinfo.Length - 1; i >= 0; i--)
- {
- pnames[i] = pinfo[i][0];
- }
- return pnames;
- }
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/util/ProgressWatch.cs b/CSJ2K/j2k/util/ProgressWatch.cs
deleted file mode 100644
index 137024de..00000000
--- a/CSJ2K/j2k/util/ProgressWatch.cs
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
-* CVS identifier:
-*
-* $Id: ProgressWatch.java,v 1.1 2002/05/22 16:19:28 grosbois Exp $
-*
-* Class: ProgressWatch
-*
-* Description: Interface defining methods for ProgressWatch objects.
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-* */
-namespace CSJ2K.j2k.util
-{
-
- public interface ProgressWatch
- {
- /// Initialize the progress watching process
- ///
- ///
- void initProgressWatch(int min, int max, System.String info);
-
- /// Update the progress watching process to the specified value
- ///
- ///
- void updateProgressWatch(int val, System.String info);
-
- /// Terminate the progress watch process
- ///
- ///
- void terminateProgressWatch();
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/util/StreamMsgLogger.cs b/CSJ2K/j2k/util/StreamMsgLogger.cs
deleted file mode 100644
index e793352d..00000000
--- a/CSJ2K/j2k/util/StreamMsgLogger.cs
+++ /dev/null
@@ -1,243 +0,0 @@
-/*
-* CVS identifier:
-*
-* $Id: StreamMsgLogger.java,v 1.11 2000/09/05 09:25:30 grosbois Exp $
-*
-* Class: StreamMsgLogger
-*
-* Description: Implementation of MsgLogger for streams
-*
-*
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-*
-*
-*
-*/
-namespace CSJ2K.j2k.util
-{
-
- /// This class implements the MsgLogger interface for streams. Streams can
- /// be simple files, terminals, stdout, stderr, etc. The messages or simple
- /// strings are formatted using the linewidth given to the constructor.
- ///
- /// Messages are printed to the 'err' stream if they are of severity WARNING
- /// or ERROR, otherwise they are printed to the 'out' stream. Simple strings
- /// are always printed the 'out' stream.
- ///
- ///
- public class StreamMsgLogger : MsgLogger
- {
-
- /// The 'out' stream
- private System.IO.StreamWriter out_Renamed;
-
- /// The 'err' stream
- private System.IO.StreamWriter err;
-
- /// The printer that formats the text
- private MsgPrinter mp;
-
- /// Constructs a StreamMsgLogger that uses 'outstr' as the 'out' stream,
- /// and 'errstr' as the 'err' stream. Note that 'outstr' and 'errstr' can
- /// be System.out and System.err.
- ///
- ///
- /// Where to print simple strings and LOG and INFO messages.
- ///
- ///
- /// Where to print WARNING and ERROR messages
- ///
- ///
- /// The line width to use in formatting
- ///
- ///
- ///
- ///
- public StreamMsgLogger(System.IO.Stream outstr, System.IO.Stream errstr, int lw)
- {
- System.IO.StreamWriter temp_writer;
- temp_writer = new System.IO.StreamWriter(outstr, System.Text.Encoding.Default);
- temp_writer.AutoFlush = true;
- out_Renamed = temp_writer;
- System.IO.StreamWriter temp_writer2;
- temp_writer2 = new System.IO.StreamWriter(errstr, System.Text.Encoding.Default);
- temp_writer2.AutoFlush = true;
- err = temp_writer2;
- mp = new MsgPrinter(lw);
- }
-
- /// Constructs a StreamMsgLogger that uses 'outstr' as the 'out' stream,
- /// and 'errstr' as the 'err' stream. Note that 'outstr' and 'errstr' can
- /// be System.out and System.err.
- ///
- ///
- /// Where to print simple strings and LOG and INFO messages.
- ///
- ///
- /// Where to print WARNING and ERROR messages
- ///
- ///
- /// The line width to use in formatting
- ///
- ///
- ///
- ///
- //UPGRADE_ISSUE: Class hierarchy differences between 'java.io.Writer' and 'System.IO.StreamWriter' may cause compilation errors. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1186'"
- public StreamMsgLogger(System.IO.StreamWriter outstr, System.IO.StreamWriter errstr, int lw)
- {
- System.IO.StreamWriter temp_writer;
- temp_writer = new System.IO.StreamWriter(outstr.BaseStream, outstr.Encoding);
- temp_writer.AutoFlush = true;
- out_Renamed = temp_writer;
- System.IO.StreamWriter temp_writer2;
- temp_writer2 = new System.IO.StreamWriter(errstr.BaseStream, errstr.Encoding);
- temp_writer2.AutoFlush = true;
- err = temp_writer2;
- mp = new MsgPrinter(lw);
- }
-
- /// Constructs a StreamMsgLogger that uses 'outstr' as the 'out' stream,
- /// and 'errstr' as the 'err' stream. Note that 'outstr' and 'errstr' can
- /// be System.out and System.err.
- ///
- ///
- /// Where to print simple strings and LOG and INFO messages.
- ///
- ///
- /// Where to print WARNING and ERROR messages
- ///
- ///
- /// The line width to use in formatting
- ///
- ///
- ///
- ///
- ///
- /*
- public StreamMsgLogger(System.IO.StreamWriter outstr, System.IO.StreamWriter errstr, int lw)
- {
- out_Renamed = outstr;
- err = errstr;
- mp = new MsgPrinter(lw);
- }
- */
- /// Prints the message 'msg' to the output device, appending a newline,
- /// with severity 'sev'. The severity of the message is prepended to the
- /// message.
- ///
- ///
- /// The message severity (LOG, INFO, etc.)
- ///
- ///
- /// The message to display
- ///
- ///
- ///
- ///
- public virtual void printmsg(int sev, System.String msg)
- {
- System.IO.StreamWriter lout;
- //int ind;
- System.String prefix;
-
- switch (sev)
- {
-
- case CSJ2K.j2k.util.MsgLogger_Fields.LOG:
- prefix = "[LOG]: ";
- lout = out_Renamed;
- break;
-
- case CSJ2K.j2k.util.MsgLogger_Fields.INFO:
- prefix = "[INFO]: ";
- lout = out_Renamed;
- break;
-
- case CSJ2K.j2k.util.MsgLogger_Fields.WARNING:
- prefix = "[WARNING]: ";
- lout = err;
- break;
-
- case CSJ2K.j2k.util.MsgLogger_Fields.ERROR:
- prefix = "[ERROR]: ";
- lout = err;
- break;
-
- default:
- throw new System.ArgumentException("Severity " + sev + " not valid.");
-
- }
-
- mp.print(lout, 0, prefix.Length, prefix + msg);
- lout.Flush();
- }
-
- /// Prints the string 'str' to the 'out' stream, appending a newline. The
- /// message is reformatted to the line width given to the constructors and
- /// using 'flind' characters to indent the first line and 'ind' characters
- /// to indent the second line. However, any newlines appearing in 'str' are
- /// respected. The output device may or may not display the string until
- /// flush() is called, depending on the autoflush state of the PrintWriter,
- /// to be sure flush() should be called to write the string to the
- /// device. This method just prints the string, the string does not make
- /// part of a "message" in the sense that noe severity is associated to it.
- ///
- ///
- /// The string to print
- ///
- ///
- /// Indentation of the first line
- ///
- ///
- /// Indentation of any other lines.
- ///
- ///
- ///
- ///
- public virtual void println(System.String str, int flind, int ind)
- {
- mp.print(out_Renamed, flind, ind, str);
- }
-
- /// Writes any buffered data from the print() and println() methods to the
- /// device.
- ///
- ///
- ///
- ///
- public virtual void flush()
- {
- out_Renamed.Flush();
- }
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/util/StringFormatException.cs b/CSJ2K/j2k/util/StringFormatException.cs
deleted file mode 100644
index c09391e1..00000000
--- a/CSJ2K/j2k/util/StringFormatException.cs
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
-* CVS identifier:
-*
-* $Id: StringFormatException.java,v 1.9 2000/09/05 09:25:31 grosbois Exp $
-*
-* Class: ArgumentFormatException
-*
-* Description: Exception for badly formatted string
-* argument exceptions.
-*
-*
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-*
-*
-*
-*/
-using System;
-namespace CSJ2K.j2k.util
-{
-
- /// Thrown to indicate that the application has attempted to parse a
- /// badly formatted string.
- ///
- ///
- [Serializable]
- public class StringFormatException : System.ArgumentException
- {
-
- /// Creates the exception with an empty messgage.
- ///
- ///
- ///
- ///
- public StringFormatException() : base()
- {
- }
-
- /// Creates the exception with the specified detail message.
- ///
- ///
- /// The detail message
- ///
- ///
- ///
- ///
- public StringFormatException(System.String s) : base(s)
- {
- }
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/util/ThreadPool.cs b/CSJ2K/j2k/util/ThreadPool.cs
deleted file mode 100644
index fdcc3602..00000000
--- a/CSJ2K/j2k/util/ThreadPool.cs
+++ /dev/null
@@ -1,647 +0,0 @@
-/*
-* CVS identifier:
-*
-* $Id: ThreadPool.java,v 1.9 2002/05/22 15:00:55 grosbois Exp $
-*
-* Class: ThreadPool
-*
-* Description: A pool of threads
-*
-*
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-* */
-namespace CSJ2K.j2k.util
-{
-
- /// This class implements a thread pool. The thread pool contains a set of
- /// threads which can be given work to do.
- ///
- /// If the Java Virtual Machine (JVM) uses native threads, then the
- /// different threads will be able to execute in different processors in
- /// parallel on multiprocessors machines. However, under some JVMs and
- /// operating systems using native threads is not sufficient to allow the JVM
- /// access to multiple processors. This is the case when native threads are
- /// implemented using POSIX threads on lightweight processes
- /// (i.e. PTHREAD_SCOPE_PROCESS sopce scheduling), which is the case on most
- /// UNIX operating systems. In order to do provide access to multiple
- /// processors it is necessary to set the concurrency level to the number of
- /// processors or slightly higher. This can be achieved by setting the Java
- /// system property with the name defined by CONCURRENCY_PROP_NAME to some
- /// non-negative number. This will make use of the 'NativeServices' class and
- /// supporting native libraries. See 'NativeServices' for details. See
- /// 'CONCURRENCY_PROP_NAME' for the name of the property.
- ///
- ///
Initially the thread pool contains a user specified number of idle
- /// threads. Idle threads can be given a target which is run. While running the
- /// target the thread temporarily leaves the idle list. When the target
- /// finishes, it joins the idle list again, waiting for a new target. When a
- /// target is finished a thread can be notified on a particular object that is
- /// given as a lock.
- ///
- ///
Jobs can be submitted using Runnable interfaces, using the 'runTarget()'
- /// methods. When the job is submitted, an idle thread will be obtained, the
- /// 'run()' method of the 'Runnable' interface will be executed and when it
- /// completes the thread will be returned to the idle list. In general the
- /// 'run()' method should complete in a rather short time, so that the threds
- /// of the pool are not starved.
- ///
- ///
If using the non-asynchronous calls to 'runTarget()', it is important
- /// that any target's 'run()' method, or any method called from it, does not
- /// use non-asynchronous calls to 'runTarget()' on the same thread pool where
- /// it was started. Otherwise this could create a dead-lock when there are not
- /// enough idle threads.
- ///
- ///
The pool also has a global error and runtime exception condition (one
- /// for 'Error' and one for 'RuntimeException'). If a target's 'run()' method
- /// throws an 'Error' or 'RuntimeException' the corresponding exception
- /// condition is set and the exception object saved. In any subsequent call to
- /// 'checkTargetErrors()' the saved exception object is thrown. Likewise, if a
- /// target's 'run()' method throws any other subclass of 'Throwable' a new
- /// 'RuntimeException' is created and saved. It will be thrown on a subsequent
- /// call to 'checkTargetErrors()'. If more than one exception occurs between
- /// calls to 'checkTargetErrors()' only the last one is saved. Any 'Error'
- /// condition has precedence on all 'RuntimeException' conditions. The threads
- /// in the pool are unaffected by any exceptions thrown by targets.
- ///
- ///
The only exception to the above is the 'ThreadDeath' exception. If a
- /// target's 'run()' method throws the 'ThreadDeath' exception a warning
- /// message is printed and the exception is propagated, which will terminate
- /// the thread in which it occurs. This could lead to instabilities of the
- /// pool. The 'ThreadDeath' exception should never be thrown by the program. It
- /// is thrown by the Java(TM) Virtual Machine when Thread.stop() is
- /// called. This method is deprecated and should never be called.
- ///
- ///
All the threads in the pool are "daemon" threads and will automatically
- /// terminate when no daemon threads are running.
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- public class ThreadPool
- {
- /// Returns the size of the pool. That is the number of threads in this
- /// pool (idle + busy).
- ///
- ///
- /// The pool's size.
- ///
- ///
- ///
- virtual public int Size
- {
- get
- {
- return idle.Length;
- }
-
- }
-
- /// The name of the property that sets the concurrency level:
- /// jj2000.j2k.util.ThreadPool.concurrency
- ///
- public const System.String CONCURRENCY_PROP_NAME = "jj2000.j2k.util.ThreadPool.concurrency";
-
- /// The array of idle threads and the lock for the manipulation of the
- /// idle thread list.
- ///
- private ThreadPoolThread[] idle;
-
- /// The number of idle threads
- private int nidle;
-
- /// The name of the pool
- private System.String poolName;
-
- /// The priority for the pool
- private int poolPriority;
-
- /// The last error thrown by a target. Null if none
- // NOTE: needs to be volatile, so that only one copy exits in memory
- private volatile System.ApplicationException targetE;
-
- /// The last runtime exception thrown by a target. Null if none
- // NOTE: needs to be volatile, so that only one copy exits in memory
- private volatile System.SystemException targetRE;
-
- //UPGRADE_NOTE: Field 'EnclosingInstance' was added to class 'ThreadPoolThread' to access its enclosing instance. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1019'"
- /// The threads that are managed by the pool.
- ///
- ///
- internal class ThreadPoolThread : SupportClass.ThreadClass
- {
- private void InitBlock(ThreadPool enclosingInstance)
- {
- this.enclosingInstance = enclosingInstance;
- }
- private ThreadPool enclosingInstance;
- public ThreadPool Enclosing_Instance
- {
- get
- {
- return enclosingInstance;
- }
-
- }
- private IThreadRunnable target;
- private System.Object lock_Renamed;
- private bool doNotifyAll;
-
- /// Creates a ThreadPoolThread object, setting its name according to
- /// the given 'idx', daemon type and the priority to the one of the
- /// pool.
- ///
- ///
- /// The index of this thread in the pool
- ///
- ///
- /// The name of the thread
- ///
- ///
- public ThreadPoolThread(ThreadPool enclosingInstance, int idx, System.String name) : base(name)
- {
- InitBlock(enclosingInstance);
- IsBackground = true;
- //UPGRADE_TODO: The differences in the type of parameters for method 'java.lang.Thread.setPriority' may cause compilation errors. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1092'"
- Priority = (System.Threading.ThreadPriority)Enclosing_Instance.poolPriority;
- }
-
- /// The method that is run by the thread. This method first joins the
- /// idle state in the pool and then enters an infinite loop. In this
- /// loop it waits until a target to run exists and runs it. Once the
- /// target's run() method is done it re-joins the idle state and
- /// notifies the waiting lock object, if one exists.
- ///
- /// An interrupt on this thread has no effect other than forcing a
- /// check on the target. Normally the target is checked every time the
- /// thread is woken up by notify, no interrupts should be done.
- ///
- ///
Any exception thrown by the target's 'run()' method is catched
- /// and this thread is not affected, except for 'ThreadDeath'. If a
- /// 'ThreadDeath' exception is catched a warning message is printed by
- /// the 'FacilityManager' and the exception is propagated up. For
- /// exceptions which are subclasses of 'Error' or 'RuntimeException'
- /// the corresponding error condition is set and this thread is not
- /// affected. For any other exceptions a new 'RuntimeException' is
- /// created and the error condition is set, this thread is not affected.
- ///
- ///
- override public void Run()
- {
- // Join the idle threads list
- Enclosing_Instance.putInIdleList(this);
- // Permanently lock the object while running so that target can
- // not be changed until we are waiting again. While waiting for a
- // target the lock is released.
- lock (this)
- {
- while (true)
- {
- // Wait until we get a target
- while (target == null)
- {
- try
- {
- System.Threading.Monitor.Wait(this);
- }
- catch (System.Threading.ThreadInterruptedException)
- {
- }
- }
- // Run the target and catch all possible errors
- try
- {
- target.Run();
- }
- //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'"
- catch (System.Threading.ThreadAbortException td)
- {
- // We have been instructed to abruptly terminate
- // the thread, which should never be done. This can
- // cause another thread, or the system, to lock.
- FacilityManager.getMsgLogger().printmsg(CSJ2K.j2k.util.MsgLogger_Fields.WARNING, "Thread.stop() called on a ThreadPool " + "thread or ThreadDeath thrown. This is " + "deprecated. Lock-up might occur.");
- throw td;
- }
- catch (System.ApplicationException e)
- {
- Enclosing_Instance.targetE = e;
- }
- catch (System.SystemException re)
- {
- Enclosing_Instance.targetRE = re;
- }
- //UPGRADE_NOTE: Exception 'java.lang.Throwable' was converted to 'System.Exception' which has different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1100'"
- catch (System.Exception)
- {
- // A totally unexpected error has occurred
- // (Thread.stop(Throwable) has been used, which should
- // never be.
- Enclosing_Instance.targetRE = new System.SystemException("Unchecked exception " + "thrown by target's " + "run() method in pool " + Enclosing_Instance.poolName + ".");
- }
- // Join idle threads
- Enclosing_Instance.putInIdleList(this);
- // Release the target and notify lock (i.e. wakeup)
- target = null;
- if (lock_Renamed != null)
- {
- lock (lock_Renamed)
- {
- if (doNotifyAll)
- {
- System.Threading.Monitor.PulseAll(lock_Renamed);
- }
- else
- {
- System.Threading.Monitor.Pulse(lock_Renamed);
- }
- }
- }
- }
- }
- }
-
- /// Assigns a target to this thread, with an optional notify lock and a
- /// notify mode. The another target is currently running the method
- /// will block until it terminates. After setting the new target the
- /// runner thread will be wakenup and execytion will start.
- ///
- ///
- /// The runnable object containing the 'run()' method to
- /// run.
- ///
- ///
- /// An object on which notify will be called once the
- /// target's run method has finished. A thread to be notified should be
- /// waiting on that object. If null no thread is notified.
- ///
- ///
- /// If true 'notifyAll()', instead of 'notify()', will
- /// be called on tghe lock.
- ///
- ///
- //UPGRADE_NOTE: Synchronized keyword was removed from method 'setTarget'. Lock expression was added. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1027'"
- internal virtual void setTarget(IThreadRunnable target, System.Object lock_Renamed, bool notifyAll)
- {
- lock (this)
- {
- // Set the target
- this.target = target;
- this.lock_Renamed = lock_Renamed;
- doNotifyAll = notifyAll;
- // Wakeup the thread
- System.Threading.Monitor.Pulse(this);
- }
- }
- }
-
- /// Creates a new thread pool of the given size, thread priority and pool
- /// name.
- ///
- /// If the Java system property of the name defined by
- /// 'CONCURRENCY_PROP_NAME' is set, then an attempt will be made to load
- /// the library that supports concurrency setting (see
- /// 'NativeServices'). If that succeds the concurrency level will be set to
- /// the specified value. Otherwise a warning is printed.
- ///
- ///
- /// The size of the pool (number of threads to create in the
- /// pool).
- ///
- ///
- /// The priority to give to the threads in the pool. If
- /// less than 'Thread.MIN_PRIORITY' it will be the same as the priority of
- /// the calling thread.
- ///
- ///
- /// The name of the pool. If null a default generic name is
- /// chosen.
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- public ThreadPool(int size, int priority, System.String name)
- {
- int i;
- ThreadPoolThread t;
- //System.String prop;
- //int clevel;
-
- // Initialize variables checking for special cases
- if (size <= 0)
- {
- throw new System.ArgumentException("Pool must be of positive size");
- }
- if (priority < (int)System.Threading.ThreadPriority.Lowest)
- {
- poolPriority = (System.Int32)SupportClass.ThreadClass.Current().Priority;
- }
- else
- {
- poolPriority = (priority < (int)System.Threading.ThreadPriority.Highest) ? priority : (int)System.Threading.ThreadPriority.Highest;
- }
- if (name == null)
- {
- poolName = "Anonymous ThreadPool";
- }
- else
- {
- poolName = name;
- }
-
- // Allocate internal variables
- idle = new ThreadPoolThread[size];
- nidle = 0;
-
- // Create and start the threads
- for (i = 0; i < size; i++)
- {
- t = new ThreadPoolThread(this, i, poolName + "-" + i);
- t.Start();
- }
- }
-
- /// Runs the run method of the specified target in an idle thread of this
- /// pool. When the target's run method completes, the thread waiting on the
- /// lock object is notified, if any. If there is currently no idle thread
- /// the method will block until a thread of the pool becomes idle or the
- /// calling thread is interrupted.
- ///
- /// This method is the same as runTarget(t,l,true,false).
- ///
- ///
- /// The target. The 'run()' method of this object will be run in
- /// an idle thread of the pool.
- ///
- ///
- /// The lock object. A thread waiting on the lock of the 'l'
- /// object will be notified, through the 'notify()' call, when the target's
- /// run method completes. If null no thread is notified.
- ///
- ///
- /// True if the target was submitted to some thread. False if no
- /// idle thread could be found and the target was not submitted for
- /// execution.
- ///
- ///
- ///
- public virtual bool runTarget(IThreadRunnable t, System.Object l)
- {
- return runTarget(t, l, false, false);
- }
-
- /// Runs the run method of the specified target in an idle thread of this
- /// pool. When the target's run method completes, the thread waiting on the
- /// lock object is notified, if any. If there is currently no idle thread
- /// and the asynchronous mode is not used the method will block until a
- /// thread of the pool becomes idle or the calling thread is
- /// interrupted. If the asynchronous mode is used then the method will not
- /// block and will return false.
- ///
- /// This method is the same as runTarget(t,l,async,false).
- ///
- ///
- /// The target. The 'run()' method of this object will be run in
- /// an idle thread of the pool.
- ///
- ///
- /// The lock object. A thread waiting on the lock of the 'l'
- /// object will be notified, through the 'notify()' call, when the target's
- /// run method completes. If null no thread is notified.
- ///
- ///
- /// If true the asynchronous mode will be used.
- ///
- ///
- /// True if the target was submitted to some thread. False if no
- /// idle thread could be found and the target was not submitted for
- /// execution.
- ///
- ///
- ///
- public virtual bool runTarget(IThreadRunnable t, System.Object l, bool async)
- {
- return runTarget(t, l, async, false);
- }
-
- /// Runs the run method of the specified target in an idle thread of this
- /// pool. When the target's run method completes, the thread waiting on the
- /// lock object is notified, if any. If there is currently no idle thread
- /// and the asynchronous mode is not used the method will block until a
- /// thread of the pool becomes idle or the calling thread is
- /// interrupted. If the asynchronous mode is used then the method will not
- /// block and will return false.
- ///
- ///
- /// The target. The 'run()' method of this object will be run in
- /// an idle thread of the pool.
- ///
- ///
- /// The lock object. A thread waiting on the lock of the 'l'
- /// object will be notified, through the 'notify()' call, when the target's
- /// run method completes. If null no thread is notified.
- ///
- ///
- /// If true the asynchronous mode will be used.
- ///
- ///
- /// If true, threads waiting on the lock of the 'l' object
- /// will be notified trough the 'notifyAll()' instead of the normal
- /// 'notify()' call. This is not normally needed.
- ///
- ///
- /// True if the target was submitted to some thread. False if no
- /// idle thread could be found and the target was not submitted for
- /// execution.
- ///
- ///
- ///
- public virtual bool runTarget(IThreadRunnable t, System.Object l, bool async, bool notifyAll)
- {
- ThreadPoolThread runner; // The thread to run the target
-
- // Get a thread to run
- runner = getIdle(async);
- // If no runner return failure
- if (runner == null)
- return false;
- // Set the runner
- runner.setTarget(t, l, notifyAll);
- return true;
- }
-
- /// Checks that no error or runtime exception in any target have occurred
- /// so far. If an error or runtime exception has occurred in a target's run
- /// method they are thrown by this method.
- ///
- ///
- /// If an error condition has been thrown by a target
- /// 'run()' method.
- ///
- ///
- /// If a runtime exception has been thrown by a
- /// target 'run()' method.
- ///
- ///
- public virtual void checkTargetErrors()
- {
- // Check for Error
- if (targetE != null)
- throw targetE;
- // Check for RuntimeException
- if (targetRE != null)
- throw targetRE;
- }
-
- /// Clears the current target error conditions, if any. Note that a thread
- /// in the pool might have set the error conditions since the last check
- /// and that those error conditions will be lost. Likewise, before
- /// returning from this method another thread might set the error
- /// conditions. There is no guarantee that no error conditions exist when
- /// returning from this method.
- ///
- /// In order to ensure that no error conditions exist when returning
- /// from this method cooperation from the targets and the thread using this
- /// pool is necessary (i.e. currently no targets running or waiting to
- /// run).
- ///
- ///
- public virtual void clearTargetErrors()
- {
- // Clear the error and runtime exception conditions
- targetE = null;
- targetRE = null;
- }
-
- /// Puts the thread 't' in the idle list. The thread 't' should be in fact
- /// idle and ready to accept a new target when it joins the idle list.
- ///
- /// An idle thread that is already in the list should never add itself
- /// to the list before it is removed. For efficiency reasons there is no
- /// check to see if the thread is already in the list of idle threads.
- ///
- ///
If the idle list was empty 'notify()' will be called on the 'idle'
- /// array, to wake up a thread that might be waiting (within the
- /// 'getIdle()' method) on an idle thread to become available.
- ///
- ///
- /// The thread to put in the idle list.
- ///
- ///
- private void putInIdleList(ThreadPoolThread t)
- {
- // NOTE: if already in idle => catastrophe! (should be OK since //
- // this is private method)
- // Lock the idle array to avoid races with 'getIdle()'
- lock (idle)
- {
- idle[nidle] = t;
- nidle++;
- // If idle array was empty wakeup any waiting threads.
- if (nidle == 1)
- System.Threading.Monitor.Pulse(idle);
- }
- }
-
- /// Returns and idle thread and removes it from the list of idle
- /// threads. In asynchronous mode it will immediately return an idle
- /// thread, or null if none is available. In non-asynchronous mode it will
- /// block until a thread of the pool becomes idle or the calling thread is
- /// interrupted.
- ///
- /// If in non-asynchronous mode and there are currently no idle threads
- /// available the calling thread will wait on the 'idle' array lock, until
- /// notified by 'putInIdleList()' that an idle thread might have become
- /// available.
- ///
- ///
- /// If true asynchronous mode is used.
- ///
- ///
- /// An idle thread of the pool, that has been removed from the idle
- /// list, or null if none is available.
- ///
- ///
- private ThreadPoolThread getIdle(bool async)
- {
- // Lock the idle array to avoid races with 'putInIdleList()'
- lock (idle)
- {
- if (async)
- {
- // In asynchronous mode just return null if no idle thread
- if (nidle == 0)
- return null;
- }
- else
- {
- // In synchronous mode wait until a thread becomes idle
- while (nidle == 0)
- {
- try
- {
- System.Threading.Monitor.Wait(idle);
- }
- catch (System.Threading.ThreadInterruptedException)
- {
- // If we were interrupted just return null
- return null;
- }
- }
- }
- // Decrease the idle count and return one of the idle threads
- nidle--;
- return idle[nidle];
- }
- }
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/wavelet/FilterTypes.cs b/CSJ2K/j2k/wavelet/FilterTypes.cs
deleted file mode 100644
index cb6a1323..00000000
--- a/CSJ2K/j2k/wavelet/FilterTypes.cs
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
-* CVS identifier:
-*
-* $Id: FilterTypes.java,v 1.12 2001/05/08 16:14:28 grosbois Exp $
-*
-* Class: FilterTypes
-*
-* Description: Defines the interface for Filter types
-*
-*
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-* */
-namespace CSJ2K.j2k.wavelet
-{
-
- /// This interface defines the identifiers for the different types of filters
- /// that are supported.
- ///
- /// The identifier values are the same as those used in the codestream
- /// syntax, for the filters that are defined in the standard.
- ///
- ///
- public struct FilterTypes_Fields
- {
- /// W7x9 filter: 0x00
- public const int W9X7 = 0;
- /// W5x3 filter: 0x01
- public const int W5X3 = 1;
- /// User-defined filter: -1
- public const int CUSTOM = -1;
- }
- public interface FilterTypes
- {
- //UPGRADE_NOTE: Members of interface 'FilterTypes' were extracted into structure 'FilterTypes_Fields'. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1045'"
-
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/wavelet/Subband.cs b/CSJ2K/j2k/wavelet/Subband.cs
deleted file mode 100644
index d859b300..00000000
--- a/CSJ2K/j2k/wavelet/Subband.cs
+++ /dev/null
@@ -1,642 +0,0 @@
-/*
-* CVS identifier:
-*
-* $Id: Subband.java,v 1.47 2001/10/18 14:27:14 grosbois Exp $
-*
-* Class: Subband
-*
-* Description: Asbtract element for a tree strcuture for
-* a description of subbands.
-*
-*
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-* */
-using CSJ2K.j2k.image;
-namespace CSJ2K.j2k.wavelet
-{
-
- /// This abstract class represents a subband in a bidirectional tree structure
- /// that describes the subband decomposition for a wavelet transform. This
- /// class is implemented by the SubbandAn and SubbandSyn classes, which are for
- /// the analysis and synthesis sides respectively.
- ///
- /// The element can be either a node or a leaf of the tree. If it is a node,
- /// it has 4 descendants (LL, HL, LH and HH). If it is a leaf, it has no
- /// descendant.
- ///
- /// The tree is bidirectional. Each element in the tree structure has a
- /// "parent", which is the subband from which the element was obtained by
- /// decomposition. The only exception is the root element which, for obvious
- /// reasons, has no parent (i.e. it is null).
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- public abstract class Subband
- {
- /// Returns the parent of this subband. The parent of a subband is the
- /// subband from which this one was obtained by decomposition. The root
- /// element has no parent subband (null).
- ///
- ///
- /// The parent subband, or null for the root one.
- ///
- ///
- public abstract Subband Parent { get; }
- /// Returns the LL child subband of this subband.
- ///
- ///
- /// The LL child subband, or null if there are no childs.
- ///
- ///
- public abstract Subband LL { get; }
- /// Returns the HL (horizontal high-pass) child subband of this subband.
- ///
- ///
- /// The HL child subband, or null if there are no childs.
- ///
- ///
- public abstract Subband HL { get; }
- /// Returns the LH (vertical high-pass) child subband of this subband.
- ///
- ///
- /// The LH child subband, or null if there are no childs.
- ///
- ///
- public abstract Subband LH { get; }
- /// Returns the HH child subband of this subband.
- ///
- ///
- /// The HH child subband, or null if there are no childs.
- ///
- ///
- public abstract Subband HH { get; }
- /// Returns the first leaf subband element in the next higher resolution
- /// level.
- ///
- ///
- /// The first leaf element in the next higher resolution level, or
- /// null if there is no higher resolution level.
- ///
- ///
- virtual public Subband NextResLevel
- {
- get
- {
- Subband sb;
-
- if (level == 0)
- {
- // No higher res. level
- return null;
- }
- // Go up until we get to a different resolution level
- sb = this;
- do
- {
- sb = sb.Parent;
- if (sb == null)
- {
- // No higher resolution level
- return null;
- }
- }
- while (sb.resLvl == resLvl);
- // Now go down to HL, which is in next higher resolution level
- sb = sb.HL;
- // Now go down LL until get to a leaf
- while (sb.isNode)
- {
- sb = sb.LL;
- }
- return sb;
- }
-
- }
- /// This function returns the horizontal wavelet filter relevant to this
- /// subband
- ///
- ///
- /// The horizontal wavelet filter
- ///
- ///
- public abstract WaveletFilter HorWFilter { get; }
- /// This function returns the vertical wavelet filter relevant to this
- /// subband
- ///
- ///
- /// The vertical wavelet filter
- ///
- ///
- public abstract WaveletFilter VerWFilter { get; }
-
- /// The ID for the LL orientation
- public const int WT_ORIENT_LL = 0;
-
- /// The ID for the HL (horizontal high-pass) orientation
- public const int WT_ORIENT_HL = 1;
-
- /// The ID for the LH (vertical high-pass) orientation
- public const int WT_ORIENT_LH = 2;
-
- /// The ID for the HH orientation
- public const int WT_ORIENT_HH = 3;
-
- /// True if it is a node in the tree, false if it is a leaf.
- public bool isNode;
-
- /// The orientation of this subband (WT_ORIENT_LL, WT_ORIENT_HL,
- /// WT_ORIENT_LH, WT_ORIENT_HH).
- ///
- public int orientation;
-
- /// The level in the tree to which this subband belongs, which is the
- /// number of performed wavelet decompositions to get this subband. It is 0
- /// for the top-level (i.e. root) node.
- ///
- public int level;
-
- /// The resolution level to which this subband contributes. 0 is the
- /// smallest resolution level (the one with the lowest frequency LL
- /// subband).
- ///
- public int resLvl;
-
- /// The number of code-blocks (in both directions) contained in this
- /// subband.
- ///
- public Coord numCb = null;
-
- /// The base 2 exponent of the analysis gain of the subband. The analysis
- /// gain of a subband is defined as the gain of the previous subband
- /// (i.e. the one from which this one was obtained) multiplied by the line
- /// gain and by the column gain. The line (column) gain is the gain of the
- /// line (column) filter that was used to obtain it, which is the DC gain
- /// for a low-pass filter and the Nyquist gain for a high-pass filter. It
- /// is 0 by default.
- ///
- /// Using the base 2 exponent of the value contrains the possible gains
- /// to powers of 2. However this is perfectly compatible to the filter
- /// normalization policy assumed here. See the split() method for more
- /// details.
- ///
- ///
- ///
- ///
- ///
- public int anGainExp;
-
- /// The subband index within its resolution level. This value uniquely
- /// identifies a subband within a resolution level and a decomposition
- /// level within it. Note that only leaf elements represent "real"
- /// subbands, while node elements represent only intermediate stages.
- ///
- /// It is defined recursively. The root node gets a value of 0. For a
- /// given node, with a subband index 'b', its LL descendant gets 4*b, its
- /// HL descendant 4*b+1, its LH descendant 4*b+2, and its HH descendant
- /// 4*b+3, for their subband indexes.
- ///
- ///
- public int sbandIdx = 0;
-
- /// The horizontal coordinate of the upper-left corner of the subband, with
- /// respect to the canvas origin, in the component's grid and subband's
- /// decomposition level. This is the real horizontal index of the first
- /// column of this subband. If even the horizontal decomposition of this
- /// subband should be done with the low-pass-first convention. If odd it
- /// should be done with the high-pass-first convention.
- ///
- ///
- public int ulcx;
-
- /// The vertical coordinate of the upper-left corner of the subband, with
- /// respect to the canvas origin, in the component's grid and subband's
- /// decomposition level. This is the real vertical index of the first
- /// column of this subband. If even the vertical decomposition of this
- /// subband should be done with the low-pass-first convention. If odd it
- /// should be done with the high-pass-first convention.
- ///
- ///
- public int ulcy;
-
- /// The horizontal coordinate of the upper-left corner of the subband
- public int ulx;
-
- /// The vertical coordinate of the upper-left corner of the subband
- public int uly;
-
- /// The width of the subband
- public int w;
-
- /// The height of the subband
- public int h;
-
- /// The nominal code-block width
- public int nomCBlkW;
-
- /// The nominal code-block height
- public int nomCBlkH;
-
- /// Splits the current subband in its four subbands. This creates the four
- /// childs (LL, HL, LH and HH) and converts the leaf in a node.
- ///
- ///
- /// The horizontal wavelet filter used to decompose this
- /// subband.
- ///
- ///
- /// The vertical wavelet filter used to decompose this
- /// subband.
- ///
- ///
- /// A reference to the LL leaf (getLL()).
- ///
- ///
- protected internal abstract Subband split(WaveletFilter hfilter, WaveletFilter vfilter);
-
- /// Initializes the childs of this node with the correct values. The sizes
- /// of the child subbands are calculated by taking into account the
- /// position of the subband in the canvas.
- ///
- /// For the analysis subband gain calculation it is assumed that
- /// analysis filters are normalized with a DC gain of 1 and a Nyquist gain
- /// of 2.
- ///
- ///
- protected internal virtual void initChilds()
- {
- Subband subb_LL = LL;
- Subband subb_HL = HL;
- Subband subb_LH = LH;
- Subband subb_HH = HH;
-
- // LL subband
- subb_LL.level = level + 1;
- subb_LL.ulcx = (ulcx + 1) >> 1;
- subb_LL.ulcy = (ulcy + 1) >> 1;
- subb_LL.ulx = ulx;
- subb_LL.uly = uly;
- subb_LL.w = ((ulcx + w + 1) >> 1) - subb_LL.ulcx;
- subb_LL.h = ((ulcy + h + 1) >> 1) - subb_LL.ulcy;
- // If this subband in in the all LL path (i.e. it's global orientation
- // is LL) then child LL band contributes to a lower resolution level.
- subb_LL.resLvl = (orientation == WT_ORIENT_LL) ? resLvl - 1 : resLvl;
- subb_LL.anGainExp = anGainExp;
- subb_LL.sbandIdx = (sbandIdx << 2);
- // HL subband
- subb_HL.orientation = WT_ORIENT_HL;
- subb_HL.level = subb_LL.level;
- subb_HL.ulcx = ulcx >> 1;
- subb_HL.ulcy = subb_LL.ulcy;
- subb_HL.ulx = ulx + subb_LL.w;
- subb_HL.uly = uly;
- subb_HL.w = ((ulcx + w) >> 1) - subb_HL.ulcx;
- subb_HL.h = subb_LL.h;
- subb_HL.resLvl = resLvl;
- subb_HL.anGainExp = anGainExp + 1;
- subb_HL.sbandIdx = (sbandIdx << 2) + 1;
- // LH subband
- subb_LH.orientation = WT_ORIENT_LH;
- subb_LH.level = subb_LL.level;
- subb_LH.ulcx = subb_LL.ulcx;
- subb_LH.ulcy = ulcy >> 1;
- subb_LH.ulx = ulx;
- subb_LH.uly = uly + subb_LL.h;
- subb_LH.w = subb_LL.w;
- subb_LH.h = ((ulcy + h) >> 1) - subb_LH.ulcy;
- subb_LH.resLvl = resLvl;
- subb_LH.anGainExp = anGainExp + 1;
- subb_LH.sbandIdx = (sbandIdx << 2) + 2;
- // HH subband
- subb_HH.orientation = WT_ORIENT_HH;
- subb_HH.level = subb_LL.level;
- subb_HH.ulcx = subb_HL.ulcx;
- subb_HH.ulcy = subb_LH.ulcy;
- subb_HH.ulx = subb_HL.ulx;
- subb_HH.uly = subb_LH.uly;
- subb_HH.w = subb_HL.w;
- subb_HH.h = subb_LH.h;
- subb_HH.resLvl = resLvl;
- subb_HH.anGainExp = anGainExp + 2;
- subb_HH.sbandIdx = (sbandIdx << 2) + 3;
- }
-
- /// Creates a Subband element with all the default values. The dimensions
- /// are (0,0), the upper left corner is (0,0) and the upper-left corner
- /// with respect to the canvas is (0,0) too.
- ///
- ///
- public Subband()
- {
- }
-
- /// Creates the top-level node and the entire subband tree, with the
- /// top-level dimensions, the number of decompositions, and the
- /// decomposition tree as specified.
- ///
- /// For the analysis subband gain calculation it is assumed that
- /// analysis filters are normalized with a DC gain of 1 and a Nyquist gain
- /// of 2.
- ///
- /// This constructor does not initialize the value of the magBits member
- /// variable. This variable is normally initialized by the quantizer, on
- /// the encoder side, or the bit stream reader, on the decoder side.
- ///
- ///
- /// The top-level width
- ///
- ///
- /// The top-level height
- ///
- ///
- /// The horizontal coordinate of the upper-left corner with
- /// respect to the canvas origin, in the component grid.
- ///
- ///
- /// The vertical coordinate of the upper-left corner with
- /// respect to the canvas origin, in the component grid.
- ///
- ///
- /// The number of levels (or LL decompositions) in the tree.
- ///
- ///
- /// The horizontal wavelet filters (analysis or synthesis)
- /// for each resolution level, starting at resolution level 0. If there are
- /// less elements in the array than there are resolution levels, the last
- /// element is used for the remaining resolution levels.
- ///
- ///
- /// The vertical wavelet filters (analysis or synthesis)
- /// for each resolution level, starting at resolution level 0. If there are
- /// less elements in the array than there are resolution levels, the last
- /// element is used for the remaining resolution levels.
- ///
- ///
- ///
- ///
- ///
- public Subband(int w, int h, int ulcx, int ulcy, int lvls, WaveletFilter[] hfilters, WaveletFilter[] vfilters)
- {
- int i, hi, vi;
- Subband cur; // The current subband
-
- // Initialize top-level node
- this.w = w;
- this.h = h;
- this.ulcx = ulcx;
- this.ulcy = ulcy;
- this.resLvl = lvls;
- // First create dyadic decomposition.
- cur = this;
- for (i = 0; i < lvls; i++)
- {
- hi = (cur.resLvl <= hfilters.Length) ? cur.resLvl - 1 : hfilters.Length - 1;
- vi = (cur.resLvl <= vfilters.Length) ? cur.resLvl - 1 : vfilters.Length - 1;
- cur = cur.split(hfilters[hi], vfilters[vi]);
- }
- }
-
- /// Returns the next subband in the same resolution level, following the
- /// subband index order. If already at the last subband then null is
- /// returned. If this subband is not a leaf an IllegalArgumentException is
- /// thrown.
- ///
- ///
- /// The next subband in the same resolution level, following the
- /// subband index order, or null if already at last subband.
- ///
- ///
- public virtual Subband nextSubband()
- {
- Subband sb;
-
- if (isNode)
- {
- throw new System.ArgumentException();
- }
-
- switch (orientation)
- {
-
- case WT_ORIENT_LL:
- sb = Parent;
- if (sb == null || sb.resLvl != resLvl)
- {
- // Already at top-level or last subband in res. level
- return null;
- }
- else
- {
- return sb.HL;
- }
- //goto case WT_ORIENT_HL;
-
- case WT_ORIENT_HL:
- return Parent.LH;
-
- case WT_ORIENT_LH:
- return Parent.HH;
-
- case WT_ORIENT_HH:
- // This is the complicated one
- sb = this;
- while (sb.orientation == WT_ORIENT_HH)
- {
- sb = sb.Parent;
- }
- switch (sb.orientation)
- {
-
- case WT_ORIENT_LL:
- sb = sb.Parent;
- if (sb == null || sb.resLvl != resLvl)
- {
- // Already at top-level or last subband in res. level
- return null;
- }
- else
- {
- sb = sb.HL;
- }
- break;
-
- case WT_ORIENT_HL:
- sb = sb.Parent.LH;
- break;
-
- case WT_ORIENT_LH:
- sb = sb.Parent.HH;
- break;
-
- default:
- throw new System.ApplicationException("You have found a bug in JJ2000");
-
- }
- while (sb.isNode)
- {
- sb = sb.LL;
- }
- return sb;
-
- default:
- throw new System.ApplicationException("You have found a bug in JJ2000");
-
- }
- }
-
- /// Returns a subband element in the tree, given its resolution level and
- /// subband index. This method searches through the tree.
- ///
- ///
- /// The resolution level.
- ///
- ///
- /// The subband index, within the resolution level.
- ///
- ///
- public virtual Subband getSubbandByIdx(int rl, int sbi)
- {
- Subband sb = this;
-
- // Find the root subband for the resolution level
- if (rl > sb.resLvl || rl < 0)
- {
- throw new System.ArgumentException("Resolution level index " + "out of range");
- }
-
- // Returns directly if it is itself
- if (rl == sb.resLvl && sbi == sb.sbandIdx)
- return sb;
-
- if (sb.sbandIdx != 0)
- sb = sb.Parent;
-
- while (sb.resLvl > rl)
- sb = sb.LL;
- while (sb.resLvl < rl)
- sb = sb.Parent;
-
- switch (sbi)
- {
-
- case 0:
- default:
- return sb;
-
- case 1:
- return sb.HL;
-
- case 2:
- return sb.LH;
-
- case 3:
- return sb.HH;
- }
- }
-
- /// Returns a reference to the Subband element to which the specified point
- /// belongs. The specified point must be inside this (i.e. the one defined
- /// by this object) subband. This method searches through the tree.
- ///
- ///
- /// horizontal coordinate of the specified point.
- ///
- ///
- /// horizontal coordinate of the specified point.
- ///
- ///
- public virtual Subband getSubband(int x, int y)
- {
- Subband cur, hhs;
-
- // Check that we are inside this subband
- if (x < ulx || y < uly || x >= ulx + w || y >= uly + h)
- {
- throw new System.ArgumentException();
- }
-
- cur = this;
- while (cur.isNode)
- {
- hhs = cur.HH;
- // While we are still at a node -> continue
- if (x < hhs.ulx)
- {
- // Is the result of horizontal low-pass
- if (y < hhs.uly)
- {
- // Vertical low-pass
- cur = cur.LL;
- }
- else
- {
- // Vertical high-pass
- cur = cur.LH;
- }
- }
- else
- {
- // Is the result of horizontal high-pass
- if (y < hhs.uly)
- {
- // Vertical low-pass
- cur = cur.HL;
- }
- else
- {
- // Vertical high-pass
- cur = cur.HH;
- }
- }
- }
-
- return cur;
- }
-
- /// Returns subband informations in a string.
- ///
- ///
- /// Subband informations
- ///
- ///
- public override System.String ToString()
- {
- System.String string_Renamed = "w=" + w + ",h=" + h + ",ulx=" + ulx + ",uly=" + uly + ",ulcx=" + ulcx + ",ulcy=" + ulcy + ",idx=" + sbandIdx + ",orient=" + orientation + ",node=" + isNode + ",level=" + level + ",resLvl=" + resLvl + ",nomCBlkW=" + nomCBlkW + ",nomCBlkH=" + nomCBlkH + ",numCb=" + numCb;
-
- return string_Renamed;
- }
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/wavelet/WTDecompSpec.cs b/CSJ2K/j2k/wavelet/WTDecompSpec.cs
deleted file mode 100644
index dd7aaff4..00000000
--- a/CSJ2K/j2k/wavelet/WTDecompSpec.cs
+++ /dev/null
@@ -1,320 +0,0 @@
-/*
-* CVS identifier:
-*
-* $Id: WTDecompSpec.java,v 1.9 2000/09/05 09:26:06 grosbois Exp $
-*
-* Class: WTDecompSpec
-*
-* Description:
-*
-*
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-*
-*
-*
-*/
-using System;
-namespace CSJ2K.j2k.wavelet
-{
-
- /// This class holds the decomposition type to be used in each part of the
- /// image; the default one, the component specific ones, the tile default ones
- /// and the component-tile specific ones.
- ///
- /// The decomposition type identifiers values are the same as in the
- /// codestream.
- ///
- ///
The hierarchy is:
- /// - Tile and component specific decomposition
- /// - Tile specific default decomposition
- /// - Component main default decomposition
- /// - Main default decomposition
- ///
- ///
At the moment tiles are not supported by this class.
- ///
- ///
- public class WTDecompSpec
- {
- /// Returns the main default decomposition type.
- ///
- ///
- /// The main default decomposition type.
- ///
- ///
- ///
- ///
- virtual public int MainDefDecompType
- {
- get
- {
- return mainDefDecompType;
- }
-
- }
- /// Returns the main default decomposition number of levels.
- ///
- ///
- /// The main default decomposition number of levels.
- ///
- ///
- ///
- ///
- virtual public int MainDefLevels
- {
- get
- {
- return mainDefLevels;
- }
-
- }
- /// ID for the dyadic wavelet tree decomposition (also called
- /// "Mallat" in JPEG 2000): 0x00.
- ///
- public const int WT_DECOMP_DYADIC = 0;
-
- /// ID for the SPACL (as defined in JPEG 2000) wavelet tree
- /// decomposition (1 level of decomposition in the high bands and
- /// some specified number for the lowest LL band): 0x02.
- ///
- public const int WT_DECOMP_SPACL = 2;
-
- /// ID for the PACKET (as defined in JPEG 2000) wavelet tree
- /// decomposition (2 levels of decomposition in the high bands and
- /// some specified number for the lowest LL band): 0x01.
- ///
- public const int WT_DECOMP_PACKET = 1;
-
- /// The identifier for "main default" specified decomposition
- public const byte DEC_SPEC_MAIN_DEF = 0;
-
- /// The identifier for "component default" specified decomposition
- public const byte DEC_SPEC_COMP_DEF = 1;
-
- /// The identifier for "tile specific default" specified decomposition
- public const byte DEC_SPEC_TILE_DEF = 2;
-
- /// The identifier for "tile and component specific" specified
- /// decomposition
- ///
- public const byte DEC_SPEC_TILE_COMP = 3;
-
- /// The spec type for each tile and component. The first index is the
- /// component index, the second is the tile index. NOTE: The tile specific
- /// things are not supported yet.
- ///
- // Use byte to save memory (no need for speed here).
- private byte[] specValType;
-
- /// The main default decomposition
- private int mainDefDecompType;
-
- /// The main default number of decomposition levels
- private int mainDefLevels;
-
- /// The component main default decomposition, for each component.
- private int[] compMainDefDecompType;
-
- /// The component main default decomposition levels, for each component
- private int[] compMainDefLevels;
-
- /// Constructs a new 'WTDecompSpec' for the specified number of components
- /// and tiles, with the given main default decomposition type and number of
- /// levels.
- ///
- /// NOTE: The tile specific things are not supported yet
- ///
- ///
- /// The number of components
- ///
- ///
- /// The number of tiles
- ///
- ///
- /// The main default decomposition type
- ///
- ///
- /// The main default number of decomposition levels
- ///
- ///
- ///
- ///
- public WTDecompSpec(int nc, int dec, int lev)
- {
- mainDefDecompType = dec;
- mainDefLevels = lev;
- specValType = new byte[nc];
- }
-
- /// Sets the "component main default" decomposition type and number of
- /// levels for the specified component. Both 'dec' and 'lev' can not be
- /// negative at the same time.
- ///
- ///
- /// The component index
- ///
- ///
- /// The decomposition type. If negative then the main default is
- /// used.
- ///
- ///
- /// The number of levels. If negative then the main defaul is
- /// used.
- ///
- ///
- ///
- ///
- public virtual void setMainCompDefDecompType(int n, int dec, int lev)
- {
- if (dec < 0 && lev < 0)
- {
- throw new System.ArgumentException();
- }
- // Set spec type and decomp
- specValType[n] = DEC_SPEC_COMP_DEF;
- if (compMainDefDecompType == null)
- {
- compMainDefDecompType = new int[specValType.Length];
- compMainDefLevels = new int[specValType.Length];
- }
- compMainDefDecompType[n] = (dec >= 0) ? dec : mainDefDecompType;
- compMainDefLevels[n] = (lev >= 0) ? lev : mainDefLevels;
- // For the moment disable it since other parts of JJ2000 do not
- // support this
- throw new NotImplementedException("Currently, in JJ2000, all components " + "and tiles must have the same " + "decomposition type and number of " + "levels");
- }
-
- /// Returns the type of specification for the decomposition in the
- /// specified component and tile. The specification type is one of:
- /// 'DEC_SPEC_MAIN_DEF', 'DEC_SPEC_COMP_DEF', 'DEC_SPEC_TILE_DEF',
- /// 'DEC_SPEC_TILE_COMP'.
- ///
- /// NOTE: The tile specific things are not supported yet
- ///
- ///
- /// The component index
- ///
- ///
- /// The tile index, in raster scan order.
- ///
- ///
- /// The specification type for component 'n' and tile 't'.
- ///
- ///
- ///
- ///
- public virtual byte getDecSpecType(int n)
- {
- return specValType[n];
- }
-
- /// Returns the decomposition type to be used in component 'n' and tile
- /// 't'.
- ///
- /// NOTE: The tile specific things are not supported yet
- ///
- ///
- /// The component index.
- ///
- ///
- /// The tile index, in raster scan order
- ///
- ///
- /// The decomposition type to be used.
- ///
- ///
- ///
- ///
- public virtual int getDecompType(int n)
- {
- switch (specValType[n])
- {
-
- case DEC_SPEC_MAIN_DEF:
- return mainDefDecompType;
-
- case DEC_SPEC_COMP_DEF:
- return compMainDefDecompType[n];
-
- case DEC_SPEC_TILE_DEF:
- throw new NotImplementedException();
-
- case DEC_SPEC_TILE_COMP:
- throw new NotImplementedException();
-
- default:
- throw new System.ApplicationException("Internal JJ2000 error");
-
- }
- }
-
- /// Returns the decomposition number of levels in component 'n' and tile
- /// 't'.
- ///
- /// NOTE: The tile specific things are not supported yet
- ///
- ///
- /// The component index.
- ///
- ///
- /// The tile index, in raster scan order
- ///
- ///
- /// The decomposition number of levels.
- ///
- ///
- ///
- ///
- public virtual int getLevels(int n)
- {
- switch (specValType[n])
- {
-
- case DEC_SPEC_MAIN_DEF:
- return mainDefLevels;
-
- case DEC_SPEC_COMP_DEF:
- return compMainDefLevels[n];
-
- case DEC_SPEC_TILE_DEF:
- throw new NotImplementedException();
-
- case DEC_SPEC_TILE_COMP:
- throw new NotImplementedException();
-
- default:
- throw new System.ApplicationException("Internal JJ2000 error");
-
- }
- }
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/wavelet/WTFilterSpec.cs b/CSJ2K/j2k/wavelet/WTFilterSpec.cs
deleted file mode 100644
index 339a20ba..00000000
--- a/CSJ2K/j2k/wavelet/WTFilterSpec.cs
+++ /dev/null
@@ -1,149 +0,0 @@
-/*
-* CVS identifier:
-*
-* $Id: WTFilterSpec.java,v 1.10 2000/09/05 09:26:08 grosbois Exp $
-*
-* Class: WTFilterSpec
-*
-* Description: Generic class for storing wavelet filter specs
-*
-*
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-*
-*
-*
-*/
-namespace CSJ2K.j2k.wavelet
-{
-
- /// This is the generic class from which the ones that hold the analysis or
- /// synthesis filters to be used in each part of the image derive. See
- /// AnWTFilterSpec and SynWTFilterSpec.
- ///
- /// The filters to use are defined by a hierarchy. The hierarchy is:
- ///
- ///
- Tile and component specific filters
- /// - Tile specific default filters
- /// - Component main default filters
- /// - Main default filters
- ///
- ///
At the moment tiles are not supported by this class.
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
-
- public abstract class WTFilterSpec
- {
- /// Returns the data type used by the filters in this object, as defined in
- /// the 'DataBlk' interface.
- ///
- ///
- /// The data type of the filters in this object
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- public abstract int WTDataType { get; }
-
- /// The identifier for "main default" specified filters
- public const byte FILTER_SPEC_MAIN_DEF = 0;
-
- /// The identifier for "component default" specified filters
- public const byte FILTER_SPEC_COMP_DEF = 1;
-
- /// The identifier for "tile specific default" specified filters
- public const byte FILTER_SPEC_TILE_DEF = 2;
-
- /// The identifier for "tile and component specific" specified filters
- public const byte FILTER_SPEC_TILE_COMP = 3;
-
- /// The spec type for each tile and component. The first index is the
- /// component index, the second is the tile index. NOTE: The tile specific
- /// things are not supported yet.
- ///
- // Use byte to save memory (no need for speed here).
- protected internal byte[] specValType;
-
- /// Constructs a 'WTFilterSpec' object, initializing all the components and
- /// tiles to the 'FILTER_SPEC_MAIN_DEF' spec type, for the specified number
- /// of components and tiles.
- ///
- /// NOTE: The tile specific things are not supported yet
- ///
- ///
- /// The number of components
- ///
- ///
- /// The number of tiles
- ///
- ///
- ///
- ///
- protected internal WTFilterSpec(int nc)
- {
- specValType = new byte[nc];
- }
-
- /// Returns the type of specification for the filters in the specified
- /// component and tile. The specification type is one of:
- /// 'FILTER_SPEC_MAIN_DEF', 'FILTER_SPEC_COMP_DEF', 'FILTER_SPEC_TILE_DEF',
- /// 'FILTER_SPEC_TILE_COMP'.
- ///
- /// NOTE: The tile specific things are not supported yet
- ///
- ///
- /// The component index
- ///
- ///
- /// The tile index, in raster scan order.
- ///
- ///
- /// The specification type for component 'n' and tile 't'.
- ///
- ///
- ///
- ///
- public virtual byte getKerSpecType(int n)
- {
- return specValType[n];
- }
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/wavelet/WaveletFilter.cs b/CSJ2K/j2k/wavelet/WaveletFilter.cs
deleted file mode 100644
index e347339f..00000000
--- a/CSJ2K/j2k/wavelet/WaveletFilter.cs
+++ /dev/null
@@ -1,244 +0,0 @@
-/*
-* CVS identifier:
-*
-* $Id: WaveletFilter.java,v 1.13 2001/08/02 11:11:16 grosbois Exp $
-*
-* Class: WaveletFilter
-*
-* Description: Defines the interface for WT filters (analysis
-* and synthesis)
-*
-*
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-*/
-namespace CSJ2K.j2k.wavelet
-{
-
- /// This interface defines how a wavelet filter implementation should present
- /// itself. This interface defines only the commonalities between the analysis
- /// and synthesis filters. The AnWTFilter and SynWTFilter classes provide the
- /// specifics of analysis and synthesis filters.
- ///
- /// Both analysis and filters must be able to return the extent of the
- /// negative and positive support for both synthesis and analysis sides. This
- /// simplifies the sue of some functionalities that need extra information
- /// about the filters.
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- public struct WaveletFilter_Fields
- {
- /// The ID for integer lifting spteps implementations
- public readonly static int WT_FILTER_INT_LIFT = 0;
- /// The ID for floating-point lifting spteps implementations
- public readonly static int WT_FILTER_FLOAT_LIFT = 1;
- /// The ID for floatring-poitn convolution implementations
- public readonly static int WT_FILTER_FLOAT_CONVOL = 2;
- }
- public interface WaveletFilter
- {
- //UPGRADE_NOTE: Members of interface 'WaveletFilter' were extracted into structure 'WaveletFilter_Fields'. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1045'"
- /// Returns the negative support of the low-pass analysis filter. That is
- /// the number of taps of the filter in the negative direction.
- ///
- ///
- /// The number of taps of the low-pass analysis filter in the
- /// negative direction
- ///
- int AnLowNegSupport
- {
- get;
-
- }
- /// Returns the positive support of the low-pass analysis filter. That is
- /// the number of taps of the filter in the negative direction.
- ///
- ///
- /// The number of taps of the low-pass analysis filter in the
- /// positive direction
- ///
- int AnLowPosSupport
- {
- get;
-
- }
- /// Returns the negative support of the high-pass analysis filter. That is
- /// the number of taps of the filter in the negative direction.
- ///
- ///
- /// The number of taps of the high-pass analysis filter in the
- /// negative direction
- ///
- int AnHighNegSupport
- {
- get;
-
- }
- /// Returns the positive support of the high-pass analysis filter. That is
- /// the number of taps of the filter in the negative direction.
- ///
- ///
- /// The number of taps of the high-pass analysis filter in
- /// the positive direction
- ///
- int AnHighPosSupport
- {
- get;
-
- }
- /// Returns the negative support of the low-pass synthesis filter. That is
- /// the number of taps of the filter in the negative direction.
- ///
- ///
- /// The number of taps of the low-pass synthesis filter in the
- /// negative direction
- ///
- int SynLowNegSupport
- {
- get;
-
- }
- /// Returns the positive support of the low-pass synthesis filter. That is
- /// the number of taps of the filter in the negative direction.
- ///
- ///
- /// The number of taps of the low-pass synthesis filter in the
- /// positive direction
- ///
- int SynLowPosSupport
- {
- get;
-
- }
- /// Returns the negative support of the high-pass synthesis filter. That is
- /// the number of taps of the filter in the negative direction.
- ///
- ///
- /// The number of taps of the high-pass synthesis filter in the
- /// negative direction
- ///
- int SynHighNegSupport
- {
- get;
-
- }
- /// Returns the positive support of the high-pass synthesis filter. That is
- /// the number of taps of the filter in the negative direction.
- ///
- ///
- /// The number of taps of the high-pass synthesis filter in the
- /// positive direction
- ///
- int SynHighPosSupport
- {
- get;
-
- }
- /// Returns the implementation type of this filter, as defined in this
- /// class, such as WT_FILTER_INT_LIFT, WT_FILTER_FLOAT_LIFT,
- /// WT_FILTER_FLOAT_CONVOL.
- ///
- ///
- /// The implementation type of this filter: WT_FILTER_INT_LIFT,
- /// WT_FILTER_FLOAT_LIFT, WT_FILTER_FLOAT_CONVOL.
- ///
- int ImplType
- {
- get;
-
- }
- /// Returns the type of data on which this filter works, as defined in the
- /// DataBlk interface.
- ///
- ///
- /// The type of data as defined in the DataBlk interface.
- ///
- ///
- ///
- ///
- int DataType
- {
- get;
-
- }
- /// Returns the reversibility of the filter. A filter is considered
- /// reversible if it is suitable for lossless coding.
- ///
- ///
- /// true if the filter is reversible, false otherwise.
- ///
- ///
- bool Reversible
- {
- get;
-
- }
-
- /// Returns true if the wavelet filter computes or uses the same "inner"
- /// subband coefficient as the full frame wavelet transform, and false
- /// otherwise. In particular, for block based transforms with reduced
- /// overlap, this method should return false. The term "inner" indicates
- /// that this applies only with respect to the coefficient that are not
- /// affected by image boundaries processings such as symmetric extension,
- /// since there is not reference method for this.
- ///
- /// The result depends on the length of the allowed overlap when
- /// compared to the overlap required by the wavelet filter. It also depends
- /// on how overlap processing is implemented in the wavelet filter.
- ///
- ///
- /// This is the number of samples in the input signal
- /// before the first sample to filter that can be used for overlap.
- ///
- ///
- /// This is the number of samples in the input signal
- /// after the last sample to filter that can be used for overlap.
- ///
- ///
- /// This is the lenght of the input signal to filter.The
- /// required number of samples in the input signal after the last sample
- /// depends on the length of the input signal.
- ///
- ///
- /// true if the overlaps are large enough and correct processing is
- /// performed, false otherwise.
- ///
- ///
- bool isSameAsFullWT(int tailOvrlp, int headOvrlp, int inLen);
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/wavelet/WaveletTransform.cs b/CSJ2K/j2k/wavelet/WaveletTransform.cs
deleted file mode 100644
index c72f0e8b..00000000
--- a/CSJ2K/j2k/wavelet/WaveletTransform.cs
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
-* CVS identifier:
-*
-* $Id: WaveletTransform.java,v 1.18 2001/10/24 12:02:35 grosbois Exp $
-*
-* Class: WaveletTransform
-*
-* Description: Interface that defines how a forward or
-* inverse wavelet transform should present
-* itself.
-*
-*
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-* */
-using CSJ2K.j2k.image;
-namespace CSJ2K.j2k.wavelet
-{
-
- /// This interface defines how a forward or inverse wavelet transform should
- /// present itself. As specified in the ImgData interface, from which this
- /// class inherits, all operations are confined to the current tile, and all
- /// coordinates are relative to it.
- ///
- /// The definition of the methods in this interface allows for different
- /// types of implementation, reversibility and levels of decompositions for
- /// each component and each tile. An implementation of this interface does not
- /// need to support all this flexibility (e.g., it may provide the same
- /// implementation type and decomposition levels for all tiles and
- /// components).
- ///
- ///
- public struct WaveletTransform_Fields
- {
- /// ID for line based implementations of wavelet transforms.
- ///
- ///
- public readonly static int WT_IMPL_LINE = 0;
- /// ID for full-page based implementations of wavelet transforms. Full-page
- /// based implementations should be avoided since they require large
- /// amounts of memory.
- ///
- ///
- public readonly static int WT_IMPL_FULL = 2;
- }
- public interface WaveletTransform : ImgData
- {
- //UPGRADE_NOTE: Members of interface 'WaveletTransform' were extracted into structure 'WaveletTransform_Fields'. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1045'"
-
-
- /// Returns the reversibility of the wavelet transform for the specified
- /// component and tile. A wavelet transform is reversible when it is
- /// suitable for lossless and lossy-to-lossless compression.
- ///
- ///
- /// The index of the tile.
- ///
- ///
- /// The index of the component.
- ///
- ///
- /// true is the wavelet transform is reversible, false if not.
- ///
- ///
- bool isReversible(int t, int c);
-
- /// Returns the implementation type of this wavelet transform (WT_IMPL_LINE
- /// or WT_IMPL_FRAME) for the specified component, in the current tile.
- ///
- ///
- /// The index of the component.
- ///
- ///
- /// WT_IMPL_LINE or WT_IMPL_FULL for line, block or full-page based
- /// transforms.
- ///
- ///
- int getImplementationType(int c);
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/wavelet/analysis/AnWTFilter.cs b/CSJ2K/j2k/wavelet/analysis/AnWTFilter.cs
deleted file mode 100644
index fb2775f9..00000000
--- a/CSJ2K/j2k/wavelet/analysis/AnWTFilter.cs
+++ /dev/null
@@ -1,488 +0,0 @@
-/*
-* CVS identifier:
-*
-* $Id: AnWTFilter.java,v 1.15 2001/05/08 16:14:52 grosbois Exp $
-*
-* Class: AnWTFilter
-*
-* Description: The abstract class for all analysis wavelet filters
-*
-*
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-* */
-namespace CSJ2K.j2k.wavelet.analysis
-{
-
- /// This abstract class defines the methods of all analysis wavelet
- /// filters. Specialized abstract classes that work on particular data types
- /// (int, float) provide more specific method calls while retaining the
- /// generality of this one. See the AnWTFilterInt and AnWTFilterFloat
- /// classes. Implementations of analysis filters should inherit from one of
- /// those classes.
- ///
- /// All analysis wavelet filters should follow the following conventions:
- ///
- ///
- /// - The first sample to filter is the low-pass one. As a consequence, if
- /// the input signal is of odd-length then the low-pass output signal is one
- /// sample longer than the high-pass output one. Therefore, if the length of
- /// input signal is N, the low-pass output signal is of length N/2 if N is even
- /// and N/2+1/2 if N is odd, while the high-pass output signal is of length N/2
- /// if N is even and N/2-1/2 if N is odd.
- ///
- /// - The normalization is 1 for the DC gain and 2 for the Nyquist gain (Type
- /// I normalization), for both reversible and non-reversible filters.
- ///
- /// - If the length of input signal is N, the low-pass output signal is of
- /// length N/2 if N is even and N/2+1/2 if N is odd, while the high-pass output
- /// sample is of length N/2 if N is even and N/2-1/2 if N is odd.
- ///
- /// - The analyze method may seem very complicated, but is designed to
- /// minimize the amount of data copying and redundant calculations when used
- /// for block-based or line-based wavelet transform implementations, while
- /// being applicable to full-frame transforms as well.
- ///
- /// - All filters should implement the equals() method of the Object
- /// class. The call x.equals(y) should test if the 'x' and 'y' filters are the
- /// same or not, in what concerns the bit stream header syntax (two filters are
- /// the same if the same filter code should be output to the bit stream).
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- public abstract class AnWTFilter : WaveletFilter
- {
- /// Returns the type of filter used according to the FilterTypes interface.
- ///
- ///
- ///
- ///
- ///
- /// The filter type.
- ///
- ///
- public abstract int FilterType { get; }
- /// Returns the parameters that are used in this class and implementing
- /// classes. It returns a 2D String array. Each of the 1D arrays is for a
- /// different option, and they have 3 elements. The first element is the
- /// option name, the second one is the synopsis, the third one is a long
- /// description of what the parameter is and the fourth is its default
- /// value. The synopsis or description may be 'null', in which case it is
- /// assumed that there is no synopsis or description of the option,
- /// respectively. Null may be returned if no options are supported.
- ///
- ///
- /// the options name, their synopsis and their explanation, or null
- /// if no options are supported.
- ///
- ///
- public static System.String[][] ParameterInfo
- {
- get
- {
- return pinfo;
- }
-
- }
- public abstract int AnHighPosSupport { get; }
- public abstract int AnLowNegSupport { get; }
- public abstract int AnLowPosSupport { get; }
- public abstract bool Reversible { get; }
- public abstract int ImplType { get; }
- public abstract int SynHighNegSupport { get; }
- public abstract int SynHighPosSupport { get; }
- public abstract int AnHighNegSupport { get; }
- public abstract int DataType { get; }
- public abstract int SynLowNegSupport { get; }
- public abstract int SynLowPosSupport { get; }
-
- /// The prefix for wavelet filter options: 'F'
- public const char OPT_PREFIX = 'F';
-
- /// The list of parameters that is accepted for wavelet filters. Options
- /// for wavelet filters start with a 'F'.
- ///
- //UPGRADE_NOTE: Final was removed from the declaration of 'pinfo'. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- private static readonly System.String[][] pinfo = new System.String[][] { new System.String[] { "Ffilters", "[] " + "[ [] ...]", "Specifies which filters to use for specified tile-component. " + "If this option is not used, the encoder choses the filters " + " of the tile-components according to their quantization type." + " If this option is used, a component transformation is applied " + "to the three first components.\n" + ": see general note\n" + ": ',' separates horizontal and vertical filters, ':' separates" + " decomposition levels filters. JPEG 2000 part 1 only supports w5x3" + " and w9x7 filters.", null } };
-
- /// Filters the input signal by this analysis filter, decomposing it in a
- /// low-pass and a high-pass signal. This method performs the filtering and
- /// the subsampling with the low pass first filtering convention.
- ///
- /// The input signal resides in the inSig array. The index of the first
- /// sample to filter (i.e. that will generate the first low-pass output
- /// sample) is given by inOff. The number of samples to filter is given by
- /// inLen. This array must be of the same type as the one for which the
- /// particular implementation works with (which is returned by the
- /// getDataType() method).
- ///
- /// The input signal can be interleaved with other signals in the same
- /// inSig array, and this is determined by the inStep argument. This means
- /// that the first sample of the input signal is inSig[inOff], the second
- /// is inSig[inOff+inStep], the third is inSig[inOff+2*inStep], and so
- /// on. Therefore if inStep is 1 there is no interleaving. This feature
- /// allows to filter columns of a 2-D signal, when it is stored in a line
- /// by line order in inSig, without having to copy the data, in this case
- /// the inStep argument should be the line width.
- ///
- /// This method also allows to apply the analysis wavelet filter by
- /// parts in the input signal using an overlap and thus producing the same
- /// coefficients at the output. The tailOvrlp argument specifies how many
- /// samples in the input signal, before the first one to be filtered, can
- /// be used for overlap. Then, the filter instead of extending the input
- /// signal will use those samples to calculate the first output
- /// samples. The argument tailOvrlp can be 0 for no overlap, or some value
- /// that provides partial or full overlap. There should be enough samples
- /// in the input signal, before the first sample to be filtered, to support
- /// the overlap. The headOvrlp provides the same functionality but at the
- /// end of the input signal. The inStep argument also applies to samples
- /// used for overlap. This overlap feature can be used for line-based
- /// wavelet transforms (in which case it will only be used when filtering
- /// the columns) or for overlapping block-based wavelet transforms (in
- /// which case it will be used when filtering lines and columns).
- ///
- /// The low-pass output signal is placed in the lowSig array. The lowOff
- /// and lowStep arguments are analogous to the inOff and inStep ones, but
- /// they apply to the lowSig array. The lowSig array must be long enough to
- /// hold the low-pass output signal.
- ///
- /// The high-pass output signal is placed in the highSig array. The
- /// highOff and highStep arguments are analogous to the inOff and inStep
- /// ones, but they apply to the highSig array. The highSig array must be
- /// long enough to hold the high-pass output signal.
- ///
- ///
- /// This is the array that contains the input signal. It must
- /// be of the correct type (e.g., it must be int[] if getDataType() returns
- /// TYPE_INT).
- ///
- ///
- /// This is the index in inSig of the first sample to filter.
- ///
- ///
- /// This is the number of samples in the input signal to
- /// filter.
- ///
- ///
- /// This is the step, or interleave factor, of the input
- /// signal samples in the inSig array. See above.
- ///
- ///
- /// This is the number of samples in the input signal
- /// before the first sample to filter that can be used for overlap. See
- /// above.
- ///
- ///
- /// This is the number of samples in the input signal
- /// after the last sample to filter that can be used for overlap. See
- /// above.
- ///
- ///
- /// This is the array where the low-pass output signal is
- /// placed. It must be of the same type as inSig and it should be long
- /// enough to contain the output signal.
- ///
- ///
- /// This is the index in lowSig of the element where to put
- /// the first low-pass output sample.
- ///
- ///
- /// This is the step, or interleave factor, of the low-pass
- /// output samples in the lowSig array. See above.
- ///
- ///
- /// This is the array where the high-pass output signal is
- /// placed. It must be of the same type as inSig and it should be long
- /// enough to contain the output signal.
- ///
- ///
- /// This is the index in highSig of the element where to put
- /// the first high-pass output sample.
- ///
- ///
- /// This is the step, or interleave factor, of the
- /// high-pass output samples in the highSig array. See above.
- ///
- ///
- ///
- ///
- ///
- public abstract void analyze_lpf(System.Object inSig, int inOff, int inLen, int inStep, System.Object lowSig, int lowOff, int lowStep, System.Object highSig, int highOff, int highStep);
-
- /// Filters the input signal by this analysis filter, decomposing it in a
- /// low-pass and a high-pass signal. This method performs the filtering and
- /// the subsampling with the high pass first filtering convention.
- ///
- /// The input signal resides in the inSig array. The index of the first
- /// sample to filter (i.e. that will generate the first high-pass output
- /// sample) is given by inOff. The number of samples to filter is given by
- /// inLen. This array must be of the same type as the one for which the
- /// particular implementation works with (which is returned by the
- /// getDataType() method).
- ///
- /// The input signal can be interleaved with other signals in the same
- /// inSig array, and this is determined by the inStep argument. This means
- /// that the first sample of the input signal is inSig[inOff], the second
- /// is inSig[inOff+inStep], the third is inSig[inOff+2*inStep], and so
- /// on. Therefore if inStep is 1 there is no interleaving. This feature
- /// allows to filter columns of a 2-D signal, when it is stored in a line
- /// by line order in inSig, without having to copy the data, in this case
- /// the inStep argument should be the line width.
- ///
- /// The low-pass output signal is placed in the lowSig array. The lowOff
- /// and lowStep arguments are analogous to the inOff and inStep ones, but
- /// they apply to the lowSig array. The lowSig array must be long enough to
- /// hold the low-pass output signal.
- ///
- /// The high-pass output signal is placed in the highSig array. The
- /// highOff and highStep arguments are analogous to the inOff and inStep
- /// ones, but they apply to the highSig array. The highSig array must be
- /// long enough to hold the high-pass output signal.
- ///
- ///
- /// This is the array that contains the input signal. It must
- /// be of the correct type (e.g., it must be int[] if getDataType() returns
- /// TYPE_INT).
- ///
- ///
- /// This is the index in inSig of the first sample to filter.
- ///
- ///
- /// This is the number of samples in the input signal to
- /// filter.
- ///
- ///
- /// This is the step, or interleave factor, of the input
- /// signal samples in the inSig array. See above.
- ///
- ///
- /// This is the array where the low-pass output signal is
- /// placed. It must be of the same type as inSig and it should be long
- /// enough to contain the output signal.
- ///
- ///
- /// This is the index in lowSig of the element where to put
- /// the first low-pass output sample.
- ///
- ///
- /// This is the step, or interleave factor, of the low-pass
- /// output samples in the lowSig array. See above.
- ///
- ///
- /// This is the array where the high-pass output signal is
- /// placed. It must be of the same type as inSig and it should be long
- /// enough to contain the output signal.
- ///
- ///
- /// This is the index in highSig of the element where to put
- /// the first high-pass output sample.
- ///
- ///
- /// This is the step, or interleave factor, of the
- /// high-pass output samples in the highSig array. See above.
- ///
- ///
- ///
- ///
- ///
- public abstract void analyze_hpf(System.Object inSig, int inOff, int inLen, int inStep, System.Object lowSig, int lowOff, int lowStep, System.Object highSig, int highOff, int highStep);
-
- /// Returns the time-reversed low-pass synthesis waveform of the filter,
- /// which is the low-pass filter. This is the time-reversed impulse
- /// response of the low-pass synthesis filter. It is used to calculate the
- /// L2-norm of the synthesis basis functions for a particular subband (also
- /// called energy weight).
- ///
- /// The returned array may not be modified (i.e. a reference to the
- /// internal array may be returned by the implementation of this
- /// method).
- ///
- ///
- /// The time-reversed low-pass synthesis waveform of the filter.
- ///
- ///
- public abstract float[] getLPSynthesisFilter();
-
- /// Returns the time-reversed high-pass synthesis waveform of the filter,
- /// which is the high-pass filter. This is the time-reversed impulse
- /// response of the high-pass synthesis filter. It is used to calculate the
- /// L2-norm of the synthesis basis functions for a particular subband (also
- /// called energy weight).
- ///
- /// The returned array may not be modified (i.e. a reference to the
- /// internal array may be returned by the implementation of this
- /// method).
- ///
- ///
- /// The time-reversed high-pass synthesis waveform of the filter.
- ///
- ///
- public abstract float[] getHPSynthesisFilter();
-
- /// Returns the equivalent low-pass synthesis waveform of a cascade of
- /// filters, given the syhthesis waveform of the previous stage. This is
- /// the result of upsampling 'in' by 2, and concolving it with the low-pass
- /// synthesis waveform of the filter. The length of the returned signal is
- /// 2*in_l+lp_l-2, where in_l is the length of 'in' and 'lp_l' is the
- /// lengthg of the low-pass synthesis filter.
- ///
- /// The length of the low-pass synthesis filter is
- /// getSynLowNegSupport()+getSynLowPosSupport().
- ///
- ///
- /// The synthesis waveform of the previous stage.
- ///
- ///
- /// If non-null this array is used to store the resulting
- /// signal. It must be long enough, or an IndexOutOfBoundsException is
- /// thrown.
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- public virtual float[] getLPSynWaveForm(float[] in_Renamed, float[] out_Renamed)
- {
- return upsampleAndConvolve(in_Renamed, getLPSynthesisFilter(), out_Renamed);
- }
-
- /// Returns the equivalent high-pass synthesis waveform of a cascade of
- /// filters, given the syhthesis waveform of the previous stage. This is
- /// the result of upsampling 'in' by 2, and concolving it with the
- /// high-pass synthesis waveform of the filter. The length of the returned
- /// signal is 2*in_l+hp_l-2, where in_l is the length of 'in' and 'hp_l' is
- /// the lengthg of the high-pass synthesis filter.
- ///
- /// The length of the high-pass synthesis filter is
- /// getSynHighNegSupport()+getSynHighPosSupport().
- ///
- ///
- /// The synthesis waveform of the previous stage.
- ///
- ///
- /// If non-null this array is used to store the resulting
- /// signal. It must be long enough, or an IndexOutOfBoundsException is
- /// thrown.
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- public virtual float[] getHPSynWaveForm(float[] in_Renamed, float[] out_Renamed)
- {
- return upsampleAndConvolve(in_Renamed, getHPSynthesisFilter(), out_Renamed);
- }
-
- /// Returns the signal resulting of upsampling (by 2) the input signal 'in'
- /// and then convolving it with the time-reversed signal 'wf'. The returned
- /// signal is of length l_in*2+l_wf-2, where l_in is the length of 'in',
- /// and l_wf is the length of 'wf'.
- ///
- /// The 'wf' signal has to be already time-reversed, therefore only a
- /// dot-product is performed (instead of a convolution). This is equivalent
- /// to convolving with the non-time-reversed 'wf' signal.
- ///
- ///
- /// The signal to upsample and filter. If null it is considered
- /// to be a dirac.
- ///
- ///
- /// The time-reversed impulse response used for filtering.
- ///
- ///
- /// If non-null this array is used to store the resulting
- /// signal, it must be of length in.length*2+wf.length-2 at least. An
- /// IndexOutOfBoundsException is thrown if this is not the case.
- ///
- ///
- /// The resulting signal, of length in.length*2+wf.length-2
- ///
- ///
- private static float[] upsampleAndConvolve(float[] in_Renamed, float[] wf, float[] out_Renamed)
- {
- // NOTE: the effective length of the signal 'in' upsampled by
- // 2 is 2*in.length-1 (not 2*in.length), so the resulting signal
- // (after convolution) is of length 2*in.length-1+wf.length-1,
- // which is 2*in.length+wf.length-2
-
- int i, k, j;
- float tmp;
- int maxi, maxk;
-
- // If in null, then simulate dirac
- if (in_Renamed == null)
- {
- in_Renamed = new float[1];
- in_Renamed[0] = 1.0f;
- }
-
- // Get output buffer if necessary
- if (out_Renamed == null)
- {
- out_Renamed = new float[in_Renamed.Length * 2 + wf.Length - 2];
- }
- // Convolve the signals
- for (i = 0, maxi = in_Renamed.Length * 2 + wf.Length - 2; i < maxi; i++)
- {
- tmp = 0.0f;
-
- // Calculate limits of loop below
- k = (i - wf.Length + 2) / 2;
- if (k < 0)
- k = 0;
- maxk = i / 2 + 1;
- if (maxk > in_Renamed.Length)
- maxk = in_Renamed.Length;
-
- // Calculate dot-product with upsampling of 'in' by 2.
- for (j = 2 * k - i + wf.Length - 1; k < maxk; k++, j += 2)
- {
- tmp += in_Renamed[k] * wf[j];
- }
- // Store result
- out_Renamed[i] = tmp;
- }
-
- return out_Renamed;
- }
- public abstract bool isSameAsFullWT(int param1, int param2, int param3);
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/wavelet/analysis/AnWTFilterFloat.cs b/CSJ2K/j2k/wavelet/analysis/AnWTFilterFloat.cs
deleted file mode 100644
index 68a48b98..00000000
--- a/CSJ2K/j2k/wavelet/analysis/AnWTFilterFloat.cs
+++ /dev/null
@@ -1,310 +0,0 @@
-/*
-* CVS identifier:
-*
-* $Id: AnWTFilterFloat.java,v 1.7 2000/09/05 09:25:37 grosbois Exp $
-*
-* Class: AnWTFilterFloat
-*
-* Description: A specialized wavelet filter interface that
-* works on float data.
-*
-*
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-*
-*
-*
-*/
-using CSJ2K.j2k.image;
-namespace CSJ2K.j2k.wavelet.analysis
-{
-
- /// This extends the analysis wavelet filter general definitions of
- /// AnWTFilter by adding methods that work for float data
- /// specifically. Implementations that work on float data should inherit
- /// from this class.
- ///
- /// See the AnWTFilter class for details such as
- /// normalization, how to split odd-length signals, etc.
- ///
- ///
The advantage of using the specialized method is that no casts
- /// are performed.
- ///
- ///
- ///
- ///
- ///
- public abstract class AnWTFilterFloat : AnWTFilter
- {
- /// Returns the type of data on which this filter works, as defined
- /// in the DataBlk interface, which is always TYPE_FLOAT for this
- /// class.
- ///
- ///
- /// The type of data as defined in the DataBlk interface.
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- override public int DataType
- {
- get
- {
- return DataBlk.TYPE_FLOAT;
- }
-
- }
-
- /// A specific version of the analyze_lpf() method that works on int
- /// data. See the general description of the analyze_lpf() method in
- /// the AnWTFilter class for more details.
- ///
- ///
- /// This is the array that contains the input
- /// signal.
- ///
- ///
- /// This is the index in inSig of the first sample to
- /// filter.
- ///
- ///
- /// This is the number of samples in the input signal
- /// to filter.
- ///
- ///
- /// This is the step, or interleave factor, of the
- /// input signal samples in the inSig array.
- ///
- ///
- /// This is the array where the low-pass output
- /// signal is placed.
- ///
- ///
- /// This is the index in lowSig of the element where
- /// to put the first low-pass output sample.
- ///
- ///
- /// This is the step, or interleave factor, of the
- /// low-pass output samples in the lowSig array.
- ///
- ///
- /// This is the array where the high-pass output
- /// signal is placed.
- ///
- ///
- /// This is the index in highSig of the element where
- /// to put the first high-pass output sample.
- ///
- ///
- /// This is the step, or interleave factor, of the
- /// high-pass output samples in the highSig array.
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- public abstract void analyze_lpf(float[] inSig, int inOff, int inLen, int inStep, float[] lowSig, int lowOff, int lowStep, float[] highSig, int highOff, int highStep);
-
- /// The general version of the analyze_lpf() method, it just calls the
- /// specialized version. See the description of the analyze_lpf()
- /// method of the AnWTFilter class for more details.
- ///
- ///
- /// This is the array that contains the input
- /// signal. It must be an float[].
- ///
- ///
- /// This is the index in inSig of the first sample to
- /// filter.
- ///
- ///
- /// This is the number of samples in the input signal
- /// to filter.
- ///
- ///
- /// This is the step, or interleave factor, of the
- /// input signal samples in the inSig array.
- ///
- ///
- /// This is the array where the low-pass output
- /// signal is placed. It must be an float[].
- ///
- ///
- /// This is the index in lowSig of the element where
- /// to put the first low-pass output sample.
- ///
- ///
- /// This is the step, or interleave factor, of the
- /// low-pass output samples in the lowSig array.
- ///
- ///
- /// This is the array where the high-pass output
- /// signal is placed. It must be an float[].
- ///
- ///
- /// This is the index in highSig of the element where
- /// to put the first high-pass output sample.
- ///
- ///
- /// This is the step, or interleave factor, of the
- /// high-pass output samples in the highSig array.
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- public override void analyze_lpf(System.Object inSig, int inOff, int inLen, int inStep, System.Object lowSig, int lowOff, int lowStep, System.Object highSig, int highOff, int highStep)
- {
-
- analyze_lpf((float[])inSig, inOff, inLen, inStep, (float[])lowSig, lowOff, lowStep, (float[])highSig, highOff, highStep);
- }
-
- /// A specific version of the analyze_hpf() method that works on int
- /// data. See the general description of the analyze_hpf() method in the
- /// AnWTFilter class for more details.
- ///
- ///
- /// This is the array that contains the input
- /// signal.
- ///
- ///
- /// This is the index in inSig of the first sample to
- /// filter.
- ///
- ///
- /// This is the number of samples in the input signal
- /// to filter.
- ///
- ///
- /// This is the step, or interleave factor, of the
- /// input signal samples in the inSig array.
- ///
- ///
- /// This is the array where the low-pass output
- /// signal is placed.
- ///
- ///
- /// This is the index in lowSig of the element where
- /// to put the first low-pass output sample.
- ///
- ///
- /// This is the step, or interleave factor, of the
- /// low-pass output samples in the lowSig array.
- ///
- ///
- /// This is the array where the high-pass output
- /// signal is placed.
- ///
- ///
- /// This is the index in highSig of the element where
- /// to put the first high-pass output sample.
- ///
- ///
- /// This is the step, or interleave factor, of the
- /// high-pass output samples in the highSig array.
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- public abstract void analyze_hpf(float[] inSig, int inOff, int inLen, int inStep, float[] lowSig, int lowOff, int lowStep, float[] highSig, int highOff, int highStep);
-
-
-
- /// The general version of the analyze_hpf() method, it just calls the
- /// specialized version. See the description of the analyze_hpf()
- /// method of the AnWTFilter class for more details.
- ///
- ///
- /// This is the array that contains the input
- /// signal. It must be an float[].
- ///
- ///
- /// This is the index in inSig of the first sample to
- /// filter.
- ///
- ///
- /// This is the number of samples in the input signal
- /// to filter.
- ///
- ///
- /// This is the step, or interleave factor, of the
- /// input signal samples in the inSig array.
- ///
- ///
- /// This is the array where the low-pass output
- /// signal is placed. It must be an float[].
- ///
- ///
- /// This is the index in lowSig of the element where
- /// to put the first low-pass output sample.
- ///
- ///
- /// This is the step, or interleave factor, of the
- /// low-pass output samples in the lowSig array.
- ///
- ///
- /// This is the array where the high-pass output
- /// signal is placed. It must be an float[].
- ///
- ///
- /// This is the index in highSig of the element where
- /// to put the first high-pass output sample.
- ///
- ///
- /// This is the step, or interleave factor, of the
- /// high-pass output samples in the highSig array.
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- public override void analyze_hpf(System.Object inSig, int inOff, int inLen, int inStep, System.Object lowSig, int lowOff, int lowStep, System.Object highSig, int highOff, int highStep)
- {
-
- analyze_hpf((float[])inSig, inOff, inLen, inStep, (float[])lowSig, lowOff, lowStep, (float[])highSig, highOff, highStep);
- }
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/wavelet/analysis/AnWTFilterFloatLift9x7.cs b/CSJ2K/j2k/wavelet/analysis/AnWTFilterFloatLift9x7.cs
deleted file mode 100644
index 59cf28c8..00000000
--- a/CSJ2K/j2k/wavelet/analysis/AnWTFilterFloatLift9x7.cs
+++ /dev/null
@@ -1,803 +0,0 @@
-/*
-* CVS identifier:
-*
-* $Id: AnWTFilterFloatLift9x7.java,v 1.18 2002/01/22 13:31:31 grosbois Exp $
-*
-* Class: AnWTFilterFloatLift9x7
-*
-* Description: An analyzing wavelet filter implementing the
-* lifting 9x7 transform.
-*
-*
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-* */
-namespace CSJ2K.j2k.wavelet.analysis
-{
-
- /// This class inherits from the analysis wavelet filter definition
- /// for int data. It implements the forward wavelet transform
- /// specifically for the 9x7 filter. The implementation is based on
- /// the lifting scheme.
- ///
- /// See the AnWTFilter class for details such as
- /// normalization, how to split odd-length signals, etc. In particular,
- /// this method assumes that the low-pass coefficient is computed first.
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- public class AnWTFilterFloatLift9x7 : AnWTFilterFloat
- {
- /// Returns the negative support of the low-pass analysis
- /// filter. That is the number of taps of the filter in the
- /// negative direction.
- ///
- ///
- /// 2
- ///
- ///
- override public int AnLowNegSupport
- {
- get
- {
- return 4;
- }
-
- }
- /// Returns the positive support of the low-pass analysis
- /// filter. That is the number of taps of the filter in the
- /// negative direction.
- ///
- ///
- /// The number of taps of the low-pass analysis filter in
- /// the positive direction
- ///
- ///
- override public int AnLowPosSupport
- {
- get
- {
- return 4;
- }
-
- }
- /// Returns the negative support of the high-pass analysis
- /// filter. That is the number of taps of the filter in the
- /// negative direction.
- ///
- ///
- /// The number of taps of the high-pass analysis filter in
- /// the negative direction
- ///
- ///
- override public int AnHighNegSupport
- {
- get
- {
- return 3;
- }
-
- }
- /// Returns the positive support of the high-pass analysis
- /// filter. That is the number of taps of the filter in the
- /// negative direction.
- ///
- ///
- /// The number of taps of the high-pass analysis filter in
- /// the positive direction
- ///
- ///
- override public int AnHighPosSupport
- {
- get
- {
- return 3;
- }
-
- }
- /// Returns the negative support of the low-pass synthesis
- /// filter. That is the number of taps of the filter in the
- /// negative direction.
- ///
- /// A MORE PRECISE DEFINITION IS NEEDED
- ///
- ///
- /// The number of taps of the low-pass synthesis filter in
- /// the negative direction
- ///
- ///
- override public int SynLowNegSupport
- {
- get
- {
- return 3;
- }
-
- }
- /// Returns the positive support of the low-pass synthesis
- /// filter. That is the number of taps of the filter in the
- /// negative direction.
- ///
- /// A MORE PRECISE DEFINITION IS NEEDED
- ///
- ///
- /// The number of taps of the low-pass synthesis filter in
- /// the positive direction
- ///
- ///
- override public int SynLowPosSupport
- {
- get
- {
- return 3;
- }
-
- }
- /// Returns the negative support of the high-pass synthesis
- /// filter. That is the number of taps of the filter in the
- /// negative direction.
- ///
- /// A MORE PRECISE DEFINITION IS NEEDED
- ///
- ///
- /// The number of taps of the high-pass synthesis filter in
- /// the negative direction
- ///
- ///
- override public int SynHighNegSupport
- {
- get
- {
- return 4;
- }
-
- }
- /// Returns the positive support of the high-pass synthesis
- /// filter. That is the number of taps of the filter in the
- /// negative direction.
- ///
- /// A MORE PRECISE DEFINITION IS NEEDED
- ///
- ///
- /// The number of taps of the high-pass synthesis filter in
- /// the positive direction
- ///
- ///
- override public int SynHighPosSupport
- {
- get
- {
- return 4;
- }
-
- }
- /// Returns the implementation type of this filter, as defined in
- /// this class, such as WT_FILTER_INT_LIFT, WT_FILTER_FLOAT_LIFT,
- /// WT_FILTER_FLOAT_CONVOL.
- ///
- ///
- /// WT_FILTER_INT_LIFT.
- ///
- ///
- override public int ImplType
- {
- get
- {
- return CSJ2K.j2k.wavelet.WaveletFilter_Fields.WT_FILTER_FLOAT_LIFT;
- }
-
- }
- /// Returns the reversibility of the filter. A filter is considered
- /// reversible if it is suitable for lossless coding.
- ///
- ///
- /// true since the 9x7 is reversible, provided the appropriate
- /// rounding is performed.
- ///
- ///
- override public bool Reversible
- {
- get
- {
- return false;
- }
-
- }
- /// Returns the type of filter used according to the FilterTypes
- /// interface(W9x7).
- ///
- ///
- ///
- ///
- ///
- /// The filter type.
- ///
- ///
- override public int FilterType
- {
- get
- {
- return CSJ2K.j2k.wavelet.FilterTypes_Fields.W9X7;
- }
-
- }
-
- /// The low-pass synthesis filter of the 9x7 wavelet transform
- //UPGRADE_NOTE: Final was removed from the declaration of 'LPSynthesisFilter'. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- private static readonly float[] LPSynthesisFilter = new float[] { -0.091272f, -0.057544f, 0.591272f, 1.115087f, 0.591272f, -0.057544f, -0.091272f };
-
- /// The high-pass synthesis filter of the 9x7 wavelet transform
- //UPGRADE_NOTE: Final was removed from the declaration of 'HPSynthesisFilter'. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- private static readonly float[] HPSynthesisFilter = new float[] { 0.026749f, 0.016864f, -0.078223f, -0.266864f, 0.602949f, -0.266864f, -0.078223f, 0.016864f, 0.026749f };
-
- /// The value of the first lifting step coefficient
- public const float ALPHA = -1.586134342f;
-
- /// The value of the second lifting step coefficient
- public const float BETA = -0.05298011854f;
-
- /// The value of the third lifting step coefficient
- public const float GAMMA = 0.8829110762f;
-
- /// The value of the fourth lifting step coefficient
- public const float DELTA = 0.4435068522f;
-
- /// The value of the low-pass subband normalization factor
- public const float KL = 0.8128930655f;
-
- /// The value of the high-pass subband normalization factor
- public const float KH = 1.230174106f;
-
- /// An implementation of the analyze_lpf() method that works on int
- /// data, for the forward 9x7 wavelet transform using the
- /// lifting scheme. See the general description of the analyze_lpf()
- /// method in the AnWTFilter class for more details.
- ///
- /// The coefficients of the first lifting step are [ALPHA 1 ALPHA].
- ///
- ///
The coefficients of the second lifting step are [BETA 1 BETA].
- ///
- ///
The coefficients of the third lifting step are [GAMMA 1 GAMMA].
- ///
- ///
The coefficients of the fourth lifting step are [DELTA 1 DELTA].
- ///
- ///
The low-pass and high-pass subbands are normalized by respectively
- /// a factor of KL and a factor of KH
- ///
- ///
- /// This is the array that contains the input
- /// signal.
- ///
- ///
- /// This is the index in inSig of the first sample to
- /// filter.
- ///
- ///
- /// This is the number of samples in the input signal
- /// to filter.
- ///
- ///
- /// This is the step, or interleave factor, of the
- /// input signal samples in the inSig array.
- ///
- ///
- /// This is the array where the low-pass output
- /// signal is placed.
- ///
- ///
- /// This is the index in lowSig of the element where
- /// to put the first low-pass output sample.
- ///
- ///
- /// This is the step, or interleave factor, of the
- /// low-pass output samples in the lowSig array.
- ///
- ///
- /// This is the array where the high-pass output
- /// signal is placed.
- ///
- ///
- /// This is the index in highSig of the element where
- /// to put the first high-pass output sample.
- ///
- ///
- /// This is the step, or interleave factor, of the
- /// high-pass output samples in the highSig array.
- ///
- ///
- public override void analyze_lpf(float[] inSig, int inOff, int inLen, int inStep, float[] lowSig, int lowOff, int lowStep, float[] highSig, int highOff, int highStep)
- {
- int i, maxi;
- int iStep = 2 * inStep; //Subsampling in inSig
- int ik; //Indexing inSig
- int lk; //Indexing lowSig
- int hk; //Indexing highSig
-
- // Generate intermediate high frequency subband
-
- //Initialize counters
- ik = inOff + inStep;
- lk = lowOff;
- hk = highOff;
-
- //Apply first lifting step to each "inner" sample
- for (i = 1, maxi = inLen - 1; i < maxi; i += 2)
- {
- highSig[hk] = inSig[ik] + ALPHA * (inSig[ik - inStep] + inSig[ik + inStep]);
-
- ik += iStep;
- hk += highStep;
- }
-
- //Handle head boundary effect if input signal has even length
- if (inLen % 2 == 0)
- {
- highSig[hk] = inSig[ik] + 2 * ALPHA * inSig[ik - inStep];
- }
-
- // Generate intermediate low frequency subband
-
- //Initialize counters
- ik = inOff;
- lk = lowOff;
- hk = highOff;
-
- if (inLen > 1)
- {
- lowSig[lk] = inSig[ik] + 2 * BETA * highSig[hk];
- }
- else
- {
- lowSig[lk] = inSig[ik];
- }
-
- ik += iStep;
- lk += lowStep;
- hk += highStep;
-
- //Apply lifting step to each "inner" sample
- for (i = 2, maxi = inLen - 1; i < maxi; i += 2)
- {
- lowSig[lk] = inSig[ik] + BETA * (highSig[hk - highStep] + highSig[hk]);
-
- ik += iStep;
- lk += lowStep;
- hk += highStep;
- }
-
- //Handle head boundary effect if input signal has odd length
- if ((inLen % 2 == 1) && (inLen > 2))
- {
- lowSig[lk] = inSig[ik] + 2 * BETA * highSig[hk - highStep];
- }
-
- // Generate high frequency subband
-
- //Initialize counters
- lk = lowOff;
- hk = highOff;
-
- //Apply first lifting step to each "inner" sample
- for (i = 1, maxi = inLen - 1; i < maxi; i += 2)
- {
- highSig[hk] += GAMMA * (lowSig[lk] + lowSig[lk + lowStep]);
-
- lk += lowStep;
- hk += highStep;
- }
-
- //Handle head boundary effect if input signal has even length
- if (inLen % 2 == 0)
- {
- highSig[hk] += 2 * GAMMA * lowSig[lk];
- }
-
- // Generate low frequency subband
-
- //Initialize counters
- lk = lowOff;
- hk = highOff;
-
- //Handle tail boundary effect
- //If access the overlap then perform the lifting step
- if (inLen > 1)
- {
- lowSig[lk] += 2 * DELTA * highSig[hk];
- }
-
- lk += lowStep;
- hk += highStep;
-
- //Apply lifting step to each "inner" sample
- for (i = 2, maxi = inLen - 1; i < maxi; i += 2)
- {
- lowSig[lk] += DELTA * (highSig[hk - highStep] + highSig[hk]);
-
- lk += lowStep;
- hk += highStep;
- }
-
- //Handle head boundary effect if input signal has odd length
- if ((inLen % 2 == 1) && (inLen > 2))
- {
- lowSig[lk] += 2 * DELTA * highSig[hk - highStep];
- }
-
- // Normalize low and high frequency subbands
-
- //Re-initialize counters
- lk = lowOff;
- hk = highOff;
-
- //Normalize each sample
- for (i = 0; i < (inLen >> 1); i++)
- {
- lowSig[lk] *= KL;
- highSig[hk] *= KH;
- lk += lowStep;
- hk += highStep;
- }
- //If the input signal has odd length then normalize the last low-pass
- //coefficient (if input signal is length one filter is identity)
- if (inLen % 2 == 1 && inLen != 1)
- {
- lowSig[lk] *= KL;
- }
- }
-
- /// An implementation of the analyze_hpf() method that works on int
- /// data, for the forward 9x7 wavelet transform using the
- /// lifting scheme. See the general description of the analyze_hpf() method
- /// in the AnWTFilter class for more details.
- ///
- /// The coefficients of the first lifting step are [ALPHA 1 ALPHA].
- ///
- ///
The coefficients of the second lifting step are [BETA 1 BETA].
- ///
- ///
The coefficients of the third lifting step are [GAMMA 1 GAMMA].
- ///
- ///
The coefficients of the fourth lifting step are [DELTA 1 DELTA].
- ///
- ///
The low-pass and high-pass subbands are normalized by respectively
- /// a factor of KL and a factor of KH
- ///
- ///
- /// This is the array that contains the input
- /// signal.
- ///
- ///
- /// This is the index in inSig of the first sample to
- /// filter.
- ///
- ///
- /// This is the number of samples in the input signal
- /// to filter.
- ///
- ///
- /// This is the step, or interleave factor, of the
- /// input signal samples in the inSig array.
- ///
- ///
- /// This is the array where the low-pass output
- /// signal is placed.
- ///
- ///
- /// This is the index in lowSig of the element where
- /// to put the first low-pass output sample.
- ///
- ///
- /// This is the step, or interleave factor, of the
- /// low-pass output samples in the lowSig array.
- ///
- ///
- /// This is the array where the high-pass output
- /// signal is placed.
- ///
- ///
- /// This is the index in highSig of the element where
- /// to put the first high-pass output sample.
- ///
- ///
- /// This is the step, or interleave factor, of the
- /// high-pass output samples in the highSig array.
- ///
- ///
- ///
- ///
- ///
- public override void analyze_hpf(float[] inSig, int inOff, int inLen, int inStep, float[] lowSig, int lowOff, int lowStep, float[] highSig, int highOff, int highStep)
- {
-
- int i; // maxi removed
- int iStep = 2 * inStep; //Subsampling in inSig
- int ik; //Indexing inSig
- int lk; //Indexing lowSig
- int hk; //Indexing highSig
-
- // Generate intermediate high frequency subband
-
- //Initialize counters
- ik = inOff;
- lk = lowOff;
- hk = highOff;
-
- if (inLen > 1)
- {
- // apply symmetric extension.
- highSig[hk] = inSig[ik] + 2 * ALPHA * inSig[ik + inStep];
- }
- else
- {
- // Normalize for Nyquist gain
- highSig[hk] = inSig[ik] * 2;
- }
-
- ik += iStep;
- hk += highStep;
-
- //Apply first lifting step to each "inner" sample
- for (i = 2; i < inLen - 1; i += 2)
- {
- highSig[hk] = inSig[ik] + ALPHA * (inSig[ik - inStep] + inSig[ik + inStep]);
- ik += iStep;
- hk += highStep;
- }
-
- //If input signal has odd length then we perform the lifting step
- // i.e. apply a symmetric extension.
- if ((inLen % 2 == 1) && (inLen > 1))
- {
- highSig[hk] = inSig[ik] + 2 * ALPHA * inSig[ik - inStep];
- }
-
- // Generate intermediate low frequency subband
-
- //Initialize counters
- //ik = inOff + inStep;
- ik = inOff + inStep;
- lk = lowOff;
- hk = highOff;
-
- //Apply lifting step to each "inner" sample
- // we are at the component boundary
- for (i = 1; i < inLen - 1; i += 2)
- {
- lowSig[lk] = inSig[ik] + BETA * (highSig[hk] + highSig[hk + highStep]);
-
- ik += iStep;
- lk += lowStep;
- hk += highStep;
- }
- if (inLen > 1 && inLen % 2 == 0)
- {
- // symetric extension
- lowSig[lk] = inSig[ik] + 2 * BETA * highSig[hk];
- }
-
- // Generate high frequency subband
-
- //Initialize counters
- lk = lowOff;
- hk = highOff;
-
- if (inLen > 1)
- {
- // symmetric extension.
- highSig[hk] += GAMMA * 2 * lowSig[lk];
- }
- //lk += lowStep;
- hk += highStep;
-
- //Apply first lifting step to each "inner" sample
- for (i = 2; i < inLen - 1; i += 2)
- {
- highSig[hk] += GAMMA * (lowSig[lk] + lowSig[lk + lowStep]);
- lk += lowStep;
- hk += highStep;
- }
-
- //Handle head boundary effect
- if (inLen > 1 && inLen % 2 == 1)
- {
- // symmetric extension.
- highSig[hk] += GAMMA * 2 * lowSig[lk];
- }
-
- // Generate low frequency subband
-
- //Initialize counters
- lk = lowOff;
- hk = highOff;
-
- // we are at the component boundary
- for (i = 1; i < inLen - 1; i += 2)
- {
- lowSig[lk] += DELTA * (highSig[hk] + highSig[hk + highStep]);
- lk += lowStep;
- hk += highStep;
- }
-
- if (inLen > 1 && inLen % 2 == 0)
- {
- lowSig[lk] += DELTA * 2 * highSig[hk];
- }
-
- // Normalize low and high frequency subbands
-
- //Re-initialize counters
- lk = lowOff;
- hk = highOff;
-
- //Normalize each sample
- for (i = 0; i < (inLen >> 1); i++)
- {
- lowSig[lk] *= KL;
- highSig[hk] *= KH;
- lk += lowStep;
- hk += highStep;
- }
- //If the input signal has odd length then normalize the last high-pass
- //coefficient (if input signal is length one filter is identity)
- if (inLen % 2 == 1 && inLen != 1)
- {
- highSig[hk] *= KH;
- }
- }
-
- /// Returns the time-reversed low-pass synthesis waveform of the
- /// filter, which is the low-pass filter. This is the time-reversed
- /// impulse response of the low-pass synthesis filter. It is used
- /// to calculate the L2-norm of the synthesis basis functions for a
- /// particular subband (also called energy weight).
- ///
- /// The returned array may not be modified (i.e. a reference to
- /// the internal array may be returned by the implementation of
- /// this method).
- ///
- ///
- /// The time-reversed low-pass synthesis waveform of the
- /// filter.
- ///
- ///
- public override float[] getLPSynthesisFilter()
- {
- return LPSynthesisFilter;
- }
-
- /// Returns the time-reversed high-pass synthesis waveform of the
- /// filter, which is the high-pass filter. This is the
- /// time-reversed impulse response of the high-pass synthesis
- /// filter. It is used to calculate the L2-norm of the synthesis
- /// basis functions for a particular subband (also called energy
- /// weight).
- ///
- /// The returned array may not be modified (i.e. a reference to
- /// the internal array may be returned by the implementation of
- /// this method).
- ///
- ///
- /// The time-reversed high-pass synthesis waveform of the
- /// filter.
- ///
- ///
- public override float[] getHPSynthesisFilter()
- {
- return HPSynthesisFilter;
- }
-
- /// Returns true if the wavelet filter computes or uses the
- /// same "inner" subband coefficient as the full frame wavelet transform,
- /// and false otherwise. In particular, for block based transforms with
- /// reduced overlap, this method should return false. The term "inner"
- /// indicates that this applies only with respect to the coefficient that
- /// are not affected by image boundaries processings such as symmetric
- /// extension, since there is not reference method for this.
- ///
- /// The result depends on the length of the allowed overlap when
- /// compared to the overlap required by the wavelet filter. It also
- /// depends on how overlap processing is implemented in the wavelet
- /// filter.
- ///
- ///
- /// This is the number of samples in the input
- /// signal before the first sample to filter that can be used for
- /// overlap.
- ///
- ///
- /// This is the number of samples in the input
- /// signal after the last sample to filter that can be used for
- /// overlap.
- ///
- ///
- /// This is the lenght of the input signal to filter.The
- /// required number of samples in the input signal after the last sample
- /// depends on the length of the input signal.
- ///
- ///
- /// true if both overlaps are greater than 2, and correct
- /// processing is applied in the analyze() method.
- ///
- ///
- public override bool isSameAsFullWT(int tailOvrlp, int headOvrlp, int inLen)
- {
-
- //If the input signal has even length.
- if (inLen % 2 == 0)
- {
- if (tailOvrlp >= 4 && headOvrlp >= 3)
- return true;
- else
- return false;
- }
- //Else if the input signal has odd length.
- else
- {
- if (tailOvrlp >= 4 && headOvrlp >= 4)
- return true;
- else
- return false;
- }
- }
-
- /// Tests if the 'obj' object is the same filter as this one. Two filters
- /// are the same if the same filter code should be output for both filters
- /// by the encodeFilterCode() method.
- ///
- /// Currently the implementation of this method only tests if 'obj' is
- /// also of the class AnWTFilterFloatLift9x7
- ///
- ///
- /// object against which to test inequality.
- ///
- ///
- public override bool Equals(System.Object obj)
- {
- // To spped up test, first test for reference equality
- return obj == this || obj is AnWTFilterFloatLift9x7;
- }
-
- /// Debugging method
- public override System.String ToString()
- {
- return "w9x7";
- }
- //UPGRADE_NOTE: The following method implementation was automatically added to preserve functionality. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1306'"
- public override int GetHashCode()
- {
- return base.GetHashCode();
- }
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/wavelet/analysis/AnWTFilterInt.cs b/CSJ2K/j2k/wavelet/analysis/AnWTFilterInt.cs
deleted file mode 100644
index 25567cca..00000000
--- a/CSJ2K/j2k/wavelet/analysis/AnWTFilterInt.cs
+++ /dev/null
@@ -1,315 +0,0 @@
-/*
-* CVS identifier:
-*
-* $Id: AnWTFilterInt.java,v 1.7 2000/09/05 09:25:42 grosbois Exp $
-*
-* Class: AnWTFilterInt
-*
-* Description: A specialized wavelet filter interface that
-* works on int data.
-*
-*
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-*
-*
-*
-*/
-using CSJ2K.j2k.image;
-namespace CSJ2K.j2k.wavelet.analysis
-{
-
- /// This extends the analysis wavelet filter general definitions of
- /// AnWTFilter by adding methods that work for int data
- /// specifically. Implementations that work on int data should inherit
- /// from this class.
- ///
- /// See the AnWTFilter class for details such as
- /// normalization, how to split odd-length signals, etc.
- ///
- ///
The advantage of using the specialized method is that no casts
- /// are performed.
- ///
- ///
- ///
- ///
- ///
- public abstract class AnWTFilterInt : AnWTFilter
- {
- /// Returns the type of data on which this filter works, as defined
- /// in the DataBlk interface, which is always TYPE_INT for this
- /// class.
- ///
- ///
- /// The type of data as defined in the DataBlk interface.
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- override public int DataType
- {
- get
- {
- return DataBlk.TYPE_INT;
- }
-
- }
-
- /// A specific version of the analyze_lpf() method that works on int
- /// data. See the general description of the analyze_lpf() method in
- /// the AnWTFilter class for more details.
- ///
- ///
- /// This is the array that contains the input
- /// signal.
- ///
- ///
- /// This is the index in inSig of the first sample to
- /// filter.
- ///
- ///
- /// This is the number of samples in the input signal
- /// to filter.
- ///
- ///
- /// This is the step, or interleave factor, of the
- /// input signal samples in the inSig array.
- ///
- ///
- /// This is the array where the low-pass output
- /// signal is placed.
- ///
- ///
- /// This is the index in lowSig of the element where
- /// to put the first low-pass output sample.
- ///
- ///
- /// This is the step, or interleave factor, of the
- /// low-pass output samples in the lowSig array.
- ///
- ///
- /// This is the array where the high-pass output
- /// signal is placed.
- ///
- ///
- /// This is the index in highSig of the element where
- /// to put the first high-pass output sample.
- ///
- ///
- /// This is the step, or interleave factor, of the
- /// high-pass output samples in the highSig array.
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- public abstract void analyze_lpf(int[] inSig, int inOff, int inLen, int inStep, int[] lowSig, int lowOff, int lowStep, int[] highSig, int highOff, int highStep);
-
- /// The general version of the analyze_lpf() method, it just calls the
- /// specialized version. See the description of the analyze_lpf()
- /// method of the AnWTFilter class for more details.
- ///
- ///
- /// This is the array that contains the input
- /// signal. It must be an int[].
- ///
- ///
- /// This is the index in inSig of the first sample to
- /// filter.
- ///
- ///
- /// This is the number of samples in the input signal
- /// to filter.
- ///
- ///
- /// This is the step, or interleave factor, of the
- /// input signal samples in the inSig array.
- ///
- ///
- /// This is the array where the low-pass output
- /// signal is placed. It must be an int[].
- ///
- ///
- /// This is the index in lowSig of the element where
- /// to put the first low-pass output sample.
- ///
- ///
- /// This is the step, or interleave factor, of the
- /// low-pass output samples in the lowSig array.
- ///
- ///
- /// This is the array where the high-pass output
- /// signal is placed. It must be an int[].
- ///
- ///
- /// This is the index in highSig of the element where
- /// to put the first high-pass output sample.
- ///
- ///
- /// This is the step, or interleave factor, of the
- /// high-pass output samples in the highSig array.
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
-
- public override void analyze_lpf(System.Object inSig, int inOff, int inLen, int inStep, System.Object lowSig, int lowOff, int lowStep, System.Object highSig, int highOff, int highStep)
- {
-
- analyze_lpf((int[])inSig, inOff, inLen, inStep, (int[])lowSig, lowOff, lowStep, (int[])highSig, highOff, highStep);
- }
-
- /// A specific version of the analyze_hpf() method that works on int
- /// data. See the general description of the analyze_hpf() method in
- /// the AnWTFilter class for more details.
- ///
- ///
- /// This is the array that contains the input
- /// signal.
- ///
- ///
- /// This is the index in inSig of the first sample to
- /// filter.
- ///
- ///
- /// This is the number of samples in the input signal
- /// to filter.
- ///
- ///
- /// This is the step, or interleave factor, of the
- /// input signal samples in the inSig array.
- ///
- ///
- /// This is the array where the low-pass output
- /// signal is placed.
- ///
- ///
- /// This is the index in lowSig of the element where
- /// to put the first low-pass output sample.
- ///
- ///
- /// This is the step, or interleave factor, of the
- /// low-pass output samples in the lowSig array.
- ///
- ///
- /// This is the array where the high-pass output
- /// signal is placed.
- ///
- ///
- /// This is the index in highSig of the element where
- /// to put the first high-pass output sample.
- ///
- ///
- /// This is the step, or interleave factor, of the
- /// high-pass output samples in the highSig array.
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- public abstract void analyze_hpf(int[] inSig, int inOff, int inLen, int inStep, int[] lowSig, int lowOff, int lowStep, int[] highSig, int highOff, int highStep);
- /// The general version of the analyze_hpf() method, it just calls the
- /// specialized version. See the description of the analyze_hpf()
- /// method of the AnWTFilter class for more details.
- ///
- ///
- /// This is the array that contains the input
- /// signal. It must be an int[].
- ///
- ///
- /// This is the index in inSig of the first sample to
- /// filter.
- ///
- ///
- /// This is the number of samples in the input signal
- /// to filter.
- ///
- ///
- /// This is the step, or interleave factor, of the
- /// input signal samples in the inSig array.
- ///
- ///
- /// This is the array where the low-pass output
- /// signal is placed. It must be an int[].
- ///
- ///
- /// This is the index in lowSig of the element where
- /// to put the first low-pass output sample.
- ///
- ///
- /// This is the step, or interleave factor, of the
- /// low-pass output samples in the lowSig array.
- ///
- ///
- /// This is the array where the high-pass output
- /// signal is placed. It must be an int[].
- ///
- ///
- /// This is the index in highSig of the element where
- /// to put the first high-pass output sample.
- ///
- ///
- /// This is the step, or interleave factor, of the
- /// high-pass output samples in the highSig array.
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
-
- public override void analyze_hpf(System.Object inSig, int inOff, int inLen, int inStep, System.Object lowSig, int lowOff, int lowStep, System.Object highSig, int highOff, int highStep)
- {
-
- analyze_hpf((int[])inSig, inOff, inLen, inStep, (int[])lowSig, lowOff, lowStep, (int[])highSig, highOff, highStep);
- }
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/wavelet/analysis/AnWTFilterIntLift5x3.cs b/CSJ2K/j2k/wavelet/analysis/AnWTFilterIntLift5x3.cs
deleted file mode 100644
index ef481338..00000000
--- a/CSJ2K/j2k/wavelet/analysis/AnWTFilterIntLift5x3.cs
+++ /dev/null
@@ -1,604 +0,0 @@
-/*
-* CVS identifier:
-*
-* $Id: AnWTFilterIntLift5x3.java,v 1.15 2001/08/02 11:19:27 grosbois Exp $
-*
-* Class: AnWTFilterIntLift5x3
-*
-* Description: An analyzing wavelet filter implementing the
-* lifting 5x3 transform.
-*
-*
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-* */
-namespace CSJ2K.j2k.wavelet.analysis
-{
-
- /// This class inherits from the analysis wavelet filter definition for int
- /// data. It implements the forward wavelet transform specifically for the 5x3
- /// filter. The implementation is based on the lifting scheme.
- ///
- /// See the AnWTFilter class for details such as normalization, how to split
- /// odd-length signals, etc. In particular, this method assumes that the
- /// low-pass coefficient is computed first.
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- public class AnWTFilterIntLift5x3 : AnWTFilterInt
- {
- /// Returns the negative support of the low-pass analysis filter. That is
- /// the number of taps of the filter in the negative direction.
- ///
- ///
- /// 2
- ///
- ///
- override public int AnLowNegSupport
- {
- get
- {
- return 2;
- }
-
- }
- /// Returns the positive support of the low-pass analysis filter. That is
- /// the number of taps of the filter in the negative direction.
- ///
- ///
- /// The number of taps of the low-pass analysis filter in the
- /// positive direction
- ///
- ///
- override public int AnLowPosSupport
- {
- get
- {
- return 2;
- }
-
- }
- /// Returns the negative support of the high-pass analysis filter. That is
- /// the number of taps of the filter in the negative direction.
- ///
- ///
- /// The number of taps of the high-pass analysis filter in
- /// the negative direction
- ///
- ///
- override public int AnHighNegSupport
- {
- get
- {
- return 1;
- }
-
- }
- /// Returns the positive support of the high-pass analysis filter. That is
- /// the number of taps of the filter in the negative direction.
- ///
- ///
- /// The number of taps of the high-pass analysis filter in the
- /// positive direction
- ///
- ///
- override public int AnHighPosSupport
- {
- get
- {
- return 1;
- }
-
- }
- /// Returns the negative support of the low-pass synthesis filter. That is
- /// the number of taps of the filter in the negative direction.
- ///
- ///
- /// The number of taps of the low-pass synthesis filter in the
- /// negative direction
- ///
- ///
- override public int SynLowNegSupport
- {
- get
- {
- return 1;
- }
-
- }
- /// Returns the positive support of the low-pass synthesis filter. That is
- /// the number of taps of the filter in the negative direction.
- ///
- ///
- /// The number of taps of the low-pass synthesis filter in
- /// the positive direction
- ///
- ///
- override public int SynLowPosSupport
- {
- get
- {
- return 1;
- }
-
- }
- /// Returns the negative support of the high-pass synthesis filter. That is
- /// the number of taps of the filter in the negative direction.
- ///
- ///
- /// The number of taps of the high-pass synthesis filter in the
- /// negative direction
- ///
- ///
- override public int SynHighNegSupport
- {
- get
- {
- return 2;
- }
-
- }
- /// Returns the positive support of the high-pass synthesis filter. That is
- /// the number of taps of the filter in the negative direction.
- ///
- ///
- /// The number of taps of the high-pass synthesis filter in the
- /// positive direction
- ///
- ///
- override public int SynHighPosSupport
- {
- get
- {
- return 2;
- }
-
- }
- /// Returns the implementation type of this filter, as defined in this
- /// class, such as WT_FILTER_INT_LIFT, WT_FILTER_FLOAT_LIFT,
- /// WT_FILTER_FLOAT_CONVOL.
- ///
- ///
- /// WT_FILTER_INT_LIFT.
- ///
- ///
- override public int ImplType
- {
- get
- {
- return CSJ2K.j2k.wavelet.WaveletFilter_Fields.WT_FILTER_INT_LIFT;
- }
-
- }
- /// Returns the reversibility of the filter. A filter is considered
- /// reversible if it is suitable for lossless coding.
- ///
- ///
- /// true since the 5x3 is reversible, provided the appropriate
- /// rounding is performed.
- ///
- ///
- override public bool Reversible
- {
- get
- {
- return true;
- }
-
- }
- /// Returns the type of filter used according to the FilterTypes interface
- /// (W5x3).
- ///
- ///
- ///
- ///
- ///
- /// The filter type.
- ///
- ///
- override public int FilterType
- {
- get
- {
- return CSJ2K.j2k.wavelet.FilterTypes_Fields.W5X3;
- }
-
- }
-
- /// The low-pass synthesis filter of the 5x3 wavelet transform
- //UPGRADE_NOTE: Final was removed from the declaration of 'LPSynthesisFilter'. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- private static readonly float[] LPSynthesisFilter = new float[] { 0.5f, 1f, 0.5f };
-
- /// The high-pass synthesis filter of the 5x3 wavelet transform
- //UPGRADE_NOTE: Final was removed from the declaration of 'HPSynthesisFilter'. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- private static readonly float[] HPSynthesisFilter = new float[] { -0.125f, -0.25f, 0.75f, -0.25f, -0.125f };
-
- /// An implementation of the analyze_lpf() method that works on int data,
- /// for the forward 5x3 wavelet transform using the lifting scheme. See the
- /// general description of the analyze_lpf() method in the AnWTFilter class
- /// for more details.
- ///
- /// The coefficients of the first lifting step are [-1/2 1 -1/2].
- ///
- /// The coefficients of the second lifting step are [1/4 1 1/4].
- ///
- ///
- /// This is the array that contains the input signal.
- ///
- ///
- /// This is the index in inSig of the first sample to filter.
- ///
- ///
- /// This is the number of samples in the input signal to
- /// filter.
- ///
- ///
- /// This is the step, or interleave factor, of the input
- /// signal samples in the inSig array.
- ///
- ///
- /// This is the array where the low-pass output signal is
- /// placed.
- ///
- ///
- /// This is the index in lowSig of the element where to put
- /// the first low-pass output sample.
- ///
- ///
- /// This is the step, or interleave factor, of the low-pass
- /// output samples in the lowSig array.
- ///
- ///
- /// This is the array where the high-pass output signal is
- /// placed.
- ///
- ///
- /// This is the index in highSig of the element where to put
- /// the first high-pass output sample.
- ///
- ///
- /// This is the step, or interleave factor, of the
- /// high-pass output samples in the highSig array.
- ///
- ///
- public override void analyze_lpf(int[] inSig, int inOff, int inLen, int inStep, int[] lowSig, int lowOff, int lowStep, int[] highSig, int highOff, int highStep)
- {
- int i;
- int iStep = 2 * inStep; //Subsampling in inSig
- int ik; //Indexing inSig
- int lk; //Indexing lowSig
- int hk; //Indexing highSig
-
- /* Generate high frequency subband */
-
- //Initialize counters
- ik = inOff + inStep;
- hk = highOff;
-
- //Apply first lifting step to each "inner" sample.
- for (i = 1; i < inLen - 1; i += 2)
- {
- highSig[hk] = inSig[ik] - ((inSig[ik - inStep] + inSig[ik + inStep]) >> 1);
-
- ik += iStep;
- hk += highStep;
- }
-
- //Handle head boundary effect if input signal has even length.
- if (inLen % 2 == 0)
- {
- highSig[hk] = inSig[ik] - ((2 * inSig[ik - inStep]) >> 1);
- }
-
- /* Generate low frequency subband */
-
- //Initialize counters
- ik = inOff;
- lk = lowOff;
- hk = highOff;
-
- if (inLen > 1)
- {
- lowSig[lk] = inSig[ik] + ((highSig[hk] + 1) >> 1);
- }
- else
- {
- lowSig[lk] = inSig[ik];
- }
-
- ik += iStep;
- lk += lowStep;
- hk += highStep;
-
- //Apply lifting step to each "inner" sample.
- for (i = 2; i < inLen - 1; i += 2)
- {
- lowSig[lk] = inSig[ik] + ((highSig[hk - highStep] + highSig[hk] + 2) >> 2);
-
- ik += iStep;
- lk += lowStep;
- hk += highStep;
- }
-
- //Handle head boundary effect if input signal has odd length.
- if (inLen % 2 == 1)
- {
- if (inLen > 2)
- {
- lowSig[lk] = inSig[ik] + ((2 * highSig[hk - highStep] + 2) >> 2);
- }
- }
- }
-
- /// An implementation of the analyze_hpf() method that works on int data,
- /// for the forward 5x3 wavelet transform using the lifting scheme. See the
- /// general description of the analyze_hpf() method in the AnWTFilter class
- /// for more details.
- ///
- /// The coefficients of the first lifting step are [-1/2 1 -1/2].
- ///
- /// The coefficients of the second lifting step are [1/4 1 1/4].
- ///
- ///
- /// This is the array that contains the input signal.
- ///
- ///
- /// This is the index in inSig of the first sample to filter.
- ///
- ///
- /// This is the number of samples in the input signal to
- /// filter.
- ///
- ///
- /// This is the step, or interleave factor, of the input
- /// signal samples in the inSig array.
- ///
- ///
- /// This is the array where the low-pass output signal is
- /// placed.
- ///
- ///
- /// This is the index in lowSig of the element where to put
- /// the first low-pass output sample.
- ///
- ///
- /// This is the step, or interleave factor, of the low-pass
- /// output samples in the lowSig array.
- ///
- ///
- /// This is the array where the high-pass output signal is
- /// placed.
- ///
- ///
- /// This is the index in highSig of the element where to put
- /// the first high-pass output sample.
- ///
- ///
- /// This is the step, or interleave factor, of the
- /// high-pass output samples in the highSig array.
- ///
- ///
- ///
- ///
- ///
- public override void analyze_hpf(int[] inSig, int inOff, int inLen, int inStep, int[] lowSig, int lowOff, int lowStep, int[] highSig, int highOff, int highStep)
- {
- int i;
- int iStep = 2 * inStep; //Subsampling in inSig
- int ik; //Indexing inSig
- int lk; //Indexing lowSig
- int hk; //Indexing highSig
-
- /* Generate high frequency subband */
-
- //Initialize counters
- ik = inOff;
- hk = highOff;
-
- if (inLen > 1)
- {
- // apply a symmetric extension.
- highSig[hk] = inSig[ik] - inSig[ik + inStep];
- }
- else
- {
- // Normalize for Nyquist gain
- highSig[hk] = inSig[ik] << 1;
- }
-
- ik += iStep;
- hk += highStep;
-
- //Apply first lifting step to each "inner" sample.
- if (inLen > 3)
- {
- for (i = 2; i < inLen - 1; i += 2)
- {
- highSig[hk] = inSig[ik] - ((inSig[ik - inStep] + inSig[ik + inStep]) >> 1);
- ik += iStep;
- hk += highStep;
- }
- }
-
- //If input signal has odd length then we perform the lifting step
- //i.e. apply a symmetric extension.
- if (inLen % 2 == 1 && inLen > 1)
- {
- highSig[hk] = inSig[ik] - inSig[ik - inStep];
- }
-
- /* Generate low frequency subband */
-
- //Initialize counters
- ik = inOff + inStep;
- lk = lowOff;
- hk = highOff;
-
- for (i = 1; i < inLen - 1; i += 2)
- {
-
- lowSig[lk] = inSig[ik] + ((highSig[hk] + highSig[hk + highStep] + 2) >> 2);
-
- ik += iStep;
- lk += lowStep;
- hk += highStep;
- }
-
- if (inLen > 1 && inLen % 2 == 0)
- {
- // apply a symmetric extension.
- lowSig[lk] = inSig[ik] + ((2 * highSig[hk] + 2) >> 2);
- }
- }
-
- /// Returns the time-reversed low-pass synthesis waveform of the filter,
- /// which is the low-pass filter. This is the time-reversed impulse
- /// response of the low-pass synthesis filter. It is used to calculate the
- /// L2-norm of the synthesis basis functions for a particular subband (also
- /// called energy weight).
- ///
- /// The returned array may not be modified (i.e. a reference to the
- /// internal array may be returned by the implementation of this
- /// method).
- ///
- ///
- /// The time-reversed low-pass synthesis waveform of the filter.
- ///
- ///
- public override float[] getLPSynthesisFilter()
- {
- return LPSynthesisFilter;
- }
-
- /// Returns the time-reversed high-pass synthesis waveform of the filter,
- /// which is the high-pass filter. This is the time-reversed impulse
- /// response of the high-pass synthesis filter. It is used to calculate the
- /// L2-norm of the synthesis basis functions for a particular subband (also
- /// called energy weight).
- ///
- /// The returned array may not be modified (i.e. a reference to the
- /// internal array may be returned by the implementation of this
- /// method).
- ///
- ///
- /// The time-reversed high-pass synthesis waveform of the filter.
- ///
- ///
- public override float[] getHPSynthesisFilter()
- {
- return HPSynthesisFilter;
- }
-
- /// Returns true if the wavelet filter computes or uses the same "inner"
- /// subband coefficient as the full frame wavelet transform, and false
- /// otherwise. In particular, for block based transforms with reduced
- /// overlap, this method should return false. The term "inner" indicates
- /// that this applies only with respect to the coefficient that are not
- /// affected by image boundaries processings such as symmetric extension,
- /// since there is not reference method for this.
- ///
- /// The result depends on the length of the allowed overlap when
- /// compared to the overlap required by the wavelet filter. It also depends
- /// on how overlap processing is implemented in the wavelet filter.
- ///
- ///
- /// This is the number of samples in the input signal
- /// before the first sample to filter that can be used for overlap.
- ///
- ///
- /// This is the number of samples in the input signal
- /// after the last sample to filter that can be used for overlap.
- ///
- ///
- /// This is the lenght of the input signal to filter.The
- /// required number of samples in the input signal after the last sample
- /// depends on the length of the input signal.
- ///
- ///
- /// true if both overlaps are greater than 2, and correct
- /// processing is applied in the analyze() method.
- ///
- ///
- public override bool isSameAsFullWT(int tailOvrlp, int headOvrlp, int inLen)
- {
-
- //If the input signal has even length.
- if (inLen % 2 == 0)
- {
- if (tailOvrlp >= 2 && headOvrlp >= 1)
- return true;
- else
- return false;
- }
- //Else if the input signal has odd length.
- else
- {
- if (tailOvrlp >= 2 && headOvrlp >= 2)
- return true;
- else
- return false;
- }
- }
-
- /// Tests if the 'obj' object is the same filter as this one. Two filters
- /// are the same if the same filter code should be output for both filters
- /// by the encodeFilterCode() method.
- ///
- /// Currently the implementation of this method only tests if 'obj' is
- /// also of the class AnWTFilterIntLift5x3.
- ///
- ///
- /// object against which to test inequality.
- ///
- ///
- public override bool Equals(System.Object obj)
- {
- // To speed up test, first test for reference equality
- return obj == this || obj is AnWTFilterIntLift5x3;
- }
-
- /// Debugging method
- public override System.String ToString()
- {
- return "w5x3";
- }
- //UPGRADE_NOTE: The following method implementation was automatically added to preserve functionality. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1306'"
- public override int GetHashCode()
- {
- return base.GetHashCode();
- }
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/wavelet/analysis/AnWTFilterSpec.cs b/CSJ2K/j2k/wavelet/analysis/AnWTFilterSpec.cs
deleted file mode 100644
index ecc6ddf7..00000000
--- a/CSJ2K/j2k/wavelet/analysis/AnWTFilterSpec.cs
+++ /dev/null
@@ -1,554 +0,0 @@
-/*
-* CVS identifier:
-*
-* $Id: AnWTFilterSpec.java,v 1.27 2001/05/08 16:11:37 grosbois Exp $
-*
-* Class: AnWTFilterSpec
-*
-* Description: Analysis filters specification
-*
-*
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-* */
-using CSJ2K.j2k.quantization;
-using CSJ2K.j2k.util;
-namespace CSJ2K.j2k.wavelet.analysis
-{
-
- /// This class extends ModuleSpec class for analysis filters specification
- /// holding purpose.
- ///
- ///
- ///
- ///
- ///
- public class AnWTFilterSpec : ModuleSpec
- {
-
- /// The reversible default filter
- private const System.String REV_FILTER_STR = "w5x3";
-
- /// The non-reversible default filter
- private const System.String NON_REV_FILTER_STR = "w9x7";
-
- /// Constructs a new 'AnWTFilterSpec' for the specified number of
- /// components and tiles.
- ///
- ///
- /// The number of tiles
- ///
- ///
- /// The number of components
- ///
- ///
- /// the type of the specification module i.e. tile specific,
- /// component specific or both.
- ///
- ///
- /// Quantization specifications
- ///
- ///
- /// The ParameterList
- ///
- ///
- public AnWTFilterSpec(int nt, int nc, byte type, QuantTypeSpec qts, ParameterList pl) : base(nt, nc, type)
- {
-
- // Check parameters
- pl.checkList(AnWTFilter.OPT_PREFIX, CSJ2K.j2k.util.ParameterList.toNameArray(AnWTFilter.ParameterInfo));
-
- System.String param = pl.getParameter("Ffilters");
- bool isFilterSpecified = true;
-
- // No parameter specified
- if (param == null)
- {
- isFilterSpecified = false;
-
- // If lossless compression, uses the reversible filters in each
- // tile-components
- if (pl.getBooleanParameter("lossless"))
- {
- setDefault(parseFilters(REV_FILTER_STR));
- return;
- }
-
- // If no filter is specified through the command-line, use
- // REV_FILTER_STR or NON_REV_FILTER_STR according to the
- // quantization type
- for (int t = nt - 1; t >= 0; t--)
- {
- for (int c = nc - 1; c >= 0; c--)
- {
- switch (qts.getSpecValType(t, c))
- {
-
- case SPEC_DEF:
- if (getDefault() == null)
- {
- if (pl.getBooleanParameter("lossless"))
- setDefault(parseFilters(REV_FILTER_STR));
- if (((System.String)qts.getDefault()).Equals("reversible"))
- {
- setDefault(parseFilters(REV_FILTER_STR));
- }
- else
- {
- setDefault(parseFilters(NON_REV_FILTER_STR));
- }
- }
- specValType[t][c] = SPEC_DEF;
- break;
-
- case SPEC_COMP_DEF:
- if (!isCompSpecified(c))
- {
- if (((System.String)qts.getCompDef(c)).Equals("reversible"))
- {
- setCompDef(c, parseFilters(REV_FILTER_STR));
- }
- else
- {
- setCompDef(c, parseFilters(NON_REV_FILTER_STR));
- }
- }
- specValType[t][c] = SPEC_COMP_DEF;
- break;
-
- case SPEC_TILE_DEF:
- if (!isTileSpecified(t))
- {
- if (((System.String)qts.getTileDef(t)).Equals("reversible"))
- {
- setTileDef(t, parseFilters(REV_FILTER_STR));
- }
- else
- {
- setTileDef(t, parseFilters(NON_REV_FILTER_STR));
- }
- }
- specValType[t][c] = SPEC_TILE_DEF;
- break;
-
- case SPEC_TILE_COMP:
- if (!isTileCompSpecified(t, c))
- {
- if (((System.String)qts.getTileCompVal(t, c)).Equals("reversible"))
- {
- setTileCompVal(t, c, parseFilters(REV_FILTER_STR));
- }
- else
- {
- setTileCompVal(t, c, parseFilters(NON_REV_FILTER_STR));
- }
- }
- specValType[t][c] = SPEC_TILE_COMP;
- break;
-
- default:
- throw new System.ArgumentException("Unsupported " + "specification " + "type");
-
- }
- }
- }
- return;
- }
-
- // Parse argument
- SupportClass.Tokenizer stk = new SupportClass.Tokenizer(param);
- System.String word; // current word
- byte curSpecType = SPEC_DEF; // Specification type of the
- // current parameter
- bool[] tileSpec = null; // Tiles concerned by the specification
- bool[] compSpec = null; // Components concerned by the specification
- AnWTFilter[][] filter;
-
- while (stk.HasMoreTokens())
- {
- word = stk.NextToken();
-
- switch (word[0])
- {
-
- case 't':
- // Tiles specification
- case 'T': // Tiles specification
- tileSpec = parseIdx(word, nTiles);
- if (curSpecType == SPEC_COMP_DEF)
- curSpecType = SPEC_TILE_COMP;
- else
- curSpecType = SPEC_TILE_DEF;
- break;
-
- case 'c':
- // Components specification
- case 'C': // Components specification
- compSpec = parseIdx(word, nComp);
- if (curSpecType == SPEC_TILE_DEF)
- curSpecType = SPEC_TILE_COMP;
- else
- curSpecType = SPEC_COMP_DEF;
- break;
-
- case 'w':
- // WT filters specification
- case 'W': // WT filters specification
- if (pl.getBooleanParameter("lossless") && word.ToUpper().Equals("w9x7".ToUpper()))
- {
- throw new System.ArgumentException("Cannot use non " + "reversible " + "wavelet transform with" + " '-lossless' option");
- }
-
- filter = parseFilters(word);
- if (curSpecType == SPEC_DEF)
- {
- setDefault(filter);
- }
- else if (curSpecType == SPEC_TILE_DEF)
- {
- for (int i = tileSpec.Length - 1; i >= 0; i--)
- if (tileSpec[i])
- {
- setTileDef(i, filter);
- }
- }
- else if (curSpecType == SPEC_COMP_DEF)
- {
- for (int i = compSpec.Length - 1; i >= 0; i--)
- if (compSpec[i])
- {
- setCompDef(i, filter);
- }
- }
- else
- {
- for (int i = tileSpec.Length - 1; i >= 0; i--)
- {
- for (int j = compSpec.Length - 1; j >= 0; j--)
- {
- if (tileSpec[i] && compSpec[j])
- {
- setTileCompVal(i, j, filter);
- }
- }
- }
- }
-
- // Re-initialize
- curSpecType = SPEC_DEF;
- tileSpec = null;
- compSpec = null;
- break;
-
-
- default:
- throw new System.ArgumentException("Bad construction for " + "parameter: " + word);
-
- }
- }
-
- // Check that default value has been specified
- if (getDefault() == null)
- {
- int ndefspec = 0;
- for (int t = nt - 1; t >= 0; t--)
- {
- for (int c = nc - 1; c >= 0; c--)
- {
- if (specValType[t][c] == SPEC_DEF)
- {
- ndefspec++;
- }
- }
- }
-
- // If some tile-component have received no specification, it takes
- // the default value defined in ParameterList
- if (ndefspec != 0)
- {
- if (((System.String)qts.getDefault()).Equals("reversible"))
- setDefault(parseFilters(REV_FILTER_STR));
- else
- setDefault(parseFilters(NON_REV_FILTER_STR));
- }
- else
- {
- // All tile-component have been specified, takes the first
- // tile-component value as default.
- setDefault(getTileCompVal(0, 0));
- switch (specValType[0][0])
- {
-
- case SPEC_TILE_DEF:
- for (int c = nc - 1; c >= 0; c--)
- {
- if (specValType[0][c] == SPEC_TILE_DEF)
- specValType[0][c] = SPEC_DEF;
- }
- tileDef[0] = null;
- break;
-
- case SPEC_COMP_DEF:
- for (int t = nt - 1; t >= 0; t--)
- {
- if (specValType[t][0] == SPEC_COMP_DEF)
- specValType[t][0] = SPEC_DEF;
- }
- compDef[0] = null;
- break;
-
- case SPEC_TILE_COMP:
- specValType[0][0] = SPEC_DEF;
- tileCompVal["t0c0"] = null;
- break;
- }
- }
- }
-
- // Check consistency between filter and quantization type
- // specification
- for (int t = nt - 1; t >= 0; t--)
- {
- for (int c = nc - 1; c >= 0; c--)
- {
- // Reversible quantization
- if (((System.String)qts.getTileCompVal(t, c)).Equals("reversible"))
- {
- // If filter is reversible, it is OK
- if (isReversible(t, c))
- continue;
-
- // If no filter has been defined, use reversible filter
- if (!isFilterSpecified)
- {
- setTileCompVal(t, c, parseFilters(REV_FILTER_STR));
- }
- else
- {
- // Non reversible filter specified -> Error
- throw new System.ArgumentException("Filter of " + "tile-component" + " (" + t + "," + c + ") does" + " not allow " + "reversible " + "quantization. " + "Specify '-Qtype " + "expounded' or " + "'-Qtype derived'" + "in " + "the command line.");
- }
- }
- else
- {
- // No reversible quantization
- // No reversible filter -> OK
- if (!isReversible(t, c))
- continue;
-
- // If no filter has been specified, use non-reversible
- // filter
- if (!isFilterSpecified)
- {
- setTileCompVal(t, c, parseFilters(NON_REV_FILTER_STR));
- }
- else
- {
- // Reversible filter specified -> Error
- throw new System.ArgumentException("Filter of " + "tile-component" + " (" + t + "," + c + ") does" + " not allow " + "non-reversible " + "quantization. " + "Specify '-Qtype " + "reversible' in " + "the command line");
- }
- }
- }
- }
- }
-
- /// Parse filters from the given word
- ///
- ///
- /// String to parse
- ///
- ///
- /// Analysis wavelet filter (first dimension: by direction,
- /// second dimension: by decomposition levels)
- ///
- private AnWTFilter[][] parseFilters(System.String word)
- {
- AnWTFilter[][] filt = new AnWTFilter[2][];
- for (int i = 0; i < 2; i++)
- {
- filt[i] = new AnWTFilter[1];
- }
- if (word.ToUpper().Equals("w5x3".ToUpper()))
- {
- filt[0][0] = new AnWTFilterIntLift5x3();
- filt[1][0] = new AnWTFilterIntLift5x3();
- return filt;
- }
- else if (word.ToUpper().Equals("w9x7".ToUpper()))
- {
- filt[0][0] = new AnWTFilterFloatLift9x7();
- filt[1][0] = new AnWTFilterFloatLift9x7();
- return filt;
- }
- else
- {
- throw new System.ArgumentException("Non JPEG 2000 part I filter: " + word);
- }
- }
-
- /// Returns the data type used by the filters in this object, as defined in
- /// the 'DataBlk' interface for specified tile-component.
- ///
- ///
- /// Tile index
- ///
- ///
- /// Component index
- ///
- ///
- /// The data type of the filters in this object
- ///
- ///
- ///
- ///
- ///
- public virtual int getWTDataType(int t, int c)
- {
- AnWTFilter[][] an = (AnWTFilter[][])getSpec(t, c);
- return an[0][0].DataType;
- }
-
- /// Returns the horizontal analysis filters to be used in component 'n' and
- /// tile 't'.
- ///
- /// The horizontal analysis filters are returned in an array of
- /// AnWTFilter. Each element contains the horizontal filter for each
- /// resolution level starting with resolution level 1 (i.e. the analysis
- /// filter to go from resolution level 1 to resolution level 0). If there
- /// are less elements than the maximum resolution level, then the last
- /// element is assumed to be repeated.
- ///
- ///
- /// The tile index, in raster scan order
- ///
- ///
- /// The component index.
- ///
- ///
- /// The array of horizontal analysis filters for component 'n' and
- /// tile 't'.
- ///
- ///
- public virtual AnWTFilter[] getHFilters(int t, int c)
- {
- AnWTFilter[][] an = (AnWTFilter[][])getSpec(t, c);
- return an[0];
- }
-
- /// Returns the vertical analysis filters to be used in component 'n' and
- /// tile 't'.
- ///
- /// The vertical analysis filters are returned in an array of
- /// AnWTFilter. Each element contains the vertical filter for each
- /// resolution level starting with resolution level 1 (i.e. the analysis
- /// filter to go from resolution level 1 to resolution level 0). If there
- /// are less elements than the maximum resolution level, then the last
- /// element is assumed to be repeated.
- ///
- ///
- /// The tile index, in raster scan order
- ///
- ///
- /// The component index.
- ///
- ///
- /// The array of horizontal analysis filters for component 'n' and
- /// tile 't'.
- ///
- ///
- public virtual AnWTFilter[] getVFilters(int t, int c)
- {
- AnWTFilter[][] an = (AnWTFilter[][])getSpec(t, c);
- return an[1];
- }
-
- /// Debugging method
- public override System.String ToString()
- {
- System.String str = "";
- AnWTFilter[][] an;
-
- str += ("nTiles=" + nTiles + "\nnComp=" + nComp + "\n\n");
-
- for (int t = 0; t < nTiles; t++)
- {
- for (int c = 0; c < nComp; c++)
- {
- an = (AnWTFilter[][])getSpec(t, c);
-
- str += ("(t:" + t + ",c:" + c + ")\n");
-
- // Horizontal filters
- str += "\tH:";
- for (int i = 0; i < an[0].Length; i++)
- {
- //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Object.toString' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'"
- str += (" " + an[0][i]);
- }
- // Horizontal filters
- str += "\n\tV:";
- for (int i = 0; i < an[1].Length; i++)
- {
- //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Object.toString' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'"
- str += (" " + an[1][i]);
- }
- str += "\n";
- }
- }
-
- return str;
- }
-
- /// Check the reversibility of filters contained is the given
- /// tile-component.
- ///
- ///
- /// The index of the tile
- ///
- ///
- /// The index of the component
- ///
- ///
- public virtual bool isReversible(int t, int c)
- {
- // Note: no need to buffer the result since this method is
- // normally called once per tile-component.
- AnWTFilter[] hfilter = getHFilters(t, c), vfilter = getVFilters(t, c);
-
- // As soon as a filter is not reversible, false can be returned
- for (int i = hfilter.Length - 1; i >= 0; i--)
- if (!hfilter[i].Reversible || !vfilter[i].Reversible)
- return false;
- return true;
- }
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/wavelet/analysis/CBlkWTData.cs b/CSJ2K/j2k/wavelet/analysis/CBlkWTData.cs
deleted file mode 100644
index 3805d4b5..00000000
--- a/CSJ2K/j2k/wavelet/analysis/CBlkWTData.cs
+++ /dev/null
@@ -1,224 +0,0 @@
-/*
-* CVS identifier:
-*
-* $Id: CBlkWTData.java,v 1.18 2001/08/15 17:15:14 grosbois Exp $
-*
-* Class: CBlkWTData
-*
-* Description: Storage for code-blocks of WT data.
-*
-*
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-* */
-using CSJ2K.j2k.image;
-namespace CSJ2K.j2k.wavelet.analysis
-{
-
- /// This is a generic abstract class to store a code-block of wavelet data,
- /// quantized or not. This class does not have the notion of
- /// components. Therefore, it should be used for data from a single
- /// component. Subclasses should implement the different types of storage
- /// (int, float, etc.).
- ///
- /// The data is always stored in one array, of the type matching the data
- /// type (i.e. for 'int' it's an 'int[]'). The data should be stored in the
- /// array in standard scan-line order. That is the samples go from the top-left
- /// corner of the code-block to the lower-right corner by line and then
- /// column.
- ///
- /// The member variable 'offset' gives the index in the array of the first
- /// data element (i.e. the top-left coefficient). The member variable 'scanw'
- /// gives the width of the scan that is used to store the data, that can be
- /// different from the width of the block. Element '(x,y)' of the code-block
- /// (i.e. '(0,0)' is the top-left coefficient), will appear at position
- /// 'offset+y*scanw+x' in the array of data.
- ///
- /// The classes CBlkWTDataInt and CBlkWTDataFloat provide
- /// implementations for int and float types respectively.
- ///
- /// The types of data are the same as those defined by the 'DataBlk'
- /// class.
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- public abstract class CBlkWTData
- {
- /// Returns the data type of the CBlkWTData object, as defined in
- /// the DataBlk class.
- ///
- ///
- /// The data type of the object, as defined in the DataBlk class.
- ///
- ///
- ///
- ///
- ///
- public abstract int DataType { get; }
- //UPGRADE_NOTE: Respective javadoc comments were merged. It should be changed in order to comply with .NET documentation conventions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1199'"
- /// Returns the array containing the data, or null if there is no data. The
- /// returned array is of the type returned by getDataType() (e.g.,
- /// for TYPE_INT, it is a int[]).
- ///
- /// Each implementing class should provide a type specific equivalent
- /// method (e.g., getDataInt() in DataBlkInt) which
- /// returns an array of the correct type explicitely and not through an
- /// Object.
- ///
- ///
- /// The array containing the data, or null if there is no
- /// data.
- ///
- ///
- ///
- ///
- ///
- /// Sets the data array to the specified one. The type of the specified
- /// data array must match the one returned by getDataType() (e.g.,
- /// for TYPE_INT, it should be a int[]). If the wrong
- /// type of array is given a ClassCastException will be thrown.
- ///
- /// The size of the array is not necessarily checked for consistency
- /// with w and h or any other fields.
- ///
- /// Each implementing class should provide a type specific equivalent
- /// method (e.g., setDataInt() in DataBlkInt) which takes
- /// an array of the correct type explicetely and not through an
- /// Object.
- ///
- ///
- /// The new data array to use
- ///
- ///
- ///
- ///
- ///
- public abstract System.Object Data { get; set; }
-
- /// The horizontal coordinate of the upper-left corner of the code-block
- public int ulx;
-
- /// The vertical coordinate of the upper left corner of the code-block
- public int uly;
-
- /// The horizontal index of the code-block, within the subband
- public int n;
-
- /// The vertical index of the code-block, within the subband
- public int m;
-
- /// The subband in which this code-block is found
- public SubbandAn sb;
-
- /// The width of the code-block
- public int w;
-
- /// The height of the code-block
- public int h;
-
- /// The offset in the array of the top-left coefficient
- public int offset;
-
- /// The width of the scanlines used to store the data in the array
- public int scanw;
-
- /// The number of magnitude bits in the integer representation. This is
- /// only used for quantized wavelet data.
- ///
- public int magbits;
-
- /// The WMSE scaling factor (multiplicative) to apply to the distortion
- /// measures of the data of this code-block. By default it is 1.
- ///
- public float wmseScaling = 1f;
-
- /// The value by which the absolute value of the data has to be divided in
- /// order to get the real absolute value. This value is useful to obtain
- /// the complement of 2 representation of a coefficient that is currently
- /// using the sign-magnitude representation.
- ///
- public double convertFactor = 1.0;
-
- /// The quantization step size of the code-block. The value is updated by
- /// the quantizer module
- ///
- public double stepSize = 1.0;
-
- /// Number of ROI coefficients in the code-block
- public int nROIcoeff = 0;
-
- /// Number of ROI magnitude bit-planes
- public int nROIbp = 0;
-
- /// Returns a string of informations about the DataBlk
- ///
- ///
- /// Block dimensions and progressiveness in a string
- ///
- ///
- public override System.String ToString()
- {
- System.String typeString = "";
- switch (DataType)
- {
-
- case DataBlk.TYPE_BYTE:
- typeString = "Unsigned Byte";
- break;
-
- case DataBlk.TYPE_SHORT:
- typeString = "Short";
- break;
-
- case DataBlk.TYPE_INT:
- typeString = "Integer";
- break;
-
- case DataBlk.TYPE_FLOAT:
- typeString = "Float";
- break;
- }
-
- return "ulx=" + ulx + ", uly=" + uly + ", idx=(" + m + "," + n + "), w=" + w + ", h=" + h + ", off=" + offset + ", scanw=" + scanw + ", wmseScaling=" + wmseScaling + ", convertFactor=" + convertFactor + ", stepSize=" + stepSize + ", type=" + typeString + ", magbits=" + magbits + ", nROIcoeff=" + nROIcoeff + ", nROIbp=" + nROIbp;
- }
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/wavelet/analysis/CBlkWTDataFloat.cs b/CSJ2K/j2k/wavelet/analysis/CBlkWTDataFloat.cs
deleted file mode 100644
index 75065a18..00000000
--- a/CSJ2K/j2k/wavelet/analysis/CBlkWTDataFloat.cs
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
-* CVS identifier:
-*
-* $Id: CBlkWTDataFloat.java,v 1.11 2001/08/15 17:18:43 grosbois Exp $
-*
-* Class: CBlkWTDataFloat
-*
-* Description: Implementation of CBlkWTData for 'float' data
-*
-*
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-* */
-using CSJ2K.j2k.image;
-namespace CSJ2K.j2k.wavelet.analysis
-{
-
- /// This is an implementation of the 'CBlkWTData' abstract class for 32 bit
- /// floating point data (float).
- ///
- /// The methods in this class are declared final, so that they can be
- /// inlined by inlining compilers.
- ///
- ///
- ///
- ///
- ///
- public class CBlkWTDataFloat : CBlkWTData
- {
- /// Returns the identifier of this data type, TYPE_FLOAT, as
- /// defined in DataBlk.
- ///
- ///
- /// The type of data stored. Always DataBlk.TYPE_FLOAT
- ///
- ///
- ///
- ///
- ///
- override public int DataType
- {
- get
- {
- return DataBlk.TYPE_FLOAT;
- }
-
- }
- //UPGRADE_NOTE: Respective javadoc comments were merged. It should be changed in order to comply with .NET documentation conventions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1199'"
- /// Returns the array containing the data, or null if there is no data
- /// array. The returned array is a float array.
- ///
- ///
- /// The array of data (a float[]) or null if there is no data.
- ///
- ///
- /// Sets the data array to the specified one. The provided array must be a
- /// float array, otherwise a ClassCastException is thrown. The size of the
- /// array is not checked for consistency with the code-block dimensions.
- ///
- ///
- /// The data array to use. Must be a float array.
- ///
- ///
- override public System.Object Data
- {
- get
- {
- return data;
- }
-
- set
- {
- data = (float[])value;
- }
-
- }
- //UPGRADE_NOTE: Respective javadoc comments were merged. It should be changed in order to comply with .NET documentation conventions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1199'"
- /// Returns the array containing the data, or null if there is no data
- /// array.
- ///
- ///
- /// The array of data or null if there is no data.
- ///
- ///
- /// Sets the data array to the specified one. The size of the array is not
- /// checked for consistency with the code-block dimensions. This method is
- /// more efficient than 'setData()'.
- ///
- ///
- /// The data array to use.
- ///
- ///
- virtual public float[] DataFloat
- {
- get
- {
- return data;
- }
-
- set
- {
- data = value;
- }
-
- }
-
- /// The array where the data is stored
- private float[] data;
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/wavelet/analysis/CBlkWTDataInt.cs b/CSJ2K/j2k/wavelet/analysis/CBlkWTDataInt.cs
deleted file mode 100644
index 43fc30db..00000000
--- a/CSJ2K/j2k/wavelet/analysis/CBlkWTDataInt.cs
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
-* CVS identifier:
-*
-* $Id: CBlkWTDataInt.java,v 1.10 2001/08/15 17:18:51 grosbois Exp $
-*
-* Class: CBlkWTDataInt
-*
-* Description: Implementation of CBlkWTData for 'int' data
-*
-*
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-* */
-using CSJ2K.j2k.image;
-namespace CSJ2K.j2k.wavelet.analysis
-{
-
- /// This is an implementation of the 'CBlkWTData' abstract class for signed 32
- /// bit integer data.
- ///
- /// The methods in this class are declared final, so that they can be
- /// inlined by inlining compilers.
- ///
- ///
- ///
- ///
- ///
- public class CBlkWTDataInt : CBlkWTData
- {
- /// Returns the data type of this object, always DataBlk.TYPE_INT.
- ///
- ///
- /// The data type of the object, always DataBlk.TYPE_INT
- ///
- ///
- override public int DataType
- {
- get
- {
- return DataBlk.TYPE_INT;
- }
-
- }
- //UPGRADE_NOTE: Respective javadoc comments were merged. It should be changed in order to comply with .NET documentation conventions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1199'"
- /// Returns the array containing the data, or null if there is no data
- /// array. The returned array is an int array.
- ///
- ///
- /// The array of data (a int[]) or null if there is no data.
- ///
- ///
- /// Sets the data array to the specified one. The provided array must be a
- /// int array, otherwise a ClassCastException is thrown. The size of the
- /// array is not checked for consistency with the code-block dimensions.
- ///
- ///
- /// The data array to use. Must be an int array.
- ///
- ///
- override public System.Object Data
- {
- get
- {
- return data_array;
- }
-
- set
- {
- data_array = (int[])value;
- }
-
- }
- //UPGRADE_NOTE: Respective javadoc comments were merged. It should be changed in order to comply with .NET documentation conventions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1199'"
- /// Returns the array containing the data, or null if there is no data
- /// array.
- ///
- ///
- /// The array of data or null if there is no data.
- ///
- ///
- /// Sets the data array to the specified one. The size of the array is not
- /// checked for consistency with the code-block dimensions. This method is
- /// more efficient than 'setData()'.
- ///
- ///
- /// The data array to use.
- ///
- ///
- virtual public int[] DataInt
- {
- get
- {
- return data_array;
- }
-
- set
- {
- data_array = value;
- }
-
- }
-
- /// The array where the data is stored
- public int[] data_array;
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/wavelet/analysis/CBlkWTDataSrc.cs b/CSJ2K/j2k/wavelet/analysis/CBlkWTDataSrc.cs
deleted file mode 100644
index b879f9b6..00000000
--- a/CSJ2K/j2k/wavelet/analysis/CBlkWTDataSrc.cs
+++ /dev/null
@@ -1,191 +0,0 @@
-/*
-* CVS identifier:
-*
-* $Id: CBlkWTDataSrc.java,v 1.18 2001/09/14 08:45:25 grosbois Exp $
-*
-* Class: CBlkWTDataSrc
-*
-* Description: Interface that define methods for transfer of WT
-* data in a code-block basis.
-*
-*
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-* */
-namespace CSJ2K.j2k.wavelet.analysis
-{
-
- /// This abstract class defines methods to transfer wavelet data in a
- /// code-block by code-block basis. In each call to 'getNextCodeBlock()' or
- /// 'getNextInternCodeBlock()' a new code-block is returned. The code-blocks
- /// are returned in no specific order.
- ///
- /// This class is the source of data for the quantizer. See the 'Quantizer'
- /// class.
- ///
- /// Note that no more of one object may request data, otherwise one object
- /// would get some of the data and another one another part, in no defined
- /// manner.
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- public interface CBlkWTDataSrc : ForwWTDataProps
- {
-
- /// Returns the position of the fixed point in the specified component, or
- /// equivalently the number of fractional bits. This is the position of the
- /// least significant integral (i.e. non-fractional) bit, which is
- /// equivalent to the number of fractional bits. For instance, for
- /// fixed-point values with 2 fractional bits, 2 is returned. For
- /// floating-point data this value does not apply and 0 should be
- /// returned. Position 0 is the position of the least significant bit in
- /// the data.
- ///
- ///
- /// The index of the component.
- ///
- ///
- /// The position of the fixed-point, which is the same as the
- /// number of fractional bits. For floating-point data 0 is returned.
- ///
- ///
- int getFixedPoint(int c);
-
- /// Return the data type of this CBlkWTDataSrc for the given component in
- /// the current tile. Its value should be either DataBlk.TYPE_INT or
- /// DataBlk.TYPE_FLOAT but can change according to the current
- /// tile-component.
- ///
- ///
- /// Tile index
- ///
- ///
- /// Component index
- ///
- ///
- /// Current data type
- ///
- ///
- int getDataType(int t, int c);
-
- /// Returns the next code-block in the current tile for the specified
- /// component, as a copy (see below). The order in which code-blocks are
- /// returned is not specified. However each code-block is returned only
- /// once and all code-blocks will be returned if the method is called 'N'
- /// times, where 'N' is the number of code-blocks in the tile. After all
- /// the code-blocks have been returned for the current tile calls to this
- /// method will return 'null'.
- ///
- /// When changing the current tile (through 'setTile()' or 'nextTile()')
- /// this method will always return the first code-block, as if this method
- /// was never called before for the new current tile.
- ///
- /// The data returned by this method is always a copy of the internal
- /// data of this object, if any, and it can be modified "in place" without
- /// any problems after being returned. The 'offset' of the returned data is
- /// 0, and the 'scanw' is the same as the code-block width. The 'magbits'
- /// of the returned data is not set by this method and should be
- /// ignored. See the 'CBlkWTData' class.
- ///
- /// The 'ulx' and 'uly' members of the returned 'CBlkWTData' object
- /// contain the coordinates of the top-left corner of the block, with
- /// respect to the tile, not the subband.
- ///
- ///
- /// The component for which to return the next code-block.
- ///
- ///
- /// If non-null this object will be used to return the new
- /// code-block. If null a new one will be allocated and returned. If the
- /// "data" array of the object is non-null it will be reused, if possible,
- /// to return the data.
- ///
- ///
- /// The next code-block in the current tile for component 'c', or
- /// null if all code-blocks for the current tile have been returned.
- ///
- ///
- ///
- ///
- ///
- CBlkWTData getNextCodeBlock(int c, CBlkWTData cblk);
-
- /// Returns the next code-block in the current tile for the specified
- /// component. The order in which code-blocks are returned is not
- /// specified. However each code-block is returned only once and all
- /// code-blocks will be returned if the method is called 'N' times, where
- /// 'N' is the number of code-blocks in the tile. After all the code-blocks
- /// have been returned for the current tile calls to this method will
- /// return 'null'.
- ///
- /// When changing the current tile (through 'setTile()' or 'nextTile()')
- /// this method will always return the first code-block, as if this method
- /// was never called before for the new current tile.
- ///
- /// The data returned by this method can be the data in the internal
- /// buffer of this object, if any, and thus can not be modified by the
- /// caller. The 'offset' and 'scanw' of the returned data can be
- /// arbitrary. The 'magbits' of the returned data is not set by this method
- /// and should be ignored. See the 'CBlkWTData' class.
- ///
- /// The 'ulx' and 'uly' members of the returned 'CBlkWTData' object
- /// contain the coordinates of the top-left corner of the block, with
- /// respect to the tile, not the subband.
- ///
- ///
- /// The component for which to return the next code-block.
- ///
- ///
- /// If non-null this object will be used to return the new
- /// code-block. If null a new one will be allocated and returned. If the
- /// "data" array of the object is non-null it will be reused, if possible,
- /// to return the data.
- ///
- ///
- /// The next code-block in the current tile for component 'n', or
- /// null if all code-blocks for the current tile have been returned.
- ///
- ///
- ///
- ///
- ///
- CBlkWTData getNextInternCodeBlock(int c, CBlkWTData cblk);
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/wavelet/analysis/ForwWT.cs b/CSJ2K/j2k/wavelet/analysis/ForwWT.cs
deleted file mode 100644
index 653c212b..00000000
--- a/CSJ2K/j2k/wavelet/analysis/ForwWT.cs
+++ /dev/null
@@ -1,145 +0,0 @@
-/*
-* CVS identifier:
-*
-* $Id: ForwWT.java,v 1.9 2001/10/24 12:02:13 grosbois Exp $
-*
-* Class: ForwWT
-*
-* Description: The interface for implementations of a forward
-* wavelet transform.
-*
-*
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-* */
-namespace CSJ2K.j2k.wavelet.analysis
-{
-
- /// This interface extends the WaveletTransform with the specifics of forward
- /// wavelet transforms. Classes that implement forward wavelet transfoms should
- /// implement this interface.
- ///
- /// This class does not define the methods to transfer data, just the
- /// specifics to forward wavelet transform. Different data transfer methods are
- /// evisageable for different transforms.
- ///
- ///
- public interface ForwWT : WaveletTransform, ForwWTDataProps
- {
-
- /// Returns the horizontal analysis wavelet filters used in each level, for
- /// the specified tile-component. The first element in the array is the
- /// filter used to obtain the lowest resolution (resolution level 0)
- /// subbands (i.e. lowest frequency LL subband), the second element is the
- /// one used to generate the resolution level 1 subbands, and so on. If
- /// there are less elements in the array than the number of resolution
- /// levels, then the last one is assumed to repeat itself.
- ///
- /// The returned filters are applicable only to the specified component
- /// and in the current tile.
- ///
- /// The resolution level of a subband is the resolution level to which a
- /// subband contributes, which is different from its decomposition
- /// level.
- ///
- ///
- /// The index of the tile for which to return the filters.
- ///
- ///
- /// The index of the component for which to return the filters.
- ///
- ///
- /// The horizontal analysis wavelet filters used in each level.
- ///
- ///
- AnWTFilter[] getHorAnWaveletFilters(int t, int c);
-
- /// Returns the vertical analysis wavelet filters used in each level, for
- /// the specified tile-component. The first element in the array is the
- /// filter used to obtain the lowest resolution (resolution level 0)
- /// subbands (i.e. lowest frequency LL subband), the second element is the
- /// one used to generate the resolution level 1 subbands, and so on. If
- /// there are less elements in the array than the number of resolution
- /// levels, then the last one is assumed to repeat itself.
- ///
- /// The returned filters are applicable only to the specified component
- /// and in the current tile.
- ///
- /// The resolution level of a subband is the resolution level to which a
- /// subband contributes, which is different from its decomposition
- /// level.
- ///
- ///
- /// The index of the tile for which to return the filters.
- ///
- ///
- /// The index of the component for which to return the filters.
- ///
- ///
- /// The vertical analysis wavelet filters used in each level.
- ///
- ///
- AnWTFilter[] getVertAnWaveletFilters(int t, int c);
-
- /// Returns the number of decomposition levels that are applied to obtain
- /// the LL band, in the specified tile-component. A value of 0 means that
- /// no wavelet transform is applied.
- ///
- ///
- /// The tile index
- ///
- ///
- /// The index of the component.
- ///
- ///
- /// The number of decompositions applied to obtain the LL subband
- /// (0 for no wavelet transform).
- ///
- ///
- int getDecompLevels(int t, int c);
-
- /// Returns the wavelet tree decomposition. Only WT_DECOMP_DYADIC is
- /// supported by JPEG 2000 part I.
- ///
- ///
- /// The tile index
- ///
- ///
- /// The index of the component.
- ///
- ///
- /// The wavelet decomposition.
- ///
- ///
- int getDecomp(int t, int c);
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/wavelet/analysis/ForwWTDataProps.cs b/CSJ2K/j2k/wavelet/analysis/ForwWTDataProps.cs
deleted file mode 100644
index 17805998..00000000
--- a/CSJ2K/j2k/wavelet/analysis/ForwWTDataProps.cs
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
-* CVS identifier:
-*
-* $Id: ForwWTDataProps.java,v 1.10 2001/09/20 12:42:42 grosbois Exp $
-*
-* Class: ForwWTDataProps
-*
-* Description: Extends ImgData with forward wavelet specific
-* things.
-*
-*
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-* */
-using CSJ2K.j2k.image;
-namespace CSJ2K.j2k.wavelet.analysis
-{
-
- /// This interface extends the ImgData interface with methods that are
- /// necessary for forward wavelet data (i.e. data that is produced by a forward
- /// wavelet transform).
- ///
- public interface ForwWTDataProps : ImgData
- {
- /// Returns the horizontal offset of the code-block partition. Allowable
- /// values are 0 and 1, nothing else.
- ///
- ///
- int CbULX
- {
- get;
-
- }
- /// Returns the vertical offset of the code-block partition. Allowable
- /// values are 0 and 1, nothing else.
- ///
- ///
- int CbULY
- {
- get;
-
- }
-
- /// Returns the reversibility of the given tile-component. Data is
- /// reversible when it is suitable for lossless and lossy-to-lossless
- /// compression.
- ///
- ///
- /// Tile index
- ///
- ///
- /// Component index
- ///
- ///
- /// true is the data is reversible, false if not.
- ///
- ///
- bool isReversible(int t, int c);
-
- /// Returns a reference to the root of subband tree structure representing
- /// the subband decomposition for the specified tile-component.
- ///
- ///
- /// The index of the tile.
- ///
- ///
- /// The index of the component.
- ///
- ///
- /// The root of the subband tree structure, see Subband.
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- SubbandAn getAnSubbandTree(int t, int c);
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/wavelet/analysis/ForwWTFull.cs b/CSJ2K/j2k/wavelet/analysis/ForwWTFull.cs
deleted file mode 100644
index cd4eeb99..00000000
--- a/CSJ2K/j2k/wavelet/analysis/ForwWTFull.cs
+++ /dev/null
@@ -1,1225 +0,0 @@
-/*
-* CVS identifier:
-*
-* $Id: ForwWTFull.java,v 1.30 2001/09/20 12:42:59 grosbois Exp $
-*
-* Class: ForwWTFull
-*
-* Description: This class implements the full page
-* forward wavelet transform for both integer
-* and floating point implementations.
-*
-*
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-* */
-using CSJ2K.j2k.encoder;
-using CSJ2K.j2k.entropy;
-using CSJ2K.j2k.image;
-using CSJ2K.j2k.util;
-using System;
-namespace CSJ2K.j2k.wavelet.analysis
-{
-
- /// This class implements the ForwardWT abstract class with the full-page
- /// approach to be used either with integer or floating-point filters
- ///
- ///
- ///
- ///
- ///
- public class ForwWTFull : ForwardWT
- {
- /// Returns the horizontal offset of the code-block partition. Allowable
- /// values are 0 and 1, nothing else.
- ///
- ///
- override public int CbULX
- {
- get
- {
- return cb0x;
- }
-
- }
- /// Returns the vertical offset of the code-block partition. Allowable
- /// values are 0 and 1, nothing else.
- ///
- ///
- override public int CbULY
- {
- get
- {
- return cb0y;
- }
-
- }
-
- /// Boolean to know if one are currently dealing with int or float data.
- private bool intData;
-
- /// The subband trees of each tile-component. The array is allocated by the
- /// constructor of this class and updated by the getAnSubbandTree() method
- /// when needed. The first index is the tile index (in lexicographical
- /// order) and the second index is the component index.
- ///
- /// The subband tree for a component in the current tile is created on
- /// the first call to getAnSubbandTree() for that component, in the current
- /// tile. Before that, the element in 'subbTrees' is null.
- ///
- ///
- private SubbandAn[][] subbTrees;
-
- /// The source of image data
- private BlkImgDataSrc src;
-
- /// The horizontal coordinate of the code-block partition origin on the
- /// reference grid
- ///
- private int cb0x;
-
- /// The vertical coordinate of the code-block partition on the reference
- /// grid
- ///
- private int cb0y;
-
- /// The number of decomposition levels specification
- private IntegerSpec dls;
-
- /// Wavelet filters for all components and tiles
- private AnWTFilterSpec filters;
-
- /// The code-block size specifications
- private CBlkSizeSpec cblks;
-
- /// The precinct partition specifications
- private PrecinctSizeSpec pss;
-
- /// Block storing the full band decomposition for each component.
- private DataBlk[] decomposedComps;
-
- /// The horizontal index of the last "sent" code-block in the current
- /// subband in each component. It should be -1 if none have been sent yet.
- ///
- ///
- private int[] lastn;
-
- /// The vertical index of the last "sent" code-block in the current
- /// subband in each component. It should be 0 if none have been sent yet.
- ///
- ///
- private int[] lastm;
-
- /// The subband being dealt with in each component
- internal SubbandAn[] currentSubband;
-
- /// Cache object to avoid excessive allocation/desallocation. This
- /// variable makes the class inheritently thread unsafe.
- ///
- internal Coord ncblks;
-
- /// Initializes this object with the given source of image data and with
- /// all the decompositon parameters
- ///
- ///
- /// From where the image data should be obtained.
- ///
- ///
- /// The encoder specifications
- ///
- ///
- /// The horizontal coordinate of the code-block partition
- /// origin on the reference grid.
- ///
- ///
- /// The vertical coordinate of the code-block partition origin
- /// on the reference grid.
- ///
- ///
- ///
- ///
- ///
- public ForwWTFull(BlkImgDataSrc src, EncoderSpecs encSpec, int cb0x, int cb0y) : base(src)
- {
- this.src = src;
- this.cb0x = cb0x;
- this.cb0y = cb0y;
- this.dls = encSpec.dls;
- this.filters = encSpec.wfs;
- this.cblks = encSpec.cblks;
- this.pss = encSpec.pss;
-
- int ncomp = src.NumComps;
- int ntiles = src.getNumTiles();
-
- currentSubband = new SubbandAn[ncomp];
- decomposedComps = new DataBlk[ncomp];
- subbTrees = new SubbandAn[ntiles][];
- for (int i = 0; i < ntiles; i++)
- {
- subbTrees[i] = new SubbandAn[ncomp];
- }
- lastn = new int[ncomp];
- lastm = new int[ncomp];
- }
-
- /// Returns the implementation type of this wavelet transform, WT_IMPL_FULL
- /// (full-page based transform). All components return the same.
- ///
- ///
- /// The index of the component.
- ///
- ///
- /// WT_IMPL_FULL
- ///
- ///
- public override int getImplementationType(int c)
- {
- return CSJ2K.j2k.wavelet.WaveletTransform_Fields.WT_IMPL_FULL;
- }
-
- /// Returns the number of decomposition levels that are applied to the LL
- /// band, in the specified tile-component. A value of 0 means that no
- /// wavelet transform is applied.
- ///
- ///
- /// The tile index
- ///
- ///
- /// The index of the component.
- ///
- ///
- /// The number of decompositions applied to the LL band (0 for no
- /// wavelet transform).
- ///
- ///
- public override int getDecompLevels(int t, int c)
- {
- return ((System.Int32)dls.getTileCompVal(t, c));
- }
-
- /// Returns the wavelet tree decomposition. Actually JPEG 2000 part 1 only
- /// supports WT_DECOMP_DYADIC decomposition.
- ///
- ///
- /// The tile-index
- ///
- ///
- /// The index of the component.
- ///
- ///
- /// The wavelet decomposition.
- ///
- ///
- public override int getDecomp(int t, int c)
- {
- return WT_DECOMP_DYADIC;
- }
-
- /// Returns the horizontal analysis wavelet filters used in each level, for
- /// the specified component and tile. The first element in the array is the
- /// filter used to obtain the lowest resolution (resolution level 0)
- /// subbands (i.e. lowest frequency LL subband), the second element is the
- /// one used to generate the resolution level 1 subbands, and so on. If
- /// there are less elements in the array than the number of resolution
- /// levels, then the last one is assumed to repeat itself.
- ///
- /// The returned filters are applicable only to the specified component
- /// and in the current tile.
- ///
- /// The resolution level of a subband is the resolution level to which a
- /// subband contributes, which is different from its decomposition
- /// level.
- ///
- ///
- /// The index of the tile for which to return the filters.
- ///
- ///
- /// The index of the component for which to return the filters.
- ///
- ///
- /// The horizontal analysis wavelet filters used in each level.
- ///
- ///
- public override AnWTFilter[] getHorAnWaveletFilters(int t, int c)
- {
- return filters.getHFilters(t, c);
- }
-
- /// Returns the vertical analysis wavelet filters used in each level, for
- /// the specified component and tile. The first element in the array is the
- /// filter used to obtain the lowest resolution (resolution level 0)
- /// subbands (i.e. lowest frequency LL subband), the second element is the
- /// one used to generate the resolution level 1 subbands, and so on. If
- /// there are less elements in the array than the number of resolution
- /// levels, then the last one is assumed to repeat itself.
- ///
- /// The returned filters are applicable only to the specified component
- /// and in the current tile.
- ///
- /// The resolution level of a subband is the resolution level to which a
- /// subband contributes, which is different from its decomposition
- /// level.
- ///
- ///
- /// The index of the tile for which to return the filters.
- ///
- ///
- /// The index of the component for which to return the filters.
- ///
- ///
- /// The vertical analysis wavelet filters used in each level.
- ///
- ///
- public override AnWTFilter[] getVertAnWaveletFilters(int t, int c)
- {
- return filters.getVFilters(t, c);
- }
-
- /// Returns the reversibility of the wavelet transform for the specified
- /// component and tile. A wavelet transform is reversible when it is
- /// suitable for lossless and lossy-to-lossless compression.
- ///
- ///
- /// The index of the tile.
- ///
- ///
- /// The index of the component.
- ///
- ///
- /// true is the wavelet transform is reversible, false if not.
- ///
- ///
- public override bool isReversible(int t, int c)
- {
- return filters.isReversible(t, c);
- }
-
- /// Returns the position of the fixed point in the specified
- /// component. This is the position of the least significant integral
- /// (i.e. non-fractional) bit, which is equivalent to the number of
- /// fractional bits. For instance, for fixed-point values with 2 fractional
- /// bits, 2 is returned. For floating-point data this value does not apply
- /// and 0 should be returned. Position 0 is the position of the least
- /// significant bit in the data.
- ///
- ///
- /// The index of the component.
- ///
- ///
- /// The position of the fixed-point, which is the same as the
- /// number of fractional bits. For floating-point data 0 is returned.
- ///
- ///
- public override int getFixedPoint(int c)
- {
- return src.getFixedPoint(c);
- }
-
- /// Returns the next code-block in the current tile for the specified
- /// component. The order in which code-blocks are returned is not
- /// specified. However each code-block is returned only once and all
- /// code-blocks will be returned if the method is called 'N' times, where
- /// 'N' is the number of code-blocks in the tile. After all the code-blocks
- /// have been returned for the current tile calls to this method will
- /// return 'null'.
- ///
- /// When changing the current tile (through 'setTile()' or 'nextTile()')
- /// this method will always return the first code-block, as if this method
- /// was never called before for the new current tile.
- ///
- /// The data returned by this method is the data in the internal buffer
- /// of this object, and thus can not be modified by the caller. The
- /// 'offset' and 'scanw' of the returned data have, in general, some
- /// non-zero value. The 'magbits' of the returned data is not set by this
- /// method and should be ignored. See the 'CBlkWTData' class.
- ///
- /// The 'ulx' and 'uly' members of the returned 'CBlkWTData' object
- /// contain the coordinates of the top-left corner of the block, with
- /// respect to the tile, not the subband.
- ///
- ///
- /// The component for which to return the next code-block.
- ///
- ///
- /// If non-null this object will be used to return the new
- /// code-block. If null a new one will be allocated and returned.
- ///
- ///
- /// The next code-block in the current tile for component 'n', or
- /// null if all code-blocks for the current tile have been returned.
- ///
- ///
- ///
- ///
- ///
- public override CBlkWTData getNextInternCodeBlock(int c, CBlkWTData cblk)
- {
- int cbm, cbn, cn, cm;
- int acb0x, acb0y;
- SubbandAn sb;
- intData = (filters.getWTDataType(tIdx, c) == DataBlk.TYPE_INT);
-
- //If the source image has not been decomposed
- if (decomposedComps[c] == null)
- {
- int k, w, h;
- DataBlk bufblk;
- System.Object dst_data;
-
- w = getTileCompWidth(tIdx, c);
- h = getTileCompHeight(tIdx, c);
-
- //Get the source image data
- if (intData)
- {
- decomposedComps[c] = new DataBlkInt(0, 0, w, h);
- bufblk = new DataBlkInt();
- }
- else
- {
- decomposedComps[c] = new DataBlkFloat(0, 0, w, h);
- bufblk = new DataBlkFloat();
- }
-
- // Get data from source line by line (this diminishes the memory
- // requirements on the data source)
- dst_data = decomposedComps[c].Data;
- int lstart = getCompULX(c);
- bufblk.ulx = lstart;
- bufblk.w = w;
- bufblk.h = 1;
- int kk = getCompULY(c);
- for (k = 0; k < h; k++, kk++)
- {
- bufblk.uly = kk;
- bufblk.ulx = lstart;
- bufblk = src.getInternCompData(bufblk, c);
- // CONVERSION PROBLEM?
- Array.Copy((System.Array)bufblk.Data, bufblk.offset, (System.Array)dst_data, k * w, w);
- }
-
- //Decompose source image
- waveletTreeDecomposition(decomposedComps[c], getAnSubbandTree(tIdx, c), c);
-
- // Make the first subband the current one
- currentSubband[c] = getNextSubband(c);
-
- lastn[c] = -1;
- lastm[c] = 0;
- }
-
- // Get the next code-block to "send"
- do
- {
- // Calculate number of code-blocks in current subband
- ncblks = currentSubband[c].numCb;
- // Goto next code-block
- lastn[c]++;
- if (lastn[c] == ncblks.x)
- {
- // Got to end of this row of
- // code-blocks
- lastn[c] = 0;
- lastm[c]++;
- }
- if (lastm[c] < ncblks.y)
- {
- // Not past the last code-block in the subband, we can return
- // this code-block
- break;
- }
- // If we get here we already sent all code-blocks in this subband,
- // goto next subband
- currentSubband[c] = getNextSubband(c);
- lastn[c] = -1;
- lastm[c] = 0;
- if (currentSubband[c] == null)
- {
- // We don't need the transformed data any more (a priori)
- decomposedComps[c] = null;
- // All code-blocks from all subbands in the current
- // tile have been returned so we return a null
- // reference
- return null;
- }
- // Loop to find the next code-block
- }
- while (true);
-
-
- // Project code-block partition origin to subband. Since the origin is
- // always 0 or 1, it projects to the low-pass side (throught the ceil
- // operator) as itself (i.e. no change) and to the high-pass side
- // (through the floor operator) as 0, always.
- acb0x = cb0x;
- acb0y = cb0y;
- switch (currentSubband[c].sbandIdx)
- {
-
- case Subband.WT_ORIENT_LL:
- // No need to project since all low-pass => nothing to do
- break;
-
- case Subband.WT_ORIENT_HL:
- acb0x = 0;
- break;
-
- case Subband.WT_ORIENT_LH:
- acb0y = 0;
- break;
-
- case Subband.WT_ORIENT_HH:
- acb0x = 0;
- acb0y = 0;
- break;
-
- default:
- throw new System.ApplicationException("Internal JJ2000 error");
-
- }
-
- // Initialize output code-block
- if (cblk == null)
- {
- if (intData)
- {
- cblk = new CBlkWTDataInt();
- }
- else
- {
- cblk = new CBlkWTDataFloat();
- }
- }
- cbn = lastn[c];
- cbm = lastm[c];
- sb = currentSubband[c];
- cblk.n = cbn;
- cblk.m = cbm;
- cblk.sb = sb;
- // Calculate the indexes of first code-block in subband with respect
- // to the partitioning origin, to then calculate the position and size
- // NOTE: when calculating "floor()" by integer division the dividend
- // and divisor must be positive, we ensure that by adding the divisor
- // to the dividend and then substracting 1 to the result of the
- // division
- cn = (sb.ulcx - acb0x + sb.nomCBlkW) / sb.nomCBlkW - 1;
- cm = (sb.ulcy - acb0y + sb.nomCBlkH) / sb.nomCBlkH - 1;
- if (cbn == 0)
- {
- // Left-most code-block, starts where subband starts
- cblk.ulx = sb.ulx;
- }
- else
- {
- // Calculate starting canvas coordinate and convert to subb. coords
- cblk.ulx = (cn + cbn) * sb.nomCBlkW - (sb.ulcx - acb0x) + sb.ulx;
- }
- if (cbm == 0)
- {
- // Bottom-most code-block, starts where subband starts
- cblk.uly = sb.uly;
- }
- else
- {
- cblk.uly = (cm + cbm) * sb.nomCBlkH - (sb.ulcy - acb0y) + sb.uly;
- }
- if (cbn < ncblks.x - 1)
- {
- // Calculate where next code-block starts => width
- cblk.w = (cn + cbn + 1) * sb.nomCBlkW - (sb.ulcx - acb0x) + sb.ulx - cblk.ulx;
- }
- else
- {
- // Right-most code-block, ends where subband ends
- cblk.w = sb.ulx + sb.w - cblk.ulx;
- }
- if (cbm < ncblks.y - 1)
- {
- // Calculate where next code-block starts => height
- cblk.h = (cm + cbm + 1) * sb.nomCBlkH - (sb.ulcy - acb0y) + sb.uly - cblk.uly;
- }
- else
- {
- // Bottom-most code-block, ends where subband ends
- cblk.h = sb.uly + sb.h - cblk.uly;
- }
- cblk.wmseScaling = 1f;
-
- // Since we are in getNextInternCodeBlock() we can return a
- // reference to the internal buffer, no need to copy. Just initialize
- // the 'offset' and 'scanw'
- cblk.offset = cblk.uly * decomposedComps[c].w + cblk.ulx;
- cblk.scanw = decomposedComps[c].w;
-
- // For the data just put a reference to our buffer
- cblk.Data = decomposedComps[c].Data;
- // Return code-block
- return cblk;
- }
-
- /// Returns the next code-block in the current tile for the specified
- /// component, as a copy (see below). The order in which code-blocks are
- /// returned is not specified. However each code-block is returned only
- /// once and all code-blocks will be returned if the method is called 'N'
- /// times, where 'N' is the number of code-blocks in the tile. After all
- /// the code-blocks have been returned for the current tile calls to this
- /// method will return 'null'.
- ///
- /// When changing the current tile (through 'setTile()' or 'nextTile()')
- /// this method will always return the first code-block, as if this method
- /// was never called before for the new current tile.
- ///
- /// The data returned by this method is always a copy of the internal
- /// data of this object, and it can be modified "in place" without
- /// any problems after being returned. The 'offset' of the returned data is
- /// 0, and the 'scanw' is the same as the code-block width. The 'magbits'
- /// of the returned data is not set by this method and should be
- /// ignored. See the 'CBlkWTData' class.
- ///
- /// The 'ulx' and 'uly' members of the returned 'CBlkWTData' object
- /// contain the coordinates of the top-left corner of the block, with
- /// respect to the tile, not the subband.
- ///
- ///
- /// The component for which to return the next code-block.
- ///
- ///
- /// If non-null this object will be used to return the new
- /// code-block. If null a new one will be allocated and returned. If the
- /// "data" array of the object is non-null it will be reused, if possible,
- /// to return the data.
- ///
- ///
- /// The next code-block in the current tile for component 'c', or
- /// null if all code-blocks for the current tile have been returned.
- ///
- ///
- ///
- ///
- ///
- public override CBlkWTData getNextCodeBlock(int c, CBlkWTData cblk)
- {
- // We can not directly use getNextInternCodeBlock() since that returns
- // a reference to the internal buffer, we have to copy that data
-
- int j, k;
- int w;
- System.Object dst_data; // a int[] or float[] object
- int[] dst_data_int;
- float[] dst_data_float;
- System.Object src_data; // a int[] or float[] object
-
- intData = (filters.getWTDataType(tIdx, c) == DataBlk.TYPE_INT);
-
- dst_data = null;
-
- // Cache the data array, if any
- if (cblk != null)
- {
- dst_data = cblk.Data;
- }
-
- // Get the next code-block
- cblk = getNextInternCodeBlock(c, cblk);
-
- if (cblk == null)
- {
- return null; // No more code-blocks in current tile for component
- // c
- }
-
- // Ensure size of output buffer
- if (intData)
- {
- // int data
- dst_data_int = (int[])dst_data;
- if (dst_data_int == null || dst_data_int.Length < cblk.w * cblk.h)
- {
- dst_data = new int[cblk.w * cblk.h];
- }
- }
- else
- {
- // float data
- dst_data_float = (float[])dst_data;
- if (dst_data_float == null || dst_data_float.Length < cblk.w * cblk.h)
- {
- dst_data = new float[cblk.w * cblk.h];
- }
- }
-
- // Copy data line by line
- src_data = cblk.Data;
- w = cblk.w;
- for (j = w * (cblk.h - 1), k = cblk.offset + (cblk.h - 1) * cblk.scanw; j >= 0; j -= w, k -= cblk.scanw)
- {
- // CONVERSION PROBLEM?
- Array.Copy((System.Array)src_data, k, (System.Array)dst_data, j, w);
- }
- cblk.Data = dst_data;
- cblk.offset = 0;
- cblk.scanw = w;
-
- return cblk;
- }
-
- /// Return the data type of this CBlkWTDataSrc. Its value should be either
- /// DataBlk.TYPE_INT or DataBlk.TYPE_FLOAT but can change according to the
- /// current tile-component.
- ///
- ///
- /// The index of the tile for which to return the data type.
- ///
- ///
- /// The index of the component for which to return the data type.
- ///
- ///
- /// Current data type
- ///
- ///
- public override int getDataType(int t, int c)
- {
- return filters.getWTDataType(t, c);
- }
-
- /// Returns the next subband that will be used to get the next code-block
- /// to return by the getNext[Intern]CodeBlock method.
- ///
- ///
- /// The component
- ///
- ///
- /// Its returns the next subband that will be used to get the next
- /// code-block to return by the getNext[Intern]CodeBlock method.
- ///
- ///
- private SubbandAn getNextSubband(int c)
- {
- int down = 1;
- int up = 0;
- int direction = down;
- SubbandAn nextsb;
-
- nextsb = currentSubband[c];
- //If it is the first call to this method
- if (nextsb == null)
- {
- nextsb = getAnSubbandTree(tIdx, c);
- //If there is no decomposition level then send the whole image
- if (!nextsb.isNode)
- {
- return nextsb;
- }
- }
-
- //Find the next subband to send
- do
- {
- //If the current subband is null then break
- if (nextsb == null)
- {
- break;
- }
- //If the current subband is a leaf then select the next leaf to
- //send or go up in the decomposition tree if the leaf was a LL
- //one.
- else if (!nextsb.isNode)
- {
- switch (nextsb.orientation)
- {
-
- case Subband.WT_ORIENT_HH:
- nextsb = (SubbandAn)nextsb.Parent.LH;
- direction = down;
- break;
-
- case Subband.WT_ORIENT_LH:
- nextsb = (SubbandAn)nextsb.Parent.HL;
- direction = down;
- break;
-
- case Subband.WT_ORIENT_HL:
- nextsb = (SubbandAn)nextsb.Parent.LL;
- direction = down;
- break;
-
- case Subband.WT_ORIENT_LL:
- nextsb = (SubbandAn)nextsb.Parent;
- direction = up;
- break;
- }
- }
- //Else if the current subband is a node
- else if (nextsb.isNode)
- {
- //If the direction is down the select the HH subband of the
- //current node.
- if (direction == down)
- {
- nextsb = (SubbandAn)nextsb.HH;
- }
- //Else the direction is up the select the next node to cover
- //or still go up in the decomposition tree if the node is a LL
- //subband
- else if (direction == up)
- {
- switch (nextsb.orientation)
- {
-
- case Subband.WT_ORIENT_HH:
- nextsb = (SubbandAn)nextsb.Parent.LH;
- direction = down;
- break;
-
- case Subband.WT_ORIENT_LH:
- nextsb = (SubbandAn)nextsb.Parent.HL;
- direction = down;
- break;
-
- case Subband.WT_ORIENT_HL:
- nextsb = (SubbandAn)nextsb.Parent.LL;
- direction = down;
- break;
-
- case Subband.WT_ORIENT_LL:
- nextsb = (SubbandAn)nextsb.Parent;
- direction = up;
- break;
- }
- }
- }
-
- if (nextsb == null)
- {
- break;
- }
- }
- while (nextsb.isNode);
- return nextsb;
- }
-
- /// Performs the forward wavelet transform on the whole band. It
- /// iteratively decomposes the subbands from the top node to the leaves.
- ///
- ///
- /// The band containing the float data to decompose
- ///
- ///
- /// The structure containing the coordinates of the current
- /// subband in the whole band to decompose.
- ///
- ///
- /// The index of the current component to decompose
- ///
- ///
- private void waveletTreeDecomposition(DataBlk band, SubbandAn subband, int c)
- {
-
- //If the current subband is a leaf then nothing to be done (a leaf is
- //not decomposed).
- if (!subband.isNode)
- {
- return;
- }
- else
- {
- //Perform the 2D wavelet decomposition of the current subband
- wavelet2DDecomposition(band, (SubbandAn)subband, c);
-
- //Perform the decomposition of the four resulting subbands
- waveletTreeDecomposition(band, (SubbandAn)subband.HH, c);
- waveletTreeDecomposition(band, (SubbandAn)subband.LH, c);
- waveletTreeDecomposition(band, (SubbandAn)subband.HL, c);
- waveletTreeDecomposition(band, (SubbandAn)subband.LL, c);
- }
- }
-
- /// Performs the 2D forward wavelet transform on a subband of the initial
- /// band. This method will successively perform 1D filtering steps on all
- /// lines and then all columns of the subband. In this class only filters
- /// with floating point implementations can be used.
- ///
- ///
- /// The band containing the float data to decompose
- ///
- ///
- /// The structure containing the coordinates of the subband
- /// in the whole band to decompose.
- ///
- ///
- /// The index of the current component to decompose
- ///
- ///
- private void wavelet2DDecomposition(DataBlk band, SubbandAn subband, int c)
- {
-
- int ulx, uly, w, h;
- int band_w, band_h;
-
- // If subband is empty (i.e. zero size) nothing to do
- if (subband.w == 0 || subband.h == 0)
- {
- return;
- }
-
- ulx = subband.ulx;
- uly = subband.uly;
- w = subband.w;
- h = subband.h;
- band_w = getTileCompWidth(tIdx, c);
- band_h = getTileCompHeight(tIdx, c);
-
- if (intData)
- {
- //Perform the decompositions if the filter is implemented with an
- //integer arithmetic.
- int i, j;
- int offset;
- int[] tmpVector = new int[System.Math.Max(w, h)];
- int[] data = ((DataBlkInt)band).DataInt;
-
- //Perform the vertical decomposition
- if (subband.ulcy % 2 == 0)
- {
- // Even start index => use LPF
- for (j = 0; j < w; j++)
- {
- offset = uly * band_w + ulx + j;
- for (i = 0; i < h; i++)
- tmpVector[i] = data[offset + (i * band_w)];
- subband.vFilter.analyze_lpf(tmpVector, 0, h, 1, data, offset, band_w, data, offset + ((h + 1) / 2) * band_w, band_w);
- }
- }
- else
- {
- // Odd start index => use HPF
- for (j = 0; j < w; j++)
- {
- offset = uly * band_w + ulx + j;
- for (i = 0; i < h; i++)
- tmpVector[i] = data[offset + (i * band_w)];
- subband.vFilter.analyze_hpf(tmpVector, 0, h, 1, data, offset, band_w, data, offset + (h / 2) * band_w, band_w);
- }
- }
-
- //Perform the horizontal decomposition.
- if (subband.ulcx % 2 == 0)
- {
- // Even start index => use LPF
- for (i = 0; i < h; i++)
- {
- offset = (uly + i) * band_w + ulx;
- for (j = 0; j < w; j++)
- tmpVector[j] = data[offset + j];
- subband.hFilter.analyze_lpf(tmpVector, 0, w, 1, data, offset, 1, data, offset + (w + 1) / 2, 1);
- }
- }
- else
- {
- // Odd start index => use HPF
- for (i = 0; i < h; i++)
- {
- offset = (uly + i) * band_w + ulx;
- for (j = 0; j < w; j++)
- tmpVector[j] = data[offset + j];
- subband.hFilter.analyze_hpf(tmpVector, 0, w, 1, data, offset, 1, data, offset + w / 2, 1);
- }
- }
- }
- else
- {
- //Perform the decompositions if the filter is implemented with a
- //float arithmetic.
- int i, j;
- int offset;
- float[] tmpVector = new float[System.Math.Max(w, h)];
- float[] data = ((DataBlkFloat)band).DataFloat;
-
- //Perform the vertical decomposition.
- if (subband.ulcy % 2 == 0)
- {
- // Even start index => use LPF
- for (j = 0; j < w; j++)
- {
- offset = uly * band_w + ulx + j;
- for (i = 0; i < h; i++)
- tmpVector[i] = data[offset + (i * band_w)];
- subband.vFilter.analyze_lpf(tmpVector, 0, h, 1, data, offset, band_w, data, offset + ((h + 1) / 2) * band_w, band_w);
- }
- }
- else
- {
- // Odd start index => use HPF
- for (j = 0; j < w; j++)
- {
- offset = uly * band_w + ulx + j;
- for (i = 0; i < h; i++)
- tmpVector[i] = data[offset + (i * band_w)];
- subband.vFilter.analyze_hpf(tmpVector, 0, h, 1, data, offset, band_w, data, offset + (h / 2) * band_w, band_w);
- }
- }
- //Perform the horizontal decomposition.
- if (subband.ulcx % 2 == 0)
- {
- // Even start index => use LPF
- for (i = 0; i < h; i++)
- {
- offset = (uly + i) * band_w + ulx;
- for (j = 0; j < w; j++)
- tmpVector[j] = data[offset + j];
- subband.hFilter.analyze_lpf(tmpVector, 0, w, 1, data, offset, 1, data, offset + (w + 1) / 2, 1);
- }
- }
- else
- {
- // Odd start index => use HPF
- for (i = 0; i < h; i++)
- {
- offset = (uly + i) * band_w + ulx;
- for (j = 0; j < w; j++)
- tmpVector[j] = data[offset + j];
- subband.hFilter.analyze_hpf(tmpVector, 0, w, 1, data, offset, 1, data, offset + w / 2, 1);
- }
- }
- }
- }
-
- /// Changes the current tile, given the new coordinates.
- ///
- /// This method resets the 'subbTrees' array, and recalculates the
- /// values of the 'reversible' array. It also resets the decomposed
- /// component buffers.
- ///
- ///
- /// The horizontal coordinate of the tile.
- ///
- ///
- /// The vertical coordinate of the new tile.
- ///
- ///
- public override void setTile(int x, int y)
- {
- int i;
-
- // Change tile
- base.setTile(x, y);
-
- // Reset the decomposed component buffers.
- if (decomposedComps != null)
- {
- for (i = decomposedComps.Length - 1; i >= 0; i--)
- {
- decomposedComps[i] = null;
- currentSubband[i] = null;
- }
- }
- }
-
- /// Advances to the next tile, in standard scan-line order (by rows then
- /// columns). An NoNextElementException is thrown if the current tile is
- /// the last one (i.e. there is no next tile).
- ///
- /// This method resets the 'subbTrees' array, and recalculates the
- /// values of the 'reversible' array. It also resets the decomposed
- /// component buffers.
- ///
- ///
- public override void nextTile()
- {
- int i;
-
- // Change tile
- base.nextTile();
- // Reset the decomposed component buffers
- if (decomposedComps != null)
- {
- for (i = decomposedComps.Length - 1; i >= 0; i--)
- {
- decomposedComps[i] = null;
- currentSubband[i] = null;
- }
- }
- }
-
- /// Returns a reference to the subband tree structure representing the
- /// subband decomposition for the specified tile-component of the source.
- ///
- ///
- /// The index of the tile.
- ///
- ///
- /// The index of the component.
- ///
- ///
- /// The subband tree structure, see Subband.
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- public override SubbandAn getAnSubbandTree(int t, int c)
- {
- if (subbTrees[t][c] == null)
- {
- subbTrees[t][c] = new SubbandAn(getTileCompWidth(t, c), getTileCompHeight(t, c), getCompULX(c), getCompULY(c), getDecompLevels(t, c), getHorAnWaveletFilters(t, c), getVertAnWaveletFilters(t, c));
- initSubbandsFields(t, c, subbTrees[t][c]);
- }
- return subbTrees[t][c];
- }
-
- /// Initialises subbands fields, such as number of code-blocks and
- /// code-blocks dimension, in the subband tree. The nominal code-block
- /// width/height depends on the precincts dimensions if used.
- ///
- ///
- /// The tile index of the subband
- ///
- ///
- /// The component index
- ///
- ///
- /// The subband tree to be initialised.
- ///
- ///
- private void initSubbandsFields(int t, int c, Subband sb)
- {
- int cbw = cblks.getCBlkWidth(ModuleSpec.SPEC_TILE_COMP, t, c);
- int cbh = cblks.getCBlkHeight(ModuleSpec.SPEC_TILE_COMP, t, c);
-
- if (!sb.isNode)
- {
- // Code-blocks dimension
- int ppx, ppy;
- int ppxExp, ppyExp, cbwExp, cbhExp;
- ppx = pss.getPPX(t, c, sb.resLvl);
- ppy = pss.getPPY(t, c, sb.resLvl);
-
- if (ppx != CSJ2K.j2k.codestream.Markers.PRECINCT_PARTITION_DEF_SIZE || ppy != CSJ2K.j2k.codestream.Markers.PRECINCT_PARTITION_DEF_SIZE)
- {
-
- ppxExp = MathUtil.log2(ppx);
- ppyExp = MathUtil.log2(ppy);
- cbwExp = MathUtil.log2(cbw);
- cbhExp = MathUtil.log2(cbh);
-
- // Precinct partition is used
- switch (sb.resLvl)
- {
-
- case 0:
- sb.nomCBlkW = (cbwExp < ppxExp ? (1 << cbwExp) : (1 << ppxExp));
- sb.nomCBlkH = (cbhExp < ppyExp ? (1 << cbhExp) : (1 << ppyExp));
- break;
-
-
- default:
- sb.nomCBlkW = (cbwExp < ppxExp - 1 ? (1 << cbwExp) : (1 << (ppxExp - 1)));
- sb.nomCBlkH = (cbhExp < ppyExp - 1 ? (1 << cbhExp) : (1 << (ppyExp - 1)));
- break;
-
- }
- }
- else
- {
- sb.nomCBlkW = cbw;
- sb.nomCBlkH = cbh;
- }
-
- // Number of code-blocks
- if (sb.numCb == null)
- sb.numCb = new Coord();
- if (sb.w != 0 && sb.h != 0)
- {
- int acb0x = cb0x;
- int acb0y = cb0y;
- int tmp;
-
- // Project code-block partition origin to subband. Since the
- // origin is always 0 or 1, it projects to the low-pass side
- // (throught the ceil operator) as itself (i.e. no change) and
- // to the high-pass side (through the floor operator) as 0,
- // always.
- switch (sb.sbandIdx)
- {
-
- case Subband.WT_ORIENT_LL:
- // No need to project since all low-pass => nothing to do
- break;
-
- case Subband.WT_ORIENT_HL:
- acb0x = 0;
- break;
-
- case Subband.WT_ORIENT_LH:
- acb0y = 0;
- break;
-
- case Subband.WT_ORIENT_HH:
- acb0x = 0;
- acb0y = 0;
- break;
-
- default:
- throw new System.ApplicationException("Internal JJ2000 error");
-
- }
- if (sb.ulcx - acb0x < 0 || sb.ulcy - acb0y < 0)
- {
- throw new System.ArgumentException("Invalid code-blocks " + "partition origin or " + "image offset in the " + "reference grid.");
- }
- // NOTE: when calculating "floor()" by integer division the
- // dividend and divisor must be positive, we ensure that by
- // adding the divisor to the dividend and then substracting 1
- // to the result of the division
- tmp = sb.ulcx - acb0x + sb.nomCBlkW;
- sb.numCb.x = (tmp + sb.w - 1) / sb.nomCBlkW - (tmp / sb.nomCBlkW - 1);
- tmp = sb.ulcy - acb0y + sb.nomCBlkH;
- sb.numCb.y = (tmp + sb.h - 1) / sb.nomCBlkH - (tmp / sb.nomCBlkH - 1);
- }
- else
- {
- sb.numCb.x = sb.numCb.y = 0;
- }
- }
- else
- {
- initSubbandsFields(t, c, sb.LL);
- initSubbandsFields(t, c, sb.HL);
- initSubbandsFields(t, c, sb.LH);
- initSubbandsFields(t, c, sb.HH);
- }
- }
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/wavelet/analysis/ForwardWT.cs b/CSJ2K/j2k/wavelet/analysis/ForwardWT.cs
deleted file mode 100644
index 21a23794..00000000
--- a/CSJ2K/j2k/wavelet/analysis/ForwardWT.cs
+++ /dev/null
@@ -1,209 +0,0 @@
-/*
-* CVS identifier:
-*
-* $Id: ForwardWT.java,v 1.60 2001/09/14 09:54:53 grosbois Exp $
-*
-* Class: ForwardWT
-*
-* Description: This interface defines the specifics
-* of forward wavelet transforms
-*
-*
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-* */
-using CSJ2K.j2k.encoder;
-using CSJ2K.j2k.image;
-using CSJ2K.j2k.util;
-namespace CSJ2K.j2k.wavelet.analysis
-{
-
- /// This abstract class represents the forward wavelet transform functional
- /// block. The functional block may actually be comprised of several classes
- /// linked together, but a subclass of this abstract class is the one that is
- /// returned as the functional block that performs the forward wavelet
- /// transform.
- ///
- /// This class assumes that data is transferred in code-blocks, as defined
- /// by the 'CBlkWTDataSrc' interface. The internal calculation of the wavelet
- /// transform may be done differently but a buffering class should convert to
- /// that type of transfer.
- ///
- ///
- public abstract class ForwardWT : ImgDataAdapter, ForwWT, CBlkWTDataSrc
- {
- /// Returns the parameters that are used in this class and implementing
- /// classes. It returns a 2D String array. Each of the 1D arrays is for a
- /// different option, and they have 3 elements. The first element is the
- /// option name, the second one is the synopsis and the third one is a long
- /// description of what the parameter is. The synopsis or description may
- /// be 'null', in which case it is assumed that there is no synopsis or
- /// description of the option, respectively. Null may be returned if no
- /// options are supported.
- ///
- ///
- /// the options name, their synopsis and their explanation, or null
- /// if no options are supported.
- ///
- ///
- public static System.String[][] ParameterInfo
- {
- get
- {
- return pinfo;
- }
-
- }
- public abstract int CbULY { get; }
- public abstract int CbULX { get; }
-
- /// ID for the dyadic wavelet tree decomposition (also called "Mallat" in
- /// JPEG 2000): 0x00.
- ///
- ///
- public const int WT_DECOMP_DYADIC = 0;
-
- /// The prefix for wavelet transform options: 'W'
- public const char OPT_PREFIX = 'W';
-
- /// The list of parameters that is accepted for wavelet transform. Options
- /// for the wavelet transform start with 'W'.
- ///
- //UPGRADE_NOTE: Final was removed from the declaration of 'pinfo'. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
- private static readonly System.String[][] pinfo = new System.String[][] { new System.String[] { "Wlev", "", "Specifies the number of wavelet decomposition levels to apply to " + "the image. If 0 no wavelet transform is performed. All components " + "and all tiles have the same number of decomposition levels.", "5" }, new System.String[] { "Wwt", "[full]", "Specifies the wavelet transform to be used. Possible value is: " + "'full' (full page). The value 'full' performs a normal DWT.", "full" }, new System.String[] { "Wcboff", "", "Code-blocks partition offset in the reference grid. Allowed for " + " and are 0 and 1.\n" + "Note: This option is defined in JPEG 2000 part 2 and may not" + " be supported by all JPEG 2000 decoders.", "0 0" } };
-
- /// Initializes this object for the specified number of tiles 'nt' and
- /// components 'nc'.
- ///
- ///
- /// The source of ImgData
- ///
- ///
- protected internal ForwardWT(ImgData src) : base(src)
- {
- }
-
- /// Creates a ForwardWT object with the specified filters, and with other
- /// options specified in the parameter list 'pl'.
- ///
- ///
- /// The source of data to be transformed
- ///
- ///
- /// The parameter list (or options).
- ///
- ///
- /// The encoder specifications.
- ///
- ///
- /// A new ForwardWT object with the specified filters and options
- /// from 'pl'.
- ///
- ///
- /// If mandatory parameters are missing
- /// or if invalid values are given.
- ///
- ///
- public static ForwardWT createInstance(BlkImgDataSrc src, ParameterList pl, EncoderSpecs encSpec)
- {
- int deflev; // defdec removed
- //System.String decompstr;
- //System.String wtstr;
- //System.String pstr;
- //SupportClass.StreamTokenizerSupport stok;
- //SupportClass.Tokenizer strtok;
- //int prefx, prefy; // Partitioning reference point coordinates
-
- // Check parameters
- pl.checkList(OPT_PREFIX, CSJ2K.j2k.util.ParameterList.toNameArray(pinfo));
-
- deflev = ((System.Int32)encSpec.dls.getDefault());
-
- // Code-block partition origin
- System.String str = "";
- if (pl.getParameter("Wcboff") == null)
- {
- throw new System.ApplicationException("You must specify an argument to the '-Wcboff' " + "option. See usage with the '-u' option");
- }
- SupportClass.Tokenizer stk = new SupportClass.Tokenizer(pl.getParameter("Wcboff"));
- if (stk.Count != 2)
- {
- throw new System.ArgumentException("'-Wcboff' option needs two" + " arguments. See usage with " + "the '-u' option.");
- }
- int cb0x = 0;
- str = stk.NextToken();
- try
- {
- cb0x = (System.Int32.Parse(str));
- }
- catch (System.FormatException)
- {
- throw new System.ArgumentException("Bad first parameter for the " + "'-Wcboff' option: " + str);
- }
- if (cb0x < 0 || cb0x > 1)
- {
- throw new System.ArgumentException("Invalid horizontal " + "code-block partition origin.");
- }
- int cb0y = 0;
- str = stk.NextToken();
- try
- {
- cb0y = (System.Int32.Parse(str));
- }
- catch (System.FormatException)
- {
- throw new System.ArgumentException("Bad second parameter for the " + "'-Wcboff' option: " + str);
- }
- if (cb0y < 0 || cb0y > 1)
- {
- throw new System.ArgumentException("Invalid vertical " + "code-block partition origin.");
- }
- if (cb0x != 0 || cb0y != 0)
- {
- FacilityManager.getMsgLogger().printmsg(CSJ2K.j2k.util.MsgLogger_Fields.WARNING, "Code-blocks partition origin is " + "different from (0,0). This is defined in JPEG 2000" + " part 2 and may be not supported by all JPEG 2000 " + "decoders.");
- }
-
- return new ForwWTFull(src, encSpec, cb0x, cb0y);
- }
- public abstract bool isReversible(int param1, int param2);
- public abstract CSJ2K.j2k.wavelet.analysis.CBlkWTData getNextInternCodeBlock(int param1, CSJ2K.j2k.wavelet.analysis.CBlkWTData param2);
- public abstract int getFixedPoint(int param1);
- public abstract CSJ2K.j2k.wavelet.analysis.AnWTFilter[] getHorAnWaveletFilters(int param1, int param2);
- public abstract CSJ2K.j2k.wavelet.analysis.AnWTFilter[] getVertAnWaveletFilters(int param1, int param2);
- public abstract CSJ2K.j2k.wavelet.analysis.SubbandAn getAnSubbandTree(int param1, int param2);
- public abstract int getDecompLevels(int param1, int param2);
- public abstract CSJ2K.j2k.wavelet.analysis.CBlkWTData getNextCodeBlock(int param1, CSJ2K.j2k.wavelet.analysis.CBlkWTData param2);
- public abstract int getImplementationType(int param1);
- public abstract int getDataType(int param1, int param2);
- public abstract int getDecomp(int param1, int param2);
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/wavelet/analysis/SubbandAn.cs b/CSJ2K/j2k/wavelet/analysis/SubbandAn.cs
deleted file mode 100644
index c0a9a6c6..00000000
--- a/CSJ2K/j2k/wavelet/analysis/SubbandAn.cs
+++ /dev/null
@@ -1,513 +0,0 @@
-/*
-* CVS identifier:
-*
-* $Id: SubbandAn.java,v 1.30 2001/08/02 09:13:53 grosbois Exp $
-*
-* Class: SubbandAn
-*
-* Description: Element for a tree structure for a descripotion
-* of subbands on the anslysis side.
-*
-*
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-* */
-namespace CSJ2K.j2k.wavelet.analysis
-{
-
- /// This class represents a subband in a bidirectional tree structure that
- /// describes the subband decomposition for a wavelet transform, specifically
- /// for the analysis side.
- ///
- /// The element can be either a node or a leaf of the tree. If it is a node
- /// then ther are 4 descendants (LL, HL, LH and HH). If it is a leaf there are
- /// no descendants.
- ///
- /// The tree is bidirectional. Each element in the tree structure has a
- /// "parent", which is the subband from which the element was obtained by
- /// decomposition. The only exception is the root element which has no parent
- /// (i.e.it's null), for obvious reasons.
- ///
- ///
- public class SubbandAn : Subband
- {
- /// Returns the parent of this subband. The parent of a subband is the
- /// subband from which this one was obtained by decomposition. The root
- /// element has no parent subband (null).
- ///
- ///
- /// The parent subband, or null for the root one.
- ///
- ///
- override public Subband Parent
- {
- get
- {
- return parentband;
- }
-
- }
- /// Returns the LL child subband of this subband.
- ///
- ///
- /// The LL child subband, or null if there are no childs.
- ///
- ///
- override public Subband LL
- {
- get
- {
- return subb_LL;
- }
-
- }
- /// Returns the HL (horizontal high-pass) child subband of this subband.
- ///
- ///
- /// The HL child subband, or null if there are no childs.
- ///
- ///
- override public Subband HL
- {
- get
- {
- return subb_HL;
- }
-
- }
- /// Returns the LH (vertical high-pass) child subband of this subband.
- ///
- ///
- /// The LH child subband, or null if there are no childs.
- ///
- ///
- override public Subband LH
- {
- get
- {
- return subb_LH;
- }
-
- }
- /// Returns the HH child subband of this subband.
- ///
- ///
- /// The HH child subband, or null if there are no childs.
- ///
- ///
- override public Subband HH
- {
- get
- {
- return subb_HH;
- }
-
- }
- /// This function returns the horizontal wavelet filter relevant to this
- /// subband
- ///
- ///
- /// The horizontal wavelet filter
- ///
- ///
- override public WaveletFilter HorWFilter
- {
- get
- {
- return hFilter;
- }
-
- }
- /// This function returns the vertical wavelet filter relevant to this
- /// subband
- ///
- ///
- /// The vertical wavelet filter
- ///
- ///
- override public WaveletFilter VerWFilter
- {
- get
- {
- return hFilter;
- }
-
- }
-
- /// The reference to the parent of this subband. It is null for the root
- /// element. It is null by default.
- ///
- public SubbandAn parentband = null;
-
- /// The reference to the LL subband resulting from the decomposition of
- /// this subband. It is null by default.
- ///
- public SubbandAn subb_LL;
-
- /// The reference to the HL subband (horizontal high-pass) resulting from
- /// the decomposition of this subband. It is null by default.
- ///
- public SubbandAn subb_HL;
-
- /// The reference to the LH subband (vertical high-pass) resulting from
- /// the decomposition of this subband. It is null by default.
- ///
- ///
- public SubbandAn subb_LH;
-
- /// The reference to the HH subband resulting from the decomposition of
- /// this subband. It is null by default.
- ///
- public SubbandAn subb_HH;
-
- /// The horizontal analysis filter used to decompose this subband. This is
- /// applicable to "node" elements only. The default value is null.
- ///
- public AnWTFilter hFilter;
-
- /// The vertical analysis filter used to decompose this subband. This is
- /// applicable to "node" elements only. The default value is null.
- ///
- public AnWTFilter vFilter;
-
- /// The L2-norm of the synthesis basis waveform of this subband,
- /// applicable to "leafs" only. By default it is -1 (i.e. not calculated
- /// yet).
- ///
- ///
- public float l2Norm = -1.0f;
-
- /// The contribution to the MSE or WMSE error that would result in the
- /// image if there was an error of exactly one quantization step size in
- /// the sample of the subband. This value is expressed relative to a
- /// nominal dynamic range in the image domain of exactly 1.0. This field
- /// contains valid data only after quantization 9See Quantizer).
- ///
- ///
- ///
- ///
- ///
- public float stepWMSE;
-
- /// Creates a SubbandAn element with all the default values. The dimensions
- /// are (0,0) and the upper left corner is (0,0).
- ///
- ///
- public SubbandAn()
- {
- }
-
- /// Creates the top-level node and the entire subband tree, with the
- /// top-level dimensions, the number of decompositions, and the
- /// decomposition tree as specified.
- ///
- /// This constructor just calls the same constructor of the super class,
- /// and then calculates the L2-norm (or energy weight) of each leaf.
- ///
- /// This constructor does not initialize the value of the magBits or
- /// stepWMSE member variables. This variables are normally initialized by
- /// the quantizer (see Quantizer).
- ///
- ///
- /// The top-level width
- ///
- ///
- /// The top-level height
- ///
- ///
- /// The horizontal coordinate of the upper-left corner with
- /// respect to the canvas origin, in the component grid.
- ///
- ///
- /// The vertical coordinate of the upper-left corner with
- /// respect to the canvas origin, in the component grid.
- ///
- ///
- /// The number of levels (or LL decompositions) in the tree.
- ///
- ///
- /// The horizontal wavelet analysis filters for each
- /// resolution level, starting at resolution level 0.
- ///
- ///
- /// The vertical wavelet analysis filters for each
- /// resolution level, starting at resolution level 0.
- ///
- ///
- ///
- /// WaveletFilter[],WaveletFilter[])
- ///
- ///
- ///
- ///
- ///
- public SubbandAn(int w, int h, int ulcx, int ulcy, int lvls, WaveletFilter[] hfilters, WaveletFilter[] vfilters) : base(w, h, ulcx, ulcy, lvls, hfilters, vfilters)
- {
- // Caculate the L2-norms
- calcL2Norms();
- }
-
- /// Splits the current subband in its four subbands. It changes the status
- /// of this element (from a leaf to a node, and sets the filters), creates
- /// the childs and initializes them. An IllegalArgumentException is thrown
- /// if this subband is not a leaf.
- ///
- /// It uses the initChilds() method to initialize the childs.
- ///
- ///
- /// The horizontal wavelet filter used to decompose this
- /// subband. It has to be a AnWTFilter object.
- ///
- ///
- /// The vertical wavelet filter used to decompose this
- /// subband. It has to be a AnWTFilter object.
- ///
- ///
- /// A reference to the LL leaf (subb_LL).
- ///
- ///
- ///
- ///
- ///
- protected internal override Subband split(WaveletFilter hfilter, WaveletFilter vfilter)
- {
- // Test that this is a node
- if (isNode)
- {
- throw new System.ArgumentException();
- }
-
- // Modify this element into a node and set the filters
- isNode = true;
- this.hFilter = (AnWTFilter)hfilter;
- this.vFilter = (AnWTFilter)vfilter;
-
- // Create childs
- subb_LL = new SubbandAn();
- subb_LH = new SubbandAn();
- subb_HL = new SubbandAn();
- subb_HH = new SubbandAn();
-
- // Assign parent
- subb_LL.parentband = this;
- subb_HL.parentband = this;
- subb_LH.parentband = this;
- subb_HH.parentband = this;
-
- // Initialize childs
- initChilds();
-
- // Return reference to LL subband
- return subb_LL;
- }
-
- /// Calculates the basis waveform of the first leaf for which the L2-norm
- /// has not been calculated yet. This method searches recursively for the
- /// first leaf for which the value has not been calculated yet, and then
- /// calculates the L2-norm on the return path.
- ///
- /// The wfs argument should be a size 2 array of float arrays (i.e. 2D
- /// array) and it must be of length 2 (or more). When returning, wfs[0]
- /// will contain the line waveform, and wfs[1] will contain the column
- /// waveform.
- ///
- /// This method can not be called on an element that ahs a non-negative
- /// value in l2Norm, since that means that we are done.
- ///
- ///
- /// An size 2 array where the line and column waveforms will be
- /// returned.
- ///
- ///
- private void calcBasisWaveForms(float[][] wfs)
- {
- if (l2Norm < 0)
- {
- // We are not finished with this element yet
- if (isNode)
- {
- // We are on a node => search on childs
- if (subb_LL.l2Norm < 0f)
- {
- subb_LL.calcBasisWaveForms(wfs);
- wfs[0] = hFilter.getLPSynWaveForm(wfs[0], null);
- wfs[1] = vFilter.getLPSynWaveForm(wfs[1], null);
- }
- else if (subb_HL.l2Norm < 0f)
- {
- subb_HL.calcBasisWaveForms(wfs);
- wfs[0] = hFilter.getHPSynWaveForm(wfs[0], null);
- wfs[1] = vFilter.getLPSynWaveForm(wfs[1], null);
- }
- else if (subb_LH.l2Norm < 0f)
- {
- subb_LH.calcBasisWaveForms(wfs);
- wfs[0] = hFilter.getLPSynWaveForm(wfs[0], null);
- wfs[1] = vFilter.getHPSynWaveForm(wfs[1], null);
- }
- else if (subb_HH.l2Norm < 0f)
- {
- subb_HH.calcBasisWaveForms(wfs);
- wfs[0] = hFilter.getHPSynWaveForm(wfs[0], null);
- wfs[1] = vFilter.getHPSynWaveForm(wfs[1], null);
- }
- else
- {
- // There is an error! If all childs have non-negative
- // l2norm, then this node should have non-negative l2norm
- throw new System.ApplicationException("You have found a bug in JJ2000!");
- }
- }
- else
- {
- // This is a leaf, just use diracs (null is equivalent to
- // dirac)
- wfs[0] = new float[1];
- wfs[0][0] = 1.0f;
- wfs[1] = new float[1];
- wfs[1][0] = 1.0f;
- }
- }
- else
- {
- // This is an error! The calcBasisWaveForms() method is never
- // called on an element with non-negative l2norm
- throw new System.ApplicationException("You have found a bug in JJ2000!");
- }
- }
-
- /// Assigns the given L2-norm to the first leaf that does not have an
- /// L2-norm value yet (i.e. l2norm is negative). The search is done
- /// recursively and in the same order as that of the calcBasisWaveForms()
- /// method, so that this method is used to assigne the l2norm of the
- /// previously computed waveforms.
- ///
- /// This method can not be called on an element that ahs a non-negative
- /// value in l2Norm, since that means that we are done.
- ///
- ///
- /// The L2-norm to assign.
- ///
- ///
- private void assignL2Norm(float l2n)
- {
- if (l2Norm < 0)
- {
- // We are not finished with this element yet
- if (isNode)
- {
- // We are on a node => search on childs
- if (subb_LL.l2Norm < 0f)
- {
- subb_LL.assignL2Norm(l2n);
- }
- else if (subb_HL.l2Norm < 0f)
- {
- subb_HL.assignL2Norm(l2n);
- }
- else if (subb_LH.l2Norm < 0f)
- {
- subb_LH.assignL2Norm(l2n);
- }
- else if (subb_HH.l2Norm < 0f)
- {
- subb_HH.assignL2Norm(l2n);
- // If child now is done, we are done
- if (subb_HH.l2Norm >= 0f)
- {
- l2Norm = 0f; // We are on a node, any non-neg value OK
- }
- }
- else
- {
- // There is an error! If all childs have non-negative
- // l2norm, then this node should have non-negative l2norm
- throw new System.ApplicationException("You have found a bug in JJ2000!");
- }
- }
- else
- {
- // This is a leaf, assign the L2-norm
- l2Norm = l2n;
- }
- }
- else
- {
- // This is an error! The assignL2Norm() method is never called on
- // an element with non-negative l2norm
- throw new System.ApplicationException("You have found a bug in JJ2000!");
- }
- }
-
-
- /// Calculates the L2-norm of the sythesis waveforms of every leaf in the
- /// tree. This method should only be called on the root element.
- ///
- ///
- private void calcL2Norms()
- {
- int i;
- float[][] wfs = new float[2][];
- double acc;
- float l2n;
-
- // While we are not done on the root element, compute basis functions
- // and assign L2-norm
- while (l2Norm < 0f)
- {
- calcBasisWaveForms(wfs);
- // Compute line L2-norm, which is the product of the line
- // and column L2-norms
- acc = 0.0;
- for (i = wfs[0].Length - 1; i >= 0; i--)
- {
- acc += wfs[0][i] * wfs[0][i];
- }
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- l2n = (float)System.Math.Sqrt(acc);
- // Compute column L2-norm
- acc = 0.0;
- for (i = wfs[1].Length - 1; i >= 0; i--)
- {
- acc += wfs[1][i] * wfs[1][i];
- }
- //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
- l2n *= (float)System.Math.Sqrt(acc);
- // Release waveforms
- wfs[0] = null;
- wfs[1] = null;
- // Assign the value
- assignL2Norm(l2n);
- }
- }
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/wavelet/synthesis/CBlkWTDataSrcDec.cs b/CSJ2K/j2k/wavelet/synthesis/CBlkWTDataSrcDec.cs
deleted file mode 100644
index 5aec3e4c..00000000
--- a/CSJ2K/j2k/wavelet/synthesis/CBlkWTDataSrcDec.cs
+++ /dev/null
@@ -1,212 +0,0 @@
-/*
-* CVS identifier:
-*
-* $Id: CBlkWTDataSrcDec.java,v 1.19 2001/09/20 12:46:31 grosbois Exp $
-*
-* Class: CBlkWTDataSrcDec
-*
-* Description: Interface that define methods for trasnfer of WT
-* data in a code-block basis (decoder side).
-*
-*
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-* */
-using CSJ2K.j2k.image;
-namespace CSJ2K.j2k.wavelet.synthesis
-{
-
- /// This abstract class defines methods to transfer wavelet data in a
- /// code-block by code-block basis, for the decoder side. In each call to
- /// 'getCodeBlock()' or 'getInternCodeBlock()' a new code-block is
- /// returned. The code-blocks are returned in no specific order.
- ///
- /// This class is the source of data, in general, for the inverse wavelet
- /// transforms. See the 'InverseWT' class.
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- public interface CBlkWTDataSrcDec : InvWTData
- {
-
- /// Returns the number of bits, referred to as the "range bits",
- /// corresponding to the nominal range of the data in the specified
- /// component.
- ///
- /// The returned value corresponds to the nominal dynamic range of the
- /// reconstructed image data, not of the wavelet coefficients
- /// themselves. This is because different subbands have different gains and
- /// thus different nominal ranges. To have an idea of the nominal range in
- /// each subband the subband analysis gain value from the subband tree
- /// structure, returned by the 'getSynSubbandTree()' method, can be
- /// used. See the 'Subband' class for more details.
- ///
- /// If this number is b then for unsigned data the nominal range
- /// is between 0 and 2^b-1, and for signed data it is between -2^(b-1) and
- /// 2^(b-1)-1.
- ///
- ///
- /// The index of the component.
- ///
- ///
- /// The number of bits corresponding to the nominal range of the
- /// data.
- ///
- ///
- ///
- ///
- ///
- int getNomRangeBits(int c);
-
- /// Returns the position of the fixed point in the specified component, or
- /// equivalently the number of fractional bits. This is the position of the
- /// least significant integral (i.e. non-fractional) bit, which is
- /// equivalent to the number of fractional bits. For instance, for
- /// fixed-point values with 2 fractional bits, 2 is returned. For
- /// floating-point data this value does not apply and 0 should be
- /// returned. Position 0 is the position of the least significant bit in
- /// the data.
- ///
- ///
- /// The index of the component.
- ///
- ///
- /// The position of the fixed-point, which is the same as the
- /// number of fractional bits. For floating-point data 0 is returned.
- ///
- ///
- int getFixedPoint(int c);
-
- /// Returns the specified code-block in the current tile for the specified
- /// component, as a copy (see below).
- ///
- /// The returned code-block may be progressive, which is indicated by
- /// the 'progressive' variable of the returned 'DataBlk' object. If a
- /// code-block is progressive it means that in a later request to this
- /// method for the same code-block it is possible to retrieve data which is
- /// a better approximation, since meanwhile more data to decode for the
- /// code-block could have been received. If the code-block is not
- /// progressive then later calls to this method for the same code-block
- /// will return the exact same data values.
- ///
- /// The data returned by this method is always a copy of the internal
- /// data of this object, if any, and it can be modified "in place" without
- /// any problems after being returned. The 'offset' of the returned data is
- /// 0, and the 'scanw' is the same as the code-block width. See the
- /// 'DataBlk' class.
- ///
- ///
- /// The component for which to return the next code-block.
- ///
- ///
- /// The vertical index of the code-block to return,
- /// in the specified subband.
- ///
- ///
- /// The horizontal index of the code-block to return,
- /// in the specified subband.
- ///
- ///
- /// The subband in which the code-block to return is.
- ///
- ///
- /// If non-null this object will be used to return the new
- /// code-block. If null a new one will be allocated and returned. If the
- /// "data" array of the object is non-null it will be reused, if possible,
- /// to return the data.
- ///
- ///
- /// The next code-block in the current tile for component 'n', or
- /// null if all code-blocks for the current tile have been returned.
- ///
- ///
- ///
- ///
- ///
- DataBlk getCodeBlock(int c, int m, int n, SubbandSyn sb, DataBlk cblk);
-
- /// Returns the specified code-block in the current tile for the specified
- /// component (as a reference or copy).
- ///
- /// The returned code-block may be progressive, which is indicated by
- /// the 'progressive' variable of the returned 'DataBlk' object. If a
- /// code-block is progressive it means that in a later request to this
- /// method for the same code-block it is possible to retrieve data which is
- /// a better approximation, since meanwhile more data to decode for the
- /// code-block could have been received. If the code-block is not
- /// progressive then later calls to this method for the same code-block
- /// will return the exact same data values.
- ///
- /// The data returned by this method can be the data in the internal
- /// buffer of this object, if any, and thus can not be modified by the
- /// caller. The 'offset' and 'scanw' of the returned data can be
- /// arbitrary. See the 'DataBlk' class.
- ///
- ///
- /// The component for which to return the next code-block.
- ///
- ///
- /// The vertical index of the code-block to return, in the
- /// specified subband.
- ///
- ///
- /// The horizontal index of the code-block to return, in the
- /// specified subband.
- ///
- ///
- /// The subband in which the code-block to return is.
- ///
- ///
- /// If non-null this object will be used to return the new
- /// code-block. If null a new one will be allocated and returned. If the
- /// "data" array of the object is non-null it will be reused, if possible,
- /// to return the data.
- ///
- ///
- /// The next code-block in the current tile for component 'n', or
- /// null if all code-blocks for the current tile have been returned.
- ///
- ///
- ///
- ///
- ///
- DataBlk getInternCodeBlock(int c, int m, int n, SubbandSyn sb, DataBlk cblk);
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/wavelet/synthesis/InvWT.cs b/CSJ2K/j2k/wavelet/synthesis/InvWT.cs
deleted file mode 100644
index c4de4ec1..00000000
--- a/CSJ2K/j2k/wavelet/synthesis/InvWT.cs
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
-* CVS identifier:
-*
-* $Id:
-*
-* Class: InvWT
-*
-* Description: The interface for implementations of a inverse
-* wavelet transform.
-*
-*
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-* */
-namespace CSJ2K.j2k.wavelet.synthesis
-{
-
- /// This interface extends the WaveletTransform with the specifics of inverse
- /// wavelet transforms. Classes that implement inverse wavelet transfoms should
- /// implement this interface.
- ///
- /// This class does not define the methods to transfer data, just the
- /// specifics to inverse wavelet transform. Different data transfer methods are
- /// envisageable for different transforms.
- ///
- ///
- public interface InvWT : WaveletTransform
- {
- /// Sets the image reconstruction resolution level. A value of 0 means
- /// reconstruction of an image with the lowest resolution (dimension)
- /// available.
- ///
- /// Note: Image resolution level indexes may differ from tile-component
- /// resolution index. They are indeed indexed starting from the lowest
- /// number of decomposition levels of each component of each tile.
- ///
- /// Example: For an image (1 tile) with 2 components (component 0 having
- /// 2 decomposition levels and component 1 having 3 decomposition levels),
- /// the first (tile-) component has 3 resolution levels and the second one
- /// has 4 resolution levels, whereas the image has only 3 resolution levels
- /// available.
- ///
- ///
- /// The image resolution level.
- ///
- ///
- /// The vertical coordinate of the image origin in the canvas
- /// system, on the reference grid.
- ///
- ///
- int ImgResLevel
- {
- set;
-
- }
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/wavelet/synthesis/InvWTAdapter.cs b/CSJ2K/j2k/wavelet/synthesis/InvWTAdapter.cs
deleted file mode 100644
index f3713e7f..00000000
--- a/CSJ2K/j2k/wavelet/synthesis/InvWTAdapter.cs
+++ /dev/null
@@ -1,592 +0,0 @@
-/*
-* CVS identifier:
-*
-* $Id: InvWTAdapter.java,v 1.14 2002/07/25 15:11:03 grosbois Exp $
-*
-* Class: InvWTAdapter
-*
-* Description:
-*
-*
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-* */
-using CSJ2K.j2k.decoder;
-using CSJ2K.j2k.image;
-namespace CSJ2K.j2k.wavelet.synthesis
-{
-
- /// This class provides default implementation of the methods in the 'InvWT'
- /// interface. The source is always a 'MultiResImgData', which is a
- /// multi-resolution image. The default implementation is just to return the
- /// value of the source at the current image resolution level, which is set by
- /// the 'setImgResLevel()' method.
- ///
- /// This abstract class can be used to facilitate the development of other
- /// classes that implement the 'InvWT' interface, because most of the trivial
- /// methods are already implemented.
- ///
- /// If the default implementation of a method provided in this class does
- /// not suit a particular implementation of the 'InvWT' interface, the method
- /// can be overriden to implement the proper behaviour.
- ///
- /// If the 'setImgResLevel()' method is overriden then it is very important
- /// that the one of this class is called from the overriding method, so that
- /// the other methods in this class return the correct values.
- ///
- ///
- ///
- ///
- ///
- public abstract class InvWTAdapter : InvWT
- {
- /// Sets the image reconstruction resolution level. A value of 0 means
- /// reconstruction of an image with the lowest resolution (dimension)
- /// available.
- ///
- /// Note: Image resolution level indexes may differ from tile-component
- /// resolution index. They are indeed indexed starting from the lowest
- /// number of decomposition levels of each component of each tile.
- ///
- /// Example: For an image (1 tile) with 2 components (component 0 having
- /// 2 decomposition levels and component 1 having 3 decomposition levels),
- /// the first (tile-) component has 3 resolution levels and the second one
- /// has 4 resolution levels, whereas the image has only 3 resolution levels
- /// available.
- ///
- ///
- /// The image resolution level.
- ///
- ///
- /// The vertical coordinate of the image origin in the canvas
- /// system, on the reference grid.
- ///
- ///
- virtual public int ImgResLevel
- {
- set
- {
- if (value < 0)
- {
- throw new System.ArgumentException("Resolution level index " + "cannot be negative.");
- }
- reslvl = value;
- }
-
- }
- /// Returns the overall width of the current tile in pixels. This is the
- /// tile's width without accounting for any component subsampling. This is
- /// also referred as the reference grid width in the current tile.
- ///
- /// This default implementation returns the value of the source at the
- /// current reconstruction resolution level.
- ///
- ///
- /// The total current tile's width in pixels.
- ///
- ///
- virtual public int TileWidth
- {
- get
- {
- // Retrieves the tile maximum resolution level index and request the
- // width from the source module.
- int tIdx = TileIdx;
- int rl = 10000;
- int mrl;
- int nc = mressrc.NumComps;
- for (int c = 0; c < nc; c++)
- {
- mrl = mressrc.getSynSubbandTree(tIdx, c).resLvl;
- if (mrl < rl)
- rl = mrl;
- }
- return mressrc.getTileWidth(rl);
- }
-
- }
- /// Returns the overall height of the current tile in pixels. This
- /// is the tile's height without accounting for any component
- /// subsampling. This is also referred as the reference grid height
- /// in the current tile.
- ///
- /// This default implementation returns the value of the source at the
- /// current reconstruction resolution level.
- ///
- ///
- /// The total current tile's height in pixels.
- ///
- ///
- virtual public int TileHeight
- {
- get
- {
- // Retrieves the tile maximum resolution level index and request the
- // height from the source module.
- int tIdx = TileIdx;
- int rl = 10000;
- int mrl;
- int nc = mressrc.NumComps;
- for (int c = 0; c < nc; c++)
- {
- mrl = mressrc.getSynSubbandTree(tIdx, c).resLvl;
- if (mrl < rl)
- rl = mrl;
- }
- return mressrc.getTileHeight(rl);
- }
-
- }
- /// Returns the nominal width of tiles
- virtual public int NomTileWidth
- {
- get
- {
- return mressrc.NomTileWidth;
- }
-
- }
- /// Returns the nominal height of tiles
- virtual public int NomTileHeight
- {
- get
- {
- return mressrc.NomTileHeight;
- }
-
- }
- /// Returns the overall width of the image in pixels. This is the
- /// image's width without accounting for any component subsampling
- /// or tiling.
- ///
- ///
- /// The total image's width in pixels.
- ///
- ///
- virtual public int ImgWidth
- {
- get
- {
- return mressrc.getImgWidth(reslvl);
- }
-
- }
- /// Returns the overall height of the image in pixels. This is the
- /// image's height without accounting for any component subsampling
- /// or tiling.
- ///
- ///
- /// The total image's height in pixels.
- ///
- ///
- virtual public int ImgHeight
- {
- get
- {
- return mressrc.getImgHeight(reslvl);
- }
-
- }
- /// Returns the number of components in the image.
- ///
- ///
- /// The number of components in the image.
- ///
- ///
- virtual public int NumComps
- {
- get
- {
- return mressrc.NumComps;
- }
-
- }
- /// Returns the index of the current tile, relative to a standard scan-line
- /// order.
- ///
- /// This default implementation returns the value of the source.
- ///
- ///
- /// The current tile's index (starts at 0).
- ///
- ///
- virtual public int TileIdx
- {
- get
- {
- return mressrc.TileIdx;
- }
-
- }
- /// Returns the horizontal coordinate of the image origin, the top-left
- /// corner, in the canvas system, on the reference grid.
- ///
- /// This default implementation returns the value of the source at the
- /// current reconstruction resolution level.
- ///
- ///
- /// The horizontal coordinate of the image origin in the canvas
- /// system, on the reference grid.
- ///
- ///
- virtual public int ImgULX
- {
- get
- {
- return mressrc.getImgULX(reslvl);
- }
-
- }
- /// Returns the vertical coordinate of the image origin, the top-left
- /// corner, in the canvas system, on the reference grid.
- ///
- /// This default implementation returns the value of the source at the
- /// current reconstruction resolution level.
- ///
- ///
- /// The vertical coordinate of the image origin in the canvas
- /// system, on the reference grid.
- ///
- ///
- virtual public int ImgULY
- {
- get
- {
- return mressrc.getImgULY(reslvl);
- }
-
- }
- /// Returns the horizontal tile partition offset in the reference grid
- virtual public int TilePartULX
- {
- get
- {
- return mressrc.TilePartULX;
- }
-
- }
- /// Returns the vertical tile partition offset in the reference grid
- virtual public int TilePartULY
- {
- get
- {
- return mressrc.TilePartULY;
- }
-
- }
-
- /// The decoder specifications
- protected internal DecoderSpecs decSpec;
-
- /// The 'MultiResImgData' source
- protected internal MultiResImgData mressrc;
-
- /// The resquested image resolution level for reconstruction.
- protected internal int reslvl;
-
- /// The maximum available image resolution level
- protected internal int maxImgRes;
-
- /// Instantiates the 'InvWTAdapter' object using the specified
- /// 'MultiResImgData' source. The reconstruction resolution level is set to
- /// full resolution (i.e. the maximum resolution level).
- ///
- ///
- /// From where to obtain the values to return
- ///
- ///
- /// The decoder specifications
- ///
- ///
- protected internal InvWTAdapter(MultiResImgData src, DecoderSpecs decSpec)
- {
- mressrc = src;
- this.decSpec = decSpec;
- maxImgRes = decSpec.dls.Min;
- }
-
- /// Returns the component subsampling factor in the horizontal
- /// direction, for the specified component. This is, approximately,
- /// the ratio of dimensions between the reference grid and the
- /// component itself, see the 'ImgData' interface desription for
- /// details.
- ///
- ///
- /// The index of the component (between 0 and N-1).
- ///
- ///
- /// The horizontal subsampling factor of component 'c'.
- ///
- ///
- ///
- ///
- ///
- public virtual int getCompSubsX(int c)
- {
- return mressrc.getCompSubsX(c);
- }
-
- /// Returns the component subsampling factor in the vertical
- /// direction, for the specified component. This is, approximately,
- /// the ratio of dimensions between the reference grid and the
- /// component itself, see the 'ImgData' interface desription for
- /// details.
- ///
- ///
- /// The index of the component (between 0 and N-1).
- ///
- ///
- /// The vertical subsampling factor of component 'c'.
- ///
- ///
- ///
- ///
- ///
- public virtual int getCompSubsY(int c)
- {
- return mressrc.getCompSubsY(c);
- }
-
- /// Returns the width in pixels of the specified tile-component
- ///
- ///
- /// Tile index
- ///
- ///
- /// The index of the component, from 0 to N-1.
- ///
- ///
- /// The width in pixels of component n in tile t.
- ///
- ///
- public virtual int getTileCompWidth(int t, int c)
- {
- // Retrieves the tile-component maximum resolution index and gets the
- // width from the source.
- int rl = mressrc.getSynSubbandTree(t, c).resLvl;
- return mressrc.getTileCompWidth(t, c, rl);
- }
-
- /// Returns the height in pixels of the specified tile-component.
- ///
- /// This default implementation returns the value of the source at the
- /// current reconstruction resolution level.
- ///
- ///
- /// The tile index.
- ///
- ///
- /// The index of the component, from 0 to N-1.
- ///
- ///
- /// The height in pixels of component n in tile
- /// t.
- ///
- ///
- public virtual int getTileCompHeight(int t, int c)
- {
- // Retrieves the tile-component maximum resolution index and gets the
- // height from the source.
- int rl = mressrc.getSynSubbandTree(t, c).resLvl;
- return mressrc.getTileCompHeight(t, c, rl);
- }
-
- /// Returns the width in pixels of the specified component in the overall
- /// image.
- ///
- ///
- /// The index of the component, from 0 to N-1.
- ///
- ///
- /// The width in pixels of component c in the overall
- /// image.
- ///
- ///
- public virtual int getCompImgWidth(int c)
- {
- // Retrieves the component maximum resolution index and gets the width
- // from the source module.
- int rl = decSpec.dls.getMinInComp(c);
- return mressrc.getCompImgWidth(c, rl);
- }
-
- /// Returns the height in pixels of the specified component in the overall
- /// image.
- ///
- /// This default implementation returns the value of the source at the
- /// current reconstruction resolution level.
- ///
- ///
- /// The index of the component, from 0 to N-1.
- ///
- ///
- /// The height in pixels of component n in the overall
- /// image.
- ///
- ///
- public virtual int getCompImgHeight(int c)
- {
- // Retrieves the component maximum resolution index and gets the
- // height from the source module.
- int rl = decSpec.dls.getMinInComp(c);
- return mressrc.getCompImgHeight(c, rl);
- }
-
- /// Changes the current tile, given the new indices. An
- /// IllegalArgumentException is thrown if the coordinates do not correspond
- /// to a valid tile.
- ///
- /// This default implementation calls the same method on the source.
- ///
- ///
- /// The horizontal index of the tile.
- ///
- ///
- /// The vertical index of the new tile.
- ///
- ///
- public virtual void setTile(int x, int y)
- {
- mressrc.setTile(x, y);
- }
-
- /// Advances to the next tile, in standard scan-line order (by rows then
- /// columns). An NoNextElementException is thrown if the current tile is
- /// the last one (i.e. there is no next tile).
- ///
- /// This default implementation calls the same method on the source.
- ///
- ///
- public virtual void nextTile()
- {
- mressrc.nextTile();
- }
-
- /// Returns the indixes of the current tile. These are the horizontal and
- /// vertical indexes of the current tile.
- ///
- /// This default implementation returns the value of the source.
- ///
- ///
- /// If not null this object is used to return the information. If
- /// null a new one is created and returned.
- ///
- ///
- /// The current tile's indices (vertical and horizontal indexes).
- ///
- ///
- public virtual Coord getTile(Coord co)
- {
- return mressrc.getTile(co);
- }
-
- /// Returns the horizontal coordinate of the upper-left corner of the
- /// specified component in the current tile.
- ///
- ///
- /// The component index.
- ///
- ///
- public virtual int getCompULX(int c)
- {
- // Find tile-component maximum resolution index and gets information
- // from the source module.
- int tIdx = TileIdx;
- int rl = mressrc.getSynSubbandTree(tIdx, c).resLvl;
- return mressrc.getResULX(c, rl);
- }
-
- /// Returns the vertical coordinate of the upper-left corner of the
- /// specified component in the current tile.
- ///
- ///
- /// The component index.
- ///
- ///
- public virtual int getCompULY(int c)
- {
- // Find tile-component maximum resolution index and gets information
- // from the source module.
- int tIdx = TileIdx;
- int rl = mressrc.getSynSubbandTree(tIdx, c).resLvl;
- return mressrc.getResULY(c, rl);
- }
-
- /// Returns the number of tiles in the horizontal and vertical directions.
- ///
- /// This default implementation returns the value of the source.
- ///
- ///
- /// If not null this object is used to return the information. If
- /// null a new one is created and returned.
- ///
- ///
- /// The number of tiles in the horizontal (Coord.x) and vertical
- /// (Coord.y) directions.
- ///
- ///
- public virtual Coord getNumTiles(Coord co)
- {
- return mressrc.getNumTiles(co);
- }
-
- /// Returns the total number of tiles in the image.
- ///
- /// This default implementation returns the value of the source.
- ///
- ///
- /// The total number of tiles in the image.
- ///
- ///
- public virtual int getNumTiles()
- {
- return mressrc.getNumTiles();
- }
-
- /// Returns the specified synthesis subband tree
- ///
- ///
- /// Tile index.
- ///
- ///
- /// Component index.
- ///
- ///
- public virtual SubbandSyn getSynSubbandTree(int t, int c)
- {
- return mressrc.getSynSubbandTree(t, c);
- }
- public abstract bool isReversible(int param1, int param2);
- public abstract int getNomRangeBits(int param1);
- public abstract int getImplementationType(int param1);
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/wavelet/synthesis/InvWTData.cs b/CSJ2K/j2k/wavelet/synthesis/InvWTData.cs
deleted file mode 100644
index 446cf810..00000000
--- a/CSJ2K/j2k/wavelet/synthesis/InvWTData.cs
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
-* CVS identifier:
-*
-* $Id: InvWTData.java,v 1.15 2001/09/20 13:07:09 grosbois Exp $
-*
-* Class: InvWTData
-*
-* Description:
-*
-*
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-* */
-namespace CSJ2K.j2k.wavelet.synthesis
-{
-
- /// This interface extends the MultiResImgData interface with the methods that
- /// are necessary for inverse wavelet data (i.e. data that is the source to an
- /// inverse wavlet trasnform).
- ///
- ///
- public interface InvWTData : MultiResImgData
- {
- /// Returns the horizontal code-block partition origin. Allowable values
- /// are 0 and 1, nothing else.
- ///
- ///
- int CbULX
- {
- get;
-
- }
- /// Returns the vertical code-block partition origin Allowable values are 0
- /// and 1, nothing else.
- ///
- ///
- int CbULY
- {
- get;
-
- }
-
- /// Returns the subband tree, for the specified tile-component. This method
- /// returns the root element of the subband tree structure, see 'Subband'
- /// and 'SubbandSyn'. The tree comprises all the available resolution
- /// levels.
- ///
- ///
- /// The index of the tile, from 0 to T-1.
- ///
- ///
- /// The index of the component, from 0 to C-1.
- ///
- ///
- /// The root of the tree structure.
- ///
- ///
- new SubbandSyn getSynSubbandTree(int t, int c);
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/wavelet/synthesis/InvWTFull.cs b/CSJ2K/j2k/wavelet/synthesis/InvWTFull.cs
deleted file mode 100644
index 2a8a1140..00000000
--- a/CSJ2K/j2k/wavelet/synthesis/InvWTFull.cs
+++ /dev/null
@@ -1,738 +0,0 @@
-/*
-* CVS identifier:
-*
-* $Id: InvWTFull.java,v 1.20 2002/05/22 15:01:32 grosbois Exp $
-*
-* Class: InvWTFull
-*
-* Description: This class implements a full page inverse DWT for
-* int and float data.
-*
-* the InvWTFullInt and InvWTFullFloat
-* classes by Bertrand Berthelot, Apr-19-1999
-*
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-* */
-using CSJ2K.j2k.decoder;
-using CSJ2K.j2k.image;
-using CSJ2K.j2k.util;
-using System;
-using System.Collections.Generic;
-namespace CSJ2K.j2k.wavelet.synthesis
-{
-
- /// This class implements the InverseWT with the full-page approach for int and
- /// float data.
- ///
- /// The image can be reconstructed at different (image) resolution levels
- /// indexed from the lowest resolution available for each tile-component. This
- /// is controlled by the setImgResLevel() method.
- ///
- /// Note: Image resolution level indexes may differ from tile-component
- /// resolution index. They are indeed indexed starting from the lowest number
- /// of decomposition levels of each component of each tile.
- ///
- /// Example: For an image (1 tile) with 2 components (component 0 having 2
- /// decomposition levels and component 1 having 3 decomposition levels), the
- /// first (tile-) component has 3 resolution levels and the second one has 4
- /// resolution levels, whereas the image has only 3 resolution levels
- /// available.
- ///
- /// This implementation does not support progressive data: Data is
- /// considered to be non-progressive (i.e. "final" data) and the 'progressive'
- /// attribute of the 'DataBlk' class is always set to false, see the 'DataBlk'
- /// class.
- ///
- ///
- ///
- ///
- ///
- 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;
-
- /// The number of already decoded code-blocks
- private int nDecCblk = 0;
-
- /// the code-block buffer's source i.e. the quantizer
- private CBlkWTDataSrcDec src;
-
- /// Current data type
- private int dtype;
-
- /// Block storing the reconstructed image for each component
- private DataBlk[] reconstructedComps;
-
- /// Number of decomposition levels in each component
- private int[] ndl;
-
- /// The reversible flag for each component in each tile. The first index is
- /// the tile index, the second one is the component index. The
- /// reversibility of the components for each tile are calculated on a as
- /// needed basis.
- ///
- ///
- private Dictionary reversible = new Dictionary();
- //private bool[][] reversible;
-
- /// Initializes this object with the given source of wavelet
- /// coefficients. It initializes the resolution level for full resolutioin
- /// reconstruction.
- ///
- ///
- /// from where the wavelet coefficinets should be obtained.
- ///
- ///
- /// The decoder specifications
- ///
- ///
- public InvWTFull(CBlkWTDataSrcDec src, DecoderSpecs decSpec) : base(src, decSpec)
- {
- this.src = src;
- int nc = src.NumComps;
- reconstructedComps = new DataBlk[nc];
- ndl = new int[nc];
- pw = FacilityManager.ProgressWatch;
- }
-
- /// Returns the reversibility of the current subband. It computes
- /// iteratively the reversibility of the child subbands. For each subband
- /// it tests the reversibility of the horizontal and vertical synthesis
- /// filters used to reconstruct this subband.
- ///
- ///
- /// The current subband.
- ///
- ///
- /// true if all the filters used to reconstruct the current
- /// subband are reversible
- ///
- ///
- private bool isSubbandReversible(Subband subband)
- {
- if (subband.isNode)
- {
- // It's reversible if the filters to obtain the 4 subbands are
- // reversible and the ones for this one are reversible too.
- return isSubbandReversible(subband.LL) && isSubbandReversible(subband.HL) && isSubbandReversible(subband.LH) && isSubbandReversible(subband.HH) && ((SubbandSyn)subband).hFilter.Reversible && ((SubbandSyn)subband).vFilter.Reversible;
- }
- else
- {
- // Leaf subband. Reversibility of data depends on source, so say
- // it's true
- return true;
- }
- }
-
- /// Returns the reversibility of the wavelet transform for the specified
- /// component, in the current tile. A wavelet transform is reversible when
- /// it is suitable for lossless and lossy-to-lossless compression.
- ///
- ///
- /// The index of the tile.
- ///
- ///
- /// The index of the component.
- ///
- ///
- /// true is the wavelet transform is reversible, false if not.
- ///
- ///
- public override bool isReversible(int t, int c)
- {
- if (reversible[t] == null)
- {
- // Reversibility not yet calculated for this tile
- reversible[t] = new bool[NumComps];
- for (int i = reversible[t].Length - 1; i >= 0; i--)
- {
- reversible[t][i] = isSubbandReversible(src.getSynSubbandTree(t, i));
- }
- }
- return reversible[t][c];
- }
-
- /// Returns the number of bits, referred to as the "range bits",
- /// corresponding to the nominal range of the data in the specified
- /// component.
- ///
- /// The returned value corresponds to the nominal dynamic range of the
- /// reconstructed image data, as long as the getNomRangeBits() method of
- /// the source returns a value corresponding to the nominal dynamic range
- /// of the image data and not not of the wavelet coefficients.
- ///
- /// If this number is b then for unsigned data the nominal range
- /// is between 0 and 2^b-1, and for signed data it is between -2^(b-1) and
- /// 2^(b-1)-1.
- ///
- ///
- /// The index of the component.
- ///
- ///
- /// The number of bits corresponding to the nominal range of the
- /// data.
- ///
- ///
- public override int getNomRangeBits(int c)
- {
- return src.getNomRangeBits(c);
- }
-
- /// Returns the position of the fixed point in the specified
- /// component. This is the position of the least significant integral
- /// (i.e. non-fractional) bit, which is equivalent to the number of
- /// fractional bits. For instance, for fixed-point values with 2 fractional
- /// bits, 2 is returned. For floating-point data this value does not apply
- /// and 0 should be returned. Position 0 is the position of the least
- /// significant bit in the data.
- ///
- /// This default implementation assumes that the wavelet transform does
- /// not modify the fixed point. If that were the case this method should be
- /// overriden.
- ///
- ///
- /// The index of the component.
- ///
- ///
- /// The position of the fixed-point, which is the same as the
- /// number of fractional bits. For floating-point data 0 is returned.
- ///
- ///
- public override int getFixedPoint(int c)
- {
- return src.getFixedPoint(c);
- }
-
- /// Returns a block of image data containing the specifed rectangular area,
- /// in the specified component, as a reference to the internal buffer (see
- /// below). The rectangular area is specified by the coordinates and
- /// dimensions of the 'blk' object.
- ///
- /// The area to return is specified by the 'ulx', 'uly', 'w' and 'h'
- /// members of the 'blk' argument. These members are not modified by this
- /// method.
- ///
- /// The data returned by this method can be the data in the internal
- /// buffer of this object, if any, and thus can not be modified by the
- /// caller. The 'offset' and 'scanw' of the returned data can be
- /// arbitrary. See the 'DataBlk' class.
- ///
- /// The returned data has its 'progressive' attribute unset
- /// (i.e. false).
- ///
- ///
- /// Its coordinates and dimensions specify the area to return.
- ///
- ///
- /// The index of the component from which to get the data.
- ///
- ///
- /// The requested DataBlk
- ///
- ///
- ///
- ///
- ///
- public override DataBlk getInternCompData(DataBlk blk, int c)
- {
- int tIdx = TileIdx;
- if (src.getSynSubbandTree(tIdx, c).HorWFilter == null)
- {
- dtype = DataBlk.TYPE_INT;
- }
- else
- {
- dtype = src.getSynSubbandTree(tIdx, c).HorWFilter.DataType;
- }
-
- //If the source image has not been decomposed
- if (reconstructedComps[c] == null)
- {
- //Allocate component data buffer
- switch (dtype)
- {
-
- case DataBlk.TYPE_FLOAT:
- reconstructedComps[c] = new DataBlkFloat(0, 0, getTileCompWidth(tIdx, c), getTileCompHeight(tIdx, c));
- break;
-
- case DataBlk.TYPE_INT:
- reconstructedComps[c] = new DataBlkInt(0, 0, getTileCompWidth(tIdx, c), getTileCompHeight(tIdx, c));
- break;
- }
- //Reconstruct source image
- waveletTreeReconstruction(reconstructedComps[c], src.getSynSubbandTree(tIdx, c), c);
- if (pw != null && c == src.NumComps - 1)
- {
- pw.terminateProgressWatch();
- }
- }
-
- if (blk.DataType != dtype)
- {
- if (dtype == DataBlk.TYPE_INT)
- {
- blk = new DataBlkInt(blk.ulx, blk.uly, blk.w, blk.h);
- }
- else
- {
- blk = new DataBlkFloat(blk.ulx, blk.uly, blk.w, blk.h);
- }
- }
- // Set the reference to the internal buffer
- blk.Data = reconstructedComps[c].Data;
- blk.offset = reconstructedComps[c].w * blk.uly + blk.ulx;
- blk.scanw = reconstructedComps[c].w;
- blk.progressive = false;
- return blk;
- }
-
- /// Returns a block of image data containing the specifed rectangular area,
- /// in the specified component, as a copy (see below). The rectangular area
- /// is specified by the coordinates and dimensions of the 'blk' object.
- ///
- /// The area to return is specified by the 'ulx', 'uly', 'w' and 'h'
- /// members of the 'blk' argument. These members are not modified by this
- /// method.
- ///
- /// The data returned by this method is always a copy of the internal
- /// data of this object, if any, and it can be modified "in place" without
- /// any problems after being returned. The 'offset' of the returned data is
- /// 0, and the 'scanw' is the same as the block's width. See the 'DataBlk'
- /// class.
- ///
- /// If the data array in 'blk' is null, then a new one is
- /// created. If the data array is not null then it must be big
- /// enough to contain the requested area.
- ///
- /// The returned data always has its 'progressive' attribute unset (i.e
- /// false)
- ///
- ///
- /// Its coordinates and dimensions specify the area to
- /// return. If it contains a non-null data array, then it must be large
- /// enough. If it contains a null data array a new one is created. The
- /// fields in this object are modified to return the data.
- ///
- ///
- /// The index of the component from which to get the data.
- ///
- ///
- /// The requested DataBlk
- ///
- ///
- ///
- ///
- ///
- public override DataBlk getCompData(DataBlk blk, int c)
- {
- //int j;
- System.Object dst_data; // src_data removed
- int[] dst_data_int; // src_data_int removed
- float[] dst_data_float; // src_data_float removed
-
- // To keep compiler happy
- dst_data = null;
-
- // Ensure output buffer
- switch (blk.DataType)
- {
-
- case DataBlk.TYPE_INT:
- dst_data_int = (int[])blk.Data;
- if (dst_data_int == null || dst_data_int.Length < blk.w * blk.h)
- {
- dst_data_int = new int[blk.w * blk.h];
- }
- dst_data = dst_data_int;
- break;
-
- case DataBlk.TYPE_FLOAT:
- dst_data_float = (float[])blk.Data;
- if (dst_data_float == null || dst_data_float.Length < blk.w * blk.h)
- {
- dst_data_float = new float[blk.w * blk.h];
- }
- dst_data = dst_data_float;
- break;
- }
-
- // Use getInternCompData() to get the data, since getInternCompData()
- // returns reference to internal buffer, we must copy it.
- blk = getInternCompData(blk, c);
-
- // Copy the data
- blk.Data = dst_data;
- blk.offset = 0;
- blk.scanw = blk.w;
- return blk;
- }
-
- /// Performs the 2D inverse wavelet transform on a subband of the image, on
- /// the specified component. This method will successively perform 1D
- /// filtering steps on all columns and then all lines of the subband.
- ///
- ///
- /// the buffer for the image/wavelet data.
- ///
- ///
- /// The subband to reconstruct.
- ///
- ///
- /// The index of the component to reconstruct
- ///
- ///
- private void wavelet2DReconstruction(DataBlk db, SubbandSyn sb, int c)
- {
- System.Object data;
- System.Object buf;
- int ulx, uly, w, h;
- int i, j, k;
- int offset;
-
- // If subband is empty (i.e. zero size) nothing to do
- if (sb.w == 0 || sb.h == 0)
- {
- return;
- }
-
- data = db.Data;
-
- ulx = sb.ulx;
- uly = sb.uly;
- w = sb.w;
- h = sb.h;
-
- buf = null; // To keep compiler happy
-
- switch (sb.HorWFilter.DataType)
- {
-
- case DataBlk.TYPE_INT:
- buf = new int[(w >= h) ? w : h];
- break;
-
- case DataBlk.TYPE_FLOAT:
- buf = new float[(w >= h) ? w : h];
- break;
- }
-
- //Perform the horizontal reconstruction
- offset = (uly - db.uly) * db.w + ulx - db.ulx;
- if (sb.ulcx % 2 == 0)
- {
- // start index is even => use LPF
- for (i = 0; i < h; i++, offset += db.w)
- {
- // CONVERSION PROBLEM?
- Array.Copy((System.Array)data, offset, (System.Array)buf, 0, w);
- sb.hFilter.synthetize_lpf(buf, 0, (w + 1) / 2, 1, buf, (w + 1) / 2, w / 2, 1, data, offset, 1);
- }
- }
- else
- {
- // start index is odd => use HPF
- for (i = 0; i < h; i++, offset += db.w)
- {
- // CONVERSION PROBLEM?
- Array.Copy((System.Array)data, offset, (System.Array)buf, 0, w);
- sb.hFilter.synthetize_hpf(buf, 0, w / 2, 1, buf, w / 2, (w + 1) / 2, 1, data, offset, 1);
- }
- }
-
- //Perform the vertical reconstruction
- offset = (uly - db.uly) * db.w + ulx - db.ulx;
- switch (sb.VerWFilter.DataType)
- {
-
- case DataBlk.TYPE_INT:
- int[] data_int, buf_int;
- data_int = (int[])data;
- buf_int = (int[])buf;
- if (sb.ulcy % 2 == 0)
- {
- // start index is even => use LPF
- for (j = 0; j < w; j++, offset++)
- {
- for (i = h - 1, k = offset + i * db.w; i >= 0; i--, k -= db.w)
- buf_int[i] = data_int[k];
- sb.vFilter.synthetize_lpf(buf, 0, (h + 1) / 2, 1, buf, (h + 1) / 2, h / 2, 1, data, offset, db.w);
- }
- }
- else
- {
- // start index is odd => use HPF
- for (j = 0; j < w; j++, offset++)
- {
- for (i = h - 1, k = offset + i * db.w; i >= 0; i--, k -= db.w)
- buf_int[i] = data_int[k];
- sb.vFilter.synthetize_hpf(buf, 0, h / 2, 1, buf, h / 2, (h + 1) / 2, 1, data, offset, db.w);
- }
- }
- break;
-
- case DataBlk.TYPE_FLOAT:
- float[] data_float, buf_float;
- data_float = (float[])data;
- buf_float = (float[])buf;
- if (sb.ulcy % 2 == 0)
- {
- // start index is even => use LPF
- for (j = 0; j < w; j++, offset++)
- {
- for (i = h - 1, k = offset + i * db.w; i >= 0; i--, k -= db.w)
- buf_float[i] = data_float[k];
- sb.vFilter.synthetize_lpf(buf, 0, (h + 1) / 2, 1, buf, (h + 1) / 2, h / 2, 1, data, offset, db.w);
- }
- }
- else
- {
- // start index is odd => use HPF
- for (j = 0; j < w; j++, offset++)
- {
- for (i = h - 1, k = offset + i * db.w; i >= 0; i--, k -= db.w)
- buf_float[i] = data_float[k];
- sb.vFilter.synthetize_hpf(buf, 0, h / 2, 1, buf, h / 2, (h + 1) / 2, 1, data, offset, db.w);
- }
- }
- break;
- }
- }
-
- /// Performs the inverse wavelet transform on the whole component. It
- /// iteratively reconstructs the subbands from leaves up to the root
- /// node. This method is recursive, the first call to it the 'sb' must be
- /// the root of the subband tree. The method will then process the entire
- /// subband tree by calling itslef recursively.
- ///
- ///
- /// The buffer for the image/wavelet data.
- ///
- ///
- /// The subband to reconstruct.
- ///
- ///
- /// The index of the component to reconstruct
- ///
- ///
- private void waveletTreeReconstruction(DataBlk img, SubbandSyn sb, int c)
- {
-
- DataBlk subbData;
-
- // If the current subband is a leaf then get the data from the source
- if (!sb.isNode)
- {
- int i, m, n;
- System.Object src_data, dst_data;
- Coord ncblks;
-
- if (sb.w == 0 || sb.h == 0)
- {
- return; // If empty subband do nothing
- }
-
- // Get all code-blocks in subband
- if (dtype == DataBlk.TYPE_INT)
- {
- subbData = new DataBlkInt();
- }
- else
- {
- subbData = new DataBlkFloat();
- }
- ncblks = sb.numCb;
- 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_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
- Array.Copy((System.Array)src_data, subbData.offset + i * subbData.scanw, (System.Array)dst_data, (subbData.uly + i) * img.w + subbData.ulx, subbData.w);
- }
- }
- }
- }
- else if (sb.isNode)
- {
- // Reconstruct the lower resolution levels if the current subbands
- // is a node
-
- //Perform the reconstruction of the LL subband
- waveletTreeReconstruction(img, (SubbandSyn)sb.LL, c);
-
- if (sb.resLvl <= reslvl - maxImgRes + ndl[c])
- {
- //Reconstruct the other subbands
- waveletTreeReconstruction(img, (SubbandSyn)sb.HL, c);
- waveletTreeReconstruction(img, (SubbandSyn)sb.LH, c);
- waveletTreeReconstruction(img, (SubbandSyn)sb.HH, c);
-
- //Perform the 2D wavelet decomposition of the current subband
- wavelet2DReconstruction(img, (SubbandSyn)sb, c);
- }
- }
- }
-
- /// Returns the implementation type of this wavelet transform, WT_IMPL_FULL
- /// (full-page based transform). All components return the same.
- ///
- ///
- /// The index of the component.
- ///
- ///
- /// WT_IMPL_FULL
- ///
- ///
- ///
- ///
- ///
- public override int getImplementationType(int c)
- {
- return CSJ2K.j2k.wavelet.WaveletTransform_Fields.WT_IMPL_FULL;
- }
-
- /// Changes the current tile, given the new indexes. An
- /// IllegalArgumentException is thrown if the indexes do not correspond to
- /// a valid tile.
- ///
- ///
- /// The horizontal index of the tile.
- ///
- ///
- /// The vertical index of the new tile.
- ///
- ///
- public override void setTile(int x, int y)
- {
- int i;
-
- // Change tile
- base.setTile(x, y);
-
- int nc = src.NumComps;
- int tIdx = src.TileIdx;
- for (int c = 0; c < nc; c++)
- {
- ndl[c] = src.getSynSubbandTree(tIdx, c).resLvl;
- }
-
- // Reset the decomposed component buffers.
- if (reconstructedComps != null)
- {
- for (i = reconstructedComps.Length - 1; i >= 0; i--)
- {
- reconstructedComps[i] = null;
- }
- }
-
- cblkToDecode = 0;
- SubbandSyn root, sb;
- for (int c = 0; c < nc; c++)
- {
- root = src.getSynSubbandTree(tIdx, c);
- for (int r = 0; r <= reslvl - maxImgRes + root.resLvl; r++)
- {
- if (r == 0)
- {
- sb = (SubbandSyn)root.getSubbandByIdx(0, 0);
- if (sb != null)
- cblkToDecode += sb.numCb.x * sb.numCb.y;
- }
- else
- {
- sb = (SubbandSyn)root.getSubbandByIdx(r, 1);
- if (sb != null)
- cblkToDecode += sb.numCb.x * sb.numCb.y;
- sb = (SubbandSyn)root.getSubbandByIdx(r, 2);
- if (sb != null)
- cblkToDecode += sb.numCb.x * sb.numCb.y;
- sb = (SubbandSyn)root.getSubbandByIdx(r, 3);
- if (sb != null)
- cblkToDecode += sb.numCb.x * sb.numCb.y;
- }
- } // Loop on resolution levels
- } // Loop on components
- nDecCblk = 0;
-
- if (pw != null)
- {
- pw.initProgressWatch(0, cblkToDecode, "Decoding tile " + tIdx + "...");
- }
- }
-
- /// Advances to the next tile, in standard scan-line order (by rows then
- /// columns). An 'NoNextElementException' is thrown if the current tile is
- /// the last one (i.e. there is no next tile).
- ///
- ///
- public override void nextTile()
- {
- int i;
-
- // Change tile
- base.nextTile();
-
- int nc = src.NumComps;
- int tIdx = src.TileIdx;
- for (int c = 0; c < nc; c++)
- {
- ndl[c] = src.getSynSubbandTree(tIdx, c).resLvl;
- }
-
- // Reset the decomposed component buffers.
- if (reconstructedComps != null)
- {
- for (i = reconstructedComps.Length - 1; i >= 0; i--)
- {
- reconstructedComps[i] = null;
- }
- }
- }
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/wavelet/synthesis/InverseWT.cs b/CSJ2K/j2k/wavelet/synthesis/InverseWT.cs
deleted file mode 100644
index 398e400d..00000000
--- a/CSJ2K/j2k/wavelet/synthesis/InverseWT.cs
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
-* CVS identifier:
-*
-* $Id: InverseWT.java,v 1.34 2001/10/09 12:52:55 grosbois Exp $
-*
-* Class: InverseWT
-*
-* Description: This interface defines the specifics
-* of inverse wavelet transforms.
-*
-*
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-* */
-using CSJ2K.j2k.decoder;
-using CSJ2K.j2k.image;
-namespace CSJ2K.j2k.wavelet.synthesis
-{
-
- /// This abstract class extends the WaveletTransform one with the specifics of
- /// inverse wavelet transforms.
- ///
- /// The image can be reconstructed at different resolution levels. This is
- /// controlled by the setResLevel() method. All the image, tile and component
- /// dimensions are relative the the resolution level being used. The number of
- /// resolution levels indicates the number of wavelet recompositions that will
- /// be used, if it is equal as the number of decomposition levels then the full
- /// resolution image is reconstructed.
- ///
- /// It is assumed in this class that all tiles and components the same
- /// reconstruction resolution level. If that where not the case the
- /// implementing class should have additional data structures to store those
- /// values for each tile. However, the 'recResLvl' member variable always
- /// contain the values applicable to the current tile, since many methods
- /// implemented here rely on them.
- ///
- ///
- public abstract class InverseWT : InvWTAdapter, BlkImgDataSrc
- {
-
- /// Initializes this object with the given source of wavelet
- /// coefficients. It initializes the resolution level for full resolutioin
- /// reconstruction (i.e. the maximum resolution available from the 'src'
- /// source).
- ///
- /// It is assumed here that all tiles and components have the same
- /// reconstruction resolution level. If that was not the case it should be
- /// the value for the current tile of the source.
- ///
- ///
- /// from where the wavelet coefficinets should be obtained.
- ///
- ///
- /// The decoder specifications
- ///
- ///
- public InverseWT(MultiResImgData src, DecoderSpecs decSpec) : base(src, decSpec)
- {
- }
-
- /// Creates an InverseWT object that works on the data type of the source,
- /// with the special additional parameters from the parameter
- /// list. Currently the parameter list is ignored since no special
- /// parameters can be specified for the inverse wavelet transform yet.
- ///
- ///
- /// The source of data for the inverse wavelet
- /// transform.
- ///
- ///
- /// The parameter list containing parameters applicable to the
- /// inverse wavelet transform (other parameters can also be present).
- ///
- ///
- public static InverseWT createInstance(CBlkWTDataSrcDec src, DecoderSpecs decSpec)
- {
-
- // full page wavelet transform
- return new InvWTFull(src, decSpec);
- }
- public abstract int getFixedPoint(int param1);
- public abstract CSJ2K.j2k.image.DataBlk getInternCompData(CSJ2K.j2k.image.DataBlk param1, int param2);
- public abstract CSJ2K.j2k.image.DataBlk getCompData(CSJ2K.j2k.image.DataBlk param1, int param2);
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/wavelet/synthesis/MultiResImgData.cs b/CSJ2K/j2k/wavelet/synthesis/MultiResImgData.cs
deleted file mode 100644
index 7fac6e4f..00000000
--- a/CSJ2K/j2k/wavelet/synthesis/MultiResImgData.cs
+++ /dev/null
@@ -1,417 +0,0 @@
-/*
-* CVS identifier:
-*
-* $Id: MultiResImgData.java,v 1.11 2002/07/25 15:11:33 grosbois Exp $
-*
-* Class: MultiResImgData
-*
-* Description: The interface for classes that provide
-* multi-resolution image data.
-*
-*
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-* */
-using CSJ2K.j2k.image;
-namespace CSJ2K.j2k.wavelet.synthesis
-{
-
- /// This interface defines methods to access image attributes (width, height,
- /// number of components, etc.) of multiresolution images, such as those
- /// resulting from an inverse wavelet transform. The image can be tiled or not
- /// (i.e. if the image is not tiled then there is only 1 tile). It should be
- /// implemented by all classes that provide multi-resolution image data, such
- /// as entropy decoders, dequantizers, etc. This interface, however, does not
- /// define methods to transfer image data (i.e. pixel data), that is defined by
- /// other interfaces, such as 'CBlkQuantDataSrcDec'.
- ///
- /// This interface is very similar to the 'ImgData' one. It differs only by
- /// the fact that it handles multiple resolutions.
- ///
- /// Resolution levels are counted from 0 to L. Resolution level 0 is the
- /// lower resolution, while L is the maximum resolution level, or full
- /// resolution, which is returned by 'getMaxResLvl()'. Note that there are L+1
- /// resolution levels available.
- ///
- /// As in the 'ImgData' interface a multi-resolution image lies on top of a
- /// canvas. The canvas coordinates are mapped from the full resolution
- /// reference grid (i.e. resolution level 'L' reference grid) to a resolution
- /// level 'l' reference grid by '(x_l,y_l) =
- /// (ceil(x_l/2^(L-l)),ceil(y_l/2^(L-l)))', where '(x,y)' are the full
- /// resolution reference grid coordinates and '(x_l,y_l)' are the level 'l'
- /// reference grid coordinates.
- ///
- /// For details on the canvas system and its implications consult the
- /// 'ImgData' interface.
- ///
- /// Note that tile sizes may not be obtained by simply dividing the tile
- /// size in the reference grid by the subsampling factor.
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- public interface MultiResImgData
- {
- /// Returns the nominal tiles width
- int NomTileWidth
- {
- get;
-
- }
- /// Returns the nominal tiles height
- int NomTileHeight
- {
- get;
-
- }
- /// Returns the number of components in the image.
- ///
- ///
- /// The number of components in the image.
- ///
- ///
- int NumComps
- {
- get;
-
- }
- /// Returns the index of the current tile, relative to a standard scan-line
- /// order.
- ///
- ///
- /// The current tile's index (starts at 0).
- ///
- ///
- int TileIdx
- {
- get;
-
- }
- /// Returns the horizontal tile partition offset in the reference grid
- int TilePartULX
- {
- get;
-
- }
- /// Returns the vertical tile partition offset in the reference grid
- int TilePartULY
- {
- get;
-
- }
-
- /// Returns the overall width of the current tile in pixels for the given
- /// resolution level. This is the tile's width without accounting for any
- /// component subsampling. The resolution level is indexed from the lowest
- /// number of resolution levels of all components of the current tile.
- ///
- ///
- /// The resolution level, from 0 to L.
- ///
- ///
- /// The total current tile's width in pixels.
- ///
- ///
- int getTileWidth(int rl);
-
- /// Returns the overall height of the current tile in pixels, for the given
- /// resolution level. This is the tile's height without accounting for any
- /// component subsampling. The resolution level is indexed from the lowest
- /// number of resolution levels of all components of the current tile.
- ///
- ///
- /// The resolution level, from 0 to L.
- ///
- ///
- /// The total current tile's height in pixels.
- ///
- ///
- int getTileHeight(int rl);
-
- /// Returns the overall width of the image in pixels, for the given
- /// resolution level. This is the image's width without accounting for any
- /// component subsampling or tiling. The resolution level is indexed from
- /// the lowest number of resolution levels of all components of the current
- /// tile.
- ///
- ///
- /// The resolution level, from 0 to L.
- ///
- ///
- /// The total image's width in pixels.
- ///
- ///
- int getImgWidth(int rl);
-
- /// Returns the overall height of the image in pixels, for the given
- /// resolution level. This is the image's height without accounting for any
- /// component subsampling or tiling. The resolution level is indexed from
- /// the lowest number of resolution levels of all components of the current
- /// tile.
- ///
- ///
- /// The resolution level, from 0 to L.
- ///
- ///
- /// The total image's height in pixels.
- ///
- ///
- int getImgHeight(int rl);
-
- /// Returns the component subsampling factor in the horizontal direction,
- /// for the specified component. This is, approximately, the ratio of
- /// dimensions between the reference grid and the component itself, see the
- /// 'ImgData' interface desription for details.
- ///
- ///
- /// The index of the component (between 0 and N-1)
- ///
- ///
- /// The horizontal subsampling factor of component 'c'
- ///
- ///
- ///
- ///
- ///
- int getCompSubsX(int c);
-
- /// Returns the component subsampling factor in the vertical direction, for
- /// the specified component. This is, approximately, the ratio of
- /// dimensions between the reference grid and the component itself, see the
- /// 'ImgData' interface desription for details.
- ///
- ///
- /// The index of the component (between 0 and N-1)
- ///
- ///
- /// The vertical subsampling factor of component 'c'
- ///
- ///
- ///
- ///
- ///
- int getCompSubsY(int c);
-
- /// Returns the width in pixels of the specified tile-component for the
- /// given resolution level.
- ///
- ///
- /// Tile index
- ///
- ///
- /// The index of the component, from 0 to N-1.
- ///
- ///
- /// The resolution level, from 0 to L.
- ///
- ///
- /// The width in pixels of component c in tile t
- /// for resolution rl.
- ///
- ///
- int getTileCompWidth(int t, int c, int rl);
-
- /// Returns the height in pixels of the specified tile-component for the
- /// given resolution level.
- ///
- ///
- /// The tile index.
- ///
- ///
- /// The index of the component, from 0 to N-1.
- ///
- ///
- /// The resolution level, from 0 to L.
- ///
- ///
- /// The height in pixels of component c in tile
- /// t.
- ///
- ///
- int getTileCompHeight(int t, int c, int rl);
-
- /// Returns the width in pixels of the specified component in the overall
- /// image, for the given resolution level.
- ///
- ///
- /// The index of the component, from 0 to N-1.
- ///
- ///
- /// The resolution level, from 0 to L.
- ///
- ///
- /// The width in pixels of component c in the overall
- /// image.
- ///
- ///
- int getCompImgWidth(int c, int rl);
-
- /// Returns the height in pixels of the specified component in the overall
- /// image, for the given resolution level.
- ///
- ///
- /// The index of the component, from 0 to N-1.
- ///
- ///
- /// The resolution level, from 0 to L.
- ///
- ///
- /// The height in pixels of component n in the overall
- /// image.
- ///
- ///
- int getCompImgHeight(int n, int rl);
-
- /// Changes the current tile, given the new indexes. An
- /// IllegalArgumentException is thrown if the indexes do not correspond to
- /// a valid tile.
- ///
- ///
- /// The horizontal indexes the tile.
- ///
- ///
- /// The vertical indexes of the new tile.
- ///
- ///
- void setTile(int x, int y);
-
- /// Advances to the next tile, in standard scan-line order (by rows then
- /// columns). An NoNextElementException is thrown if the current tile is
- /// the last one (i.e. there is no next tile).
- ///
- ///
- void nextTile();
-
- /// Returns the indexes of the current tile. These are the horizontal and
- /// vertical indexes of the current tile.
- ///
- ///
- /// If not null this object is used to return the information. If
- /// null a new one is created and returned.
- ///
- ///
- /// The current tile's indexes (vertical and horizontal indexes).
- ///
- ///
- Coord getTile(Coord co);
-
- /// Returns the horizontal coordinate of the upper-left corner of the
- /// specified resolution in the given component of the current tile.
- ///
- ///
- /// The component index.
- ///
- ///
- /// The resolution level index.
- ///
- ///
- int getResULX(int c, int rl);
-
- /// Returns the vertical coordinate of the upper-left corner of the
- /// specified resolution in the given component of the current tile.
- ///
- ///
- /// The component index.
- ///
- ///
- /// The resolution level index.
- ///
- ///
- int getResULY(int c, int rl);
-
- /// Returns the horizontal coordinate of the image origin, the top-left
- /// corner, in the canvas system, on the reference grid at the specified
- /// resolution level. The resolution level is indexed from the lowest
- /// number of resolution levels of all components of the current tile.
- ///
- ///
- /// The resolution level, from 0 to L.
- ///
- ///
- /// The horizontal coordinate of the image origin in the canvas
- /// system, on the reference grid.
- ///
- ///
- int getImgULX(int rl);
-
- /// Returns the vertical coordinate of the image origin, the top-left
- /// corner, in the canvas system, on the reference grid at the specified
- /// resolution level. The resolution level is indexed from the lowest
- /// number of resolution levels of all components of the current tile.
- ///
- ///
- /// The resolution level, from 0 to L.
- ///
- ///
- /// The vertical coordinate of the image origin in the canvas
- /// system, on the reference grid.
- ///
- ///
- int getImgULY(int rl);
-
- /// Returns the number of tiles in the horizontal and vertical directions.
- ///
- ///
- /// If not null this object is used to return the information. If
- /// null a new one is created and returned.
- ///
- ///
- /// The number of tiles in the horizontal (Coord.x) and vertical
- /// (Coord.y) directions.
- ///
- ///
- Coord getNumTiles(Coord co);
-
- /// Returns the total number of tiles in the image.
- ///
- ///
- /// The total number of tiles in the image.
- ///
- ///
- int getNumTiles();
-
- /// Returns the specified synthesis subband tree
- ///
- ///
- /// Tile index.
- ///
- ///
- /// Component index.
- ///
- ///
- SubbandSyn getSynSubbandTree(int t, int c);
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/wavelet/synthesis/MultiResImgDataAdapter.cs b/CSJ2K/j2k/wavelet/synthesis/MultiResImgDataAdapter.cs
deleted file mode 100644
index 42a43dd9..00000000
--- a/CSJ2K/j2k/wavelet/synthesis/MultiResImgDataAdapter.cs
+++ /dev/null
@@ -1,517 +0,0 @@
-/*
-* CVS identifier:
-*
-* $Id: MultiResImgDataAdapter.java,v 1.10 2002/07/25 15:11:55 grosbois Exp $
-*
-* Class: MultiResImgDataAdapter
-*
-* Description: A default implementation of the MultiResImgData
-* interface that has and MultiResImgData source
-* and just returns the values of the source.
-*
-*
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-* */
-using CSJ2K.j2k.image;
-namespace CSJ2K.j2k.wavelet.synthesis
-{
-
- /// This class provides a default implementation for the methods of the
- /// 'MultiResImgData' interface. The default implementation consists just in
- /// returning the value of the source, where the source is another
- /// 'MultiResImgData' object.
- ///
- /// This abstract class can be used to facilitate the development of other
- /// classes that implement 'MultiResImgData'. For example a dequantizer can
- /// inherit from this class and all the trivial methods do not have to be
- /// reimplemented.
- ///
- /// If the default implementation of a method provided in this class does
- /// not suit a particular implementation of the 'MultiResImgData' interface,
- /// the method can be overriden to implement the proper behaviour.
- ///
- ///
- ///
- ///
- ///
- public abstract class MultiResImgDataAdapter : MultiResImgData
- {
- /// Returns the nominal tiles width
- virtual public int NomTileWidth
- {
- get
- {
- return mressrc.NomTileWidth;
- }
-
- }
- /// Returns the nominal tiles height
- virtual public int NomTileHeight
- {
- get
- {
- return mressrc.NomTileHeight;
- }
-
- }
- /// Returns the number of components in the image.
- ///
- /// This default implementation returns the value of the source.
- ///
- ///
- /// The number of components in the image.
- ///
- ///
- virtual public int NumComps
- {
- get
- {
- return mressrc.NumComps;
- }
-
- }
- /// Returns the index of the current tile, relative to a standard scan-line
- /// order.
- ///
- /// This default implementation returns the value of the source.
- ///
- ///
- /// The current tile's index (starts at 0).
- ///
- ///
- virtual public int TileIdx
- {
- get
- {
- return mressrc.TileIdx;
- }
-
- }
- /// Returns the horizontal tile partition offset in the reference grid
- virtual public int TilePartULX
- {
- get
- {
- return mressrc.TilePartULX;
- }
-
- }
- /// Returns the vertical tile partition offset in the reference grid
- virtual public int TilePartULY
- {
- get
- {
- return mressrc.TilePartULY;
- }
-
- }
-
- /// Index of the current tile
- protected internal int tIdx = 0;
-
- /// The MultiResImgData source
- protected internal MultiResImgData mressrc;
-
- /// Instantiates the MultiResImgDataAdapter object specifying the
- /// MultiResImgData source.
- ///
- ///
- /// From where to obrtain the MultiResImgData values.
- ///
- ///
- protected internal MultiResImgDataAdapter(MultiResImgData src)
- {
- mressrc = src;
- }
-
- /// Returns the overall width of the current tile in pixels, for the given
- /// resolution level. This is the tile's width without accounting for any
- /// component subsampling.
- ///
- /// This default implementation returns the value of the source.
- ///
- ///
- /// The resolution level, from 0 to L.
- ///
- ///
- /// The total current tile's width in pixels.
- ///
- ///
- public virtual int getTileWidth(int rl)
- {
- return mressrc.getTileWidth(rl);
- }
-
- /// Returns the overall height of the current tile in pixels, for the given
- /// resolution level. This is the tile's height without accounting for any
- /// component subsampling.
- ///
- /// This default implementation returns the value of the source.
- ///
- ///
- /// The resolution level, from 0 to L.
- ///
- ///
- /// The total current tile's height in pixels.
- ///
- ///
- public virtual int getTileHeight(int rl)
- {
- return mressrc.getTileHeight(rl);
- }
-
- /// Returns the overall width of the image in pixels, for the given
- /// resolution level. This is the image's width without accounting for any
- /// component subsampling or tiling.
- ///
- /// This default implementation returns the value of the source.
- ///
- ///
- /// The resolution level, from 0 to L.
- ///
- ///
- /// The total image's width in pixels.
- ///
- ///
- public virtual int getImgWidth(int rl)
- {
- return mressrc.getImgWidth(rl);
- }
-
- /// Returns the overall height of the image in pixels, for the given
- /// resolution level. This is the image's height without accounting for any
- /// component subsampling or tiling.
- ///
- /// This default implementation returns the value of the source.
- ///
- ///
- /// The resolution level, from 0 to L.
- ///
- ///
- /// The total image's height in pixels.
- ///
- ///
- public virtual int getImgHeight(int rl)
- {
- return mressrc.getImgHeight(rl);
- }
-
- /// Returns the component subsampling factor in the horizontal direction,
- /// for the specified component. This is, approximately, the ratio of
- /// dimensions between the reference grid and the component itself, see the
- /// 'ImgData' interface desription for details.
- ///
- /// This default implementation returns the value of the source.
- ///
- ///
- /// The index of the component (between 0 and N-1)
- ///
- ///
- /// The horizontal subsampling factor of component 'c'
- ///
- ///
- ///
- ///
- ///
- public virtual int getCompSubsX(int c)
- {
- return mressrc.getCompSubsX(c);
- }
-
- /// Returns the component subsampling factor in the vertical direction, for
- /// the specified component. This is, approximately, the ratio of
- /// dimensions between the reference grid and the component itself, see the
- /// 'ImgData' interface desription for details.
- ///
- /// This default implementation returns the value of the source.
- ///
- ///
- /// The index of the component (between 0 and N-1)
- ///
- ///
- /// The vertical subsampling factor of component 'c'
- ///
- ///
- ///
- ///
- ///
- public virtual int getCompSubsY(int c)
- {
- return mressrc.getCompSubsY(c);
- }
-
- /// Returns the width in pixels of the specified tile-component for the
- /// given resolution level.
- ///
- /// This default implementation returns the value of the source.
- ///
- ///
- /// Tile index.
- ///
- ///
- /// The index of the component, from 0 to N-1.
- ///
- ///
- /// The resolution level, from 0 to L.
- ///
- ///
- /// The width in pixels of component c in tile t
- /// for resolution level rl.
- ///
- ///
- public virtual int getTileCompWidth(int t, int c, int rl)
- {
- return mressrc.getTileCompWidth(t, c, rl);
- }
-
- /// Returns the height in pixels of the specified tile-component for the
- /// given resolution level.
- ///
- /// This default implementation returns the value of the source.
- ///
- ///
- /// The tile index.
- ///
- ///
- /// The index of the component, from 0 to N-1.
- ///
- ///
- /// The resolution level, from 0 to L.
- ///
- ///
- /// The height in pixels of component c in tile
- /// t.
- ///
- ///
- public virtual int getTileCompHeight(int t, int c, int rl)
- {
- return mressrc.getTileCompHeight(t, c, rl);
- }
-
- /// Returns the width in pixels of the specified component in the overall
- /// image, for the given resolution level.
- ///
- /// This default implementation returns the value of the source.
- ///
- ///
- /// The index of the component, from 0 to N-1.
- ///
- ///
- /// The resolution level, from 0 to L.
- ///
- ///
- /// The width in pixels of component c in the overall
- /// image.
- ///
- ///
- public virtual int getCompImgWidth(int c, int rl)
- {
- return mressrc.getCompImgWidth(c, rl);
- }
-
- /// Returns the height in pixels of the specified component in the overall
- /// image, for the given resolution level.
- ///
- /// This default implementation returns the value of the source.
- ///
- ///
- /// The index of the component, from 0 to N-1.
- ///
- ///
- /// The resolution level, from 0 to L.
- ///
- ///
- /// The height in pixels of component c in the overall
- /// image.
- ///
- ///
- public virtual int getCompImgHeight(int c, int rl)
- {
- return mressrc.getCompImgHeight(c, rl);
- }
-
- /// Changes the current tile, given the new indexes. An
- /// IllegalArgumentException is thrown if the indexes do not correspond to
- /// a valid tile.
- ///
- /// This default implementation just changes the tile in the source.
- ///
- ///
- /// The horizontal indexes the tile.
- ///
- ///
- /// The vertical indexes of the new tile.
- ///
- ///
- public virtual void setTile(int x, int y)
- {
- mressrc.setTile(x, y);
- tIdx = TileIdx;
- }
-
- /// Advances to the next tile, in standard scan-line order (by rows then
- /// columns). An NoNextElementException is thrown if the current tile is
- /// the last one (i.e. there is no next tile).
- ///
- /// This default implementation just changes the tile in the source.
- ///
- ///
- public virtual void nextTile()
- {
- mressrc.nextTile();
- tIdx = TileIdx;
- }
-
- /// Returns the indexes of the current tile. These are the horizontal and
- /// vertical indexes of the current tile.
- ///
- /// This default implementation returns the value of the source.
- ///
- ///
- /// If not null this object is used to return the information. If
- /// null a new one is created and returned.
- ///
- ///
- /// The current tile's indexes (vertical and horizontal indexes).
- ///
- ///
- public virtual Coord getTile(Coord co)
- {
- return mressrc.getTile(co);
- }
-
- /// Returns the horizontal coordinate of the upper-left corner of the
- /// specified resolution level in the given component of the current tile.
- ///
- /// This default implementation returns the value of the source.
- ///
- ///
- /// The component index.
- ///
- ///
- /// The resolution level index.
- ///
- ///
- public virtual int getResULX(int c, int rl)
- {
- return mressrc.getResULX(c, rl);
- }
-
- /// Returns the vertical coordinate of the upper-left corner of the
- /// specified resolution in the given component of the current tile.
- ///
- /// This default implementation returns the value of the source.
- ///
- ///
- /// The component index.
- ///
- ///
- /// The resolution level index.
- ///
- ///
- public virtual int getResULY(int c, int rl)
- {
- return mressrc.getResULY(c, rl);
- }
-
- /// Returns the horizontal coordinate of the image origin, the top-left
- /// corner, in the canvas system, on the reference grid at the specified
- /// resolution level.
- ///
- /// This default implementation returns the value of the source.
- ///
- ///
- /// The resolution level, from 0 to L.
- ///
- ///
- /// The horizontal coordinate of the image origin in the canvas
- /// system, on the reference grid.
- ///
- ///
- public virtual int getImgULX(int rl)
- {
- return mressrc.getImgULX(rl);
- }
-
- /// Returns the vertical coordinate of the image origin, the top-left
- /// corner, in the canvas system, on the reference grid at the specified
- /// resolution level.
- ///
- /// This default implementation returns the value of the source.
- ///
- ///
- /// The resolution level, from 0 to L.
- ///
- ///
- /// The vertical coordinate of the image origin in the canvas
- /// system, on the reference grid.
- ///
- ///
- public virtual int getImgULY(int rl)
- {
- return mressrc.getImgULY(rl);
- }
-
- /// Returns the number of tiles in the horizontal and vertical directions.
- ///
- /// This default implementation returns the value of the source.
- ///
- ///
- /// If not null this object is used to return the information. If
- /// null a new one is created and returned.
- ///
- ///
- /// The number of tiles in the horizontal (Coord.x) and vertical
- /// (Coord.y) directions.
- ///
- ///
- public virtual Coord getNumTiles(Coord co)
- {
- return mressrc.getNumTiles(co);
- }
-
- /// Returns the total number of tiles in the image.
- ///
- /// This default implementation returns the value of the source.
- ///
- ///
- /// The total number of tiles in the image.
- ///
- ///
- public virtual int getNumTiles()
- {
- return mressrc.getNumTiles();
- }
- public abstract CSJ2K.j2k.wavelet.synthesis.SubbandSyn getSynSubbandTree(int param1, int param2);
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/wavelet/synthesis/SubbandSyn.cs b/CSJ2K/j2k/wavelet/synthesis/SubbandSyn.cs
deleted file mode 100644
index 20e7d64f..00000000
--- a/CSJ2K/j2k/wavelet/synthesis/SubbandSyn.cs
+++ /dev/null
@@ -1,310 +0,0 @@
-/*
-* CVS identifier:
-*
-* $Id: SubbandSyn.java,v 1.25 2001/07/26 08:54:59 grosbois Exp $
-*
-* Class: SubbandSyn
-*
-* Description: Element for a tree structure for a description
-* of subband for the synthesis side.
-*
-*
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-* */
-namespace CSJ2K.j2k.wavelet.synthesis
-{
-
- /// This class represents a subband in a tree structure that describes the
- /// subband decomposition for a wavelet transform, specifically for the
- /// syhthesis side.
- ///
- /// The element can be either a node or a leaf of the tree. If it is a node
- /// then ther are 4 descendants (LL, HL, LH and HH). If it is a leaf there are
- /// no descendants.
- ///
- /// The tree is bidirectional. Each element in the tree structure has a
- /// "parent", which is the subband from which the element was obtained by
- /// decomposition. The only exception is the root element which has no parent
- /// (i.e.it's null), for obvious reasons.
- ///
- ///
- public class SubbandSyn : Subband
- {
- /// Returns the parent of this subband. The parent of a subband is the
- /// subband from which this one was obtained by decomposition. The root
- /// element has no parent subband (null).
- ///
- ///
- /// The parent subband, or null for the root one.
- ///
- ///
- override public Subband Parent
- {
- get
- {
- return parent;
- }
-
- }
- /// Returns the LL child subband of this subband.
- ///
- ///
- /// The LL child subband, or null if there are no childs.
- ///
- ///
- override public Subband LL
- {
- get
- {
- return subb_LL;
- }
-
- }
- /// Returns the HL (horizontal high-pass) child subband of this subband.
- ///
- ///
- /// The HL child subband, or null if there are no childs.
- ///
- ///
- override public Subband HL
- {
- get
- {
- return subb_HL;
- }
-
- }
- /// Returns the LH (vertical high-pass) child subband of this subband.
- ///
- ///
- /// The LH child subband, or null if there are no childs.
- ///
- ///
- override public Subband LH
- {
- get
- {
- return subb_LH;
- }
-
- }
- /// Returns the HH child subband of this subband.
- ///
- ///
- /// The HH child subband, or null if there are no childs.
- ///
- ///
- override public Subband HH
- {
- get
- {
- return subb_HH;
- }
-
- }
- /// This function returns the horizontal wavelet filter relevant to this
- /// subband
- ///
- ///
- /// The horizontal wavelet filter
- ///
- ///
- override public WaveletFilter HorWFilter
- {
- get
- {
- return hFilter;
- }
-
- }
- /// This function returns the vertical wavelet filter relevant to this
- /// subband
- ///
- ///
- /// The vertical wavelet filter
- ///
- ///
- override public WaveletFilter VerWFilter
- {
- get
- {
- return hFilter;
- }
-
- }
-
- /// The reference to the parent of this subband. It is null for the root
- /// element. It is null by default.
- ///
- private SubbandSyn parent;
-
- /// The reference to the LL subband resulting from the decomposition of
- /// this subband. It is null by default.
- ///
- private SubbandSyn subb_LL;
-
- /// The reference to the HL subband (horizontal high-pass) resulting from
- /// the decomposition of this subband. It is null by default.
- ///
- private SubbandSyn subb_HL;
-
- /// The reference to the LH subband (vertical high-pass) resulting from
- /// the decomposition of this subband. It is null by default.
- ///
- ///
- private SubbandSyn subb_LH;
-
- /// The reference to the HH subband resulting from the decomposition of
- /// this subband. It is null by default.
- ///
- private SubbandSyn subb_HH;
-
- /// The horizontal analysis filter used to recompose this subband, from
- /// its childs. This is applicable to "node" elements only. The default
- /// value is null.
- ///
- public SynWTFilter hFilter;
-
- /// The vertical analysis filter used to decompose this subband, from its
- /// childs. This is applicable to "node" elements only. The default value
- /// is null.
- ///
- public SynWTFilter vFilter;
-
- /// The number of magnitude bits
- public int magbits = 0;
-
- /// Creates a SubbandSyn element with all the default values. The
- /// dimensions are (0,0) and the upper left corner is (0,0).
- ///
- ///
- public SubbandSyn()
- {
- }
-
- /// Creates the top-level node and the entire subband tree, with the
- /// top-level dimensions, the number of decompositions, and the
- /// decomposition tree as specified.
- ///
- /// This constructor just calls the same constructor of the super
- /// class.
- ///
- ///
- /// The top-level width
- ///
- ///
- /// The top-level height
- ///
- ///
- /// The horizontal coordinate of the upper-left corner with
- /// respect to the canvas origin, in the component grid.
- ///
- ///
- /// The vertical coordinate of the upper-left corner with
- /// respect to the canvas origin, in the component grid.
- ///
- ///
- /// The number of levels (or LL decompositions) in the tree.
- ///
- ///
- /// The horizontal wavelet synthesis filters for each
- /// resolution level, starting at resolution level 0.
- ///
- ///
- /// The vertical wavelet synthesis filters for each
- /// resolution level, starting at resolution level 0.
- ///
- ///
- ///
- /// WaveletFilter[],WaveletFilter[])
- ///
- ///
- public SubbandSyn(int w, int h, int ulcx, int ulcy, int lvls, WaveletFilter[] hfilters, WaveletFilter[] vfilters) : base(w, h, ulcx, ulcy, lvls, hfilters, vfilters)
- {
- }
-
- /// Splits the current subband in its four subbands. It changes the status
- /// of this element (from a leaf to a node, and sets the filters), creates
- /// the childs and initializes them. An IllegalArgumentException is thrown
- /// if this subband is not a leaf.
- ///
- /// It uses the initChilds() method to initialize the childs.
- ///
- ///
- /// The horizontal wavelet filter used to decompose this
- /// subband. It has to be a SynWTFilter object.
- ///
- ///
- /// The vertical wavelet filter used to decompose this
- /// subband. It has to be a SynWTFilter object.
- ///
- ///
- /// A reference to the LL leaf (subb_LL).
- ///
- ///
- ///
- ///
- ///
- protected internal override Subband split(WaveletFilter hfilter, WaveletFilter vfilter)
- {
- // Test that this is a node
- if (isNode)
- {
- throw new System.ArgumentException();
- }
-
- // Modify this element into a node and set the filters
- isNode = true;
- this.hFilter = (SynWTFilter)hfilter;
- this.vFilter = (SynWTFilter)vfilter;
-
- // Create childs
- subb_LL = new SubbandSyn();
- subb_LH = new SubbandSyn();
- subb_HL = new SubbandSyn();
- subb_HH = new SubbandSyn();
-
- // Assign parent
- subb_LL.parent = this;
- subb_HL.parent = this;
- subb_LH.parent = this;
- subb_HH.parent = this;
-
- // Initialize childs
- initChilds();
-
- // Return reference to LL subband
- return subb_LL;
- }
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/wavelet/synthesis/SynWTFilter.cs b/CSJ2K/j2k/wavelet/synthesis/SynWTFilter.cs
deleted file mode 100644
index 262b2187..00000000
--- a/CSJ2K/j2k/wavelet/synthesis/SynWTFilter.cs
+++ /dev/null
@@ -1,262 +0,0 @@
-/*
-* CVS identifier:
-*
-* $Id: SynWTFilter.java,v 1.9 2001/08/02 10:05:58 grosbois Exp $
-*
-* Class: SynWTFilter
-*
-* Description: The abstract class for all synthesis wavelet
-* filters.
-*
-*
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-* */
-namespace CSJ2K.j2k.wavelet.synthesis
-{
-
- /// This abstract class defines the methods of all synthesis wavelet
- /// filters. Specialized abstract classes that work on particular data types
- /// (int, float) provide more specific method calls while retaining the
- /// generality of this one. See the SynWTFilterInt and SynWTFilterFloat
- /// classes. Implementations of snythesis filters should inherit from one of
- /// those classes.
- ///
- /// The length of the output signal is always the sum of the length of the
- /// low-pass and high-pass input signals.
- ///
- /// All synthesis wavelet filters should follow the following conventions:
- ///
- ///
- ///
- /// - The first sample of the output corresponds to the low-pass one. As a
- /// consequence, if the output signal is of odd-length then the low-pass input
- /// signal is one sample longer than the high-pass input one. Therefore, if the
- /// length of output signal is N, the low-pass input signal is of length N/2 if
- /// N is even and N/2+1/2 if N is odd, while the high-pass input signal is of
- /// length N/2 if N is even and N/2-1/2 if N is odd.
- ///
- /// - The normalization of the analysis filters is 1 for the DC gain and 2
- /// for the Nyquist gain (Type I normalization), for both reversible and
- /// non-reversible filters. The normalization of the synthesis filters should
- /// ensure prefect reconstruction according to this normalization of the
- /// analysis wavelet filters.
- ///
- ///
- ///
- /// The synthetize method may seem very complicated, but is designed to
- /// minimize the amount of data copying and redundant calculations when used
- /// for block-based or line-based wavelet transform implementations, while
- /// being applicable to full-frame transforms as well.
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- public abstract class SynWTFilter : WaveletFilter
- {
- public abstract int AnHighPosSupport { get; }
- public abstract int AnLowNegSupport { get; }
- public abstract int AnLowPosSupport { get; }
- public abstract bool Reversible { get; }
- public abstract int ImplType { get; }
- public abstract int SynHighNegSupport { get; }
- public abstract int SynHighPosSupport { get; }
- public abstract int AnHighNegSupport { get; }
- public abstract int DataType { get; }
- public abstract int SynLowNegSupport { get; }
- public abstract int SynLowPosSupport { get; }
-
- /// Reconstructs the output signal by the synthesis filter, recomposing the
- /// low-pass and high-pass input signals in one output signal. This method
- /// performs the upsampling and fitering with the low pass first filtering
- /// convention.
- ///
- /// The input low-pass (high-pass) signal resides in the lowSig
- /// array. The index of the first sample to filter (i.e. that will generate
- /// the first (second) output sample). is given by lowOff (highOff). This
- /// array must be of the same type as the one for which the particular
- /// implementation works with (which is returned by the getDataType()
- /// method).
- ///
- /// The low-pass (high-pass) input signal can be interleaved with other
- /// signals in the same lowSig (highSig) array, and this is determined by
- /// the lowStep (highStep) argument. This means that the first sample of
- /// the low-pass (high-pass) input signal is lowSig[lowOff]
- /// (highSig[highOff]), the second is lowSig[lowOff+lowStep]
- /// (highSig[highOff+highStep]), the third is lowSig[lowOff+2*lowStep]
- /// (highSig[highOff+2*highStep]), and so on. Therefore if lowStep
- /// (highStep) is 1 there is no interleaving. This feature allows to filter
- /// columns of a 2-D signal, when it is stored in a line by line order in
- /// lowSig (highSig), without having to copy the data, in this case the
- /// lowStep (highStep) argument should be the line width of the low-pass
- /// (high-pass) signal.
- ///
- /// The output signal is placed in the outSig array. The outOff and
- /// outStep arguments are analogous to the lowOff and lowStep ones, but
- /// they apply to the outSig array. The outSig array must be long enough to
- /// hold the low-pass output signal.
- ///
- ///
- /// This is the array that contains the low-pass input
- /// signal. It must be of the correct type (e.g., it must be int[] if
- /// getDataType() returns TYPE_INT).
- ///
- ///
- /// This is the index in lowSig of the first sample to
- /// filter.
- ///
- ///
- /// This is the number of samples in the low-pass input
- /// signal to filter.
- ///
- ///
- /// This is the step, or interleave factor, of the low-pass
- /// input signal samples in the lowSig array. See above.
- ///
- ///
- /// This is the array that contains the high-pass input
- /// signal. It must be of the correct type (e.g., it must be int[] if
- /// getDataType() returns TYPE_INT).
- ///
- ///
- /// This is the index in highSig of the first sample to
- /// filter.
- ///
- ///
- /// This is the number of samples in the high-pass input
- /// signal to filter.
- ///
- ///
- /// This is the step, or interleave factor, of the
- /// high-pass input signal samples in the highSig array. See above.
- ///
- ///
- /// This is the array where the output signal is placed. It
- /// must be of the same type as lowSig and it should be long enough to
- /// contain the output signal.
- ///
- ///
- /// This is the index in outSig of the element where to put
- /// the first output sample.
- ///
- ///
- /// This is the step, or interleave factor, of the output
- /// samples in the outSig array. See above.
- ///
- ///
- public abstract void synthetize_lpf(System.Object lowSig, int lowOff, int lowLen, int lowStep, System.Object highSig, int highOff, int highLen, int highStep, System.Object outSig, int outOff, int outStep);
-
- /// Reconstructs the output signal by the synthesis filter, recomposing the
- /// low-pass and high-pass input signals in one output signal. This method
- /// performs the upsampling and fitering with the high pass first filtering
- /// convention.
- ///
- /// The input low-pass (high-pass) signal resides in the lowSig
- /// array. The index of the first sample to filter (i.e. that will generate
- /// the first (second) output sample). is given by lowOff (highOff). This
- /// array must be of the same type as the one for which the particular
- /// implementation works with (which is returned by the getDataType()
- /// method).
- ///
- /// The low-pass (high-pass) input signal can be interleaved with other
- /// signals in the same lowSig (highSig) array, and this is determined by
- /// the lowStep (highStep) argument. This means that the first sample of
- /// the low-pass (high-pass) input signal is lowSig[lowOff]
- /// (highSig[highOff]), the second is lowSig[lowOff+lowStep]
- /// (highSig[highOff+highStep]), the third is lowSig[lowOff+2*lowStep]
- /// (highSig[highOff+2*highStep]), and so on. Therefore if lowStep
- /// (highStep) is 1 there is no interleaving. This feature allows to filter
- /// columns of a 2-D signal, when it is stored in a line by line order in
- /// lowSig (highSig), without having to copy the data, in this case the
- /// lowStep (highStep) argument should be the line width of the low-pass
- /// (high-pass) signal.
- ///
- /// The output signal is placed in the outSig array. The outOff and
- /// outStep arguments are analogous to the lowOff and lowStep ones, but
- /// they apply to the outSig array. The outSig array must be long enough to
- /// hold the low-pass output signal.
- ///
- ///
- /// This is the array that contains the low-pass input
- /// signal. It must be of the correct type (e.g., it must be int[] if
- /// getDataType() returns TYPE_INT).
- ///
- ///
- /// This is the index in lowSig of the first sample to
- /// filter.
- ///
- ///
- /// This is the number of samples in the low-pass input
- /// signal to filter.
- ///
- ///
- /// This is the step, or interleave factor, of the low-pass
- /// input signal samples in the lowSig array. See above.
- ///
- ///
- /// This is the array that contains the high-pass input
- /// signal. It must be of the correct type (e.g., it must be int[] if
- /// getDataType() returns TYPE_INT).
- ///
- ///
- /// This is the index in highSig of the first sample to
- /// filter.
- ///
- ///
- /// This is the number of samples in the high-pass input
- /// signal to filter.
- ///
- ///
- /// This is the step, or interleave factor, of the
- /// high-pass input signal samples in the highSig array. See above.
- ///
- ///
- /// This is the array where the output signal is placed. It
- /// must be of the same type as lowSig and it should be long enough to
- /// contain the output signal.
- ///
- ///
- /// This is the index in outSig of the element where to put
- /// the first output sample.
- ///
- ///
- /// This is the step, or interleave factor, of the output
- /// samples in the outSig array. See above.
- ///
- ///
- public abstract void synthetize_hpf(System.Object lowSig, int lowOff, int lowLen, int lowStep, System.Object highSig, int highOff, int highLen, int highStep, System.Object outSig, int outOff, int outStep);
- public abstract bool isSameAsFullWT(int param1, int param2, int param3);
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/wavelet/synthesis/SynWTFilterFloat.cs b/CSJ2K/j2k/wavelet/synthesis/SynWTFilterFloat.cs
deleted file mode 100644
index cedcf4fd..00000000
--- a/CSJ2K/j2k/wavelet/synthesis/SynWTFilterFloat.cs
+++ /dev/null
@@ -1,332 +0,0 @@
-/*
-* CVS identifier:
-*
-* $Id: SynWTFilterFloat.java,v 1.7 2000/09/05 09:26:32 grosbois Exp $
-*
-* Class: SynWTFilterFloat
-*
-* Description: A specialized synthesis wavelet filter interface
-* that works on float data.
-*
-*
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-*
-*
-*
-*/
-using CSJ2K.j2k.image;
-namespace CSJ2K.j2k.wavelet.synthesis
-{
-
- /// This extends the synthesis wavelet filter general definitions of
- /// SynWTFilter by adding methods that work for float data
- /// specifically. Implementations that work on float data should inherit
- /// from this class.
- ///
- /// See the SynWTFilter class for details such as
- /// normalization, how to split odd-length signals, etc.
- ///
- ///
The advantage of using the specialized method is that no casts
- /// are performed.
- ///
- ///
- ///
- ///
- ///
- public abstract class SynWTFilterFloat : SynWTFilter
- {
- /// Returns the type of data on which this filter works, as defined
- /// in the DataBlk interface, which is always TYPE_FLOAT for this
- /// class.
- ///
- ///
- /// The type of data as defined in the DataBlk interface.
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- override public int DataType
- {
- get
- {
- return DataBlk.TYPE_FLOAT;
- }
-
- }
-
- /// A specific version of the synthetize_lpf() method that works on float
- /// data. See the general description of the synthetize_lpf() method in the
- /// SynWTFilter class for more details.
- ///
- ///
- /// This is the array that contains the low-pass
- /// input signal.
- ///
- ///
- /// This is the index in lowSig of the first sample to
- /// filter.
- ///
- ///
- /// This is the number of samples in the low-pass
- /// input signal to filter.
- ///
- ///
- /// This is the step, or interleave factor, of the
- /// low-pass input signal samples in the lowSig array.
- ///
- ///
- /// This is the array that contains the high-pass
- /// input signal.
- ///
- ///
- /// This is the index in highSig of the first sample to
- /// filter.
- ///
- ///
- /// This is the number of samples in the high-pass
- /// input signal to filter.
- ///
- ///
- /// This is the step, or interleave factor, of the
- /// high-pass input signal samples in the highSig array.
- ///
- ///
- /// This is the array where the output signal is
- /// placed. It should be long enough to contain the output signal.
- ///
- ///
- /// This is the index in outSig of the element where
- /// to put the first output sample.
- ///
- ///
- /// This is the step, or interleave factor, of the
- /// output samples in the outSig array.
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- public abstract void synthetize_lpf(float[] lowSig, int lowOff, int lowLen, int lowStep, float[] highSig, int highOff, int highLen, int highStep, float[] outSig, int outOff, int outStep);
-
- /// The general version of the synthetize_lpf() method, it just calls
- /// the specialized version. See the description of the synthetize_lpf()
- /// method of the SynWTFilter class for more details.
- ///
- ///
- /// This is the array that contains the low-pass
- /// input signal. It must be an float[].
- ///
- ///
- /// This is the index in lowSig of the first sample to
- /// filter.
- ///
- ///
- /// This is the number of samples in the low-pass
- /// input signal to filter.
- ///
- ///
- /// This is the step, or interleave factor, of the
- /// low-pass input signal samples in the lowSig array.
- ///
- ///
- /// This is the array that contains the high-pass
- /// input signal. It must be an float[].
- ///
- ///
- /// This is the index in highSig of the first sample to
- /// filter.
- ///
- ///
- /// This is the number of samples in the high-pass
- /// input signal to filter.
- ///
- ///
- /// This is the step, or interleave factor, of the
- /// high-pass input signal samples in the highSig array.
- ///
- ///
- /// This is the array where the output signal is
- /// placed. It should be and float[] and long enough to contain the
- /// output signal.
- ///
- ///
- /// This is the index in outSig of the element where
- /// to put the first output sample.
- ///
- ///
- /// This is the step, or interleave factor, of the
- /// output samples in the outSig array.
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- public override void synthetize_lpf(System.Object lowSig, int lowOff, int lowLen, int lowStep, System.Object highSig, int highOff, int highLen, int highStep, System.Object outSig, int outOff, int outStep)
- {
-
- synthetize_lpf((float[])lowSig, lowOff, lowLen, lowStep, (float[])highSig, highOff, highLen, highStep, (float[])outSig, outOff, outStep);
- }
-
- /// A specific version of the synthetize_hpf() method that works on float
- /// data. See the general description of the synthetize_hpf() method in the
- /// SynWTFilter class for more details.
- ///
- ///
- /// This is the array that contains the low-pass
- /// input signal.
- ///
- ///
- /// This is the index in lowSig of the first sample to
- /// filter.
- ///
- ///
- /// This is the number of samples in the low-pass
- /// input signal to filter.
- ///
- ///
- /// This is the step, or interleave factor, of the
- /// low-pass input signal samples in the lowSig array.
- ///
- ///
- /// This is the array that contains the high-pass
- /// input signal.
- ///
- ///
- /// This is the index in highSig of the first sample to
- /// filter.
- ///
- ///
- /// This is the number of samples in the high-pass
- /// input signal to filter.
- ///
- ///
- /// This is the step, or interleave factor, of the
- /// high-pass input signal samples in the highSig array.
- ///
- ///
- /// This is the array where the output signal is
- /// placed. It should be long enough to contain the output signal.
- ///
- ///
- /// This is the index in outSig of the element where
- /// to put the first output sample.
- ///
- ///
- /// This is the step, or interleave factor, of the
- /// output samples in the outSig array.
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- public abstract void synthetize_hpf(float[] lowSig, int lowOff, int lowLen, int lowStep, float[] highSig, int highOff, int highLen, int highStep, float[] outSig, int outOff, int outStep);
-
- /// The general version of the synthetize_hpf() method, it just calls
- /// the specialized version. See the description of the synthetize_hpf()
- /// method of the SynWTFilter class for more details.
- ///
- ///
- /// This is the array that contains the low-pass
- /// input signal. It must be an float[].
- ///
- ///
- /// This is the index in lowSig of the first sample to
- /// filter.
- ///
- ///
- /// This is the number of samples in the low-pass
- /// input signal to filter.
- ///
- ///
- /// This is the step, or interleave factor, of the
- /// low-pass input signal samples in the lowSig array.
- ///
- ///
- /// This is the array that contains the high-pass
- /// input signal. It must be an float[].
- ///
- ///
- /// This is the index in highSig of the first sample to
- /// filter.
- ///
- ///
- /// This is the number of samples in the high-pass
- /// input signal to filter.
- ///
- ///
- /// This is the step, or interleave factor, of the
- /// high-pass input signal samples in the highSig array.
- ///
- ///
- /// This is the array where the output signal is
- /// placed. It should be and float[] and long enough to contain the
- /// output signal.
- ///
- ///
- /// This is the index in outSig of the element where
- /// to put the first output sample.
- ///
- ///
- /// This is the step, or interleave factor, of the
- /// output samples in the outSig array.
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- public override void synthetize_hpf(System.Object lowSig, int lowOff, int lowLen, int lowStep, System.Object highSig, int highOff, int highLen, int highStep, System.Object outSig, int outOff, int outStep)
- {
-
- synthetize_hpf((float[])lowSig, lowOff, lowLen, lowStep, (float[])highSig, highOff, highLen, highStep, (float[])outSig, outOff, outStep);
- }
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/wavelet/synthesis/SynWTFilterFloatLift9x7.cs b/CSJ2K/j2k/wavelet/synthesis/SynWTFilterFloatLift9x7.cs
deleted file mode 100644
index 7adf53b8..00000000
--- a/CSJ2K/j2k/wavelet/synthesis/SynWTFilterFloatLift9x7.cs
+++ /dev/null
@@ -1,691 +0,0 @@
-/*
-* CVS identifier:
-*
-* $Id: SynWTFilterFloatLift9x7.java,v 1.15 2002/05/22 15:01:56 grosbois Exp $
-*
-* Class: SynWTFilterFloatLift9x7
-*
-* Description: A synthetizing wavelet filter implementing the
-* lifting 9x7 transform.
-*
-*
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-* */
-namespace CSJ2K.j2k.wavelet.synthesis
-{
-
- /// This class inherits from the synthesis wavelet filter definition for int
- /// data. It implements the inverse wavelet transform specifically for the 9x7
- /// filter. The implementation is based on the lifting scheme.
- ///
- /// See the SynWTFilter class for details such as normalization, how to
- /// split odd-length signals, etc. In particular, this method assumes that the
- /// low-pass coefficient is computed first.
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- public class SynWTFilterFloatLift9x7 : SynWTFilterFloat
- {
- /// Returns the negative support of the low-pass analysis filter. That is
- /// the number of taps of the filter in the negative direction.
- ///
- ///
- /// 2
- ///
- ///
- override public int AnLowNegSupport
- {
- get
- {
- return 4;
- }
-
- }
- /// Returns the positive support of the low-pass analysis filter. That is
- /// the number of taps of the filter in the negative direction.
- ///
- ///
- /// The number of taps of the low-pass analysis filter in the
- /// positive direction
- ///
- ///
- override public int AnLowPosSupport
- {
- get
- {
- return 4;
- }
-
- }
- /// Returns the negative support of the high-pass analysis filter. That is
- /// the number of taps of the filter in the negative direction.
- ///
- ///
- /// The number of taps of the high-pass analysis filter in
- /// the negative direction
- ///
- ///
- override public int AnHighNegSupport
- {
- get
- {
- return 3;
- }
-
- }
- /// Returns the positive support of the high-pass analysis filter. That is
- /// the number of taps of the filter in the negative direction.
- ///
- ///
- /// The number of taps of the high-pass analysis filter in the
- /// positive direction
- ///
- ///
- override public int AnHighPosSupport
- {
- get
- {
- return 3;
- }
-
- }
- /// Returns the negative support of the low-pass synthesis filter. That is
- /// the number of taps of the filter in the negative direction.
- ///
- /// A MORE PRECISE DEFINITION IS NEEDED
- ///
- ///
- /// The number of taps of the low-pass synthesis filter in the
- /// negative direction
- ///
- ///
- override public int SynLowNegSupport
- {
- get
- {
- return 3;
- }
-
- }
- /// Returns the positive support of the low-pass synthesis filter. That is
- /// the number of taps of the filter in the negative direction.
- ///
- /// A MORE PRECISE DEFINITION IS NEEDED
- ///
- ///
- /// The number of taps of the low-pass synthesis filter in the
- /// positive direction
- ///
- ///
- override public int SynLowPosSupport
- {
- get
- {
- return 3;
- }
-
- }
- /// Returns the negative support of the high-pass synthesis filter. That is
- /// the number of taps of the filter in the negative direction.
- ///
- /// A MORE PRECISE DEFINITION IS NEEDED
- ///
- ///
- /// The number of taps of the high-pass synthesis filter in the
- /// negative direction
- ///
- ///
- override public int SynHighNegSupport
- {
- get
- {
- return 4;
- }
-
- }
- /// Returns the positive support of the high-pass synthesis filter. That is
- /// the number of taps of the filter in the negative direction.
- ///
- /// A MORE PRECISE DEFINITION IS NEEDED
- ///
- ///
- /// The number of taps of the high-pass synthesis filter in the
- /// positive direction
- ///
- ///
- override public int SynHighPosSupport
- {
- get
- {
- return 4;
- }
-
- }
- /// Returns the implementation type of this filter, as defined in this
- /// class, such as WT_FILTER_INT_LIFT, WT_FILTER_FLOAT_LIFT,
- /// WT_FILTER_FLOAT_CONVOL.
- ///
- ///
- /// WT_FILTER_INT_LIFT.
- ///
- ///
- override public int ImplType
- {
- get
- {
- return CSJ2K.j2k.wavelet.WaveletFilter_Fields.WT_FILTER_FLOAT_LIFT;
- }
-
- }
- /// Returns the reversibility of the filter. A filter is considered
- /// reversible if it is suitable for lossless coding.
- ///
- ///
- /// true since the 9x7 is reversible, provided the appropriate
- /// rounding is performed.
- ///
- ///
- override public bool Reversible
- {
- get
- {
- return false;
- }
-
- }
-
- /// The value of the first lifting step coefficient
- public const float ALPHA = -1.586134342f;
-
- /// The value of the second lifting step coefficient
- public const float BETA = -0.05298011854f;
-
- /// The value of the third lifting step coefficient
- public const float GAMMA = 0.8829110762f;
-
- /// The value of the fourth lifting step coefficient
- public const float DELTA = 0.4435068522f;
-
- /// The value of the low-pass subband normalization factor
- public const float KL = 0.8128930655f;
-
- /// The value of the high-pass subband normalization factor
- public const float KH = 1.230174106f;
-
- /// An implementation of the synthetize_lpf() method that works on int
- /// data, for the inverse 9x7 wavelet transform using the lifting
- /// scheme. See the general description of the synthetize_lpf() method in
- /// the SynWTFilter class for more details.
- ///
- /// The low-pass and high-pass subbands are normalized by respectively a
- /// factor of 1/KL and a factor of 1/KH
- ///
- ///
The coefficients of the first lifting step are [-DELTA 1 -DELTA].
- ///
- ///
The coefficients of the second lifting step are [-GAMMA 1 -GAMMA].
- ///
- ///
The coefficients of the third lifting step are [-BETA 1 -BETA].
- ///
- ///
The coefficients of the fourth lifting step are [-ALPHA 1 -ALPHA].
- ///
- ///
- /// This is the array that contains the low-pass input
- /// signal.
- ///
- ///
- /// This is the index in lowSig of the first sample to
- /// filter.
- ///
- ///
- /// This is the number of samples in the low-pass input
- /// signal to filter.
- ///
- ///
- /// This is the step, or interleave factor, of the low-pass
- /// input signal samples in the lowSig array.
- ///
- ///
- /// This is the array that contains the high-pass input
- /// signal.
- ///
- ///
- /// This is the index in highSig of the first sample to
- /// filter.
- ///
- ///
- /// This is the number of samples in the high-pass input
- /// signal to filter.
- ///
- ///
- /// This is the step, or interleave factor, of the
- /// high-pass input signal samples in the highSig array.
- ///
- ///
- /// This is the array where the output signal is placed. It
- /// should be long enough to contain the output signal.
- ///
- ///
- /// This is the index in outSig of the element where to put
- /// the first output sample.
- ///
- ///
- /// This is the step, or interleave factor, of the output
- /// samples in the outSig array.
- ///
- ///
- ///
- ///
- ///
- public override void synthetize_lpf(float[] lowSig, int lowOff, int lowLen, int lowStep, float[] highSig, int highOff, int highLen, int highStep, float[] outSig, int outOff, int outStep)
- {
-
- int i;
- int outLen = lowLen + highLen; //Length of the output signal
- int iStep = 2 * outStep; //Upsampling in outSig
- int ik; //Indexing outSig
- int lk; //Indexing lowSig
- int hk; //Indexing highSig
-
- // Generate intermediate low frequency subband
- //float sample = 0;
-
- //Initialize counters
- lk = lowOff;
- hk = highOff;
- ik = outOff;
-
- //Handle tail boundary effect. Use symmetric extension
- if (outLen > 1)
- {
- outSig[ik] = lowSig[lk] / KL - 2 * DELTA * highSig[hk] / KH;
- }
- else
- {
- outSig[ik] = lowSig[lk];
- }
-
- lk += lowStep;
- hk += highStep;
- ik += iStep;
-
- //Apply lifting step to each "inner" sample
- for (i = 2; i < outLen - 1; i += 2, ik += iStep, lk += lowStep, hk += highStep)
- {
- outSig[ik] = lowSig[lk] / KL - DELTA * (highSig[hk - highStep] + highSig[hk]) / KH;
- }
-
- //Handle head boundary effect if input signal has odd length
- if (outLen % 2 == 1)
- {
- if (outLen > 2)
- {
- outSig[ik] = lowSig[lk] / KL - 2 * DELTA * highSig[hk - highStep] / KH;
- }
- }
-
- // Generate intermediate high frequency subband
-
- //Initialize counters
- lk = lowOff;
- hk = highOff;
- ik = outOff + outStep;
-
- //Apply lifting step to each "inner" sample
- for (i = 1; i < outLen - 1; i += 2, ik += iStep, hk += highStep, lk += lowStep)
- {
- outSig[ik] = highSig[hk] / KH - GAMMA * (outSig[ik - outStep] + outSig[ik + outStep]);
- }
-
- //Handle head boundary effect if output signal has even length
- if (outLen % 2 == 0)
- {
- outSig[ik] = highSig[hk] / KH - 2 * GAMMA * outSig[ik - outStep];
- }
-
- // Generate even samples (inverse low-pass filter)
-
- //Initialize counters
- ik = outOff;
-
- //Handle tail boundary effect
- //If access the overlap then perform the lifting step.
- if (outLen > 1)
- {
- outSig[ik] -= 2 * BETA * outSig[ik + outStep];
- }
- ik += iStep;
-
- //Apply lifting step to each "inner" sample
- for (i = 2; i < outLen - 1; i += 2, ik += iStep)
- {
- outSig[ik] -= BETA * (outSig[ik - outStep] + outSig[ik + outStep]);
- }
-
- //Handle head boundary effect if input signal has odd length
- if (outLen % 2 == 1 && outLen > 2)
- {
- outSig[ik] -= 2 * BETA * outSig[ik - outStep];
- }
-
- // Generate odd samples (inverse high pass-filter)
-
- //Initialize counters
- ik = outOff + outStep;
-
- //Apply first lifting step to each "inner" sample
- for (i = 1; i < outLen - 1; i += 2, ik += iStep)
- {
- outSig[ik] -= ALPHA * (outSig[ik - outStep] + outSig[ik + outStep]);
- }
-
- //Handle head boundary effect if input signal has even length
- if (outLen % 2 == 0)
- {
- outSig[ik] -= 2 * ALPHA * outSig[ik - outStep];
- }
- }
-
- /// An implementation of the synthetize_hpf() method that works on int
- /// data, for the inverse 9x7 wavelet transform using the lifting
- /// scheme. See the general description of the synthetize_hpf() method in
- /// the SynWTFilter class for more details.
- ///
- /// The low-pass and high-pass subbands are normalized by respectively
- /// a factor of 1/KL and a factor of 1/KH
- ///
- ///
The coefficients of the first lifting step are [-DELTA 1 -DELTA].
- ///
- ///
The coefficients of the second lifting step are [-GAMMA 1 -GAMMA].
- ///
- ///
The coefficients of the third lifting step are [-BETA 1 -BETA].
- ///
- ///
The coefficients of the fourth lifting step are [-ALPHA 1 -ALPHA].
- ///
- ///
- /// This is the array that contains the low-pass
- /// input signal.
- ///
- ///
- /// This is the index in lowSig of the first sample to
- /// filter.
- ///
- ///
- /// This is the number of samples in the low-pass input
- /// signal to filter.
- ///
- ///
- /// This is the step, or interleave factor, of the low-pass
- /// input signal samples in the lowSig array.
- ///
- ///
- /// This is the array that contains the high-pass input
- /// signal.
- ///
- ///
- /// This is the index in highSig of the first sample to
- /// filter.
- ///
- ///
- /// This is the number of samples in the high-pass input
- /// signal to filter.
- ///
- ///
- /// This is the step, or interleave factor, of the
- /// high-pass input signal samples in the highSig array.
- ///
- ///
- /// This is the array where the output signal is placed. It
- /// should be long enough to contain the output signal.
- ///
- ///
- /// This is the index in outSig of the element where to put
- /// the first output sample.
- ///
- ///
- /// This is the step, or interleave factor, of the output
- /// samples in the outSig array.
- ///
- ///
- ///
- ///
- ///
- public override void synthetize_hpf(float[] lowSig, int lowOff, int lowLen, int lowStep, float[] highSig, int highOff, int highLen, int highStep, float[] outSig, int outOff, int outStep)
- {
-
- int i;
- int outLen = lowLen + highLen; //Length of the output signal
- int iStep = 2 * outStep; //Upsampling in outSig
- int ik; //Indexing outSig
- int lk; //Indexing lowSig
- int hk; //Indexing highSig
-
- // Initialize counters
- lk = lowOff;
- hk = highOff;
-
- if (outLen != 1)
- {
- int outLen2 = outLen >> 1;
- // "Inverse normalize" each sample
- for (i = 0; i < outLen2; i++)
- {
- lowSig[lk] /= KL;
- highSig[hk] /= KH;
- lk += lowStep;
- hk += highStep;
- }
- // "Inverse normalise" last high pass coefficient
- if (outLen % 2 == 1)
- {
- highSig[hk] /= KH;
- }
- }
- else
- {
- // Normalize for Nyquist gain
- highSig[highOff] /= 2;
- }
-
- // Generate intermediate low frequency subband
-
- //Initialize counters
- lk = lowOff;
- hk = highOff;
- ik = outOff + outStep;
-
- //Apply lifting step to each "inner" sample
- for (i = 1; i < outLen - 1; i += 2)
- {
- outSig[ik] = lowSig[lk] - DELTA * (highSig[hk] + highSig[hk + highStep]);
- ik += iStep;
- lk += lowStep;
- hk += highStep;
- }
-
- if (outLen % 2 == 0 && outLen > 1)
- {
- //Use symmetric extension
- outSig[ik] = lowSig[lk] - 2 * DELTA * highSig[hk];
- }
-
- // Generate intermediate high frequency subband
-
- //Initialize counters
- hk = highOff;
- ik = outOff;
-
- if (outLen > 1)
- {
- outSig[ik] = highSig[hk] - 2 * GAMMA * outSig[ik + outStep];
- }
- else
- {
- outSig[ik] = highSig[hk];
- }
-
- ik += iStep;
- hk += highStep;
-
- //Apply lifting step to each "inner" sample
- for (i = 2; i < outLen - 1; i += 2)
- {
- outSig[ik] = highSig[hk] - GAMMA * (outSig[ik - outStep] + outSig[ik + outStep]);
- ik += iStep;
- hk += highStep;
- }
-
- //Handle head boundary effect if output signal has even length
- if (outLen % 2 == 1 && outLen > 1)
- {
- //Use symmetric extension
- outSig[ik] = highSig[hk] - 2 * GAMMA * outSig[ik - outStep];
- }
-
- // Generate even samples (inverse low-pass filter)
-
- //Initialize counters
- ik = outOff + outStep;
-
- //Apply lifting step to each "inner" sample
- for (i = 1; i < outLen - 1; i += 2)
- {
- outSig[ik] -= BETA * (outSig[ik - outStep] + outSig[ik + outStep]);
- ik += iStep;
- }
-
- if (outLen % 2 == 0 && outLen > 1)
- {
- // symmetric extension.
- outSig[ik] -= 2 * BETA * outSig[ik - outStep];
- }
-
- // Generate odd samples (inverse high pass-filter)
-
- //Initialize counters
- ik = outOff;
-
- if (outLen > 1)
- {
- // symmetric extension.
- outSig[ik] -= 2 * ALPHA * outSig[ik + outStep];
- }
- ik += iStep;
-
- //Apply first lifting step to each "inner" sample
- for (i = 2; i < outLen - 1; i += 2)
- {
- outSig[ik] -= ALPHA * (outSig[ik - outStep] + outSig[ik + outStep]);
- ik += iStep;
- }
-
- //Handle head boundary effect if input signal has even length
- if ((outLen % 2 == 1) && (outLen > 1))
- {
- //Use symmetric extension
- outSig[ik] -= 2 * ALPHA * outSig[ik - outStep];
- }
- }
-
- /// Returns true if the wavelet filter computes or uses the
- /// same "inner" subband coefficient as the full frame wavelet transform,
- /// and false otherwise. In particular, for block based transforms with
- /// reduced overlap, this method should return false. The term "inner"
- /// indicates that this applies only with respect to the coefficient that
- /// are not affected by image boundaries processings such as symmetric
- /// extension, since there is not reference method for this.
- ///
- /// The result depends on the length of the allowed overlap when
- /// compared to the overlap required by the wavelet filter. It also
- /// depends on how overlap processing is implemented in the wavelet
- /// filter.
- ///
- ///
- /// This is the number of samples in the input
- /// signal before the first sample to filter that can be used for
- /// overlap.
- ///
- ///
- /// This is the number of samples in the input
- /// signal after the last sample to filter that can be used for
- /// overlap.
- ///
- ///
- /// This is the lenght of the input signal to filter.The
- /// required number of samples in the input signal after the last sample
- /// depends on the length of the input signal.
- ///
- ///
- /// true if both overlaps are greater than 2, and correct
- /// processing is applied in the analyze() method.
- ///
- ///
- ///
- ///
- public override bool isSameAsFullWT(int tailOvrlp, int headOvrlp, int inLen)
- {
-
- //If the input signal has even length.
- if (inLen % 2 == 0)
- {
- if (tailOvrlp >= 2 && headOvrlp >= 1)
- return true;
- else
- return false;
- }
- //Else if the input signal has odd length.
- else
- {
- if (tailOvrlp >= 2 && headOvrlp >= 2)
- return true;
- else
- return false;
- }
- }
-
- /// Returns a string of information about the synthesis wavelet filter
- ///
- ///
- /// wavelet filter type.
- ///
- ///
- ///
- public override System.String ToString()
- {
- return "w9x7 (lifting)";
- }
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/wavelet/synthesis/SynWTFilterInt.cs b/CSJ2K/j2k/wavelet/synthesis/SynWTFilterInt.cs
deleted file mode 100644
index 7dbd24d0..00000000
--- a/CSJ2K/j2k/wavelet/synthesis/SynWTFilterInt.cs
+++ /dev/null
@@ -1,334 +0,0 @@
-/*
-* CVS identifier:
-*
-* $Id: SynWTFilterInt.java,v 1.7 2000/09/05 09:26:35 grosbois Exp $
-*
-* Class: SynWTFilterInt
-*
-* Description: A specialized synthesis wavelet filter interface
-* that works on int data.
-*
-*
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-*
-*
-*
-*/
-using CSJ2K.j2k.image;
-namespace CSJ2K.j2k.wavelet.synthesis
-{
-
- /// This extends the synthesis wavelet filter general definitions of
- /// SynWTFilter by adding methods that work for int data
- /// specifically. Implementations that work on int data should inherit
- /// from this class.
- ///
- /// See the SynWTFilter class for details such as
- /// normalization, how to split odd-length signals, etc.
- ///
- ///
The advantage of using the specialized method is that no casts
- /// are performed.
- ///
- ///
- ///
- ///
- ///
- public abstract class SynWTFilterInt : SynWTFilter
- {
- /// Returns the type of data on which this filter works, as defined
- /// in the DataBlk interface, which is always TYPE_INT for this
- /// class.
- ///
- ///
- /// The type of data as defined in the DataBlk interface.
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- override public int DataType
- {
- get
- {
- return DataBlk.TYPE_INT;
- }
-
- }
-
- /// A specific version of the synthetize_lpf() method that works on int
- /// data. See the general description of the synthetize_lpf() method in the
- /// SynWTFilter class for more details.
- ///
- ///
- /// This is the array that contains the low-pass
- /// input signal.
- ///
- ///
- /// This is the index in lowSig of the first sample to
- /// filter.
- ///
- ///
- /// This is the number of samples in the low-pass
- /// input signal to filter.
- ///
- ///
- /// This is the step, or interleave factor, of the
- /// low-pass input signal samples in the lowSig array.
- ///
- ///
- /// This is the array that contains the high-pass
- /// input signal.
- ///
- ///
- /// This is the index in highSig of the first sample to
- /// filter.
- ///
- ///
- /// This is the number of samples in the high-pass
- /// input signal to filter.
- ///
- ///
- /// This is the step, or interleave factor, of the
- /// high-pass input signal samples in the highSig array.
- ///
- ///
- /// This is the array where the output signal is
- /// placed. It should be long enough to contain the output signal.
- ///
- ///
- /// This is the index in outSig of the element where
- /// to put the first output sample.
- ///
- ///
- /// This is the step, or interleave factor, of the
- /// output samples in the outSig array.
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- public abstract void synthetize_lpf(int[] lowSig, int lowOff, int lowLen, int lowStep, int[] highSig, int highOff, int highLen, int highStep, int[] outSig, int outOff, int outStep);
-
- /// The general version of the synthetize_lpf() method, it just calls
- /// the specialized version. See the description of the synthetize_lpf()
- /// method of the SynWTFilter class for more details.
- ///
- ///
- /// This is the array that contains the low-pass
- /// input signal. It must be an int[].
- ///
- ///
- /// This is the index in lowSig of the first sample to
- /// filter.
- ///
- ///
- /// This is the number of samples in the low-pass
- /// input signal to filter.
- ///
- ///
- /// This is the step, or interleave factor, of the
- /// low-pass input signal samples in the lowSig array.
- ///
- ///
- /// This is the array that contains the high-pass
- /// input signal. Itmust be an int[].
- ///
- ///
- /// This is the index in highSig of the first sample to
- /// filter.
- ///
- ///
- /// This is the number of samples in the high-pass
- /// input signal to filter.
- ///
- ///
- /// This is the step, or interleave factor, of the
- /// high-pass input signal samples in the highSig array.
- ///
- ///
- /// This is the array where the output signal is
- /// placed. It should be and int[] and long enough to contain the
- /// output signal.
- ///
- ///
- /// This is the index in outSig of the element where
- /// to put the first output sample.
- ///
- ///
- /// This is the step, or interleave factor, of the
- /// output samples in the outSig array.
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- public override void synthetize_lpf(System.Object lowSig, int lowOff, int lowLen, int lowStep, System.Object highSig, int highOff, int highLen, int highStep, System.Object outSig, int outOff, int outStep)
- {
-
- synthetize_lpf((int[])lowSig, lowOff, lowLen, lowStep, (int[])highSig, highOff, highLen, highStep, (int[])outSig, outOff, outStep);
- }
-
- /// A specific version of the synthetize_hpf() method that works on int
- /// data. See the general description of the synthetize_hpf() method in the
- /// SynWTFilter class for more details.
- ///
- ///
- /// This is the array that contains the low-pass
- /// input signal.
- ///
- ///
- /// This is the index in lowSig of the first sample to
- /// filter.
- ///
- ///
- /// This is the number of samples in the low-pass
- /// input signal to filter.
- ///
- ///
- /// This is the step, or interleave factor, of the
- /// low-pass input signal samples in the lowSig array.
- ///
- ///
- /// This is the array that contains the high-pass
- /// input signal.
- ///
- ///
- /// This is the index in highSig of the first sample to
- /// filter.
- ///
- ///
- /// This is the number of samples in the high-pass
- /// input signal to filter.
- ///
- ///
- /// This is the step, or interleave factor, of the
- /// high-pass input signal samples in the highSig array.
- ///
- ///
- /// This is the array where the output signal is
- /// placed. It should be long enough to contain the output signal.
- ///
- ///
- /// This is the index in outSig of the element where
- /// to put the first output sample.
- ///
- ///
- /// This is the step, or interleave factor, of the
- /// output samples in the outSig array.
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- public abstract void synthetize_hpf(int[] lowSig, int lowOff, int lowLen, int lowStep, int[] highSig, int highOff, int highLen, int highStep, int[] outSig, int outOff, int outStep);
-
-
-
- /// The general version of the synthetize_hpf() method, it just calls
- /// the specialized version. See the description of the synthetize_hpf()
- /// method of the SynWTFilter class for more details.
- ///
- ///
- /// This is the array that contains the low-pass
- /// input signal. It must be an int[].
- ///
- ///
- /// This is the index in lowSig of the first sample to
- /// filter.
- ///
- ///
- /// This is the number of samples in the low-pass
- /// input signal to filter.
- ///
- ///
- /// This is the step, or interleave factor, of the
- /// low-pass input signal samples in the lowSig array.
- ///
- ///
- /// This is the array that contains the high-pass
- /// input signal. Itmust be an int[].
- ///
- ///
- /// This is the index in highSig of the first sample to
- /// filter.
- ///
- ///
- /// This is the number of samples in the high-pass
- /// input signal to filter.
- ///
- ///
- /// This is the step, or interleave factor, of the
- /// high-pass input signal samples in the highSig array.
- ///
- ///
- /// This is the array where the output signal is
- /// placed. It should be and int[] and long enough to contain the
- /// output signal.
- ///
- ///
- /// This is the index in outSig of the element where
- /// to put the first output sample.
- ///
- ///
- /// This is the step, or interleave factor, of the
- /// output samples in the outSig array.
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- public override void synthetize_hpf(System.Object lowSig, int lowOff, int lowLen, int lowStep, System.Object highSig, int highOff, int highLen, int highStep, System.Object outSig, int outOff, int outStep)
- {
-
- synthetize_hpf((int[])lowSig, lowOff, lowLen, lowStep, (int[])highSig, highOff, highLen, highStep, (int[])outSig, outOff, outStep);
- }
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/wavelet/synthesis/SynWTFilterIntLift5x3.cs b/CSJ2K/j2k/wavelet/synthesis/SynWTFilterIntLift5x3.cs
deleted file mode 100644
index 93381d0c..00000000
--- a/CSJ2K/j2k/wavelet/synthesis/SynWTFilterIntLift5x3.cs
+++ /dev/null
@@ -1,538 +0,0 @@
-/*
-* CVS identifier:
-*
-* $Id: SynWTFilterIntLift5x3.java,v 1.11 2001/08/02 11:24:23 grosbois Exp $
-*
-* Class: SynWTFilterIntLift5x3
-*
-* Description: A synthetizing wavelet filter implementing the
-* lifting 5x3 transform.
-*
-*
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-* */
-namespace CSJ2K.j2k.wavelet.synthesis
-{
-
- /// This class inherits from the synthesis wavelet filter definition for int
- /// data. It implements the inverse wavelet transform specifically for the 5x3
- /// filter. The implementation is based on the lifting scheme.
- ///
- /// See the SynWTFilter class for details such as normalization, how to
- /// split odd-length signals, etc. In particular, this method assumes that the
- /// low-pass coefficient is computed first.
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- public class SynWTFilterIntLift5x3 : SynWTFilterInt
- {
- /// Returns the negative support of the low-pass analysis filter. That is
- /// the number of taps of the filter in the negative direction.
- ///
- ///
- /// 2
- ///
- ///
- override public int AnLowNegSupport
- {
- get
- {
- return 2;
- }
-
- }
- /// Returns the positive support of the low-pass analysis filter. That is
- /// the number of taps of the filter in the negative direction.
- ///
- ///
- /// The number of taps of the low-pass analysis filter in the
- /// positive direction
- ///
- ///
- override public int AnLowPosSupport
- {
- get
- {
- return 2;
- }
-
- }
- /// Returns the negative support of the high-pass analysis filter. That is
- /// the number of taps of the filter in the negative direction.
- ///
- ///
- /// The number of taps of the high-pass analysis filter in the
- /// negative direction
- ///
- ///
- override public int AnHighNegSupport
- {
- get
- {
- return 1;
- }
-
- }
- /// Returns the positive support of the high-pass analysis filter. That is
- /// the number of taps of the filter in the negative direction.
- ///
- ///
- /// The number of taps of the high-pass analysis filter in the
- /// positive direction
- ///
- ///
- override public int AnHighPosSupport
- {
- get
- {
- return 1;
- }
-
- }
- /// Returns the negative support of the low-pass synthesis filter. That is
- /// the number of taps of the filter in the negative direction.
- ///
- ///
- /// The number of taps of the low-pass synthesis filter in the
- /// negative direction
- ///
- ///
- override public int SynLowNegSupport
- {
- get
- {
- return 1;
- }
-
- }
- /// Returns the positive support of the low-pass synthesis filter. That is
- /// the number of taps of the filter in the negative direction.
- ///
- ///
- /// The number of taps of the low-pass synthesis filter in the
- /// positive direction
- ///
- ///
- override public int SynLowPosSupport
- {
- get
- {
- return 1;
- }
-
- }
- /// Returns the negative support of the high-pass synthesis filter. That is
- /// the number of taps of the filter in the negative direction.
- ///
- ///
- /// The number of taps of the high-pass synthesis filter in the
- /// negative direction
- ///
- ///
- override public int SynHighNegSupport
- {
- get
- {
- return 2;
- }
-
- }
- /// Returns the positive support of the high-pass synthesis filter. That is
- /// the number of taps of the filter in the negative direction.
- ///
- ///
- /// The number of taps of the high-pass synthesis filter in the
- /// positive direction
- ///
- ///
- override public int SynHighPosSupport
- {
- get
- {
- return 2;
- }
-
- }
- /// Returns the implementation type of this filter, as defined in this
- /// class, such as WT_FILTER_INT_LIFT, WT_FILTER_FLOAT_LIFT,
- /// WT_FILTER_FLOAT_CONVOL.
- ///
- ///
- /// WT_FILTER_INT_LIFT.
- ///
- ///
- override public int ImplType
- {
- get
- {
- return CSJ2K.j2k.wavelet.WaveletFilter_Fields.WT_FILTER_INT_LIFT;
- }
-
- }
- /// Returns the reversibility of the filter. A filter is considered
- /// reversible if it is suitable for lossless coding.
- ///
- ///
- /// true since the 5x3 is reversible, provided the appropriate
- /// rounding is performed.
- ///
- ///
- override public bool Reversible
- {
- get
- {
- return true;
- }
-
- }
-
- /// An implementation of the synthetize_lpf() method that works on int
- /// data, for the inverse 5x3 wavelet transform using the lifting
- /// scheme. See the general description of the synthetize_lpf() method in
- /// the SynWTFilter class for more details.
- ///
- /// The coefficients of the first lifting step are [-1/4 1 -1/4].
- ///
- /// The coefficients of the second lifting step are [1/2 1 1/2].
- ///
- ///
- /// This is the array that contains the low-pass input
- /// signal.
- ///
- ///
- /// This is the index in lowSig of the first sample to
- /// filter.
- ///
- ///
- /// This is the number of samples in the low-pass input
- /// signal to filter.
- ///
- ///
- /// This is the step, or interleave factor, of the low-pass
- /// input signal samples in the lowSig array.
- ///
- ///
- /// This is the array that contains the high-pass input
- /// signal.
- ///
- ///
- /// This is the index in highSig of the first sample to
- /// filter.
- ///
- ///
- /// This is the number of samples in the high-pass input
- /// signal to filter.
- ///
- ///
- /// This is the step, or interleave factor, of the
- /// high-pass input signal samples in the highSig array.
- ///
- ///
- /// This is the array where the output signal is placed. It
- /// should be long enough to contain the output signal.
- ///
- ///
- /// This is the index in outSig of the element where to put
- /// the first output sample.
- ///
- ///
- /// This is the step, or interleave factor, of the output
- /// samples in the outSig array.
- ///
- ///
- ///
- ///
- ///
- public override void synthetize_lpf(int[] lowSig, int lowOff, int lowLen, int lowStep, int[] highSig, int highOff, int highLen, int highStep, int[] outSig, int outOff, int outStep)
- {
-
- int i;
- int outLen = lowLen + highLen; //Length of the output signal
- int iStep = 2 * outStep; //Upsampling in outSig
- int ik; //Indexing outSig
- int lk; //Indexing lowSig
- int hk; //Indexing highSig
-
- /* Generate even samples (inverse low-pass filter) */
-
- //Initialize counters
- lk = lowOff;
- hk = highOff;
- ik = outOff;
-
- //Handle tail boundary effect. Use symmetric extension.
- if (outLen > 1)
- {
- outSig[ik] = lowSig[lk] - ((highSig[hk] + 1) >> 1);
- }
- else
- {
- outSig[ik] = lowSig[lk];
- }
-
- lk += lowStep;
- hk += highStep;
- ik += iStep;
-
- //Apply lifting step to each "inner" sample.
- for (i = 2; i < outLen - 1; i += 2)
- {
- outSig[ik] = lowSig[lk] - ((highSig[hk - highStep] + highSig[hk] + 2) >> 2);
-
- lk += lowStep;
- hk += highStep;
- ik += iStep;
- }
-
- //Handle head boundary effect if input signal has odd length.
- if ((outLen % 2 == 1) && (outLen > 2))
- {
- outSig[ik] = lowSig[lk] - ((2 * highSig[hk - highStep] + 2) >> 2);
- }
-
- /* Generate odd samples (inverse high pass-filter) */
-
- //Initialize counters
- hk = highOff;
- ik = outOff + outStep;
-
- //Apply first lifting step to each "inner" sample.
- for (i = 1; i < outLen - 1; i += 2)
- {
- // Since signs are inversed (add instead of substract)
- // the +1 rounding dissapears.
- outSig[ik] = highSig[hk] + ((outSig[ik - outStep] + outSig[ik + outStep]) >> 1);
-
- hk += highStep;
- ik += iStep;
- }
-
- //Handle head boundary effect if input signal has even length.
- if (outLen % 2 == 0 && outLen > 1)
- {
- outSig[ik] = highSig[hk] + outSig[ik - outStep];
- }
- }
-
- /// An implementation of the synthetize_hpf() method that works on int
- /// data, for the inverse 5x3 wavelet transform using thelifting
- /// scheme. See the general description of the synthetize_hpf() method in
- /// the SynWTFilter class for more details.
- ///
- /// The coefficients of the first lifting step are [-1/4 1 -1/4].
- ///
- /// The coefficients of the second lifting step are [1/2 1 1/2].
- ///
- ///
- /// This is the array that contains the low-pass input
- /// signal.
- ///
- ///
- /// This is the index in lowSig of the first sample to
- /// filter.
- ///
- ///
- /// This is the number of samples in the low-pass input
- /// signal to filter.
- ///
- ///
- /// This is the step, or interleave factor, of the low-pass
- /// input signal samples in the lowSig array.
- ///
- ///
- /// This is the array that contains the high-pass input
- /// signal.
- ///
- ///
- /// This is the index in highSig of the first sample to
- /// filter.
- ///
- ///
- /// This is the number of samples in the high-pass input
- /// signal to filter.
- ///
- ///
- /// This is the step, or interleave factor, of the
- /// high-pass input signal samples in the highSig array.
- ///
- ///
- /// This is the array where the output signal is placed. It
- /// should be long enough to contain the output signal.
- ///
- ///
- /// This is the index in outSig of the element where to put
- /// the first output sample.
- ///
- ///
- /// This is the step, or interleave factor, of the output
- /// samples in the outSig array.
- ///
- ///
- ///
- ///
- ///
- public override void synthetize_hpf(int[] lowSig, int lowOff, int lowLen, int lowStep, int[] highSig, int highOff, int highLen, int highStep, int[] outSig, int outOff, int outStep)
- {
-
- int i;
- int outLen = lowLen + highLen; //Length of the output signal
- int iStep = 2 * outStep; //Upsampling in outSig
- int ik; //Indexing outSig
- int lk; //Indexing lowSig
- int hk; //Indexing highSig
-
- /* Generate even samples (inverse low-pass filter) */
-
- //Initialize counters
- lk = lowOff;
- hk = highOff;
- ik = outOff + outStep;
-
- //Apply lifting step to each "inner" sample.
- for (i = 1; i < outLen - 1; i += 2)
- {
- outSig[ik] = lowSig[lk] - ((highSig[hk] + highSig[hk + highStep] + 2) >> 2);
-
- lk += lowStep;
- hk += highStep;
- ik += iStep;
- }
-
- if ((outLen > 1) && (outLen % 2 == 0))
- {
- // symmetric extension.
- outSig[ik] = lowSig[lk] - ((2 * highSig[hk] + 2) >> 2);
- }
- /* Generate odd samples (inverse high pass-filter) */
-
- //Initialize counters
- hk = highOff;
- ik = outOff;
-
- if (outLen > 1)
- {
- outSig[ik] = highSig[hk] + outSig[ik + outStep];
- }
- else
- {
- // Normalize for Nyquist gain
- outSig[ik] = highSig[hk] >> 1;
- }
-
- hk += highStep;
- ik += iStep;
-
- //Apply first lifting step to each "inner" sample.
- for (i = 2; i < outLen - 1; i += 2)
- {
- // Since signs are inversed (add instead of substract)
- // the +1 rounding dissapears.
- outSig[ik] = highSig[hk] + ((outSig[ik - outStep] + outSig[ik + outStep]) >> 1);
- hk += highStep;
- ik += iStep;
- }
-
- //Handle head boundary effect if input signal has odd length.
- if (outLen % 2 == 1 && outLen > 1)
- {
- outSig[ik] = highSig[hk] + outSig[ik - outStep];
- }
- }
-
- /// Returns true if the wavelet filter computes or uses the same "inner"
- /// subband coefficient as the full frame wavelet transform, and false
- /// otherwise. In particular, for block based transforms with reduced
- /// overlap, this method should return false. The term "inner" indicates
- /// that this applies only with respect to the coefficient that are not
- /// affected by image boundaries processings such as symmetric extension,
- /// since there is not reference method for this.
- ///
- /// The result depends on the length of the allowed overlap when
- /// compared to the overlap required by the wavelet filter. It also depends
- /// on how overlap processing is implemented in the wavelet filter.
- ///
- ///
- /// This is the number of samples in the input signal
- /// before the first sample to filter that can be used for overlap.
- ///
- ///
- /// This is the number of samples in the input signal
- /// after the last sample to filter that can be used for overlap.
- ///
- ///
- /// This is the lenght of the input signal to filter.The
- /// required number of samples in the input signal after the last sample
- /// depends on the length of the input signal.
- ///
- ///
- /// true if both overlaps are greater than 2, and correct
- /// processing is applied in the analyze() method.
- ///
- ///
- public override bool isSameAsFullWT(int tailOvrlp, int headOvrlp, int inLen)
- {
-
- //If the input signal has even length.
- if (inLen % 2 == 0)
- {
- if (tailOvrlp >= 2 && headOvrlp >= 1)
- return true;
- else
- return false;
- }
- //Else if the input signal has odd length.
- else
- {
- if (tailOvrlp >= 2 && headOvrlp >= 2)
- return true;
- else
- return false;
- }
- }
-
- /// Returns a string of information about the synthesis wavelet filter
- ///
- ///
- /// wavelet filter type.
- ///
- ///
- public override System.String ToString()
- {
- return "w5x3 (lifting)";
- }
- }
-}
\ No newline at end of file
diff --git a/CSJ2K/j2k/wavelet/synthesis/SynWTFilterSpec.cs b/CSJ2K/j2k/wavelet/synthesis/SynWTFilterSpec.cs
deleted file mode 100644
index b9a6f9c3..00000000
--- a/CSJ2K/j2k/wavelet/synthesis/SynWTFilterSpec.cs
+++ /dev/null
@@ -1,210 +0,0 @@
-/*
-* CVS identifier:
-*
-* $Id: SynWTFilterSpec.java,v 1.15 2001/08/02 10:01:30 grosbois Exp $
-*
-* Class: SynWTFilterSpec
-*
-* Description: Synthesis filters specification
-*
-*
-*
-* COPYRIGHT:
-*
-* This software module was originally developed by Raphaël Grosbois and
-* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-* Centre France S.A) in the course of development of the JPEG2000
-* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-* software module is an implementation of a part of the JPEG 2000
-* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-* Systems AB and Canon Research Centre France S.A (collectively JJ2000
-* Partners) agree not to assert against ISO/IEC and users of the JPEG
-* 2000 Standard (Users) any of their rights under the copyright, not
-* including other intellectual property rights, for this software module
-* with respect to the usage by ISO/IEC and Users of this software module
-* or modifications thereof for use in hardware or software products
-* claiming conformance to the JPEG 2000 Standard. Those intending to use
-* this software module in hardware or software products are advised that
-* their use may infringe existing patents. The original developers of
-* this software module, JJ2000 Partners and ISO/IEC assume no liability
-* for use of this software module or modifications thereof. No license
-* or right to this software module is granted for non JPEG 2000 Standard
-* conforming products. JJ2000 Partners have full right to use this
-* software module for his/her own purpose, assign or donate this
-* software module to any third party and to inhibit third parties from
-* using this software module for non JPEG 2000 Standard conforming
-* products. This copyright notice must be included in all copies or
-* derivative works of this software module.
-*
-* Copyright (c) 1999/2000 JJ2000 Partners.
-* */
-namespace CSJ2K.j2k.wavelet.synthesis
-{
-
- /// This class extends ModuleSpec class for synthesis filters specification
- /// holding purpose.
- ///
- ///
- ///
- ///
- ///
- public class SynWTFilterSpec : ModuleSpec
- {
-
- /// Constructs a new 'SynWTFilterSpec' for the specified number of
- /// components and tiles.
- ///
- ///
- /// The number of tiles
- ///
- ///
- /// The number of components
- ///
- ///
- /// the type of the specification module i.e. tile specific,
- /// component specific or both.
- ///
- ///
- public SynWTFilterSpec(int nt, int nc, byte type) : base(nt, nc, type)
- {
- }
-
- /// Returns the data type used by the filters in this object, as defined in
- /// the 'DataBlk' interface for specified tile-component.
- ///
- ///
- /// Tile index
- ///
- ///
- /// Component index
- ///
- ///
- /// The data type of the filters in this object
- ///
- ///
- ///
- ///
- ///
- public virtual int getWTDataType(int t, int c)
- {
- SynWTFilter[][] an = (SynWTFilter[][])getSpec(t, c);
- return an[0][0].DataType;
- }
-
- /// Returns the horizontal analysis filters to be used in component 'n' and
- /// tile 't'.
- ///
- /// The horizontal analysis filters are returned in an array of
- /// SynWTFilter. Each element contains the horizontal filter for each
- /// resolution level starting with resolution level 1 (i.e. the analysis
- /// filter to go from resolution level 1 to resolution level 0). If there
- /// are less elements than the maximum resolution level, then the last
- /// element is assumed to be repeated.
- ///
- ///
- /// The tile index, in raster scan order
- ///
- ///
- /// The component index.
- ///
- ///
- /// The array of horizontal analysis filters for component 'n' and
- /// tile 't'.
- ///
- ///
- public virtual SynWTFilter[] getHFilters(int t, int c)
- {
- SynWTFilter[][] an = (SynWTFilter[][])getSpec(t, c);
- return an[0];
- }
-
- /// Returns the vertical analysis filters to be used in component 'n' and
- /// tile 't'.
- ///
- /// The vertical analysis filters are returned in an array of
- /// SynWTFilter. Each element contains the vertical filter for each
- /// resolution level starting with resolution level 1 (i.e. the analysis
- /// filter to go from resolution level 1 to resolution level 0). If there
- /// are less elements than the maximum resolution level, then the last
- /// element is assumed to be repeated.
- ///
- ///
- /// The tile index, in raster scan order
- ///
- ///
- /// The component index.
- ///
- ///
- /// The array of horizontal analysis filters for component 'n' and
- /// tile 't'.
- ///
- ///
- public virtual SynWTFilter[] getVFilters(int t, int c)
- {
- SynWTFilter[][] an = (SynWTFilter[][])getSpec(t, c);
- return an[1];
- }
-
- /// Debugging method
- public override System.String ToString()
- {
- System.String str = "";
- SynWTFilter[][] an;
-
- str += ("nTiles=" + nTiles + "\nnComp=" + nComp + "\n\n");
-
- for (int t = 0; t < nTiles; t++)
- {
- for (int c = 0; c < nComp; c++)
- {
- an = (SynWTFilter[][])getSpec(t, c);
-
- str += ("(t:" + t + ",c:" + c + ")\n");
-
- // Horizontal filters
- str += "\tH:";
- for (int i = 0; i < an[0].Length; i++)
- {
- //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Object.toString' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'"
- str += (" " + an[0][i]);
- }
- // Horizontal filters
- str += "\n\tV:";
- for (int i = 0; i < an[1].Length; i++)
- {
- //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Object.toString' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'"
- str += (" " + an[1][i]);
- }
- str += "\n";
- }
- }
-
- return str;
- }
-
- /// Check the reversibility of filters contained is the given
- /// tile-component.
- ///
- ///
- /// The index of the tile
- ///
- ///
- /// The index of the component
- ///
- ///
- public virtual bool isReversible(int t, int c)
- {
- // Note: no need to buffer the result since this method is normally
- // called once per tile-component.
- SynWTFilter[] hfilter = getHFilters(t, c), vfilter = getVFilters(t, c);
-
- // As soon as a filter is not reversible, false can be returned
- for (int i = hfilter.Length - 1; i >= 0; i--)
- if (!hfilter[i].Reversible || !vfilter[i].Reversible)
- return false;
- return true;
- }
- }
-}
\ No newline at end of file
diff --git a/Directory.Build.props b/Directory.Build.props
index 1c8a703b..e080a9ee 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -1,11 +1,33 @@
-
- 1.1.6
- 1.1.6
- 1.1.6
- $(SolutionDir)\obj\$(Configuration)\$(MSBuildProjectName)\
- $(SolutionDir)\obj\$(Configuration)\$(MSBuildProjectName)\
- $(SolutionDir)\bin\$(Configuration)\$(AssemblyName)\
- $(OutputPath)
-
+
+ OpenMetaverse
+ Utopa Skye LLC, OpenMetaverse Developers
+ Utopia Skye LLC
+ net8.0
+ enable
+ disable
+
+
+
+ all
+ 3.9.50
+
+
+
+ BSD-3-Clause
+ https://github.com/OpenSim-NGC/libopenmetaverse
+ false
+ OMV OpenMetaverse OpenSim Halcyon OpenMetaverseFoundation VirtualWorld VirtualReality 3D SecondLife
+ https://github.com/OpenSim-NGC/libopenmetaverse.git
+ git
+ master
+
+
+
+ true
+ snupkg
+
+ true
+ true
+
diff --git a/LICENSE.txt b/LICENSE.txt
index 43b484b2..426f81ff 100644
--- a/LICENSE.txt
+++ b/LICENSE.txt
@@ -1,4 +1,7 @@
+ Copyright (c) Opensimulator, http://opensimulator.org/
+ All rights reserved.
+
Copyright (c) 2006-2016, openmetaverse.co
All rights reserved.
diff --git a/OpenMetaverse.GUI/AvatarList.cs b/OpenMetaverse.GUI/AvatarList.cs
index 0276b7c0..6423d0c1 100644
--- a/OpenMetaverse.GUI/AvatarList.cs
+++ b/OpenMetaverse.GUI/AvatarList.cs
@@ -97,10 +97,10 @@ public AvatarList()
this.ListViewItemSorter = _ColumnSorter;
EventHandler clickHandler = new EventHandler(defaultMenuItem_Click);
- this.ContextMenu = new ContextMenu();
- this.ContextMenu.MenuItems.Add("Offer Teleport", clickHandler);
- this.ContextMenu.MenuItems.Add("Teleport To", clickHandler);
- this.ContextMenu.MenuItems.Add("Walk To", clickHandler);
+ this.ContextMenuStrip = new ContextMenuStrip();
+ this.ContextMenuStrip.Items.Add("Offer Teleport", null, clickHandler);
+ this.ContextMenuStrip.Items.Add("Teleport To", null, clickHandler);
+ this.ContextMenuStrip.Items.Add("Walk To", null, clickHandler);
this.DoubleBuffered = true;
this.ListViewItemSorter = _ColumnSorter;
@@ -360,7 +360,7 @@ private void UpdateCoarseInfo(Simulator sim, List newEntries, List r
private void defaultMenuItem_Click(object sender, EventArgs e)
{
- MenuItem menuItem = (MenuItem)sender;
+ ToolStripItem menuItem = (ToolStripItem)sender;
switch (menuItem.Text)
{
diff --git a/OpenMetaverse.GUI/InventoryTree.cs b/OpenMetaverse.GUI/InventoryTree.cs
index 12e1352d..cf2cc9a9 100644
--- a/OpenMetaverse.GUI/InventoryTree.cs
+++ b/OpenMetaverse.GUI/InventoryTree.cs
@@ -1,226 +1,226 @@
-/*
- * Copyright (c) 2006-2016, openmetaverse.co
- * All rights reserved.
- *
- * - Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * - Redistributions of source code must retain the above copyright notice, this
- * list of conditions and the following disclaimer.
- * - Neither the name of the openmetaverse.co nor the names
- * of its contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * 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.
- */
-
-using System;
-using System.Collections.Generic;
-using System.Drawing;
-using System.Windows.Forms;
-
-namespace OpenMetaverse.GUI
-{
-
- ///
- /// TreeView GUI component for browsing a client's inventory
- ///
- public class InventoryTree : TreeView
- {
- private GridClient _Client;
- private ContextMenu _ContextMenu;
- private UUID _SelectedItemID;
-
- ///
- /// Gets or sets the context menu associated with this control
- ///
- public ContextMenu Menu
- {
- get { return _ContextMenu; }
- set { _ContextMenu = value; }
- }
-
- ///
- /// Gets or sets the GridClient associated with this control
- ///
- public GridClient Client
- {
- get { return _Client; }
- set { if (value != null) InitializeClient(value); }
- }
-
- ///
- /// TreeView control for an unspecified client's inventory
- ///
- public InventoryTree()
- {
- EventHandler clickHandler = new EventHandler(defaultMenuItem_Click);
- _ContextMenu = new ContextMenu();
- _ContextMenu.MenuItems.Add("Wear", clickHandler);
- _ContextMenu.MenuItems.Add("Detach", clickHandler);
-
- this.NodeMouseClick += new TreeNodeMouseClickEventHandler(InventoryTree_NodeMouseClick);
- this.BeforeExpand += new TreeViewCancelEventHandler(InventoryTree_BeforeExpand);
- }
-
- ///
- /// TreeView control for the specified client's inventory
- ///
- ///
- public InventoryTree(GridClient client) : this()
- {
- InitializeClient(client);
- }
-
- ///
- /// Thread-safe method for clearing the TreeView control
- ///
- public void ClearNodes()
- {
- if (this.InvokeRequired) this.BeginInvoke((MethodInvoker)delegate { ClearNodes(); });
- else this.Nodes.Clear();
- }
-
- ///
- /// Thread-safe method for collapsing a TreeNode in the control
- ///
- ///
- public void CollapseNode(TreeNode node)
- {
- if (this.InvokeRequired) this.BeginInvoke((MethodInvoker)delegate { CollapseNode(node); });
- else if (!node.IsExpanded) node.Collapse();
- }
-
- ///
- /// Thread-safe method for expanding a TreeNode in the control
- ///
- ///
- public void ExpandNode(TreeNode node)
- {
- if (this.InvokeRequired) this.BeginInvoke((MethodInvoker)delegate { ExpandNode(node); });
- else if (!node.IsExpanded) node.Expand();
- }
-
- ///
- /// Thread-safe method for updating the contents of the specified folder UUID
- ///
- ///
- public void UpdateFolder(UUID folderID)
- {
- if (this.InvokeRequired) this.BeginInvoke((MethodInvoker)delegate { UpdateFolder(folderID); });
- else
- {
- TreeNode node = null;
- TreeNodeCollection children;
-
- if (folderID != Client.Inventory.Store.RootFolder.UUID)
- {
- TreeNode[] found = Nodes.Find(folderID.ToString(), true);
- if (found.Length > 0)
- {
- node = found[0];
- children = node.Nodes;
- }
- else
- {
- Logger.Log("Received update for unknown TreeView node " + folderID, Helpers.LogLevel.Warning);
- return;
- }
- }
- else children = this.Nodes;
-
- children.Clear();
-
- List contents = Client.Inventory.Store.GetContents(folderID);
- if (contents.Count == 0)
- {
- TreeNode add = children.Add(null, "(empty)");
- add.ForeColor = Color.FromKnownColor(KnownColor.GrayText);
- }
- else
- {
- foreach (InventoryBase inv in contents)
- {
- string key = inv.UUID.ToString();
-
- children.Add(key, inv.Name);
- if (inv is InventoryFolder)
- {
- children[key].Nodes.Add(null, "(loading...)").ForeColor = Color.FromKnownColor(KnownColor.GrayText);
- }
- }
- }
- }
- }
-
- private void InitializeClient(GridClient client)
- {
- _Client = client;
- _Client.Inventory.FolderUpdated += Inventory_OnFolderUpdated;
- _Client.Network.LoginProgress += Network_OnLogin;
- }
-
- private void defaultMenuItem_Click(object sender, EventArgs e)
- {
- MenuItem menuItem = (MenuItem)sender;
-
- InventoryItem item = (InventoryItem)Client.Inventory.Store[_SelectedItemID];
-
- switch (menuItem.Text)
- {
- case "Wear":
- {
- Client.Appearance.Attach(item, AttachmentPoint.Default);
- break;
- }
- case "Detach":
- {
- Client.Appearance.Detach(item);
- break;
- }
- }
- }
-
- void Network_OnLogin(object sender, LoginProgressEventArgs e)
- {
- if (e.Status == LoginStatus.Success)
- {
- if (Client.Inventory.Store != null)
- UpdateFolder(Client.Inventory.Store.RootFolder.UUID);
- }
- }
-
- private void Inventory_OnFolderUpdated(object sender, FolderUpdatedEventArgs e)
- {
- UpdateFolder(e.FolderID);
- }
-
- void InventoryTree_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
- {
- if (e.Button == MouseButtons.Right)
- {
- _SelectedItemID = new UUID(e.Node.Name);
- _ContextMenu.Show(this, e.Location);
- }
- }
-
- private void InventoryTree_BeforeExpand(object sender, TreeViewCancelEventArgs e)
- {
- InventoryFolder folder = (InventoryFolder)Client.Inventory.Store[new UUID(e.Node.Name)];
- Client.Inventory.RequestFolderContents(folder.UUID, _Client.Self.AgentID, true, true, InventorySortOrder.ByDate | InventorySortOrder.FoldersByName);
- }
-
- }
-
-}
-
+/*
+ * Copyright (c) 2006-2016, openmetaverse.co
+ * All rights reserved.
+ *
+ * - Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ * - Neither the name of the openmetaverse.co nor the names
+ * of its contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * 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.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Drawing;
+using System.Windows.Forms;
+
+namespace OpenMetaverse.GUI
+{
+
+ ///
+ /// TreeView GUI component for browsing a client's inventory
+ ///
+ public class InventoryTree : TreeView
+ {
+ private GridClient _Client;
+ private ContextMenuStrip _ContextMenu;
+ private UUID _SelectedItemID;
+
+ ///
+ /// Gets or sets the context menu associated with this control
+ ///
+ public ContextMenuStrip Menu
+ {
+ get { return _ContextMenu; }
+ set { _ContextMenu = value; }
+ }
+
+ ///
+ /// Gets or sets the GridClient associated with this control
+ ///
+ public GridClient Client
+ {
+ get { return _Client; }
+ set { if (value != null) InitializeClient(value); }
+ }
+
+ ///
+ /// TreeView control for an unspecified client's inventory
+ ///
+ public InventoryTree()
+ {
+ EventHandler clickHandler = new EventHandler(defaultMenuItem_Click);
+ _ContextMenu = new ContextMenuStrip();
+ _ContextMenu.Items.Add("Wear", null, clickHandler);
+ _ContextMenu.Items.Add("Detach", null, clickHandler);
+
+ this.NodeMouseClick += new TreeNodeMouseClickEventHandler(InventoryTree_NodeMouseClick);
+ this.BeforeExpand += new TreeViewCancelEventHandler(InventoryTree_BeforeExpand);
+ }
+
+ ///
+ /// TreeView control for the specified client's inventory
+ ///
+ ///
+ public InventoryTree(GridClient client) : this ()
+ {
+ InitializeClient(client);
+ }
+
+ ///
+ /// Thread-safe method for clearing the TreeView control
+ ///
+ public void ClearNodes()
+ {
+ if (this.InvokeRequired) this.BeginInvoke((MethodInvoker)delegate { ClearNodes(); });
+ else this.Nodes.Clear();
+ }
+
+ ///
+ /// Thread-safe method for collapsing a TreeNode in the control
+ ///
+ ///
+ public void CollapseNode(TreeNode node)
+ {
+ if (this.InvokeRequired) this.BeginInvoke((MethodInvoker)delegate { CollapseNode(node); });
+ else if (!node.IsExpanded) node.Collapse();
+ }
+
+ ///
+ /// Thread-safe method for expanding a TreeNode in the control
+ ///
+ ///
+ public void ExpandNode(TreeNode node)
+ {
+ if (this.InvokeRequired) this.BeginInvoke((MethodInvoker)delegate { ExpandNode(node); });
+ else if (!node.IsExpanded) node.Expand();
+ }
+
+ ///
+ /// Thread-safe method for updating the contents of the specified folder UUID
+ ///
+ ///
+ public void UpdateFolder(UUID folderID)
+ {
+ if (this.InvokeRequired) this.BeginInvoke((MethodInvoker)delegate { UpdateFolder(folderID); });
+ else
+ {
+ TreeNode node = null;
+ TreeNodeCollection children;
+
+ if (folderID != Client.Inventory.Store.RootFolder.UUID)
+ {
+ TreeNode[] found = Nodes.Find(folderID.ToString(), true);
+ if (found.Length > 0)
+ {
+ node = found[0];
+ children = node.Nodes;
+ }
+ else
+ {
+ Logger.Log("Received update for unknown TreeView node " + folderID, Helpers.LogLevel.Warning);
+ return;
+ }
+ }
+ else children = this.Nodes;
+
+ children.Clear();
+
+ List contents = Client.Inventory.Store.GetContents(folderID);
+ if (contents.Count == 0)
+ {
+ TreeNode add = children.Add(null, "(empty)");
+ add.ForeColor = Color.FromKnownColor(KnownColor.GrayText);
+ }
+ else
+ {
+ foreach (InventoryBase inv in contents)
+ {
+ string key = inv.UUID.ToString();
+
+ children.Add(key, inv.Name);
+ if (inv is InventoryFolder)
+ {
+ children[key].Nodes.Add(null, "(loading...)").ForeColor = Color.FromKnownColor(KnownColor.GrayText);
+ }
+ }
+ }
+ }
+ }
+
+ private void InitializeClient(GridClient client)
+ {
+ _Client = client;
+ _Client.Inventory.FolderUpdated += Inventory_OnFolderUpdated;
+ _Client.Network.LoginProgress += Network_OnLogin;
+ }
+
+ private void defaultMenuItem_Click(object sender, EventArgs e)
+ {
+ ToolStripItem menuItem = (ToolStripItem)sender;
+
+ InventoryItem item = (InventoryItem)Client.Inventory.Store[_SelectedItemID];
+
+ switch(menuItem.Text)
+ {
+ case "Wear":
+ {
+ Client.Appearance.Attach(item, AttachmentPoint.Default);
+ break;
+ }
+ case "Detach":
+ {
+ Client.Appearance.Detach(item);
+ break;
+ }
+ }
+ }
+
+ void Network_OnLogin(object sender, LoginProgressEventArgs e)
+ {
+ if (e.Status == LoginStatus.Success)
+ {
+ if (Client.Inventory.Store != null)
+ UpdateFolder(Client.Inventory.Store.RootFolder.UUID);
+ }
+ }
+
+ private void Inventory_OnFolderUpdated(object sender, FolderUpdatedEventArgs e)
+ {
+ UpdateFolder(e.FolderID);
+ }
+
+ void InventoryTree_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
+ {
+ if (e.Button == MouseButtons.Right)
+ {
+ _SelectedItemID = new UUID(e.Node.Name);
+ _ContextMenu.Show(this, e.Location);
+ }
+ }
+
+ private void InventoryTree_BeforeExpand(object sender, TreeViewCancelEventArgs e)
+ {
+ InventoryFolder folder = (InventoryFolder)Client.Inventory.Store[new UUID(e.Node.Name)];
+ Client.Inventory.RequestFolderContents(folder.UUID, _Client.Self.AgentID, true, true, InventorySortOrder.ByDate | InventorySortOrder.FoldersByName);
+ }
+
+ }
+
+}
+
diff --git a/OpenMetaverse.GUI/MiniMap.cs b/OpenMetaverse.GUI/MiniMap.cs
index 5f7b628d..9f9d129f 100644
--- a/OpenMetaverse.GUI/MiniMap.cs
+++ b/OpenMetaverse.GUI/MiniMap.cs
@@ -28,7 +28,9 @@
using OpenMetaverse.Imaging;
using System.Collections.Generic;
using System.Drawing;
+using System.IO;
using System.Windows.Forms;
+using SkiaSharp;
namespace OpenMetaverse.GUI
{
@@ -216,10 +218,23 @@ void Network_OnCurrentSimChanged(object sender, SimChangedEventArgs e)
delegate (TextureRequestState state, AssetTexture asset)
{
if (state == TextureRequestState.Finished)
- OpenJPEG.DecodeToImage(asset.AssetData, out nullImage, out _MapLayer);
+ {
+ SKBitmap skMapLayer;
+ OpenJPEG.DecodeToImage(asset.AssetData, out nullImage, out skMapLayer);
+ _MapLayer = skMapLayer != null ? ConvertToBitmap(skMapLayer) : null;
+ }
});
}
}
+ private static Bitmap ConvertToBitmap(SKBitmap skBitmap)
+ {
+ using SKImage image = SKImage.FromBitmap(skBitmap);
+ using SKData data = image.Encode(SKEncodedImageFormat.Png, 100);
+ using MemoryStream stream = new MemoryStream(data.ToArray());
+ using Bitmap tmp = new Bitmap(stream);
+ return new Bitmap(tmp);
+ }
+
}
}
diff --git a/OpenMetaverse.GUI/OpenMetaverse.GUI.csproj b/OpenMetaverse.GUI/OpenMetaverse.GUI.csproj
index 5f61070c..13728e9e 100644
--- a/OpenMetaverse.GUI/OpenMetaverse.GUI.csproj
+++ b/OpenMetaverse.GUI/OpenMetaverse.GUI.csproj
@@ -1,12 +1,14 @@

Local
- net48
- 1591,1574,0419,0618
+ Library
True
+ net8.0-windows
+ true
+ true
-
+
@@ -17,15 +19,4 @@
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/OpenMetaverse.PrimMesher/OpenMetaverse.PrimMesher.csproj b/OpenMetaverse.PrimMesher/OpenMetaverse.PrimMesher.csproj
deleted file mode 100644
index b18c3b3a..00000000
--- a/OpenMetaverse.PrimMesher/OpenMetaverse.PrimMesher.csproj
+++ /dev/null
@@ -1,20 +0,0 @@
-
-
- net48
- Dhalia Trimble, OpenSim Contributors, Cinder Roxley
- OpenMetaverse.PrimMesher
- OpenMetaverse.PrimMesher
- true
-
-
- full
- TRACE;DEBUG;VERTEX_INDEXER
-
-
- pdbonly
- TRACE;VERTEX_INDEXER
-
-
-
-
-
\ No newline at end of file
diff --git a/OpenMetaverse.PrimMesher/PrimMesher.cs b/OpenMetaverse.PrimMesher/PrimMesher.cs
deleted file mode 100644
index f5a5490e..00000000
--- a/OpenMetaverse.PrimMesher/PrimMesher.cs
+++ /dev/null
@@ -1,2327 +0,0 @@
-/*
- * Copyright (c) Contributors
- * See CONTRIBUTORS.TXT for a full list of copyright holders.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * 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.
- * * Neither the name of the OpenSimulator Project nor the
- * names of its contributors may be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``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 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.
- */
-
-using System;
-using System.Collections.Generic;
-using System.IO;
-
-namespace OpenMetaverse.PrimMesher
-{
- public struct Quat
- {
- /// X value
- public float X;
-
- /// Y value
- public float Y;
-
- /// Z value
- public float Z;
-
- /// W value
- public float W;
-
- public Quat(float x, float y, float z, float w)
- {
- X = x;
- Y = y;
- Z = z;
- W = w;
- }
-
- public Quat(Coord axis, float angle)
- {
- axis = axis.Normalize();
-
- angle *= 0.5f;
- var c = (float) Math.Cos(angle);
- var s = (float) Math.Sin(angle);
-
- X = axis.X * s;
- Y = axis.Y * s;
- Z = axis.Z * s;
- W = c;
-
- Normalize();
- }
-
- public float Length()
- {
- return (float) Math.Sqrt(X * X + Y * Y + Z * Z + W * W);
- }
-
- public Quat Normalize()
- {
- const float MAG_THRESHOLD = 0.0000001f;
- var mag = Length();
-
- // Catch very small rounding errors when normalizing
- if (mag > MAG_THRESHOLD)
- {
- var oomag = 1f / mag;
- X *= oomag;
- Y *= oomag;
- Z *= oomag;
- W *= oomag;
- }
- else
- {
- X = 0f;
- Y = 0f;
- Z = 0f;
- W = 1f;
- }
-
- return this;
- }
-
- public static Quat operator *(Quat q1, Quat q2)
- {
- var x = q1.W * q2.X + q1.X * q2.W + q1.Y * q2.Z - q1.Z * q2.Y;
- var y = q1.W * q2.Y - q1.X * q2.Z + q1.Y * q2.W + q1.Z * q2.X;
- var z = q1.W * q2.Z + q1.X * q2.Y - q1.Y * q2.X + q1.Z * q2.W;
- var w = q1.W * q2.W - q1.X * q2.X - q1.Y * q2.Y - q1.Z * q2.Z;
- return new Quat(x, y, z, w);
- }
-
- public override string ToString()
- {
- return "< X: " + X + ", Y: " + Y + ", Z: " + Z + ", W: " + W + ">";
- }
- }
-
- public struct Coord
- {
- public float X;
- public float Y;
- public float Z;
-
- public Coord(float x, float y, float z)
- {
- X = x;
- Y = y;
- Z = z;
- }
-
- public float Length()
- {
- return (float) Math.Sqrt(X * X + Y * Y + Z * Z);
- }
-
- public Coord Invert()
- {
- X = -X;
- Y = -Y;
- Z = -Z;
-
- return this;
- }
-
- public Coord Normalize()
- {
- const float MAG_THRESHOLD = 0.0000001f;
- var mag = Length();
-
- // Catch very small rounding errors when normalizing
- if (mag > MAG_THRESHOLD)
- {
- var oomag = 1.0f / mag;
- X *= oomag;
- Y *= oomag;
- Z *= oomag;
- }
- else
- {
- X = 0.0f;
- Y = 0.0f;
- Z = 0.0f;
- }
-
- return this;
- }
-
- public override string ToString()
- {
- return X + " " + Y + " " + Z;
- }
-
- public static Coord Cross(Coord c1, Coord c2)
- {
- return new Coord(
- c1.Y * c2.Z - c2.Y * c1.Z,
- c1.Z * c2.X - c2.Z * c1.X,
- c1.X * c2.Y - c2.X * c1.Y
- );
- }
-
- public static Coord operator +(Coord v, Coord a)
- {
- return new Coord(v.X + a.X, v.Y + a.Y, v.Z + a.Z);
- }
-
- public static Coord operator *(Coord v, Coord m)
- {
- return new Coord(v.X * m.X, v.Y * m.Y, v.Z * m.Z);
- }
-
- public static Coord operator *(Coord v, Quat q)
- {
- // From http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/transforms/
-
- var c2 = new Coord(0.0f, 0.0f, 0.0f);
-
- c2.X = q.W * q.W * v.X +
- 2f * q.Y * q.W * v.Z -
- 2f * q.Z * q.W * v.Y +
- q.X * q.X * v.X +
- 2f * q.Y * q.X * v.Y +
- 2f * q.Z * q.X * v.Z -
- q.Z * q.Z * v.X -
- q.Y * q.Y * v.X;
-
- c2.Y =
- 2f * q.X * q.Y * v.X +
- q.Y * q.Y * v.Y +
- 2f * q.Z * q.Y * v.Z +
- 2f * q.W * q.Z * v.X -
- q.Z * q.Z * v.Y +
- q.W * q.W * v.Y -
- 2f * q.X * q.W * v.Z -
- q.X * q.X * v.Y;
-
- c2.Z =
- 2f * q.X * q.Z * v.X +
- 2f * q.Y * q.Z * v.Y +
- q.Z * q.Z * v.Z -
- 2f * q.W * q.Y * v.X -
- q.Y * q.Y * v.Z +
- 2f * q.W * q.X * v.Y -
- q.X * q.X * v.Z +
- q.W * q.W * v.Z;
-
- return c2;
- }
- }
-
- public struct UVCoord
- {
- public float U;
- public float V;
-
-
- public UVCoord(float u, float v)
- {
- U = u;
- V = v;
- }
-
- public UVCoord Flip()
- {
- U = 1.0f - U;
- V = 1.0f - V;
- return this;
- }
- }
-
- public struct Face
- {
- public int primFace;
-
- // vertices
- public int v1;
-
- public int v2;
- public int v3;
-
- //normals
- public int n1;
-
- public int n2;
- public int n3;
-
- // uvs
- public int uv1;
-
- public int uv2;
- public int uv3;
-
- public Face(int v1, int v2, int v3)
- {
- primFace = 0;
-
- this.v1 = v1;
- this.v2 = v2;
- this.v3 = v3;
-
- n1 = 0;
- n2 = 0;
- n3 = 0;
-
- uv1 = 0;
- uv2 = 0;
- uv3 = 0;
- }
-
- public Face(int v1, int v2, int v3, int n1, int n2, int n3)
- {
- primFace = 0;
-
- this.v1 = v1;
- this.v2 = v2;
- this.v3 = v3;
-
- this.n1 = n1;
- this.n2 = n2;
- this.n3 = n3;
-
- uv1 = 0;
- uv2 = 0;
- uv3 = 0;
- }
-
- public Coord SurfaceNormal(List coordList)
- {
- var c1 = coordList[v1];
- var c2 = coordList[v2];
- var c3 = coordList[v3];
-
- var edge1 = new Coord(c2.X - c1.X, c2.Y - c1.Y, c2.Z - c1.Z);
- var edge2 = new Coord(c3.X - c1.X, c3.Y - c1.Y, c3.Z - c1.Z);
-
- return Coord.Cross(edge1, edge2).Normalize();
- }
- }
-
- public struct ViewerFace
- {
- public int primFaceNumber;
-
- public Coord v1;
- public Coord v2;
- public Coord v3;
-
- public int coordIndex1;
- public int coordIndex2;
- public int coordIndex3;
-
- public Coord n1;
- public Coord n2;
- public Coord n3;
-
- public UVCoord uv1;
- public UVCoord uv2;
- public UVCoord uv3;
-
- public ViewerFace(int primFaceNumber)
- {
- this.primFaceNumber = primFaceNumber;
-
- v1 = new Coord();
- v2 = new Coord();
- v3 = new Coord();
-
- coordIndex1 = coordIndex2 = coordIndex3 = -1; // -1 means not assigned yet
-
- n1 = new Coord();
- n2 = new Coord();
- n3 = new Coord();
-
- uv1 = new UVCoord();
- uv2 = new UVCoord();
- uv3 = new UVCoord();
- }
-
- public void Scale(float x, float y, float z)
- {
- v1.X *= x;
- v1.Y *= y;
- v1.Z *= z;
-
- v2.X *= x;
- v2.Y *= y;
- v2.Z *= z;
-
- v3.X *= x;
- v3.Y *= y;
- v3.Z *= z;
- }
-
- public void AddPos(float x, float y, float z)
- {
- v1.X += x;
- v2.X += x;
- v3.X += x;
-
- v1.Y += y;
- v2.Y += y;
- v3.Y += y;
-
- v1.Z += z;
- v2.Z += z;
- v3.Z += z;
- }
-
- public void AddRot(Quat q)
- {
- v1 *= q;
- v2 *= q;
- v3 *= q;
-
- n1 *= q;
- n2 *= q;
- n3 *= q;
- }
-
- public void CalcSurfaceNormal()
- {
- var edge1 = new Coord(v2.X - v1.X, v2.Y - v1.Y, v2.Z - v1.Z);
- var edge2 = new Coord(v3.X - v1.X, v3.Y - v1.Y, v3.Z - v1.Z);
-
- n1 = n2 = n3 = Coord.Cross(edge1, edge2).Normalize();
- }
- }
-
- internal struct Angle
- {
- internal float angle;
- internal float X;
- internal float Y;
-
- internal Angle(float angle, float x, float y)
- {
- this.angle = angle;
- X = x;
- Y = y;
- }
- }
-
- internal class AngleList
- {
- private static readonly Angle[] angles3 =
- {
- new Angle(0.0f, 1.0f, 0.0f),
- new Angle(0.33333333333333333f, -0.5f, 0.86602540378443871f),
- new Angle(0.66666666666666667f, -0.5f, -0.86602540378443837f),
- new Angle(1.0f, 1.0f, 0.0f)
- };
-
- private static readonly Coord[] normals3 =
- {
- new Coord(0.25f, 0.4330127019f, 0.0f).Normalize(),
- new Coord(-0.5f, 0.0f, 0.0f).Normalize(),
- new Coord(0.25f, -0.4330127019f, 0.0f).Normalize(),
- new Coord(0.25f, 0.4330127019f, 0.0f).Normalize()
- };
-
- private static readonly Angle[] angles4 =
- {
- new Angle(0.0f, 1.0f, 0.0f),
- new Angle(0.25f, 0.0f, 1.0f),
- new Angle(0.5f, -1.0f, 0.0f),
- new Angle(0.75f, 0.0f, -1.0f),
- new Angle(1.0f, 1.0f, 0.0f)
- };
-
- private static readonly Coord[] normals4 =
- {
- new Coord(0.5f, 0.5f, 0.0f).Normalize(),
- new Coord(-0.5f, 0.5f, 0.0f).Normalize(),
- new Coord(-0.5f, -0.5f, 0.0f).Normalize(),
- new Coord(0.5f, -0.5f, 0.0f).Normalize(),
- new Coord(0.5f, 0.5f, 0.0f).Normalize()
- };
-
- private static readonly Angle[] angles24 =
- {
- new Angle(0.0f, 1.0f, 0.0f),
- new Angle(0.041666666666666664f, 0.96592582628906831f, 0.25881904510252074f),
- new Angle(0.083333333333333329f, 0.86602540378443871f, 0.5f),
- new Angle(0.125f, 0.70710678118654757f, 0.70710678118654746f),
- new Angle(0.16666666666666667f, 0.5f, 0.8660254037844386f),
- new Angle(0.20833333333333331f, 0.25881904510252096f, 0.9659258262890682f),
- new Angle(0.25f, 0.0f, 1.0f),
- new Angle(0.29166666666666663f, -0.25881904510252063f, 0.96592582628906831f),
- new Angle(0.33333333333333333f, -0.5f, 0.86602540378443871f),
- new Angle(0.375f, -0.70710678118654746f, 0.70710678118654757f),
- new Angle(0.41666666666666663f, -0.86602540378443849f, 0.5f),
- new Angle(0.45833333333333331f, -0.9659258262890682f, 0.25881904510252102f),
- new Angle(0.5f, -1.0f, 0.0f),
- new Angle(0.54166666666666663f, -0.96592582628906842f, -0.25881904510252035f),
- new Angle(0.58333333333333326f, -0.86602540378443882f, -0.5f),
- new Angle(0.62499999999999989f, -0.70710678118654791f, -0.70710678118654713f),
- new Angle(0.66666666666666667f, -0.5f, -0.86602540378443837f),
- new Angle(0.70833333333333326f, -0.25881904510252152f, -0.96592582628906809f),
- new Angle(0.75f, 0.0f, -1.0f),
- new Angle(0.79166666666666663f, 0.2588190451025203f, -0.96592582628906842f),
- new Angle(0.83333333333333326f, 0.5f, -0.86602540378443904f),
- new Angle(0.875f, 0.70710678118654735f, -0.70710678118654768f),
- new Angle(0.91666666666666663f, 0.86602540378443837f, -0.5f),
- new Angle(0.95833333333333326f, 0.96592582628906809f, -0.25881904510252157f),
- new Angle(1.0f, 1.0f, 0.0f)
- };
-
- internal List angles;
- private float iX, iY; // intersection point
- internal List normals;
-
- private Angle interpolatePoints(float newPoint, Angle p1, Angle p2)
- {
- var m = (newPoint - p1.angle) / (p2.angle - p1.angle);
- return new Angle(newPoint, p1.X + m * (p2.X - p1.X), p1.Y + m * (p2.Y - p1.Y));
- }
-
- private void intersection(double x1, double y1, double x2, double y2, double x3, double y3, double x4,
- double y4)
- {
- // ref: http://local.wasp.uwa.edu.au/~pbourke/geometry/lineline2d/
- var denom = (y4 - y3) * (x2 - x1) - (x4 - x3) * (y2 - y1);
- var uaNumerator = (x4 - x3) * (y1 - y3) - (y4 - y3) * (x1 - x3);
-
- if (denom != 0.0)
- {
- var ua = uaNumerator / denom;
- iX = (float) (x1 + ua * (x2 - x1));
- iY = (float) (y1 + ua * (y2 - y1));
- }
- }
-
- internal void makeAngles(int sides, float startAngle, float stopAngle)
- {
- angles = new List();
- normals = new List();
-
- var twoPi = Math.PI * 2.0;
- var twoPiInv = 1.0f / (float) twoPi;
-
- if (sides < 1)
- throw new Exception("number of sides not greater than zero");
- if (stopAngle <= startAngle)
- throw new Exception("stopAngle not greater than startAngle");
-
- if (sides == 3 || sides == 4 || sides == 24)
- {
- startAngle *= twoPiInv;
- stopAngle *= twoPiInv;
-
- Angle[] sourceAngles;
- if (sides == 3)
- sourceAngles = angles3;
- else if (sides == 4)
- sourceAngles = angles4;
- else sourceAngles = angles24;
-
- var startAngleIndex = (int) (startAngle * sides);
- var endAngleIndex = sourceAngles.Length - 1;
- if (stopAngle < 1.0f)
- endAngleIndex = (int) (stopAngle * sides) + 1;
- if (endAngleIndex == startAngleIndex)
- endAngleIndex++;
-
- for (var angleIndex = startAngleIndex; angleIndex < endAngleIndex + 1; angleIndex++)
- {
- angles.Add(sourceAngles[angleIndex]);
- if (sides == 3)
- normals.Add(normals3[angleIndex]);
- else if (sides == 4)
- normals.Add(normals4[angleIndex]);
- }
-
- if (startAngle > 0.0f)
- angles[0] = interpolatePoints(startAngle, angles[0], angles[1]);
-
- if (stopAngle < 1.0f)
- {
- var lastAngleIndex = angles.Count - 1;
- angles[lastAngleIndex] =
- interpolatePoints(stopAngle, angles[lastAngleIndex - 1], angles[lastAngleIndex]);
- }
- }
- else
- {
- var stepSize = twoPi / sides;
-
- var startStep = (int) (startAngle / stepSize);
- var angle = stepSize * startStep;
- var step = startStep;
- double stopAngleTest = stopAngle;
- if (stopAngle < twoPi)
- {
- stopAngleTest = stepSize * ((int) (stopAngle / stepSize) + 1);
- if (stopAngleTest < stopAngle)
- stopAngleTest += stepSize;
- if (stopAngleTest > twoPi)
- stopAngleTest = twoPi;
- }
-
- while (angle <= stopAngleTest)
- {
- Angle newAngle;
- newAngle.angle = (float) angle;
- newAngle.X = (float) Math.Cos(angle);
- newAngle.Y = (float) Math.Sin(angle);
- angles.Add(newAngle);
- step += 1;
- angle = stepSize * step;
- }
-
- if (startAngle > angles[0].angle)
- {
- Angle newAngle;
- intersection(angles[0].X, angles[0].Y, angles[1].X, angles[1].Y, 0.0f, 0.0f,
- (float) Math.Cos(startAngle), (float) Math.Sin(startAngle));
- newAngle.angle = startAngle;
- newAngle.X = iX;
- newAngle.Y = iY;
- angles[0] = newAngle;
- }
-
- var index = angles.Count - 1;
- if (stopAngle < angles[index].angle)
- {
- Angle newAngle;
- intersection(angles[index - 1].X, angles[index - 1].Y, angles[index].X, angles[index].Y, 0.0f, 0.0f,
- (float) Math.Cos(stopAngle), (float) Math.Sin(stopAngle));
- newAngle.angle = stopAngle;
- newAngle.X = iX;
- newAngle.Y = iY;
- angles[index] = newAngle;
- }
- }
- }
- }
-
- ///
- /// generates a profile for extrusion
- ///
- public class Profile
- {
- private const float twoPi = 2.0f * (float) Math.PI;
- public int bottomFaceNumber;
-
- public bool calcVertexNormals;
-
- public List coords;
- public List cut1CoordIndices;
- public List cut2CoordIndices;
- public Coord cutNormal1;
- public Coord cutNormal2;
-
- public string errorMessage;
-
- public Coord faceNormal = new Coord(0.0f, 0.0f, 1.0f);
- public List faceNumbers;
- public List faces;
- public List faceUVs;
- public List hollowCoordIndices;
- public int hollowFaceNumber = -1;
- public int numHollowVerts;
-
- public int numOuterVerts;
- public int numPrimFaces;
-
- // use these for making individual meshes for each prim face
- public List outerCoordIndices;
-
- public int outerFaceNumber = -1;
- public List us;
- public List vertexNormals;
-
- public Profile()
- {
- coords = new List();
- faces = new List();
- vertexNormals = new List();
- us = new List();
- faceUVs = new List();
- faceNumbers = new List();
- }
-
- public Profile(int sides, float profileStart, float profileEnd, float hollow, int hollowSides, bool createFaces,
- bool calcVertexNormals)
- {
- this.calcVertexNormals = calcVertexNormals;
- coords = new List();
- faces = new List();
- vertexNormals = new List();
- us = new List();
- faceUVs = new List();
- faceNumbers = new List();
-
- var center = new Coord(0.0f, 0.0f, 0.0f);
-
- var hollowCoords = new List();
- var hollowNormals = new List();
- var hollowUs = new List();
-
- if (calcVertexNormals)
- {
- outerCoordIndices = new List();
- hollowCoordIndices = new List();
- cut1CoordIndices = new List();
- cut2CoordIndices = new List();
- }
-
- var hasHollow = hollow > 0.0f;
-
- var hasProfileCut = profileStart > 0.0f || profileEnd < 1.0f;
-
- var angles = new AngleList();
- var hollowAngles = new AngleList();
-
- var xScale = 0.5f;
- var yScale = 0.5f;
- if (sides == 4) // corners of a square are sqrt(2) from center
- {
- xScale = 0.707107f;
- yScale = 0.707107f;
- }
-
- var startAngle = profileStart * twoPi;
- var stopAngle = profileEnd * twoPi;
-
- try
- {
- angles.makeAngles(sides, startAngle, stopAngle);
- }
- catch (Exception ex)
- {
- errorMessage = "makeAngles failed: Exception: " + ex
- + "\nsides: " + sides + " startAngle: " + startAngle + " stopAngle: " + stopAngle;
-
- return;
- }
-
- numOuterVerts = angles.angles.Count;
-
- // flag to create as few triangles as possible for 3 or 4 side profile
- var simpleFace = sides < 5 && !hasHollow && !hasProfileCut;
-
- if (hasHollow)
- {
- if (sides == hollowSides)
- hollowAngles = angles;
- else
- try
- {
- hollowAngles.makeAngles(hollowSides, startAngle, stopAngle);
- }
- catch (Exception ex)
- {
- errorMessage = "makeAngles failed: Exception: " + ex
- + "\nsides: " + sides + " startAngle: " + startAngle + " stopAngle: " +
- stopAngle;
-
- return;
- }
- numHollowVerts = hollowAngles.angles.Count;
- }
- else if (!simpleFace)
- {
- coords.Add(center);
- if (this.calcVertexNormals)
- vertexNormals.Add(new Coord(0.0f, 0.0f, 1.0f));
- us.Add(0.0f);
- }
-
- var z = 0.0f;
-
- Angle angle;
- var newVert = new Coord();
- if (hasHollow && hollowSides != sides)
- {
- var numHollowAngles = hollowAngles.angles.Count;
- for (var i = 0; i < numHollowAngles; i++)
- {
- angle = hollowAngles.angles[i];
- newVert.X = hollow * xScale * angle.X;
- newVert.Y = hollow * yScale * angle.Y;
- newVert.Z = z;
-
- hollowCoords.Add(newVert);
- if (this.calcVertexNormals)
- {
- hollowNormals.Add(hollowSides < 5
- ? hollowAngles.normals[i].Invert()
- : new Coord(-angle.X, -angle.Y, 0.0f));
-
- if (hollowSides == 4)
- hollowUs.Add(angle.angle * hollow * 0.707107f);
- else
- hollowUs.Add(angle.angle * hollow);
- }
- }
- }
-
- var index = 0;
- var numAngles = angles.angles.Count;
-
- for (var i = 0; i < numAngles; i++)
- {
- angle = angles.angles[i];
- newVert.X = angle.X * xScale;
- newVert.Y = angle.Y * yScale;
- newVert.Z = z;
- coords.Add(newVert);
- if (this.calcVertexNormals)
- {
- outerCoordIndices.Add(coords.Count - 1);
-
- if (sides < 5)
- {
- vertexNormals.Add(angles.normals[i]);
- var u = angle.angle;
- us.Add(u);
- }
- else
- {
- vertexNormals.Add(new Coord(angle.X, angle.Y, 0.0f));
- us.Add(angle.angle);
- }
- }
-
- if (hasHollow)
- {
- if (hollowSides == sides)
- {
- newVert.X *= hollow;
- newVert.Y *= hollow;
- newVert.Z = z;
- hollowCoords.Add(newVert);
- if (this.calcVertexNormals)
- {
- hollowNormals.Add(sides < 5
- ? angles.normals[i].Invert()
- : new Coord(-angle.X, -angle.Y, 0.0f));
-
- hollowUs.Add(angle.angle * hollow);
- }
- }
- }
- else if (!simpleFace && createFaces && angle.angle > 0.0001f)
- {
- var newFace = new Face
- {
- v1 = 0,
- v2 = index,
- v3 = index + 1
- };
-
- faces.Add(newFace);
- }
- index += 1;
- }
-
- if (hasHollow)
- {
- hollowCoords.Reverse();
- if (this.calcVertexNormals)
- {
- hollowNormals.Reverse();
- hollowUs.Reverse();
- }
-
- if (createFaces)
- {
- var numTotalVerts = numOuterVerts + numHollowVerts;
-
- if (numOuterVerts == numHollowVerts)
- {
- var newFace = new Face();
-
- for (var coordIndex = 0; coordIndex < numOuterVerts - 1; coordIndex++)
- {
- newFace.v1 = coordIndex;
- newFace.v2 = coordIndex + 1;
- newFace.v3 = numTotalVerts - coordIndex - 1;
- faces.Add(newFace);
-
- newFace.v1 = coordIndex + 1;
- newFace.v2 = numTotalVerts - coordIndex - 2;
- newFace.v3 = numTotalVerts - coordIndex - 1;
- faces.Add(newFace);
- }
- }
- else
- {
- if (numOuterVerts < numHollowVerts)
- {
- var newFace = new Face();
- var j = 0; // j is the index for outer vertices
- var maxJ = numOuterVerts - 1;
- for (var i = 0; i < numHollowVerts; i++) // i is the index for inner vertices
- {
- if (j < maxJ)
- if (angles.angles[j + 1].angle - hollowAngles.angles[i].angle <
- hollowAngles.angles[i].angle - angles.angles[j].angle + 0.000001f)
- {
- newFace.v1 = numTotalVerts - i - 1;
- newFace.v2 = j;
- newFace.v3 = j + 1;
-
- faces.Add(newFace);
- j += 1;
- }
-
- newFace.v1 = j;
- newFace.v2 = numTotalVerts - i - 2;
- newFace.v3 = numTotalVerts - i - 1;
-
- faces.Add(newFace);
- }
- }
- else // numHollowVerts < numOuterVerts
- {
- var newFace = new Face();
- var j = 0; // j is the index for inner vertices
- var maxJ = numHollowVerts - 1;
- for (var i = 0; i < numOuterVerts; i++)
- {
- if (j < maxJ)
- if (hollowAngles.angles[j + 1].angle - angles.angles[i].angle <
- angles.angles[i].angle - hollowAngles.angles[j].angle + 0.000001f)
- {
- newFace.v1 = i;
- newFace.v2 = numTotalVerts - j - 2;
- newFace.v3 = numTotalVerts - j - 1;
-
- faces.Add(newFace);
- j += 1;
- }
-
- newFace.v1 = numTotalVerts - j - 1;
- newFace.v2 = i;
- newFace.v3 = i + 1;
-
- faces.Add(newFace);
- }
- }
- }
- }
-
- if (calcVertexNormals)
- foreach (var hc in hollowCoords)
- {
- coords.Add(hc);
- hollowCoordIndices.Add(coords.Count - 1);
- }
- else
- coords.AddRange(hollowCoords);
-
- if (this.calcVertexNormals)
- {
- vertexNormals.AddRange(hollowNormals);
- us.AddRange(hollowUs);
- }
- }
-
- if (simpleFace && createFaces)
- if (sides == 3)
- {
- faces.Add(new Face(0, 1, 2));
- }
- else if (sides == 4)
- {
- faces.Add(new Face(0, 1, 2));
- faces.Add(new Face(0, 2, 3));
- }
-
- if (calcVertexNormals && hasProfileCut)
- {
- var lastOuterVertIndex = numOuterVerts - 1;
-
- if (hasHollow)
- {
- cut1CoordIndices.Add(0);
- cut1CoordIndices.Add(coords.Count - 1);
-
- cut2CoordIndices.Add(lastOuterVertIndex + 1);
- cut2CoordIndices.Add(lastOuterVertIndex);
-
- cutNormal1.X = coords[0].Y - coords[coords.Count - 1].Y;
- cutNormal1.Y = -(coords[0].X - coords[coords.Count - 1].X);
-
- cutNormal2.X = coords[lastOuterVertIndex + 1].Y - coords[lastOuterVertIndex].Y;
- cutNormal2.Y = -(coords[lastOuterVertIndex + 1].X - coords[lastOuterVertIndex].X);
- }
-
- else
- {
- cut1CoordIndices.Add(0);
- cut1CoordIndices.Add(1);
-
- cut2CoordIndices.Add(lastOuterVertIndex);
- cut2CoordIndices.Add(0);
-
- cutNormal1.X = vertexNormals[1].Y;
- cutNormal1.Y = -vertexNormals[1].X;
-
- cutNormal2.X = -vertexNormals[vertexNormals.Count - 2].Y;
- cutNormal2.Y = vertexNormals[vertexNormals.Count - 2].X;
- }
- cutNormal1.Normalize();
- cutNormal2.Normalize();
- }
-
- MakeFaceUVs();
-
- hollowCoords = null;
- hollowNormals = null;
- hollowUs = null;
-
- if (calcVertexNormals)
- {
- // calculate prim face numbers
-
- // face number order is top, outer, hollow, bottom, start cut, end cut
- // I know it's ugly but so is the whole concept of prim face numbers
-
- var faceNum = 1; // start with outer faces
- outerFaceNumber = faceNum;
-
- var startVert = hasProfileCut && !hasHollow ? 1 : 0;
- if (startVert > 0)
- faceNumbers.Add(-1);
- for (var i = 0; i < numOuterVerts - 1; i++)
- faceNumbers.Add(sides < 5 && i <= sides ? faceNum++ : faceNum);
-
- faceNumbers.Add(hasProfileCut ? -1 : faceNum++);
-
- if (sides > 4 && (hasHollow || hasProfileCut))
- faceNum++;
-
- if (sides < 5 && (hasHollow || hasProfileCut) && numOuterVerts < sides)
- faceNum++;
-
- if (hasHollow)
- {
- for (var i = 0; i < numHollowVerts; i++)
- faceNumbers.Add(faceNum);
-
- hollowFaceNumber = faceNum++;
- }
-
- bottomFaceNumber = faceNum++;
-
- if (hasHollow && hasProfileCut)
- faceNumbers.Add(faceNum++);
-
- for (var i = 0; i < faceNumbers.Count; i++)
- if (faceNumbers[i] == -1)
- faceNumbers[i] = faceNum++;
-
- numPrimFaces = faceNum;
- }
- }
-
- public void MakeFaceUVs()
- {
- faceUVs = new List();
- foreach (var c in coords)
- faceUVs.Add(new UVCoord(1.0f - (0.5f + c.X), 1.0f - (0.5f - c.Y)));
- }
-
- public Profile Copy()
- {
- return Copy(true);
- }
-
- public Profile Copy(bool needFaces)
- {
- var copy = new Profile();
-
- copy.coords.AddRange(coords);
- copy.faceUVs.AddRange(faceUVs);
-
- if (needFaces)
- copy.faces.AddRange(faces);
- if (copy.calcVertexNormals = calcVertexNormals)
- {
- copy.vertexNormals.AddRange(vertexNormals);
- copy.faceNormal = faceNormal;
- copy.cutNormal1 = cutNormal1;
- copy.cutNormal2 = cutNormal2;
- copy.us.AddRange(us);
- copy.faceNumbers.AddRange(faceNumbers);
-
- copy.cut1CoordIndices = new List(cut1CoordIndices);
- copy.cut2CoordIndices = new List(cut2CoordIndices);
- copy.hollowCoordIndices = new List(hollowCoordIndices);
- copy.outerCoordIndices = new List(outerCoordIndices);
- }
- copy.numOuterVerts = numOuterVerts;
- copy.numHollowVerts = numHollowVerts;
-
- return copy;
- }
-
- public void AddPos(Coord v)
- {
- AddPos(v.X, v.Y, v.Z);
- }
-
- public void AddPos(float x, float y, float z)
- {
- int i;
- var numVerts = coords.Count;
- Coord vert;
-
- for (i = 0; i < numVerts; i++)
- {
- vert = coords[i];
- vert.X += x;
- vert.Y += y;
- vert.Z += z;
- coords[i] = vert;
- }
- }
-
- public void AddRot(Quat q)
- {
- int i;
- var numVerts = coords.Count;
-
- for (i = 0; i < numVerts; i++)
- coords[i] *= q;
-
- if (calcVertexNormals)
- {
- var numNormals = vertexNormals.Count;
- for (i = 0; i < numNormals; i++)
- vertexNormals[i] *= q;
-
- faceNormal *= q;
- cutNormal1 *= q;
- cutNormal2 *= q;
- }
- }
-
- public void Scale(float x, float y)
- {
- int i;
- var numVerts = coords.Count;
- Coord vert;
-
- for (i = 0; i < numVerts; i++)
- {
- vert = coords[i];
- vert.X *= x;
- vert.Y *= y;
- coords[i] = vert;
- }
- }
-
- ///
- /// Changes order of the vertex indices and negates the center vertex normal. Does not alter vertex normals of radial
- /// vertices
- ///
- public void FlipNormals()
- {
- int i;
- var numFaces = faces.Count;
- Face tmpFace;
- int tmp;
-
- for (i = 0; i < numFaces; i++)
- {
- tmpFace = faces[i];
- tmp = tmpFace.v3;
- tmpFace.v3 = tmpFace.v1;
- tmpFace.v1 = tmp;
- faces[i] = tmpFace;
- }
-
- if (calcVertexNormals)
- {
- var normalCount = vertexNormals.Count;
- if (normalCount > 0)
- {
- var n = vertexNormals[normalCount - 1];
- n.Z = -n.Z;
- vertexNormals[normalCount - 1] = n;
- }
- }
-
- faceNormal.X = -faceNormal.X;
- faceNormal.Y = -faceNormal.Y;
- faceNormal.Z = -faceNormal.Z;
-
- var numfaceUVs = faceUVs.Count;
- for (i = 0; i < numfaceUVs; i++)
- {
- var uv = faceUVs[i];
- uv.V = 1.0f - uv.V;
- faceUVs[i] = uv;
- }
- }
-
- public void AddValue2FaceVertexIndices(int num)
- {
- var numFaces = faces.Count;
- Face tmpFace;
- for (var i = 0; i < numFaces; i++)
- {
- tmpFace = faces[i];
- tmpFace.v1 += num;
- tmpFace.v2 += num;
- tmpFace.v3 += num;
-
- faces[i] = tmpFace;
- }
- }
-
- public void AddValue2FaceNormalIndices(int num)
- {
- if (calcVertexNormals)
- {
- var numFaces = faces.Count;
- Face tmpFace;
- for (var i = 0; i < numFaces; i++)
- {
- tmpFace = faces[i];
- tmpFace.n1 += num;
- tmpFace.n2 += num;
- tmpFace.n3 += num;
-
- faces[i] = tmpFace;
- }
- }
- }
-
- public void DumpRaw(string path, string name, string title)
- {
- if (path == null)
- return;
- var fileName = name + "_" + title + ".raw";
- var completePath = System.IO.Path.Combine(path, fileName);
- var sw = new StreamWriter(completePath);
-
- for (var i = 0; i < faces.Count; i++)
- {
- var s = coords[faces[i].v1].ToString();
- s += " " + coords[faces[i].v2];
- s += " " + coords[faces[i].v3];
-
- sw.WriteLine(s);
- }
-
- sw.Close();
- }
- }
-
- public struct PathNode
- {
- public Coord position;
- public Quat rotation;
- public float xScale;
- public float yScale;
- public float percentOfPath;
- }
-
- public enum PathType
- {
- Linear = 0,
- Circular = 1,
- Flexible = 2
- }
-
- public class Path
- {
- private const float twoPi = 2.0f * (float) Math.PI;
- public float dimpleBegin;
- public float dimpleEnd = 1.0f;
- public float holeSizeX = 1.0f; // called pathScaleX in pbs
- public float holeSizeY = 0.25f;
- public float pathCutBegin;
- public float pathCutEnd = 1.0f;
- public List pathNodes = new List();
- public float radius;
- public float revolutions = 1.0f;
- public float skew;
- public int stepsPerRevolution = 24;
- public float taperX;
- public float taperY;
- public float topShearX;
- public float topShearY;
-
- public float twistBegin;
- public float twistEnd;
-
- public void Create(PathType pathType, int steps)
- {
- if (taperX > 0.999f)
- taperX = 0.999f;
- if (taperX < -0.999f)
- taperX = -0.999f;
- if (taperY > 0.999f)
- taperY = 0.999f;
- if (taperY < -0.999f)
- taperY = -0.999f;
-
- if (pathType == PathType.Linear || pathType == PathType.Flexible)
- {
- var step = 0;
-
- var length = pathCutEnd - pathCutBegin;
- var twistTotal = twistEnd - twistBegin;
- var twistTotalAbs = Math.Abs(twistTotal);
- if (twistTotalAbs > 0.01f)
- steps += (int) (twistTotalAbs * 3.66); // dahlia's magic number
-
- var start = -0.5f;
- var stepSize = length / steps;
- var percentOfPathMultiplier = stepSize * 0.999999f;
- var xOffset = topShearX * pathCutBegin;
- var yOffset = topShearY * pathCutBegin;
- var zOffset = start;
- var xOffsetStepIncrement = topShearX * length / steps;
- var yOffsetStepIncrement = topShearY * length / steps;
-
- var percentOfPath = pathCutBegin;
- zOffset += percentOfPath;
-
- // sanity checks
-
- var done = false;
-
- while (!done)
- {
- var newNode = new PathNode {xScale = 1.0f};
-
- if (taperX == 0.0f)
- newNode.xScale = 1.0f;
- else if (taperX > 0.0f)
- newNode.xScale = 1.0f - percentOfPath * taperX;
- else newNode.xScale = 1.0f + (1.0f - percentOfPath) * taperX;
-
- newNode.yScale = 1.0f;
- if (taperY == 0.0f)
- newNode.yScale = 1.0f;
- else if (taperY > 0.0f)
- newNode.yScale = 1.0f - percentOfPath * taperY;
- else newNode.yScale = 1.0f + (1.0f - percentOfPath) * taperY;
-
- var twist = twistBegin + twistTotal * percentOfPath;
-
- newNode.rotation = new Quat(new Coord(0.0f, 0.0f, 1.0f), twist);
- newNode.position = new Coord(xOffset, yOffset, zOffset);
- newNode.percentOfPath = percentOfPath;
-
- pathNodes.Add(newNode);
-
- if (step < steps)
- {
- step += 1;
- percentOfPath += percentOfPathMultiplier;
- xOffset += xOffsetStepIncrement;
- yOffset += yOffsetStepIncrement;
- zOffset += stepSize;
- if (percentOfPath > pathCutEnd)
- done = true;
- }
- else
- {
- done = true;
- }
- }
- } // end of linear path code
-
- else // pathType == Circular
- {
- var twistTotal = twistEnd - twistBegin;
-
- // if the profile has a lot of twist, add more layers otherwise the layers may overlap
- // and the resulting mesh may be quite inaccurate. This method is arbitrary and doesn't
- // accurately match the viewer
- var twistTotalAbs = Math.Abs(twistTotal);
- if (twistTotalAbs > 0.01f)
- {
- if (twistTotalAbs > Math.PI * 1.5f)
- steps *= 2;
- if (twistTotalAbs > Math.PI * 3.0f)
- steps *= 2;
- }
-
- var yPathScale = holeSizeY * 0.5f;
- var pathLength = pathCutEnd - pathCutBegin;
- var totalSkew = skew * 2.0f * pathLength;
- var skewStart = pathCutBegin * 2.0f * skew - skew;
- var xOffsetTopShearXFactor = topShearX * (0.25f + 0.5f * (0.5f - holeSizeY));
- var yShearCompensation = 1.0f + Math.Abs(topShearY) * 0.25f;
-
- // It's not quite clear what pushY (Y top shear) does, but subtracting it from the start and end
- // angles appears to approximate it's effects on path cut. Likewise, adding it to the angle used
- // to calculate the sine for generating the path radius appears to approximate it's effects there
- // too, but there are some subtle differences in the radius which are noticeable as the prim size
- // increases and it may affect megaprims quite a bit. The effect of the Y top shear parameter on
- // the meshes generated with this technique appear nearly identical in shape to the same prims when
- // displayed by the viewer.
-
- var startAngle = twoPi * pathCutBegin * revolutions - topShearY * 0.9f;
- var endAngle = twoPi * pathCutEnd * revolutions - topShearY * 0.9f;
- var stepSize = twoPi / stepsPerRevolution;
-
- var step = (int) (startAngle / stepSize);
- var angle = startAngle;
-
- var done = false;
- while (!done) // loop through the length of the path and add the layers
- {
- var newNode = new PathNode();
-
- var xProfileScale = (1.0f - Math.Abs(skew)) * holeSizeX;
- var yProfileScale = holeSizeY;
-
- var percentOfPath = angle / (twoPi * revolutions);
- var percentOfAngles = (angle - startAngle) / (endAngle - startAngle);
-
- if (taperX > 0.01f)
- xProfileScale *= 1.0f - percentOfPath * taperX;
- else if (taperX < -0.01f)
- xProfileScale *= 1.0f + (1.0f - percentOfPath) * taperX;
-
- if (taperY > 0.01f)
- yProfileScale *= 1.0f - percentOfPath * taperY;
- else if (taperY < -0.01f)
- yProfileScale *= 1.0f + (1.0f - percentOfPath) * taperY;
-
- newNode.xScale = xProfileScale;
- newNode.yScale = yProfileScale;
-
- var radiusScale = 1.0f;
- if (radius > 0.001f)
- radiusScale = 1.0f - radius * percentOfPath;
- else if (radius < 0.001f)
- radiusScale = 1.0f + radius * (1.0f - percentOfPath);
-
- var twist = twistBegin + twistTotal * percentOfPath;
-
- var xOffset = 0.5f * (skewStart + totalSkew * percentOfAngles);
- xOffset += (float) Math.Sin(angle) * xOffsetTopShearXFactor;
-
- var yOffset = yShearCompensation * (float) Math.Cos(angle) * (0.5f - yPathScale) * radiusScale;
-
- var zOffset = (float) Math.Sin(angle + topShearY) * (0.5f - yPathScale) * radiusScale;
-
- newNode.position = new Coord(xOffset, yOffset, zOffset);
-
- // now orient the rotation of the profile layer relative to it's position on the path
- // adding taperY to the angle used to generate the quat appears to approximate the viewer
-
- newNode.rotation = new Quat(new Coord(1.0f, 0.0f, 0.0f), angle + topShearY);
-
- // next apply twist rotation to the profile layer
- if (twistTotal != 0.0f || twistBegin != 0.0f)
- newNode.rotation *= new Quat(new Coord(0.0f, 0.0f, 1.0f), twist);
-
- newNode.percentOfPath = percentOfPath;
-
- pathNodes.Add(newNode);
-
- // calculate terms for next iteration
- // calculate the angle for the next iteration of the loop
-
- if (angle >= endAngle - 0.01)
- {
- done = true;
- }
- else
- {
- step += 1;
- angle = stepSize * step;
- if (angle > endAngle)
- angle = endAngle;
- }
- }
- }
- }
- }
-
- public class PrimMesh
- {
- private const float twoPi = 2.0f * (float) Math.PI;
- public bool calcVertexNormals;
-
- public List coords;
- public float dimpleBegin;
- public float dimpleEnd = 1.0f;
- public string errorMessage = "";
- public List faces;
-
- public float holeSizeX = 1.0f; // called pathScaleX in pbs
- public float holeSizeY = 0.25f;
- private readonly float hollow;
- private readonly int hollowSides = 4;
- public List normals;
- private bool normalsProcessed;
-
- public int numPrimFaces;
- public float pathCutBegin;
- public float pathCutEnd = 1.0f;
- private readonly float profileEnd = 1.0f;
-
- private readonly float profileStart;
- public float radius;
- public float revolutions = 1.0f;
-
- private readonly int sides = 4;
- public float skew;
- public bool sphereMode = false;
- public int stepsPerRevolution = 24;
- public float taperX;
- public float taperY;
- public float topShearX;
- public float topShearY;
- public int twistBegin;
- public int twistEnd;
-
- public List viewerFaces;
- public bool viewerMode;
-
-
- ///
- /// Constructs a PrimMesh object and creates the profile for extrusion.
- ///
- ///
- ///
- ///
- ///
- ///
- public PrimMesh(int sides, float profileStart, float profileEnd, float hollow, int hollowSides)
- {
- coords = new List();
- faces = new List();
-
- this.sides = sides;
- this.profileStart = profileStart;
- this.profileEnd = profileEnd;
- this.hollow = hollow;
- this.hollowSides = hollowSides;
-
- if (sides < 3)
- this.sides = 3;
- if (hollowSides < 3)
- this.hollowSides = 3;
- if (profileStart < 0.0f)
- this.profileStart = 0.0f;
- if (profileEnd > 1.0f)
- this.profileEnd = 1.0f;
- if (profileEnd < 0.02f)
- this.profileEnd = 0.02f;
- if (profileStart >= profileEnd)
- this.profileStart = profileEnd - 0.02f;
- if (hollow > 0.99f)
- this.hollow = 0.99f;
- if (hollow < 0.0f)
- this.hollow = 0.0f;
- }
-
- public int ProfileOuterFaceNumber { get; private set; } = -1;
-
- public int ProfileHollowFaceNumber { get; private set; } = -1;
-
- public bool HasProfileCut { get; private set; }
-
- public bool HasHollow { get; private set; }
-
- ///
- /// Human readable string representation of the parameters used to create a mesh.
- ///
- ///
- public string ParamsToDisplayString()
- {
- var s = "";
- s += "sides..................: " + sides;
- s += "\nhollowSides..........: " + hollowSides;
- s += "\nprofileStart.........: " + profileStart;
- s += "\nprofileEnd...........: " + profileEnd;
- s += "\nhollow...............: " + hollow;
- s += "\ntwistBegin...........: " + twistBegin;
- s += "\ntwistEnd.............: " + twistEnd;
- s += "\ntopShearX............: " + topShearX;
- s += "\ntopShearY............: " + topShearY;
- s += "\npathCutBegin.........: " + pathCutBegin;
- s += "\npathCutEnd...........: " + pathCutEnd;
- s += "\ndimpleBegin..........: " + dimpleBegin;
- s += "\ndimpleEnd............: " + dimpleEnd;
- s += "\nskew.................: " + skew;
- s += "\nholeSizeX............: " + holeSizeX;
- s += "\nholeSizeY............: " + holeSizeY;
- s += "\ntaperX...............: " + taperX;
- s += "\ntaperY...............: " + taperY;
- s += "\nradius...............: " + radius;
- s += "\nrevolutions..........: " + revolutions;
- s += "\nstepsPerRevolution...: " + stepsPerRevolution;
- s += "\nsphereMode...........: " + sphereMode;
- s += "\nhasProfileCut........: " + HasProfileCut;
- s += "\nhasHollow............: " + HasHollow;
- s += "\nviewerMode...........: " + viewerMode;
-
- return s;
- }
-
- ///
- /// Extrudes a profile along a path.
- ///
- public void Extrude(PathType pathType)
- {
- var needEndFaces = false;
-
- coords = new List();
- this.faces = new List();
-
- if (viewerMode)
- {
- viewerFaces = new List();
- calcVertexNormals = true;
- }
-
- if (calcVertexNormals)
- normals = new List();
-
- var steps = 1;
-
- var length = pathCutEnd - pathCutBegin;
- normalsProcessed = false;
-
- if (viewerMode && sides == 3)
- if (Math.Abs(taperX) > 0.01 || Math.Abs(taperY) > 0.01)
- steps = (int) (steps * 4.5 * length);
-
- if (sphereMode)
- HasProfileCut = profileEnd - profileStart < 0.4999f;
- else
- HasProfileCut = profileEnd - profileStart < 0.9999f;
- HasHollow = this.hollow > 0.001f;
-
- var twistBegin = this.twistBegin / 360.0f * twoPi;
- var twistEnd = this.twistEnd / 360.0f * twoPi;
- var twistTotal = twistEnd - twistBegin;
- var twistTotalAbs = Math.Abs(twistTotal);
- if (twistTotalAbs > 0.01f)
- steps += (int) (twistTotalAbs * 3.66); // dahlia's magic number
-
- var hollow = this.hollow;
-
- if (pathType == PathType.Circular)
- {
- needEndFaces = false;
- if (pathCutBegin != 0.0f || pathCutEnd != 1.0f)
- needEndFaces = true;
- else if (taperX != 0.0f || taperY != 0.0f)
- needEndFaces = true;
- else if (skew != 0.0f)
- needEndFaces = true;
- else if (twistTotal != 0.0f)
- needEndFaces = true;
- else if (radius != 0.0f)
- needEndFaces = true;
- }
- else
- {
- needEndFaces = true;
- }
-
- // sanity checks
- var initialProfileRot = 0.0f;
- if (pathType == PathType.Circular)
- {
- switch (sides)
- {
- case 3:
- initialProfileRot = (float) Math.PI;
- if (hollowSides == 4)
- {
- if (hollow > 0.7f)
- hollow = 0.7f;
- hollow *= 0.707f;
- }
- else
- {
- hollow *= 0.5f;
- }
- break;
- case 4:
- initialProfileRot = 0.25f * (float) Math.PI;
- if (hollowSides != 4)
- hollow *= 0.707f;
- break;
- default:
- if (sides > 4)
- {
- initialProfileRot = (float) Math.PI;
- if (hollowSides == 4)
- {
- if (hollow > 0.7f)
- hollow = 0.7f;
- hollow /= 0.7f;
- }
- }
- break;
- }
- }
- else
- {
- switch (sides)
- {
- case 3:
- if (hollowSides == 4)
- {
- if (hollow > 0.7f)
- hollow = 0.7f;
- hollow *= 0.707f;
- }
- else
- {
- hollow *= 0.5f;
- }
- break;
- case 4:
- initialProfileRot = 1.25f * (float) Math.PI;
- if (hollowSides != 4)
- hollow *= 0.707f;
- break;
- case 24 when hollowSides == 4:
- hollow *= 1.414f;
- break;
- }
- }
-
- var profile = new Profile(sides, profileStart, profileEnd, hollow, hollowSides, true, calcVertexNormals);
- errorMessage = profile.errorMessage;
-
- numPrimFaces = profile.numPrimFaces;
-
- var cut1FaceNumber = profile.bottomFaceNumber + 1;
- var cut2FaceNumber = cut1FaceNumber + 1;
- if (!needEndFaces)
- {
- cut1FaceNumber -= 2;
- cut2FaceNumber -= 2;
- }
-
- ProfileOuterFaceNumber = profile.outerFaceNumber;
- if (!needEndFaces)
- ProfileOuterFaceNumber--;
-
- if (HasHollow)
- {
- ProfileHollowFaceNumber = profile.hollowFaceNumber;
- if (!needEndFaces)
- ProfileHollowFaceNumber--;
- }
-
- var cut1Vert = -1;
- var cut2Vert = -1;
- if (HasProfileCut)
- {
- cut1Vert = HasHollow ? profile.coords.Count - 1 : 0;
- cut2Vert = HasHollow ? profile.numOuterVerts - 1 : profile.numOuterVerts;
- }
-
- if (initialProfileRot != 0.0f)
- {
- profile.AddRot(new Quat(new Coord(0.0f, 0.0f, 1.0f), initialProfileRot));
- if (viewerMode)
- profile.MakeFaceUVs();
- }
-
- var lastCutNormal1 = new Coord();
- var lastCutNormal2 = new Coord();
- var thisV = 0.0f;
- var lastV = 0.0f;
-
- var path = new Path
- {
- twistBegin = twistBegin,
- twistEnd = twistEnd,
- topShearX = topShearX,
- topShearY = topShearY,
- pathCutBegin = pathCutBegin,
- pathCutEnd = pathCutEnd,
- dimpleBegin = dimpleBegin,
- dimpleEnd = dimpleEnd,
- skew = skew,
- holeSizeX = holeSizeX,
- holeSizeY = holeSizeY,
- taperX = taperX,
- taperY = taperY,
- radius = radius,
- revolutions = revolutions,
- stepsPerRevolution = stepsPerRevolution
- };
-
- path.Create(pathType, steps);
-
- for (var nodeIndex = 0; nodeIndex < path.pathNodes.Count; nodeIndex++)
- {
- var node = path.pathNodes[nodeIndex];
- var newLayer = profile.Copy();
- newLayer.Scale(node.xScale, node.yScale);
-
- newLayer.AddRot(node.rotation);
- newLayer.AddPos(node.position);
-
- if (needEndFaces && nodeIndex == 0)
- {
- newLayer.FlipNormals();
-
- // add the bottom faces to the viewerFaces list
- if (viewerMode)
- {
- var faceNormal = newLayer.faceNormal;
- var newViewerFace = new ViewerFace(profile.bottomFaceNumber);
- var numFaces = newLayer.faces.Count;
- var faces = newLayer.faces;
-
- for (var i = 0; i < numFaces; i++)
- {
- var face = faces[i];
- newViewerFace.v1 = newLayer.coords[face.v1];
- newViewerFace.v2 = newLayer.coords[face.v2];
- newViewerFace.v3 = newLayer.coords[face.v3];
-
- newViewerFace.coordIndex1 = face.v1;
- newViewerFace.coordIndex2 = face.v2;
- newViewerFace.coordIndex3 = face.v3;
-
- newViewerFace.n1 = faceNormal;
- newViewerFace.n2 = faceNormal;
- newViewerFace.n3 = faceNormal;
-
- newViewerFace.uv1 = newLayer.faceUVs[face.v1];
- newViewerFace.uv2 = newLayer.faceUVs[face.v2];
- newViewerFace.uv3 = newLayer.faceUVs[face.v3];
-
- if (pathType == PathType.Linear)
- {
- newViewerFace.uv1.Flip();
- newViewerFace.uv2.Flip();
- newViewerFace.uv3.Flip();
- }
-
- viewerFaces.Add(newViewerFace);
- }
- }
- } // if (nodeIndex == 0)
-
- // append this layer
-
- var coordsLen = coords.Count;
- newLayer.AddValue2FaceVertexIndices(coordsLen);
-
- coords.AddRange(newLayer.coords);
-
- if (calcVertexNormals)
- {
- newLayer.AddValue2FaceNormalIndices(normals.Count);
- normals.AddRange(newLayer.vertexNormals);
- }
-
- if (node.percentOfPath < pathCutBegin + 0.01f || node.percentOfPath > pathCutEnd - 0.01f)
- this.faces.AddRange(newLayer.faces);
-
- // fill faces between layers
-
- var numVerts = newLayer.coords.Count;
- var newFace1 = new Face();
- var newFace2 = new Face();
-
- thisV = 1.0f - node.percentOfPath;
-
- if (nodeIndex > 0)
- {
- var startVert = coordsLen + 1;
- var endVert = coords.Count;
-
- if (sides < 5 || HasProfileCut || HasHollow)
- startVert--;
-
- for (var i = startVert; i < endVert; i++)
- {
- var iNext = i + 1;
- if (i == endVert - 1)
- iNext = startVert;
-
- var whichVert = i - startVert;
-
- newFace1.v1 = i;
- newFace1.v2 = i - numVerts;
- newFace1.v3 = iNext;
-
- newFace1.n1 = newFace1.v1;
- newFace1.n2 = newFace1.v2;
- newFace1.n3 = newFace1.v3;
- faces.Add(newFace1);
-
- newFace2.v1 = iNext;
- newFace2.v2 = i - numVerts;
- newFace2.v3 = iNext - numVerts;
-
- newFace2.n1 = newFace2.v1;
- newFace2.n2 = newFace2.v2;
- newFace2.n3 = newFace2.v3;
- faces.Add(newFace2);
-
- if (viewerMode)
- {
- // add the side faces to the list of viewerFaces here
-
- var primFaceNum = profile.faceNumbers[whichVert];
- if (!needEndFaces)
- primFaceNum -= 1;
-
- var newViewerFace1 = new ViewerFace(primFaceNum);
- var newViewerFace2 = new ViewerFace(primFaceNum);
-
- var uIndex = whichVert;
- if (!HasHollow && sides > 4 && uIndex < newLayer.us.Count - 1)
- uIndex++;
-
- var u1 = newLayer.us[uIndex];
- var u2 = 1.0f;
- if (uIndex < newLayer.us.Count - 1)
- u2 = newLayer.us[uIndex + 1];
-
- if (whichVert == cut1Vert || whichVert == cut2Vert)
- {
- u1 = 0.0f;
- u2 = 1.0f;
- }
- else if (sides < 5)
- {
- if (whichVert < profile.numOuterVerts)
- {
- // boxes and prisms have one texture face per side of the prim, so the U values have to be scaled
- // to reflect the entire texture width
- u1 *= sides;
- u2 *= sides;
- u2 -= (int) u1;
- u1 -= (int) u1;
- if (u2 < 0.1f)
- u2 = 1.0f;
- }
- }
-
- if (sphereMode)
- if (whichVert != cut1Vert && whichVert != cut2Vert)
- {
- u1 = u1 * 2.0f - 1.0f;
- u2 = u2 * 2.0f - 1.0f;
-
- if (whichVert >= newLayer.numOuterVerts)
- {
- u1 -= hollow;
- u2 -= hollow;
- }
- }
-
- newViewerFace1.uv1.U = u1;
- newViewerFace1.uv2.U = u1;
- newViewerFace1.uv3.U = u2;
-
- newViewerFace1.uv1.V = thisV;
- newViewerFace1.uv2.V = lastV;
- newViewerFace1.uv3.V = thisV;
-
- newViewerFace2.uv1.U = u2;
- newViewerFace2.uv2.U = u1;
- newViewerFace2.uv3.U = u2;
-
- newViewerFace2.uv1.V = thisV;
- newViewerFace2.uv2.V = lastV;
- newViewerFace2.uv3.V = lastV;
-
- newViewerFace1.v1 = coords[newFace1.v1];
- newViewerFace1.v2 = coords[newFace1.v2];
- newViewerFace1.v3 = coords[newFace1.v3];
-
- newViewerFace2.v1 = coords[newFace2.v1];
- newViewerFace2.v2 = coords[newFace2.v2];
- newViewerFace2.v3 = coords[newFace2.v3];
-
- newViewerFace1.coordIndex1 = newFace1.v1;
- newViewerFace1.coordIndex2 = newFace1.v2;
- newViewerFace1.coordIndex3 = newFace1.v3;
-
- newViewerFace2.coordIndex1 = newFace2.v1;
- newViewerFace2.coordIndex2 = newFace2.v2;
- newViewerFace2.coordIndex3 = newFace2.v3;
-
- // profile cut faces
- if (whichVert == cut1Vert)
- {
- newViewerFace1.primFaceNumber = cut1FaceNumber;
- newViewerFace2.primFaceNumber = cut1FaceNumber;
- newViewerFace1.n1 = newLayer.cutNormal1;
- newViewerFace1.n2 = newViewerFace1.n3 = lastCutNormal1;
-
- newViewerFace2.n1 = newViewerFace2.n3 = newLayer.cutNormal1;
- newViewerFace2.n2 = lastCutNormal1;
- }
- else if (whichVert == cut2Vert)
- {
- newViewerFace1.primFaceNumber = cut2FaceNumber;
- newViewerFace2.primFaceNumber = cut2FaceNumber;
- newViewerFace1.n1 = newLayer.cutNormal2;
- newViewerFace1.n2 = lastCutNormal2;
- newViewerFace1.n3 = lastCutNormal2;
-
- newViewerFace2.n1 = newLayer.cutNormal2;
- newViewerFace2.n3 = newLayer.cutNormal2;
- newViewerFace2.n2 = lastCutNormal2;
- }
-
- else // outer and hollow faces
- {
- if (sides < 5 && whichVert < newLayer.numOuterVerts ||
- hollowSides < 5 && whichVert >= newLayer.numOuterVerts)
- {
- // looks terrible when path is twisted... need vertex normals here
- newViewerFace1.CalcSurfaceNormal();
- newViewerFace2.CalcSurfaceNormal();
- }
- else
- {
- newViewerFace1.n1 = normals[newFace1.n1];
- newViewerFace1.n2 = normals[newFace1.n2];
- newViewerFace1.n3 = normals[newFace1.n3];
-
- newViewerFace2.n1 = normals[newFace2.n1];
- newViewerFace2.n2 = normals[newFace2.n2];
- newViewerFace2.n3 = normals[newFace2.n3];
- }
- }
-
- viewerFaces.Add(newViewerFace1);
- viewerFaces.Add(newViewerFace2);
- }
- }
- }
-
- lastCutNormal1 = newLayer.cutNormal1;
- lastCutNormal2 = newLayer.cutNormal2;
- lastV = thisV;
-
- if (needEndFaces && nodeIndex == path.pathNodes.Count - 1 && viewerMode)
- {
- // add the top faces to the viewerFaces list here
- var faceNormal = newLayer.faceNormal;
- var newViewerFace = new ViewerFace(0);
- var numFaces = newLayer.faces.Count;
- var faces = newLayer.faces;
-
- for (var i = 0; i < numFaces; i++)
- {
- var face = faces[i];
- newViewerFace.v1 = newLayer.coords[face.v1 - coordsLen];
- newViewerFace.v2 = newLayer.coords[face.v2 - coordsLen];
- newViewerFace.v3 = newLayer.coords[face.v3 - coordsLen];
-
- newViewerFace.coordIndex1 = face.v1 - coordsLen;
- newViewerFace.coordIndex2 = face.v2 - coordsLen;
- newViewerFace.coordIndex3 = face.v3 - coordsLen;
-
- newViewerFace.n1 = faceNormal;
- newViewerFace.n2 = faceNormal;
- newViewerFace.n3 = faceNormal;
-
- newViewerFace.uv1 = newLayer.faceUVs[face.v1 - coordsLen];
- newViewerFace.uv2 = newLayer.faceUVs[face.v2 - coordsLen];
- newViewerFace.uv3 = newLayer.faceUVs[face.v3 - coordsLen];
-
- if (pathType == PathType.Linear)
- {
- newViewerFace.uv1.Flip();
- newViewerFace.uv2.Flip();
- newViewerFace.uv3.Flip();
- }
-
- viewerFaces.Add(newViewerFace);
- }
- }
- } // for (int nodeIndex = 0; nodeIndex < path.pathNodes.Count; nodeIndex++)
- }
-
-
- ///
- /// DEPRICATED - use Extrude(PathType.Linear) instead
- /// Extrudes a profile along a straight line path. Used for prim types box, cylinder, and prism.
- ///
- public void ExtrudeLinear()
- {
- Extrude(PathType.Linear);
- }
-
-
- ///
- /// DEPRICATED - use Extrude(PathType.Circular) instead
- /// Extrude a profile into a circular path prim mesh. Used for prim types torus, tube, and ring.
- ///
- public void ExtrudeCircular()
- {
- Extrude(PathType.Circular);
- }
-
-
- private Coord SurfaceNormal(Coord c1, Coord c2, Coord c3)
- {
- var edge1 = new Coord(c2.X - c1.X, c2.Y - c1.Y, c2.Z - c1.Z);
- var edge2 = new Coord(c3.X - c1.X, c3.Y - c1.Y, c3.Z - c1.Z);
-
- var normal = Coord.Cross(edge1, edge2);
-
- normal.Normalize();
-
- return normal;
- }
-
- private Coord SurfaceNormal(Face face)
- {
- return SurfaceNormal(coords[face.v1], coords[face.v2], coords[face.v3]);
- }
-
- ///
- /// Calculate the surface normal for a face in the list of faces
- ///
- ///
- ///
- public Coord SurfaceNormal(int faceIndex)
- {
- var numFaces = faces.Count;
- if (faceIndex < 0 || faceIndex >= numFaces)
- throw new Exception("faceIndex out of range");
-
- return SurfaceNormal(faces[faceIndex]);
- }
-
- ///
- /// Duplicates a PrimMesh object. All object properties are copied by value, including lists.
- ///
- ///
- public PrimMesh Copy()
- {
- var copy = new PrimMesh(sides, profileStart, profileEnd, hollow, hollowSides)
- {
- twistBegin = twistBegin,
- twistEnd = twistEnd,
- topShearX = topShearX,
- topShearY = topShearY,
- pathCutBegin = pathCutBegin,
- pathCutEnd = pathCutEnd,
- dimpleBegin = dimpleBegin,
- dimpleEnd = dimpleEnd,
- skew = skew,
- holeSizeX = holeSizeX,
- holeSizeY = holeSizeY,
- taperX = taperX,
- taperY = taperY,
- radius = radius,
- revolutions = revolutions,
- stepsPerRevolution = stepsPerRevolution,
- calcVertexNormals = calcVertexNormals,
- normalsProcessed = normalsProcessed,
- viewerMode = viewerMode,
- numPrimFaces = numPrimFaces,
- errorMessage = errorMessage,
- coords = new List(coords),
- faces = new List(faces),
- viewerFaces = new List(viewerFaces),
- normals = new List(normals)
- };
-
-
- return copy;
- }
-
- ///
- /// Calculate surface normals for all of the faces in the list of faces in this mesh
- ///
- public void CalcNormals()
- {
- if (normalsProcessed)
- return;
-
- normalsProcessed = true;
-
- var numFaces = faces.Count;
-
- if (!calcVertexNormals)
- normals = new List();
-
- for (var i = 0; i < numFaces; i++)
- {
- var face = faces[i];
-
- normals.Add(SurfaceNormal(i).Normalize());
-
- var normIndex = normals.Count - 1;
- face.n1 = normIndex;
- face.n2 = normIndex;
- face.n3 = normIndex;
-
- faces[i] = face;
- }
- }
-
- ///
- /// Adds a value to each XYZ vertex coordinate in the mesh
- ///
- ///
- ///
- ///
- public void AddPos(float x, float y, float z)
- {
- int i;
- var numVerts = coords.Count;
- Coord vert;
-
- for (i = 0; i < numVerts; i++)
- {
- vert = coords[i];
- vert.X += x;
- vert.Y += y;
- vert.Z += z;
- coords[i] = vert;
- }
-
- if (viewerFaces != null)
- {
- var numViewerFaces = viewerFaces.Count;
-
- for (i = 0; i < numViewerFaces; i++)
- {
- var v = viewerFaces[i];
- v.AddPos(x, y, z);
- viewerFaces[i] = v;
- }
- }
- }
-
- ///
- /// Rotates the mesh
- ///
- ///
- public void AddRot(Quat q)
- {
- int i;
- var numVerts = coords.Count;
-
- for (i = 0; i < numVerts; i++)
- coords[i] *= q;
-
- if (normals != null)
- {
- var numNormals = normals.Count;
- for (i = 0; i < numNormals; i++)
- normals[i] *= q;
- }
-
- if (viewerFaces != null)
- {
- var numViewerFaces = viewerFaces.Count;
-
- for (i = 0; i < numViewerFaces; i++)
- {
- var v = viewerFaces[i];
- v.v1 *= q;
- v.v2 *= q;
- v.v3 *= q;
-
- v.n1 *= q;
- v.n2 *= q;
- v.n3 *= q;
- viewerFaces[i] = v;
- }
- }
- }
-
-#if VERTEX_INDEXER
- public VertexIndexer GetVertexIndexer()
- {
- if (viewerMode && viewerFaces.Count > 0)
- return new VertexIndexer(this);
- return null;
- }
-#endif
-
- ///
- /// Scales the mesh
- ///
- ///
- ///
- ///
- public void Scale(float x, float y, float z)
- {
- int i;
- var numVerts = coords.Count;
- //Coord vert;
-
- var m = new Coord(x, y, z);
- for (i = 0; i < numVerts; i++)
- coords[i] *= m;
-
- if (viewerFaces != null)
- {
- var numViewerFaces = viewerFaces.Count;
- for (i = 0; i < numViewerFaces; i++)
- {
- var v = viewerFaces[i];
- v.v1 *= m;
- v.v2 *= m;
- v.v3 *= m;
- viewerFaces[i] = v;
- }
- }
- }
-
- ///
- /// Dumps the mesh to a Blender compatible "Raw" format file
- ///
- ///
- ///
- ///
- public void DumpRaw(string path, string name, string title)
- {
- if (path == null)
- return;
- var fileName = name + "_" + title + ".raw";
- var completePath = System.IO.Path.Combine(path, fileName);
- var sw = new StreamWriter(completePath);
-
- for (var i = 0; i < faces.Count; i++)
- {
- var s = coords[faces[i].v1].ToString();
- s += " " + coords[faces[i].v2];
- s += " " + coords[faces[i].v3];
-
- sw.WriteLine(s);
- }
-
- sw.Close();
- }
- }
-}
\ No newline at end of file
diff --git a/OpenMetaverse.Rendering.Meshmerizer/MeshmerizerR.cs b/OpenMetaverse.Rendering.Meshmerizer/MeshmerizerR.cs
index d2a32cc8..1ee46ee3 100644
--- a/OpenMetaverse.Rendering.Meshmerizer/MeshmerizerR.cs
+++ b/OpenMetaverse.Rendering.Meshmerizer/MeshmerizerR.cs
@@ -31,12 +31,9 @@
* using PrimMesher (http://forge.opensimulator.org/projects/primmesher).
*/
-using System;
-using System.Collections.Generic;
-using System.Drawing;
-
using OMV = OpenMetaverse;
using OMVR = OpenMetaverse.Rendering;
+using SkiaSharp;
namespace OpenMetaverse.Rendering
{
@@ -44,7 +41,7 @@ namespace OpenMetaverse.Rendering
/// Meshing code based on the Idealist Viewer (20081213).
///
[RendererName("MeshmerizerR")]
- public class MeshmerizerR : IRendering
+ public class MeshmerizerR : OMVR.IRendering
{
///
/// Generates a basic mesh structure from a primitive
@@ -58,16 +55,15 @@ public OMVR.SimpleMesh GenerateSimpleMesh(Primitive prim, OMVR.DetailLevel lod)
if (newPrim == null)
return null;
- SimpleMesh mesh = new SimpleMesh();
- mesh.Path = new Path();
- mesh.Prim = prim;
- mesh.Profile = new Profile();
- mesh.Vertices = new List(newPrim.coords.Count);
- for (int i = 0; i < newPrim.coords.Count; i++)
+ SimpleMesh mesh = new()
{
- PrimMesher.Coord c = newPrim.coords[i];
- mesh.Vertices.Add(new Vertex { Position = new Vector3(c.X, c.Y, c.Z) });
- }
+ Path = new Path(),
+ Prim = prim,
+ Profile = new Profile(),
+ Vertices = new List(newPrim.coords.Count)
+ };
+ for (int i = 0; i < newPrim.coords.Count; i++)
+ mesh.Vertices.Add(new Vertex { Position = newPrim.coords[i] });
mesh.Indices = new List(newPrim.faces.Count * 3);
for (int i = 0; i < newPrim.faces.Count; i++)
@@ -88,7 +84,7 @@ public OMVR.SimpleMesh GenerateSimpleMesh(Primitive prim, OMVR.DetailLevel lod)
/// Sculpt texture
/// Level of detail to generate the mesh at
/// The generated mesh or null on failure
- public OMVR.SimpleMesh GenerateSimpleSculptMesh(OMV.Primitive prim, Bitmap sculptTexture, OMVR.DetailLevel lod)
+ public OMVR.SimpleMesh GenerateSimpleSculptMesh(OMV.Primitive prim, SKBitmap sculptTexture, OMVR.DetailLevel lod)
{
OMVR.FacetedMesh faceted = GenerateFacetedSculptMesh(prim, sculptTexture, lod);
@@ -110,6 +106,97 @@ public OMVR.SimpleMesh GenerateSimpleSculptMesh(OMV.Primitive prim, Bitmap sculp
return null;
}
+ public static FacetedMesh m_BasicBoxMesh = null;
+ private static readonly object m_BasicBoxMeshLock = new();
+ public static List m_indexs_012023 = [0, 1, 2, 0, 2, 3];
+ public static List m_indexs_012213 = [0, 1, 2, 2, 1, 3];
+ public static List m_indexs_012302 = [0, 1, 2, 3, 0, 2];
+ public static FacetedMesh GetBasicBoxMesh()
+ {
+ if(m_BasicBoxMesh == null)
+ {
+ lock (m_BasicBoxMeshLock)
+ {
+ m_BasicBoxMesh ??= new()
+ {
+ Faces =
+ [
+ new Face()
+ {
+ Vertices =
+ [
+ new() { Position = new(-0.5f, -0.5f, 0.5f), Normal = Vector3.UnitZ, TexCoord = new(0f, 0f)},
+ new() { Position = new( 0.5f, -0.5f, 0.5f), Normal = Vector3.UnitZ, TexCoord = new(1f, 0f)},
+ new() { Position = new( 0.5f, 0.5f, 0.5f), Normal = Vector3.UnitZ, TexCoord = new(1f, 1f)},
+ new() { Position = new(-0.5f, 0.5f, 0.5f), Normal = Vector3.UnitZ, TexCoord = new(0f, 1f)},
+ ],
+ Indices = m_indexs_012023,
+ },
+ new Face()
+ {
+ Vertices =
+ [
+ new() { Position = new(-0.5f, -0.5f, 0.5f), Normal = -Vector3.UnitY, TexCoord = new(0f, 1f)},
+ new() { Position = new(-0.5f, -0.5f, -0.5f), Normal = -Vector3.UnitY, TexCoord = new(0f, 0f)},
+ new() { Position = new( 0.5f, -0.5f, 0.5f), Normal = -Vector3.UnitY, TexCoord = new(1f, 1f)},
+ new() { Position = new( 0.5f, -0.5f, -0.5f), Normal = -Vector3.UnitY, TexCoord = new(1f, 0f)},
+ ],
+ Indices = m_indexs_012213,
+ },
+ new Face()
+ {
+ Vertices =
+ [
+ new() { Position = new( 0.5f, -0.5f, 0.5f), Normal = Vector3.UnitX, TexCoord = new(0f, 1f)},
+ new() { Position = new( 0.5f, -0.5f, -0.5f), Normal = Vector3.UnitX, TexCoord = new(0f, 0f)},
+ new() { Position = new( 0.5f, 0.5f, 0.5f), Normal = Vector3.UnitX, TexCoord = new(1f, 1f)},
+ new() { Position = new( 0.5f, 0.5f, -0.5f), Normal = Vector3.UnitX, TexCoord = new(1f, 0f)},
+ ],
+ Indices = m_indexs_012213,
+ },
+ new Face()
+ {
+ Vertices =
+ [
+ new() { Position = new( 0.5f, 0.5f, 0.5f), Normal = Vector3.UnitY, TexCoord = new(0f, 1f)},
+ new() { Position = new( 0.5f, 0.5f, -0.5f), Normal = Vector3.UnitY, TexCoord = new(0f, 0f)},
+ new() { Position = new( -0.5f, 0.5f, 0.5f), Normal = Vector3.UnitY, TexCoord = new(1f, 1f)},
+ new() { Position = new( -0.5f, 0.5f, -0.5f), Normal = Vector3.UnitY, TexCoord = new(1f, 0f)},
+ ],
+ Indices = m_indexs_012213,
+ },
+ new Face()
+ {
+ Vertices =
+ [
+ new() { Position = new( -0.5f, 0.5f, 0.5f), Normal = -Vector3.UnitX, TexCoord = new(0f, 1f)},
+ new() { Position = new( -0.5f, 0.5f, -0.5f), Normal = -Vector3.UnitX, TexCoord = new(0f, 0f)},
+ new() { Position = new( -0.5f, -0.5f, 0.5f), Normal = -Vector3.UnitX, TexCoord = new(1f, 1f)},
+ new() { Position = new( -0.5f, -0.5f, -0.5f), Normal = -Vector3.UnitX, TexCoord = new(1f, 0f)},
+ ],
+ Indices = m_indexs_012213,
+ },
+ new Face()
+ {
+ Vertices =
+ [
+ new() { Position = new( 0.5f, 0.5f, -0.5f), Normal = -Vector3.UnitZ, TexCoord = new(1f, 0f)},
+ new() { Position = new( 0.5f, -0.5f, -0.5f), Normal = -Vector3.UnitZ, TexCoord = new(1f, 1f)},
+ new() { Position = new( -0.5f, -0.5f, -0.5f), Normal = -Vector3.UnitZ, TexCoord = new(0f, 1f)},
+ new() { Position = new( -0.5f, 0.5f, -0.5f), Normal = -Vector3.UnitZ, TexCoord = new(0f, 0f)},
+ ],
+ Indices = m_indexs_012302,
+ },
+ ]
+ };
+ }
+ }
+
+ return m_BasicBoxMesh;
+ }
+
+
+
///
/// Generates a a series of faces, each face containing a mesh and
/// metadata
@@ -119,35 +206,52 @@ public OMVR.SimpleMesh GenerateSimpleSculptMesh(OMV.Primitive prim, Bitmap sculp
/// The generated mesh
public OMVR.FacetedMesh GenerateFacetedMesh(OMV.Primitive prim, OMVR.DetailLevel lod)
{
- bool isSphere = ((OMV.ProfileCurve)(prim.PrimData.profileCurve & 0x07) == OMV.ProfileCurve.HalfCircle);
+ OMV.ProfileCurve profileCurve = (OMV.ProfileCurve)(prim.PrimData.profileCurve & 0x07);
+
+ if ( profileCurve == OMV.ProfileCurve.Square && prim.PrimData.PathCurve == OMV.PathCurve.Line)
+ {
+ if( prim.PrimData.ProfileHole == 0 &&
+ prim.PrimData.ProfileBegin == 0f && prim.PrimData.ProfileEnd == 1f &&
+ prim.PrimData.PathBegin == 0f && prim.PrimData.PathEnd == 1f &&
+ prim.PrimData.PathScaleX == 1f && prim.PrimData.PathScaleY == 1f &&
+ prim.PrimData.PathShearX == 0 && prim.PrimData.PathShearY == 0 &&
+ prim.PrimData.PathRevolutions == 1f
+ )
+ {
+ return GetBasicBoxMesh();
+ }
+ }
+
PrimMesher.PrimMesh newPrim = GeneratePrimMesh(prim, lod, true);
if (newPrim == null)
return null;
// copy the vertex information into OMVR.IRendering structures
- OMVR.FacetedMesh omvrmesh = new OMVR.FacetedMesh();
- omvrmesh.Faces = new List();
- omvrmesh.Prim = prim;
- omvrmesh.Profile = new OMVR.Profile();
- omvrmesh.Profile.Faces = new List();
- omvrmesh.Profile.Positions = new List();
- omvrmesh.Path = new OMVR.Path();
- omvrmesh.Path.Points = new List();
+ OMVR.FacetedMesh omvrmesh = new()
+ {
+ Faces = [],
+ Prim = prim,
+ Profile = new() { Faces = [], Positions = [] },
+ Path = new() { Points = [] }
+ };
+
var indexer = newPrim.GetVertexIndexer();
for (int i = 0; i < indexer.numPrimFaces; i++)
{
- OMVR.Face oface = new OMVR.Face();
- oface.Vertices = new List();
- oface.Indices = new List();
- oface.TextureFace = prim.Textures.GetFace((uint)i);
+ OMVR.Face oface = new()
+ {
+ Vertices = [],
+ Indices = [],
+ TextureFace = prim.Textures.GetFace((uint)i)
+ };
for (int j = 0; j < indexer.viewerVertices[i].Count; j++)
{
var vert = new OMVR.Vertex();
var m = indexer.viewerVertices[i][j];
- vert.Position = new Vector3(m.v.X, m.v.Y, m.v.Z);
- vert.Normal = new Vector3(m.n.X, m.n.Y, m.n.Z);
+ vert.Position = m.v;
+ vert.Normal = m.n;
vert.TexCoord = new OMV.Vector2(m.uv.U, 1.0f - m.uv.V);
oface.Vertices.Add(vert);
}
@@ -173,7 +277,7 @@ public OMVR.FacetedMesh GenerateFacetedMesh(OMV.Primitive prim, OMVR.DetailLevel
/// routine since all the context for finding teh texture is elsewhere.
///
/// The faceted mesh or null if can't do it
- public OMVR.FacetedMesh GenerateFacetedSculptMesh(OMV.Primitive prim, Bitmap scupltTexture, OMVR.DetailLevel lod)
+ public OMVR.FacetedMesh GenerateFacetedSculptMesh(OMV.Primitive prim, SKBitmap scupltTexture, OMVR.DetailLevel lod)
{
PrimMesher.SculptMesh.SculptType smSculptType;
switch (prim.Sculpt.Type)
@@ -327,16 +431,16 @@ public void TransformTexCoords(List vertices, OMV.Vector3 center, O
private PrimMesher.PrimMesh GeneratePrimMesh(Primitive prim, DetailLevel lod, bool viewerMode)
{
- OMV.Primitive.ConstructionData primData = prim.PrimData;
int sides = 4;
int hollowsides = 4;
- float profileBegin = primData.ProfileBegin;
- float profileEnd = primData.ProfileEnd;
+ float profileBegin = prim.PrimData.ProfileBegin;
+ float profileEnd = prim.PrimData.ProfileEnd;
bool isSphere = false;
- if ((OMV.ProfileCurve)(primData.profileCurve & 0x07) == OMV.ProfileCurve.Circle)
+ OMV.ProfileCurve profileCurve = (OMV.ProfileCurve)(prim.PrimData.profileCurve & 0x07);
+ if (profileCurve == OMV.ProfileCurve.Circle)
{
switch (lod)
{
@@ -351,9 +455,9 @@ private PrimMesher.PrimMesh GeneratePrimMesh(Primitive prim, DetailLevel lod, bo
break;
}
}
- else if ((OMV.ProfileCurve)(primData.profileCurve & 0x07) == OMV.ProfileCurve.EqualTriangle)
+ else if (profileCurve == OMV.ProfileCurve.EqualTriangle)
sides = 3;
- else if ((OMV.ProfileCurve)(primData.profileCurve & 0x07) == OMV.ProfileCurve.HalfCircle)
+ else if (profileCurve == OMV.ProfileCurve.HalfCircle)
{
// half circle, prim is a sphere
isSphere = true;
@@ -373,9 +477,9 @@ private PrimMesher.PrimMesh GeneratePrimMesh(Primitive prim, DetailLevel lod, bo
profileEnd = 0.5f * profileEnd + 0.5f;
}
- if ((OMV.HoleType)primData.ProfileHole == OMV.HoleType.Same)
+ if ((OMV.HoleType)prim.PrimData.ProfileHole == OMV.HoleType.Same)
hollowsides = sides;
- else if ((OMV.HoleType)primData.ProfileHole == OMV.HoleType.Circle)
+ else if (prim.PrimData.ProfileHole == OMV.HoleType.Circle)
{
switch (lod)
{
@@ -390,21 +494,21 @@ private PrimMesher.PrimMesh GeneratePrimMesh(Primitive prim, DetailLevel lod, bo
break;
}
}
- else if ((OMV.HoleType)primData.ProfileHole == OMV.HoleType.Triangle)
+ else if (prim.PrimData.ProfileHole == OMV.HoleType.Triangle)
hollowsides = 3;
- PrimMesher.PrimMesh newPrim = new PrimMesher.PrimMesh(sides, profileBegin, profileEnd, (float)primData.ProfileHollow, hollowsides);
+ PrimMesher.PrimMesh newPrim = new(sides, profileBegin, profileEnd, prim.PrimData.ProfileHollow, hollowsides);
newPrim.viewerMode = viewerMode;
newPrim.sphereMode = isSphere;
- newPrim.holeSizeX = primData.PathScaleX;
- newPrim.holeSizeY = primData.PathScaleY;
- newPrim.pathCutBegin = primData.PathBegin;
- newPrim.pathCutEnd = primData.PathEnd;
- newPrim.topShearX = primData.PathShearX;
- newPrim.topShearY = primData.PathShearY;
- newPrim.radius = primData.PathRadiusOffset;
- newPrim.revolutions = primData.PathRevolutions;
- newPrim.skew = primData.PathSkew;
+ newPrim.holeSizeX = prim.PrimData.PathScaleX;
+ newPrim.holeSizeY = prim.PrimData.PathScaleY;
+ newPrim.pathCutBegin = prim.PrimData.PathBegin;
+ newPrim.pathCutEnd = prim.PrimData.PathEnd;
+ newPrim.topShearX = prim.PrimData.PathShearX;
+ newPrim.topShearY = prim.PrimData.PathShearY;
+ newPrim.radius = prim.PrimData.PathRadiusOffset;
+ newPrim.revolutions = prim.PrimData.PathRevolutions;
+ newPrim.skew = prim.PrimData.PathSkew;
switch (lod)
{
case OMVR.DetailLevel.Low:
@@ -418,20 +522,20 @@ private PrimMesher.PrimMesh GeneratePrimMesh(Primitive prim, DetailLevel lod, bo
break;
}
- if ((primData.PathCurve == OMV.PathCurve.Line) || (primData.PathCurve == OMV.PathCurve.Flexible))
+ if ((prim.PrimData.PathCurve == OMV.PathCurve.Line) || (prim.PrimData.PathCurve == OMV.PathCurve.Flexible))
{
- newPrim.taperX = 1.0f - primData.PathScaleX;
- newPrim.taperY = 1.0f - primData.PathScaleY;
- newPrim.twistBegin = (int)(180 * primData.PathTwistBegin);
- newPrim.twistEnd = (int)(180 * primData.PathTwist);
+ newPrim.taperX = 1.0f - prim.PrimData.PathScaleX;
+ newPrim.taperY = 1.0f - prim.PrimData.PathScaleY;
+ newPrim.twistBegin = (int)(180 * prim.PrimData.PathTwistBegin);
+ newPrim.twistEnd = (int)(180 * prim.PrimData.PathTwist);
newPrim.ExtrudeLinear();
}
else
{
- newPrim.taperX = primData.PathTaperX;
- newPrim.taperY = primData.PathTaperY;
- newPrim.twistBegin = (int)(360 * primData.PathTwistBegin);
- newPrim.twistEnd = (int)(360 * primData.PathTwist);
+ newPrim.taperX = prim.PrimData.PathTaperX;
+ newPrim.taperY = prim.PrimData.PathTaperY;
+ newPrim.twistBegin = (int)(360 * prim.PrimData.PathTwistBegin);
+ newPrim.twistEnd = (int)(360 * prim.PrimData.PathTwist);
newPrim.ExtrudeCircular();
}
diff --git a/OpenMetaverse.Rendering.Meshmerizer/OpenMetaverse.Rendering.Meshmerizer.csproj b/OpenMetaverse.Rendering.Meshmerizer/OpenMetaverse.Rendering.Meshmerizer.csproj
index f3b90a4c..2efdd8d8 100644
--- a/OpenMetaverse.Rendering.Meshmerizer/OpenMetaverse.Rendering.Meshmerizer.csproj
+++ b/OpenMetaverse.Rendering.Meshmerizer/OpenMetaverse.Rendering.Meshmerizer.csproj
@@ -1,19 +1,23 @@

Local
- net48
+ Library
+ OpenMetaverse.Rendering.Meshmerizer
+ Full primitive and sculpt mesh renderer using the Meshmerizer engine for the OpenMetaverse library.
True
- 1591,1574,0419,0618
true
-
-
-
-
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/OpenMetaverse.Rendering.Simple/OpenMetaverse.Rendering.Simple.csproj b/OpenMetaverse.Rendering.Simple/OpenMetaverse.Rendering.Simple.csproj
index 030e6b5d..5724560c 100644
--- a/OpenMetaverse.Rendering.Simple/OpenMetaverse.Rendering.Simple.csproj
+++ b/OpenMetaverse.Rendering.Simple/OpenMetaverse.Rendering.Simple.csproj
@@ -1,14 +1,12 @@

Local
- net48
+ Library
+ OpenMetaverse.Rendering.Simple
+ Simple faceted primitive mesh renderer for the OpenMetaverse library.
True
- 1591,1574,0419,0618
true
-
-
-
diff --git a/OpenMetaverse.Rendering.Simple/SimpleRenderer.cs b/OpenMetaverse.Rendering.Simple/SimpleRenderer.cs
index 370487c0..85eb0709 100644
--- a/OpenMetaverse.Rendering.Simple/SimpleRenderer.cs
+++ b/OpenMetaverse.Rendering.Simple/SimpleRenderer.cs
@@ -25,6 +25,7 @@
*/
using System.Collections.Generic;
+using SkiaSharp;
namespace OpenMetaverse.Rendering
{
@@ -46,7 +47,7 @@ public SimpleMesh GenerateSimpleMesh(Primitive prim, DetailLevel lod)
return mesh;
}
- public SimpleMesh GenerateSimpleSculptMesh(Primitive prim, System.Drawing.Bitmap sculptTexture, DetailLevel lod)
+ public SimpleMesh GenerateSimpleSculptMesh(Primitive prim, SKBitmap sculptTexture, DetailLevel lod)
{
return GenerateSimpleMesh(prim, lod);
}
@@ -65,7 +66,7 @@ public FacetedMesh GenerateFacetedMesh(Primitive prim, DetailLevel lod)
return mesh;
}
- public FacetedMesh GenerateFacetedSculptMesh(Primitive prim, System.Drawing.Bitmap sculptTexture, DetailLevel lod)
+ public FacetedMesh GenerateFacetedSculptMesh(Primitive prim, SKBitmap sculptTexture, DetailLevel lod)
{
return GenerateFacetedMesh(prim, lod);
}
diff --git a/OpenMetaverse.StructuredData/JSON/JsonData.cs b/OpenMetaverse.StructuredData/JSON/JsonData.cs
index d96712b9..e2a8446e 100644
--- a/OpenMetaverse.StructuredData/JSON/JsonData.cs
+++ b/OpenMetaverse.StructuredData/JSON/JsonData.cs
@@ -36,7 +36,6 @@ public class JsonData : IJsonWrapper, IEquatable
private IList> object_list;
#endregion
-
#region Properties
public int Count
{
@@ -136,8 +135,7 @@ ICollection IDictionary.Keys
EnsureDictionary();
IList keys = new List();
- foreach (KeyValuePair entry in
- object_list)
+ foreach (KeyValuePair entry in object_list)
{
keys.Add(entry.Key);
}
@@ -153,8 +151,7 @@ ICollection IDictionary.Values
EnsureDictionary();
IList values = new List();
- foreach (KeyValuePair entry in
- object_list)
+ foreach (KeyValuePair entry in object_list)
{
values.Add(entry.Value);
}
@@ -263,8 +260,7 @@ object IOrderedDictionary.this[int idx]
inst_object[old_entry.Key] = data;
- KeyValuePair entry =
- new KeyValuePair(old_entry.Key, data);
+ KeyValuePair entry = new KeyValuePair(old_entry.Key, data);
object_list[idx] = entry;
}
@@ -304,8 +300,7 @@ public JsonData this[string prop_name]
{
EnsureDictionary();
- KeyValuePair entry =
- new KeyValuePair(prop_name, value);
+ KeyValuePair entry = new KeyValuePair(prop_name, value);
if (inst_object.ContainsKey(prop_name))
{
@@ -348,8 +343,7 @@ public JsonData this[int index]
else
{
KeyValuePair entry = object_list[index];
- KeyValuePair new_entry =
- new KeyValuePair(entry.Key, value);
+ KeyValuePair new_entry = new KeyValuePair(entry.Key, value);
object_list[index] = new_entry;
inst_object[entry.Key] = value;
@@ -497,11 +491,11 @@ public static explicit operator Int32(JsonData data)
public static explicit operator Int64(JsonData data)
{
- if (data.type != JsonType.Long)
+ if (data.type != JsonType.Long && data.type != JsonType.Int)
throw new InvalidCastException(
"Instance of JsonData doesn't hold an int");
- return data.inst_long;
+ return (data.type == JsonType.Long) ? data.inst_long : data.inst_int;
}
public static explicit operator String(JsonData data)
@@ -530,8 +524,7 @@ void IDictionary.Add(object key, object value)
EnsureDictionary().Add(key, data);
- KeyValuePair entry =
- new KeyValuePair((string)key, data);
+ KeyValuePair entry = new KeyValuePair((string)key, data);
object_list.Add(entry);
json = null;
diff --git a/OpenMetaverse.StructuredData/JSON/JsonException.cs b/OpenMetaverse.StructuredData/JSON/JsonException.cs
index 509fb253..cc44377e 100644
--- a/OpenMetaverse.StructuredData/JSON/JsonException.cs
+++ b/OpenMetaverse.StructuredData/JSON/JsonException.cs
@@ -21,29 +21,22 @@ public JsonException() : base()
}
internal JsonException(ParserToken token) :
- base(String.Format(
- "Invalid token '{0}' in input string", token))
+ base(String.Format("Invalid token '{0}' in input string", token))
{
}
- internal JsonException(ParserToken token,
- Exception inner_exception) :
- base(String.Format(
- "Invalid token '{0}' in input string", token),
- inner_exception)
+ internal JsonException(ParserToken token, Exception inner_exception) :
+ base(String.Format("Invalid token '{0}' in input string", token), inner_exception)
{
}
internal JsonException(int c) :
- base(String.Format(
- "Invalid character '{0}' in input string", (char)c))
+ base(String.Format("Invalid character '{0}' in input string", (char)c))
{
}
internal JsonException(int c, Exception inner_exception) :
- base(String.Format(
- "Invalid character '{0}' in input string", (char)c),
- inner_exception)
+ base(String.Format("Invalid character '{0}' in input string", (char)c), inner_exception)
{
}
diff --git a/OpenMetaverse.StructuredData/JSON/JsonMapper.cs b/OpenMetaverse.StructuredData/JSON/JsonMapper.cs
index b4241930..3c6614f8 100644
--- a/OpenMetaverse.StructuredData/JSON/JsonMapper.cs
+++ b/OpenMetaverse.StructuredData/JSON/JsonMapper.cs
@@ -26,14 +26,12 @@ internal struct PropertyMetadata
public Type Type;
}
-
internal struct ArrayMetadata
{
private Type element_type;
private bool is_array;
private bool is_list;
-
public Type ElementType
{
get
@@ -60,7 +58,6 @@ public bool IsList
}
}
-
internal struct ObjectMetadata
{
private Type element_type;
@@ -68,7 +65,6 @@ internal struct ObjectMetadata
private IDictionary properties;
-
public Type ElementType
{
get
@@ -95,7 +91,6 @@ public IDictionary Properties
}
}
-
internal delegate void ExporterFunc(object obj, JsonWriter writer);
public delegate void ExporterFunc(T obj, JsonWriter writer);
@@ -104,7 +99,6 @@ public IDictionary Properties
public delegate IJsonWrapper WrapperFactory();
-
public class JsonMapper
{
#region Fields
@@ -115,30 +109,25 @@ public class JsonMapper
private static IDictionary base_exporters_table;
private static IDictionary custom_exporters_table;
- private static IDictionary> base_importers_table;
- private static IDictionary> custom_importers_table;
+ private static IDictionary> base_importers_table;
+ private static IDictionary> custom_importers_table;
private static IDictionary array_metadata;
- private static readonly object array_metadata_lock = new Object();
+ private static readonly object array_metadata_lock = new object();
- private static IDictionary> conv_ops;
- private static readonly object conv_ops_lock = new Object();
+ private static IDictionary> conv_ops;
+ private static readonly object conv_ops_lock = new object();
private static IDictionary object_metadata;
- private static readonly object object_metadata_lock = new Object();
+ private static readonly object object_metadata_lock = new object();
- private static IDictionary> type_properties;
- private static readonly object type_properties_lock = new Object();
+ private static IDictionary> type_properties;
+ private static readonly object type_properties_lock = new object();
private static JsonWriter static_writer;
- private static readonly object static_writer_lock = new Object();
+ private static readonly object static_writer_lock = new object();
#endregion
-
#region Constructors
static JsonMapper()
{
@@ -147,8 +136,7 @@ static JsonMapper()
array_metadata = new Dictionary();
conv_ops = new Dictionary>();
object_metadata = new Dictionary();
- type_properties = new Dictionary>();
+ type_properties = new Dictionary>();
static_writer = new JsonWriter();
@@ -157,17 +145,14 @@ static JsonMapper()
base_exporters_table = new Dictionary();
custom_exporters_table = new Dictionary();
- base_importers_table = new Dictionary>();
- custom_importers_table = new Dictionary>();
+ base_importers_table = new Dictionary>();
+ custom_importers_table = new Dictionary>();
RegisterBaseExporters();
RegisterBaseImporters();
}
#endregion
-
#region Private Methods
private static void AddArrayMetadata(Type type)
{
@@ -316,8 +301,7 @@ private static MethodInfo GetConvOp(Type t1, Type t2)
if (conv_ops[t1].ContainsKey(t2))
return conv_ops[t1][t2];
- MethodInfo op = t1.GetMethod(
- "op_Implicit", new Type[] { t2 });
+ MethodInfo op = t1.GetMethod("op_Implicit", new Type[] { t2 });
lock (conv_ops_lock)
{
@@ -362,7 +346,6 @@ private static object ReadValue(Type inst_type, JsonReader reader)
reader.Token == JsonToken.String ||
reader.Token == JsonToken.Boolean)
{
-
Type json_type = reader.Value.GetType();
if (value_type.IsAssignableFrom(json_type))
@@ -370,25 +353,17 @@ private static object ReadValue(Type inst_type, JsonReader reader)
// If there's a custom importer that fits, use it
if (custom_importers_table.ContainsKey(json_type) &&
- custom_importers_table[json_type].ContainsKey(
- value_type))
+ custom_importers_table[json_type].ContainsKey(value_type))
{
-
- ImporterFunc importer =
- custom_importers_table[json_type][value_type];
-
+ ImporterFunc importer = custom_importers_table[json_type][value_type];
return importer(reader.Value);
}
// Maybe there's a base importer that works
if (base_importers_table.ContainsKey(json_type) &&
- base_importers_table[json_type].ContainsKey(
- value_type))
+ base_importers_table[json_type].ContainsKey(value_type))
{
-
- ImporterFunc importer =
- base_importers_table[json_type][value_type];
-
+ ImporterFunc importer = base_importers_table[json_type][value_type];
return importer(reader.Value);
}
@@ -400,8 +375,7 @@ private static object ReadValue(Type inst_type, JsonReader reader)
MethodInfo conv_op = GetConvOp(value_type, json_type);
if (conv_op != null)
- return conv_op.Invoke(null,
- new object[] { reader.Value });
+ return conv_op.Invoke(null, new object[] { reader.Value });
// No luck
throw new JsonException(String.Format(
@@ -413,7 +387,6 @@ private static object ReadValue(Type inst_type, JsonReader reader)
if (reader.Token == JsonToken.ArrayStart)
{
-
AddArrayMetadata(inst_type);
ArrayMetadata t_data = array_metadata[inst_type];
@@ -475,8 +448,7 @@ private static object ReadValue(Type inst_type, JsonReader reader)
if (t_data.Properties.ContainsKey(property))
{
- PropertyMetadata prop_data =
- t_data.Properties[property];
+ PropertyMetadata prop_data = t_data.Properties[property];
if (prop_data.IsField)
{
@@ -485,14 +457,10 @@ private static object ReadValue(Type inst_type, JsonReader reader)
}
else
{
- PropertyInfo p_info =
- (PropertyInfo)prop_data.Info;
+ PropertyInfo p_info = (PropertyInfo)prop_data.Info;
if (p_info.CanWrite)
- p_info.SetValue(
- instance,
- ReadValue(prop_data.Type, reader),
- null);
+ p_info.SetValue(instance, ReadValue(prop_data.Type, reader), null);
else
ReadValue(prop_data.Type, reader);
}
@@ -517,25 +485,19 @@ private static object ReadValue(Type inst_type, JsonReader reader)
}
}
- ((IDictionary)instance).Add(
- property, ReadValue(
- t_data.ElementType, reader));
+ ((IDictionary)instance).Add( property, ReadValue(t_data.ElementType, reader));
}
-
}
-
}
return instance;
}
- private static IJsonWrapper ReadValue(WrapperFactory factory,
- JsonReader reader)
+ private static IJsonWrapper ReadValue(WrapperFactory factory, JsonReader reader)
{
reader.Read();
- if (reader.Token == JsonToken.ArrayEnd ||
- reader.Token == JsonToken.Null)
+ if (reader.Token == JsonToken.ArrayEnd || reader.Token == JsonToken.Null)
return null;
IJsonWrapper instance = factory();
@@ -607,8 +569,7 @@ private static IJsonWrapper ReadValue(WrapperFactory factory,
private static void ReadSkip(JsonReader reader)
{
- ToWrapper(
- delegate { return new JsonMockWrapper(); }, reader);
+ ToWrapper(delegate { return new JsonMockWrapper(); }, reader);
}
private static void RegisterBaseExporters()
diff --git a/OpenMetaverse.StructuredData/JSON/JsonOSUTF8Writer.cs b/OpenMetaverse.StructuredData/JSON/JsonOSUTF8Writer.cs
new file mode 100644
index 00000000..d5359524
--- /dev/null
+++ b/OpenMetaverse.StructuredData/JSON/JsonOSUTF8Writer.cs
@@ -0,0 +1,440 @@
+
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.IO;
+using System.Text;
+using OpenMetaverse;
+
+namespace LitJson
+{
+ public class JsonOSUTF8Writer
+ {
+ #region Fields
+ private static NumberFormatInfo number_format;
+
+ private WriterContext context;
+ private Stack ctx_stack;
+ private bool has_reached_end;
+ private byte[] hex_seq;
+ private int indentation;
+ private int indent_value;
+ private osUTF8 sb;
+ private bool ownsb;
+ private bool pretty_print;
+ private bool validate;
+
+ #endregion
+
+ #region Properties
+ public int IndentValue
+ {
+ get { return indent_value; }
+ set
+ {
+ indentation = (indentation / indent_value) * value;
+ indent_value = value;
+ }
+ }
+
+ public bool PrettyPrint
+ {
+ get { return pretty_print; }
+ set { pretty_print = value; }
+ }
+
+ public bool Validate
+ {
+ get { return validate; }
+ set { validate = value; }
+ }
+ #endregion
+
+ #region Constructors
+ static JsonOSUTF8Writer()
+ {
+ number_format = NumberFormatInfo.InvariantInfo;
+ }
+
+ public JsonOSUTF8Writer()
+ {
+ sb = OSUTF8Cached.Acquire();
+ ownsb = true;
+ Init();
+ }
+
+ public JsonOSUTF8Writer(osUTF8 sb)
+ {
+ this.sb = sb;
+ ownsb = false;
+ Init();
+ }
+ #endregion
+
+
+ #region Private Methods
+ private void DoValidation(Condition cond)
+ {
+ if (!context.ExpectingValue)
+ context.Count++;
+
+ if (!validate)
+ return;
+
+ if (has_reached_end)
+ throw new JsonException(
+ "A complete JSON symbol has already been written");
+
+ switch (cond)
+ {
+ case Condition.InArray:
+ if (!context.InArray)
+ throw new JsonException(
+ "Can't close an array here");
+ break;
+
+ case Condition.InObject:
+ if (!context.InObject || context.ExpectingValue)
+ throw new JsonException(
+ "Can't close an object here");
+ break;
+
+ case Condition.NotAProperty:
+ if (context.InObject && !context.ExpectingValue)
+ throw new JsonException(
+ "Expected a property");
+ break;
+
+ case Condition.Property:
+ if (!context.InObject || context.ExpectingValue)
+ throw new JsonException(
+ "Can't add a property here");
+ break;
+
+ case Condition.Value:
+ if (!context.InArray &&
+ (!context.InObject || !context.ExpectingValue))
+ throw new JsonException(
+ "Can't add a value here");
+
+ break;
+ }
+ }
+
+ private void Init()
+ {
+ has_reached_end = false;
+ hex_seq = new byte[4];
+ indentation = 0;
+ indent_value = 4;
+ pretty_print = false;
+ validate = true;
+
+ ctx_stack = new Stack();
+ context = new WriterContext();
+ ctx_stack.Push(context);
+ }
+
+ private void Indent()
+ {
+ if (pretty_print)
+ indentation += indent_value;
+ }
+
+
+ private void Put(string str)
+ {
+ if (pretty_print && !context.ExpectingValue)
+ for (int i = 0; i < indentation; i++)
+ sb.AppendASCII(' ');
+
+ sb.AppendASCII(str);
+ }
+
+ private void Put(char c)
+ {
+ if (pretty_print && !context.ExpectingValue)
+ for (int i = 0; i < indentation; i++)
+ sb.AppendASCII(' ');
+
+ sb.AppendASCII(c);
+ }
+
+ private void PutNewline()
+ {
+ PutNewline(true);
+ }
+
+ private void PutNewline(bool add_comma)
+ {
+ if (add_comma && !context.ExpectingValue &&
+ context.Count > 1)
+ sb.AppendASCII(',');
+
+ if (pretty_print && !context.ExpectingValue)
+ sb.AppendASCII('\n');
+ }
+
+ private void PutString(string str)
+ {
+ if (pretty_print && !context.ExpectingValue)
+ for (int i = 0; i < indentation; i++)
+ sb.AppendASCII(' ');
+
+ sb.AppendASCII('"');
+ for (int i = 0; i < str.Length; i++)
+ {
+ char c = str[i];
+ switch (c)
+ {
+ case '\n':
+ sb.AppendASCII("\\n");
+ break;
+
+ case '\r':
+ sb.AppendASCII("\\r");
+ break;
+
+ case '\t':
+ sb.AppendASCII("\\t");
+ break;
+
+ case '"':
+ case '\\':
+ sb.AppendASCII('\\');
+ sb.AppendASCII(c);
+ break;
+
+ case '\f':
+ sb.AppendASCII("\\f");
+ break;
+
+ case '\b':
+ sb.AppendASCII("\\b");
+ break;
+
+ default:
+ // Default, turn into a \uXXXX sequence
+ if (c >= 32 && c <= 126)
+ sb.AppendASCII(c);
+ else
+ {
+ sb.AppendASCII("\\u");
+ sb.Append(Utils.NibbleToHexUpper((byte)(c >> 12)));
+ sb.Append(Utils.NibbleToHexUpper((byte)(c >> 8)));
+ sb.Append(Utils.NibbleToHexUpper((byte)(c >> 4)));
+ sb.Append(Utils.NibbleToHexUpper((byte)c));
+ }
+ break;
+ }
+ }
+ sb.AppendASCII('"');
+ }
+
+ private void Unindent()
+ {
+ if (pretty_print)
+ indentation -= indent_value;
+ }
+ #endregion
+
+ public override string ToString()
+ {
+ if (sb == null)
+ return String.Empty;
+ if (ownsb)
+ {
+ string ret = sb.ToString();
+ OSUTF8Cached.Release(sb);
+ return ret;
+ }
+ return sb.ToString();
+ }
+
+ public byte[] ToBytes()
+ {
+ if (sb == null)
+ return new byte[0];
+ if (ownsb)
+ return OSUTF8Cached.GetArrayAndRelease(sb);
+ return sb.ToArray();
+ }
+
+ public void Reset()
+ {
+ has_reached_end = false;
+
+ ctx_stack.Clear();
+ context = new WriterContext();
+ ctx_stack.Push(context);
+
+ if (sb != null)
+ sb.Clear();
+ }
+
+ public void Write(bool boolean)
+ {
+ DoValidation(Condition.Value);
+ PutNewline();
+
+ Put(boolean ? "true" : "false");
+
+ context.ExpectingValue = false;
+ }
+
+ public void Write(decimal number)
+ {
+ DoValidation(Condition.Value);
+ PutNewline();
+
+ Put(Convert.ToString(number, number_format));
+
+ context.ExpectingValue = false;
+ }
+
+ public void Write(double number)
+ {
+ DoValidation(Condition.Value);
+ PutNewline();
+
+ string str = Convert.ToString(number, number_format);
+ Put(str);
+
+ if (str.IndexOfAny(new char[] { '.', 'E' }) == -1)
+ sb.AppendASCII(".0");
+
+ context.ExpectingValue = false;
+ }
+
+ public void Write(int number)
+ {
+ DoValidation(Condition.Value);
+ PutNewline();
+
+ Put(Convert.ToString(number, number_format));
+
+ context.ExpectingValue = false;
+ }
+
+ public void Write(long number)
+ {
+ DoValidation(Condition.Value);
+ PutNewline();
+
+ Put(Convert.ToString(number, number_format));
+
+ context.ExpectingValue = false;
+ }
+
+ public void Write(string str)
+ {
+ DoValidation(Condition.Value);
+ PutNewline();
+
+ if (str == null)
+ Put("null");
+ else
+ PutString(str);
+
+ context.ExpectingValue = false;
+ }
+
+ public void Write(ulong number)
+ {
+ DoValidation(Condition.Value);
+ PutNewline();
+
+ Put(Convert.ToString(number, number_format));
+
+ context.ExpectingValue = false;
+ }
+
+ public void WriteArrayEnd()
+ {
+ DoValidation(Condition.InArray);
+ PutNewline(false);
+
+ ctx_stack.Pop();
+ if (ctx_stack.Count == 1)
+ has_reached_end = true;
+ else
+ {
+ context = ctx_stack.Peek();
+ context.ExpectingValue = false;
+ }
+
+ Unindent();
+ Put(']');
+ }
+
+ public void WriteArrayStart()
+ {
+ DoValidation(Condition.NotAProperty);
+ PutNewline();
+
+ Put('[');
+
+ context = new WriterContext();
+ context.InArray = true;
+ ctx_stack.Push(context);
+
+ Indent();
+ }
+
+ public void WriteObjectEnd()
+ {
+ DoValidation(Condition.InObject);
+ PutNewline(false);
+
+ ctx_stack.Pop();
+ if (ctx_stack.Count == 1)
+ has_reached_end = true;
+ else
+ {
+ context = ctx_stack.Peek();
+ context.ExpectingValue = false;
+ }
+
+ Unindent();
+ Put('}');
+ }
+
+ public void WriteObjectStart()
+ {
+ DoValidation(Condition.NotAProperty);
+ PutNewline();
+
+ Put('{');
+
+ context = new WriterContext();
+ context.InObject = true;
+ ctx_stack.Push(context);
+
+ Indent();
+ }
+
+ public void WritePropertyName(string property_name)
+ {
+ DoValidation(Condition.Property);
+ PutNewline();
+
+ PutString(property_name);
+
+ if (pretty_print)
+ {
+ if (property_name.Length > context.Padding)
+ context.Padding = property_name.Length;
+
+ for (int i = context.Padding - property_name.Length;
+ i >= 0; i--)
+ sb.AppendASCII(' ');
+
+ sb.AppendASCII(": ");
+ }
+ else
+ sb.AppendASCII(':');
+
+ context.ExpectingValue = true;
+ }
+ }
+}
diff --git a/OpenMetaverse.StructuredData/JSON/JsonReader.cs b/OpenMetaverse.StructuredData/JSON/JsonReader.cs
index 00549e01..cafd3ee0 100644
--- a/OpenMetaverse.StructuredData/JSON/JsonReader.cs
+++ b/OpenMetaverse.StructuredData/JSON/JsonReader.cs
@@ -13,7 +13,6 @@
using System.Collections.Generic;
using System.IO;
-
namespace LitJson
{
public enum JsonToken
@@ -59,7 +58,6 @@ public class JsonReader
private JsonToken token;
#endregion
-
#region Public Properties
public bool AllowComments
{
@@ -263,17 +261,12 @@ private static void TableAddRow(ParserToken rule)
}
#endregion
-
#region Private Methods
private void ProcessNumber(string number)
{
- if (number.IndexOf('.') != -1 ||
- number.IndexOf('e') != -1 ||
- number.IndexOf('E') != -1)
+ if (number.IndexOfAny(['.','e','E']) >= 0)
{
-
- double n_double;
- if (Double.TryParse(number, out n_double))
+ if (double.TryParse(number, out double n_double))
{
token = JsonToken.Double;
token_value = n_double;
@@ -282,26 +275,23 @@ private void ProcessNumber(string number)
}
}
- int n_int32;
- if (Int32.TryParse(number, out n_int32))
+ if (long.TryParse(number, out long n_int64))
+ {
+ if(n_int64 >= int.MinValue && n_int64 <= int.MaxValue)
{
token = JsonToken.Int;
- token_value = n_int32;
-
- return;
+ token_value = (int)n_int64;
}
-
- long n_int64;
- if (Int64.TryParse(number, out n_int64))
+ else
{
token = JsonToken.Long;
token_value = n_int64;
+ }
return;
}
- ulong n_uint64;
- if (UInt64.TryParse(number, out n_uint64))
+ if (ulong.TryParse(number, out ulong n_uint64))
{
token = JsonToken.Long;
token_value = n_uint64;
diff --git a/OpenMetaverse.StructuredData/JSON/JsonWriter.cs b/OpenMetaverse.StructuredData/JSON/JsonWriter.cs
index 262c0924..1bbbe00a 100644
--- a/OpenMetaverse.StructuredData/JSON/JsonWriter.cs
+++ b/OpenMetaverse.StructuredData/JSON/JsonWriter.cs
@@ -14,7 +14,7 @@
using System.Globalization;
using System.IO;
using System.Text;
-
+using OpenMetaverse;
namespace LitJson
{
@@ -125,40 +125,34 @@ private void DoValidation(Condition cond)
return;
if (has_reached_end)
- throw new JsonException(
- "A complete JSON symbol has already been written");
+ throw new JsonException("A complete JSON symbol has already been written");
switch (cond)
{
case Condition.InArray:
if (!context.InArray)
- throw new JsonException(
- "Can't close an array here");
+ throw new JsonException("Can't close an array here");
break;
case Condition.InObject:
if (!context.InObject || context.ExpectingValue)
- throw new JsonException(
- "Can't close an object here");
+ throw new JsonException("Can't close an object here");
break;
case Condition.NotAProperty:
if (context.InObject && !context.ExpectingValue)
- throw new JsonException(
- "Expected a property");
+ throw new JsonException("Expected a property");
break;
case Condition.Property:
if (!context.InObject || context.ExpectingValue)
- throw new JsonException(
- "Can't add a property here");
+ throw new JsonException("Can't add a property here");
break;
case Condition.Value:
if (!context.InArray &&
(!context.InObject || !context.ExpectingValue))
- throw new JsonException(
- "Can't add a value here");
+ throw new JsonException("Can't add a value here");
break;
}
@@ -178,23 +172,6 @@ private void Init()
ctx_stack.Push(context);
}
- private static void IntToHex(int n, char[] hex)
- {
- int num;
-
- for (int i = 0; i < 4; i++)
- {
- num = n % 16;
-
- if (num < 10)
- hex[3 - i] = (char)('0' + num);
- else
- hex[3 - i] = (char)('A' + (num - 10));
-
- n >>= 4;
- }
- }
-
private void Indent()
{
if (pretty_print)
@@ -218,8 +195,7 @@ private void PutNewline()
private void PutNewline(bool add_comma)
{
- if (add_comma && !context.ExpectingValue &&
- context.Count > 1)
+ if (add_comma && !context.ExpectingValue && context.Count > 1)
writer.Write(',');
if (pretty_print && !context.ExpectingValue)
@@ -228,52 +204,57 @@ private void PutNewline(bool add_comma)
private void PutString(string str)
{
- Put(String.Empty);
+ Put(string.Empty);
writer.Write('"');
-
- int n = str.Length;
- for (int i = 0; i < n; i++)
+ for (int i = 0; i < str.Length; i++)
{
- switch (str[i])
+ char c = str[i];
+ switch (c)
{
case '\n':
writer.Write("\\n");
- continue;
+ break;
case '\r':
writer.Write("\\r");
- continue;
+ break;
case '\t':
writer.Write("\\t");
- continue;
+ break;
case '"':
case '\\':
+ //case '/':
writer.Write('\\');
- writer.Write(str[i]);
- continue;
+ writer.Write(c);
+ break;
case '\f':
writer.Write("\\f");
- continue;
+ break;
case '\b':
writer.Write("\\b");
- continue;
+ break;
+
+ default:
+ // Default, turn into a \uXXXX sequence
+ if (c >= 32 && c <= 126)
+ {
+ writer.Write(c);
+ }
+ else
+ {
+ writer.Write("\\u");
+ writer.Write(Utils.charNibbleToHexUpper((byte)(c >> 12)));
+ writer.Write(Utils.charNibbleToHexUpper((byte)(c >> 8)));
+ writer.Write(Utils.charNibbleToHexUpper((byte)(c >> 4)));
+ writer.Write(Utils.charNibbleToHexUpper((byte)c));
+ }
+ break;
}
-
- if ((int)str[i] >= 32 && (int)str[i] <= 126)
- {
- writer.Write(str[i]);
- continue;
- }
-
- // Default, turn into a \uXXXX sequence
- IntToHex((int)str[i], hex_seq);
- writer.Write("\\u");
- writer.Write(hex_seq);
}
writer.Write('"');
@@ -286,7 +267,6 @@ private void Unindent()
}
#endregion
-
public override string ToString()
{
if (inst_string_builder == null)
@@ -304,7 +284,7 @@ public void Reset()
ctx_stack.Push(context);
if (inst_string_builder != null)
- inst_string_builder.Remove(0, inst_string_builder.Length);
+ inst_string_builder.Clear();
}
public void Write(bool boolean)
@@ -335,8 +315,7 @@ public void Write(double number)
string str = Convert.ToString(number, number_format);
Put(str);
- if (str.IndexOf('.') == -1 &&
- str.IndexOf('E') == -1)
+ if (str.IndexOfAny(['.', 'e' ,'E']) < 0)
writer.Write(".0");
context.ExpectingValue = false;
diff --git a/OpenMetaverse.StructuredData/JSON/OSDJson.cs b/OpenMetaverse.StructuredData/JSON/OSDJson.cs
index bcc34b55..b3bee906 100644
--- a/OpenMetaverse.StructuredData/JSON/OSDJson.cs
+++ b/OpenMetaverse.StructuredData/JSON/OSDJson.cs
@@ -3,8 +3,11 @@
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
+using System.Globalization;
using System.IO;
using System.Text;
+using LitJson;
+using OpenMetaverse;
namespace OpenMetaverse.StructuredData
{
@@ -66,6 +69,7 @@ public static OSD DeserializeJson(JsonData json)
}
}
+ /*
public static string SerializeJsonString(OSD osd)
{
return SerializeJson(osd, false).ToJson();
@@ -80,7 +84,7 @@ public static string SerializeJsonString(OSD osd, bool preserveDefaults)
{
return SerializeJson(osd, preserveDefaults).ToJson();
}
-
+ */
public static void SerializeJsonString(OSD osd, bool preserveDefaults, ref JsonWriter writer)
{
SerializeJson(osd, preserveDefaults).ToJson(writer);
@@ -94,12 +98,16 @@ public static JsonData SerializeJson(OSD osd, bool preserveDefaults)
return new JsonData(osd.AsBoolean());
case OSDType.Integer:
return new JsonData(osd.AsInteger());
+ case OSDType.Long:
+ return new JsonData(osd.AsLong());
case OSDType.Real:
return new JsonData(osd.AsReal());
case OSDType.String:
case OSDType.Date:
case OSDType.URI:
case OSDType.UUID:
+ case OSDType.OSDUTF8:
+ case OSDType.LLSDxml:
return new JsonData(osd.AsString());
case OSDType.Binary:
byte[] binary = osd.AsBinary();
@@ -121,13 +129,7 @@ public static JsonData SerializeJson(OSD osd, bool preserveDefaults)
OSDMap map = (OSDMap)osd;
foreach (KeyValuePair kvp in map)
{
- JsonData data;
-
- if (preserveDefaults)
- data = SerializeJson(kvp.Value, preserveDefaults);
- else
- data = SerializeJsonNoDefaults(kvp.Value);
-
+ JsonData data = preserveDefaults ? SerializeJson(kvp.Value, true) : SerializeJsonNoDefaults(kvp.Value);
if (data != null)
jsonmap[kvp.Key] = data;
}
@@ -154,6 +156,10 @@ private static JsonData SerializeJsonNoDefaults(OSD osd)
return null;
return new JsonData(v);
+
+ case OSDType.Long:
+ return new JsonData(osd.AsLong());
+
case OSDType.Real:
double d = osd.AsReal();
if (d == 0.0d)
@@ -163,6 +169,8 @@ private static JsonData SerializeJsonNoDefaults(OSD osd)
case OSDType.String:
case OSDType.Date:
case OSDType.URI:
+ case OSDType.OSDUTF8:
+ case OSDType.LLSDxml:
string str = osd.AsString();
if (String.IsNullOrEmpty(str))
return null;
@@ -170,13 +178,13 @@ private static JsonData SerializeJsonNoDefaults(OSD osd)
return new JsonData(str);
case OSDType.UUID:
UUID uuid = osd.AsUUID();
- if (uuid == UUID.Zero)
+ if (uuid.IsZero())
return null;
return new JsonData(uuid.ToString());
case OSDType.Binary:
byte[] binary = osd.AsBinary();
- if (binary == Utils.EmptyBytes)
+ if (binary.Length == 0)
return null;
JsonData jsonbinarray = new JsonData();
@@ -207,5 +215,437 @@ private static JsonData SerializeJsonNoDefaults(OSD osd)
return null;
}
}
+
+ public static string SerializeJsonString(OSD osd)
+ {
+ osUTF8 sb = OSUTF8Cached.Acquire();
+ SerializeJson(osd, sb, false);
+ return OSUTF8Cached.GetStringAndRelease(sb);
+ }
+
+ public static byte[] SerializeJsonToBytes(OSD osd)
+ {
+ osUTF8 sb = OSUTF8Cached.Acquire();
+ SerializeJson(osd, sb, false);
+ return OSUTF8Cached.GetArrayAndRelease(sb);
+ }
+
+ public static string SerializeJsonString(OSD osd, bool preserveDefaults)
+ {
+ osUTF8 sb = OSUTF8Cached.Acquire();
+ SerializeJson(osd, sb, preserveDefaults);
+ return OSUTF8Cached.GetStringAndRelease(sb);
+ }
+
+ public static void SerializeJson(OSD osd, osUTF8 sb, bool preserveDefaults)
+ {
+ int i;
+ switch (osd.Type)
+ {
+ case OSDType.Boolean:
+ sb.Append(osd.AsBoolean() ? osUTF8Const.OSUTF8true : osUTF8Const.OSUTF8false);
+ break;
+ case OSDType.Integer:
+ sb.AppendInt(osd.AsInteger());
+ break;
+ case OSDType.Long:
+ sb.AppendInt(osd.AsLong());
+ break;
+ case OSDType.Real:
+ string str = Convert.ToString(osd.AsReal(), NumberFormatInfo.InvariantInfo);
+ sb.AppendASCII(str);
+
+ if (str.IndexOfAny(new char[]{'.','E' }) == -1)
+ sb.AppendASCII(".0");
+ break;
+ case OSDType.String:
+ case OSDType.URI:
+ case OSDType.LLSDxml:
+ appendJsonString(osd.AsString(), sb);
+ break;
+ case OSDType.OSDUTF8:
+ osUTF8 ou8 = ((OSDUTF8)osd).value;
+ appendJsonOSUTF8(ou8, sb);
+ break;
+ case OSDType.UUID:
+ sb.AppendASCII('"');
+ sb.AppendUUID(osd.AsUUID());
+ sb.AppendASCII('"');
+ break;
+ case OSDType.Date:
+ appendJsonString(osd.AsString(), sb);
+ break;
+ case OSDType.Binary:
+ byte[] binary = osd.AsBinary();
+ i = 0;
+ sb.AppendASCII('[');
+ while (i < binary.Length - 1)
+ {
+ sb.AppendInt(binary[i++]);
+ sb.AppendASCII(',');
+ }
+ if (i < binary.Length)
+ sb.AppendInt(binary[i]);
+ sb.AppendASCII(']');
+ break;
+ case OSDType.Array:
+ sb.AppendASCII('[');
+ OSDArray array = (OSDArray)osd;
+ i = 0;
+ while (i < array.Count - 1)
+ {
+ SerializeJson(array[i++], sb, preserveDefaults);
+ sb.AppendASCII(',');
+ }
+ if (i < array.Count)
+ SerializeJson(array[i], sb, preserveDefaults);
+ sb.AppendASCII(']');
+ break;
+ case OSDType.Map:
+ sb.AppendASCII('{');
+ OSDMap map = (OSDMap)osd;
+ i = 0;
+ foreach(KeyValuePair kvp in map)
+ {
+ if(preserveDefaults)
+ {
+ if (i++ > 0)
+ sb.AppendASCII(',');
+ appendJsonString(kvp.Key, sb);
+ sb.AppendASCII(':');
+ SerializeJson(kvp.Value, sb, true);
+ }
+ else
+ SerializeJsonMapNoDefaults(kvp.Key, kvp.Value, ref i, sb);
+ }
+ sb.AppendASCII('}');
+ break;
+ case OSDType.Unknown:
+ default:
+ sb.Append(osUTF8Const.OSUTF8null);
+ break;
+ }
+ }
+
+ public static void SerializeJsonMapNoDefaults(string name, OSD osd, ref int mapcont, osUTF8 sb)
+ {
+ int i;
+ switch (osd.Type)
+ {
+ case OSDType.Boolean:
+ bool ob = osd.AsBoolean();
+ if (ob)
+ {
+ if (mapcont++ > 0)
+ sb.AppendASCII(',');
+ appendJsonString(name, sb);
+ sb.AppendASCII(':');
+ sb.Append(ob ? osUTF8Const.OSUTF8true : osUTF8Const.OSUTF8false);
+ }
+ break;
+ case OSDType.Integer:
+ int oi = osd.AsInteger();
+ if(oi != 0)
+ {
+ if (mapcont++ > 0)
+ sb.AppendASCII(',');
+ appendJsonString(name, sb);
+ sb.AppendASCII(':');
+ sb.AppendInt(oi);
+ }
+ break;
+ case OSDType.Long:
+ long ol = osd.AsLong();
+ if(ol != 0)
+ {
+ if (mapcont++ > 0)
+ sb.AppendASCII(',');
+ appendJsonString(name, sb);
+ sb.AppendASCII(':');
+ sb.AppendInt(ol);
+ }
+ break;
+
+ case OSDType.Real:
+ double od = osd.AsReal();
+ if(od != 0)
+ {
+ if (mapcont++ > 0)
+ sb.AppendASCII(',');
+ appendJsonString(name, sb);
+ sb.AppendASCII(':');
+ string str = Convert.ToString(od, NumberFormatInfo.InvariantInfo);
+ sb.AppendASCII(str);
+
+ if (str.IndexOfAny(new char[] { '.', 'E' }) == -1)
+ sb.AppendASCII(".0");
+ }
+ break;
+ case OSDType.String:
+ case OSDType.URI:
+ case OSDType.LLSDxml:
+ string ostr = osd.AsString();
+ if (!string.IsNullOrEmpty(ostr))
+ {
+ if (mapcont++ > 0)
+ sb.AppendASCII(',');
+ appendJsonString(name, sb);
+ sb.AppendASCII(':');
+ appendJsonString(ostr, sb);
+ }
+ break;
+ case OSDType.OSDUTF8:
+ osUTF8 ou8 = ((OSDUTF8)osd).value;
+ if (ou8 != null && ou8.Length > 0)
+ {
+ if (mapcont++ > 0)
+ sb.AppendASCII(',');
+ appendJsonString(name, sb);
+ sb.AppendASCII(':');
+ appendJsonOSUTF8(ou8, sb);
+ }
+ break;
+ case OSDType.UUID:
+ UUID ou = osd.AsUUID();
+ if(ou.IsNotZero())
+ {
+ if (mapcont++ > 0)
+ sb.AppendASCII(',');
+ appendJsonString(name, sb);
+ sb.AppendASCII(":\"");
+ sb.AppendUUID(ou);
+ sb.AppendASCII('"');
+ }
+ break;
+ case OSDType.Date:
+ if (mapcont++ > 0)
+ sb.AppendASCII(',');
+ appendJsonString(name, sb);
+ sb.AppendASCII(':');
+ appendJsonString(osd.AsString(), sb);
+ break;
+ case OSDType.Binary:
+ byte[] binary = osd.AsBinary();
+ if (mapcont++ > 0)
+ sb.AppendASCII(',');
+ appendJsonString(name, sb);
+ sb.AppendASCII(":[");
+ if (binary != null && binary.Length > 0)
+ {
+ i = 0;
+ while (i < binary.Length - 1)
+ {
+ sb.AppendInt(binary[i++]);
+ sb.AppendASCII(',');
+ }
+ if (i < binary.Length)
+ sb.AppendInt(binary[i]);
+ }
+ sb.AppendASCII(']');
+ break;
+ case OSDType.Array:
+ if (mapcont++ > 0)
+ sb.AppendASCII(",");
+ appendJsonString(name, sb);
+ sb.AppendASCII(":[");
+
+ OSDArray array = (OSDArray)osd;
+ if (array != null && array.Count > 0)
+ {
+ i = 0;
+ while (i < array.Count - 1)
+ {
+ SerializeJson(array[i++], sb, false);
+ sb.AppendASCII(',');
+ }
+ if (i < array.Count)
+ SerializeJson(array[i], sb, false);
+ }
+ sb.AppendASCII(']');
+ break;
+ case OSDType.Map:
+ OSDMap map = (OSDMap)osd;
+ if (map != null && map.Count > 0)
+ {
+ if (mapcont++ > 0)
+ sb.AppendASCII(',');
+ appendJsonString(name, sb);
+ sb.AppendASCII(":{");
+
+ i = 0;
+ foreach (KeyValuePair kvp in map)
+ SerializeJsonMapNoDefaults(kvp.Key, kvp.Value, ref i, sb);
+ sb.AppendASCII('}');
+ }
+ break;
+ case OSDType.Unknown:
+ default:
+ break;
+ }
+ }
+
+ public static void appendJsonString(string str, osUTF8 sb)
+ {
+ sb.AppendASCII('"');
+ for (int i = 0; i < str.Length; i++)
+ {
+ char c = str[i];
+ switch (c)
+ {
+ case '\n':
+ sb.AppendASCII("\\n");
+ break;
+
+ case '\r':
+ sb.AppendASCII("\\r");
+ break;
+
+ case '\t':
+ sb.AppendASCII("\\t");
+ break;
+
+ case '"':
+ //case '/':
+ case '\\':
+ sb.AppendASCII('\\');
+ sb.AppendASCII(c);
+ break;
+
+ case '\f':
+ sb.AppendASCII("\\f");
+ break;
+
+ case '\b':
+ sb.AppendASCII("\\b");
+ break;
+
+ default:
+ // Default, turn into a \uXXXX sequence
+ if (c >= 32 && c <= 126)
+ sb.AppendASCII(c);
+ else
+ {
+ sb.AppendASCII("\\u");
+ sb.Append(Utils.NibbleToHexUpper((byte)(c >> 12)));
+ sb.Append(Utils.NibbleToHexUpper((byte)(c >> 8)));
+ sb.Append(Utils.NibbleToHexUpper((byte)(c >> 4)));
+ sb.Append(Utils.NibbleToHexUpper((byte)c));
+ }
+ break;
+ }
+ }
+ sb.AppendASCII('"');
+ }
+
+ public static void appendJsonOSUTF8(osUTF8 str, osUTF8 sb)
+ {
+ int code;
+ sb.AppendASCII('"');
+ for (int i = 0; i < str.Length; i++)
+ {
+ byte c = str[i];
+ if (c < 0x80)
+ {
+ switch (c)
+ {
+ case (byte)'\n':
+ sb.AppendASCII("\\n");
+ break;
+
+ case (byte)'\r':
+ sb.AppendASCII("\\r");
+ break;
+
+ case (byte)'\t':
+ sb.AppendASCII("\\t");
+ break;
+
+ case (byte)'"':
+ case (byte)'/':
+ case (byte)'\\':
+ sb.AppendASCII('\\');
+ sb.Append(c);
+ break;
+
+ case (byte)'\f':
+ sb.AppendASCII("\\f");
+ break;
+
+ case (byte)'\b':
+ sb.AppendASCII("\\b");
+ break;
+
+ default:
+ // Default, turn into a \uXXXX sequence
+ if (c >= 32 && c <= 126)
+ sb.Append(c);
+ else
+ {
+ sb.AppendASCII("\\u00");
+ sb.Append(Utils.NibbleToHexUpper((byte)(c >> 4)));
+ sb.Append(Utils.NibbleToHexUpper((byte)c));
+ }
+ break;
+ }
+ }
+ if(c < 0xc0)
+ continue; // invalid
+ if (c < 0xe0)
+ {
+ // 2 bytes
+ if (i + 1 >= str.Length)
+ return;
+
+ code = (c & 0x1f) << 6;
+ code |= str[++i] & 0x3f;
+
+ sb.AppendASCII("\\u0");
+ sb.Append(Utils.NibbleToHexUpper((byte)(code >> 8)));
+ sb.Append(Utils.NibbleToHexUpper((byte)(code >> 4)));
+ sb.Append(Utils.NibbleToHexUpper((byte)code));
+ }
+ else if (c < 0xF0)
+ {
+ // 3 bytes
+ if (i + 2 >= str.Length)
+ return;
+
+ // 1110aaaa 10bbbbcc 10ccdddd
+ sb.AppendASCII("\\u");
+ sb.Append(Utils.NibbleToHexUpper(c));
+ c = str[++i];
+ sb.Append(Utils.NibbleToHexUpper((byte)(c >> 2)));
+ code = (c & 3) << 2;
+ c = str[++i];
+ code |= (c & 0x30) >> 4;
+ sb.Append(Utils.NibbleToHexUpper((byte)code));
+ sb.Append(Utils.NibbleToHexUpper(c));
+ }
+ else if (c < 0xf8 )
+ {
+ if (i + 3 >= str.Length)
+ return;
+
+ code = (c & 0x07) << 18;
+ code |= (str[++i] & 0x3f) << 6;
+ code |= (str[++i] & 0x3f) << 6;
+ code |= str[++i] & 0x3f;
+ int a = (code >> 10) + 0xd7c0;
+ code &= (code & 0x3ff) + 0xdc00;
+
+ sb.AppendASCII("\\u");
+ sb.Append(Utils.NibbleToHexUpper((byte)(a >> 12)));
+ sb.Append(Utils.NibbleToHexUpper((byte)(a >> 8)));
+ sb.Append(Utils.NibbleToHexUpper((byte)(a >> 4)));
+ sb.Append(Utils.NibbleToHexUpper((byte)a));
+ sb.AppendASCII("\\u");
+ sb.Append(Utils.NibbleToHexUpper((byte)(code >> 12)));
+ sb.Append(Utils.NibbleToHexUpper((byte)(code >> 8)));
+ sb.Append(Utils.NibbleToHexUpper((byte)(code >> 4)));
+ sb.Append(Utils.NibbleToHexUpper((byte)code));
+ }
+ }
+ sb.AppendASCII('"');
+ }
}
}
diff --git a/OpenMetaverse.StructuredData/LLSD/BinaryLLSD.cs b/OpenMetaverse.StructuredData/LLSD/BinaryLLSD.cs
index 352e9a4c..22a05e3d 100644
--- a/OpenMetaverse.StructuredData/LLSD/BinaryLLSD.cs
+++ b/OpenMetaverse.StructuredData/LLSD/BinaryLLSD.cs
@@ -184,6 +184,7 @@ private static void SerializeLLSDBinaryElement(MemoryStream stream, OSD osd)
stream.Write(stringLengthNetEnd, 0, int32Length);
stream.Write(rawString, 0, rawString.Length);
break;
+ case OSDType.Long:
case OSDType.Binary:
stream.WriteByte(binaryBinaryMarker);
byte[] rawBinary = osd.AsBinary();
diff --git a/OpenMetaverse.StructuredData/LLSD/LLSDxmlEncode.cs b/OpenMetaverse.StructuredData/LLSD/LLSDxmlEncode.cs
index 26db742f..5bfac35c 100644
--- a/OpenMetaverse.StructuredData/LLSD/LLSDxmlEncode.cs
+++ b/OpenMetaverse.StructuredData/LLSD/LLSDxmlEncode.cs
@@ -49,7 +49,7 @@ public static void AddStart(osUTF8 sb, bool addxmlversion = false)
sb.Append(osUTF8Const.XMLllsdStart);
}
- public static osUTF8 Start(int size = 4096, bool addxmlversion = false)
+ public static osUTF8 Start(int size = OSUTF8Cached.MAXDATASIZE, bool addxmlversion = false)
{
osUTF8 sb = OSUTF8Cached.Acquire(size);
if(addxmlversion)
@@ -128,7 +128,7 @@ public static void AddEndArrayAndMap(osUTF8 sb)
// undefined or null
public static void AddUnknownElem(osUTF8 sb)
{
- sb.Append(osUTF8Const.XMLundef);
+ sb.Append(""u8);
}
public static void AddElem(bool e, osUTF8 sb)
@@ -315,7 +315,7 @@ public static void AddElem(double e, osUTF8 sb)
public static void AddElem(UUID e, osUTF8 sb)
{
- if(e == UUID.Zero)
+ if(e.IsZero())
sb.Append(osUTF8Const.XMLuuidEmpty);
else
{
@@ -678,7 +678,7 @@ public static void AddElem(string name, UUID e, osUTF8 sb)
sb.AppendASCII(name);
sb.Append(osUTF8Const.XMLkeyEnd);
- if (e == UUID.Zero)
+ if (e.IsZero())
sb.Append(osUTF8Const.XMLuuidEmpty);
else
{
@@ -810,7 +810,7 @@ public static void AddElem_name(string s, osUTF8 sb)
public static void AddElem_agent_id(UUID e, osUTF8 sb)
{
- if (e == UUID.Zero)
+ if (e.IsZero())
sb.Append(osUTF8Const.XMLelement_agent_id_Empty);
else
{
@@ -822,7 +822,7 @@ public static void AddElem_agent_id(UUID e, osUTF8 sb)
public static void AddElem_owner_id(UUID e, osUTF8 sb)
{
- if (e == UUID.Zero)
+ if (e.IsZero())
sb.Append(osUTF8Const.XMLelement_owner_id_Empty);
else
{
@@ -834,7 +834,7 @@ public static void AddElem_owner_id(UUID e, osUTF8 sb)
public static void AddElem_parent_id(UUID e, osUTF8 sb)
{
- if (e == UUID.Zero)
+ if (e.IsZero())
sb.Append(osUTF8Const.XMLelement_parent_id_Empty);
else
{
@@ -846,7 +846,7 @@ public static void AddElem_parent_id(UUID e, osUTF8 sb)
public static void AddElem_folder_id(UUID e, osUTF8 sb)
{
- if (e == UUID.Zero)
+ if (e.IsZero())
sb.Append(osUTF8Const.XMLelement_folder_id_Empty);
else
{
@@ -856,6 +856,93 @@ public static void AddElem_folder_id(UUID e, osUTF8 sb)
}
}
+ public static void AddElem_asset_id(UUID e, osUTF8 sb)
+ {
+ if (e.IsZero())
+ sb.Append(osUTF8Const.XMLelement_asset_id_Empty);
+ else
+ {
+ sb.Append(osUTF8Const.XMLelement_asset_id_Start);
+ sb.AppendUUID(e);
+ sb.Append(osUTF8Const.XMLuuidEnd);
+ }
+ }
+
+ public static void AddElem_item_id(UUID e, osUTF8 sb)
+ {
+ if (e.IsZero())
+ sb.Append(osUTF8Const.XMLelement_item_id_Empty);
+ else
+ {
+ sb.Append(osUTF8Const.XMLelement_item_id_Start);
+ sb.AppendUUID(e);
+ sb.Append(osUTF8Const.XMLuuidEnd);
+ }
+ }
+
+ public static void AddElem_category_id(UUID e, osUTF8 sb)
+ {
+ if (e.IsZero())
+ sb.Append(osUTF8Const.XMLelement_category_id_Empty);
+ else
+ {
+ sb.Append(osUTF8Const.XMLelement_category_id_Start);
+ sb.AppendUUID(e);
+ sb.Append(osUTF8Const.XMLuuidEnd);
+ }
+ }
+
+ public static void AddElem_creator_id(UUID e, osUTF8 sb)
+ {
+ if (e.IsZero())
+ sb.Append(osUTF8Const.XMLelement_creator_id_Empty);
+ else
+ {
+ sb.Append(osUTF8Const.XMLelement_creator_id_Start);
+ sb.AppendUUID(e);
+ sb.Append(osUTF8Const.XMLuuidEnd);
+ }
+ }
+
+ public static void AddElem_group_id(UUID e, osUTF8 sb)
+ {
+ if (e.IsZero())
+ sb.Append(osUTF8Const.XMLelement_group_id_Empty);
+ else
+ {
+ sb.Append(osUTF8Const.XMLelement_group_id_Start);
+ sb.AppendUUID(e);
+ sb.Append(osUTF8Const.XMLuuidEnd);
+ }
+ }
+
+ public static void AddElem_version(int v, osUTF8 sb)
+ {
+ if (v == 0)
+ sb.Append(osUTF8Const.XMLelement_version_Empty);
+ else
+ {
+ sb.Append(osUTF8Const.XMLelement_version_Start);
+ sb.AppendInt(v);
+ sb.Append(osUTF8Const.XMLintegerEnd);
+ }
+ }
+
+ public static void AddElem_sale_info(int price, byte type, osUTF8 sb)
+ {
+ if(price == 0 && type == 0)
+ sb.Append(osUTF8Const.XMLelement_sale_info_Empty);
+ else
+ {
+ sb.Append(osUTF8Const.XMLelement_sale_info_Start);
+ sb.AppendInt(price);
+ sb.Append(osUTF8Const.XMLelement_sale_info_Mid);
+ sb.AppendInt(type);
+ sb.Append(osUTF8Const.XMLelement_sale_info_End);
+ }
+ }
+
+
public static byte[] ulongToByteArray(ulong uLongValue)
{
return new byte[8]
diff --git a/OpenMetaverse.StructuredData/LLSD/NotationLLSD.cs b/OpenMetaverse.StructuredData/LLSD/NotationLLSD.cs
index 812f57b1..834a99f7 100644
--- a/OpenMetaverse.StructuredData/LLSD/NotationLLSD.cs
+++ b/OpenMetaverse.StructuredData/LLSD/NotationLLSD.cs
@@ -232,7 +232,7 @@ private static OSD DeserializeLLSDNotationElement(TextReader reader)
if (reader.Read(uuidBuf, 0, 36) < 36)
throw new OSDException("Notation LLSD parsing: Unexpected end of stream in UUID.");
UUID lluuid;
- if (!UUID.TryParse(new String(uuidBuf), out lluuid))
+ if (!UUID.TryParse(new String(uuidBuf).AsSpan(), out lluuid))
throw new OSDException("Notation LLSD parsing: Invalid UUID discovered.");
osd = OSD.FromUUID(lluuid);
break;
@@ -470,6 +470,10 @@ private static void SerializeLLSDNotationElement(TextWriter writer, OSD osd)
EscapeCharacter(osd.AsString(), singleQuotesNotationMarker, writer);
writer.Write(singleQuotesNotationMarker);
break;
+ case OSDType.LLSDxml:
+ writer.Write(osd.AsString());
+ break;
+ case OSDType.Long:
case OSDType.Binary:
writer.Write(binaryNotationMarker);
writer.Write("64");
@@ -547,8 +551,7 @@ private static void SerializeLLSDNotationArray(TextWriter writer, OSDArray osdAr
{
writer.Write(arrayBeginNotationMarker);
int lastIndex = osdArray.Count - 1;
-
- for (int idx = 0; idx <= lastIndex; idx++)
+ for (int idx = 0; idx < osdArray.Count; idx++)
{
SerializeLLSDNotationElement(writer, osdArray[idx]);
if (idx < lastIndex)
@@ -608,6 +611,10 @@ private static void SerializeLLSDNotationElementFormatted(TextWriter writer, str
EscapeCharacter(osd.AsString(), singleQuotesNotationMarker, writer);
writer.Write(singleQuotesNotationMarker);
break;
+ case OSDType.LLSDxml:
+ writer.Write(osd.AsString());
+ break;
+ case OSDType.Long:
case OSDType.Binary:
writer.Write(binaryNotationMarker);
writer.Write("64");
@@ -880,7 +887,7 @@ public static int BufferCharactersEqual(TextReader reader, char[] buffer, int of
///
///
///
- ///
+ ///
///
public static string UnescapeCharacter(String s, char d)
{
@@ -959,7 +966,7 @@ public static string UnescapeCharacter(String s, char d)
///
///
///
- ///
+ ///
///
public static string EscapeCharacter(String s, char d)
{
diff --git a/OpenMetaverse.StructuredData/LLSD/XmlLLSD.cs b/OpenMetaverse.StructuredData/LLSD/XmlLLSD.cs
index 929bd5d9..e39afffe 100644
--- a/OpenMetaverse.StructuredData/LLSD/XmlLLSD.cs
+++ b/OpenMetaverse.StructuredData/LLSD/XmlLLSD.cs
@@ -1,1031 +1,870 @@
-/*
- * Copyright (c) 2006-2016, openmetaverse.co
- * All rights reserved.
- *
- * - Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * - Redistributions of source code must retain the above copyright notice, this
- * list of conditions and the following disclaimer.
- * - Neither the name of the openmetaverse.co nor the names
- * of its contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * 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.
- */
-
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Xml;
-using System.Xml.Schema;
-using System.Text;
-using System.Runtime.InteropServices;
-using OpenMetaverse;
-
-namespace OpenMetaverse.StructuredData
-{
- ///
- ///
- ///
- public static partial class OSDParser
- {
- private static XmlSchema XmlSchema;
- private static XmlTextReader XmlTextReader;
- private static string LastXmlErrors = String.Empty;
- private static object XmlValidationLock = new object();
-
- ///
- ///
- ///
- ///
- ///
- public static OSD DeserializeLLSDXml(byte[] xmlData)
- {
- using (MemoryStream ms = new MemoryStream(xmlData))
- using (XmlTextReader xrd = new XmlTextReader(ms))
- return DeserializeLLSDXml(xrd);
- }
-
- public static OSD DeserializeLLSDXml(Stream xmlStream)
- {
- using (XmlTextReader xrd = new XmlTextReader(xmlStream))
- return DeserializeLLSDXml(xrd);
- }
-
- ///
- ///
- ///
- ///
- ///
- public static OSD DeserializeLLSDXml(string xmlData)
- {
- using (StringReader sr = new StringReader(xmlData))
- using (XmlTextReader xrd = new XmlTextReader(sr))
- return DeserializeLLSDXml(xrd);
- }
-
- ///
- ///
- ///
- ///
- ///
- public static OSD DeserializeLLSDXml(XmlTextReader xmlData)
- {
- try
- {
- xmlData.Read();
- SkipWhitespace(xmlData);
-
- xmlData.Read();
- OSD ret = ParseLLSDXmlElement(xmlData);
-
- return ret;
- }
- catch
- {
- return new OSD();
- }
- }
-
- public static byte[] SerializeLLSDXmlToBytes(OSD data, bool formal = false)
- {
- osUTF8 tmp = OSUTF8Cached.Acquire();
- if (formal)
- tmp.Append(osUTF8Const.XMLformalHeaderllsdstart);
- else
- tmp.Append(osUTF8Const.XMLllsdStart);
- SerializeLLSDXmlElement(tmp, data, formal);
- tmp.Append(osUTF8Const.XMLllsdEnd);
-
- return OSUTF8Cached.GetArrayAndRelease(tmp);
- }
-
- public static byte[] SerializeLLSDXmlToBytes(OSD data)
- {
- osUTF8 tmp = OSUTF8Cached.Acquire();
-
- tmp.Append(osUTF8Const.XMLllsdStart);
- SerializeLLSDXmlElement(tmp, data, false);
- tmp.Append(osUTF8Const.XMLllsdEnd);
-
- return OSUTF8Cached.GetArrayAndRelease(tmp);
- }
-
- public static byte[] SerializeInnerLLSDXmlToBytes(OSD data)
- {
- osUTF8 tmp = OSUTF8Cached.Acquire();
- SerializeLLSDXmlElement(tmp, data, false);
-
- return OSUTF8Cached.GetArrayAndRelease(tmp);
- }
-
- public static byte[] SerializeLLSDXmlBytes(OSD data, bool formal = false)
- {
- return SerializeLLSDXmlToBytes(data, formal);
- }
-
- ///
- ///
- ///
- ///
- ///
- public static string SerializeLLSDXmlString(OSD data, bool formal = false)
- {
- StringBuilder sb = osStringBuilderCache.Acquire();
- if (formal)
- sb.Append("");
-
- sb.Append("");
- SerializeLLSDXmlElement(sb, data, formal);
- sb.Append("");
-
- return osStringBuilderCache.GetStringAndRelease(sb);
- }
-
- public static string SerializeLLSDInnerXmlString(OSD data, bool formal = false)
- {
- StringBuilder sb = osStringBuilderCache.Acquire();
- SerializeLLSDXmlElement(sb, data, formal);
-
- return osStringBuilderCache.GetStringAndRelease(sb);
- }
-
- ///
- ///
- ///
- ///
- ///
- public static void SerializeLLSDXmlElement(StringBuilder sb, OSD data, bool formal)
- {
- switch (data.Type)
- {
- case OSDType.Unknown:
- sb.Append("");
- break;
- case OSDType.Boolean:
- if (data.AsBoolean())
- sb.Append("1");
- else
- sb.Append("0");
- break;
- case OSDType.Integer:
- sb.Append("");
- sb.Append(data.AsString());
- sb.Append("");
- break;
- case OSDType.Real:
- sb.Append("");
- sb.Append(data.AsString());
- sb.Append("");
- break;
- case OSDType.String:
- sb.Append("");
- EscapeToXML(data.AsString(), sb);
- sb.Append("");
- break;
- case OSDType.UUID:
- sb.Append("");
- sb.Append(data.AsString());
- sb.Append("");
- break;
- case OSDType.Date:
- sb.Append("");
- sb.Append(data.AsString());
- sb.Append("");
- break;
- case OSDType.URI:
- sb.Append("");
- sb.Append(data.AsString());
- sb.Append("");
- break;
- case OSDType.Binary:
- if (formal)
- sb.Append("");
- else
- sb.Append("");
- base64Encode(data.AsBinary(), sb);
- sb.Append("");
- break;
- case OSDType.Map:
- OSDMap map = (OSDMap)data;
- sb.Append("");
- break;
- case OSDType.Array:
- OSDArray array = (OSDArray)data;
- sb.Append("");
- for (int i = 0; i < array.Count; i++)
- {
- SerializeLLSDXmlElement(sb, array[i], formal);
- }
- sb.Append("");
- break;
- case OSDType.LLSDxml:
- sb.Append(data.AsString());
- break;
- default:
- break;
- }
- }
-
- public static void EscapeToXML(string s, StringBuilder sb)
- {
- char c;
- for (int i = 0; i < s.Length; ++i)
- {
- c = s[i];
- switch (c)
- {
- case '<':
- sb.Append("<");
- break;
- case '>':
- sb.Append(">");
- break;
- case '&':
- sb.Append("&");
- break;
- case '"':
- sb.Append(""");
- break;
- case '\\':
- sb.Append("'");
- break;
- default:
- sb.Append(c);
- break;
- }
- }
- }
-
- public static void EscapeASCIIToXML(osUTF8 ms, string s)
- {
- char c;
- for (int i = 0; i < s.Length; i++)
- {
- c = s[i];
- switch (c)
- {
- case '<':
- ms.Append(osUTF8Const.XMLamp_lt);
- break;
- case '>':
- ms.Append(osUTF8Const.XMLamp_gt);
- break;
- case '&':
- ms.Append(osUTF8Const.XMLamp);
- break;
- case '"':
- ms.Append(osUTF8Const.XMLamp_quot);
- break;
- case '\\':
- ms.Append(osUTF8Const.XMLamp_apos);
- break;
- default:
- ms.AppendASCII(c);
- break;
- }
- }
- }
-
- public static void EscapeToXML(osUTF8 ms, string s)
- {
- char c;
- for (int i = 0; i < s.Length; i++)
- {
- c = s[i];
- switch (c)
- {
- case '<':
- ms.Append(osUTF8Const.XMLamp_lt);
- break;
- case '>':
- ms.Append(osUTF8Const.XMLamp_gt);
- break;
- case '&':
- ms.Append(osUTF8Const.XMLamp);
- break;
- case '"':
- ms.Append(osUTF8Const.XMLamp_quot);
- break;
- case '\\':
- ms.Append(osUTF8Const.XMLamp_apos);
- break;
- default:
- ms.AppendCharBytes(c, ref s, ref i);
- break;
- }
- }
- }
-
- public static void EscapeToXML(osUTF8 ms, osUTF8 s)
- {
- byte c;
- for (int i = 0; i < s.Length; i++)
- {
- c = s[i];
- switch (c)
- {
- case (byte)'<':
- ms.Append(osUTF8Const.XMLamp_lt);
- break;
- case (byte)'>':
- ms.Append(osUTF8Const.XMLamp_gt);
- break;
- case (byte)'&':
- ms.Append(osUTF8Const.XMLamp);
- break;
- case (byte)'"':
- ms.Append(osUTF8Const.XMLamp_quot);
- break;
- case (byte)'\\':
- ms.Append(osUTF8Const.XMLamp_apos);
- break;
- default:
- ms.Append(c);
- break;
- }
- }
- }
-
- public static void SerializeLLSDXmlElement(osUTF8 mb, OSD data, bool formal)
- {
- switch (data.Type)
- {
- case OSDType.Unknown:
- mb.Append(osUTF8Const.XMLundef);
- break;
- case OSDType.Boolean:
- if (data.AsBoolean())
- mb.Append(osUTF8Const.XMLfullbooleanOne);
- else
- mb.Append(osUTF8Const.XMLfullbooleanZero);
- break;
- case OSDType.Integer:
- mb.Append(osUTF8Const.XMLintegerStart);
- mb.AppendInt(data.AsInteger());
- mb.Append(osUTF8Const.XMLintegerEnd);
- break;
- case OSDType.Real:
- mb.Append(osUTF8Const.XMLrealStart);
- mb.AppendASCII(data.ToString());
- mb.Append(osUTF8Const.XMLrealEnd);
- break;
- case OSDType.String:
- mb.Append(osUTF8Const.XMLstringStart);
- EscapeToXML(mb, data);
- mb.Append(osUTF8Const.XMLstringEnd);
- break;
- case OSDType.UUID:
- mb.Append(osUTF8Const.XMLuuidStart);
- mb.AppendUUID(data.AsUUID());
- mb.Append(osUTF8Const.XMLuuidEnd);
- break;
- case OSDType.Date:
- mb.Append(osUTF8Const.XMLdateStart);
- mb.AppendASCII(data.ToString());
- mb.Append(osUTF8Const.XMLdateEnd);
- break;
- case OSDType.URI:
- mb.Append(osUTF8Const.XMLuriStart);
- EscapeToXML(mb, data.ToString());
- mb.Append(osUTF8Const.XMLuriEnd);
- break;
- case OSDType.Binary:
- if (formal)
- mb.Append(osUTF8Const.XMLformalBinaryStart);
- else
- mb.Append(osUTF8Const.XMLbinaryStart);
- base64Encode(data.AsBinary(), mb);
- mb.Append(osUTF8Const.XMLbinaryEnd);
- break;
- case OSDType.Map:
- mb.Append(osUTF8Const.XMLmapStart);
- foreach (KeyValuePair kvp in (OSDMap)data)
- {
- mb.Append(osUTF8Const.XMLkeyStart);
- mb.Append(kvp.Key.ToString());
- mb.Append(osUTF8Const.XMLkeyEnd);
-
- SerializeLLSDXmlElement(mb, kvp.Value, formal);
- }
- mb.Append(osUTF8Const.XMLmapEnd);
- break;
- case OSDType.Array:
- OSDArray array = (OSDArray)data;
- mb.Append(osUTF8Const.XMLarrayStart);
- for (int i = 0; i < array.Count; i++)
- {
- SerializeLLSDXmlElement(mb, array[i], formal);
- }
- mb.Append(osUTF8Const.XMLarrayEnd);
- break;
- case OSDType.LLSDxml:
- mb.Append(data.AsString());
- break;
- default:
- break;
- }
- }
-
- public static unsafe void base64Encode(byte[] data, osUTF8 mb)
- {
- int lenMod3 = data.Length % 3;
- int len = data.Length - lenMod3;
-
- mb.CheckCapacity(4 * data.Length / 3);
-
- fixed (byte* d = data, b64 = osUTF8Const.base64Bytes)
- {
- int i = 0;
- while (i < len)
- {
- mb.Append(b64[d[i] >> 2]);
- mb.Append(b64[((d[i] & 0x03) << 4) | ((d[i + 1] & 0xf0) >> 4)]);
- mb.Append(b64[((d[i + 1] & 0x0f) << 2) | ((d[i + 2] & 0xc0) >> 6)]);
- mb.Append(b64[d[i + 2] & 0x3f]);
- i += 3;
- }
-
- switch (lenMod3)
- {
- case 2:
- {
- i = len;
- mb.Append(b64[d[i] >> 2]);
- mb.Append(b64[((d[i] & 0x03) << 4) | ((d[i + 1] & 0xf0) >> 4)]);
- mb.Append(b64[((d[i + 1] & 0x0f) << 2)]);
- mb.Append((byte)'=');
- break;
- }
- case 1:
- {
- i = len;
- mb.Append(b64[d[i] >> 2]);
- mb.Append(b64[(d[i] & 0x03) << 4]);
- mb.Append((byte)'=');
- mb.Append((byte)'=');
- break;
- }
- }
- }
- }
-
- public static unsafe void base64Encode(byte[] data, int start, int lenght, osUTF8 mb)
- {
- int lenMod3 = lenght % 3;
- int len = lenght - lenMod3;
-
- fixed (byte* d = &data[start], b64 = osUTF8Const.base64Bytes)
- {
- int i = 0;
- while (i < len)
- {
- mb.Append(b64[d[i] >> 2]);
- mb.Append(b64[((d[i] & 0x03) << 4) | ((d[i + 1] & 0xf0) >> 4)]);
- mb.Append(b64[((d[i + 1] & 0x0f) << 2) | ((d[i + 2] & 0xc0) >> 6)]);
- mb.Append(b64[d[i + 2] & 0x3f]);
- i += 3;
- }
-
- switch (lenMod3)
- {
- case 2:
- {
- i = len;
- mb.Append(b64[d[i] >> 2]);
- mb.Append(b64[((d[i] & 0x03) << 4) | ((d[i + 1] & 0xf0) >> 4)]);
- mb.Append(b64[((d[i + 1] & 0x0f) << 2)]);
- mb.Append((byte)'=');
- break;
- }
- case 1:
- {
- i = len;
- mb.Append(b64[d[i] >> 2]);
- mb.Append(b64[(d[i] & 0x03) << 4]);
- mb.Append((byte)'=');
- mb.Append((byte)'=');
- break;
- }
- }
- }
- }
-
- static readonly char[] base64Chars = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O',
- 'P','Q','R','S','T','U','V','W','X','Y','Z','a','b','c','d',
- 'e','f','g','h','i','j','k','l','m','n','o','p','q','r','s',
- 't','u','v','w','x','y','z','0','1','2','3','4','5','6','7',
- '8','9','+','/'};
-
- public static unsafe void base64Encode(byte[] data, StringBuilder sb)
- {
- int lenMod3 = data.Length % 3;
- int len = data.Length - lenMod3;
-
- fixed (byte* d = data)
- {
- fixed (char* b64 = base64Chars)
- {
- int i = 0;
- while (i < len)
- {
- sb.Append(b64[d[i] >> 2]);
- sb.Append(b64[((d[i] & 0x03) << 4) | ((d[i + 1] & 0xf0) >> 4)]);
- sb.Append(b64[((d[i + 1] & 0x0f) << 2) | ((d[i + 2] & 0xc0) >> 6)]);
- sb.Append(b64[d[i + 2] & 0x3f]);
- i += 3;
- }
-
- switch (lenMod3)
- {
- case 2:
- {
- i = len;
- sb.Append(b64[d[i] >> 2]);
- sb.Append(b64[((d[i] & 0x03) << 4) | ((d[i + 1] & 0xf0) >> 4)]);
- sb.Append(b64[((d[i + 1] & 0x0f) << 2)]);
- sb.Append('=');
- break;
- }
- case 1:
- {
- i = len;
- sb.Append(b64[d[i] >> 2]);
- sb.Append(b64[(d[i] & 0x03) << 4]);
- sb.Append("==");
- break;
- }
- }
- }
- }
- }
-
-
- ///
- ///
- ///
- ///
- ///
- ///
- public static bool TryValidateLLSDXml(XmlTextReader xmlData, out string error)
- {
- lock (XmlValidationLock)
- {
- LastXmlErrors = String.Empty;
- XmlTextReader = xmlData;
-
- CreateLLSDXmlSchema();
-
- XmlReaderSettings readerSettings = new XmlReaderSettings();
- readerSettings.ValidationType = ValidationType.Schema;
- readerSettings.Schemas.Add(XmlSchema);
- readerSettings.ValidationEventHandler += new ValidationEventHandler(LLSDXmlSchemaValidationHandler);
-
- using (XmlReader reader = XmlReader.Create(xmlData, readerSettings))
- {
-
- try
- {
- while (reader.Read()) { }
- }
- catch (XmlException)
- {
- error = LastXmlErrors;
- return false;
- }
-
- if (LastXmlErrors == String.Empty)
- {
- error = null;
- return true;
- }
- else
- {
- error = LastXmlErrors;
- return false;
- }
- }
- }
- }
-
- ///
- ///
- ///
- ///
- ///
- private static OSD ParseLLSDXmlElement(XmlTextReader reader)
- {
- SkipWhitespace(reader);
-
- if (reader.NodeType != XmlNodeType.Element)
- throw new OSDException("Expected an element");
-
- string type = reader.LocalName;
- OSD ret;
-
- switch (type)
- {
- case "undef":
- if (reader.IsEmptyElement)
- {
- reader.Read();
- return new OSD();
- }
-
- reader.Read();
- SkipWhitespace(reader);
- ret = new OSD();
- break;
- case "boolean":
- if (reader.IsEmptyElement)
- {
- reader.Read();
- return OSD.FromBoolean(false);
- }
-
- if (reader.Read())
- {
- string s = reader.ReadString().Trim();
-
- if (!String.IsNullOrEmpty(s) && (s == "true" || s == "1"))
- {
- ret = OSD.FromBoolean(true);
- break;
- }
- }
-
- ret = OSD.FromBoolean(false);
- break;
- case "integer":
- if (reader.IsEmptyElement)
- {
- reader.Read();
- return OSD.FromInteger(0);
- }
-
- if (reader.Read())
- {
- int value = 0;
- Int32.TryParse(reader.ReadString().Trim(), out value);
- ret = OSD.FromInteger(value);
- break;
- }
-
- ret = OSD.FromInteger(0);
- break;
- case "real":
- if (reader.IsEmptyElement)
- {
- reader.Read();
- return OSD.FromReal(0d);
- }
-
- if (reader.Read())
- {
- double value = 0d;
- string str = reader.ReadString().Trim().ToLower();
-
- if (str == "nan")
- value = Double.NaN;
- else
- Utils.TryParseDouble(str, out value);
-
- ret = OSD.FromReal(value);
- break;
- }
-
- ret = OSD.FromReal(0d);
- break;
- case "uuid":
- if (reader.IsEmptyElement)
- {
- reader.Read();
- return OSD.FromUUID(UUID.Zero);
- }
-
- if (reader.Read())
- {
- UUID value = UUID.Zero;
- UUID.TryParse(reader.ReadString().Trim(), out value);
- ret = OSD.FromUUID(value);
- break;
- }
-
- ret = OSD.FromUUID(UUID.Zero);
- break;
- case "date":
- if (reader.IsEmptyElement)
- {
- reader.Read();
- return OSD.FromDate(Utils.Epoch);
- }
-
- if (reader.Read())
- {
- DateTime value = Utils.Epoch;
- DateTime.TryParse(reader.ReadString().Trim(), out value);
- ret = OSD.FromDate(value);
- break;
- }
-
- ret = OSD.FromDate(Utils.Epoch);
- break;
- case "string":
- if (reader.IsEmptyElement)
- {
- reader.Read();
- return OSD.FromString(String.Empty);
- }
-
- if (reader.Read())
- {
- ret = OSD.FromString(reader.ReadString());
- break;
- }
-
- ret = OSD.FromString(String.Empty);
- break;
- case "binary":
- if (reader.IsEmptyElement)
- {
- reader.Read();
- return OSD.FromBinary(Utils.EmptyBytes);
- }
-
- if (reader.GetAttribute("encoding") != null && reader.GetAttribute("encoding") != "base64")
- throw new OSDException("Unsupported binary encoding: " + reader.GetAttribute("encoding"));
-
- if (reader.Read())
- {
- try
- {
- ret = OSD.FromBinary(Convert.FromBase64String(reader.ReadString().Trim()));
- break;
- }
- catch (FormatException ex)
- {
- throw new OSDException("Binary decoding exception: " + ex.Message);
- }
- }
-
- ret = OSD.FromBinary(Utils.EmptyBytes);
- break;
- case "uri":
- if (reader.IsEmptyElement)
- {
- reader.Read();
- return OSD.FromUri(new Uri(String.Empty, UriKind.RelativeOrAbsolute));
- }
-
- if (reader.Read())
- {
- ret = OSD.FromUri(new Uri(reader.ReadString(), UriKind.RelativeOrAbsolute));
- break;
- }
-
- ret = OSD.FromUri(new Uri(String.Empty, UriKind.RelativeOrAbsolute));
- break;
- case "map":
- return ParseLLSDXmlMap(reader);
- case "array":
- return ParseLLSDXmlArray(reader);
- default:
- reader.Read();
- ret = null;
- break;
- }
-
- if (reader.NodeType != XmlNodeType.EndElement || reader.LocalName != type)
- {
- throw new OSDException("Expected " + type + ">");
- }
- else
- {
- reader.Read();
- return ret;
- }
- }
-
- private static OSDMap ParseLLSDXmlMap(XmlTextReader reader)
- {
- if (reader.NodeType != XmlNodeType.Element || reader.LocalName != "map")
- throw new NotImplementedException("Expected