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
4a8dc0f0
Commit
4a8dc0f0
authored
9 years ago
by
Thomas Guillem
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
h264_nal: fix confusion between NAL size and NAL length size.
parent
65df83c9
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
23 additions
and
23 deletions
+23
-23
modules/codec/mft.c
modules/codec/mft.c
+3
-3
modules/codec/omxil/mediacodec.c
modules/codec/omxil/mediacodec.c
+7
-7
modules/packetizer/h264_nal.c
modules/packetizer/h264_nal.c
+10
-10
modules/packetizer/h264_nal.h
modules/packetizer/h264_nal.h
+3
-3
No files found.
modules/codec/mft.c
View file @
4a8dc0f0
...
@@ -100,7 +100,7 @@ struct decoder_sys_t
...
@@ -100,7 +100,7 @@ struct decoder_sys_t
IMFMediaType
*
output_type
;
IMFMediaType
*
output_type
;
/* H264 only. */
/* H264 only. */
uint32_t
nal_size
;
uint32_t
nal_
length_
size
;
};
};
static
const
int
pi_channels_maps
[
9
]
=
static
const
int
pi_channels_maps
[
9
]
=
...
@@ -575,7 +575,7 @@ static int ProcessInputStream(decoder_t *p_dec, DWORD stream_id, block_t *p_bloc
...
@@ -575,7 +575,7 @@ static int ProcessInputStream(decoder_t *p_dec, DWORD stream_id, block_t *p_bloc
if
(
p_dec
->
fmt_in
.
i_codec
==
VLC_CODEC_H264
)
if
(
p_dec
->
fmt_in
.
i_codec
==
VLC_CODEC_H264
)
{
{
/* in-place NAL to annex B conversion. */
/* in-place NAL to annex B conversion. */
convert_h264_to_annexb
(
buffer_start
,
p_block
->
i_buffer
,
p_sys
->
nal_size
);
convert_h264_to_annexb
(
buffer_start
,
p_block
->
i_buffer
,
p_sys
->
nal_
length_
size
);
}
}
hr
=
IMFMediaBuffer_Unlock
(
input_media_buffer
);
hr
=
IMFMediaBuffer_Unlock
(
input_media_buffer
);
...
@@ -993,7 +993,7 @@ static int InitializeMFT(decoder_t *p_dec)
...
@@ -993,7 +993,7 @@ static int InitializeMFT(decoder_t *p_dec)
{
{
convert_sps_pps
(
p_dec
,
p_dec
->
fmt_in
.
p_extra
,
p_dec
->
fmt_in
.
i_extra
,
convert_sps_pps
(
p_dec
,
p_dec
->
fmt_in
.
p_extra
,
p_dec
->
fmt_in
.
i_extra
,
buf
,
buf_size
,
buf
,
buf_size
,
&
size
,
&
p_sys
->
nal_size
);
&
size
,
&
p_sys
->
nal_
length_
size
);
}
}
free
(
buf
);
free
(
buf
);
}
}
...
...
This diff is collapsed.
Click to expand it.
modules/codec/omxil/mediacodec.c
View file @
4a8dc0f0
...
@@ -86,7 +86,7 @@ struct decoder_sys_t
...
@@ -86,7 +86,7 @@ struct decoder_sys_t
{
{
AWindowHandler
*
p_awh
;
AWindowHandler
*
p_awh
;
int
i_pixel_format
,
i_stride
,
i_slice_height
,
i_width
,
i_height
;
int
i_pixel_format
,
i_stride
,
i_slice_height
,
i_width
,
i_height
;
uint32_t
i_nal_size
;
uint32_t
i_nal_
length_
size
;
size_t
i_h264_profile
;
size_t
i_h264_profile
;
ArchitectureSpecificCopyData
ascd
;
ArchitectureSpecificCopyData
ascd
;
/* stores the inflight picture for each output buffer or NULL */
/* stores the inflight picture for each output buffer or NULL */
...
@@ -295,13 +295,13 @@ static int ParseVideoExtra(decoder_t *p_dec, uint8_t *p_extra, int i_extra)
...
@@ -295,13 +295,13 @@ static int ParseVideoExtra(decoder_t *p_dec, uint8_t *p_extra, int i_extra)
if
(
p_extra
[
0
]
==
1
if
(
p_extra
[
0
]
==
1
&&
convert_sps_pps
(
p_dec
,
p_extra
,
i_extra
,
&&
convert_sps_pps
(
p_dec
,
p_extra
,
i_extra
,
p_buf
,
buf_size
,
&
size
,
p_buf
,
buf_size
,
&
size
,
&
p_sys
->
u
.
video
.
i_nal_size
)
==
VLC_SUCCESS
)
&
p_sys
->
u
.
video
.
i_nal_
length_
size
)
==
VLC_SUCCESS
)
H264SetCSD
(
p_dec
,
p_buf
,
size
,
NULL
);
H264SetCSD
(
p_dec
,
p_buf
,
size
,
NULL
);
}
else
}
else
{
{
if
(
convert_hevc_nal_units
(
p_dec
,
p_extra
,
i_extra
,
if
(
convert_hevc_nal_units
(
p_dec
,
p_extra
,
i_extra
,
p_buf
,
buf_size
,
&
size
,
p_buf
,
buf_size
,
&
size
,
&
p_sys
->
u
.
video
.
i_nal_size
)
==
VLC_SUCCESS
)
&
p_sys
->
u
.
video
.
i_nal_
length_
size
)
==
VLC_SUCCESS
)
{
{
struct
csd
csd
;
struct
csd
csd
;
...
@@ -1056,10 +1056,10 @@ static void H264ProcessBlock(decoder_t *p_dec, block_t *p_block,
...
@@ -1056,10 +1056,10 @@ static void H264ProcessBlock(decoder_t *p_dec, block_t *p_block,
assert
(
p_dec
->
fmt_in
.
i_codec
==
VLC_CODEC_H264
&&
p_block
);
assert
(
p_dec
->
fmt_in
.
i_codec
==
VLC_CODEC_H264
&&
p_block
);
if
(
p_sys
->
u
.
video
.
i_nal_size
)
if
(
p_sys
->
u
.
video
.
i_nal_
length_
size
)
{
{
convert_h264_to_annexb
(
p_block
->
p_buffer
,
p_block
->
i_buffer
,
convert_h264_to_annexb
(
p_block
->
p_buffer
,
p_block
->
i_buffer
,
p_sys
->
u
.
video
.
i_nal_size
);
p_sys
->
u
.
video
.
i_nal_
length_
size
);
}
else
if
(
H264SetCSD
(
p_dec
,
p_block
->
p_buffer
,
p_block
->
i_buffer
,
}
else
if
(
H264SetCSD
(
p_dec
,
p_block
->
p_buffer
,
p_block
->
i_buffer
,
p_size_changed
)
==
VLC_SUCCESS
)
p_size_changed
)
==
VLC_SUCCESS
)
{
{
...
@@ -1074,10 +1074,10 @@ static void HEVCProcessBlock(decoder_t *p_dec, block_t *p_block,
...
@@ -1074,10 +1074,10 @@ static void HEVCProcessBlock(decoder_t *p_dec, block_t *p_block,
assert
(
p_dec
->
fmt_in
.
i_codec
==
VLC_CODEC_HEVC
&&
p_block
);
assert
(
p_dec
->
fmt_in
.
i_codec
==
VLC_CODEC_HEVC
&&
p_block
);
if
(
p_sys
->
u
.
video
.
i_nal_size
)
if
(
p_sys
->
u
.
video
.
i_nal_
length_
size
)
{
{
convert_h264_to_annexb
(
p_block
->
p_buffer
,
p_block
->
i_buffer
,
convert_h264_to_annexb
(
p_block
->
p_buffer
,
p_block
->
i_buffer
,
p_sys
->
u
.
video
.
i_nal_size
);
p_sys
->
u
.
video
.
i_nal_
length_
size
);
}
}
/* TODO */
/* TODO */
...
...
This diff is collapsed.
Click to expand it.
modules/packetizer/h264_nal.c
View file @
4a8dc0f0
...
@@ -32,7 +32,7 @@ static const uint8_t annexb_startcode[] = { 0x00, 0x00, 0x01 };
...
@@ -32,7 +32,7 @@ static const uint8_t annexb_startcode[] = { 0x00, 0x00, 0x01 };
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
,
uint32_t
*
p_nal_size
)
uint32_t
*
p_nal_
length_
size
)
{
{
int
i_profile
;
int
i_profile
;
uint32_t
i_data_size
=
i_buf_size
,
i_nal_size
,
i_sps_pps_size
=
0
;
uint32_t
i_data_size
=
i_buf_size
,
i_nal_size
,
i_sps_pps_size
=
0
;
...
@@ -47,8 +47,8 @@ int convert_sps_pps( decoder_t *p_dec, const uint8_t *p_buf,
...
@@ -47,8 +47,8 @@ int convert_sps_pps( decoder_t *p_dec, const uint8_t *p_buf,
/* Read infos in first 6 bytes */
/* Read infos in first 6 bytes */
i_profile
=
(
p_buf
[
1
]
<<
16
)
|
(
p_buf
[
2
]
<<
8
)
|
p_buf
[
3
];
i_profile
=
(
p_buf
[
1
]
<<
16
)
|
(
p_buf
[
2
]
<<
8
)
|
p_buf
[
3
];
if
(
p_nal_size
)
if
(
p_nal_
length_
size
)
*
p_nal_size
=
(
p_buf
[
4
]
&
0x03
)
+
1
;
*
p_nal_
length_
size
=
(
p_buf
[
4
]
&
0x03
)
+
1
;
p_buf
+=
5
;
p_buf
+=
5
;
i_data_size
-=
5
;
i_data_size
-=
5
;
...
@@ -107,23 +107,23 @@ int convert_sps_pps( decoder_t *p_dec, const uint8_t *p_buf,
...
@@ -107,23 +107,23 @@ int convert_sps_pps( decoder_t *p_dec, const uint8_t *p_buf,
}
}
void
convert_h264_to_annexb
(
uint8_t
*
p_buf
,
uint32_t
i_len
,
void
convert_h264_to_annexb
(
uint8_t
*
p_buf
,
uint32_t
i_len
,
size_t
i_nal_size
)
size_t
i_nal_
length_
size
)
{
{
uint32_t
nal_len
=
0
,
nal_pos
=
0
;
uint32_t
nal_len
=
0
,
nal_pos
=
0
;
if
(
i_nal_
size
<
3
||
i_nal
_size
>
4
)
if
(
i_nal_
length_size
<
3
||
i_nal_length
_size
>
4
)
return
;
return
;
/* This only works for NAL sizes 3-4 */
/* This only works for NAL sizes 3-4 */
while
(
i_len
>
0
)
while
(
i_len
>
0
)
{
{
if
(
nal_pos
<
i_nal_size
)
{
if
(
nal_pos
<
i_nal_
length_
size
)
{
unsigned
int
i
;
unsigned
int
i
;
for
(
i
=
0
;
nal_pos
<
i_nal_size
&&
i
<
i_len
;
i
++
,
nal_pos
++
)
{
for
(
i
=
0
;
nal_pos
<
i_nal_
length_
size
&&
i
<
i_len
;
i
++
,
nal_pos
++
)
{
nal_len
=
(
nal_len
<<
8
)
|
p_buf
[
i
];
nal_len
=
(
nal_len
<<
8
)
|
p_buf
[
i
];
p_buf
[
i
]
=
0
;
p_buf
[
i
]
=
0
;
}
}
if
(
nal_pos
<
i_nal_size
)
if
(
nal_pos
<
i_nal_
length_
size
)
return
;
return
;
p_buf
[
i
-
1
]
=
1
;
p_buf
[
i
-
1
]
=
1
;
p_buf
+=
i
;
p_buf
+=
i
;
...
@@ -518,7 +518,7 @@ int h264_parse_pps( const uint8_t *p_pps_buf, int i_pps_size,
...
@@ -518,7 +518,7 @@ int h264_parse_pps( const uint8_t *p_pps_buf, int i_pps_size,
}
}
bool
h264_get_profile_level
(
const
es_format_t
*
p_fmt
,
size_t
*
p_profile
,
bool
h264_get_profile_level
(
const
es_format_t
*
p_fmt
,
size_t
*
p_profile
,
size_t
*
p_level
,
size_t
*
p_nal_size
)
size_t
*
p_level
,
size_t
*
p_nal_
length_
size
)
{
{
uint8_t
*
p
=
(
uint8_t
*
)
p_fmt
->
p_extra
;
uint8_t
*
p
=
(
uint8_t
*
)
p_fmt
->
p_extra
;
if
(
!
p
||
!
p_fmt
->
p_extra
)
return
false
;
if
(
!
p
||
!
p_fmt
->
p_extra
)
return
false
;
...
@@ -527,7 +527,7 @@ bool h264_get_profile_level(const es_format_t *p_fmt, size_t *p_profile,
...
@@ -527,7 +527,7 @@ bool h264_get_profile_level(const es_format_t *p_fmt, size_t *p_profile,
if
(
p_fmt
->
i_original_fourcc
==
VLC_FOURCC
(
'a'
,
'v'
,
'c'
,
'1'
)
&&
p
[
0
]
==
1
)
if
(
p_fmt
->
i_original_fourcc
==
VLC_FOURCC
(
'a'
,
'v'
,
'c'
,
'1'
)
&&
p
[
0
]
==
1
)
{
{
if
(
p_fmt
->
i_extra
<
12
)
return
false
;
if
(
p_fmt
->
i_extra
<
12
)
return
false
;
if
(
p_nal_
size
)
*
p_nal
_size
=
1
+
(
p
[
4
]
&
0x03
);
if
(
p_nal_
length_size
)
*
p_nal_length
_size
=
1
+
(
p
[
4
]
&
0x03
);
if
(
!
(
p
[
5
]
&
0x1f
))
return
false
;
if
(
!
(
p
[
5
]
&
0x1f
))
return
false
;
p
+=
8
;
p
+=
8
;
}
}
...
...
This diff is collapsed.
Click to expand it.
modules/packetizer/h264_nal.h
View file @
4a8dc0f0
...
@@ -118,10 +118,10 @@ static inline void CreateDecodedNAL( uint8_t **pp_ret, int *pi_ret,
...
@@ -118,10 +118,10 @@ static inline void CreateDecodedNAL( uint8_t **pp_ret, int *pi_ret,
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
,
uint32_t
*
p_nal_size
);
uint32_t
*
p_nal_
length_
size
);
void
convert_h264_to_annexb
(
uint8_t
*
p_buf
,
uint32_t
i_len
,
void
convert_h264_to_annexb
(
uint8_t
*
p_buf
,
uint32_t
i_len
,
size_t
i_nal_size
);
size_t
i_nal_
length_
size
);
/* Get the SPS/PPS pointers from an Annex B buffer
/* Get the SPS/PPS pointers from an Annex B buffer
* Returns 0 if a SPS and/or a PPS is found */
* Returns 0 if a SPS and/or a PPS is found */
...
@@ -141,6 +141,6 @@ int h264_parse_pps( const uint8_t *p_pps_buf, int i_pps_size,
...
@@ -141,6 +141,6 @@ int h264_parse_pps( const uint8_t *p_pps_buf, int i_pps_size,
/* Get level and Profile */
/* Get level and Profile */
bool
h264_get_profile_level
(
const
es_format_t
*
p_fmt
,
size_t
*
p_profile
,
bool
h264_get_profile_level
(
const
es_format_t
*
p_fmt
,
size_t
*
p_profile
,
size_t
*
p_level
,
size_t
*
p_nal_size
);
size_t
*
p_level
,
size_t
*
p_nal_
length_
size
);
#endif
/* H264_NAL_H */
#endif
/* H264_NAL_H */
This diff is collapsed.
Click to expand it.
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