diff options
author | Anton Khirnov <anton@khirnov.net> | 2012-07-14 09:25:33 +0200 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2012-07-22 09:14:05 +0200 |
commit | d4f89906e3b310609b636cf6071313ec557ec873 (patch) | |
tree | af879b33d3d8b1fdf14c517bfb1317f349042b15 /libavfilter | |
parent | e9b992d035b58209d66115bd7d964741dd31d592 (diff) | |
download | ffmpeg-d4f89906e3b310609b636cf6071313ec557ec873.tar.gz |
lavfi: add error handling to end_frame().
Diffstat (limited to 'libavfilter')
-rw-r--r-- | libavfilter/avfilter.h | 4 | ||||
-rw-r--r-- | libavfilter/fifo.c | 5 | ||||
-rw-r--r-- | libavfilter/internal.h | 4 | ||||
-rw-r--r-- | libavfilter/split.c | 12 | ||||
-rw-r--r-- | libavfilter/vf_blackframe.c | 4 | ||||
-rw-r--r-- | libavfilter/vf_crop.c | 4 | ||||
-rw-r--r-- | libavfilter/vf_cropdetect.c | 4 | ||||
-rw-r--r-- | libavfilter/vf_delogo.c | 9 | ||||
-rw-r--r-- | libavfilter/vf_drawtext.c | 9 | ||||
-rw-r--r-- | libavfilter/vf_fade.c | 7 | ||||
-rw-r--r-- | libavfilter/vf_fieldorder.c | 4 | ||||
-rw-r--r-- | libavfilter/vf_fps.c | 17 | ||||
-rw-r--r-- | libavfilter/vf_frei0r.c | 9 | ||||
-rw-r--r-- | libavfilter/vf_gradfun.c | 10 | ||||
-rw-r--r-- | libavfilter/vf_hqdn3d.c | 9 | ||||
-rw-r--r-- | libavfilter/vf_libopencv.c | 9 | ||||
-rw-r--r-- | libavfilter/vf_overlay.c | 9 | ||||
-rw-r--r-- | libavfilter/vf_pad.c | 4 | ||||
-rw-r--r-- | libavfilter/vf_select.c | 7 | ||||
-rw-r--r-- | libavfilter/vf_showinfo.c | 4 | ||||
-rw-r--r-- | libavfilter/vf_transpose.c | 10 | ||||
-rw-r--r-- | libavfilter/vf_unsharp.c | 9 | ||||
-rw-r--r-- | libavfilter/vf_yadif.c | 12 | ||||
-rw-r--r-- | libavfilter/video.c | 18 | ||||
-rw-r--r-- | libavfilter/video.h | 6 | ||||
-rw-r--r-- | libavfilter/vsink_nullsink.c | 3 |
26 files changed, 126 insertions, 76 deletions
diff --git a/libavfilter/avfilter.h b/libavfilter/avfilter.h index 3cd65da1e7..7ca9eb42b3 100644 --- a/libavfilter/avfilter.h +++ b/libavfilter/avfilter.h @@ -287,8 +287,10 @@ struct AVFilterPad { * in the link structure during start_frame(). * * Input video pads only. + * + * @return >= 0 on success, a negative AVERROR on error. */ - void (*end_frame)(AVFilterLink *link); + int (*end_frame)(AVFilterLink *link); /** * Slice drawing callback. This is where a filter receives video data diff --git a/libavfilter/fifo.c b/libavfilter/fifo.c index f7788b26a6..16a86b3565 100644 --- a/libavfilter/fifo.c +++ b/libavfilter/fifo.c @@ -98,7 +98,10 @@ static void queue_pop(FifoContext *s) s->root.next = tmp; } -static void end_frame(AVFilterLink *inlink) { } +static int end_frame(AVFilterLink *inlink) +{ + return 0; +} static int draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir) { diff --git a/libavfilter/internal.h b/libavfilter/internal.h index 3a2d50d65c..6f868ae89f 100644 --- a/libavfilter/internal.h +++ b/libavfilter/internal.h @@ -98,8 +98,10 @@ struct AVFilterPad { * in the link structure during start_frame(). * * Input video pads only. + * + * @return >= 0 on success, a negative AVERROR on error. */ - void (*end_frame)(AVFilterLink *link); + int (*end_frame)(AVFilterLink *link); /** * Slice drawing callback. This is where a filter receives video data diff --git a/libavfilter/split.c b/libavfilter/split.c index 0ae0a60056..469f69d76a 100644 --- a/libavfilter/split.c +++ b/libavfilter/split.c @@ -90,13 +90,17 @@ static int draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir) return ret; } -static void end_frame(AVFilterLink *inlink) +static int end_frame(AVFilterLink *inlink) { AVFilterContext *ctx = inlink->dst; - int i; + int i, ret = 0; - for (i = 0; i < ctx->nb_outputs; i++) - ff_end_frame(ctx->outputs[i]); + for (i = 0; i < ctx->nb_outputs; i++) { + ret = ff_end_frame(ctx->outputs[i]); + if (ret < 0) + break; + } + return ret; } AVFilter avfilter_vf_split = { diff --git a/libavfilter/vf_blackframe.c b/libavfilter/vf_blackframe.c index 9fd544921b..bf0b18bea3 100644 --- a/libavfilter/vf_blackframe.c +++ b/libavfilter/vf_blackframe.c @@ -91,7 +91,7 @@ static int draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir) return ff_draw_slice(ctx->outputs[0], y, h, slice_dir); } -static void end_frame(AVFilterLink *inlink) +static int end_frame(AVFilterLink *inlink) { AVFilterContext *ctx = inlink->dst; BlackFrameContext *blackframe = ctx->priv; @@ -106,7 +106,7 @@ static void end_frame(AVFilterLink *inlink) blackframe->frame++; blackframe->nblack = 0; - ff_end_frame(inlink->dst->outputs[0]); + return ff_end_frame(inlink->dst->outputs[0]); } AVFilter avfilter_vf_blackframe = { diff --git a/libavfilter/vf_crop.c b/libavfilter/vf_crop.c index f7d311a9a8..4361ba5a8c 100644 --- a/libavfilter/vf_crop.c +++ b/libavfilter/vf_crop.c @@ -315,12 +315,12 @@ static int draw_slice(AVFilterLink *link, int y, int h, int slice_dir) return ff_draw_slice(ctx->outputs[0], y - crop->y, h, slice_dir); } -static void end_frame(AVFilterLink *link) +static int end_frame(AVFilterLink *link) { CropContext *crop = link->dst->priv; crop->var_values[VAR_N] += 1.0; - ff_end_frame(link->dst->outputs[0]); + return ff_end_frame(link->dst->outputs[0]); } AVFilter avfilter_vf_crop = { diff --git a/libavfilter/vf_cropdetect.c b/libavfilter/vf_cropdetect.c index 1790f4b4e5..8b6063c996 100644 --- a/libavfilter/vf_cropdetect.c +++ b/libavfilter/vf_cropdetect.c @@ -114,7 +114,7 @@ static int config_input(AVFilterLink *inlink) return 0; } -static void end_frame(AVFilterLink *inlink) +static int end_frame(AVFilterLink *inlink) { AVFilterContext *ctx = inlink->dst; CropDetectContext *cd = ctx->priv; @@ -191,7 +191,7 @@ static void end_frame(AVFilterLink *inlink) w, h, x, y); } - ff_end_frame(inlink->dst->outputs[0]); + return ff_end_frame(inlink->dst->outputs[0]); } AVFilter avfilter_vf_cropdetect = { diff --git a/libavfilter/vf_delogo.c b/libavfilter/vf_delogo.c index 6e77cf19a8..81f33b727e 100644 --- a/libavfilter/vf_delogo.c +++ b/libavfilter/vf_delogo.c @@ -250,7 +250,7 @@ static int null_draw_slice(AVFilterLink *link, int y, int h, int slice_dir) return 0; } -static void end_frame(AVFilterLink *inlink) +static int end_frame(AVFilterLink *inlink) { DelogoContext *delogo = inlink->dst->priv; AVFilterLink *outlink = inlink->dst->outputs[0]; @@ -260,6 +260,7 @@ static void end_frame(AVFilterLink *inlink) int hsub0 = av_pix_fmt_descriptors[inlink->format].log2_chroma_w; int vsub0 = av_pix_fmt_descriptors[inlink->format].log2_chroma_h; int plane; + int ret; for (plane = 0; plane < 4 && inpicref->data[plane]; plane++) { int hsub = plane == 1 || plane == 2 ? hsub0 : 0; @@ -274,8 +275,10 @@ static void end_frame(AVFilterLink *inlink) delogo->show, direct); } - ff_draw_slice(outlink, 0, inlink->h, 1); - ff_end_frame(outlink); + if ((ret = ff_draw_slice(outlink, 0, inlink->h, 1)) < 0 || + (ret = ff_end_frame(outlink)) < 0) + return ret; + return 0; } AVFilter avfilter_vf_delogo = { diff --git a/libavfilter/vf_drawtext.c b/libavfilter/vf_drawtext.c index 732ab32aaa..30bdcea16d 100644 --- a/libavfilter/vf_drawtext.c +++ b/libavfilter/vf_drawtext.c @@ -860,19 +860,22 @@ static int start_frame(AVFilterLink *inlink, AVFilterBufferRef *inpicref) return ff_start_frame(inlink->dst->outputs[0], buf_out); } -static void end_frame(AVFilterLink *inlink) +static int end_frame(AVFilterLink *inlink) { AVFilterLink *outlink = inlink->dst->outputs[0]; AVFilterBufferRef *picref = inlink->cur_buf; DrawTextContext *dtext = inlink->dst->priv; + int ret; if (dtext->draw) draw_text(inlink->dst, picref, picref->video->w, picref->video->h); dtext->var_values[VAR_N] += 1.0; - ff_draw_slice(outlink, 0, picref->video->h, 1); - ff_end_frame(outlink); + if ((ret = ff_draw_slice(outlink, 0, picref->video->h, 1)) < 0 || + (ret = ff_end_frame(outlink)) < 0) + return ret; + return 0; } AVFilter avfilter_vf_drawtext = { diff --git a/libavfilter/vf_fade.c b/libavfilter/vf_fade.c index 0a2a655cce..c30a862ad6 100644 --- a/libavfilter/vf_fade.c +++ b/libavfilter/vf_fade.c @@ -137,17 +137,20 @@ static int draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir) return ff_draw_slice(inlink->dst->outputs[0], y, h, slice_dir); } -static void end_frame(AVFilterLink *inlink) +static int end_frame(AVFilterLink *inlink) { FadeContext *fade = inlink->dst->priv; + int ret; - ff_end_frame(inlink->dst->outputs[0]); + ret = ff_end_frame(inlink->dst->outputs[0]); if (fade->frame_index >= fade->start_frame && fade->frame_index <= fade->stop_frame) fade->factor += fade->fade_per_frame; fade->factor = av_clip_uint16(fade->factor); fade->frame_index++; + + return ret; } AVFilter avfilter_vf_fade = { diff --git a/libavfilter/vf_fieldorder.c b/libavfilter/vf_fieldorder.c index 312ff4fc26..4ea7fe1127 100644 --- a/libavfilter/vf_fieldorder.c +++ b/libavfilter/vf_fieldorder.c @@ -163,7 +163,7 @@ static int draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir) return 0; } -static void end_frame(AVFilterLink *inlink) +static int end_frame(AVFilterLink *inlink) { AVFilterContext *ctx = inlink->dst; FieldOrderContext *fieldorder = ctx->priv; @@ -227,7 +227,7 @@ static void end_frame(AVFilterLink *inlink) "not interlaced or field order already correct\n"); } - ff_end_frame(outlink); + return ff_end_frame(outlink); } AVFilter avfilter_vf_fieldorder = { diff --git a/libavfilter/vf_fps.c b/libavfilter/vf_fps.c index 619a86cc11..9ca0668c76 100644 --- a/libavfilter/vf_fps.c +++ b/libavfilter/vf_fps.c @@ -166,14 +166,14 @@ static int write_to_fifo(AVFifoBuffer *fifo, AVFilterBufferRef *buf) return 0; } -static void end_frame(AVFilterLink *inlink) +static int end_frame(AVFilterLink *inlink) { AVFilterContext *ctx = inlink->dst; FPSContext *s = ctx->priv; AVFilterLink *outlink = ctx->outputs[0]; AVFilterBufferRef *buf = inlink->cur_buf; int64_t delta; - int i; + int i, ret; inlink->cur_buf = NULL; s->frames_in++; @@ -188,13 +188,12 @@ static void end_frame(AVFilterLink *inlink) avfilter_unref_buffer(buf); s->drop++; } - return; + return 0; } /* now wait for the next timestamp */ if (buf->pts == AV_NOPTS_VALUE) { - write_to_fifo(s->fifo, buf); - return; + return write_to_fifo(s->fifo, buf); } /* number of output frames */ @@ -211,10 +210,10 @@ static void end_frame(AVFilterLink *inlink) av_fifo_generic_read(s->fifo, &tmp, sizeof(tmp), NULL); flush_fifo(s->fifo); - write_to_fifo(s->fifo, tmp); + ret = write_to_fifo(s->fifo, tmp); avfilter_unref_buffer(buf); - return; + return ret; } /* can output >= 1 frames */ @@ -239,8 +238,10 @@ static void end_frame(AVFilterLink *inlink) } flush_fifo(s->fifo); - write_to_fifo(s->fifo, buf); + ret = write_to_fifo(s->fifo, buf); s->pts = s->first_pts + av_rescale_q(s->frames_out, outlink->time_base, inlink->time_base); + + return ret; } static int null_start_frame(AVFilterLink *link, AVFilterBufferRef *buf) diff --git a/libavfilter/vf_frei0r.c b/libavfilter/vf_frei0r.c index 21221e1ed8..4721779348 100644 --- a/libavfilter/vf_frei0r.c +++ b/libavfilter/vf_frei0r.c @@ -345,18 +345,21 @@ static int null_draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir) return 0; } -static void end_frame(AVFilterLink *inlink) +static int end_frame(AVFilterLink *inlink) { Frei0rContext *frei0r = inlink->dst->priv; AVFilterLink *outlink = inlink->dst->outputs[0]; AVFilterBufferRef *inpicref = inlink->cur_buf; AVFilterBufferRef *outpicref = outlink->out_buf; + int ret; frei0r->update(frei0r->instance, inpicref->pts * av_q2d(inlink->time_base) * 1000, (const uint32_t *)inpicref->data[0], (uint32_t *)outpicref->data[0]); - ff_draw_slice(outlink, 0, outlink->h, 1); - ff_end_frame(outlink); + if ((ret = ff_draw_slice(outlink, 0, outlink->h, 1)) || + (ret = ff_end_frame(outlink)) < 0) + return ret; + return 0; } AVFilter avfilter_vf_frei0r = { diff --git a/libavfilter/vf_gradfun.c b/libavfilter/vf_gradfun.c index 61be40c913..d73e833865 100644 --- a/libavfilter/vf_gradfun.c +++ b/libavfilter/vf_gradfun.c @@ -215,13 +215,13 @@ static int null_draw_slice(AVFilterLink *link, int y, int h, int slice_dir) return 0; } -static void end_frame(AVFilterLink *inlink) +static int end_frame(AVFilterLink *inlink) { GradFunContext *gf = inlink->dst->priv; AVFilterBufferRef *inpic = inlink->cur_buf; AVFilterLink *outlink = inlink->dst->outputs[0]; AVFilterBufferRef *outpic = outlink->out_buf; - int p; + int p, ret; for (p = 0; p < 4 && inpic->data[p]; p++) { int w = inlink->w; @@ -239,8 +239,10 @@ static void end_frame(AVFilterLink *inlink) av_image_copy_plane(outpic->data[p], outpic->linesize[p], inpic->data[p], inpic->linesize[p], w, h); } - ff_draw_slice(outlink, 0, inlink->h, 1); - ff_end_frame(outlink); + if ((ret = ff_draw_slice(outlink, 0, inlink->h, 1)) < 0 || + (ret = ff_end_frame(outlink)) < 0) + return ret; + return 0; } AVFilter avfilter_vf_gradfun = { diff --git a/libavfilter/vf_hqdn3d.c b/libavfilter/vf_hqdn3d.c index 3985ce4501..9e01606041 100644 --- a/libavfilter/vf_hqdn3d.c +++ b/libavfilter/vf_hqdn3d.c @@ -295,7 +295,7 @@ static int null_draw_slice(AVFilterLink *link, int y, int h, int slice_dir) return 0; } -static void end_frame(AVFilterLink *inlink) +static int end_frame(AVFilterLink *inlink) { HQDN3DContext *hqdn3d = inlink->dst->priv; AVFilterLink *outlink = inlink->dst->outputs[0]; @@ -303,6 +303,7 @@ static void end_frame(AVFilterLink *inlink) AVFilterBufferRef *outpic = outlink->out_buf; int cw = inpic->video->w >> hqdn3d->hsub; int ch = inpic->video->h >> hqdn3d->vsub; + int ret; deNoise(inpic->data[0], outpic->data[0], hqdn3d->Line, &hqdn3d->Frame[0], inpic->video->w, inpic->video->h, @@ -323,8 +324,10 @@ static void end_frame(AVFilterLink *inlink) hqdn3d->Coefs[2], hqdn3d->Coefs[3]); - ff_draw_slice(outlink, 0, inpic->video->h, 1); - ff_end_frame(outlink); + if ((ret = ff_draw_slice(outlink, 0, inpic->video->h, 1)) < 0 || + (ret = ff_end_frame(outlink)) < 0) + return ret; + return 0; } AVFilter avfilter_vf_hqdn3d = { diff --git a/libavfilter/vf_libopencv.c b/libavfilter/vf_libopencv.c index aa30d36880..e60caf2bc3 100644 --- a/libavfilter/vf_libopencv.c +++ b/libavfilter/vf_libopencv.c @@ -354,7 +354,7 @@ static av_cold void uninit(AVFilterContext *ctx) memset(ocv, 0, sizeof(*ocv)); } -static void end_frame(AVFilterLink *inlink) +static int end_frame(AVFilterLink *inlink) { AVFilterContext *ctx = inlink->dst; OCVContext *ocv = ctx->priv; @@ -362,14 +362,17 @@ static void end_frame(AVFilterLink *inlink) AVFilterBufferRef *inpicref = inlink ->cur_buf; AVFilterBufferRef *outpicref = outlink->out_buf; IplImage inimg, outimg; + int ret; fill_iplimage_from_picref(&inimg , inpicref , inlink->format); fill_iplimage_from_picref(&outimg, outpicref, inlink->format); ocv->end_frame_filter(ctx, &inimg, &outimg); fill_picref_from_iplimage(outpicref, &outimg, inlink->format); - ff_draw_slice(outlink, 0, outlink->h, 1); - ff_end_frame(outlink); + if ((ret = ff_draw_slice(outlink, 0, outlink->h, 1)) < 0 || + (ret = ff_end_frame(outlink)) < 0) + return ret; + return 0; } AVFilter avfilter_vf_ocv = { diff --git a/libavfilter/vf_overlay.c b/libavfilter/vf_overlay.c index 2b9439c911..a0c423de26 100644 --- a/libavfilter/vf_overlay.c +++ b/libavfilter/vf_overlay.c @@ -337,9 +337,9 @@ static int draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir) return ff_draw_slice(outlink, y, h, slice_dir); } -static void end_frame(AVFilterLink *inlink) +static int end_frame(AVFilterLink *inlink) { - ff_end_frame(inlink->dst->outputs[0]); + return ff_end_frame(inlink->dst->outputs[0]); } static int null_draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir) @@ -347,7 +347,10 @@ static int null_draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir) return 0; } -static void null_end_frame(AVFilterLink *inlink) { } +static int null_end_frame(AVFilterLink *inlink) +{ + return 0; +} static int poll_frame(AVFilterLink *link) { diff --git a/libavfilter/vf_pad.c b/libavfilter/vf_pad.c index 2f641f2eb6..262a416488 100644 --- a/libavfilter/vf_pad.c +++ b/libavfilter/vf_pad.c @@ -362,9 +362,9 @@ fail: return ret; } -static void end_frame(AVFilterLink *link) +static int end_frame(AVFilterLink *link) { - ff_end_frame(link->dst->outputs[0]); + return ff_end_frame(link->dst->outputs[0]); } static int draw_send_bar_slice(AVFilterLink *link, int y, int h, int slice_dir, int before_slice) diff --git a/libavfilter/vf_select.c b/libavfilter/vf_select.c index a4bb2dfe2b..b9e053fc03 100644 --- a/libavfilter/vf_select.c +++ b/libavfilter/vf_select.c @@ -258,15 +258,16 @@ static int draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir) return 0; } -static void end_frame(AVFilterLink *inlink) +static int end_frame(AVFilterLink *inlink) { SelectContext *select = inlink->dst->priv; if (select->select) { if (select->cache_frames) - return; - ff_end_frame(inlink->dst->outputs[0]); + return 0; + return ff_end_frame(inlink->dst->outputs[0]); } + return 0; } static int request_frame(AVFilterLink *outlink) diff --git a/libavfilter/vf_showinfo.c b/libavfilter/vf_showinfo.c index cc1360e76c..254141d677 100644 --- a/libavfilter/vf_showinfo.c +++ b/libavfilter/vf_showinfo.c @@ -40,7 +40,7 @@ static av_cold int init(AVFilterContext *ctx, const char *args) return 0; } -static void end_frame(AVFilterLink *inlink) +static int end_frame(AVFilterLink *inlink) { AVFilterContext *ctx = inlink->dst; ShowInfoContext *showinfo = ctx->priv; @@ -76,7 +76,7 @@ static void end_frame(AVFilterLink *inlink) checksum, plane_checksum[0], plane_checksum[1], plane_checksum[2], plane_checksum[3]); showinfo->frame++; - ff_end_frame(inlink->dst->outputs[0]); + return ff_end_frame(inlink->dst->outputs[0]); } AVFilter avfilter_vf_showinfo = { diff --git a/libavfilter/vf_transpose.c b/libavfilter/vf_transpose.c index cafd17d42a..49b54d760b 100644 --- a/libavfilter/vf_transpose.c +++ b/libavfilter/vf_transpose.c @@ -138,13 +138,13 @@ static int start_frame(AVFilterLink *inlink, AVFilterBufferRef *picref) return ff_start_frame(outlink, avfilter_ref_buffer(outlink->out_buf, ~0)); } -static void end_frame(AVFilterLink *inlink) +static int end_frame(AVFilterLink *inlink) { TransContext *trans = inlink->dst->priv; AVFilterBufferRef *inpic = inlink->cur_buf; AVFilterBufferRef *outpic = inlink->dst->outputs[0]->out_buf; AVFilterLink *outlink = inlink->dst->outputs[0]; - int plane; + int plane, ret; for (plane = 0; outpic->data[plane]; plane++) { int hsub = plane == 1 || plane == 2 ? trans->hsub : 0; @@ -195,8 +195,10 @@ static void end_frame(AVFilterLink *inlink) } } - ff_draw_slice(outlink, 0, outpic->video->h, 1); - ff_end_frame(outlink); + if ((ret = ff_draw_slice(outlink, 0, outpic->video->h, 1)) < 0 || + (ret = ff_end_frame(outlink)) < 0) + return ret; + return 0; } AVFilter avfilter_vf_transpose = { diff --git a/libavfilter/vf_unsharp.c b/libavfilter/vf_unsharp.c index 41bcae2dd1..6140c75a87 100644 --- a/libavfilter/vf_unsharp.c +++ b/libavfilter/vf_unsharp.c @@ -213,20 +213,23 @@ static av_cold void uninit(AVFilterContext *ctx) free_filter_param(&unsharp->chroma); } -static void end_frame(AVFilterLink *link) +static int end_frame(AVFilterLink *link) { UnsharpContext *unsharp = link->dst->priv; AVFilterBufferRef *in = link->cur_buf; AVFilterBufferRef *out = link->dst->outputs[0]->out_buf; int cw = SHIFTUP(link->w, unsharp->hsub); int ch = SHIFTUP(link->h, unsharp->vsub); + int ret; apply_unsharp(out->data[0], out->linesize[0], in->data[0], in->linesize[0], link->w, link->h, &unsharp->luma); apply_unsharp(out->data[1], out->linesize[1], in->data[1], in->linesize[1], cw, ch, &unsharp->chroma); apply_unsharp(out->data[2], out->linesize[2], in->data[2], in->linesize[2], cw, ch, &unsharp->chroma); - ff_draw_slice(link->dst->outputs[0], 0, link->h, 1); - ff_end_frame(link->dst->outputs[0]); + if ((ret = ff_draw_slice(link->dst->outputs[0], 0, link->h, 1)) < 0 || + (ret = ff_end_frame(link->dst->outputs[0])) < 0) + return ret; + return 0; } static int draw_slice(AVFilterLink *link, int y, int h, int slice_dir) diff --git a/libavfilter/vf_yadif.c b/libavfilter/vf_yadif.c index 19652aa465..69efc8a08a 100644 --- a/libavfilter/vf_yadif.c +++ b/libavfilter/vf_yadif.c @@ -240,21 +240,23 @@ static int start_frame(AVFilterLink *link, AVFilterBufferRef *picref) return ff_start_frame(ctx->outputs[0], yadif->out); } -static void end_frame(AVFilterLink *link) +static int end_frame(AVFilterLink *link) { AVFilterContext *ctx = link->dst; YADIFContext *yadif = ctx->priv; if (!yadif->out) - return; + return 0; if (yadif->auto_enable && !yadif->cur->video->interlaced) { - ff_draw_slice(ctx->outputs[0], 0, link->h, 1); - ff_end_frame(ctx->outputs[0]); - return; + int ret = ff_draw_slice(ctx->outputs[0], 0, link->h, 1); + if (ret >= 0) + ret = ff_end_frame(ctx->outputs[0]); + return ret; } return_frame(ctx, 0); + return 0; } static int request_frame(AVFilterLink *link) diff --git a/libavfilter/video.c b/libavfilter/video.c index ffcc2347fc..8dd5bf4272 100644 --- a/libavfilter/video.c +++ b/libavfilter/video.c @@ -234,12 +234,12 @@ int ff_start_frame(AVFilterLink *link, AVFilterBufferRef *picref) return ret; } -void ff_null_end_frame(AVFilterLink *link) +int ff_null_end_frame(AVFilterLink *link) { - ff_end_frame(link->dst->outputs[0]); + return ff_end_frame(link->dst->outputs[0]); } -static void default_end_frame(AVFilterLink *inlink) +static int default_end_frame(AVFilterLink *inlink) { AVFilterLink *outlink = NULL; @@ -247,20 +247,24 @@ static void default_end_frame(AVFilterLink *inlink) outlink = inlink->dst->outputs[0]; if (outlink) { - ff_end_frame(outlink); + return ff_end_frame(outlink); } + return 0; } -void ff_end_frame(AVFilterLink *link) +int ff_end_frame(AVFilterLink *link) { - void (*end_frame)(AVFilterLink *); + int (*end_frame)(AVFilterLink *); + int ret; if (!(end_frame = link->dstpad->end_frame)) end_frame = default_end_frame; - end_frame(link); + ret = end_frame(link); clear_link(link); + + return ret; } int ff_null_draw_slice(AVFilterLink *link, int y, int h, int slice_dir) diff --git a/libavfilter/video.h b/libavfilter/video.h index 893960e7c1..ef4a1a9c32 100644 --- a/libavfilter/video.h +++ b/libavfilter/video.h @@ -41,7 +41,7 @@ AVFilterBufferRef *ff_get_video_buffer(AVFilterLink *link, int perms, int ff_null_start_frame(AVFilterLink *link, AVFilterBufferRef *picref); int ff_null_draw_slice(AVFilterLink *link, int y, int h, int slice_dir); -void ff_null_end_frame(AVFilterLink *link); +int ff_null_end_frame(AVFilterLink *link); /** * Notify the next filter of the start of a frame. @@ -61,8 +61,10 @@ int ff_start_frame(AVFilterLink *link, AVFilterBufferRef *picref); * Notify the next filter that the current frame has finished. * * @param link the output link the frame was sent over + * + * @return >= 0 on success, a negative AVERROR on error */ -void ff_end_frame(AVFilterLink *link); +int ff_end_frame(AVFilterLink *link); /** * Send a slice to the next filter. diff --git a/libavfilter/vsink_nullsink.c b/libavfilter/vsink_nullsink.c index 8d656e111f..e03dcf0085 100644 --- a/libavfilter/vsink_nullsink.c +++ b/libavfilter/vsink_nullsink.c @@ -24,8 +24,9 @@ static int start_frame(AVFilterLink *link, AVFilterBufferRef *picref) return 0; } -static void end_frame(AVFilterLink *link) +static int end_frame(AVFilterLink *link) { + return 0; } AVFilter avfilter_vsink_nullsink = { |