Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
F
ffmpeg.wasm-core
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
ffmpeg.wasm-core
Commits
f0a87479
Commit
f0a87479
authored
Feb 13, 2015
by
Luca Barbato
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rtp: h264: Move STAP-A NAL parsing to a function
parent
a9a0b8d6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
61 additions
and
54 deletions
+61
-54
rtpdec_h264.c
libavformat/rtpdec_h264.c
+61
-54
No files found.
libavformat/rtpdec_h264.c
View file @
f0a87479
...
...
@@ -180,6 +180,66 @@ static int sdp_parse_fmtp_config_h264(AVFormatContext *s,
return
0
;
}
static
int
h264_handle_packet_stap_a
(
AVFormatContext
*
ctx
,
AVPacket
*
pkt
,
const
uint8_t
*
buf
,
int
len
)
{
int
pass
=
0
;
int
total_length
=
0
;
uint8_t
*
dst
=
NULL
;
int
ret
;
for
(
pass
=
0
;
pass
<
2
;
pass
++
)
{
const
uint8_t
*
src
=
buf
;
int
src_len
=
len
;
while
(
src_len
>
2
)
{
uint16_t
nal_size
=
AV_RB16
(
src
);
// consume the length of the aggregate
src
+=
2
;
src_len
-=
2
;
if
(
nal_size
<=
src_len
)
{
if
(
pass
==
0
)
{
// counting
total_length
+=
sizeof
(
start_sequence
)
+
nal_size
;
}
else
{
// copying
assert
(
dst
);
memcpy
(
dst
,
start_sequence
,
sizeof
(
start_sequence
));
dst
+=
sizeof
(
start_sequence
);
memcpy
(
dst
,
src
,
nal_size
);
COUNT_NAL_TYPE
(
data
,
*
src
);
dst
+=
nal_size
;
}
}
else
{
av_log
(
ctx
,
AV_LOG_ERROR
,
"nal size exceeds length: %d %d
\n
"
,
nal_size
,
src_len
);
}
// eat what we handled
src
+=
nal_size
;
src_len
-=
nal_size
;
if
(
src_len
<
0
)
av_log
(
ctx
,
AV_LOG_ERROR
,
"Consumed more bytes than we got! (%d)
\n
"
,
src_len
);
}
if
(
pass
==
0
)
{
/* now we know the total size of the packet (with the
* start sequences added) */
if
((
ret
=
av_new_packet
(
pkt
,
total_length
))
<
0
)
return
ret
;
dst
=
pkt
->
data
;
}
else
{
assert
(
dst
-
pkt
->
data
==
total_length
);
}
}
return
0
;
}
// return 0 on packet, no more left, 1 on packet, 1 on partial packet
static
int
h264_handle_packet
(
AVFormatContext
*
ctx
,
PayloadContext
*
data
,
AVStream
*
st
,
AVPacket
*
pkt
,
uint32_t
*
timestamp
,
...
...
@@ -219,60 +279,7 @@ static int h264_handle_packet(AVFormatContext *ctx, PayloadContext *data,
buf
++
;
len
--
;
// first we are going to figure out the total size
{
int
pass
=
0
;
int
total_length
=
0
;
uint8_t
*
dst
=
NULL
;
for
(
pass
=
0
;
pass
<
2
;
pass
++
)
{
const
uint8_t
*
src
=
buf
;
int
src_len
=
len
;
while
(
src_len
>
2
)
{
uint16_t
nal_size
=
AV_RB16
(
src
);
// consume the length of the aggregate
src
+=
2
;
src_len
-=
2
;
if
(
nal_size
<=
src_len
)
{
if
(
pass
==
0
)
{
// counting
total_length
+=
sizeof
(
start_sequence
)
+
nal_size
;
}
else
{
// copying
assert
(
dst
);
memcpy
(
dst
,
start_sequence
,
sizeof
(
start_sequence
));
dst
+=
sizeof
(
start_sequence
);
memcpy
(
dst
,
src
,
nal_size
);
COUNT_NAL_TYPE
(
data
,
*
src
);
dst
+=
nal_size
;
}
}
else
{
av_log
(
ctx
,
AV_LOG_ERROR
,
"nal size exceeds length: %d %d
\n
"
,
nal_size
,
src_len
);
}
// eat what we handled
src
+=
nal_size
;
src_len
-=
nal_size
;
if
(
src_len
<
0
)
av_log
(
ctx
,
AV_LOG_ERROR
,
"Consumed more bytes than we got! (%d)
\n
"
,
src_len
);
}
if
(
pass
==
0
)
{
/* now we know the total size of the packet (with the
* start sequences added) */
if
((
result
=
av_new_packet
(
pkt
,
total_length
))
<
0
)
return
result
;
dst
=
pkt
->
data
;
}
else
{
assert
(
dst
-
pkt
->
data
==
total_length
);
}
}
}
result
=
h264_handle_packet_stap_a
(
ctx
,
pkt
,
buf
,
len
);
break
;
case
25
:
// STAP-B
...
...
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