Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
P
ParaEncode
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Linshizhi
ParaEncode
Commits
8b1268bf
Commit
8b1268bf
authored
May 17, 2022
by
Linshizhi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add encode parameters to encgroup.
parent
7ae6479d
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
7 deletions
+36
-7
encWW.js
resources/workers/encWW.js
+16
-3
encGroup.js
src/encGroup.js
+16
-3
paraEncodeSpec.spec.js
tests/paraEncodeSpec.spec.js
+4
-1
No files found.
resources/workers/encWW.js
View file @
8b1268bf
...
...
@@ -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
,
{}));
...
...
src/encGroup.js
View file @
8b1268bf
...
...
@@ -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
);
...
...
tests/paraEncodeSpec.spec.js
View file @
8b1268bf
...
...
@@ -35,7 +35,7 @@ describe("ParaEncoder", () => {
},
3000000
);
});
describe
(
"ParaEncoder Blockbased"
,
()
=>
{
f
describe
(
"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
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment