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
de707bc8
Commit
de707bc8
authored
Oct 03, 2012
by
Michael Niedermayer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mux/nut: factorize ff_choose_timebase() out of nut
Signed-off-by:
Michael Niedermayer
<
michaelni@gmx.at
>
parent
05e5a24f
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
5 deletions
+28
-5
internal.h
libavformat/internal.h
+8
-0
mux.c
libavformat/mux.c
+19
-0
nutenc.c
libavformat/nutenc.c
+1
-5
No files found.
libavformat/internal.h
View file @
de707bc8
...
...
@@ -354,5 +354,13 @@ void ff_compute_frame_duration(int *pnum, int *pden, AVStream *st,
int
ff_get_audio_frame_size
(
AVCodecContext
*
enc
,
int
size
,
int
mux
);
/**
* Chooses a timebase for muxing the specified stream.
*
* The choosen timebase allows sample accurate timestamps based
* on the framerate or sample rate for audio streams. It also is
* at least as precisse as 1/min_precission would be.
*/
AVRational
ff_choose_timebase
(
AVFormatContext
*
s
,
AVStream
*
st
,
int
min_precission
);
#endif
/* AVFORMAT_INTERNAL_H */
libavformat/mux.c
View file @
de707bc8
...
...
@@ -103,6 +103,25 @@ static void frac_add(AVFrac *f, int64_t incr)
f
->
num
=
num
;
}
AVRational
ff_choose_timebase
(
AVFormatContext
*
s
,
AVStream
*
st
,
int
min_precission
)
{
AVRational
q
;
int
j
;
if
(
st
->
codec
->
codec_type
==
AVMEDIA_TYPE_AUDIO
)
{
q
=
(
AVRational
){
1
,
st
->
codec
->
sample_rate
};
}
else
{
q
=
st
->
codec
->
time_base
;
}
for
(
j
=
2
;
j
<
2000
;
j
+=
1
+
(
j
>
2
))
while
(
q
.
den
/
q
.
num
<
min_precission
&&
q
.
num
%
j
==
0
)
q
.
num
/=
j
;
while
(
q
.
den
/
q
.
num
<
min_precission
&&
q
.
den
<
(
1
<<
24
))
q
.
den
<<=
1
;
return
q
;
}
int
avformat_alloc_output_context2
(
AVFormatContext
**
avctx
,
AVOutputFormat
*
oformat
,
const
char
*
format
,
const
char
*
filename
)
{
...
...
libavformat/nutenc.c
View file @
de707bc8
...
...
@@ -676,11 +676,7 @@ static int nut_write_header(AVFormatContext *s){
if
(
st
->
codec
->
codec_type
==
AVMEDIA_TYPE_AUDIO
&&
st
->
codec
->
sample_rate
)
{
time_base
=
(
AVRational
){
1
,
st
->
codec
->
sample_rate
};
}
else
{
for
(
j
=
2
;
j
<
2000
;
j
+=
1
+
(
j
>
2
))
while
(
time_base
.
den
/
time_base
.
num
<
48000
&&
time_base
.
num
%
j
==
0
)
time_base
.
num
/=
j
;
while
(
time_base
.
den
/
time_base
.
num
<
48000
&&
time_base
.
den
<
(
1
<<
24
))
time_base
.
den
<<=
1
;
time_base
=
ff_choose_timebase
(
s
,
st
,
48000
);
}
avpriv_set_pts_info
(
st
,
64
,
time_base
.
num
,
time_base
.
den
);
...
...
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