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
f3fea5ba
Commit
f3fea5ba
authored
May 31, 2012
by
Stefano Sabatini
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lavfi/lut: fix component -> rgba mapping
parent
8b0e1735
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
24 deletions
+20
-24
vf_lut.c
libavfilter/vf_lut.c
+20
-24
No files found.
libavfilter/vf_lut.c
View file @
f3fea5ba
...
@@ -60,7 +60,6 @@ typedef struct {
...
@@ -60,7 +60,6 @@ typedef struct {
int
hsub
,
vsub
;
int
hsub
,
vsub
;
double
var_values
[
VAR_VARS_NB
];
double
var_values
[
VAR_VARS_NB
];
int
is_rgb
,
is_yuv
;
int
is_rgb
,
is_yuv
;
int
rgba_map
[
4
];
int
step
;
int
step
;
int
negate_alpha
;
/* only used by negate */
int
negate_alpha
;
/* only used by negate */
}
LutContext
;
}
LutContext
;
...
@@ -199,6 +198,7 @@ static int config_props(AVFilterLink *inlink)
...
@@ -199,6 +198,7 @@ static int config_props(AVFilterLink *inlink)
AVFilterContext
*
ctx
=
inlink
->
dst
;
AVFilterContext
*
ctx
=
inlink
->
dst
;
LutContext
*
lut
=
ctx
->
priv
;
LutContext
*
lut
=
ctx
->
priv
;
const
AVPixFmtDescriptor
*
desc
=
&
av_pix_fmt_descriptors
[
inlink
->
format
];
const
AVPixFmtDescriptor
*
desc
=
&
av_pix_fmt_descriptors
[
inlink
->
format
];
int
rgba_map
[
4
];
/* component index -> RGBA color index map */
int
min
[
4
],
max
[
4
];
int
min
[
4
],
max
[
4
];
int
val
,
comp
,
ret
;
int
val
,
comp
,
ret
;
...
@@ -232,54 +232,50 @@ static int config_props(AVFilterLink *inlink)
...
@@ -232,54 +232,50 @@ static int config_props(AVFilterLink *inlink)
if
(
lut
->
is_rgb
)
{
if
(
lut
->
is_rgb
)
{
switch
(
inlink
->
format
)
{
switch
(
inlink
->
format
)
{
case
PIX_FMT_ARGB
:
lut
->
rgba_map
[
A
]
=
0
;
lut
->
rgba_map
[
R
]
=
1
;
lut
->
rgba_map
[
G
]
=
2
;
lut
->
rgba_map
[
B
]
=
3
;
break
;
case
PIX_FMT_ARGB
:
rgba_map
[
0
]
=
A
;
rgba_map
[
1
]
=
R
;
rgba_map
[
2
]
=
G
;
rgba_map
[
3
]
=
B
;
break
;
case
PIX_FMT_ABGR
:
lut
->
rgba_map
[
A
]
=
0
;
lut
->
rgba_map
[
B
]
=
1
;
lut
->
rgba_map
[
G
]
=
2
;
lut
->
rgba_map
[
R
]
=
3
;
break
;
case
PIX_FMT_ABGR
:
rgba_map
[
0
]
=
A
;
rgba_map
[
1
]
=
B
;
rgba_map
[
2
]
=
G
;
rgba_map
[
3
]
=
R
;
break
;
case
PIX_FMT_RGBA
:
case
PIX_FMT_RGBA
:
case
PIX_FMT_RGB24
:
lut
->
rgba_map
[
R
]
=
0
;
lut
->
rgba_map
[
G
]
=
1
;
lut
->
rgba_map
[
B
]
=
2
;
lut
->
rgba_map
[
A
]
=
3
;
break
;
case
PIX_FMT_RGB24
:
rgba_map
[
0
]
=
R
;
rgba_map
[
1
]
=
G
;
rgba_map
[
2
]
=
B
;
rgba_map
[
3
]
=
A
;
break
;
case
PIX_FMT_BGRA
:
case
PIX_FMT_BGRA
:
case
PIX_FMT_BGR24
:
lut
->
rgba_map
[
B
]
=
0
;
lut
->
rgba_map
[
G
]
=
1
;
lut
->
rgba_map
[
R
]
=
2
;
lut
->
rgba_map
[
A
]
=
3
;
break
;
case
PIX_FMT_BGR24
:
rgba_map
[
0
]
=
B
;
rgba_map
[
1
]
=
G
;
rgba_map
[
2
]
=
R
;
rgba_map
[
3
]
=
A
;
break
;
}
}
lut
->
step
=
av_get_bits_per_pixel
(
desc
)
>>
3
;
lut
->
step
=
av_get_bits_per_pixel
(
desc
)
>>
3
;
}
}
for
(
comp
=
0
;
comp
<
desc
->
nb_components
;
comp
++
)
{
for
(
comp
=
0
;
comp
<
desc
->
nb_components
;
comp
++
)
{
double
res
;
double
res
;
int
tcomp
;
int
color
=
lut
->
is_rgb
?
rgba_map
[
comp
]
:
comp
;
if
(
lut
->
is_rgb
)
{
for
(
tcomp
=
0
;
lut
->
rgba_map
[
tcomp
]
!=
comp
;
tcomp
++
)
;
}
else
tcomp
=
comp
;
/* create the parsed expression */
/* create the parsed expression */
ret
=
av_expr_parse
(
&
lut
->
comp_expr
[
co
mp
],
lut
->
comp_expr_str
[
comp
],
ret
=
av_expr_parse
(
&
lut
->
comp_expr
[
co
lor
],
lut
->
comp_expr_str
[
color
],
var_names
,
funcs1_names
,
funcs1
,
NULL
,
NULL
,
0
,
ctx
);
var_names
,
funcs1_names
,
funcs1
,
NULL
,
NULL
,
0
,
ctx
);
if
(
ret
<
0
)
{
if
(
ret
<
0
)
{
av_log
(
ctx
,
AV_LOG_ERROR
,
av_log
(
ctx
,
AV_LOG_ERROR
,
"Error when parsing the expression '%s' for the component %d.
\n
"
,
"Error when parsing the expression '%s' for the component %d
and color %d
.
\n
"
,
lut
->
comp_expr_str
[
comp
],
comp
);
lut
->
comp_expr_str
[
comp
],
comp
,
color
);
return
AVERROR
(
EINVAL
);
return
AVERROR
(
EINVAL
);
}
}
/* compute the lut */
/* compute the lut */
lut
->
var_values
[
VAR_MAXVAL
]
=
max
[
co
mp
];
lut
->
var_values
[
VAR_MAXVAL
]
=
max
[
co
lor
];
lut
->
var_values
[
VAR_MINVAL
]
=
min
[
co
mp
];
lut
->
var_values
[
VAR_MINVAL
]
=
min
[
co
lor
];
for
(
val
=
0
;
val
<
256
;
val
++
)
{
for
(
val
=
0
;
val
<
256
;
val
++
)
{
lut
->
var_values
[
VAR_VAL
]
=
val
;
lut
->
var_values
[
VAR_VAL
]
=
val
;
lut
->
var_values
[
VAR_CLIPVAL
]
=
av_clip
(
val
,
min
[
co
mp
],
max
[
comp
]);
lut
->
var_values
[
VAR_CLIPVAL
]
=
av_clip
(
val
,
min
[
co
lor
],
max
[
color
]);
lut
->
var_values
[
VAR_NEGVAL
]
=
lut
->
var_values
[
VAR_NEGVAL
]
=
av_clip
(
min
[
co
mp
]
+
max
[
comp
]
-
lut
->
var_values
[
VAR_VAL
],
av_clip
(
min
[
co
lor
]
+
max
[
color
]
-
lut
->
var_values
[
VAR_VAL
],
min
[
co
mp
],
max
[
comp
]);
min
[
co
lor
],
max
[
color
]);
res
=
av_expr_eval
(
lut
->
comp_expr
[
co
mp
],
lut
->
var_values
,
lut
);
res
=
av_expr_eval
(
lut
->
comp_expr
[
co
lor
],
lut
->
var_values
,
lut
);
if
(
isnan
(
res
))
{
if
(
isnan
(
res
))
{
av_log
(
ctx
,
AV_LOG_ERROR
,
av_log
(
ctx
,
AV_LOG_ERROR
,
"Error when evaluating the expression '%s' for the value %d for the component
#
%d.
\n
"
,
"Error when evaluating the expression '%s' for the value %d for the component %d.
\n
"
,
lut
->
comp_expr_str
[
co
mp
],
val
,
comp
);
lut
->
comp_expr_str
[
co
lor
],
val
,
comp
);
return
AVERROR
(
EINVAL
);
return
AVERROR
(
EINVAL
);
}
}
lut
->
lut
[
tcomp
][
val
]
=
av_clip
((
int
)
res
,
min
[
comp
],
max
[
comp
]);
lut
->
lut
[
comp
][
val
]
=
av_clip
((
int
)
res
,
min
[
color
],
max
[
color
]);
av_log
(
ctx
,
AV_LOG_DEBUG
,
"val[%d][%d] = %d
\n
"
,
comp
,
val
,
lut
->
lut
[
t
comp
][
val
]);
av_log
(
ctx
,
AV_LOG_DEBUG
,
"val[%d][%d] = %d
\n
"
,
comp
,
val
,
lut
->
lut
[
comp
][
val
]);
}
}
}
}
...
...
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