mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-01-13 21:28:01 +02:00
avfilter/vf_premultiply: add planes option
Signed-off-by: Paul B Mahol <onemda@gmail.com>
This commit is contained in:
parent
9d1f9ba582
commit
710c97d5f6
@ -11077,6 +11077,14 @@ of second stream as alpha.
|
||||
|
||||
Both streams must have same dimensions and same pixel format.
|
||||
|
||||
The filter accepts the following option:
|
||||
|
||||
@table @option
|
||||
@item planes
|
||||
Set which planes will be processed, unprocessed planes will be copied.
|
||||
By default value 0xf, all planes will be processed.
|
||||
@end table
|
||||
|
||||
@section prewitt
|
||||
Apply prewitt operator to input video stream.
|
||||
|
||||
|
@ -30,6 +30,7 @@
|
||||
typedef struct PreMultiplyContext {
|
||||
const AVClass *class;
|
||||
int width[4], height[4];
|
||||
int linesize[4];
|
||||
int nb_planes;
|
||||
int planes;
|
||||
int half, depth, offset;
|
||||
@ -47,6 +48,7 @@ typedef struct PreMultiplyContext {
|
||||
#define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
|
||||
|
||||
static const AVOption premultiply_options[] = {
|
||||
{ "planes", "set planes", OFFSET(planes), AV_OPT_TYPE_INT, {.i64=0xF}, 0, 0xF, FLAGS },
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
@ -269,6 +271,12 @@ static int process_frame(FFFrameSync *fs)
|
||||
}
|
||||
|
||||
for (p = 0; p < s->nb_planes; p++) {
|
||||
if (!((1 << p) & s->planes)) {
|
||||
av_image_copy_plane(out->data[p], out->linesize[p], base->data[p], base->linesize[p],
|
||||
s->linesize[p], s->height[p]);
|
||||
continue;
|
||||
}
|
||||
|
||||
s->premultiply[p](base->data[p], alpha->data[0],
|
||||
out->data[p],
|
||||
base->linesize[p], alpha->linesize[0],
|
||||
@ -287,10 +295,13 @@ static int config_input(AVFilterLink *inlink)
|
||||
AVFilterContext *ctx = inlink->dst;
|
||||
PreMultiplyContext *s = ctx->priv;
|
||||
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink->format);
|
||||
int vsub, hsub;
|
||||
int vsub, hsub, ret;
|
||||
|
||||
s->nb_planes = av_pix_fmt_count_planes(inlink->format);
|
||||
|
||||
if ((ret = av_image_fill_linesizes(s->linesize, inlink->format, inlink->w)) < 0)
|
||||
return ret;
|
||||
|
||||
hsub = desc->log2_chroma_w;
|
||||
vsub = desc->log2_chroma_h;
|
||||
s->height[1] = s->height[2] = AV_CEIL_RSHIFT(inlink->h, vsub);
|
||||
|
Loading…
Reference in New Issue
Block a user