Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
F
ffmpeg
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
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
ffmpeg
Commits
3a9f2f1d
Commit
3a9f2f1d
authored
Nov 13, 2011
by
Stefano Sabatini
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
vsrc_mandelbrot: set options through the opt framework
parent
c15400af
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
60 additions
and
24 deletions
+60
-24
avfilter.h
libavfilter/avfilter.h
+1
-1
vsrc_mandelbrot.c
libavfilter/vsrc_mandelbrot.c
+59
-23
No files found.
libavfilter/avfilter.h
View file @
3a9f2f1d
...
@@ -30,7 +30,7 @@
...
@@ -30,7 +30,7 @@
#define LIBAVFILTER_VERSION_MAJOR 2
#define LIBAVFILTER_VERSION_MAJOR 2
#define LIBAVFILTER_VERSION_MINOR 48
#define LIBAVFILTER_VERSION_MINOR 48
#define LIBAVFILTER_VERSION_MICRO
0
#define LIBAVFILTER_VERSION_MICRO
1
#define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \
#define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \
LIBAVFILTER_VERSION_MINOR, \
LIBAVFILTER_VERSION_MINOR, \
...
...
libavfilter/vsrc_mandelbrot.c
View file @
3a9f2f1d
...
@@ -28,6 +28,7 @@
...
@@ -28,6 +28,7 @@
#include "avfilter.h"
#include "avfilter.h"
#include "libavutil/imgutils.h"
#include "libavutil/imgutils.h"
#include "libavutil/opt.h"
#include "libavutil/parseutils.h"
#include "libavutil/parseutils.h"
#define SQR(a) ((a)*(a))
#define SQR(a) ((a)*(a))
...
@@ -48,9 +49,11 @@ typedef struct Point {
...
@@ -48,9 +49,11 @@ typedef struct Point {
}
Point
;
}
Point
;
typedef
struct
{
typedef
struct
{
const
AVClass
*
class
;
int
w
,
h
;
int
w
,
h
;
AVRational
time_base
;
AVRational
time_base
;
uint64_t
pts
;
uint64_t
pts
;
char
*
size
,
*
rate
;
int
maxiter
;
int
maxiter
;
double
start_x
;
double
start_x
;
double
start_y
;
double
start_y
;
...
@@ -67,41 +70,72 @@ typedef struct {
...
@@ -67,41 +70,72 @@ typedef struct {
double
(
*
zyklus
)[
2
];
double
(
*
zyklus
)[
2
];
}
MBContext
;
}
MBContext
;
#define OFFSET(x) offsetof(MBContext, x)
static
const
AVOption
mandelbrot_options
[]
=
{
{
"size"
,
"set frame size"
,
OFFSET
(
size
),
AV_OPT_TYPE_STRING
,
{.
str
=
"640x480"
},
CHAR_MIN
,
CHAR_MAX
},
{
"s"
,
"set frame size"
,
OFFSET
(
size
),
AV_OPT_TYPE_STRING
,
{.
str
=
"640x480"
},
CHAR_MIN
,
CHAR_MAX
},
{
"rate"
,
"set frame rate"
,
OFFSET
(
rate
),
AV_OPT_TYPE_STRING
,
{.
str
=
"25"
},
CHAR_MIN
,
CHAR_MAX
},
{
"r"
,
"set frame rate"
,
OFFSET
(
rate
),
AV_OPT_TYPE_STRING
,
{.
str
=
"25"
},
CHAR_MIN
,
CHAR_MAX
},
{
"maxiter"
,
"set max iterations number"
,
OFFSET
(
maxiter
),
AV_OPT_TYPE_INT
,
{.
dbl
=
4096
},
1
,
INT_MAX
},
{
"start_x"
,
"set the initial x position"
,
OFFSET
(
start_x
),
AV_OPT_TYPE_DOUBLE
,
{.
dbl
=-
0
.
743643887037158704752191506114774
},
-
INFINITY
,
INFINITY
},
{
"start_y"
,
"set the initial y position"
,
OFFSET
(
start_y
),
AV_OPT_TYPE_DOUBLE
,
{.
dbl
=-
0
.
131825904205311970493132056385139
},
-
INFINITY
,
INFINITY
},
{
"start_scale"
,
"set the initial scale value"
,
OFFSET
(
start_scale
),
AV_OPT_TYPE_DOUBLE
,
{.
dbl
=
3
.
0
},
-
INFINITY
,
INFINITY
},
{
"end_scale"
,
"set the terminal scale value"
,
OFFSET
(
end_scale
),
AV_OPT_TYPE_DOUBLE
,
{.
dbl
=
0
.
3
},
-
INFINITY
,
INFINITY
},
{
"end_pts"
,
"set the terminal pts value"
,
OFFSET
(
end_pts
),
AV_OPT_TYPE_DOUBLE
,
{.
dbl
=
800
},
-
INFINITY
,
INFINITY
},
{
"bailout"
,
"set the bailout value"
,
OFFSET
(
bailout
),
AV_OPT_TYPE_DOUBLE
,
{.
dbl
=
10
},
-
INFINITY
,
INFINITY
},
{
"outer"
,
"set outer coloring mode"
,
OFFSET
(
outer
),
AV_OPT_TYPE_INT
,
{.
dbl
=
NORMALIZED_ITERATION_COUNT
},
0
,
INT_MAX
,
0
,
"outer"
},
{
"iteration_count"
,
"set iteration count mode"
,
0
,
AV_OPT_TYPE_CONST
,
{.
dbl
=
ITERATION_COUNT
},
INT_MIN
,
INT_MAX
,
0
,
"outer"
},
{
"normalized_iteration_count"
,
"set normalized iteration count mode"
,
0
,
AV_OPT_TYPE_CONST
,
{.
dbl
=
NORMALIZED_ITERATION_COUNT
},
INT_MIN
,
INT_MAX
,
0
,
"outer"
},
{
"inner"
,
"set inner coloring mode"
,
OFFSET
(
inner
),
AV_OPT_TYPE_INT
,
{.
dbl
=
BLACK
},
0
,
INT_MAX
,
0
,
"inner"
},
{
"black"
,
"set black mode"
,
0
,
AV_OPT_TYPE_CONST
,
{.
dbl
=
BLACK
},
INT_MIN
,
INT_MAX
,
0
,
"inner"
},
{
"period"
,
"set period mode"
,
0
,
AV_OPT_TYPE_CONST
,
{.
dbl
=
PERIOD
},
INT_MIN
,
INT_MAX
,
0
,
"inner"
},
{
NULL
},
};
static
const
char
*
mandelbrot_get_name
(
void
*
ctx
)
{
return
"mandelbrot"
;
}
static
const
AVClass
mandelbrot_class
=
{
"MBContext"
,
mandelbrot_get_name
,
mandelbrot_options
};
static
av_cold
int
init
(
AVFilterContext
*
ctx
,
const
char
*
args
,
void
*
opaque
)
static
av_cold
int
init
(
AVFilterContext
*
ctx
,
const
char
*
args
,
void
*
opaque
)
{
{
MBContext
*
mb
=
ctx
->
priv
;
MBContext
*
mb
=
ctx
->
priv
;
char
frame_size
[
128
]
=
"640x480"
;
AVRational
rate_q
;
char
frame_rate
[
128
]
=
"25"
;
int
err
;
AVRational
frame_rate_q
;
mb
->
class
=
&
mandelbrot_class
;
mb
->
maxiter
=
4096
;
av_opt_set_defaults
(
mb
);
mb
->
start_x
=-
0
.
743643887037158704752191506114774
;
mb
->
start_y
=-
0
.
131825904205311970493132056385139
;
if
((
err
=
(
av_set_options_string
(
mb
,
args
,
"="
,
":"
)))
<
0
)
{
mb
->
start_scale
=
3
.
0
;
av_log
(
ctx
,
AV_LOG_ERROR
,
"Error parsing options string: '%s'
\n
"
,
args
);
mb
->
end_scale
=
0
.
3
;
return
err
;
mb
->
end_pts
=
800
;
}
mb
->
bailout
=
10
;
mb
->
outer
=
NORMALIZED_ITERATION_COUNT
;
if
(
args
)
sscanf
(
args
,
"%127[^:]:%127[^:]:%d:%lf:%lf:%lf:%lf:%lf:%lf:%d"
,
frame_size
,
frame_rate
,
&
mb
->
maxiter
,
&
mb
->
start_x
,
&
mb
->
start_y
,
&
mb
->
start_scale
,
&
mb
->
end_scale
,
&
mb
->
end_pts
,
&
mb
->
bailout
,
&
mb
->
outer
);
mb
->
bailout
*=
mb
->
bailout
;
mb
->
bailout
*=
mb
->
bailout
;
if
(
av_parse_video_size
(
&
mb
->
w
,
&
mb
->
h
,
frame_
size
)
<
0
)
{
if
(
av_parse_video_size
(
&
mb
->
w
,
&
mb
->
h
,
mb
->
size
)
<
0
)
{
av_log
(
ctx
,
AV_LOG_ERROR
,
"Invalid frame size: %s
\n
"
,
frame_
size
);
av_log
(
ctx
,
AV_LOG_ERROR
,
"Invalid frame size: %s
\n
"
,
mb
->
size
);
return
AVERROR
(
EINVAL
);
return
AVERROR
(
EINVAL
);
}
}
mb
->
start_scale
/=
mb
->
h
;
mb
->
start_scale
/=
mb
->
h
;
mb
->
end_scale
/=
mb
->
h
;
mb
->
end_scale
/=
mb
->
h
;
if
(
av_parse_video_rate
(
&
frame_rate_q
,
frame_
rate
)
<
0
||
if
(
av_parse_video_rate
(
&
rate_q
,
mb
->
rate
)
<
0
||
frame_rate_q
.
den
<=
0
||
frame_
rate_q
.
num
<=
0
)
{
rate_q
.
den
<=
0
||
rate_q
.
num
<=
0
)
{
av_log
(
ctx
,
AV_LOG_ERROR
,
"Invalid frame rate: %s
\n
"
,
frame_
rate
);
av_log
(
ctx
,
AV_LOG_ERROR
,
"Invalid frame rate: %s
\n
"
,
mb
->
rate
);
return
AVERROR
(
EINVAL
);
return
AVERROR
(
EINVAL
);
}
}
mb
->
time_base
.
num
=
frame_
rate_q
.
den
;
mb
->
time_base
.
num
=
rate_q
.
den
;
mb
->
time_base
.
den
=
frame_
rate_q
.
num
;
mb
->
time_base
.
den
=
rate_q
.
num
;
mb
->
cache_allocated
=
mb
->
w
*
mb
->
h
*
3
;
mb
->
cache_allocated
=
mb
->
w
*
mb
->
h
*
3
;
mb
->
cache_used
=
0
;
mb
->
cache_used
=
0
;
...
@@ -116,6 +150,8 @@ static av_cold void uninit(AVFilterContext *ctx)
...
@@ -116,6 +150,8 @@ static av_cold void uninit(AVFilterContext *ctx)
{
{
MBContext
*
mb
=
ctx
->
priv
;
MBContext
*
mb
=
ctx
->
priv
;
av_freep
(
&
mb
->
size
);
av_freep
(
&
mb
->
rate
);
av_freep
(
&
mb
->
point_cache
);
av_freep
(
&
mb
->
point_cache
);
av_freep
(
&
mb
->
next_cache
);
av_freep
(
&
mb
->
next_cache
);
av_freep
(
&
mb
->
zyklus
);
av_freep
(
&
mb
->
zyklus
);
...
...
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