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
4c64fed3
Commit
4c64fed3
authored
May 10, 2012
by
Anton Khirnov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lavfi: move formats-related functions from default.c to formats.c
It's more convenient to have them all in one file.
parent
c5432d3c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
64 additions
and
64 deletions
+64
-64
defaults.c
libavfilter/defaults.c
+0
-64
formats.c
libavfilter/formats.c
+64
-0
No files found.
libavfilter/defaults.c
View file @
4c64fed3
...
...
@@ -55,67 +55,3 @@ int avfilter_default_config_output_link(AVFilterLink *link)
return
0
;
}
#define SET_COMMON_FORMATS(ctx, fmts, in_fmts, out_fmts, ref, list) \
{ \
int count = 0, i; \
\
for (i = 0; i < ctx->input_count; i++) { \
if (ctx->inputs[i]) { \
ref(fmts, &ctx->inputs[i]->out_fmts); \
count++; \
} \
} \
for (i = 0; i < ctx->output_count; i++) { \
if (ctx->outputs[i]) { \
ref(fmts, &ctx->outputs[i]->in_fmts); \
count++; \
} \
} \
\
if (!count) { \
av_freep(&fmts->list); \
av_freep(&fmts->refs); \
av_freep(&fmts); \
} \
}
void
ff_set_common_channel_layouts
(
AVFilterContext
*
ctx
,
AVFilterChannelLayouts
*
layouts
)
{
SET_COMMON_FORMATS
(
ctx
,
layouts
,
in_channel_layouts
,
out_channel_layouts
,
ff_channel_layouts_ref
,
channel_layouts
);
}
void
ff_set_common_samplerates
(
AVFilterContext
*
ctx
,
AVFilterFormats
*
samplerates
)
{
SET_COMMON_FORMATS
(
ctx
,
samplerates
,
in_samplerates
,
out_samplerates
,
avfilter_formats_ref
,
formats
);
}
/**
* A helper for query_formats() which sets all links to the same list of
* formats. If there are no links hooked to this filter, the list of formats is
* freed.
*/
void
avfilter_set_common_formats
(
AVFilterContext
*
ctx
,
AVFilterFormats
*
formats
)
{
SET_COMMON_FORMATS
(
ctx
,
formats
,
in_formats
,
out_formats
,
avfilter_formats_ref
,
formats
);
}
int
avfilter_default_query_formats
(
AVFilterContext
*
ctx
)
{
enum
AVMediaType
type
=
ctx
->
inputs
&&
ctx
->
inputs
[
0
]
?
ctx
->
inputs
[
0
]
->
type
:
ctx
->
outputs
&&
ctx
->
outputs
[
0
]
?
ctx
->
outputs
[
0
]
->
type
:
AVMEDIA_TYPE_VIDEO
;
avfilter_set_common_formats
(
ctx
,
avfilter_all_formats
(
type
));
if
(
type
==
AVMEDIA_TYPE_AUDIO
)
{
ff_set_common_channel_layouts
(
ctx
,
ff_all_channel_layouts
());
ff_set_common_samplerates
(
ctx
,
ff_all_samplerates
());
}
return
0
;
}
libavfilter/formats.c
View file @
4c64fed3
...
...
@@ -314,3 +314,67 @@ void avfilter_formats_changeref(AVFilterFormats **oldref,
{
FORMATS_CHANGEREF
(
oldref
,
newref
);
}
#define SET_COMMON_FORMATS(ctx, fmts, in_fmts, out_fmts, ref, list) \
{ \
int count = 0, i; \
\
for (i = 0; i < ctx->input_count; i++) { \
if (ctx->inputs[i]) { \
ref(fmts, &ctx->inputs[i]->out_fmts); \
count++; \
} \
} \
for (i = 0; i < ctx->output_count; i++) { \
if (ctx->outputs[i]) { \
ref(fmts, &ctx->outputs[i]->in_fmts); \
count++; \
} \
} \
\
if (!count) { \
av_freep(&fmts->list); \
av_freep(&fmts->refs); \
av_freep(&fmts); \
} \
}
void
ff_set_common_channel_layouts
(
AVFilterContext
*
ctx
,
AVFilterChannelLayouts
*
layouts
)
{
SET_COMMON_FORMATS
(
ctx
,
layouts
,
in_channel_layouts
,
out_channel_layouts
,
ff_channel_layouts_ref
,
channel_layouts
);
}
void
ff_set_common_samplerates
(
AVFilterContext
*
ctx
,
AVFilterFormats
*
samplerates
)
{
SET_COMMON_FORMATS
(
ctx
,
samplerates
,
in_samplerates
,
out_samplerates
,
avfilter_formats_ref
,
formats
);
}
/**
* A helper for query_formats() which sets all links to the same list of
* formats. If there are no links hooked to this filter, the list of formats is
* freed.
*/
void
avfilter_set_common_formats
(
AVFilterContext
*
ctx
,
AVFilterFormats
*
formats
)
{
SET_COMMON_FORMATS
(
ctx
,
formats
,
in_formats
,
out_formats
,
avfilter_formats_ref
,
formats
);
}
int
avfilter_default_query_formats
(
AVFilterContext
*
ctx
)
{
enum
AVMediaType
type
=
ctx
->
inputs
&&
ctx
->
inputs
[
0
]
?
ctx
->
inputs
[
0
]
->
type
:
ctx
->
outputs
&&
ctx
->
outputs
[
0
]
?
ctx
->
outputs
[
0
]
->
type
:
AVMEDIA_TYPE_VIDEO
;
avfilter_set_common_formats
(
ctx
,
avfilter_all_formats
(
type
));
if
(
type
==
AVMEDIA_TYPE_AUDIO
)
{
ff_set_common_channel_layouts
(
ctx
,
ff_all_channel_layouts
());
ff_set_common_samplerates
(
ctx
,
ff_all_samplerates
());
}
return
0
;
}
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