diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2012-07-22 22:57:02 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2012-07-22 23:56:21 +0200 |
commit | 88beb2df982aa4de257f742ff41f777927cc5173 (patch) | |
tree | 15427851afeaa2fee531f53808237948b81b2e44 /libavfilter/vf_pad.c | |
parent | 9023de342f88e961a3741753aff68925eebf884e (diff) | |
parent | df53a4a7c1c496363e3fc165b431940ccd0cb8a0 (diff) |
Merge remote-tracking branch 'qatar/master'
* qatar/master:
FATE: fix the asyncts test
build: Drop gcc-specific warning flag from header compilation rule
FATE: add a test for the asyncts audio filter.
matroskadec: return more correct error code on read error.
buffersrc: check ff_get_audio_buffer() for errors.
lavfi: check all ff_get_video_buffer() calls for errors.
lavfi: check all avfilter_ref_buffer() calls for errors.
vf_select: avoid an unnecessary avfilter_ref_buffer().
buffersrc: avoid creating unnecessary buffer reference
lavfi: use avfilter_unref_bufferp() where appropriate.
vf_fps: add more error checks.
vf_fps: fix a memleak on malloc failure.
lavfi: check all ff_start_frame/draw_slice/end_frame calls for errors
lavfi: add error handling to end_frame().
lavfi: add error handling to draw_slice().
lavfi: add error handling to start_frame().
Conflicts:
Makefile
ffplay.c
libavfilter/buffersrc.c
libavfilter/vf_boxblur.c
libavfilter/vf_drawtext.c
libavfilter/vf_fade.c
libavfilter/vf_frei0r.c
libavfilter/vf_hflip.c
libavfilter/vf_overlay.c
libavfilter/vf_pad.c
libavfilter/vf_scale.c
libavfilter/video.c
libavfilter/vsrc_color.c
Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavfilter/vf_pad.c')
-rw-r--r-- | libavfilter/vf_pad.c | 49 |
1 files changed, 37 insertions, 12 deletions
diff --git a/libavfilter/vf_pad.c b/libavfilter/vf_pad.c index e88ea1348b..3e9dfa2680 100644 --- a/libavfilter/vf_pad.c +++ b/libavfilter/vf_pad.c @@ -226,6 +226,9 @@ static AVFilterBufferRef *get_video_buffer(AVFilterLink *inlink, int perms, int h + (pad->h - pad->in_h)); int plane; + if (!picref) + return NULL; + picref->video->w = w; picref->video->h = h; @@ -259,12 +262,15 @@ static int does_clip(PadContext *pad, AVFilterBufferRef *outpicref, int plane, i return 0; } -static void start_frame(AVFilterLink *inlink, AVFilterBufferRef *inpicref) +static int start_frame(AVFilterLink *inlink, AVFilterBufferRef *inpicref) { PadContext *pad = inlink->dst->priv; AVFilterBufferRef *outpicref = avfilter_ref_buffer(inpicref, ~0); AVFilterBufferRef *for_next_filter; - int plane; + int plane, ret = 0; + + if (!outpicref) + return AVERROR(ENOMEM); for (plane = 0; plane < 4 && outpicref->data[plane] && pad->draw.pixelstep[plane]; plane++) { int hsub = pad->draw.hsub[plane]; @@ -292,22 +298,37 @@ static void start_frame(AVFilterLink *inlink, AVFilterBufferRef *inpicref) outpicref = ff_get_video_buffer(inlink->dst->outputs[0], AV_PERM_WRITE | AV_PERM_NEG_LINESIZES, FFMAX(inlink->w, pad->w), FFMAX(inlink->h, pad->h)); + if (!outpicref) + return AVERROR(ENOMEM); + avfilter_copy_buffer_ref_props(outpicref, inpicref); } - inlink->dst->outputs[0]->out_buf = outpicref; - outpicref->video->w = pad->w; outpicref->video->h = pad->h; for_next_filter = avfilter_ref_buffer(outpicref, ~0); - ff_start_frame(inlink->dst->outputs[0], for_next_filter); + if (!for_next_filter) { + ret = AVERROR(ENOMEM); + goto fail; + } + + ret = ff_start_frame(inlink->dst->outputs[0], for_next_filter); + if (ret < 0) + goto fail; + + inlink->dst->outputs[0]->out_buf = outpicref; + return 0; + +fail: + avfilter_unref_bufferp(&outpicref); + return ret; } -static void draw_send_bar_slice(AVFilterLink *link, int y, int h, int slice_dir, int before_slice) +static int draw_send_bar_slice(AVFilterLink *link, int y, int h, int slice_dir, int before_slice) { PadContext *pad = link->dst->priv; - int bar_y, bar_h = 0; + int bar_y, bar_h = 0, ret = 0; if (slice_dir * before_slice == 1 && y == pad->y) { /* top bar */ @@ -324,15 +345,17 @@ static void draw_send_bar_slice(AVFilterLink *link, int y, int h, int slice_dir, link->dst->outputs[0]->out_buf->data, link->dst->outputs[0]->out_buf->linesize, 0, bar_y, pad->w, bar_h); - ff_draw_slice(link->dst->outputs[0], bar_y, bar_h, slice_dir); + ret = ff_draw_slice(link->dst->outputs[0], bar_y, bar_h, slice_dir); } + return ret; } -static void draw_slice(AVFilterLink *link, int y, int h, int slice_dir) +static int draw_slice(AVFilterLink *link, int y, int h, int slice_dir) { PadContext *pad = link->dst->priv; AVFilterBufferRef *outpic = link->dst->outputs[0]->out_buf; AVFilterBufferRef *inpic = link->cur_buf; + int ret; y += pad->y; @@ -340,7 +363,7 @@ static void draw_slice(AVFilterLink *link, int y, int h, int slice_dir) h = ff_draw_round_to_sub(&pad->draw, 1, -1, h); if (!h) - return; + return 0; draw_send_bar_slice(link, y, h, slice_dir, 1); /* left border */ @@ -357,9 +380,11 @@ static void draw_slice(AVFilterLink *link, int y, int h, int slice_dir) /* right border */ ff_fill_rectangle(&pad->draw, &pad->color, outpic->data, outpic->linesize, pad->x + pad->in_w, y, pad->w - pad->x - pad->in_w, h); - ff_draw_slice(link->dst->outputs[0], y, h, slice_dir); + ret = ff_draw_slice(link->dst->outputs[0], y, h, slice_dir); + if (ret < 0) + return ret; - draw_send_bar_slice(link, y, h, slice_dir, -1); + return draw_send_bar_slice(link, y, h, slice_dir, -1); } AVFilter avfilter_vf_pad = { |