Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Spectral Band Replication for HE-AAC v1 #13

Open
wants to merge 19 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"presets": ["es2015"],
"plugins": ["multidimensional-array"]
}
14 changes: 14 additions & 0 deletions src/PooledObject.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
export default class PooledObject {
static getFromPool() {
let pool = this._pool || (this._pool = []);
let obj = pool.length ? pool.pop() : new this(...arguments);
obj.init(...arguments)
return obj;
}

init() {}
release() {
let pool = this.constructor._pool || (this.constructor._pool = []);
pool.push(this);
}
}
24 changes: 12 additions & 12 deletions src/adts_demuxer.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
var AV = require('av');
var tables = require('./tables');

var ADTSDemuxer = AV.Demuxer.extend(function() {
AV.Demuxer.register(this);

this.probe = function(stream) {
class ADTSDemuxer extends AV.Demuxer {
static probe(stream) {
var offset = stream.offset;

// attempt to find ADTS syncword
Expand All @@ -17,15 +15,15 @@ var ADTSDemuxer = AV.Demuxer.extend(function() {

stream.seek(offset);
return false;
};
}

this.prototype.init = function() {
init() {
this.bitstream = new AV.Bitstream(this.stream);
};
}

// Reads an ADTS header
// See http://wiki.multimedia.cx/index.php?title=ADTS
this.readHeader = function(stream) {
static readHeader(stream) {
if (stream.read(12) !== 0xfff)
throw new Error('Invalid ADTS header.');

Expand All @@ -49,9 +47,9 @@ var ADTSDemuxer = AV.Demuxer.extend(function() {
stream.advance(16);

return ret;
};
}

this.prototype.readChunk = function() {
readChunk() {
if (!this.sentHeader) {
var offset = this.stream.offset;
var header = ADTSDemuxer.readHeader(this.bitstream);
Expand All @@ -77,7 +75,9 @@ var ADTSDemuxer = AV.Demuxer.extend(function() {
var buffer = this.stream.readSingleBuffer(this.stream.remainingBytes());
this.emit('data', buffer);
}
};
});
}
}

AV.Demuxer.register(ADTSDemuxer);

module.exports = ADTSDemuxer;
Loading