Unified · Split
| @@ -28,12 +28,13 @@ · 27 unmodified lines | ||
| 28 | 28 | typedef struct LumakeyContext { |
| 29 | 29 | const AVClass *class; |
| 30 | 30 | |
| 31 | − int threshold; | |
| 32 | − int tolerance; | |
| 33 | − int softness; | |
| 31 | + double threshold; | |
| 32 | + double tolerance; | |
| 33 | + double softness; | |
| 34 | 34 | |
| 35 | 35 | int white; |
| 36 | 36 | int black; |
| 37 | + int so; | |
| 37 | 38 | int max; |
| 38 | 39 | |
| 39 | 40 | int (*do_lumakey_slice)(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs); |
| @@ -47,7 +48,7 @@ static int do_lumakey_slice8(AVFilterContext *ctx, void *arg, int jobnr, int nb_ · 7 unmodified lines | ||
| 47 | 48 | const int slice_end = (frame->height * (jobnr + 1)) / nb_jobs; |
| 48 | 49 | uint8_t *alpha = frame->data[3] + slice_start * frame->linesize[3]; |
| 49 | 50 | const uint8_t *luma = frame->data[0] + slice_start * frame->linesize[0]; |
| 50 | − const int so = s->softness; | |
| 51 | + const int so = s->so; | |
| 51 | 52 | const int w = s->white; |
| 52 | 53 | const int b = s->black; |
| 53 | 54 | int x, y; |
| @@ -79,7 +80,7 @@ static int do_lumakey_slice16(AVFilterContext *ctx, void *arg, int jobnr, int nb · 25 unmodified lines | ||
| 79 | 80 | const int slice_end = (frame->height * (jobnr + 1)) / nb_jobs; |
| 80 | 81 | uint16_t *alpha = (uint16_t *)(frame->data[3] + slice_start * frame->linesize[3]); |
| 81 | 82 | const uint16_t *luma = (const uint16_t *)(frame->data[0] + slice_start * frame->linesize[0]); |
| 82 | − const int so = s->softness; | |
| 83 | + const int so = s->so; | |
| 83 | 84 | const int w = s->white; |
| 84 | 85 | const int b = s->black; |
| 85 | 86 | const int m = s->max; |
| @@ -113,14 +114,16 @@ static int config_input(AVFilterLink *inlink) · 27 unmodified lines | ||
| 113 | 114 | |
| 114 | 115 | depth = desc->comp[0].depth; |
| 115 | 116 | if (depth == 8) { |
| 116 | − s->white = av_clip_uint8(s->threshold + s->tolerance); | |
| 117 | − s->black = av_clip_uint8(s->threshold - s->tolerance); | |
| 117 | + s->white = av_clip_uint8((s->threshold + s->tolerance) * 255); | |
| 118 | + s->black = av_clip_uint8((s->threshold - s->tolerance) * 255); | |
| 118 | 119 | s->do_lumakey_slice = do_lumakey_slice8; |
| 120 | + s->so = s->softness * 255; | |
| 119 | 121 | } else { |
| 120 | 122 | s->max = (1 << depth) - 1; |
| 121 | − s->white = av_clip(s->threshold + s->tolerance, 0, s->max); | |
| 122 | − s->black = av_clip(s->threshold - s->tolerance, 0, s->max); | |
| 123 | + s->white = av_clip((s->threshold + s->tolerance) * s->max, 0, s->max); | |
| 124 | + s->black = av_clip((s->threshold - s->tolerance) * s->max, 0, s->max); | |
| 123 | 125 | s->do_lumakey_slice = do_lumakey_slice16; |
| 126 | + s->so = s->softness * s->max; | |
| 124 | 127 | } |
| 125 | 128 | |
| 126 | 129 | return 0; |
| @@ -182,9 +185,9 @@ static const AVFilterPad lumakey_outputs[] = { · 55 unmodified lines | ||
| 182 | 185 | #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM |
| 183 | 186 | |
| 184 | 187 | static const AVOption lumakey_options[] = { |
| 185 | − { "threshold", "set the threshold value", OFFSET(threshold), AV_OPT_TYPE_INT, {.i64=0}, 0, UINT16_MAX, FLAGS }, | |
| 186 | − { "tolerance", "set the tolerance value", OFFSET(tolerance), AV_OPT_TYPE_INT, {.i64=1}, 0, UINT16_MAX, FLAGS }, | |
| 187 | − { "softness", "set the softness value", OFFSET(softness), AV_OPT_TYPE_INT, {.i64=0}, 0, UINT16_MAX, FLAGS }, | |
| 188 | + { "threshold", "set the threshold value", OFFSET(threshold), AV_OPT_TYPE_DOUBLE, {.dbl=0}, 0, 1, FLAGS }, | |
| 189 | + { "tolerance", "set the tolerance value", OFFSET(tolerance), AV_OPT_TYPE_DOUBLE, {.dbl=0.01}, 0, 1, FLAGS }, | |
| 190 | + { "softness", "set the softness value", OFFSET(softness), AV_OPT_TYPE_DOUBLE, {.dbl=0}, 0, 1, FLAGS }, | |
| 188 | 191 | { NULL } |
| 189 | 192 | }; |
| 190 | 193 | |