summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenjamin Steffes <benjaminst123@gmail.com>2016-03-17 23:10:00 +0100
committerMichael Niedermayer <michael@niedermayer.cc>2016-03-19 03:58:47 +0100
commitc411e90bc3f191c75cb9e249e6ae27fd28894d2c (patch)
tree4a7db403e4e888ebbca95e0faced1fd0689c138b
parentbe482e5165256091ecdd8aaa4cf7376abc97cf05 (diff)
downloadffmpeg-streaming-c411e90bc3f191c75cb9e249e6ae27fd28894d2c.zip
ffmpeg-streaming-c411e90bc3f191c75cb9e249e6ae27fd28894d2c.tar.gz
Fix start_frame handling in detelecine filter
Signed-off-by: Benjamin Steffes <benjaminst123@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
-rw-r--r--libavfilter/vf_detelecine.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/libavfilter/vf_detelecine.c b/libavfilter/vf_detelecine.c
index 16230f1..639a391 100644
--- a/libavfilter/vf_detelecine.c
+++ b/libavfilter/vf_detelecine.c
@@ -37,6 +37,7 @@ typedef struct {
int first_field;
char *pattern;
int start_frame;
+ int init_len;
unsigned int pattern_pos;
unsigned int nskip_fields;
int64_t start_time;
@@ -74,6 +75,7 @@ static av_cold int init(AVFilterContext *ctx)
DetelecineContext *s = ctx->priv;
const char *p;
int max = 0;
+ int sum = 0;
if (!strlen(s->pattern)) {
av_log(ctx, AV_LOG_ERROR, "No pattern provided.\n");
@@ -86,14 +88,21 @@ static av_cold int init(AVFilterContext *ctx)
return AVERROR_INVALIDDATA;
}
+ sum += *p - '0';
max = FFMAX(*p - '0', max);
s->pts.num += *p - '0';
s->pts.den += 2;
}
+ if (s->start_frame >= sum) {
+ av_log(ctx, AV_LOG_ERROR, "Provided start_frame is too big.\n");
+ return AVERROR_INVALIDDATA;
+ }
+
s->nskip_fields = 0;
s->pattern_pos = 0;
s->start_time = AV_NOPTS_VALUE;
+ s->init_len = 0;
if (s->start_frame != 0) {
int nfields = 0;
@@ -101,7 +110,7 @@ static av_cold int init(AVFilterContext *ctx)
nfields += *p - '0';
s->pattern_pos++;
if (nfields >= 2*s->start_frame) {
- s->nskip_fields = nfields - 2*s->start_frame;
+ s->init_len = nfields - 2*s->start_frame;
break;
}
}
@@ -211,6 +220,8 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *inpicref)
}
if (s->nskip_fields == 0) {
+ len = s->init_len;
+ s->init_len = 0;
while(!len && s->pattern[s->pattern_pos]) {
len = s->pattern[s->pattern_pos] - '0';
s->pattern_pos++;
OpenPOWER on IntegriCloud