Skip to content

Commit

Permalink
tsdemuxer/mp4-remuxer: simplify NAL units data structure
Browse files Browse the repository at this point in the history
use simple array, don't provide length as it is recomputed in mp4-remuxer
  • Loading branch information
mangui committed Mar 2, 2017
1 parent 7c5a7cb commit 3551f39
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/demux/sample-aes.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
return;
}

let curUnits = samples[sampleIndex].units.units;
let curUnits = samples[sampleIndex].units;
for (;; unitIndex++) {
if (unitIndex >= curUnits.length) {
break;
Expand Down
10 changes: 5 additions & 5 deletions src/demux/tsdemuxer.js
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@
}

pushAccesUnit(avcSample,avcTrack) {
if (avcSample.units.units.length && avcSample.frame) {
if (avcSample.units.length && avcSample.frame) {
// only push AVC sample if starting with a keyframe is not mandatory OR
// if keyframe already found in this fragment OR
// keyframe found in last fragment (track.sps) AND
Expand Down Expand Up @@ -643,7 +643,7 @@
}
if(avcSample && push) {
let units = avcSample.units;
units.units.push(unit);
units.push(unit);
}
});
// if last PES packet, push samples
Expand All @@ -654,7 +654,7 @@
}

_createAVCSample(key,pts,dts,debug) {
return { key : key, pts : pts, dts : dts, units : { units : [], length : 0}, debug : debug};
return { key : key, pts : pts, dts : dts, units : [], debug : debug};
}

_insertSampleInOrder(arr, data) {
Expand All @@ -681,12 +681,12 @@
_getLastNalUnit() {
let avcSample = this.avcSample, lastUnit;
// try to fallback to previous sample if current one is empty
if (!avcSample || avcSample.units.units.length === 0) {
if (!avcSample || avcSample.units.length === 0) {
let track = this._avcTrack, samples = track.samples;
avcSample = samples[samples.length-1];
}
if (avcSample) {
let units = avcSample.units.units;
let units = avcSample.units;
lastUnit = units[units.length - 1];
}
return lastUnit;
Expand Down
4 changes: 2 additions & 2 deletions src/remux/dummy-remuxer.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ class DummyRemuxer {
while (track.samples.length) {
avcSample = track.samples.shift();
// loop through AVC sample NALUs
while (avcSample.units.units.length) {
unit = avcSample.units.units.shift();
while (avcSample.units.length) {
unit = avcSample.units.shift();
}
}
//please lint
Expand Down
6 changes: 3 additions & 3 deletions src/remux/mp4-remuxer.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ class MP4Remuxer {

// for (let i = 0; i < track.samples.length; i++) {
// let avcSample = track.samples[i];
// let units = avcSample.units.units;
// let units = avcSample.units;
// let unitsString = '';
// for (let j = 0; j < units.length ; j++) {
// unitsString += units[j].type + ',';
Expand Down Expand Up @@ -257,7 +257,7 @@ class MP4Remuxer {
let nbNalu = 0, naluLen = 0;
for (let i = 0 ; i < nbSamples; i++) {
// compute total/avc sample length and nb of NAL units
let sample = inputSamples[i], units = sample.units.units, nbUnits = units.length, sampleLen = 0;
let sample = inputSamples[i], units = sample.units, nbUnits = units.length, sampleLen = 0;
for (let j = 0; j < nbUnits; j++) {
sampleLen += units[j].data.length;
}
Expand Down Expand Up @@ -297,7 +297,7 @@ class MP4Remuxer {

for (let i = 0 ; i < nbSamples; i++) {
let avcSample = inputSamples[i],
avcSampleUnits = avcSample.units.units,
avcSampleUnits = avcSample.units,
mp4SampleLength = 0,
compositionTimeOffset;
// convert NALU bitstream to MP4 format (prepend NALU with size field)
Expand Down

0 comments on commit 3551f39

Please sign in to comment.