Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-2-2
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc-2-2
Commits
e2776598
Commit
e2776598
authored
Sep 09, 2004
by
Gildas Bazin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
* include/vlc_common.h, src/extras/libc.c: added GCD() and vlc_reduce().
parent
01993028
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
73 additions
and
0 deletions
+73
-0
include/vlc_common.h
include/vlc_common.h
+8
-0
src/extras/libc.c
src/extras/libc.c
+65
-0
No files found.
include/vlc_common.h
View file @
e2776598
...
@@ -475,6 +475,12 @@ typedef int ( * vlc_callback_t ) ( vlc_object_t *, /* variable's object */
...
@@ -475,6 +475,12 @@ typedef int ( * vlc_callback_t ) ( vlc_object_t *, /* variable's object */
# define __MIN(a, b) ( ((a) < (b)) ? (a) : (b) )
# define __MIN(a, b) ( ((a) < (b)) ? (a) : (b) )
#endif
#endif
static
int64_t
GCD
(
int64_t
a
,
int64_t
b
)
{
if
(
b
)
return
GCD
(
b
,
a
%
b
);
else
return
a
;
}
/* Dynamic array handling: realloc array, move data, increment position */
/* Dynamic array handling: realloc array, move data, increment position */
#define INSERT_ELEM( p_ar, i_oldsize, i_pos, elem ) \
#define INSERT_ELEM( p_ar, i_oldsize, i_pos, elem ) \
do \
do \
...
@@ -908,6 +914,8 @@ typedef __int64 off_t;
...
@@ -908,6 +914,8 @@ typedef __int64 off_t;
# define vlc_lseek NULL
# define vlc_lseek NULL
#endif
#endif
VLC_EXPORT
(
vlc_bool_t
,
vlc_reduce
,
(
int
*
,
int
*
,
int64_t
,
int64_t
,
int64_t
)
);
/* vlc_wraptext (defined in src/extras/libc.c) */
/* vlc_wraptext (defined in src/extras/libc.c) */
#define wraptext vlc_wraptext
#define wraptext vlc_wraptext
VLC_EXPORT
(
char
*
,
vlc_wraptext
,
(
const
char
*
,
int
,
vlc_bool_t
)
);
VLC_EXPORT
(
char
*
,
vlc_wraptext
,
(
const
char
*
,
int
,
vlc_bool_t
)
);
...
...
src/extras/libc.c
View file @
e2776598
...
@@ -421,3 +421,68 @@ int vlc_iconv_close( vlc_iconv_t cd )
...
@@ -421,3 +421,68 @@ int vlc_iconv_close( vlc_iconv_t cd )
return
0
;
return
0
;
#endif
#endif
}
}
/*****************************************************************************
* reduce a fraction
* (adapted from libavcodec, author Michael Niedermayer <michaelni@gmx.at>)
*****************************************************************************/
vlc_bool_t
vlc_reduce
(
int
*
pi_dst_nom
,
int
*
pi_dst_den
,
int64_t
i_nom
,
int64_t
i_den
,
int64_t
i_max
)
{
vlc_bool_t
b_exact
=
1
,
b_sign
=
0
;
int64_t
i_gcd
;
if
(
i_den
==
0
)
{
i_nom
=
0
;
i_den
=
1
;
return
1
;
}
if
(
i_den
<
0
)
{
i_den
=
-
i_den
;
i_nom
=
-
i_nom
;
}
if
(
i_nom
<
0
)
{
i_nom
=
-
i_nom
;
b_sign
=
1
;
}
i_gcd
=
GCD
(
i_nom
,
i_den
);
i_nom
/=
i_gcd
;
i_den
/=
i_gcd
;
if
(
i_nom
>
i_max
||
i_den
>
i_max
)
{
int
i_a0_num
=
0
,
i_a0_den
=
1
,
i_a1_num
=
1
,
i_a1_den
=
0
;
b_exact
=
0
;
for
(
;
;
)
{
int64_t
i_x
=
i_nom
/
i_den
;
int64_t
i_a2n
=
i_x
*
i_a1_num
+
i_a0_num
;
int64_t
i_a2d
=
i_x
*
i_a1_den
+
i_a0_den
;
if
(
i_a2n
>
i_max
||
i_a2d
>
i_max
)
break
;
i_nom
%=
i_den
;
i_a0_num
=
i_a1_num
;
i_a0_den
=
i_a1_den
;
i_a1_num
=
i_a2n
;
i_a1_den
=
i_a2d
;
if
(
i_nom
==
0
)
break
;
i_x
=
i_nom
;
i_nom
=
i_den
;
i_den
=
i_x
;
}
i_nom
=
i_a1_num
;
i_den
=
i_a1_den
;
}
if
(
b_sign
)
i_nom
=
-
i_nom
;
*
pi_dst_nom
=
i_nom
;
*
pi_dst_den
=
i_den
;
return
b_exact
;
}
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