mjpeg-player: cosmetic changes to minimise diff

This commit is contained in:
Trek H 2019-12-13 13:53:52 +10:30
parent 47d9130385
commit 9ba9eb14af
1 changed files with 44 additions and 48 deletions

View File

@ -36,6 +36,7 @@ class MTSDemuxer{
init() { init() {
this.pmtParsed = false; this.pmtParsed = false;
this._pmtId = -1; this._pmtId = -1;
this._videoTrack = MTSDemuxer.createTrack('video'); this._videoTrack = MTSDemuxer.createTrack('video');
this._audioTrack = MTSDemuxer.createTrack('audio'); this._audioTrack = MTSDemuxer.createTrack('audio');
this._id3Track = MTSDemuxer.createTrack('id3'); this._id3Track = MTSDemuxer.createTrack('id3');
@ -80,26 +81,22 @@ class MTSDemuxer{
} }
append(data) { append(data) {
let videoTrack = this._videoTrack; let start, len = data.length, pusi, pid, afc, offset, pes,
let videoData = videoTrack.pesData; unknownPIDs = false;
let videoId = videoTrack.pid; let pmtParsed = this.pmtParsed,
videoTrack = this._videoTrack,
let audioTrack = this._audioTrack; audioTrack = this._audioTrack,
let audioData = audioTrack.pesData; id3Track = this._id3Track,
let audioId = audioTrack.pid; videoId = videoTrack.pid,
audioId = audioTrack.pid,
let id3Track = this._id3Track; id3Id = id3Track.pid,
let id3Data = id3Track.pesData; pmtId = this._pmtId,
let id3Id = id3Track.pid; videoData = videoTrack.pesData,
audioData = audioTrack.pesData,
let pmtId = this._pmtId; id3Data = id3Track.pesData,
let pmtParsed = this.pmtParsed; parsePAT = this._parsePAT,
let parsePAT = this._parsePAT; parsePMT = this._parsePMT,
let parsePMT = this._parsePMT; parsePES = this._parsePES;
let parsePES = this._parsePES;
let len = data.length;
let unknownPIDs = false;
const syncOffset = MTSDemuxer._syncOffset(data); const syncOffset = MTSDemuxer._syncOffset(data);
@ -107,7 +104,6 @@ class MTSDemuxer{
len -= (len + syncOffset) % 188; len -= (len + syncOffset) % 188;
// Loop through TS packets. // Loop through TS packets.
let start, offset, pusi, pid, afc, pes;
for (start = syncOffset; start < len; start += 188) { for (start = syncOffset; start < len; start += 188) {
if (data[start] === 0x47) { if (data[start] === 0x47) {
pusi = !!(data[start + 1] & 0x40); pusi = !!(data[start + 1] & 0x40);
@ -242,12 +238,12 @@ class MTSDemuxer{
} }
_parsePMT (data, offset) { _parsePMT (data, offset) {
let pid; let programInfoLength, pid, result = { audio: -1, video: -1, id3: -1},
let result = { audio: -1, video: -1, id3: -1}; sectionLength = (data[offset + 1] & 0x0f) << 8 | data[offset + 2],
let sectionLength = (data[offset + 1] & 0x0f) << 8 | data[offset + 2]; tableEnd = offset + 3 + sectionLength - 4;
let tableEnd = offset + 3 + sectionLength - 4; // To determine where the table is, we have to figure out how
// To determine where the table is, we have to figure out how long the program info descriptors are. // long the program info descriptors are.
let programInfoLength = (data[offset + 10] & 0x0f) << 8 | data[offset + 11]; programInfoLength = (data[offset + 10] & 0x0f) << 8 | data[offset + 11];
// Advance the offset to the first entry in the mapping table. // Advance the offset to the first entry in the mapping table.
offset += 12 + programInfoLength; offset += 12 + programInfoLength;
while (offset < tableEnd) { while (offset < tableEnd) {