diff --git a/doc/filters.texi b/doc/filters.texi index 1eb2027d02..b91d38daa2 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -15684,6 +15684,9 @@ Specify scale, if it is set it will be multiplied with sum of each weight multiplied with pixel values to give final destination pixel value. By default @var{scale} is auto scaled to sum of weights. +@item planes +Set which planes to filter. Default is all. Allowed range is from 0 to 15. + @item duration Specify how end of stream is determined. @table @samp @@ -15704,6 +15707,7 @@ This filter supports the following commands: @table @option @item weights @item scale +@item planes Syntax is same as option with same name. @end table @@ -21131,6 +21135,9 @@ unset weights. Specify scale, if it is set it will be multiplied with sum of each weight multiplied with pixel values to give final destination pixel value. By default @var{scale} is auto scaled to sum of weights. + +@item planes +Set which planes to filter. Default is all. Allowed range is from 0 to 15. @end table @subsection Examples @@ -21161,6 +21168,7 @@ This filter supports the following commands: @table @option @item weights @item scale +@item planes Syntax is same as option with same name. @end table diff --git a/libavfilter/vf_mix.c b/libavfilter/vf_mix.c index c97c09daef..5b093d2427 100644 --- a/libavfilter/vf_mix.c +++ b/libavfilter/vf_mix.c @@ -45,6 +45,7 @@ typedef struct MixContext { int depth; int max; + int planes; int nb_planes; int linesize[4]; int height[4]; @@ -147,6 +148,14 @@ static int mix_frames(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs) const int slice_end = (s->height[p] * (jobnr+1)) / nb_jobs; uint8_t *dst = out->data[p] + slice_start * out->linesize[p]; + if (!((1 << p) & s->planes)) { + av_image_copy_plane(dst, out->linesize[p], + in[0]->data[p] + slice_start * in[0]->linesize[p], + in[0]->linesize[p], + s->linesize[p], slice_end - slice_start); + continue; + } + for (y = slice_start; y < slice_end; y++) { for (x = 0; x < s->linesize[p]; x++) { float val = 0.f; @@ -169,6 +178,14 @@ static int mix_frames(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs) const int slice_end = (s->height[p] * (jobnr+1)) / nb_jobs; uint16_t *dst = (uint16_t *)(out->data[p] + slice_start * out->linesize[p]); + if (!((1 << p) & s->planes)) { + av_image_copy_plane((uint8_t *)dst, out->linesize[p], + in[0]->data[p] + slice_start * in[0]->linesize[p], + in[0]->linesize[p], + s->linesize[p], slice_end - slice_start); + continue; + } + for (y = slice_start; y < slice_end; y++) { for (x = 0; x < s->linesize[p] / 2; x++) { float val = 0.f; @@ -331,6 +348,7 @@ static const AVOption mix_options[] = { { "inputs", "set number of inputs", OFFSET(nb_inputs), AV_OPT_TYPE_INT, {.i64=2}, 2, INT16_MAX, .flags = FLAGS }, { "weights", "set weight for each input", OFFSET(weights_str), AV_OPT_TYPE_STRING, {.str="1 1"}, 0, 0, .flags = TFLAGS }, { "scale", "set scale", OFFSET(scale), AV_OPT_TYPE_FLOAT, {.dbl=0}, 0, INT16_MAX, .flags = TFLAGS }, + { "planes", "set what planes to filter", OFFSET(planes), AV_OPT_TYPE_FLAGS, {.i64=15}, 0, 15, .flags = TFLAGS }, { "duration", "how to determine end of stream", OFFSET(duration), AV_OPT_TYPE_INT, {.i64=0}, 0, 2, .flags = FLAGS, "duration" }, { "longest", "Duration of longest input", 0, AV_OPT_TYPE_CONST, {.i64=0}, 0, 0, FLAGS, "duration" }, { "shortest", "Duration of shortest input", 0, AV_OPT_TYPE_CONST, {.i64=1}, 0, 0, FLAGS, "duration" }, @@ -413,6 +431,7 @@ static const AVOption tmix_options[] = { { "frames", "set number of successive frames to mix", OFFSET(nb_inputs), AV_OPT_TYPE_INT, {.i64=3}, 1, 1024, .flags = FLAGS }, { "weights", "set weight for each frame", OFFSET(weights_str), AV_OPT_TYPE_STRING, {.str="1 1 1"}, 0, 0, .flags = TFLAGS }, { "scale", "set scale", OFFSET(scale), AV_OPT_TYPE_FLOAT, {.dbl=0}, 0, INT16_MAX, .flags = TFLAGS }, + { "planes", "set what planes to filter", OFFSET(planes), AV_OPT_TYPE_FLAGS, {.i64=15}, 0, 15, .flags = TFLAGS }, { NULL }, };