Commit RELEASE-NOTES line for the wgCategories js variable I added some time ago.
[lhc/web/wiklou.git] / js2 / mwEmbed / libEmbedVideo / binPlayers / omtk-fx / src / as / org / omtk / vorbis / Residue.as
1 /*
2
3 Copyright 2008 Tor-Einar Jarnbjo
4
5 Licensed under the Apache License, Version 2.0 (the "License");
6 you may not use this file except in compliance with the License.
7 You may obtain a copy of the License at
8
9 http://www.apache.org/licenses/LICENSE-2.0
10
11 Unless required by applicable law or agreed to in writing, software
12 distributed under the License is distributed on an "AS IS" BASIS,
13 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 See the License for the specific language governing permissions and
15 limitations under the License.
16
17 */
18
19 package org.omtk.vorbis {
20
21 import flash.errors.IllegalOperationError;
22 import flash.utils.Dictionary;
23 import org.omtk.util.BitByteArray;
24
25 public class Residue {
26
27 private var _begin:int;
28 private var _end:int;
29 private var _partitionSize:int;
30 private var _classifications:int;
31 private var _classBook:int;
32 private var _cascade:Vector.<int>;
33 private var _books:Vector.<Vector.<int>>;
34
35 private var _looks:Dictionary;
36
37
38 public function Residue(source:BitByteArray, header:SetupHeader) {
39
40 _begin = source.readUnsignedBitwiseInt(24);
41 _end = source.readUnsignedBitwiseInt(24);
42 _partitionSize = source.readUnsignedBitwiseInt(24) + 1;
43 _classifications = source.readUnsignedBitwiseInt(6) + 1;
44 _classBook = source.readUnsignedBitwiseInt(8);
45
46 _cascade = new Vector.<int>(classifications);
47
48 var acc:int = 0;
49 var i:int;
50 var j:int;
51
52 for (i = 0; i < classifications; i++) {
53 var highBits:int = 0;
54 var lowBits:int = 0;
55
56 lowBits = source.readUnsignedBitwiseInt(3);
57 if (source.readBit()) {
58 highBits = source.readUnsignedBitwiseInt(5);
59 }
60 _cascade[i] = (highBits << 3) | lowBits;
61 acc += Util.icount(cascade[i]);
62 }
63
64 _books = new Vector.<Vector.<int>>(classifications);
65
66 for (i = 0; i < classifications; i++) {
67 books[i] = new Vector.<int>(8);
68 for (j = 0; j < 8; j++) {
69 if ((cascade[i] & (1 << j)) != 0) {
70 books[i][j] = source.readUnsignedBitwiseInt(8);
71 if (books[i][j] > header.codeBooks.length) {
72 throw new Error(
73 "Reference to invalid codebook entry in residue header.");
74 }
75 }
76 }
77 }
78
79 _looks = new Dictionary();
80 }
81
82 public static function createInstance(source:BitByteArray, header:SetupHeader):Residue {
83
84 var type:int = source.readUnsignedBitwiseInt(16);
85 switch (type) {
86 case 2:
87 return new Residue2(source, header);
88 default:
89 throw new Error("Residue type " + type + " is not supported.");
90 }
91 }
92
93 public function decodeResidue(
94 vorbis:VorbisStream, source:BitByteArray,
95 mode:Mode, ch:int,
96 doNotDecodeFlags:Vector.<Boolean>, vectors0:Vector.<Number>, vectors1:Vector.<Number>):void {
97
98 throw new IllegalOperationError("not implemented");
99 }
100
101
102 public function getLook(stream:VorbisStream, key:Mode):Look {
103 var look:Look = _looks[key];
104 if (look == null) {
105 look = new Look(stream, this, key);
106 _looks[key] = look;
107 }
108 return new Look(stream, this, key);//look;
109 }
110
111
112 public function get begin():int {
113 return _begin;
114 }
115
116 public function get end():int {
117 return _end;
118 }
119
120 public function get partitionSize():int {
121 return _partitionSize;
122 }
123
124 public function get classifications():int {
125 return _classifications;
126 }
127
128 public function get classBook():int {
129 return _classBook;
130 }
131
132 public function get cascade():Vector.<int> {
133 return _cascade;
134 }
135
136 public function get books():Vector.<Vector.<int>> {
137 return _books;
138 }
139
140 }
141
142 }