Commit 8b1268bf authored by Linshizhi's avatar Linshizhi

Add encode parameters to encgroup.

parent 7ae6479d
......@@ -8,12 +8,16 @@ let bridge = null;
let wasmMem = null;
let size = null;
let eof = false;
let elapsed = 0;
/* Video parameter */
let width_ = 1920;
let height_ = 1080;
let frameRate_ = 30;
// Number of bytes for each read
// from channel
const RGBFrameSize = 1920*1080*4;
let RGBFrameSize = width_ * height_ * 4;
let READ_SIZE = RGBFrameSize;
const SLEEP_INTERVAL = 30;
const SPIN_TIMEOUT = 90000;
......@@ -91,6 +95,15 @@ async function init(msg) {
src.enableBlockMode(info.blocksize);
}
if ('width' in info && 'height' in info && 'fps' in info) {
width_ = info.width;
height_ = info.height;
frameRate_ = info.fps;
RGBFrameSize = width_ * height_ * 4;
console.log(width_, height_, frameRate_);
}
// Wait encoder init
while (encoder == null)
await sleep(100);
......@@ -98,7 +111,7 @@ async function init(msg) {
size = encoder._malloc(4);
wasmMem = encoder._malloc(RGBFrameSize);
encodedFrames = encoder._malloc(ENC_BUF_SIZE);
ret = encoder._encodeInit(1920, 1080, 30);
ret = encoder._encodeInit(width_, height_, frameRate_);
isInited = true;
postMessage(makeMsg(MESSAGE_TYPE.INIT, {}));
......
......@@ -54,6 +54,10 @@ export class H264EncWWGroup extends WWGroup {
#blockSize = 0;
#width = 1920;
#height = 1080;
#fps = 30;
/* Precondition: 2 <= options.numOfWW */
constructor(name, numOfWW, options = {}) {
......@@ -65,7 +69,6 @@ export class H264EncWWGroup extends WWGroup {
// Setting options
if (options != undefined) {
if ('max' in options)
this.#maxPayload = options.max;
......@@ -81,6 +84,12 @@ export class H264EncWWGroup extends WWGroup {
if ('blocksize' in options)
this.#blockSize = options.blocksize;
if ('width' in options && 'height' in options && 'fps' in options) {
this.#width = options.width;
this.#height = options.height;
this.#fps = options.fps;
}
this.#numOfWorkers = numOfWW;
this.#numOfEncWorker = this.#numOfWorkers - 1;
}
......@@ -117,7 +126,8 @@ export class H264EncWWGroup extends WWGroup {
await this.#encWorkers[i].start(async ww => {
return await initStrategies(encInit, INIT_FLAGS.NONE, ww,
// encInit parameters
this.#channels, this.#encChannelSize, ww, this.#blockSize);
this.#channels, this.#encChannelSize, ww, this.#blockSize,
this.#width, this.#height, this.#fps)
});
}
} catch (e) {
......@@ -278,7 +288,7 @@ function syncInitStrategy(init, ww) {
return strategy;
}
async function encInit(chnls, size, ww, blockSize) {
async function encInit(chnls, size, ww, blockSize, width, height, fps) {
let channel = new Channel(size);
if (blockSize > 0) {
......@@ -291,6 +301,9 @@ async function encInit(chnls, size, ww, blockSize) {
size: size,
ident: ww.ident(),
blocksize: blockSize,
width: width,
height: height,
fps: fps
}));
chnls.push(channel);
......
......@@ -35,7 +35,7 @@ describe("ParaEncoder", () => {
}, 3000000);
});
describe("ParaEncoder Blockbased", () => {
fdescribe("ParaEncoder Blockbased", () => {
beforeEach(async () => {
let trNum = navigator.hardwareConcurrency;
paraEnc = new ParaEncoder(trNum, {
......@@ -44,6 +44,9 @@ describe("ParaEncoder Blockbased", () => {
encchnlsize: RGBAFrameSize * 10,
bridgechnlsize: Math.pow(2, 25),
blocksize: RGBAFrameSize,
width: 1920,
height: 1080,
fps: 25
}
});
await paraEnc.init();
......
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