avfilter/vf_mergeplanes: add alternative for less user friendly option

release/5.1
Paul B Mahol 3 years ago
parent f92e4636fe
commit 385bc756bf
  1. 12
      doc/filters.texi
  2. 24
      libavfilter/vf_mergeplanes.c

@ -16072,6 +16072,18 @@ plane, 'Cc' describes the mapping for the output stream third plane and
@item format @item format
Set output pixel format. Default is @code{yuva444p}. Set output pixel format. Default is @code{yuva444p}.
@item map0s
@item map1s
@item map2s
@item map3s
Set input to output stream mapping for output Nth plane. Default is @code{0}.
@item map0p
@item map1p
@item map2p
@item map3p
Set input to output plane mapping for output Nth plane. Default is @code{0}.
@end table @end table
@subsection Examples @subsection Examples

@ -28,8 +28,8 @@
#include "framesync.h" #include "framesync.h"
typedef struct Mapping { typedef struct Mapping {
uint8_t input; int input;
uint8_t plane; int plane;
} Mapping; } Mapping;
typedef struct InputParam { typedef struct InputParam {
@ -56,8 +56,16 @@ typedef struct MergePlanesContext {
#define OFFSET(x) offsetof(MergePlanesContext, x) #define OFFSET(x) offsetof(MergePlanesContext, x)
#define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
static const AVOption mergeplanes_options[] = { static const AVOption mergeplanes_options[] = {
{ "mapping", "set input to output plane mapping", OFFSET(mapping), AV_OPT_TYPE_INT, {.i64=0}, 0, 0x33333333, FLAGS }, { "mapping", "set input to output plane mapping", OFFSET(mapping), AV_OPT_TYPE_INT, {.i64=-1}, -1, 0x33333333, FLAGS },
{ "format", "set output pixel format", OFFSET(out_fmt), AV_OPT_TYPE_PIXEL_FMT, {.i64=AV_PIX_FMT_YUVA444P}, 0, INT_MAX, .flags=FLAGS }, { "format", "set output pixel format", OFFSET(out_fmt), AV_OPT_TYPE_PIXEL_FMT, {.i64=AV_PIX_FMT_YUVA444P}, 0, INT_MAX, .flags=FLAGS },
{ "map0s", "set 1st input to output stream mapping", OFFSET(map[0].input), AV_OPT_TYPE_INT, {.i64=0}, 0, 3, FLAGS },
{ "map0p", "set 1st input to output plane mapping", OFFSET(map[0].plane), AV_OPT_TYPE_INT, {.i64=0}, 0, 3, FLAGS },
{ "map1s", "set 2nd input to output stream mapping", OFFSET(map[1].input), AV_OPT_TYPE_INT, {.i64=0}, 0, 3, FLAGS },
{ "map1p", "set 2nd input to output plane mapping", OFFSET(map[1].plane), AV_OPT_TYPE_INT, {.i64=0}, 0, 3, FLAGS },
{ "map2s", "set 3rd input to output stream mapping", OFFSET(map[2].input), AV_OPT_TYPE_INT, {.i64=0}, 0, 3, FLAGS },
{ "map2p", "set 3rd input to output plane mapping", OFFSET(map[2].plane), AV_OPT_TYPE_INT, {.i64=0}, 0, 3, FLAGS },
{ "map3s", "set 4th input to output stream mapping", OFFSET(map[3].input), AV_OPT_TYPE_INT, {.i64=0}, 0, 3, FLAGS },
{ "map3p", "set 4th input to output plane mapping", OFFSET(map[3].plane), AV_OPT_TYPE_INT, {.i64=0}, 0, 3, FLAGS },
{ NULL } { NULL }
}; };
@ -78,10 +86,12 @@ static av_cold int init(AVFilterContext *ctx)
s->nb_planes = av_pix_fmt_count_planes(s->out_fmt); s->nb_planes = av_pix_fmt_count_planes(s->out_fmt);
for (i = s->nb_planes - 1; i >= 0; i--) { for (i = s->nb_planes - 1; i >= 0; i--) {
s->map[i].plane = m & 0xf; if (m >= 0 && m <= 0x33333333) {
m >>= 4; s->map[i].plane = m & 0xf;
s->map[i].input = m & 0xf; m >>= 4;
m >>= 4; s->map[i].input = m & 0xf;
m >>= 4;
}
if (s->map[i].plane > 3 || s->map[i].input > 3) { if (s->map[i].plane > 3 || s->map[i].input > 3) {
av_log(ctx, AV_LOG_ERROR, "Mapping with out of range input and/or plane number.\n"); av_log(ctx, AV_LOG_ERROR, "Mapping with out of range input and/or plane number.\n");

Loading…
Cancel
Save