Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
FFmpeg
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
libremedia
Tethys
FFmpeg
Commits
90ed6c5c
Commit
90ed6c5c
authored
9 years ago
by
Anton Khirnov
Browse files
Options
Downloads
Patches
Plain Diff
h2645_parse: compute the actual data length, without trailing paddding
This is required by h264.
parent
b667252a
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
libavcodec/h2645_parse.c
+36
-3
36 additions, 3 deletions
libavcodec/h2645_parse.c
libavcodec/h2645_parse.h
+6
-0
6 additions, 0 deletions
libavcodec/h2645_parse.h
with
42 additions
and
3 deletions
libavcodec/h2645_parse.c
+
36
−
3
View file @
90ed6c5c
...
@@ -22,13 +22,12 @@
...
@@ -22,13 +22,12 @@
#include
"config.h"
#include
"config.h"
#include
"libavutil/intmath.h"
#include
"libavutil/intreadwrite.h"
#include
"libavutil/intreadwrite.h"
#include
"libavutil/mem.h"
#include
"libavutil/mem.h"
#include
"h2645_parse.h"
#include
"h2645_parse.h"
/* FIXME: This is adapted from ff_h264_decode_nal, avoiding duplication
* between these functions would be nice. */
int
ff_h2645_extract_rbsp
(
const
uint8_t
*
src
,
int
length
,
int
ff_h2645_extract_rbsp
(
const
uint8_t
*
src
,
int
length
,
H2645NAL
*
nal
)
H2645NAL
*
nal
)
{
{
...
@@ -128,6 +127,31 @@ nsc:
...
@@ -128,6 +127,31 @@ nsc:
return
si
;
return
si
;
}
}
static
int
get_bit_length
(
H2645NAL
*
nal
,
int
skip_trailing_zeros
)
{
int
size
=
nal
->
size
;
int
v
;
while
(
skip_trailing_zeros
&&
size
>
0
&&
nal
->
data
[
size
-
1
]
==
0
)
size
--
;
if
(
!
size
)
return
0
;
v
=
nal
->
data
[
size
-
1
];
if
(
size
>
INT_MAX
/
8
)
return
AVERROR
(
ERANGE
);
size
*=
8
;
/* remove the stop bit and following trailing zeros,
* or nothing for damaged bitstreams */
if
(
v
)
size
-=
av_ctz
(
v
)
+
1
;
return
size
;
}
/**
/**
* @return AVERROR_INVALIDDATA if the packet is not a valid NAL unit,
* @return AVERROR_INVALIDDATA if the packet is not a valid NAL unit,
* 0 if the unit should be skipped, 1 otherwise
* 0 if the unit should be skipped, 1 otherwise
...
@@ -181,6 +205,7 @@ int ff_h2645_packet_split(H2645Packet *pkt, const uint8_t *buf, int length,
...
@@ -181,6 +205,7 @@ int ff_h2645_packet_split(H2645Packet *pkt, const uint8_t *buf, int length,
while
(
length
>=
4
)
{
while
(
length
>=
4
)
{
H2645NAL
*
nal
;
H2645NAL
*
nal
;
int
extract_length
=
0
;
int
extract_length
=
0
;
int
skip_trailing_zeros
=
1
;
if
(
is_nalff
)
{
if
(
is_nalff
)
{
int
i
;
int
i
;
...
@@ -224,7 +249,15 @@ int ff_h2645_packet_split(H2645Packet *pkt, const uint8_t *buf, int length,
...
@@ -224,7 +249,15 @@ int ff_h2645_packet_split(H2645Packet *pkt, const uint8_t *buf, int length,
if
(
consumed
<
0
)
if
(
consumed
<
0
)
return
consumed
;
return
consumed
;
ret
=
init_get_bits8
(
&
nal
->
gb
,
nal
->
data
,
nal
->
size
);
/* see commit 3566042a0 */
if
(
consumed
<
length
-
3
&&
buf
[
consumed
]
==
0x00
&&
buf
[
consumed
+
1
]
==
0x00
&&
buf
[
consumed
+
2
]
==
0x01
&&
buf
[
consumed
+
3
]
==
0xE0
)
skip_trailing_zeros
=
0
;
nal
->
size_bits
=
get_bit_length
(
nal
,
skip_trailing_zeros
);
ret
=
init_get_bits
(
&
nal
->
gb
,
nal
->
data
,
nal
->
size_bits
);
if
(
ret
<
0
)
if
(
ret
<
0
)
return
ret
;
return
ret
;
...
...
This diff is collapsed.
Click to expand it.
libavcodec/h2645_parse.h
+
6
−
0
View file @
90ed6c5c
...
@@ -33,6 +33,12 @@ typedef struct H2645NAL {
...
@@ -33,6 +33,12 @@ typedef struct H2645NAL {
int
size
;
int
size
;
const
uint8_t
*
data
;
const
uint8_t
*
data
;
/**
* Size, in bits, of just the data, excluding the stop bit and any trailing
* padding. I.e. what HEVC calls SODB.
*/
int
size_bits
;
int
raw_size
;
int
raw_size
;
const
uint8_t
*
raw_data
;
const
uint8_t
*
raw_data
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment