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
2915b611
Commit
2915b611
authored
May 24, 2010
by
Laurent Aimar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Moved var_InheritURational to the core.
parent
67b39ef6
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
59 additions
and
55 deletions
+59
-55
include/vlc_variables.h
include/vlc_variables.h
+3
-0
modules/access/imem.c
modules/access/imem.c
+2
-55
src/libvlccore.sym
src/libvlccore.sym
+1
-0
src/misc/variables.c
src/misc/variables.c
+53
-0
No files found.
include/vlc_variables.h
View file @
2915b611
...
...
@@ -712,6 +712,9 @@ static inline mtime_t var_InheritTime( vlc_object_t *obj, const char *name )
}
#define var_InheritTime(o, n) var_InheritTime(VLC_OBJECT(o), n)
VLC_EXPORT
(
int
,
var_InheritURational
,
(
vlc_object_t
*
,
unsigned
*
num
,
unsigned
*
den
,
const
char
*
var
)
);
#define var_InheritURational(a,b,c,d) var_InheritURational(VLC_OBJECT(a), b, c, d)
#define var_GetInteger(a,b) var_GetInteger( VLC_OBJECT(a),b)
#define var_GetBool(a,b) var_GetBool( VLC_OBJECT(a),b)
#define var_GetTime(a,b) var_GetTime( VLC_OBJECT(a),b)
...
...
modules/access/imem.c
View file @
2915b611
...
...
@@ -224,10 +224,6 @@ typedef struct {
}
imem_sys_t
;
static
void
ParseMRL
(
vlc_object_t
*
,
const
char
*
);
#define var_InheritRational(a,b,c,d) var_InheritRational(VLC_OBJECT(a),b,c,d)
static
int
(
var_InheritRational
)(
vlc_object_t
*
,
unsigned
*
num
,
unsigned
*
den
,
const
char
*
var
);
/**
* It closes the common part of the access and access_demux
...
...
@@ -440,13 +436,13 @@ static int OpenDemux(vlc_object_t *object)
fmt
.
video
.
i_width
=
var_InheritInteger
(
object
,
"imem-width"
);
fmt
.
video
.
i_height
=
var_InheritInteger
(
object
,
"imem-height"
);
unsigned
num
,
den
;
if
(
!
var_InheritRational
(
object
,
&
num
,
&
den
,
"imem-dar"
)
&&
num
>
0
&&
den
>
0
)
{
if
(
!
var_Inherit
U
Rational
(
object
,
&
num
,
&
den
,
"imem-dar"
)
&&
num
>
0
&&
den
>
0
)
{
if
(
fmt
.
video
.
i_width
>
0
&&
fmt
.
video
.
i_height
>
0
)
{
fmt
.
video
.
i_sar_num
=
num
*
fmt
.
video
.
i_height
;
fmt
.
video
.
i_sar_den
=
den
*
fmt
.
video
.
i_width
;
}
}
if
(
!
var_InheritRational
(
object
,
&
num
,
&
den
,
"imem-fps"
)
&&
num
>
0
&&
den
>
0
)
{
if
(
!
var_Inherit
U
Rational
(
object
,
&
num
,
&
den
,
"imem-fps"
)
&&
num
>
0
&&
den
>
0
)
{
fmt
.
video
.
i_frame_rate
=
num
;
fmt
.
video
.
i_frame_rate_base
=
den
;
}
...
...
@@ -610,55 +606,6 @@ static int Demux(demux_t *demux)
return
1
;
}
/**
* It parses a rational number (it also accepts basic float number).
*
* It returns an error if the rational number cannot be parsed (0/0 is valid).
*/
static
int
(
var_InheritRational
)(
vlc_object_t
*
object
,
unsigned
*
num
,
unsigned
*
den
,
const
char
*
var
)
{
/* */
*
num
=
0
;
*
den
=
0
;
/* */
char
*
tmp
=
var_InheritString
(
object
,
var
);
if
(
!
tmp
)
goto
error
;
char
*
next
;
unsigned
n
=
strtol
(
tmp
,
&
next
,
0
);
unsigned
d
=
strtol
(
*
next
?
&
next
[
1
]
:
"0"
,
NULL
,
0
);
if
(
*
next
==
'.'
)
{
/* Interpret as a float number */
double
r
=
us_atof
(
tmp
);
double
c
=
ceil
(
r
);
if
(
c
>=
UINT_MAX
)
goto
error
;
unsigned
m
=
c
;
if
(
m
>
0
)
{
d
=
UINT_MAX
/
m
;
n
=
r
*
d
;
}
else
{
n
=
0
;
d
=
0
;
}
}
if
(
n
>
0
&&
d
>
0
)
vlc_ureduce
(
num
,
den
,
n
,
d
,
0
);
free
(
tmp
);
return
VLC_SUCCESS
;
error:
free
(
tmp
);
return
VLC_EGENERIC
;
}
/**
* Parse the MRL and extract configuration from it.
*
...
...
src/libvlccore.sym
View file @
2915b611
...
...
@@ -465,6 +465,7 @@ var_SetChecked
var_TriggerCallback
var_Type
var_Inherit
var_InheritURational
video_format_FixRgb
video_format_IsSimilar
video_format_Setup
...
...
src/misc/variables.c
View file @
2915b611
...
...
@@ -36,6 +36,8 @@
#include <search.h>
#include <assert.h>
#include <math.h>
#include <limits.h>
/*****************************************************************************
* Private types
...
...
@@ -1342,6 +1344,57 @@ int var_Inherit( vlc_object_t *p_this, const char *psz_name, int i_type,
}
/**
* It inherits a string as an unsigned rational number (it also accepts basic
* float number).
*
* It returns an error if the rational number cannot be parsed (0/0 is valid).
* The rational is already reduced.
*/
int
(
var_InheritURational
)(
vlc_object_t
*
object
,
unsigned
*
num
,
unsigned
*
den
,
const
char
*
var
)
{
/* */
*
num
=
0
;
*
den
=
0
;
/* */
char
*
tmp
=
var_InheritString
(
object
,
var
);
if
(
!
tmp
)
goto
error
;
char
*
next
;
unsigned
n
=
strtol
(
tmp
,
&
next
,
0
);
unsigned
d
=
strtol
(
*
next
?
&
next
[
1
]
:
"0"
,
NULL
,
0
);
if
(
*
next
==
'.'
)
{
/* Interpret as a float number */
double
r
=
us_atof
(
tmp
);
double
c
=
ceil
(
r
);
if
(
c
>=
UINT_MAX
)
goto
error
;
unsigned
m
=
c
;
if
(
m
>
0
)
{
d
=
UINT_MAX
/
m
;
n
=
r
*
d
;
}
else
{
n
=
0
;
d
=
0
;
}
}
if
(
n
>
0
&&
d
>
0
)
vlc_ureduce
(
num
,
den
,
n
,
d
,
0
);
free
(
tmp
);
return
VLC_SUCCESS
;
error:
free
(
tmp
);
return
VLC_EGENERIC
;
}
/**********************************************************************
* Trigger the callbacks.
* Tell we're in a callback, release the lock, call stored functions,
...
...
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