Commit 892eae20 authored by Stefan Westerfeld's avatar Stefan Westerfeld

avfilter/asubprocess: move subprocess frame processing to update_state

Signed-off-by: Stefan Westerfeld's avatarStefan Westerfeld <stefan@space.twc.de>
parent 511b83cc
......@@ -236,6 +236,8 @@ sp_read(SP *sp, char *buffer, size_t count)
}
}
static int try_read_frame(AVFilterContext *ctx);
static int update_state(AVFilterContext *ctx)
{
AVFilterLink *outlink = ctx->outputs[0];
......@@ -320,6 +322,7 @@ static int update_state(AVFilterContext *ctx)
}
}
if (s->state == STATE_IN_DATA_CHUNK) {
int ret;
int bytes_per_sample = s->out_bit_depth / 8 * outlink->ch_layout.nb_channels;
size_t expect_bytes = (s->nb_input_samples - s->nb_output_samples) * bytes_per_sample;
if ((s->nb_input_samples * bytes_per_sample) % 2) // padding byte for odd length input
......@@ -328,6 +331,11 @@ static int update_state(AVFilterContext *ctx)
av_log(ctx, AV_LOG_ERROR, "Subprocess produced more output data than expected.\n");
return AVERROR_INVALIDDATA;
}
do {
ret = try_read_frame(ctx);
if (ret < 0)
return ret;
} while (ret > 0);
}
return 0;
}
......@@ -586,6 +594,7 @@ static int write_frame(AVFilterContext *ctx, ASubProcessContext *s, AVFilterLink
return AVERROR(ENOMEM);
}
av_frame_copy_props(out, in);
// TODO: LEAK
}
ff_framequeue_add(&s->frame_queue, out);
return ret;
......@@ -639,10 +648,6 @@ static int activate(AVFilterContext *ctx)
FF_FILTER_FORWARD_STATUS_BACK(outlink, inlink);
ret = try_read_frame(ctx);
if (ret != 0)
return ret;
ret = ff_inlink_consume_frame(inlink, &in);
if (ret < 0)
return ret;
......@@ -666,9 +671,6 @@ static int activate(AVFilterContext *ctx)
return ret;
}
}
ret = try_read_frame(ctx);
if (ret != 0)
return ret;
if (s->eof) {
if (s->state != STATE_IN_DATA_CHUNK) {
......
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