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
39d11d59
Commit
39d11d59
authored
Dec 11, 2013
by
Michael Niedermayer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avformat/oggparseopus: factor opus_duration() out
Signed-off-by:
Michael Niedermayer
<
michaelni@gmx.at
>
parent
43f92553
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
15 deletions
+21
-15
oggparseopus.c
libavformat/oggparseopus.c
+21
-15
No files found.
libavformat/oggparseopus.c
View file @
39d11d59
...
...
@@ -82,6 +82,26 @@ static int opus_header(AVFormatContext *avf, int idx)
return
0
;
}
static
int
opus_duration
(
uint8_t
*
src
,
int
size
)
{
unsigned
nb_frames
=
1
;
unsigned
toc
=
src
[
0
];
unsigned
toc_config
=
toc
>>
3
;
unsigned
toc_count
=
toc
&
3
;
unsigned
frame_size
=
toc_config
<
12
?
FFMAX
(
480
,
960
*
(
toc_config
&
3
))
:
toc_config
<
16
?
480
<<
(
toc_config
&
1
)
:
120
<<
(
toc_config
&
3
);
if
(
toc_count
==
3
)
{
if
(
size
<
2
)
return
AVERROR_INVALIDDATA
;
nb_frames
=
src
[
1
]
&
0x3F
;
}
else
if
(
toc_count
)
{
nb_frames
=
2
;
}
return
frame_size
*
nb_frames
;
}
static
int
opus_packet
(
AVFormatContext
*
avf
,
int
idx
)
{
struct
ogg
*
ogg
=
avf
->
priv_data
;
...
...
@@ -89,26 +109,12 @@ static int opus_packet(AVFormatContext *avf, int idx)
AVStream
*
st
=
avf
->
streams
[
idx
];
struct
oggopus_private
*
priv
=
os
->
private
;
uint8_t
*
packet
=
os
->
buf
+
os
->
pstart
;
unsigned
toc
,
toc_config
,
toc_count
,
frame_size
,
nb_frames
=
1
;
if
(
!
os
->
psize
)
return
AVERROR_INVALIDDATA
;
toc
=
*
packet
;
toc_config
=
toc
>>
3
;
toc_count
=
toc
&
3
;
frame_size
=
toc_config
<
12
?
FFMAX
(
480
,
960
*
(
toc_config
&
3
))
:
toc_config
<
16
?
480
<<
(
toc_config
&
1
)
:
120
<<
(
toc_config
&
3
);
if
(
toc_count
==
3
)
{
if
(
os
->
psize
<
2
)
return
AVERROR_INVALIDDATA
;
nb_frames
=
packet
[
1
]
&
0x3F
;
}
else
if
(
toc_count
)
{
nb_frames
=
2
;
}
os
->
pduration
=
frame_size
*
nb_frames
;
os
->
pduration
=
opus_duration
(
packet
,
os
->
psize
)
;
if
(
os
->
lastpts
!=
AV_NOPTS_VALUE
)
{
if
(
st
->
start_time
==
AV_NOPTS_VALUE
)
st
->
start_time
=
os
->
lastpts
;
...
...
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