mirror of https://git.ffmpeg.org/ffmpeg.git
avfilter/palettegen: allow a minimum of 2 colors
This commit is contained in:
parent
c94988a781
commit
cad9d7fc85
|
@ -82,7 +82,7 @@ typedef struct PaletteGenContext {
|
||||||
#define OFFSET(x) offsetof(PaletteGenContext, x)
|
#define OFFSET(x) offsetof(PaletteGenContext, 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 palettegen_options[] = {
|
static const AVOption palettegen_options[] = {
|
||||||
{ "max_colors", "set the maximum number of colors to use in the palette", OFFSET(max_colors), AV_OPT_TYPE_INT, {.i64=256}, 4, 256, FLAGS },
|
{ "max_colors", "set the maximum number of colors to use in the palette", OFFSET(max_colors), AV_OPT_TYPE_INT, {.i64=256}, 2, 256, FLAGS },
|
||||||
{ "reserve_transparent", "reserve a palette entry for transparency", OFFSET(reserve_transparent), AV_OPT_TYPE_BOOL, {.i64=1}, 0, 1, FLAGS },
|
{ "reserve_transparent", "reserve a palette entry for transparency", OFFSET(reserve_transparent), AV_OPT_TYPE_BOOL, {.i64=1}, 0, 1, FLAGS },
|
||||||
{ "transparency_color", "set a background color for transparency", OFFSET(transparency_color), AV_OPT_TYPE_COLOR, {.str="lime"}, 0, 0, FLAGS },
|
{ "transparency_color", "set a background color for transparency", OFFSET(transparency_color), AV_OPT_TYPE_COLOR, {.str="lime"}, 0, 0, FLAGS },
|
||||||
{ "stats_mode", "set statistics mode", OFFSET(stats_mode), AV_OPT_TYPE_INT, {.i64=STATS_MODE_ALL_FRAMES}, 0, NB_STATS_MODE-1, FLAGS, "mode" },
|
{ "stats_mode", "set statistics mode", OFFSET(stats_mode), AV_OPT_TYPE_INT, {.i64=STATS_MODE_ALL_FRAMES}, 0, NB_STATS_MODE-1, FLAGS, "mode" },
|
||||||
|
@ -586,6 +586,11 @@ static int init(AVFilterContext *ctx)
|
||||||
if (s->use_alpha && s->reserve_transparent)
|
if (s->use_alpha && s->reserve_transparent)
|
||||||
s->reserve_transparent = 0;
|
s->reserve_transparent = 0;
|
||||||
|
|
||||||
|
if (s->max_colors - s->reserve_transparent < 2) {
|
||||||
|
av_log(ctx, AV_LOG_ERROR, "max_colors=2 is only allowed without reserving a transparent color slot\n");
|
||||||
|
return AVERROR(EINVAL);
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue