Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc
Commits
7d1d0736
Commit
7d1d0736
authored
Dec 03, 2015
by
Francois Cartegnie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
packetizer: simplify h264_create_avcdec_config_record
parent
289691ce
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
41 additions
and
22 deletions
+41
-22
modules/codec/videotoolbox.m
modules/codec/videotoolbox.m
+1
-1
modules/packetizer/h264_nal.c
modules/packetizer/h264_nal.c
+39
-19
modules/packetizer/h264_nal.h
modules/packetizer/h264_nal.h
+1
-2
No files found.
modules/codec/videotoolbox.m
View file @
7d1d0736
...
@@ -387,7 +387,7 @@ static int StartVideoToolbox(decoder_t *p_dec, block_t *p_block)
...
@@ -387,7 +387,7 @@ static int StartVideoToolbox(decoder_t *p_dec, block_t *p_block)
/* create avvC atom to forward to the HW decoder */
/* create avvC atom to forward to the HW decoder */
block_t
*
p_block
=
h264_create_avcdec_config_record
(
block_t
*
p_block
=
h264_create_avcdec_config_record
(
p_sys
->
i_nal_length_size
,
p_sys
->
i_nal_length_size
,
&
sps_data
,
p_sps_buf
,
i_sps_size
,
p_sps_buf
,
i_sps_size
,
p_pps_buf
,
i_pps_size
);
p_pps_buf
,
i_pps_size
);
free
(
p_alloc_buf
);
free
(
p_alloc_buf
);
if
(
!
p_block
)
{
if
(
!
p_block
)
{
...
...
modules/packetizer/h264_nal.c
View file @
7d1d0736
...
@@ -30,6 +30,27 @@
...
@@ -30,6 +30,27 @@
static
const
uint8_t
annexb_startcode
[]
=
{
0x00
,
0x00
,
0x01
};
static
const
uint8_t
annexb_startcode
[]
=
{
0x00
,
0x00
,
0x01
};
static
inline
bool
strip_AnnexB_startcode
(
const
uint8_t
**
pp_data
,
size_t
*
pi_data
)
{
const
uint8_t
*
p_data
=
*
pp_data
;
if
(
*
pi_data
<
4
)
{
return
false
;
}
else
if
(
p_data
[
0
]
==
!!
memcmp
(
&
p_data
[
1
],
annexb_startcode
,
3
)
)
{
*
pp_data
+=
4
;
*
pi_data
-=
4
;
}
else
if
(
!
memcmp
(
p_data
,
annexb_startcode
,
3
)
)
{
*
pp_data
+=
3
;
*
pi_data
-=
3
;
}
else
return
false
;
return
true
;
}
int
convert_sps_pps
(
decoder_t
*
p_dec
,
const
uint8_t
*
p_buf
,
int
convert_sps_pps
(
decoder_t
*
p_dec
,
const
uint8_t
*
p_buf
,
uint32_t
i_buf_size
,
uint8_t
*
p_out_buf
,
uint32_t
i_buf_size
,
uint8_t
*
p_out_buf
,
uint32_t
i_out_buf_size
,
uint32_t
*
p_sps_pps_size
,
uint32_t
i_out_buf_size
,
uint32_t
*
p_sps_pps_size
,
...
@@ -682,48 +703,47 @@ int h264_parse_pps( const uint8_t *p_pps_buf, int i_pps_size,
...
@@ -682,48 +703,47 @@ int h264_parse_pps( const uint8_t *p_pps_buf, int i_pps_size,
return
0
;
return
0
;
}
}
block_t
*
h264_create_avcdec_config_record
(
size_t
i_nal_length_size
,
block_t
*
h264_create_avcdec_config_record
(
uint8_t
i_nal_length_size
,
struct
nal_sps
*
p_sps
,
const
uint8_t
*
p_sps_buf
,
const
uint8_t
*
p_sps_buf
,
size_t
i_sps_size
,
size_t
i_sps_size
,
const
uint8_t
*
p_pps_buf
,
const
uint8_t
*
p_pps_buf
,
size_t
i_pps_size
)
size_t
i_pps_size
)
{
{
bo_t
bo
;
if
(
i_pps_size
>
UINT16_MAX
||
i_sps_size
>
UINT16_MAX
)
return
NULL
;
if
(
!
strip_AnnexB_startcode
(
&
p_sps_buf
,
&
i_sps_size
)
||
!
strip_AnnexB_startcode
(
&
p_pps_buf
,
&
i_pps_size
)
)
return
NULL
;
/* The length of the NAL size is encoded using 1, 2 or 4 bytes */
/* The length of the NAL size is encoded using 1, 2 or 4 bytes */
if
(
i_nal_length_size
!=
1
&&
i_nal_length_size
!=
2
if
(
i_nal_length_size
!=
1
&&
i_nal_length_size
!=
2
&&
i_nal_length_size
!=
4
)
&&
i_nal_length_size
!=
4
)
return
NULL
;
return
NULL
;
/* 6 * int(8), i_sps_size - 4, 1 * int(8), i_pps_size - 4 */
bo_t
bo
;
if
(
bo_init
(
&
bo
,
7
+
i_sps_size
+
i_pps_size
-
8
)
!=
true
)
/* 6 * int(8), i_sps_size, 1 * int(8), i_pps_size */
if
(
bo_init
(
&
bo
,
7
+
i_sps_size
+
i_pps_size
)
!=
true
)
return
NULL
;
return
NULL
;
bo_add_8
(
&
bo
,
1
);
/* configuration version */
bo_add_8
(
&
bo
,
1
);
/* configuration version */
bo_add_8
(
&
bo
,
p_sps
->
i_profile
);
bo_add_mem
(
&
bo
,
3
,
&
p_sps_buf
[
1
]
);
/* i_profile/profile_compatibility/level */
bo_add_8
(
&
bo
,
p_sps
->
i_profile_compatibility
);
bo_add_8
(
&
bo
,
p_sps
->
i_level
);
bo_add_8
(
&
bo
,
0xfc
|
(
i_nal_length_size
-
1
)
);
/* 0b11111100 | lengthsize - 1*/
bo_add_8
(
&
bo
,
0xfc
|
(
i_nal_length_size
-
1
)
);
/* 0b11111100 | lengthsize - 1*/
bo_add_8
(
&
bo
,
0xe0
|
(
i_sps_size
>
0
?
1
:
0
)
);
/* 0b11100000 | sps_count */
bo_add_8
(
&
bo
,
0xe0
|
(
i_sps_size
>
0
?
1
:
0
)
);
/* 0b11100000 | sps_count */
if
(
i_sps_size
)
if
(
i_sps_size
>
4
)
{
{
/* the SPS data we have got includes 4 leading
bo_add_16be
(
&
bo
,
i_sps_size
);
* bytes which we need to remove */
bo_add_mem
(
&
bo
,
i_sps_size
,
p_sps_buf
);
bo_add_16be
(
&
bo
,
i_sps_size
-
4
);
bo_add_mem
(
&
bo
,
i_sps_size
-
4
,
p_sps_buf
+
4
);
}
}
bo_add_8
(
&
bo
,
(
i_pps_size
>
0
?
1
:
0
)
);
/* pps_count */
bo_add_8
(
&
bo
,
(
i_pps_size
>
0
?
1
:
0
)
);
/* pps_count */
if
(
i_pps_size
>
4
)
if
(
i_pps_size
)
{
{
/* the PPS data we have got includes 4 leading
bo_add_16be
(
&
bo
,
i_pps_size
);
* bytes which we need to remove */
bo_add_mem
(
&
bo
,
i_pps_size
,
p_pps_buf
);
bo_add_16be
(
&
bo
,
i_pps_size
-
4
);
bo_add_mem
(
&
bo
,
i_pps_size
-
4
,
p_pps_buf
+
4
);
}
}
return
bo
.
b
;
return
bo
.
b
;
}
}
...
...
modules/packetizer/h264_nal.h
View file @
7d1d0736
...
@@ -152,8 +152,7 @@ int h264_parse_pps( const uint8_t *p_pps_buf, int i_pps_size,
...
@@ -152,8 +152,7 @@ int h264_parse_pps( const uint8_t *p_pps_buf, int i_pps_size,
/* Create a AVCDecoderConfigurationRecord from SPS/PPS
/* Create a AVCDecoderConfigurationRecord from SPS/PPS
* Returns a valid block_t on success, must be freed with block_Release */
* Returns a valid block_t on success, must be freed with block_Release */
block_t
*
h264_create_avcdec_config_record
(
size_t
i_nal_length_size
,
block_t
*
h264_create_avcdec_config_record
(
uint8_t
i_nal_length_size
,
struct
nal_sps
*
p_sps
,
const
uint8_t
*
p_sps_buf
,
const
uint8_t
*
p_sps_buf
,
size_t
i_sps_size
,
size_t
i_sps_size
,
const
uint8_t
*
p_pps_buf
,
const
uint8_t
*
p_pps_buf
,
...
...
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