mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-12-23 12:43:46 +02:00
vf_fade: switch to filter_frame
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
parent
2d9d444051
commit
9a65b8c0a2
@ -216,10 +216,9 @@ static void fade_plane(int y, int h, int w,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir)
|
static int filter_frame(AVFilterLink *inlink, AVFilterBufferRef *frame)
|
||||||
{
|
{
|
||||||
FadeContext *fade = inlink->dst->priv;
|
FadeContext *fade = inlink->dst->priv;
|
||||||
AVFilterBufferRef *outpic = inlink->cur_buf;
|
|
||||||
uint8_t *p;
|
uint8_t *p;
|
||||||
int i, j, plane;
|
int i, j, plane;
|
||||||
|
|
||||||
@ -228,22 +227,22 @@ static int draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir)
|
|||||||
// alpha only
|
// alpha only
|
||||||
plane = fade->is_packed_rgb ? 0 : A; // alpha is on plane 0 for packed formats
|
plane = fade->is_packed_rgb ? 0 : A; // alpha is on plane 0 for packed formats
|
||||||
// or plane 3 for planar formats
|
// or plane 3 for planar formats
|
||||||
fade_plane(y, h, inlink->w,
|
fade_plane(0, frame->video->h, inlink->w,
|
||||||
fade->factor, fade->black_level, fade->black_level_scaled,
|
fade->factor, fade->black_level, fade->black_level_scaled,
|
||||||
fade->is_packed_rgb ? fade->rgba_map[A] : 0, // alpha offset for packed formats
|
fade->is_packed_rgb ? fade->rgba_map[A] : 0, // alpha offset for packed formats
|
||||||
fade->is_packed_rgb ? 4 : 1, // pixstep for 8 bit packed formats
|
fade->is_packed_rgb ? 4 : 1, // pixstep for 8 bit packed formats
|
||||||
1, outpic->data[plane], outpic->linesize[plane]);
|
1, frame->data[plane], frame->linesize[plane]);
|
||||||
} else {
|
} else {
|
||||||
/* luma or rgb plane */
|
/* luma or rgb plane */
|
||||||
fade_plane(y, h, inlink->w,
|
fade_plane(0, frame->video->h, inlink->w,
|
||||||
fade->factor, fade->black_level, fade->black_level_scaled,
|
fade->factor, fade->black_level, fade->black_level_scaled,
|
||||||
0, 1, // offset & pixstep for Y plane or RGB packed format
|
0, 1, // offset & pixstep for Y plane or RGB packed format
|
||||||
fade->bpp, outpic->data[0], outpic->linesize[0]);
|
fade->bpp, frame->data[0], frame->linesize[0]);
|
||||||
if (outpic->data[1] && outpic->data[2]) {
|
if (frame->data[1] && frame->data[2]) {
|
||||||
/* chroma planes */
|
/* chroma planes */
|
||||||
for (plane = 1; plane < 3; plane++) {
|
for (plane = 1; plane < 3; plane++) {
|
||||||
for (i = 0; i < h; i++) {
|
for (i = 0; i < frame->video->h; i++) {
|
||||||
p = outpic->data[plane] + ((y+i) >> fade->vsub) * outpic->linesize[plane];
|
p = frame->data[plane] + (i >> fade->vsub) * frame->linesize[plane];
|
||||||
for (j = 0; j < inlink->w >> fade->hsub; j++) {
|
for (j = 0; j < inlink->w >> fade->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
|
||||||
@ -257,23 +256,13 @@ static int draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ff_draw_slice(inlink->dst->outputs[0], y, h, slice_dir);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int end_frame(AVFilterLink *inlink)
|
|
||||||
{
|
|
||||||
FadeContext *fade = inlink->dst->priv;
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
ret = ff_end_frame(inlink->dst->outputs[0]);
|
|
||||||
|
|
||||||
if (fade->frame_index >= fade->start_frame &&
|
if (fade->frame_index >= fade->start_frame &&
|
||||||
fade->frame_index <= fade->stop_frame)
|
fade->frame_index <= fade->stop_frame)
|
||||||
fade->factor += fade->fade_per_frame;
|
fade->factor += fade->fade_per_frame;
|
||||||
fade->factor = av_clip_uint16(fade->factor);
|
fade->factor = av_clip_uint16(fade->factor);
|
||||||
fade->frame_index++;
|
fade->frame_index++;
|
||||||
|
|
||||||
return ret;
|
return ff_filter_frame(inlink->dst->outputs[0], frame);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const AVFilterPad avfilter_vf_fade_inputs[] = {
|
static const AVFilterPad avfilter_vf_fade_inputs[] = {
|
||||||
@ -282,9 +271,7 @@ static const AVFilterPad avfilter_vf_fade_inputs[] = {
|
|||||||
.type = AVMEDIA_TYPE_VIDEO,
|
.type = AVMEDIA_TYPE_VIDEO,
|
||||||
.config_props = config_props,
|
.config_props = config_props,
|
||||||
.get_video_buffer = ff_null_get_video_buffer,
|
.get_video_buffer = ff_null_get_video_buffer,
|
||||||
.start_frame = ff_null_start_frame,
|
.filter_frame = filter_frame,
|
||||||
.draw_slice = draw_slice,
|
|
||||||
.end_frame = end_frame,
|
|
||||||
.min_perms = AV_PERM_READ | AV_PERM_WRITE,
|
.min_perms = AV_PERM_READ | AV_PERM_WRITE,
|
||||||
},
|
},
|
||||||
{ NULL }
|
{ NULL }
|
||||||
|
Loading…
Reference in New Issue
Block a user