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
8bd31b04
Commit
8bd31b04
authored
May 07, 2022
by
Linshizhi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
522461ca
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
11 deletions
+36
-11
interfaces.cc
src/wasms/interfaces.cc
+32
-7
ENCH264Group.spec.js
tests/ENCH264Group.spec.js
+1
-1
wasm-build.sh
wasm-build.sh
+3
-3
No files found.
src/wasms/interfaces.cc
View file @
8bd31b04
...
...
@@ -188,6 +188,7 @@ EM_PORT_API(int) getPackets(uint8_t *buffer, uint32_t size, uint32_t *osize) {
if
(
lastPkt
!=
NULL
&&
lastPkt
->
size
>
remainSize
)
{
memcpy
(
pos
,
lastPkt
->
data
,
lastPkt
->
size
);
pos
+=
lastPkt
->
size
;
remainSize
-=
lastPkt
->
size
;
av_packet_unref
(
lastPkt
);
lastPkt
=
NULL
;
...
...
@@ -198,15 +199,19 @@ EM_PORT_API(int) getPackets(uint8_t *buffer, uint32_t size, uint32_t *osize) {
while
(
true
)
{
ret
=
avcodec_receive_packet
(
cc
,
packet
);
if
(
ret
<
0
)
{
ret
=
1
;
goto
DONE
;
}
printf
(
"WASM Encode: Packet Size %d
\n
"
,
packet
->
size
);
// For video frame avcodec_receive_packet should return
// only once.
if
(
remainSize
>
packet
->
size
)
{
memcpy
(
pos
,
packet
->
data
,
packet
->
size
);
pos
+=
packet
->
size
;
remainSize
-=
packet
->
size
;
}
else
{
lastPkt
=
packet
;
...
...
@@ -217,12 +222,19 @@ EM_PORT_API(int) getPackets(uint8_t *buffer, uint32_t size, uint32_t *osize) {
}
DONE
:
*
osize
=
size
-
remainSize
;
return
ret
;
}
EM_PORT_API
(
int
)
flushEncoder
()
{
if
(
avcodec_send_frame
(
cc
,
NULL
)
<
0
)
{
return
1
;
}
return
0
;
}
///////////////////////////////////////////////////////////////////////////////
// Muxing Parts //
///////////////////////////////////////////////////////////////////////////////
...
...
@@ -252,7 +264,7 @@ public:
void
push
(
int
idx
,
AVPacket
*
packet
)
{
printf
(
"PacketBuffer: Push
\n
"
);
packets
[
idx
].
push
(
packet
);
printf
(
"size of packet in %d is %
d
\n
"
,
idx
,
packets
[
idx
].
size
());
printf
(
"size of packet in %d is %
lu
\n
"
,
idx
,
packets
[
idx
].
size
());
}
AVPacket
*
pop
(
int
idx
)
{
...
...
@@ -329,7 +341,7 @@ EM_PORT_API(int) muxPush(int sIdx, uint8_t *data, size_t size) {
}
int
bufferPackets
()
{
int
ret
=
0
,
total
=
0
;
int
ret
=
0
,
total
=
0
;
AVPacket
*
pkt
=
nullptr
;
while
(
true
)
{
...
...
@@ -415,17 +427,29 @@ void ioCtxInitialize() {
printf
(
"Size of Buffer %d: %ld
\n
"
,
i
,
MuxEnv
::
protos
[
i
].
size
());
// IOProto require 20KB to probe stream informations.
if
(
!
MuxEnv
::
inited
[
i
]
&&
MuxEnv
::
protos
[
i
].
size
()
>
6
5000
)
{
if
(
!
MuxEnv
::
inited
[
i
]
&&
MuxEnv
::
protos
[
i
].
size
()
>
2
5000
)
{
MuxEnv
::
ctxs
[
i
]
=
new
IOCtx
::
InCtx
{
""
,
&
MuxEnv
::
protos
[
i
]};
MuxEnv
::
inited
[
i
]
=
true
;
if
(
!
MuxEnv
::
oCtxInited
)
{
printf
(
"Inited Output
\n
"
);
AVStream
*
s
=
MuxEnv
::
ctxs
[
i
]
->
getStream
([](
AVStream
*
s
)
{
return
s
->
codecpar
->
codec_type
==
AVMEDIA_TYPE_VIDEO
;
});
if
(
s
==
nullptr
)
{
printf
(
"Failed to got stream
\n
"
);
}
printf
(
"Stream got
\n
"
);
printf
(
"New Stream...
\n
"
);
MuxEnv
::
oCtx
.
newStream
(
s
->
codecpar
);
printf
(
"New Stream...Done
\n
"
);
printf
(
"Write Header....
\n
"
);
MuxEnv
::
oCtx
.
writeHeader
();
printf
(
"Write Header....Done
\n
"
);
}
printf
(
"INIT DONE: %d
\n
"
,
i
);
...
...
@@ -473,6 +497,7 @@ int writeToOutput() {
goto
END_LOOP
;
}
else
if
(
p
->
data
==
nullptr
&&
p
->
size
==
0
)
{
MuxEnv
::
finished
[
i
]
=
true
;
goto
MUX_DONE
;
}
...
...
@@ -490,15 +515,15 @@ int writeToOutput() {
}
END_LOOP
:
printf
(
"SKIP %d"
,
i
);
printf
(
"SKIP %d
\n
"
,
i
);
MuxEnv
::
currentChannel
=
i
;
return
0
;
MUX_DONE
:
printf
(
"WASM MUXER DONE
\n
"
);
for
(
int
i
=
0
;
i
<
MuxEnv
::
numOfStreams
;
++
i
)
{
printf
(
"Remain in Proto %d is %
d
\n
"
,
i
,
MuxEnv
::
protos
[
i
].
size
());
printf
(
"Remain in packet buffer %d is %d
\n\n
"
,
MuxEnv
::
pktBuffer
.
size
(
i
));
printf
(
"Remain in Proto %d is %
zu
\n
"
,
i
,
MuxEnv
::
protos
[
i
].
size
());
printf
(
"Remain in packet buffer %d is %d
\n\n
"
,
i
,
MuxEnv
::
pktBuffer
.
size
(
i
));
}
MuxEnv
::
done
=
true
;
MuxEnv
::
oCtx
.
writeTrailer
();
...
...
tests/ENCH264Group.spec.js
View file @
8bd31b04
...
...
@@ -16,7 +16,7 @@ describe("H264EncWWGroup Spec", () => {
const
RGBAFrameSize
=
1920
*
1080
*
4
;
let
grp
=
new
H264EncWWGroup
(
"h264enc"
,
{
numOfWW
:
3
,
numOfWW
:
2
,
encchnlsize
:
RGBAFrameSize
*
10
,
bridgechnlsize
:
Math
.
pow
(
2
,
25
)
});
...
...
wasm-build.sh
View file @
8bd31b04
...
...
@@ -3,7 +3,6 @@
set
-euxo
pipefail
WORKPATH
=
$(
cd
$(
dirname
$0
)
;
pwd
)
DEMO_PATH
=
$WORKPATH
rm
-rf
${
DEMO_PATH
}
/resources/workers/paraencoder.js
${
DEMO_PATH
}
/resources/workers/paraencoder.wasm
...
...
@@ -101,9 +100,10 @@ FLAGS=(
-s
EXPORTED_FUNCTIONS
=
"[_main,_malloc,_free]"
# export main and proxy_main funcs
-s
EXPORTED_RUNTIME_METHODS
=
"[FS, cwrap, ccall, setValue, writeAsciiToMemory, getValue]"
# export preamble funcs
-s
INITIAL_MEMORY
=
268435456
# 64 KB * 1024 * 16 * 2047 = 2146435072 bytes ~= 2 GB, 268435456 =256M, 134,217,728 =128M
-s
ASSERTIONS
=
1
-s
SAFE_HEAP
=
1
-s
ASSERTIONS
=
2
-s
DEMANGLE_SUPPORT
=
1
-s
WARN_UNALIGNED
=
1
-s
SAFE_HEAP
=
1
--pre-js
$WORKPATH
/pre.js
--post-js
$WORKPATH
/post.js
$OPTIM_FLAGS
...
...
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