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
4fa1f52e
Commit
4fa1f52e
authored
Feb 25, 2013
by
Anton Khirnov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
af_resample: switch to an AVOptions-based system.
parent
b439c992
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
53 additions
and
20 deletions
+53
-20
af_resample.c
libavfilter/af_resample.c
+41
-16
avfilter.c
libavfilter/avfilter.c
+5
-4
avfilter.h
libavfilter/avfilter.h
+7
-0
No files found.
libavfilter/af_resample.c
View file @
4fa1f52e
...
@@ -37,6 +37,7 @@
...
@@ -37,6 +37,7 @@
#include "internal.h"
#include "internal.h"
typedef
struct
ResampleContext
{
typedef
struct
ResampleContext
{
const
AVClass
*
class
;
AVAudioResampleContext
*
avr
;
AVAudioResampleContext
*
avr
;
AVDictionary
*
options
;
AVDictionary
*
options
;
...
@@ -46,26 +47,30 @@ typedef struct ResampleContext {
...
@@ -46,26 +47,30 @@ typedef struct ResampleContext {
int
got_output
;
int
got_output
;
}
ResampleContext
;
}
ResampleContext
;
static
av_cold
int
init
(
AVFilterContext
*
ctx
,
const
char
*
arg
s
)
static
av_cold
int
init
(
AVFilterContext
*
ctx
,
AVDictionary
**
opt
s
)
{
{
ResampleContext
*
s
=
ctx
->
priv
;
ResampleContext
*
s
=
ctx
->
priv
;
const
AVClass
*
avr_class
=
avresample_get_class
();
AVDictionaryEntry
*
e
=
NULL
;
if
(
args
)
{
while
((
e
=
av_dict_get
(
*
opts
,
""
,
e
,
AV_DICT_IGNORE_SUFFIX
)))
{
int
ret
=
av_dict_parse_string
(
&
s
->
options
,
args
,
"="
,
":"
,
0
);
if
(
av_opt_find
(
&
avr_class
,
e
->
key
,
NULL
,
0
,
if
(
ret
<
0
)
{
AV_OPT_SEARCH_FAKE_OBJ
|
AV_OPT_SEARCH_CHILDREN
))
av_log
(
ctx
,
AV_LOG_ERROR
,
"error setting option string: %s
\n
"
,
args
);
av_dict_set
(
&
s
->
options
,
e
->
key
,
e
->
value
,
0
);
return
ret
;
}
/* do not allow the user to override basic format options */
av_dict_set
(
&
s
->
options
,
"in_channel_layout"
,
NULL
,
0
);
av_dict_set
(
&
s
->
options
,
"out_channel_layout"
,
NULL
,
0
);
av_dict_set
(
&
s
->
options
,
"in_sample_fmt"
,
NULL
,
0
);
av_dict_set
(
&
s
->
options
,
"out_sample_fmt"
,
NULL
,
0
);
av_dict_set
(
&
s
->
options
,
"in_sample_rate"
,
NULL
,
0
);
av_dict_set
(
&
s
->
options
,
"out_sample_rate"
,
NULL
,
0
);
}
}
e
=
NULL
;
while
((
e
=
av_dict_get
(
s
->
options
,
""
,
e
,
AV_DICT_IGNORE_SUFFIX
)))
av_dict_set
(
opts
,
e
->
key
,
NULL
,
0
);
/* do not allow the user to override basic format options */
av_dict_set
(
&
s
->
options
,
"in_channel_layout"
,
NULL
,
0
);
av_dict_set
(
&
s
->
options
,
"out_channel_layout"
,
NULL
,
0
);
av_dict_set
(
&
s
->
options
,
"in_sample_fmt"
,
NULL
,
0
);
av_dict_set
(
&
s
->
options
,
"out_sample_fmt"
,
NULL
,
0
);
av_dict_set
(
&
s
->
options
,
"in_sample_rate"
,
NULL
,
0
);
av_dict_set
(
&
s
->
options
,
"out_sample_rate"
,
NULL
,
0
);
return
0
;
return
0
;
}
}
...
@@ -272,6 +277,25 @@ fail:
...
@@ -272,6 +277,25 @@ fail:
return
ret
;
return
ret
;
}
}
static
const
AVClass
*
resample_child_class_next
(
const
AVClass
*
prev
)
{
return
prev
?
NULL
:
avresample_get_class
();
}
static
void
*
resample_child_next
(
void
*
obj
,
void
*
prev
)
{
ResampleContext
*
s
=
obj
;
return
prev
?
NULL
:
s
->
avr
;
}
static
const
AVClass
resample_class
=
{
.
class_name
=
"resample"
,
.
item_name
=
av_default_item_name
,
.
version
=
LIBAVUTIL_VERSION_INT
,
.
child_class_next
=
resample_child_class_next
,
.
child_next
=
resample_child_next
,
};
static
const
AVFilterPad
avfilter_af_resample_inputs
[]
=
{
static
const
AVFilterPad
avfilter_af_resample_inputs
[]
=
{
{
{
.
name
=
"default"
,
.
name
=
"default"
,
...
@@ -295,8 +319,9 @@ AVFilter avfilter_af_resample = {
...
@@ -295,8 +319,9 @@ AVFilter avfilter_af_resample = {
.
name
=
"resample"
,
.
name
=
"resample"
,
.
description
=
NULL_IF_CONFIG_SMALL
(
"Audio resampling and conversion."
),
.
description
=
NULL_IF_CONFIG_SMALL
(
"Audio resampling and conversion."
),
.
priv_size
=
sizeof
(
ResampleContext
),
.
priv_size
=
sizeof
(
ResampleContext
),
.
priv_class
=
&
resample_class
,
.
init
=
init
,
.
init
_dict
=
init
,
.
uninit
=
uninit
,
.
uninit
=
uninit
,
.
query_formats
=
query_formats
,
.
query_formats
=
query_formats
,
...
...
libavfilter/avfilter.c
View file @
4fa1f52e
...
@@ -501,11 +501,12 @@ int avfilter_init_filter(AVFilterContext *filter, const char *args, void *opaque
...
@@ -501,11 +501,12 @@ int avfilter_init_filter(AVFilterContext *filter, const char *args, void *opaque
}
}
}
}
if
(
filter
->
filter
->
init
)
{
if
(
filter
->
filter
->
init
)
ret
=
filter
->
filter
->
init
(
filter
,
args
);
ret
=
filter
->
filter
->
init
(
filter
,
args
);
if
(
ret
<
0
)
else
if
(
filter
->
filter
->
init_dict
)
goto
fail
;
ret
=
filter
->
filter
->
init_dict
(
filter
,
&
options
);
}
if
(
ret
<
0
)
goto
fail
;
if
((
e
=
av_dict_get
(
options
,
""
,
NULL
,
AV_DICT_IGNORE_SUFFIX
)))
{
if
((
e
=
av_dict_get
(
options
,
""
,
NULL
,
AV_DICT_IGNORE_SUFFIX
)))
{
av_log
(
filter
,
AV_LOG_ERROR
,
"No such option: %s.
\n
"
,
e
->
key
);
av_log
(
filter
,
AV_LOG_ERROR
,
"No such option: %s.
\n
"
,
e
->
key
);
...
...
libavfilter/avfilter.h
View file @
4fa1f52e
...
@@ -408,6 +408,13 @@ typedef struct AVFilter {
...
@@ -408,6 +408,13 @@ typedef struct AVFilter {
*/
*/
int
(
*
init
)(
AVFilterContext
*
ctx
,
const
char
*
args
);
int
(
*
init
)(
AVFilterContext
*
ctx
,
const
char
*
args
);
/**
* Should be set instead of init by the filters that want to pass a
* dictionary of AVOptions to nested contexts that are allocated in
* init.
*/
int
(
*
init_dict
)(
AVFilterContext
*
ctx
,
AVDictionary
**
options
);
/**
/**
* Filter uninitialization function. Should deallocate any memory held
* Filter uninitialization function. Should deallocate any memory held
* by the filter, release any buffer references, etc. This does not need
* by the filter, release any buffer references, etc. This does not need
...
...
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