summaryrefslogtreecommitdiff
path: root/libavfilter
diff options
context:
space:
mode:
authorPaul B Mahol <onemda@gmail.com>2022-03-14 17:39:01 +0100
committerPaul B Mahol <onemda@gmail.com>2022-03-14 17:43:12 +0100
commit1ab83dd3693742da42a32e1f8ed5f9a0778ed43e (patch)
treea3cbef74a53fc4138acb157376e6eea72c332e99 /libavfilter
parentc0f49378a9520ccd9ee4398bf3e1721a76b0569b (diff)
avfilter/vf_fieldhint: add pattern mode of filtering
Diffstat (limited to 'libavfilter')
-rw-r--r--libavfilter/vf_fieldhint.c31
1 files changed, 24 insertions, 7 deletions
diff --git a/libavfilter/vf_fieldhint.c b/libavfilter/vf_fieldhint.c
index e4513dddfa..e7afac1116 100644
--- a/libavfilter/vf_fieldhint.c
+++ b/libavfilter/vf_fieldhint.c
@@ -27,6 +27,13 @@
#include "internal.h"
#include "video.h"
+enum HintModes {
+ ABSOLUTE_HINT,
+ RELATIVE_HINT,
+ PATTERN_HINT,
+ NB_HINTS,
+};
+
typedef struct FieldHintContext {
const AVClass *class;
@@ -48,9 +55,10 @@ typedef struct FieldHintContext {
static const AVOption fieldhint_options[] = {
{ "hint", "set hint file", OFFSET(hint_file_str), AV_OPT_TYPE_STRING, {.str=NULL}, 0, 0, FLAGS },
- { "mode", "set hint mode", OFFSET(mode), AV_OPT_TYPE_INT, {.i64=0}, 0, 1, FLAGS, "mode" },
- { "absolute", 0, 0, AV_OPT_TYPE_CONST, {.i64=0}, 0, 0, FLAGS, "mode" },
- { "relative", 0, 0, AV_OPT_TYPE_CONST, {.i64=1}, 0, 0, FLAGS, "mode" },
+ { "mode", "set hint mode", OFFSET(mode), AV_OPT_TYPE_INT, {.i64=0}, 0, NB_HINTS-1, FLAGS, "mode" },
+ { "absolute", 0, 0, AV_OPT_TYPE_CONST, {.i64=ABSOLUTE_HINT}, 0, 0, FLAGS, "mode" },
+ { "relative", 0, 0, AV_OPT_TYPE_CONST, {.i64=RELATIVE_HINT}, 0, 0, FLAGS, "mode" },
+ { "pattern", 0, 0, AV_OPT_TYPE_CONST, {.i64=PATTERN_HINT}, 0, 0, FLAGS, "mode" },
{ NULL }
};
@@ -141,22 +149,30 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
return AVERROR_INVALIDDATA;
}
switch (s->mode) {
- case 0:
+ case ABSOLUTE_HINT:
if (tf > outlink->frame_count_in + 1 || tf < FFMAX(0, outlink->frame_count_in - 1) ||
bf > outlink->frame_count_in + 1 || bf < FFMAX(0, outlink->frame_count_in - 1)) {
av_log(ctx, AV_LOG_ERROR, "Out of range frames %"PRId64" and/or %"PRId64" on line %"PRId64" for %"PRId64". input frame.\n", tf, bf, s->line, inlink->frame_count_out);
return AVERROR_INVALIDDATA;
}
break;
- case 1:
+ case PATTERN_HINT:
+ case RELATIVE_HINT:
if (tf > 1 || tf < -1 ||
bf > 1 || bf < -1) {
av_log(ctx, AV_LOG_ERROR, "Out of range %"PRId64" and/or %"PRId64" on line %"PRId64" for %"PRId64". input frame.\n", tf, bf, s->line, inlink->frame_count_out);
return AVERROR_INVALIDDATA;
}
+ break;
+ default:
+ return AVERROR_BUG;
};
break;
} else {
+ if (s->mode == PATTERN_HINT) {
+ fseek(s->hint, 0, SEEK_SET);
+ continue;
+ }
av_log(ctx, AV_LOG_ERROR, "Missing entry for %"PRId64". input frame.\n", inlink->frame_count_out);
return AVERROR_INVALIDDATA;
}
@@ -168,11 +184,12 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
av_frame_copy_props(out, s->frame[1]);
switch (s->mode) {
- case 0:
+ case ABSOLUTE_HINT:
top = s->frame[tf - outlink->frame_count_in + 1];
bottom = s->frame[bf - outlink->frame_count_in + 1];
break;
- case 1:
+ case PATTERN_HINT:
+ case RELATIVE_HINT:
top = s->frame[1 + tf];
bottom = s->frame[1 + bf];
break;