1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

lavfi/split: handle closed outputs.

Return AVERROR_EOF if all outputs are closed.
This commit is contained in:
Nicolas George 2012-08-20 19:18:46 +02:00
parent 8b61abac2e
commit a9cfe656d7

View File

@ -71,10 +71,14 @@ static void split_uninit(AVFilterContext *ctx)
static int start_frame(AVFilterLink *inlink, AVFilterBufferRef *picref) static int start_frame(AVFilterLink *inlink, AVFilterBufferRef *picref)
{ {
AVFilterContext *ctx = inlink->dst; AVFilterContext *ctx = inlink->dst;
int i, ret = 0; int i, ret = AVERROR_EOF;
for (i = 0; i < ctx->nb_outputs; i++) { for (i = 0; i < ctx->nb_outputs; i++) {
AVFilterBufferRef *buf_out = avfilter_ref_buffer(picref, ~AV_PERM_WRITE); AVFilterBufferRef *buf_out;
if (ctx->outputs[i]->closed)
continue;
buf_out = avfilter_ref_buffer(picref, ~AV_PERM_WRITE);
if (!buf_out) if (!buf_out)
return AVERROR(ENOMEM); return AVERROR(ENOMEM);
@ -88,9 +92,11 @@ static int start_frame(AVFilterLink *inlink, AVFilterBufferRef *picref)
static int draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir) static int draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir)
{ {
AVFilterContext *ctx = inlink->dst; AVFilterContext *ctx = inlink->dst;
int i, ret = 0; int i, ret = AVERROR_EOF;
for (i = 0; i < ctx->nb_outputs; i++) { for (i = 0; i < ctx->nb_outputs; i++) {
if (ctx->outputs[i]->closed)
continue;
ret = ff_draw_slice(ctx->outputs[i], y, h, slice_dir); ret = ff_draw_slice(ctx->outputs[i], y, h, slice_dir);
if (ret < 0) if (ret < 0)
break; break;
@ -101,9 +107,11 @@ static int draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir)
static int end_frame(AVFilterLink *inlink) static int end_frame(AVFilterLink *inlink)
{ {
AVFilterContext *ctx = inlink->dst; AVFilterContext *ctx = inlink->dst;
int i, ret = 0; int i, ret = AVERROR_EOF;
for (i = 0; i < ctx->nb_outputs; i++) { for (i = 0; i < ctx->nb_outputs; i++) {
if (ctx->outputs[i]->closed)
continue;
ret = ff_end_frame(ctx->outputs[i]); ret = ff_end_frame(ctx->outputs[i]);
if (ret < 0) if (ret < 0)
break; break;