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
a9a0b8d6
Commit
a9a0b8d6
authored
Feb 13, 2015
by
Luca Barbato
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rtp: h264: Move parse_sprop_parameter_sets parsing to a function
parent
b8df0b71
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
55 additions
and
45 deletions
+55
-45
rtpdec_h264.c
libavformat/rtpdec_h264.c
+55
-45
No files found.
libavformat/rtpdec_h264.c
View file @
a9a0b8d6
...
...
@@ -93,6 +93,60 @@ static void parse_profile_level_id(AVFormatContext *s,
h264_data
->
level_idc
=
level_idc
;
}
static
int
parse_sprop_parameter_sets
(
AVFormatContext
*
s
,
AVCodecContext
*
codec
,
char
*
value
)
{
char
base64packet
[
1024
];
uint8_t
decoded_packet
[
1024
];
int
packet_size
;
while
(
*
value
)
{
char
*
dst
=
base64packet
;
while
(
*
value
&&
*
value
!=
','
&&
(
dst
-
base64packet
)
<
sizeof
(
base64packet
)
-
1
)
{
*
dst
++
=
*
value
++
;
}
*
dst
++
=
'\0'
;
if
(
*
value
==
','
)
value
++
;
packet_size
=
av_base64_decode
(
decoded_packet
,
base64packet
,
sizeof
(
decoded_packet
));
if
(
packet_size
>
0
)
{
uint8_t
*
dest
=
av_malloc
(
packet_size
+
sizeof
(
start_sequence
)
+
codec
->
extradata_size
+
FF_INPUT_BUFFER_PADDING_SIZE
);
if
(
!
dest
)
{
av_log
(
s
,
AV_LOG_ERROR
,
"Unable to allocate memory for extradata!
\n
"
);
return
AVERROR
(
ENOMEM
);
}
if
(
codec
->
extradata_size
)
{
memcpy
(
dest
,
codec
->
extradata
,
codec
->
extradata_size
);
av_free
(
codec
->
extradata
);
}
memcpy
(
dest
+
codec
->
extradata_size
,
start_sequence
,
sizeof
(
start_sequence
));
memcpy
(
dest
+
codec
->
extradata_size
+
sizeof
(
start_sequence
),
decoded_packet
,
packet_size
);
memset
(
dest
+
codec
->
extradata_size
+
sizeof
(
start_sequence
)
+
packet_size
,
0
,
FF_INPUT_BUFFER_PADDING_SIZE
);
codec
->
extradata
=
dest
;
codec
->
extradata_size
+=
sizeof
(
start_sequence
)
+
packet_size
;
}
}
av_log
(
s
,
AV_LOG_DEBUG
,
"Extradata set to %p (size: %d)
\n
"
,
codec
->
extradata
,
codec
->
extradata_size
);
return
0
;
}
static
int
sdp_parse_fmtp_config_h264
(
AVFormatContext
*
s
,
AVStream
*
stream
,
PayloadContext
*
h264_data
,
...
...
@@ -121,51 +175,7 @@ static int sdp_parse_fmtp_config_h264(AVFormatContext *s,
}
else
if
(
!
strcmp
(
attr
,
"sprop-parameter-sets"
))
{
codec
->
extradata_size
=
0
;
av_freep
(
&
codec
->
extradata
);
while
(
*
value
)
{
char
base64packet
[
1024
];
uint8_t
decoded_packet
[
1024
];
int
packet_size
;
char
*
dst
=
base64packet
;
while
(
*
value
&&
*
value
!=
','
&&
(
dst
-
base64packet
)
<
sizeof
(
base64packet
)
-
1
)
{
*
dst
++
=
*
value
++
;
}
*
dst
++
=
'\0'
;
if
(
*
value
==
','
)
value
++
;
packet_size
=
av_base64_decode
(
decoded_packet
,
base64packet
,
sizeof
(
decoded_packet
));
if
(
packet_size
>
0
)
{
uint8_t
*
dest
=
av_malloc
(
packet_size
+
sizeof
(
start_sequence
)
+
codec
->
extradata_size
+
FF_INPUT_BUFFER_PADDING_SIZE
);
if
(
!
dest
)
{
av_log
(
s
,
AV_LOG_ERROR
,
"Unable to allocate memory for extradata!
\n
"
);
return
AVERROR
(
ENOMEM
);
}
if
(
codec
->
extradata_size
)
{
memcpy
(
dest
,
codec
->
extradata
,
codec
->
extradata_size
);
av_free
(
codec
->
extradata
);
}
memcpy
(
dest
+
codec
->
extradata_size
,
start_sequence
,
sizeof
(
start_sequence
));
memcpy
(
dest
+
codec
->
extradata_size
+
sizeof
(
start_sequence
),
decoded_packet
,
packet_size
);
memset
(
dest
+
codec
->
extradata_size
+
sizeof
(
start_sequence
)
+
packet_size
,
0
,
FF_INPUT_BUFFER_PADDING_SIZE
);
codec
->
extradata
=
dest
;
codec
->
extradata_size
+=
sizeof
(
start_sequence
)
+
packet_size
;
}
}
av_log
(
s
,
AV_LOG_DEBUG
,
"Extradata set to %p (size: %d)!
\n
"
,
codec
->
extradata
,
codec
->
extradata_size
);
return
parse_sprop_parameter_sets
(
s
,
codec
,
value
);
}
return
0
;
}
...
...
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