1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-11-21 10:55:51 +02:00

avfilter/vf_mix: add planes option

This commit is contained in:
Paul B Mahol 2022-02-15 20:04:54 +01:00
parent 538be75a69
commit 30c7f37d80
2 changed files with 27 additions and 0 deletions

View File

@ -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

View File

@ -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 },
};