Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
F
ffmpeg.wasm-core
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Linshizhi
ffmpeg.wasm-core
Commits
1cb02d4f
Commit
1cb02d4f
authored
Apr 15, 2013
by
Clément Bœsch
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lavfi/curves: add support for Photoshop curves files (.acv).
parent
99dac393
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
68 additions
and
1 deletion
+68
-1
filters.texi
doc/filters.texi
+2
-0
version.h
libavfilter/version.h
+1
-1
vf_curves.c
libavfilter/vf_curves.c
+65
-0
No files found.
doc/filters.texi
View file @
1cb02d4f
...
...
@@ -2346,6 +2346,8 @@ Set the key points for all components (not including master).
Can be used in addition to the other key points component
options. In this case, the unset component(s) will fallback on this
@option{all} setting.
@item psfile
Specify a Photoshop curves file (@code{.asv}) to import the settings from.
@end table
To avoid some filtergraph syntax conflicts, each key points list need to be
...
...
libavfilter/version.h
View file @
1cb02d4f
...
...
@@ -30,7 +30,7 @@
#define LIBAVFILTER_VERSION_MAJOR 3
#define LIBAVFILTER_VERSION_MINOR 56
#define LIBAVFILTER_VERSION_MICRO 10
0
#define LIBAVFILTER_VERSION_MICRO 10
1
#define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \
LIBAVFILTER_VERSION_MINOR, \
...
...
libavfilter/vf_curves.c
View file @
1cb02d4f
...
...
@@ -19,7 +19,10 @@
*/
#include "libavutil/opt.h"
#include "libavutil/bprint.h"
#include "libavutil/eval.h"
#include "libavutil/file.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/avassert.h"
#include "avfilter.h"
#include "formats.h"
...
...
@@ -54,6 +57,7 @@ typedef struct {
char
*
comp_points_str
[
NB_COMP
+
1
];
char
*
comp_points_str_all
;
uint8_t
graph
[
NB_COMP
+
1
][
256
];
char
*
psfile
;
}
CurvesContext
;
#define OFFSET(x) offsetof(CurvesContext, x)
...
...
@@ -80,6 +84,7 @@ static const AVOption curves_options[] = {
{
"blue"
,
"set blue points coordinates"
,
OFFSET
(
comp_points_str
[
2
]),
AV_OPT_TYPE_STRING
,
{.
str
=
NULL
},
.
flags
=
FLAGS
},
{
"b"
,
"set blue points coordinates"
,
OFFSET
(
comp_points_str
[
2
]),
AV_OPT_TYPE_STRING
,
{.
str
=
NULL
},
.
flags
=
FLAGS
},
{
"all"
,
"set points coordinates for all components"
,
OFFSET
(
comp_points_str_all
),
AV_OPT_TYPE_STRING
,
{.
str
=
NULL
},
.
flags
=
FLAGS
},
{
"psfile"
,
"set Photoshop curves file name"
,
OFFSET
(
psfile
),
AV_OPT_TYPE_STRING
,
{.
str
=
NULL
},
.
flags
=
FLAGS
},
{
NULL
}
};
...
...
@@ -297,6 +302,60 @@ end:
return
ret
;
}
static
int
parse_psfile
(
AVFilterContext
*
ctx
,
const
char
*
fname
)
{
CurvesContext
*
curves
=
ctx
->
priv
;
uint8_t
*
buf
;
size_t
size
;
int
i
,
ret
,
av_unused
(
version
),
nb_curves
;
AVBPrint
ptstr
;
static
const
int
comp_ids
[]
=
{
3
,
0
,
1
,
2
};
av_bprint_init
(
&
ptstr
,
0
,
AV_BPRINT_SIZE_AUTOMATIC
);
ret
=
av_file_map
(
fname
,
&
buf
,
&
size
,
0
,
NULL
);
if
(
ret
<
0
)
return
ret
;
#define READ16(dst) do { \
if (size < 2) \
return AVERROR_INVALIDDATA; \
dst = AV_RB16(buf); \
buf += 2; \
size -= 2; \
} while (0)
READ16
(
version
);
READ16
(
nb_curves
);
for
(
i
=
0
;
i
<
FFMIN
(
nb_curves
,
FF_ARRAY_ELEMS
(
comp_ids
));
i
++
)
{
int
nb_points
,
n
;
av_bprint_clear
(
&
ptstr
);
READ16
(
nb_points
);
for
(
n
=
0
;
n
<
nb_points
;
n
++
)
{
int
y
,
x
;
READ16
(
y
);
READ16
(
x
);
av_bprintf
(
&
ptstr
,
"%f/%f "
,
x
/
255
.,
y
/
255
.);
}
if
(
*
ptstr
.
str
)
{
char
**
pts
=
&
curves
->
comp_points_str
[
comp_ids
[
i
]];
if
(
!*
pts
)
{
*
pts
=
av_strdup
(
ptstr
.
str
);
av_log
(
ctx
,
AV_LOG_DEBUG
,
"curves %d (intid=%d) [%d points]: [%s]
\n
"
,
i
,
comp_ids
[
i
],
nb_points
,
*
pts
);
if
(
!*
pts
)
{
ret
=
AVERROR
(
ENOMEM
);
goto
end
;
}
}
}
}
end:
av_bprint_finalize
(
&
ptstr
,
NULL
);
av_file_unmap
(
buf
,
size
);
return
ret
;
}
static
av_cold
int
init
(
AVFilterContext
*
ctx
)
{
int
i
,
j
,
ret
;
...
...
@@ -317,6 +376,12 @@ static av_cold int init(AVFilterContext *ctx)
}
}
if
(
curves
->
psfile
)
{
ret
=
parse_psfile
(
ctx
,
curves
->
psfile
);
if
(
ret
<
0
)
return
ret
;
}
if
(
curves
->
preset
!=
PRESET_NONE
)
{
#define SET_COMP_IF_NOT_SET(n, name) do { \
if (!pts[n] && curves_presets[curves->preset].name) { \
...
...
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