Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
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
Commits
ca546680
Commit
ca546680
authored
Sep 03, 2009
by
Laurent Aimar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed video_filter chain for chroma conversion.
parent
e67115c0
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
54 additions
and
29 deletions
+54
-29
modules/video_filter/chain.c
modules/video_filter/chain.c
+54
-29
No files found.
modules/video_filter/chain.c
View file @
ca546680
...
@@ -54,7 +54,7 @@ static int BufferAllocationInit ( filter_t *, void * );
...
@@ -54,7 +54,7 @@ static int BufferAllocationInit ( filter_t *, void * );
static
int
BuildChromaResize
(
filter_t
*
);
static
int
BuildChromaResize
(
filter_t
*
);
static
int
BuildChromaChain
(
filter_t
*
p_filter
);
static
int
BuildChromaChain
(
filter_t
*
p_filter
);
static
int
CreateChain
(
filter_chain_t
*
p_chain
,
es_format_t
*
p_fmt_mid
);
static
int
CreateChain
(
filter_chain_t
*
p_chain
,
es_format_t
*
p_fmt_mid
,
config_chain_t
*
);
static
void
EsFormatMergeSize
(
es_format_t
*
p_dst
,
static
void
EsFormatMergeSize
(
es_format_t
*
p_dst
,
const
es_format_t
*
p_base
,
const
es_format_t
*
p_base
,
const
es_format_t
*
p_size
);
const
es_format_t
*
p_size
);
...
@@ -72,7 +72,7 @@ struct filter_sys_t
...
@@ -72,7 +72,7 @@ struct filter_sys_t
filter_chain_t
*
p_chain
;
filter_chain_t
*
p_chain
;
};
};
#define CHAIN_LEVEL_MAX
4
#define CHAIN_LEVEL_MAX
1
/*****************************************************************************
/*****************************************************************************
* Activate: allocate a chroma function
* Activate: allocate a chroma function
...
@@ -88,9 +88,7 @@ static int Activate( vlc_object_t *p_this )
...
@@ -88,9 +88,7 @@ static int Activate( vlc_object_t *p_this )
const
bool
b_chroma
=
p_filter
->
fmt_in
.
video
.
i_chroma
!=
p_filter
->
fmt_out
.
video
.
i_chroma
;
const
bool
b_chroma
=
p_filter
->
fmt_in
.
video
.
i_chroma
!=
p_filter
->
fmt_out
.
video
.
i_chroma
;
const
bool
b_resize
=
p_filter
->
fmt_in
.
video
.
i_width
!=
p_filter
->
fmt_out
.
video
.
i_width
||
const
bool
b_resize
=
p_filter
->
fmt_in
.
video
.
i_width
!=
p_filter
->
fmt_out
.
video
.
i_width
||
p_filter
->
fmt_in
.
video
.
i_height
!=
p_filter
->
fmt_out
.
video
.
i_height
;
p_filter
->
fmt_in
.
video
.
i_height
!=
p_filter
->
fmt_out
.
video
.
i_height
;
if
(
!
b_chroma
&&
!
b_resize
)
/* XXX Remove check on b_resize to build chroma chain (untested) */
if
(
!
b_chroma
||
!
b_resize
)
return
VLC_EGENERIC
;
return
VLC_EGENERIC
;
p_sys
=
p_filter
->
p_sys
=
malloc
(
sizeof
(
*
p_sys
)
);
p_sys
=
p_filter
->
p_sys
=
malloc
(
sizeof
(
*
p_sys
)
);
...
@@ -105,7 +103,6 @@ static int Activate( vlc_object_t *p_this )
...
@@ -105,7 +103,6 @@ static int Activate( vlc_object_t *p_this )
free
(
p_sys
);
free
(
p_sys
);
return
VLC_EGENERIC
;
return
VLC_EGENERIC
;
}
}
filter_chain_Reset
(
p_sys
->
p_chain
,
&
p_filter
->
fmt_in
,
&
p_filter
->
fmt_out
);
if
(
b_chroma
&&
b_resize
)
if
(
b_chroma
&&
b_resize
)
i_ret
=
BuildChromaResize
(
p_filter
);
i_ret
=
BuildChromaResize
(
p_filter
);
...
@@ -151,17 +148,21 @@ static int BuildChromaResize( filter_t *p_filter )
...
@@ -151,17 +148,21 @@ static int BuildChromaResize( filter_t *p_filter )
int
i_ret
;
int
i_ret
;
/* Lets try resizing and then doing the chroma conversion */
/* Lets try resizing and then doing the chroma conversion */
filter_chain_Reset
(
p_sys
->
p_chain
,
&
p_filter
->
fmt_in
,
&
p_filter
->
fmt_out
);
msg_Dbg
(
p_filter
,
"Trying to build resize+chroma"
);
msg_Dbg
(
p_filter
,
"Trying to build resize+chroma"
);
EsFormatMergeSize
(
&
fmt_mid
,
&
p_filter
->
fmt_in
,
&
p_filter
->
fmt_out
);
EsFormatMergeSize
(
&
fmt_mid
,
&
p_filter
->
fmt_in
,
&
p_filter
->
fmt_out
);
i_ret
=
CreateChain
(
p_sys
->
p_chain
,
&
fmt_mid
);
i_ret
=
CreateChain
(
p_sys
->
p_chain
,
&
fmt_mid
,
NULL
);
es_format_Clean
(
&
fmt_mid
);
es_format_Clean
(
&
fmt_mid
);
if
(
i_ret
==
VLC_SUCCESS
)
if
(
i_ret
==
VLC_SUCCESS
)
return
VLC_SUCCESS
;
return
VLC_SUCCESS
;
/* Lets try it the other way arround (chroma and then resize) */
/* Lets try it the other way arround (chroma and then resize) */
filter_chain_Reset
(
p_sys
->
p_chain
,
&
p_filter
->
fmt_in
,
&
p_filter
->
fmt_out
);
msg_Dbg
(
p_filter
,
"Trying to build chroma+resize"
);
msg_Dbg
(
p_filter
,
"Trying to build chroma+resize"
);
EsFormatMergeSize
(
&
fmt_mid
,
&
p_filter
->
fmt_out
,
&
p_filter
->
fmt_in
);
EsFormatMergeSize
(
&
fmt_mid
,
&
p_filter
->
fmt_out
,
&
p_filter
->
fmt_in
);
i_ret
=
CreateChain
(
p_sys
->
p_chain
,
&
fmt_mid
);
i_ret
=
CreateChain
(
p_sys
->
p_chain
,
&
fmt_mid
,
NULL
);
es_format_Clean
(
&
fmt_mid
);
es_format_Clean
(
&
fmt_mid
);
if
(
i_ret
==
VLC_SUCCESS
)
if
(
i_ret
==
VLC_SUCCESS
)
return
VLC_SUCCESS
;
return
VLC_SUCCESS
;
...
@@ -173,44 +174,68 @@ static int BuildChromaChain( filter_t *p_filter )
...
@@ -173,44 +174,68 @@ static int BuildChromaChain( filter_t *p_filter )
{
{
filter_sys_t
*
p_sys
=
p_filter
->
p_sys
;
filter_sys_t
*
p_sys
=
p_filter
->
p_sys
;
es_format_t
fmt_mid
;
es_format_t
fmt_mid
;
int
i_ret
;
int
i
;
/* We have to protect ourself against a too high recursion */
/* We have to protect ourself against a too high recursion */
const
char
*
psz_option
=
MODULE_STRING
"-level"
;
const
char
*
psz_option
=
MODULE_STRING
"-level"
;
bool
b_first
=
!
var_Type
(
p_filter
,
psz_option
);
int
i_level
=
0
;
for
(
const
config_chain_t
*
c
=
p_filter
->
p_cfg
;
c
!=
NULL
;
c
=
c
->
p_next
)
if
(
var_Create
(
p_filter
,
MODULE_STRING
"-level"
,
VLC_VAR_INTEGER
|
(
b_first
?
VLC_VAR_DOINHERIT
:
0
)
)
)
{
{
msg_Err
(
p_filter
,
"Failed to create %s variable"
,
psz_option
);
if
(
c
->
psz_name
&&
c
->
psz_value
&&
!
strcmp
(
c
->
psz_name
,
psz_option
)
)
return
VLC_EGENERIC
;
{
}
i_level
=
atoi
(
c
->
psz_value
);
int
i_level
=
var_GetInteger
(
p_filter
,
psz_option
);
if
(
i_level
<
0
||
i_level
>
CHAIN_LEVEL_MAX
)
if
(
i_level
>=
CHAIN_LEVEL_MAX
)
{
{
msg_Err
(
p_filter
,
"Too high level of recursion (%d)"
,
i_level
);
msg_Err
(
p_filter
,
"Too high level of recursion (%d)"
,
i_level
);
return
VLC_EGENERIC
;
return
VLC_EGENERIC
;
}
}
var_SetInteger
(
p_filter
,
psz_option
,
i_level
+
1
);
break
;
}
}
/* */
int
i_ret
=
VLC_EGENERIC
;
/* */
config_chain_t
cfg_level
;
memset
(
&
cfg_level
,
0
,
sizeof
(
cfg_level
));
cfg_level
.
psz_name
=
strdup
(
psz_option
);
if
(
asprintf
(
&
cfg_level
.
psz_value
,
"%d"
,
i_level
+
1
)
<
0
)
cfg_level
.
psz_value
=
NULL
;
if
(
!
cfg_level
.
psz_name
||
!
cfg_level
.
psz_value
)
goto
exit
;
/* Now try chroma format list */
/* Now try chroma format list */
for
(
i
=
0
;
pi_allowed_chromas
[
i
];
i
++
)
for
(
i
nt
i
=
0
;
pi_allowed_chromas
[
i
];
i
++
)
{
{
const
vlc_fourcc_t
i_chroma
=
pi_allowed_chromas
[
i
];
const
vlc_fourcc_t
i_chroma
=
pi_allowed_chromas
[
i
];
if
(
i_chroma
==
p_filter
->
fmt_in
.
i_codec
||
i_chroma
==
p_filter
->
fmt_out
.
i_codec
)
continue
;
msg_Dbg
(
p_filter
,
"Trying to use chroma %4.4s as middle man"
,
msg_Dbg
(
p_filter
,
"Trying to use chroma %4.4s as middle man"
,
(
char
*
)
&
i_chroma
);
(
char
*
)
&
i_chroma
);
es_format_Copy
(
&
fmt_mid
,
&
p_filter
->
fmt_in
);
es_format_Copy
(
&
fmt_mid
,
&
p_filter
->
fmt_in
);
fmt_mid
.
i_codec
=
fmt_mid
.
video
.
i_chroma
=
i_chroma
;
fmt_mid
.
video
.
i_chroma
=
i_chroma
;
fmt_mid
.
video
.
i_rmask
=
0
;
fmt_mid
.
video
.
i_gmask
=
0
;
fmt_mid
.
video
.
i_bmask
=
0
;
video_format_FixRgb
(
&
fmt_mid
.
video
);
i_ret
=
CreateChain
(
p_sys
->
p_chain
,
&
fmt_mid
);
filter_chain_Reset
(
p_sys
->
p_chain
,
&
p_filter
->
fmt_in
,
&
p_filter
->
fmt_out
);
i_ret
=
CreateChain
(
p_sys
->
p_chain
,
&
fmt_mid
,
&
cfg_level
);
es_format_Clean
(
&
fmt_mid
);
es_format_Clean
(
&
fmt_mid
);
if
(
i_ret
==
VLC_SUCCESS
)
if
(
i_ret
==
VLC_SUCCESS
)
return
VLC_SUCCESS
;
break
;
}
}
return
VLC_EGENERIC
;
exit:
free
(
cfg_level
.
psz_name
);
free
(
cfg_level
.
psz_value
);
return
i_ret
;
}
}
/*****************************************************************************
/*****************************************************************************
...
@@ -239,13 +264,13 @@ static int BufferAllocationInit ( filter_t *p_filter, void *p_data )
...
@@ -239,13 +264,13 @@ static int BufferAllocationInit ( filter_t *p_filter, void *p_data )
/*****************************************************************************
/*****************************************************************************
*
*
*****************************************************************************/
*****************************************************************************/
static
int
CreateChain
(
filter_chain_t
*
p_chain
,
es_format_t
*
p_fmt_mid
)
static
int
CreateChain
(
filter_chain_t
*
p_chain
,
es_format_t
*
p_fmt_mid
,
config_chain_t
*
p_cfg
)
{
{
filter_t
*
p_filter1
;
filter_t
*
p_filter1
;
if
(
!
(
p_filter1
=
if
(
!
(
p_filter1
=
filter_chain_AppendFilter
(
p_chain
,
NULL
,
NULL
,
NULL
,
p_fmt_mid
))
)
filter_chain_AppendFilter
(
p_chain
,
NULL
,
p_cfg
,
NULL
,
p_fmt_mid
))
)
return
VLC_EGENERIC
;
return
VLC_EGENERIC
;
if
(
!
filter_chain_AppendFilter
(
p_chain
,
NULL
,
NULL
,
p_fmt_mid
,
NULL
)
)
if
(
!
filter_chain_AppendFilter
(
p_chain
,
NULL
,
p_cfg
,
p_fmt_mid
,
NULL
)
)
{
{
filter_chain_DeleteFilter
(
p_chain
,
p_filter1
);
filter_chain_DeleteFilter
(
p_chain
,
p_filter1
);
return
VLC_EGENERIC
;
return
VLC_EGENERIC
;
...
...
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