mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-01-08 13:22:53 +02:00
vf_fade: use the name 's' for the pointer to the private context
This is shorter and consistent across filters.
This commit is contained in:
parent
d3735f7ad6
commit
c0279956b3
@ -47,21 +47,21 @@ typedef struct {
|
|||||||
|
|
||||||
static av_cold int init(AVFilterContext *ctx)
|
static av_cold int init(AVFilterContext *ctx)
|
||||||
{
|
{
|
||||||
FadeContext *fade = ctx->priv;
|
FadeContext *s = ctx->priv;
|
||||||
|
|
||||||
fade->fade_per_frame = (1 << 16) / fade->nb_frames;
|
s->fade_per_frame = (1 << 16) / s->nb_frames;
|
||||||
if (fade->type == FADE_IN) {
|
if (s->type == FADE_IN) {
|
||||||
fade->factor = 0;
|
s->factor = 0;
|
||||||
} else if (fade->type == FADE_OUT) {
|
} else if (s->type == FADE_OUT) {
|
||||||
fade->fade_per_frame = -fade->fade_per_frame;
|
s->fade_per_frame = -s->fade_per_frame;
|
||||||
fade->factor = (1 << 16);
|
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,
|
av_log(ctx, AV_LOG_VERBOSE,
|
||||||
"type:%s start_frame:%d nb_frames:%d\n",
|
"type:%s start_frame:%d nb_frames:%d\n",
|
||||||
fade->type == FADE_IN ? "in" : "out", fade->start_frame,
|
s->type == FADE_IN ? "in" : "out", s->start_frame,
|
||||||
fade->nb_frames);
|
s->nb_frames);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -82,31 +82,31 @@ static int query_formats(AVFilterContext *ctx)
|
|||||||
|
|
||||||
static int config_props(AVFilterLink *inlink)
|
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);
|
const AVPixFmtDescriptor *pixdesc = av_pix_fmt_desc_get(inlink->format);
|
||||||
|
|
||||||
fade->hsub = pixdesc->log2_chroma_w;
|
s->hsub = pixdesc->log2_chroma_w;
|
||||||
fade->vsub = pixdesc->log2_chroma_h;
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
|
static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
|
||||||
{
|
{
|
||||||
FadeContext *fade = inlink->dst->priv;
|
FadeContext *s = inlink->dst->priv;
|
||||||
uint8_t *p;
|
uint8_t *p;
|
||||||
int i, j, plane;
|
int i, j, plane;
|
||||||
|
|
||||||
if (fade->factor < UINT16_MAX) {
|
if (s->factor < UINT16_MAX) {
|
||||||
/* luma or rgb plane */
|
/* luma or rgb plane */
|
||||||
for (i = 0; i < frame->height; i++) {
|
for (i = 0; i < frame->height; i++) {
|
||||||
p = frame->data[0] + i * frame->linesize[0];
|
p = frame->data[0] + i * frame->linesize[0];
|
||||||
for (j = 0; j < inlink->w * fade->bpp; j++) {
|
for (j = 0; j < inlink->w * s->bpp; j++) {
|
||||||
/* fade->factor is using 16 lower-order bits for decimal
|
/* s->factor is using 16 lower-order bits for decimal
|
||||||
* places. 32768 = 1 << 15, it is an integer representation
|
* places. 32768 = 1 << 15, it is an integer representation
|
||||||
* of 0.5 and is for rounding. */
|
* of 0.5 and is for rounding. */
|
||||||
*p = (*p * fade->factor + 32768) >> 16;
|
*p = (*p * s->factor + 32768) >> 16;
|
||||||
p++;
|
p++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -115,12 +115,12 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
|
|||||||
/* chroma planes */
|
/* chroma planes */
|
||||||
for (plane = 1; plane < 3; plane++) {
|
for (plane = 1; plane < 3; plane++) {
|
||||||
for (i = 0; i < frame->height; i++) {
|
for (i = 0; i < frame->height; i++) {
|
||||||
p = frame->data[plane] + (i >> fade->vsub) * frame->linesize[plane];
|
p = frame->data[plane] + (i >> s->vsub) * frame->linesize[plane];
|
||||||
for (j = 0; j < inlink->w >> fade->hsub; j++) {
|
for (j = 0; j < inlink->w >> s->hsub; j++) {
|
||||||
/* 8421367 = ((128 << 1) + 1) << 15. It is an integer
|
/* 8421367 = ((128 << 1) + 1) << 15. It is an integer
|
||||||
* representation of 128.5. The .5 is for rounding
|
* representation of 128.5. The .5 is for rounding
|
||||||
* purposes. */
|
* purposes. */
|
||||||
*p = ((*p - 128) * fade->factor + 8421367) >> 16;
|
*p = ((*p - 128) * s->factor + 8421367) >> 16;
|
||||||
p++;
|
p++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -128,11 +128,11 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fade->frame_index >= fade->start_frame &&
|
if (s->frame_index >= s->start_frame &&
|
||||||
fade->frame_index <= fade->stop_frame)
|
s->frame_index <= s->stop_frame)
|
||||||
fade->factor += fade->fade_per_frame;
|
s->factor += s->fade_per_frame;
|
||||||
fade->factor = av_clip_uint16(fade->factor);
|
s->factor = av_clip_uint16(s->factor);
|
||||||
fade->frame_index++;
|
s->frame_index++;
|
||||||
|
|
||||||
return ff_filter_frame(inlink->dst->outputs[0], frame);
|
return ff_filter_frame(inlink->dst->outputs[0], frame);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user