|
@@ -2,6 +2,7 @@
|
|
|
/* eslint-disable no-undef */
|
|
|
const CACHE_BUF_LENGTH = 16;
|
|
|
const YUV_BUF_LENGTH = 16;
|
|
|
+let testLastestTime = 0;
|
|
|
if ("function" === typeof importScripts) {
|
|
|
const startTime = Date.now();
|
|
|
// self.importScripts('https://static.xverse.cn/wasm/zx_test_exclusive/v2/libxv265dec.js')
|
|
@@ -336,7 +337,7 @@ if ("function" === typeof importScripts) {
|
|
|
if (this.isSlotEmpty(index)) {
|
|
|
//lost
|
|
|
// debugger
|
|
|
- console.log("[xmedia] return on SLOT EMPTY, prev: %s", prevSeq)
|
|
|
+ console.log("[xmedia] return on SLOT EMPTY, prev: %s", prevSeq);
|
|
|
this.consumerWaitingIDR = true;
|
|
|
this.consumerPrevPts = this.seqAdd(this.consumerPrevPts, 1, 65536);
|
|
|
return true;
|
|
@@ -345,7 +346,10 @@ if ("function" === typeof importScripts) {
|
|
|
if (!this.slotHasMedia(index)) {
|
|
|
// pure meta
|
|
|
// debugger
|
|
|
- console.log("[xmedia] return on meta, prev: %s, cur: %s", mediaArray[index].pts)
|
|
|
+ console.log(
|
|
|
+ "[xmedia] return on meta, prev: %s, cur: %s",
|
|
|
+ mediaArray[index].pts
|
|
|
+ );
|
|
|
this.consumerPrevPts = mediaArray[index].pts;
|
|
|
return true;
|
|
|
}
|
|
@@ -375,7 +379,14 @@ if ("function" === typeof importScripts) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- console.log("[xmedia] return finally, prev: %s, cur: %s", this.prevSeq, this.consumerCurrPts);
|
|
|
+ console.log(
|
|
|
+ "[xmedia] return finally, prev: %s, cur: %s",
|
|
|
+ this.prevSeq,
|
|
|
+ this.consumerCurrPts,
|
|
|
+ Date.now() - testLastestTime
|
|
|
+ );
|
|
|
+
|
|
|
+ testLastestTime = String(Date.now()).slice();
|
|
|
this.consumerPrevPts = this.consumerCurrPts;
|
|
|
|
|
|
this.consumerWaitingIDR = false;
|
|
@@ -428,7 +439,7 @@ if ("function" === typeof importScripts) {
|
|
|
// console.log("procBufItem", index, mediaArray[index]);
|
|
|
|
|
|
if (this.slotHasContent(index) && !needToSkip) {
|
|
|
- console.log("[xmedia] %s ------------ 001", mediaArray[index].pts)
|
|
|
+ console.log("[xmedia] %s ------------ 001", mediaArray[index].pts);
|
|
|
let objData = {
|
|
|
media: mediaArray[index].media,
|
|
|
frameCnt: mediaArray[index].pts,
|
|
@@ -439,30 +450,30 @@ if ("function" === typeof importScripts) {
|
|
|
|
|
|
// -------------------
|
|
|
if (this.checkPktOrderInConsumer(index)) {
|
|
|
- console.log("[xmedia] %s ------------ 002", mediaArray[index].pts)
|
|
|
+ console.log("[xmedia] %s ------------ 002", mediaArray[index].pts);
|
|
|
this.decodeFrame(objData);
|
|
|
}
|
|
|
|
|
|
if (mediaArray[index].isIDR) {
|
|
|
- console.log("[xmedia] %s ------------ 003", mediaArray[index].pts)
|
|
|
+ console.log("[xmedia] %s ------------ 003", mediaArray[index].pts);
|
|
|
// console.log("mediaArray[index].isIDR: this.skipFrameUntilI = false")
|
|
|
this.skipFrameUntilI = false;
|
|
|
}
|
|
|
} else {
|
|
|
- console.log("[xmedia] %s ------------ 004", mediaArray[index].pts)
|
|
|
+ console.log("[xmedia] %s ------------ 004", mediaArray[index].pts);
|
|
|
if (this.slotHasMedia(index)) {
|
|
|
- console.log("[xmedia] %s ------------ 005", mediaArray[index].pts)
|
|
|
+ console.log("[xmedia] %s ------------ 005", mediaArray[index].pts);
|
|
|
//need to skip, waiting I Frame
|
|
|
//dropCache++
|
|
|
this.dropPkt += 1;
|
|
|
// MARKER META1META2
|
|
|
// self.postMessage({ t: MessageEvent.OnlyEmitSignal, meta_only: true, meta: mediaArray[index].meta, metadata: mediaArray[index].metadata })
|
|
|
} else {
|
|
|
- console.log("[xmedia] %s ------------ 006", mediaArray[index].pts)
|
|
|
+ console.log("[xmedia] %s ------------ 006", mediaArray[index].pts);
|
|
|
// no media
|
|
|
if (mediaArray[index].meta != null) {
|
|
|
this.checkPktOrderInConsumer(index);
|
|
|
- console.log("[xmedia] %s ------------ 007", mediaArray[index].pts)
|
|
|
+ console.log("[xmedia] %s ------------ 007", mediaArray[index].pts);
|
|
|
// Still frame
|
|
|
console.log("[send signal]", mediaArray[index].pts);
|
|
|
self.postMessage({
|
|
@@ -472,7 +483,7 @@ if ("function" === typeof importScripts) {
|
|
|
metadata: mediaArray[index].metadata,
|
|
|
});
|
|
|
} else {
|
|
|
- console.log("[xmedia] %s ------------ 008", mediaArray[index].pts)
|
|
|
+ console.log("[xmedia] %s ------------ 008", mediaArray[index].pts);
|
|
|
// Lost_rcv++
|
|
|
// console.log("lost_rcv++: this.skipFrameUntilI = true")
|
|
|
// console.info('[xmedia] FFFFF This code should not be executed!!!!')
|
|
@@ -564,7 +575,7 @@ if ("function" === typeof importScripts) {
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
this.procBufItem(this.readPtr);
|
|
|
|
|
|
// if (this.getNumOfPktToBeDec() > this.prevBufNum) {
|
|
@@ -734,7 +745,7 @@ if ("function" === typeof importScripts) {
|
|
|
printConsole.log("Going to open decoder " + String(Date.now()));
|
|
|
var ret0 = Module._openDecoder(0, decoder_type, LOG_LEVEL_WASM);
|
|
|
if (ret0 == 0) {
|
|
|
- self.decoder.startDecoding(); //开始解码
|
|
|
+ self.decoder.startDecoding(); //开始解码
|
|
|
self.postMessage({
|
|
|
t: MessageEvent.WASMReady,
|
|
|
wasm_ready: true,
|
|
@@ -783,10 +794,10 @@ if ("function" === typeof importScripts) {
|
|
|
// return data.isIDR && media.byteLength !=0
|
|
|
let flag = isIDR && mediaLen != 0;
|
|
|
if(flag){
|
|
|
- console.log('metaverse---------鏄疘Frame');
|
|
|
+ console.log('metaverse---------是IFrame');
|
|
|
}
|
|
|
else{
|
|
|
- console.log('metaverse---------涓嶆槸IFrame');
|
|
|
+ console.log('metaverse---------不是IFrame');
|
|
|
}
|
|
|
return flag;
|
|
|
};
|
|
@@ -795,10 +806,10 @@ if ("function" === typeof importScripts) {
|
|
|
// return !data.isIDR && media.byteLength !=0
|
|
|
let flag = !isIDR && mediaLen != 0;
|
|
|
if(flag){
|
|
|
- console.log('metaverse---------鏄疨Frame');
|
|
|
+ console.log('metaverse---------是PFrame');
|
|
|
}
|
|
|
else{
|
|
|
- console.log('metaverse---------涓嶆槸PFrame');
|
|
|
+ console.log('metaverse---------不是PFrame');
|
|
|
}
|
|
|
return flag;
|
|
|
};
|
|
@@ -807,10 +818,10 @@ if ("function" === typeof importScripts) {
|
|
|
// return media.byteLength == 0 && meta.byteLength !=0
|
|
|
let flag = mediaLen == 0 && metaLen != 0;
|
|
|
if(flag){
|
|
|
- console.log('metaverse---------鏄疨ureMeta');
|
|
|
+ console.log('metaverse---------是PureMeta');
|
|
|
}
|
|
|
else{
|
|
|
- console.log('metaverse---------涓嶆槸PureMeta');
|
|
|
+ console.log('metaverse---------不是PureMeta');
|
|
|
}
|
|
|
return flag;
|
|
|
};
|
|
@@ -836,17 +847,17 @@ if ("function" === typeof importScripts) {
|
|
|
// console.log("[xmedia] 000-2 isIDR: %s, mediaLen: %s", isIDR, mediaLen)
|
|
|
// console.log("[xmedia] 000-3 this.isPFrame(isIDR, mediaLen): %s", this.isPFrame(isIDR, mediaLen))
|
|
|
if (this.isPFrame(isIDR, mediaLen)) {
|
|
|
- console.log("[xmedia] 001: isPFrame TRUE")
|
|
|
+ console.log("[xmedia] 001: isPFrame TRUE");
|
|
|
this.packetsDrop += 1;
|
|
|
// MARKER META1META2
|
|
|
dropPkt = true;
|
|
|
}
|
|
|
if (this.isIFrame(isIDR, mediaLen)) {
|
|
|
- console.log("[xmedia] 002: isIFrame TRUE")
|
|
|
+ console.log("[xmedia] 002: isIFrame TRUE");
|
|
|
this.isFirstFrame = false;
|
|
|
}
|
|
|
}
|
|
|
- console.log("[xmedia] 003: dropPkt: %s", dropPkt)
|
|
|
+ console.log("[xmedia] 003: dropPkt: %s", dropPkt);
|
|
|
return dropPkt;
|
|
|
};
|
|
|
|
|
@@ -865,7 +876,7 @@ if ("function" === typeof importScripts) {
|
|
|
var media;
|
|
|
|
|
|
if (data.cached) {
|
|
|
- media = IFrameCacheBuffer[JSON.stringify(data.position)][key];
|
|
|
+ media = IFrameCacheBuffer[JSON.stringify(data.position)][key];
|
|
|
} else if (data.cacheRequest) {
|
|
|
media = data.data.subarray(data.metaLen, data.metaLen + data.mediaLen);
|
|
|
self.decoder.cacheFrame(data);
|
|
@@ -881,7 +892,7 @@ if ("function" === typeof importScripts) {
|
|
|
if (this.isPFrame(data.isIDR, media.byteLength)) {
|
|
|
// MARKER META1META2
|
|
|
this.packetsDrop += 1;
|
|
|
- console.log('fk1')
|
|
|
+ console.log("fk1");
|
|
|
return;
|
|
|
}
|
|
|
this.prevSeq = this.seqDiff(pts, 1, 65536);
|
|
@@ -931,10 +942,19 @@ if ("function" === typeof importScripts) {
|
|
|
this.packetsLost -= 1;
|
|
|
// this.packetdisorder +=1
|
|
|
}
|
|
|
- console.log("[xmedia] disorder frame received. preSeq: %s, pts: %s", this.prevSeq, pts)
|
|
|
+ console.log(
|
|
|
+ "[xmedia] disorder frame received. preSeq: %s, pts: %s",
|
|
|
+ this.prevSeq,
|
|
|
+ pts
|
|
|
+ );
|
|
|
if (this.seqDiff(this.prevSeq, pts, 65536) < this.getNumOfPktToBeDec()) {
|
|
|
// slot for pts is not handled yet. just put it back:
|
|
|
- console.log('put disorder frame to enc_queue, pkt:%s, prevPts: %s, numOfPktToBeDec: %s', pts, this.prevSeq, this.getNumOfPktToBeDec())
|
|
|
+ console.log(
|
|
|
+ "put disorder frame to enc_queue, pkt:%s, prevPts: %s, numOfPktToBeDec: %s",
|
|
|
+ pts,
|
|
|
+ this.prevSeq,
|
|
|
+ this.getNumOfPktToBeDec()
|
|
|
+ );
|
|
|
} else {
|
|
|
//dropDisorder++
|
|
|
console.error(
|