Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
F
ffmpeg
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
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
ffmpeg
Commits
3b33dfb2
Commit
3b33dfb2
authored
Feb 13, 2015
by
Luca Barbato
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rtp: h264: Move FU-A NAL parsing to a function
parent
f0a87479
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
39 deletions
+39
-39
rtpdec_h264.c
libavformat/rtpdec_h264.c
+39
-39
No files found.
libavformat/rtpdec_h264.c
View file @
3b33dfb2
...
...
@@ -240,6 +240,44 @@ static int h264_handle_packet_stap_a(AVFormatContext *ctx, AVPacket *pkt,
return
0
;
}
static
int
h264_handle_packet_fu_a
(
AVFormatContext
*
ctx
,
AVPacket
*
pkt
,
const
uint8_t
*
buf
,
int
len
)
{
uint8_t
fu_indicator
,
fu_header
,
start_bit
,
nal_type
,
nal
;
int
ret
;
if
(
len
<
3
)
{
av_log
(
ctx
,
AV_LOG_ERROR
,
"Too short data for FU-A H264 RTP packet
\n
"
);
return
AVERROR_INVALIDDATA
;
}
fu_indicator
=
buf
[
0
];
fu_header
=
buf
[
1
];
start_bit
=
fu_header
>>
7
;
nal_type
=
fu_header
&
0x1f
;
nal
=
fu_indicator
&
0xe0
|
nal_type
;
// skip the fu_indicator and fu_header
buf
+=
2
;
len
-=
2
;
if
(
start_bit
)
{
COUNT_NAL_TYPE
(
data
,
nal_type
);
/* copy in the start sequence, and the reconstructed nal */
if
((
ret
=
av_new_packet
(
pkt
,
sizeof
(
start_sequence
)
+
sizeof
(
nal
)
+
len
))
<
0
)
return
ret
;
memcpy
(
pkt
->
data
,
start_sequence
,
sizeof
(
start_sequence
));
pkt
->
data
[
sizeof
(
start_sequence
)]
=
nal
;
memcpy
(
pkt
->
data
+
sizeof
(
start_sequence
)
+
sizeof
(
nal
),
buf
,
len
);
}
else
{
if
((
ret
=
av_new_packet
(
pkt
,
len
))
<
0
)
return
ret
;
memcpy
(
pkt
->
data
,
buf
,
len
);
}
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
,
...
...
@@ -293,45 +331,7 @@ static int h264_handle_packet(AVFormatContext *ctx, PayloadContext *data,
break
;
case
28
:
// FU-A (fragmented nal)
buf
++
;
len
--
;
// skip the fu_indicator
if
(
len
>
1
)
{
// these are the same as above, we just redo them here for clarity
uint8_t
fu_indicator
=
nal
;
uint8_t
fu_header
=
*
buf
;
uint8_t
start_bit
=
fu_header
>>
7
;
uint8_t
av_unused
end_bit
=
(
fu_header
&
0x40
)
>>
6
;
uint8_t
nal_type
=
fu_header
&
0x1f
;
uint8_t
reconstructed_nal
;
// Reconstruct this packet's true nal; only the data follows.
/* The original nal forbidden bit and NRI are stored in this
* packet's nal. */
reconstructed_nal
=
fu_indicator
&
0xe0
;
reconstructed_nal
|=
nal_type
;
// skip the fu_header
buf
++
;
len
--
;
if
(
start_bit
)
COUNT_NAL_TYPE
(
data
,
nal_type
);
if
(
start_bit
)
{
/* copy in the start sequence, and the reconstructed nal */
if
((
result
=
av_new_packet
(
pkt
,
sizeof
(
start_sequence
)
+
sizeof
(
nal
)
+
len
))
<
0
)
return
result
;
memcpy
(
pkt
->
data
,
start_sequence
,
sizeof
(
start_sequence
));
pkt
->
data
[
sizeof
(
start_sequence
)]
=
reconstructed_nal
;
memcpy
(
pkt
->
data
+
sizeof
(
start_sequence
)
+
sizeof
(
nal
),
buf
,
len
);
}
else
{
if
((
result
=
av_new_packet
(
pkt
,
len
))
<
0
)
return
result
;
memcpy
(
pkt
->
data
,
buf
,
len
);
}
}
else
{
av_log
(
ctx
,
AV_LOG_ERROR
,
"Too short data for FU-A H264 RTP packet
\n
"
);
result
=
AVERROR_INVALIDDATA
;
}
result
=
h264_handle_packet_fu_a
(
ctx
,
pkt
,
buf
,
len
);
break
;
case
30
:
// undefined
...
...
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