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
9ce6c138
Commit
9ce6c138
authored
Jan 17, 2009
by
Aurelien Jacobs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
export gcd function as av_gcd()
Originally committed as revision 16653 to
svn://svn.ffmpeg.org/ffmpeg/trunk
parent
3194b004
Show whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
19 additions
and
20 deletions
+19
-20
h263.c
libavcodec/h263.c
+1
-1
libxvidff.c
libavcodec/libxvidff.c
+2
-2
mpegvideo_enc.c
libavcodec/mpegvideo_enc.c
+1
-1
snow.c
libavcodec/snow.c
+1
-1
utils.c
libavcodec/utils.c
+1
-1
mov.c
libavformat/mov.c
+2
-2
nutdec.c
libavformat/nutdec.c
+1
-1
riff.c
libavformat/riff.c
+1
-1
utils.c
libavformat/utils.c
+2
-2
avutil.h
libavutil/avutil.h
+1
-1
common.h
libavutil/common.h
+0
-3
mathematics.c
libavutil/mathematics.c
+2
-2
mathematics.h
libavutil/mathematics.h
+2
-0
rational.c
libavutil/rational.c
+2
-2
No files found.
libavcodec/h263.c
View file @
9ce6c138
...
...
@@ -5156,7 +5156,7 @@ int h263_decode_picture_header(MpegEncContext *s)
av_log
(
s
,
AV_LOG_ERROR
,
"zero framerate
\n
"
);
return
-
1
;
}
gcd
=
ff
_gcd
(
s
->
avctx
->
time_base
.
den
,
s
->
avctx
->
time_base
.
num
);
gcd
=
av
_gcd
(
s
->
avctx
->
time_base
.
den
,
s
->
avctx
->
time_base
.
num
);
s
->
avctx
->
time_base
.
den
/=
gcd
;
s
->
avctx
->
time_base
.
num
/=
gcd
;
// av_log(s->avctx, AV_LOG_DEBUG, "%d/%d\n", s->avctx->time_base.den, s->avctx->time_base.num);
...
...
libavcodec/libxvidff.c
View file @
9ce6c138
...
...
@@ -557,7 +557,7 @@ void xvid_correct_framerate(AVCodecContext *avctx) {
frate
=
avctx
->
time_base
.
den
;
fbase
=
avctx
->
time_base
.
num
;
gcd
=
ff
_gcd
(
frate
,
fbase
);
gcd
=
av
_gcd
(
frate
,
fbase
);
if
(
gcd
>
1
)
{
frate
/=
gcd
;
fbase
/=
gcd
;
...
...
@@ -579,7 +579,7 @@ void xvid_correct_framerate(AVCodecContext *avctx) {
}
else
est_fbase
=
1
;
gcd
=
ff
_gcd
(
est_frate
,
est_fbase
);
gcd
=
av
_gcd
(
est_frate
,
est_fbase
);
if
(
gcd
>
1
)
{
est_frate
/=
gcd
;
est_fbase
/=
gcd
;
...
...
libavcodec/mpegvideo_enc.c
View file @
9ce6c138
...
...
@@ -464,7 +464,7 @@ av_cold int MPV_encode_init(AVCodecContext *avctx)
avctx
->
b_frame_strategy
=
0
;
}
i
=
ff
_gcd
(
avctx
->
time_base
.
den
,
avctx
->
time_base
.
num
);
i
=
av
_gcd
(
avctx
->
time_base
.
den
,
avctx
->
time_base
.
num
);
if
(
i
>
1
){
av_log
(
avctx
,
AV_LOG_INFO
,
"removing common factors from framerate
\n
"
);
avctx
->
time_base
.
den
/=
i
;
...
...
libavcodec/snow.c
View file @
9ce6c138
...
...
@@ -4773,7 +4773,7 @@ int main(void){
}
error
=
(
int
)(
sqrt
(
error
)
+
0
.
5
);
errors
[
level
][
orientation
]
=
error
;
if
(
g
)
g
=
ff
_gcd
(
g
,
error
);
if
(
g
)
g
=
av
_gcd
(
g
,
error
);
else
g
=
error
;
}
}
...
...
libavcodec/utils.c
View file @
9ce6c138
...
...
@@ -694,7 +694,7 @@ void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode)
display_aspect_ratio
.
num
,
display_aspect_ratio
.
den
);
}
if
(
av_log_get_level
()
>=
AV_LOG_DEBUG
){
int
g
=
ff
_gcd
(
enc
->
time_base
.
num
,
enc
->
time_base
.
den
);
int
g
=
av
_gcd
(
enc
->
time_base
.
num
,
enc
->
time_base
.
den
);
snprintf
(
buf
+
strlen
(
buf
),
buf_size
-
strlen
(
buf
),
", %d/%d"
,
enc
->
time_base
.
num
/
g
,
enc
->
time_base
.
den
/
g
);
...
...
libavformat/mov.c
View file @
9ce6c138
...
...
@@ -1172,7 +1172,7 @@ static int mov_read_stts(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
sc
->
stts_data
[
i
].
count
=
sample_count
;
sc
->
stts_data
[
i
].
duration
=
sample_duration
;
sc
->
time_rate
=
ff
_gcd
(
sc
->
time_rate
,
sample_duration
);
sc
->
time_rate
=
av
_gcd
(
sc
->
time_rate
,
sample_duration
);
dprintf
(
c
->
fc
,
"sample_count=%d, sample_duration=%d
\n
"
,
sample_count
,
sample_duration
);
...
...
@@ -1215,7 +1215,7 @@ static int mov_read_ctts(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
sc
->
ctts_data
[
i
].
count
=
count
;
sc
->
ctts_data
[
i
].
duration
=
duration
;
sc
->
time_rate
=
ff
_gcd
(
sc
->
time_rate
,
FFABS
(
duration
));
sc
->
time_rate
=
av
_gcd
(
sc
->
time_rate
,
FFABS
(
duration
));
}
return
0
;
}
...
...
libavformat/nutdec.c
View file @
9ce6c138
...
...
@@ -206,7 +206,7 @@ static int decode_main_header(NUTContext *nut){
for
(
i
=
0
;
i
<
nut
->
time_base_count
;
i
++
){
GET_V
(
nut
->
time_base
[
i
].
num
,
tmp
>
0
&&
tmp
<
(
1ULL
<<
31
))
GET_V
(
nut
->
time_base
[
i
].
den
,
tmp
>
0
&&
tmp
<
(
1ULL
<<
31
))
if
(
ff
_gcd
(
nut
->
time_base
[
i
].
num
,
nut
->
time_base
[
i
].
den
)
!=
1
){
if
(
av
_gcd
(
nut
->
time_base
[
i
].
num
,
nut
->
time_base
[
i
].
den
)
!=
1
){
av_log
(
s
,
AV_LOG_ERROR
,
"time base invalid
\n
"
);
return
-
1
;
}
...
...
libavformat/riff.c
View file @
9ce6c138
...
...
@@ -466,7 +466,7 @@ void ff_parse_specific_params(AVCodecContext *stream, int *au_rate, int *au_ssiz
*
au_scale
=
stream
->
block_align
?
stream
->
block_align
*
8
:
8
;
*
au_rate
=
stream
->
bit_rate
?
stream
->
bit_rate
:
8
*
stream
->
sample_rate
;
}
gcd
=
ff
_gcd
(
*
au_scale
,
*
au_rate
);
gcd
=
av
_gcd
(
*
au_scale
,
*
au_rate
);
*
au_scale
/=
gcd
;
*
au_rate
/=
gcd
;
}
libavformat/utils.c
View file @
9ce6c138
...
...
@@ -2727,7 +2727,7 @@ static void dump_stream_format(AVFormatContext *ic, int i, int index, int is_out
char
buf
[
256
];
int
flags
=
(
is_output
?
ic
->
oformat
->
flags
:
ic
->
iformat
->
flags
);
AVStream
*
st
=
ic
->
streams
[
i
];
int
g
=
ff
_gcd
(
st
->
time_base
.
num
,
st
->
time_base
.
den
);
int
g
=
av
_gcd
(
st
->
time_base
.
num
,
st
->
time_base
.
den
);
avcodec_string
(
buf
,
sizeof
(
buf
),
st
->
codec
,
is_output
);
av_log
(
NULL
,
AV_LOG_INFO
,
" Stream #%d.%d"
,
index
,
i
);
/* the pid is an important information, so we display it */
...
...
@@ -3192,7 +3192,7 @@ char *ff_data_to_hex(char *buff, const uint8_t *src, int s)
void
av_set_pts_info
(
AVStream
*
s
,
int
pts_wrap_bits
,
int
pts_num
,
int
pts_den
)
{
unsigned
int
gcd
=
ff
_gcd
(
pts_num
,
pts_den
);
unsigned
int
gcd
=
av
_gcd
(
pts_num
,
pts_den
);
s
->
pts_wrap_bits
=
pts_wrap_bits
;
s
->
time_base
.
num
=
pts_num
/
gcd
;
s
->
time_base
.
den
=
pts_den
/
gcd
;
...
...
libavutil/avutil.h
View file @
9ce6c138
...
...
@@ -35,7 +35,7 @@
#define AV_VERSION(a, b, c) AV_VERSION_DOT(a, b, c)
#define LIBAVUTIL_VERSION_MAJOR 49
#define LIBAVUTIL_VERSION_MINOR 1
2
#define LIBAVUTIL_VERSION_MINOR 1
3
#define LIBAVUTIL_VERSION_MICRO 0
#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
...
...
libavutil/common.h
View file @
9ce6c138
...
...
@@ -242,9 +242,6 @@ static inline av_const float av_clipf(float a, float amin, float amax)
else
return
a
;
}
/* math */
int64_t
av_const
ff_gcd
(
int64_t
a
,
int64_t
b
);
/**
* converts fourcc string to int
*/
...
...
libavutil/mathematics.c
View file @
9ce6c138
...
...
@@ -48,8 +48,8 @@ const uint8_t ff_log2_tab[256]={
7
,
7
,
7
,
7
,
7
,
7
,
7
,
7
,
7
,
7
,
7
,
7
,
7
,
7
,
7
,
7
,
7
,
7
,
7
,
7
,
7
,
7
,
7
,
7
,
7
,
7
,
7
,
7
,
7
,
7
,
7
,
7
};
int64_t
ff
_gcd
(
int64_t
a
,
int64_t
b
){
if
(
b
)
return
ff
_gcd
(
b
,
a
%
b
);
int64_t
av
_gcd
(
int64_t
a
,
int64_t
b
){
if
(
b
)
return
av
_gcd
(
b
,
a
%
b
);
else
return
a
;
}
...
...
libavutil/mathematics.h
View file @
9ce6c138
...
...
@@ -49,6 +49,8 @@ enum AVRounding {
AV_ROUND_NEAR_INF
=
5
,
///< round to nearest and halfway cases away from zero
};
int64_t
av_const
av_gcd
(
int64_t
a
,
int64_t
b
);
/**
* rescale a 64bit integer with rounding to nearest.
* a simple a*b/c isn't possible as it can overflow
...
...
libavutil/rational.c
View file @
9ce6c138
...
...
@@ -35,7 +35,7 @@
int
av_reduce
(
int
*
dst_nom
,
int
*
dst_den
,
int64_t
nom
,
int64_t
den
,
int64_t
max
){
AVRational
a0
=
{
0
,
1
},
a1
=
{
1
,
0
};
int
sign
=
(
nom
<
0
)
^
(
den
<
0
);
int64_t
gcd
=
ff
_gcd
(
FFABS
(
nom
),
FFABS
(
den
));
int64_t
gcd
=
av
_gcd
(
FFABS
(
nom
),
FFABS
(
den
));
if
(
gcd
){
nom
=
FFABS
(
nom
)
/
gcd
;
...
...
@@ -66,7 +66,7 @@ int av_reduce(int *dst_nom, int *dst_den, int64_t nom, int64_t den, int64_t max)
nom
=
den
;
den
=
next_den
;
}
assert
(
ff
_gcd
(
a1
.
num
,
a1
.
den
)
<=
1U
);
assert
(
av
_gcd
(
a1
.
num
,
a1
.
den
)
<=
1U
);
*
dst_nom
=
sign
?
-
a1
.
num
:
a1
.
num
;
*
dst_den
=
a1
.
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