[FFmpeg-devel] [PATCH] avfilter/rotate: remove fillcolor_enable
Paul B Mahol
onemda at gmail.com
Sun Sep 8 19:56:46 CEST 2013
This option is no good as it allows uninitialized data
in output.
Signed-off-by: Paul B Mahol <onemda at gmail.com>
---
FIXME: detect when fill_rectangle is not needed.
---
doc/filters.texi | 6 ++----
libavfilter/vf_rotate.c | 25 ++++---------------------
2 files changed, 6 insertions(+), 25 deletions(-)
diff --git a/doc/filters.texi b/doc/filters.texi
index 7f8d1b2..6937446 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -6216,9 +6216,7 @@ it. Default value is 1.
@item fillcolor, c
Set the color used to fill the output area not covered by the rotated
-image. If the special value "none" is selected then no background is
-printed (useful for example if the background is never shown). Default
-value is "black".
+image. Default value is "black".
@end table
The expressions for the angle and the output size can contain the
@@ -6295,7 +6293,7 @@ rotate='2*PI*t:ow=hypot(iw,ih):oh=ow'
Rotate the video, reduce the output size so that no background is ever
shown:
@example
-rotate=2*PI*t:ow='min(iw,ih)/sqrt(2)':oh=ow:c=none
+rotate=2*PI*t:ow='min(iw,ih)/sqrt(2)':oh=ow
@end example
@end itemize
diff --git a/libavfilter/vf_rotate.c b/libavfilter/vf_rotate.c
index d13f678..5deb02f 100644
--- a/libavfilter/vf_rotate.c
+++ b/libavfilter/vf_rotate.c
@@ -66,8 +66,6 @@ typedef struct {
char *outw_expr_str, *outh_expr_str;
int outh, outw;
uint8_t fillcolor[4]; ///< color expressed either in YUVA or RGBA colorspace for the padding area
- char *fillcolor_str;
- int fillcolor_enable;
int hsub, vsub;
int nb_planes;
int use_bilinear;
@@ -87,27 +85,14 @@ static const AVOption rotate_options[] = {
{ "ow", "set output width expression", OFFSET(outw_expr_str), AV_OPT_TYPE_STRING, {.str="iw"}, CHAR_MIN, CHAR_MAX, .flags=FLAGS },
{ "out_h", "set output height expression", OFFSET(outh_expr_str), AV_OPT_TYPE_STRING, {.str="ih"}, CHAR_MIN, CHAR_MAX, .flags=FLAGS },
{ "oh", "set output height expression", OFFSET(outh_expr_str), AV_OPT_TYPE_STRING, {.str="ih"}, CHAR_MIN, CHAR_MAX, .flags=FLAGS },
- { "fillcolor", "set background fill color", OFFSET(fillcolor_str), AV_OPT_TYPE_STRING, {.str="black"}, CHAR_MIN, CHAR_MAX, .flags=FLAGS },
- { "c", "set background fill color", OFFSET(fillcolor_str), AV_OPT_TYPE_STRING, {.str="black"}, CHAR_MIN, CHAR_MAX, .flags=FLAGS },
+ { "fillcolor", "set background fill color", OFFSET(fillcolor), AV_OPT_TYPE_COLOR, {.str="black"}, CHAR_MIN, CHAR_MAX, .flags=FLAGS },
+ { "c", "set background fill color", OFFSET(fillcolor), AV_OPT_TYPE_COLOR, {.str="black"}, CHAR_MIN, CHAR_MAX, .flags=FLAGS },
{ "bilinear", "use bilinear interpolation", OFFSET(use_bilinear), AV_OPT_TYPE_INT, {.i64=1}, 0, 1, .flags=FLAGS },
{ NULL }
};
AVFILTER_DEFINE_CLASS(rotate);
-static av_cold int init(AVFilterContext *ctx)
-{
- RotContext *rot = ctx->priv;
-
- if (!strcmp(rot->fillcolor_str, "none"))
- rot->fillcolor_enable = 0;
- else if (av_parse_color(rot->fillcolor, rot->fillcolor_str, -1, ctx) >= 0)
- rot->fillcolor_enable = 1;
- else
- return AVERROR(EINVAL);
- return 0;
-}
-
static av_cold void uninit(AVFilterContext *ctx)
{
RotContext *rot = ctx->priv;
@@ -327,9 +312,8 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
c = int_sin(angle_int + INT_PI/2);
/* fill background */
- if (rot->fillcolor_enable)
- ff_fill_rectangle(&rot->draw, &rot->color, out->data, out->linesize,
- 0, 0, outlink->w, outlink->h);
+ ff_fill_rectangle(&rot->draw, &rot->color, out->data, out->linesize,
+ 0, 0, outlink->w, outlink->h);
for (plane = 0; plane < rot->nb_planes; plane++) {
int hsub = plane == 1 || plane == 2 ? rot->hsub : 0;
@@ -445,7 +429,6 @@ AVFilter avfilter_vf_rotate = {
.name = "rotate",
.description = NULL_IF_CONFIG_SMALL("Rotate the input image."),
.priv_size = sizeof(RotContext),
- .init = init,
.uninit = uninit,
.query_formats = query_formats,
.process_command = process_command,
--
1.7.11.2
More information about the ffmpeg-devel
mailing list