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
a38eab8b
Commit
a38eab8b
authored
Jul 20, 2019
by
James Almer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avformat/aacdec: factorize the adts frame resync code
Signed-off-by:
James Almer
<
jamrial@gmail.com
>
parent
5941b7f6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
12 deletions
+25
-12
aacdec.c
libavformat/aacdec.c
+25
-12
No files found.
libavformat/aacdec.c
View file @
a38eab8b
...
...
@@ -80,10 +80,31 @@ static int adts_aac_probe(const AVProbeData *p)
return
0
;
}
static
int
adts_aac_resync
(
AVFormatContext
*
s
)
{
uint16_t
state
;
// skip data until an ADTS frame is found
state
=
avio_r8
(
s
->
pb
);
while
(
!
avio_feof
(
s
->
pb
)
&&
avio_tell
(
s
->
pb
)
<
s
->
probesize
)
{
state
=
(
state
<<
8
)
|
avio_r8
(
s
->
pb
);
if
((
state
>>
4
)
!=
0xFFF
)
continue
;
avio_seek
(
s
->
pb
,
-
2
,
SEEK_CUR
);
break
;
}
if
(
s
->
pb
->
eof_reached
)
return
AVERROR_EOF
;
if
((
state
>>
4
)
!=
0xFFF
)
return
AVERROR_INVALIDDATA
;
return
0
;
}
static
int
adts_aac_read_header
(
AVFormatContext
*
s
)
{
AVStream
*
st
;
uint16_t
state
;
int
ret
;
st
=
avformat_new_stream
(
s
,
NULL
);
if
(
!
st
)
...
...
@@ -101,17 +122,9 @@ static int adts_aac_read_header(AVFormatContext *s)
avio_seek
(
s
->
pb
,
cur
,
SEEK_SET
);
}
// skip data until the first ADTS frame is found
state
=
avio_r8
(
s
->
pb
);
while
(
!
avio_feof
(
s
->
pb
)
&&
avio_tell
(
s
->
pb
)
<
s
->
probesize
)
{
state
=
(
state
<<
8
)
|
avio_r8
(
s
->
pb
);
if
((
state
>>
4
)
!=
0xFFF
)
continue
;
avio_seek
(
s
->
pb
,
-
2
,
SEEK_CUR
);
break
;
}
if
((
state
>>
4
)
!=
0xFFF
)
return
AVERROR_INVALIDDATA
;
ret
=
adts_aac_resync
(
s
);
if
(
ret
<
0
)
return
ret
;
// LCM of all possible ADTS sample rates
avpriv_set_pts_info
(
st
,
64
,
1
,
28224000
);
...
...
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