summaryrefslogtreecommitdiff
path: root/libavfilter/vf_drawbox.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2013-05-16 10:33:31 +0200
committerMichael Niedermayer <michaelni@gmx.at>2013-05-16 10:33:31 +0200
commit04dd5ddedad384669d531e4b334888e8d8888d54 (patch)
tree450c4ce9b1293a6f894e16185c39463de2ec92fe /libavfilter/vf_drawbox.c
parenta134f9676e4f7988d360b69e0aed176055c47bcb (diff)
parentc0279956b3ca3e5fd0a6a25253893d6f07000e68 (diff)
downloadffmpeg-04dd5ddedad384669d531e4b334888e8d8888d54.tar.gz
Merge commit 'c0279956b3ca3e5fd0a6a25253893d6f07000e68'
* commit 'c0279956b3ca3e5fd0a6a25253893d6f07000e68': vf_fade: use the name 's' for the pointer to the private context vf_drawtext: use the name 's' for the pointer to the private context vf_drawbox: use the name 's' for the pointer to the private context Conflicts: libavfilter/vf_drawbox.c libavfilter/vf_drawtext.c libavfilter/vf_fade.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavfilter/vf_drawbox.c')
-rw-r--r--libavfilter/vf_drawbox.c64
1 files changed, 32 insertions, 32 deletions
diff --git a/libavfilter/vf_drawbox.c b/libavfilter/vf_drawbox.c
index 2747fbcd3e..9189e4de3c 100644
--- a/libavfilter/vf_drawbox.c
+++ b/libavfilter/vf_drawbox.c
@@ -47,19 +47,19 @@ typedef struct {
static av_cold int init(AVFilterContext *ctx)
{
- DrawBoxContext *drawbox = ctx->priv;
+ DrawBoxContext *s = ctx->priv;
uint8_t rgba_color[4];
- if (!strcmp(drawbox->color_str, "invert"))
- drawbox->invert_color = 1;
- else if (av_parse_color(rgba_color, drawbox->color_str, -1, ctx) < 0)
+ if (!strcmp(s->color_str, "invert"))
+ s->invert_color = 1;
+ else if (av_parse_color(rgba_color, s->color_str, -1, ctx) < 0)
return AVERROR(EINVAL);
- if (!drawbox->invert_color) {
- drawbox->yuv_color[Y] = RGB_TO_Y_CCIR(rgba_color[0], rgba_color[1], rgba_color[2]);
- drawbox->yuv_color[U] = RGB_TO_U_CCIR(rgba_color[0], rgba_color[1], rgba_color[2], 0);
- drawbox->yuv_color[V] = RGB_TO_V_CCIR(rgba_color[0], rgba_color[1], rgba_color[2], 0);
- drawbox->yuv_color[A] = rgba_color[3];
+ if (!s->invert_color) {
+ s->yuv_color[Y] = RGB_TO_Y_CCIR(rgba_color[0], rgba_color[1], rgba_color[2]);
+ s->yuv_color[U] = RGB_TO_U_CCIR(rgba_color[0], rgba_color[1], rgba_color[2], 0);
+ s->yuv_color[V] = RGB_TO_V_CCIR(rgba_color[0], rgba_color[1], rgba_color[2], 0);
+ s->yuv_color[A] = rgba_color[3];
}
return 0;
@@ -81,49 +81,49 @@ static int query_formats(AVFilterContext *ctx)
static int config_input(AVFilterLink *inlink)
{
- DrawBoxContext *drawbox = inlink->dst->priv;
+ DrawBoxContext *s = inlink->dst->priv;
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink->format);
- drawbox->hsub = desc->log2_chroma_w;
- drawbox->vsub = desc->log2_chroma_h;
+ s->hsub = desc->log2_chroma_w;
+ s->vsub = desc->log2_chroma_h;
- if (drawbox->w == 0) drawbox->w = inlink->w;
- if (drawbox->h == 0) drawbox->h = inlink->h;
+ if (s->w == 0) s->w = inlink->w;
+ if (s->h == 0) s->h = inlink->h;
av_log(inlink->dst, AV_LOG_VERBOSE, "x:%d y:%d w:%d h:%d color:0x%02X%02X%02X%02X\n",
- drawbox->x, drawbox->y, drawbox->w, drawbox->h,
- drawbox->yuv_color[Y], drawbox->yuv_color[U], drawbox->yuv_color[V], drawbox->yuv_color[A]);
+ s->x, s->y, s->w, s->h,
+ s->yuv_color[Y], s->yuv_color[U], s->yuv_color[V], s->yuv_color[A]);
return 0;
}
static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
{
- DrawBoxContext *drawbox = inlink->dst->priv;
- int plane, x, y, xb = drawbox->x, yb = drawbox->y;
+ DrawBoxContext *s = inlink->dst->priv;
+ int plane, x, y, xb = s->x, yb = s->y;
unsigned char *row[4];
- for (y = FFMAX(yb, 0); y < frame->height && y < (yb + drawbox->h); y++) {
+ for (y = FFMAX(yb, 0); y < frame->height && y < (yb + s->h); y++) {
row[0] = frame->data[0] + y * frame->linesize[0];
for (plane = 1; plane < 3; plane++)
row[plane] = frame->data[plane] +
- frame->linesize[plane] * (y >> drawbox->vsub);
+ frame->linesize[plane] * (y >> s->vsub);
- if (drawbox->invert_color) {
- for (x = FFMAX(xb, 0); x < xb + drawbox->w && x < frame->width; x++)
- if ((y - yb < drawbox->thickness-1) || (yb + drawbox->h - y < drawbox->thickness) ||
- (x - xb < drawbox->thickness-1) || (xb + drawbox->w - x < drawbox->thickness))
+ if (s->invert_color) {
+ for (x = FFMAX(xb, 0); x < xb + s->w && x < frame->width; x++)
+ if ((y - yb < s->thickness-1) || (yb + s->h - y < s->thickness) ||
+ (x - xb < s->thickness-1) || (xb + s->w - x < s->thickness))
row[0][x] = 0xff - row[0][x];
} else {
- for (x = FFMAX(xb, 0); x < xb + drawbox->w && x < frame->width; x++) {
- double alpha = (double)drawbox->yuv_color[A] / 255;
-
- if ((y - yb < drawbox->thickness-1) || (yb + drawbox->h - y < drawbox->thickness) ||
- (x - xb < drawbox->thickness-1) || (xb + drawbox->w - x < drawbox->thickness)) {
- row[0][x ] = (1 - alpha) * row[0][x ] + alpha * drawbox->yuv_color[Y];
- row[1][x >> drawbox->hsub] = (1 - alpha) * row[1][x >> drawbox->hsub] + alpha * drawbox->yuv_color[U];
- row[2][x >> drawbox->hsub] = (1 - alpha) * row[2][x >> drawbox->hsub] + alpha * drawbox->yuv_color[V];
+ for (x = FFMAX(xb, 0); x < xb + s->w && x < frame->width; x++) {
+ double alpha = (double)s->yuv_color[A] / 255;
+
+ if ((y - yb < s->thickness-1) || (yb + s->h - y < s->thickness) ||
+ (x - xb < s->thickness-1) || (xb + s->w - x < s->thickness)) {
+ row[0][x ] = (1 - alpha) * row[0][x ] + alpha * s->yuv_color[Y];
+ row[1][x >> s->hsub] = (1 - alpha) * row[1][x >> s->hsub] + alpha * s->yuv_color[U];
+ row[2][x >> s->hsub] = (1 - alpha) * row[2][x >> s->hsub] + alpha * s->yuv_color[V];
}
}
}