summaryrefslogtreecommitdiff
path: root/libavfilter/vf_fade.c
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2013-03-18 20:44:36 +0100
committerAnton Khirnov <anton@khirnov.net>2013-05-16 07:32:43 +0200
commitc0279956b3ca3e5fd0a6a25253893d6f07000e68 (patch)
tree616d68894808f418742a35abddf5cc3cf77113ef /libavfilter/vf_fade.c
parentd3735f7ad6e30a2837a0613abcd562ae79ea657e (diff)
vf_fade: use the name 's' for the pointer to the private context
This is shorter and consistent across filters.
Diffstat (limited to 'libavfilter/vf_fade.c')
-rw-r--r--libavfilter/vf_fade.c56
1 files changed, 28 insertions, 28 deletions
diff --git a/libavfilter/vf_fade.c b/libavfilter/vf_fade.c
index b1ecc64da5..9f3a60206a 100644
--- a/libavfilter/vf_fade.c
+++ b/libavfilter/vf_fade.c
@@ -47,21 +47,21 @@ typedef struct {
static av_cold int init(AVFilterContext *ctx)
{
- FadeContext *fade = ctx->priv;
-
- fade->fade_per_frame = (1 << 16) / fade->nb_frames;
- if (fade->type == FADE_IN) {
- fade->factor = 0;
- } else if (fade->type == FADE_OUT) {
- fade->fade_per_frame = -fade->fade_per_frame;
- fade->factor = (1 << 16);
+ FadeContext *s = ctx->priv;
+
+ s->fade_per_frame = (1 << 16) / s->nb_frames;
+ if (s->type == FADE_IN) {
+ s->factor = 0;
+ } else if (s->type == FADE_OUT) {
+ s->fade_per_frame = -s->fade_per_frame;
+ s->factor = (1 << 16);
}
- fade->stop_frame = fade->start_frame + fade->nb_frames;
+ s->stop_frame = s->start_frame + s->nb_frames;
av_log(ctx, AV_LOG_VERBOSE,
"type:%s start_frame:%d nb_frames:%d\n",
- fade->type == FADE_IN ? "in" : "out", fade->start_frame,
- fade->nb_frames);
+ s->type == FADE_IN ? "in" : "out", s->start_frame,
+ s->nb_frames);
return 0;
}
@@ -82,31 +82,31 @@ static int query_formats(AVFilterContext *ctx)
static int config_props(AVFilterLink *inlink)
{
- FadeContext *fade = inlink->dst->priv;
+ FadeContext *s = inlink->dst->priv;
const AVPixFmtDescriptor *pixdesc = av_pix_fmt_desc_get(inlink->format);
- fade->hsub = pixdesc->log2_chroma_w;
- fade->vsub = pixdesc->log2_chroma_h;
+ s->hsub = pixdesc->log2_chroma_w;
+ s->vsub = pixdesc->log2_chroma_h;
- fade->bpp = av_get_bits_per_pixel(pixdesc) >> 3;
+ s->bpp = av_get_bits_per_pixel(pixdesc) >> 3;
return 0;
}
static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
{
- FadeContext *fade = inlink->dst->priv;
+ FadeContext *s = inlink->dst->priv;
uint8_t *p;
int i, j, plane;
- if (fade->factor < UINT16_MAX) {
+ if (s->factor < UINT16_MAX) {
/* luma or rgb plane */
for (i = 0; i < frame->height; i++) {
p = frame->data[0] + i * frame->linesize[0];
- for (j = 0; j < inlink->w * fade->bpp; j++) {
- /* fade->factor is using 16 lower-order bits for decimal
+ for (j = 0; j < inlink->w * s->bpp; j++) {
+ /* s->factor is using 16 lower-order bits for decimal
* places. 32768 = 1 << 15, it is an integer representation
* of 0.5 and is for rounding. */
- *p = (*p * fade->factor + 32768) >> 16;
+ *p = (*p * s->factor + 32768) >> 16;
p++;
}
}
@@ -115,12 +115,12 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
/* chroma planes */
for (plane = 1; plane < 3; plane++) {
for (i = 0; i < frame->height; i++) {
- p = frame->data[plane] + (i >> fade->vsub) * frame->linesize[plane];
- for (j = 0; j < inlink->w >> fade->hsub; j++) {
+ p = frame->data[plane] + (i >> s->vsub) * frame->linesize[plane];
+ for (j = 0; j < inlink->w >> s->hsub; j++) {
/* 8421367 = ((128 << 1) + 1) << 15. It is an integer
* representation of 128.5. The .5 is for rounding
* purposes. */
- *p = ((*p - 128) * fade->factor + 8421367) >> 16;
+ *p = ((*p - 128) * s->factor + 8421367) >> 16;
p++;
}
}
@@ -128,11 +128,11 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
}
}
- if (fade->frame_index >= fade->start_frame &&
- fade->frame_index <= fade->stop_frame)
- fade->factor += fade->fade_per_frame;
- fade->factor = av_clip_uint16(fade->factor);
- fade->frame_index++;
+ if (s->frame_index >= s->start_frame &&
+ s->frame_index <= s->stop_frame)
+ s->factor += s->fade_per_frame;
+ s->factor = av_clip_uint16(s->factor);
+ s->frame_index++;
return ff_filter_frame(inlink->dst->outputs[0], frame);
}