summaryrefslogtreecommitdiffstats
path: root/libavfilter/vf_drawbox.c
diff options
context:
space:
mode:
authorStefano Sabatini <stefasab@gmail.com>2012-10-30 20:14:07 +0100
committerStefano Sabatini <stefasab@gmail.com>2012-10-31 12:14:21 +0100
commit1b3fdd9731012a4ae2d5b3ee5460c910d808da8e (patch)
tree61e86b2968c7e19830a6a32e498ffb3533c5b24e /libavfilter/vf_drawbox.c
parent652fab5996a3e283df69ed51132745ba45086251 (diff)
downloadffmpeg-streaming-1b3fdd9731012a4ae2d5b3ee5460c910d808da8e.zip
ffmpeg-streaming-1b3fdd9731012a4ae2d5b3ee5460c910d808da8e.tar.gz
lavfi/drawbox: implement color=invert mode
Based on a libmpcodecs/vf_rectangle.c feature.
Diffstat (limited to 'libavfilter/vf_drawbox.c')
-rw-r--r--libavfilter/vf_drawbox.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/libavfilter/vf_drawbox.c b/libavfilter/vf_drawbox.c
index a93620f..ef1bc32 100644
--- a/libavfilter/vf_drawbox.c
+++ b/libavfilter/vf_drawbox.c
@@ -41,6 +41,7 @@ typedef struct {
int x, y, w, h;
char *color_str;
unsigned char yuv_color[4];
+ int invert_color; ///< invert luma color
int vsub, hsub; ///< chroma subsampling
} DrawBoxContext;
@@ -72,7 +73,9 @@ static av_cold int init(AVFilterContext *ctx, const char *args)
if ((ret = av_opt_set_from_string(drawbox, args, shorthand, "=", ":")) < 0)
return ret;
- if (av_parse_color(rgba_color, drawbox->color_str, -1, ctx) < 0)
+ if (!strcmp(drawbox->color_str, "invert"))
+ drawbox->invert_color = 1;
+ else if (av_parse_color(rgba_color, drawbox->color_str, -1, ctx) < 0)
return AVERROR(EINVAL);
drawbox->yuv_color[Y] = RGB_TO_Y_CCIR(rgba_color[0], rgba_color[1], rgba_color[2]);
@@ -135,6 +138,12 @@ static int draw_slice(AVFilterLink *inlink, int y0, int h, int slice_dir)
row[plane] = picref->data[plane] +
picref->linesize[plane] * (y >> drawbox->vsub);
+ if (drawbox->invert_color) {
+ for (x = FFMAX(xb, 0); x < (xb + drawbox->w) && x < picref->video->w; x++)
+ if ((y - yb < 3) || (yb + drawbox->h - y < 4) ||
+ (x - xb < 3) || (xb + drawbox->w - x < 4))
+ row[0][x] = 0xff - row[0][x];
+ } else {
for (x = FFMAX(xb, 0); x < (xb + drawbox->w) && x < picref->video->w; x++) {
double alpha = (double)drawbox->yuv_color[A] / 255;
@@ -145,6 +154,7 @@ static int draw_slice(AVFilterLink *inlink, int y0, int h, int slice_dir)
row[2][x >> drawbox->hsub] = (1 - alpha) * row[2][x >> drawbox->hsub] + alpha * drawbox->yuv_color[V];
}
}
+ }
}
return ff_draw_slice(inlink->dst->outputs[0], y0, h, 1);
OpenPOWER on IntegriCloud