aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/OpenJpeg/bio.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Framework/OpenJpeg/bio.cs')
-rw-r--r--OpenSim/Framework/OpenJpeg/bio.cs162
1 files changed, 0 insertions, 162 deletions
diff --git a/OpenSim/Framework/OpenJpeg/bio.cs b/OpenSim/Framework/OpenJpeg/bio.cs
deleted file mode 100644
index 4a5b321..0000000
--- a/OpenSim/Framework/OpenJpeg/bio.cs
+++ /dev/null
@@ -1,162 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using System.Text;
31
32namespace OpenSim.Framework.OpenJpeg
33{
34 public static class bio
35 {
36 public static opj_bio bio_create()
37 {
38 opj_bio bio = new opj_bio();
39 return bio;
40 }
41
42 public static void bio_destroy(opj_bio bio)
43 {
44 // not needed on C#
45 }
46
47 public static int bio_numbytes(opj_bio bio)
48 {
49 return (bio.bp - bio.start);
50 }
51
52 public static void bio_init_enc(opj_bio bio, sbyte bp, int len)
53 {
54 bio.start = (byte)bp;
55 bio.end = (byte)(bp + (byte)len);
56 bio.bp = (byte)bp;
57 bio.buf = 0;
58 bio.ct = 8;
59 }
60
61 public static void bio_init_dec(opj_bio bio, sbyte bp, int len)
62 {
63 bio.start = (byte)bp;
64 bio.end = (byte)(bp + len);
65 bio.bp = (byte)bp;
66 bio.buf = 0;
67 bio.ct = 0;
68 }
69
70 public static void bio_write(opj_bio bio, int v, int n)
71 {
72 for (int i = n - 1; i >= 0; i--)
73 bio_putbit(bio, (v >> i) & 1);
74 }
75
76 public static int bio_read(opj_bio bio, int n)
77 {
78 int v = 0;
79 for (int i = n - 1; i >= 0; i--)
80 v += bio_getbit(bio) << i;
81
82 return v;
83 }
84
85 public static int bio_flush(opj_bio bio)
86 {
87 bio.ct = 0;
88 if (bio_byteout(bio) != 0)
89 return 1;
90
91 if (bio.ct == 7)
92 {
93 bio.ct = 0;
94 if (bio_byteout(bio) != 0)
95 return 1;
96 }
97 return 0;
98 }
99
100 public static int bio_inalign(opj_bio bio)
101 {
102 bio.ct = 0;
103 if ((bio.buf & 0xff) == 0xff)
104 {
105 if (bio_bytein(bio) != 0)
106 return 1;
107 bio.ct = 0;
108 }
109 return 0;
110 }
111
112 private static int bio_bytein(opj_bio bio)
113 {
114 bio.buf = (bio.buf << 8) & 0xffff;
115 bio.ct = bio.buf == 0xff00 ? 7 : 8;
116 if (bio.bp >= bio.end)
117 return 1;
118 bio.buf |= bio.bp++;
119
120 return 0;
121 }
122
123 private static int bio_byteout(opj_bio bio)
124 {
125 bio.buf = (bio.buf << 8) & 0xffff;
126 bio.ct = bio.buf == 0xff00 ? 7 : 8;
127 if (bio.bp >= bio.end)
128 return 1;
129
130 bio.bp = (byte)(bio.buf >> 8);
131 bio.bp++;
132 return 0;
133 }
134
135 private static void bio_putbit(opj_bio bio, int b)
136 {
137 if (bio.ct == 0)
138 bio_byteout(bio);
139
140 bio.ct--;
141 bio.buf |= (byte)(b << bio.ct);
142 }
143
144 private static int bio_getbit(opj_bio bio)
145 {
146 if (bio.ct == 0)
147 bio_bytein(bio);
148 bio.ct--;
149
150 return (int)((bio.buf >> bio.ct) & 1);
151 }
152 }
153
154 public struct opj_bio
155 {
156 public byte start;
157 public byte end;
158 public byte bp;
159 public uint buf;
160 public int ct;
161 }
162}