Skip to content

Commit

Permalink
Basic implementation of LenPriceTableEncoder
Browse files Browse the repository at this point in the history
  • Loading branch information
glinscott committed Nov 26, 2011
1 parent 862d922 commit 131b86d
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions encoder.js
Original file line number Diff line number Diff line change
Expand Up @@ -252,9 +252,37 @@ function Encoder() {

var kNumLenSpecSymbols = kNumLowLenSymbols + kNumMidLenSymbols;

// Derives from LenEncoder
this.LenPriceTableEncoder = function() {
var prices = [];
var counters = [];
var tableSize;

this.setTableSize = function(tableSize_) {
tableSize = tableSize_;
};

this.updateTable = function(posState) {
this.setPrices(posState, tableSize, prices, posState * kNumLenSymbols);
counters[posState] = tableSize;
};

this.updateTables = function(numPosStates) {
var posState;
for (posState = 0; posState < numPosStates; posState++) {
this.updateTable(posState);
}
};

this.encode = function(rangeEncoder, symbol, posState) {
this.prototype.encode(rangeEncoder, symbol, posState);
if (--counters[posState] === 0) {
this.updateTable(posState);
}
};
};

this.LenPriceTableEncoder.prototype = this.LenEncoder;

this.code = function() {
var progressPosValuePrev = nowPos;
Expand Down

0 comments on commit 131b86d

Please sign in to comment.