Commit 7ae6479d authored by Linshizhi's avatar Linshizhi

update

parent 7683665d
...@@ -55,6 +55,14 @@ export class ParaEncoder { ...@@ -55,6 +55,14 @@ export class ParaEncoder {
await this.#grp.dispatch(pixels); await this.#grp.dispatch(pixels);
} }
directWPrepare(size) {
return this.#grp.directWPrepare(size);
}
async directWConfirm() {
return await this.#grp.directWConfirm();
}
/* Does all frames provide to Encoder be encoded. /* Does all frames provide to Encoder be encoded.
* *
* Note: isDone() alwasy return false before eof. */ * Note: isDone() alwasy return false before eof. */
......
...@@ -39,7 +39,7 @@ describe("H264EncWWGroup Spec", () => { ...@@ -39,7 +39,7 @@ describe("H264EncWWGroup Spec", () => {
}, 3000000) }, 3000000)
fit("Encode By H264EncWWGroup with direct write", async () => { it("Encode By H264EncWWGroup with direct write", async () => {
const RGBAFrameSize = 1920*1080*4; const RGBAFrameSize = 1920*1080*4;
let grp = new H264EncWWGroup("h264enc", 8, { let grp = new H264EncWWGroup("h264enc", 8, {
encchnlsize: RGBAFrameSize * 10, encchnlsize: RGBAFrameSize * 10,
...@@ -50,7 +50,7 @@ describe("H264EncWWGroup Spec", () => { ...@@ -50,7 +50,7 @@ describe("H264EncWWGroup Spec", () => {
await grp.start(); await grp.start();
const data = new Uint8Array([...Array(RGBAFrameSize).keys()]); const data = new Uint8Array([...Array(RGBAFrameSize).keys()]);
for (let i = 0; i < 300; ++i) { for (let i = 0; i < 30; ++i) {
let buffers = []; let buffers = [];
while (true) { while (true) {
buffers = grp.directWPrepare(RGBAFrameSize); buffers = grp.directWPrepare(RGBAFrameSize);
......
...@@ -4,20 +4,19 @@ import { sleep, waitCond } from "../src/utils.js"; ...@@ -4,20 +4,19 @@ import { sleep, waitCond } from "../src/utils.js";
let paraEnc; let paraEnc;
const RGBAFrameSize = 1920*1080*4; const RGBAFrameSize = 1920*1080*4;
// beforeEach(async () => {
// let trNum = navigator.hardwareConcurrency;
// paraEnc = new ParaEncoder(trNum, {
// codec: "H264",
// config: {
// encchnlsize: RGBAFrameSize * 10,
// bridgechnlsize: Math.pow(2, 25),
// }
// });
// await paraEnc.init();
// }, 20000);
describe("ParaEncoder", () => { describe("ParaEncoder", () => {
beforeEach(async () => {
let trNum = navigator.hardwareConcurrency;
paraEnc = new ParaEncoder(trNum, {
codec: "H264",
config: {
encchnlsize: RGBAFrameSize * 10,
bridgechnlsize: Math.pow(2, 25),
}
});
await paraEnc.init();
}, 20000);
xit("Encode With ParaEncoder", async () => { xit("Encode With ParaEncoder", async () => {
const data = new Uint8Array([...Array(RGBAFrameSize).keys()]); const data = new Uint8Array([...Array(RGBAFrameSize).keys()]);
...@@ -35,3 +34,48 @@ describe("ParaEncoder", () => { ...@@ -35,3 +34,48 @@ describe("ParaEncoder", () => {
}, 3000000); }, 3000000);
}); });
describe("ParaEncoder Blockbased", () => {
beforeEach(async () => {
let trNum = navigator.hardwareConcurrency;
paraEnc = new ParaEncoder(trNum, {
codec: "H264",
config: {
encchnlsize: RGBAFrameSize * 10,
bridgechnlsize: Math.pow(2, 25),
blocksize: RGBAFrameSize,
}
});
await paraEnc.init();
}, 20000);
it("Encode With DirectWrite", async () => {
const data = new Uint8Array([...Array(RGBAFrameSize).keys()]);
let st = new Date();
for (let i = 0; i < 300; ++i) {
let buffers = [];
while (true) {
buffers = paraEnc.directWPrepare(RGBAFrameSize);
if (buffers.length > 0)
break;
else
await sleep(30);
}
expect(buffers.length).toBe(1);
buffers[0].set(data, 0);
await paraEnc.directWConfirm();
}
await paraEnc.encode(null);
await waitCond(() => paraEnc.isDone(), 3000000, 300);
let et = new Date();
let diff = (et - st) / 1000;
console.log("Total Elapsed time is " + diff);
}, 3000000);
})
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment