Commit c411e90b authored by Benjamin Steffes's avatar Benjamin Steffes Committed by Michael Niedermayer

Fix start_frame handling in detelecine filter

Signed-off-by: 's avatarBenjamin Steffes <benjaminst123@gmail.com>
Signed-off-by: 's avatarMichael Niedermayer <michael@niedermayer.cc>
parent be482e51
...@@ -37,6 +37,7 @@ typedef struct { ...@@ -37,6 +37,7 @@ typedef struct {
int first_field; int first_field;
char *pattern; char *pattern;
int start_frame; int start_frame;
int init_len;
unsigned int pattern_pos; unsigned int pattern_pos;
unsigned int nskip_fields; unsigned int nskip_fields;
int64_t start_time; int64_t start_time;
...@@ -74,6 +75,7 @@ static av_cold int init(AVFilterContext *ctx) ...@@ -74,6 +75,7 @@ static av_cold int init(AVFilterContext *ctx)
DetelecineContext *s = ctx->priv; DetelecineContext *s = ctx->priv;
const char *p; const char *p;
int max = 0; int max = 0;
int sum = 0;
if (!strlen(s->pattern)) { if (!strlen(s->pattern)) {
av_log(ctx, AV_LOG_ERROR, "No pattern provided.\n"); av_log(ctx, AV_LOG_ERROR, "No pattern provided.\n");
...@@ -86,14 +88,21 @@ static av_cold int init(AVFilterContext *ctx) ...@@ -86,14 +88,21 @@ static av_cold int init(AVFilterContext *ctx)
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
} }
sum += *p - '0';
max = FFMAX(*p - '0', max); max = FFMAX(*p - '0', max);
s->pts.num += *p - '0'; s->pts.num += *p - '0';
s->pts.den += 2; 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->nskip_fields = 0;
s->pattern_pos = 0; s->pattern_pos = 0;
s->start_time = AV_NOPTS_VALUE; s->start_time = AV_NOPTS_VALUE;
s->init_len = 0;
if (s->start_frame != 0) { if (s->start_frame != 0) {
int nfields = 0; int nfields = 0;
...@@ -101,7 +110,7 @@ static av_cold int init(AVFilterContext *ctx) ...@@ -101,7 +110,7 @@ static av_cold int init(AVFilterContext *ctx)
nfields += *p - '0'; nfields += *p - '0';
s->pattern_pos++; s->pattern_pos++;
if (nfields >= 2*s->start_frame) { if (nfields >= 2*s->start_frame) {
s->nskip_fields = nfields - 2*s->start_frame; s->init_len = nfields - 2*s->start_frame;
break; break;
} }
} }
...@@ -211,6 +220,8 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *inpicref) ...@@ -211,6 +220,8 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *inpicref)
} }
if (s->nskip_fields == 0) { if (s->nskip_fields == 0) {
len = s->init_len;
s->init_len = 0;
while(!len && s->pattern[s->pattern_pos]) { while(!len && s->pattern[s->pattern_pos]) {
len = s->pattern[s->pattern_pos] - '0'; len = s->pattern[s->pattern_pos] - '0';
s->pattern_pos++; s->pattern_pos++;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment