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
214f4133
Commit
214f4133
authored
May 05, 2017
by
James Almer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avcodec/hevc_parser: move hevc_find_frame_end() down in the file
Reduces differences with libav.
parent
35f3df0d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
44 additions
and
43 deletions
+44
-43
hevc_parser.c
libavcodec/hevc_parser.c
+44
-43
No files found.
libavcodec/hevc_parser.c
View file @
214f4133
...
...
@@ -49,49 +49,6 @@ typedef struct HEVCParserContext {
int
pocTid0
;
}
HEVCParserContext
;
/**
* Find the end of the current frame in the bitstream.
* @return the position of the first byte of the next frame, or END_NOT_FOUND
*/
static
int
hevc_find_frame_end
(
AVCodecParserContext
*
s
,
const
uint8_t
*
buf
,
int
buf_size
)
{
int
i
;
ParseContext
*
pc
=
s
->
priv_data
;
for
(
i
=
0
;
i
<
buf_size
;
i
++
)
{
int
nut
;
pc
->
state64
=
(
pc
->
state64
<<
8
)
|
buf
[
i
];
if
(((
pc
->
state64
>>
3
*
8
)
&
0xFFFFFF
)
!=
START_CODE
)
continue
;
nut
=
(
pc
->
state64
>>
2
*
8
+
1
)
&
0x3F
;
// Beginning of access unit
if
((
nut
>=
HEVC_NAL_VPS
&&
nut
<=
HEVC_NAL_AUD
)
||
nut
==
HEVC_NAL_SEI_PREFIX
||
(
nut
>=
41
&&
nut
<=
44
)
||
(
nut
>=
48
&&
nut
<=
55
))
{
if
(
pc
->
frame_start_found
)
{
pc
->
frame_start_found
=
0
;
return
i
-
5
;
}
}
else
if
(
nut
<=
HEVC_NAL_RASL_R
||
(
nut
>=
HEVC_NAL_BLA_W_LP
&&
nut
<=
HEVC_NAL_CRA_NUT
))
{
int
first_slice_segment_in_pic_flag
=
buf
[
i
]
>>
7
;
if
(
first_slice_segment_in_pic_flag
)
{
if
(
!
pc
->
frame_start_found
)
{
pc
->
frame_start_found
=
1
;
}
else
{
// First slice of next frame found
pc
->
frame_start_found
=
0
;
return
i
-
5
;
}
}
}
}
return
END_NOT_FOUND
;
}
static
int
hevc_parse_slice_header
(
AVCodecParserContext
*
s
,
H2645NAL
*
nal
,
AVCodecContext
*
avctx
)
{
...
...
@@ -289,6 +246,50 @@ static inline int parse_nal_units(AVCodecParserContext *s, const uint8_t *buf,
return
-
1
;
}
/**
* Find the end of the current frame in the bitstream.
* @return the position of the first byte of the next frame, or END_NOT_FOUND
*/
static
int
hevc_find_frame_end
(
AVCodecParserContext
*
s
,
const
uint8_t
*
buf
,
int
buf_size
)
{
HEVCParserContext
*
ctx
=
s
->
priv_data
;
ParseContext
*
pc
=
&
ctx
->
pc
;
int
i
;
for
(
i
=
0
;
i
<
buf_size
;
i
++
)
{
int
nut
;
pc
->
state64
=
(
pc
->
state64
<<
8
)
|
buf
[
i
];
if
(((
pc
->
state64
>>
3
*
8
)
&
0xFFFFFF
)
!=
START_CODE
)
continue
;
nut
=
(
pc
->
state64
>>
2
*
8
+
1
)
&
0x3F
;
// Beginning of access unit
if
((
nut
>=
HEVC_NAL_VPS
&&
nut
<=
HEVC_NAL_AUD
)
||
nut
==
HEVC_NAL_SEI_PREFIX
||
(
nut
>=
41
&&
nut
<=
44
)
||
(
nut
>=
48
&&
nut
<=
55
))
{
if
(
pc
->
frame_start_found
)
{
pc
->
frame_start_found
=
0
;
return
i
-
5
;
}
}
else
if
(
nut
<=
HEVC_NAL_RASL_R
||
(
nut
>=
HEVC_NAL_BLA_W_LP
&&
nut
<=
HEVC_NAL_CRA_NUT
))
{
int
first_slice_segment_in_pic_flag
=
buf
[
i
]
>>
7
;
if
(
first_slice_segment_in_pic_flag
)
{
if
(
!
pc
->
frame_start_found
)
{
pc
->
frame_start_found
=
1
;
}
else
{
// First slice of next frame found
pc
->
frame_start_found
=
0
;
return
i
-
5
;
}
}
}
}
return
END_NOT_FOUND
;
}
static
int
hevc_parse
(
AVCodecParserContext
*
s
,
AVCodecContext
*
avctx
,
const
uint8_t
**
poutbuf
,
int
*
poutbuf_size
,
...
...
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