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
1a70d8c1
Commit
1a70d8c1
authored
May 13, 2022
by
NzSN
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Parameter check in ParaEncode.
parent
5e3cc2a9
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
22 additions
and
19 deletions
+22
-19
encWW.js
resources/workers/encWW.js
+6
-0
encGroup.js
src/encGroup.js
+0
-2
paraEncode.js
src/paraEncode.js
+4
-11
paraEncodeSpec.spec.js
tests/paraEncodeSpec.spec.js
+12
-6
No files found.
resources/workers/encWW.js
View file @
1a70d8c1
...
@@ -188,8 +188,14 @@ async function RGBProcessing(frame) {
...
@@ -188,8 +188,14 @@ async function RGBProcessing(frame) {
// Encode RGB Frame into H264 Frame
// Encode RGB Frame into H264 Frame
encoder
.
HEAP8
.
set
(
frame
,
wasmMem
);
encoder
.
HEAP8
.
set
(
frame
,
wasmMem
);
let
st
,
et
;
st
=
new
Date
();
ret
=
encoder
.
_encode
(
wasmMem
,
encBuf
,
ENC_BUF_SIZE
,
size
);
ret
=
encoder
.
_encode
(
wasmMem
,
encBuf
,
ENC_BUF_SIZE
,
size
);
size_
=
encoder
.
getValue
(
size
,
'i32'
);
size_
=
encoder
.
getValue
(
size
,
'i32'
);
et
=
new
Date
();
console
.
log
(
"Encode with elapsed: "
+
(
et
-
st
));
if
(
size_
==
0
)
if
(
size_
==
0
)
return
true
;
return
true
;
...
...
src/encGroup.js
View file @
1a70d8c1
...
@@ -77,8 +77,6 @@ export class H264EncWWGroup extends WWGroup {
...
@@ -77,8 +77,6 @@ export class H264EncWWGroup extends WWGroup {
this
.
#
numOfWorkers
=
numOfWW
;
this
.
#
numOfWorkers
=
numOfWW
;
this
.
#
numOfEncWorker
=
this
.
#
numOfWorkers
-
1
;
this
.
#
numOfEncWorker
=
this
.
#
numOfWorkers
-
1
;
console
.
log
(
this
.
#
numOfEncWorker
);
}
}
// H264EncWWGroup has two types of workers:
// H264EncWWGroup has two types of workers:
...
...
src/paraEncode.js
View file @
1a70d8c1
...
@@ -13,13 +13,13 @@ export class ParaEncoder {
...
@@ -13,13 +13,13 @@ export class ParaEncoder {
#
numOfWW
=
0
;
#
numOfWW
=
0
;
#
codec
=
undefined
;
#
codec
=
undefined
;
#
mode
=
undefined
#
grp
=
null
;
#
grp
=
null
;
#
options
#
options
=
null
;
constructor
(
numOfWW
,
options
)
{
constructor
(
numOfWW
,
options
)
{
if
(
typeof
(
numOfWW
)
!=
'number'
||
if
(
typeof
(
numOfWW
)
!=
'number'
||
options
==
undefined
||
(
!
(
'codec'
in
options
)
||
!
(
options
[
'codec'
]
in
ENC_GRPS
))
||
(
!
(
'codec'
in
options
)
||
!
(
options
[
'codec'
]
in
ENC_GRPS
))
||
!
(
'config'
in
options
))
{
!
(
'config'
in
options
))
{
...
@@ -27,13 +27,14 @@ export class ParaEncoder {
...
@@ -27,13 +27,14 @@ export class ParaEncoder {
"Mismatch types parameter"
,
"paraEncode.js"
);
"Mismatch types parameter"
,
"paraEncode.js"
);
}
}
this
.
#
numOfWW
=
numOfWW
;
this
.
#
numOfWW
=
numOfWW
;
this
.
#
codec
=
options
.
codec
;
this
.
#
codec
=
options
.
codec
;
this
.
#
options
=
options
;
this
.
#
options
=
options
;
}
}
async
init
()
{
async
init
()
{
if
(
this
.
#
options
==
undefined
)
throw
new
TypeError
(
"options can not be undefined"
);
this
.
#
grp
=
new
ENC_GRPS
[
this
.
#
codec
](
this
.
#
grp
=
new
ENC_GRPS
[
this
.
#
codec
](
"ENCs"
,
this
.
#
numOfWW
,
this
.
#
options
.
config
);
"ENCs"
,
this
.
#
numOfWW
,
this
.
#
options
.
config
);
await
this
.
#
grp
.
start
();
await
this
.
#
grp
.
start
();
...
@@ -43,14 +44,6 @@ export class ParaEncoder {
...
@@ -43,14 +44,6 @@ export class ParaEncoder {
return
this
.
#
numOfWW
;
return
this
.
#
numOfWW
;
}
}
codec
()
{
return
this
.
#
codec
;
}
mode
()
{
return
this
.
#
mode
;
}
/* Encode pixels into a video frame, pixels can be generated from
/* Encode pixels into a video frame, pixels can be generated from
* WebGLRenderingContext.readPixels()
* WebGLRenderingContext.readPixels()
* details: https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/readPixels
* details: https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/readPixels
...
...
tests/paraEncodeSpec.spec.js
View file @
1a70d8c1
import
{
ParaEncoder
,
ENCODE_MODE
}
from
"../src/paraEncode.js"
;
import
{
ParaEncoder
,
ENCODE_MODE
}
from
"../src/paraEncode.js"
;
import
{
sleep
}
from
"../src/utils.js"
;
import
{
sleep
,
waitCond
}
from
"../src/utils.js"
;
let
paraEnc
;
let
paraEnc
;
const
RGBAFrameSize
=
1920
*
1080
*
4
;
const
RGBAFrameSize
=
1920
*
1080
*
4
;
beforeEach
(
async
()
=>
{
beforeEach
(
async
()
=>
{
paraEnc
=
new
ParaEncoder
(
11
,
{
let
trNum
=
navigator
.
hardwareConcurrency
;
paraEnc
=
new
ParaEncoder
(
trNum
,
{
codec
:
"H264"
,
codec
:
"H264"
,
config
:
{
config
:
{
encchnlsize
:
RGBAFrameSize
*
10
,
encchnlsize
:
RGBAFrameSize
*
10
,
...
@@ -13,19 +14,24 @@ beforeEach(async () => {
...
@@ -13,19 +14,24 @@ beforeEach(async () => {
}
}
});
});
await
paraEnc
.
init
();
await
paraEnc
.
init
();
});
}
,
20000
);
describe
(
"ParaEncoder"
,
()
=>
{
describe
(
"ParaEncoder"
,
()
=>
{
fit
(
"Encode With ParaEncoder"
,
async
()
=>
{
fit
(
"Encode With ParaEncoder"
,
async
()
=>
{
const
data
=
new
Uint8Array
([...
Array
(
RGBAFrameSize
).
keys
()]);
const
data
=
new
Uint8Array
([...
Array
(
RGBAFrameSize
).
keys
()]);
for
(
let
i
=
0
;
i
<
3000
;
++
i
)
{
let
st
=
new
Date
();
for
(
let
i
=
0
;
i
<
30000
;
++
i
)
{
await
paraEnc
.
encode
(
data
);
await
paraEnc
.
encode
(
data
);
}
}
await
paraEnc
.
encode
(
null
);
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
);
await
sleep
(
3000000
);
},
3000000
);
},
300000
);
});
});
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