summaryrefslogtreecommitdiff
path: root/libavfilter/vf_mix.c
diff options
context:
space:
mode:
authorPaul B Mahol <onemda@gmail.com>2022-02-15 20:04:54 +0100
committerPaul B Mahol <onemda@gmail.com>2022-02-15 20:07:40 +0100
commit30c7f37d807d5bed9aaf9f7bed23b6299c75a5c3 (patch)
treeb109ba732e10bcbfdbabef77a4339915f840e49a /libavfilter/vf_mix.c
parent538be75a69a7844542d77462ae0a1118839250e3 (diff)
avfilter/vf_mix: add planes option
Diffstat (limited to 'libavfilter/vf_mix.c')
-rw-r--r--libavfilter/vf_mix.c19
1 files changed, 19 insertions, 0 deletions
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 },
};