* 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
Unified · Split
| @@ -54,7 +54,7 @@ COMPILE_S = $(call COMPILE,AS) · 53 unmodified lines | |||
| 54 | $(COMPILE_S) | 54 | $(COMPILE_S) |
| 55 | 55 | ||
| 56 | %.ho: %.h | 56 | %.ho: %.h |
| 57 | $(CC) $(CPPFLAGS) $(CFLAGS) -Wno-unused -c -o $@ -x c $< | 57 | $(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ -x c $< |
| 58 | 58 | ||
| 59 | %.ver: %.v | 59 | %.ver: %.v |
| 60 | $(Q)sed 's/$$MAJOR/$($(basename $(@F))_VERSION_MAJOR)/' $^ > $@ | 60 | $(Q)sed 's/$$MAJOR/$($(basename $(@F))_VERSION_MAJOR)/' $^ > $@ |
| @@ -248,7 +248,7 @@ static void join_uninit(AVFilterContext *ctx) · 247 unmodified lines | |||
| 248 | 248 | ||
| 249 | for (i = 0; i < ctx->nb_inputs; i++) { | 249 | for (i = 0; i < ctx->nb_inputs; i++) { |
| 250 | av_freep(&ctx->input_pads[i].name); | 250 | av_freep(&ctx->input_pads[i].name); |
| 251 | avfilter_unref_buffer(s->input_frames[i]); | 251 | avfilter_unref_bufferp(&s->input_frames[i]); |
| 252 | } | 252 | } |
| 253 | 253 | ||
| 254 | av_freep(&s->channels); | 254 | av_freep(&s->channels); |
| @@ -402,7 +402,7 @@ static void join_free_buffer(AVFilterBuffer *buf) · 147 unmodified lines | |||
| 402 | int i; | 402 | int i; |
| 403 | 403 | ||
| 404 | for (i = 0; i < priv->nb_in_buffers; i++) | 404 | for (i = 0; i < priv->nb_in_buffers; i++) |
| 405 | avfilter_unref_buffer(priv->in_buffers[i]); | 405 | avfilter_unref_bufferp(&priv->in_buffers[i]); |
| 406 | 406 | ||
| 407 | av_freep(&priv->in_buffers); | 407 | av_freep(&priv->in_buffers); |
| 408 | av_freep(&buf->priv); | 408 | av_freep(&buf->priv); |
| @@ -261,8 +261,11 @@ struct AVFilterPad { · 260 unmodified lines | |||
| 261 | * picture inside the link structure. | 261 | * picture inside the link structure. |
| 262 | * | 262 | * |
| 263 | * Input video pads only. | 263 | * Input video pads only. |
| 264 | * | ||
| 265 | * @return >= 0 on success, a negative AVERROR on error. picref will be | ||
| 266 | * unreferenced by the caller in case of error. | ||
| 264 | */ | 267 | */ |
| 265 | void (*start_frame)(AVFilterLink *link, AVFilterBufferRef *picref); | 268 | int (*start_frame)(AVFilterLink *link, AVFilterBufferRef *picref); |
| 266 | 269 | ||
| 267 | /** | 270 | /** |
| 268 | * Callback function to get a video buffer. If NULL, the filter system will | 271 | * Callback function to get a video buffer. If NULL, the filter system will |
| @@ -287,16 +290,20 @@ struct AVFilterPad { · 18 unmodified lines | |||
| 287 | * in the link structure during start_frame(). | 290 | * in the link structure during start_frame(). |
| 288 | * | 291 | * |
| 289 | * Input video pads only. | 292 | * Input video pads only. |
| 293 | * | ||
| 294 | * @return >= 0 on success, a negative AVERROR on error. | ||
| 290 | */ | 295 | */ |
| 291 | void (*end_frame)(AVFilterLink *link); | 296 | int (*end_frame)(AVFilterLink *link); |
| 292 | 297 | ||
| 293 | /** | 298 | /** |
| 294 | * Slice drawing callback. This is where a filter receives video data | 299 | * Slice drawing callback. This is where a filter receives video data |
| 295 | * and should do its processing. | 300 | * and should do its processing. |
| 296 | * | 301 | * |
| 297 | * Input video pads only. | 302 | * Input video pads only. |
| 303 | * | ||
| 304 | * @return >= 0 on success, a negative AVERROR on error. | ||
| 298 | */ | 305 | */ |
| 299 | void (*draw_slice)(AVFilterLink *link, int y, int height, int slice_dir); | 306 | int (*draw_slice)(AVFilterLink *link, int y, int height, int slice_dir); |
| 300 | 307 | ||
| 301 | /** | 308 | /** |
| 302 | * Samples filtering callback. This is where a filter receives audio data | 309 | * Samples filtering callback. This is where a filter receives audio data |
| @@ -385,7 +392,7 @@ enum AVMediaType avfilter_pad_get_type(AVFilterPad *pads, int pad_idx); · 82 unmodified lines | |||
| 385 | 392 | ||
| 386 | /** default handler for end_frame() for video inputs */ | 393 | /** default handler for end_frame() for video inputs */ |
| 387 | attribute_deprecated | 394 | attribute_deprecated |
| 388 | void avfilter_default_end_frame(AVFilterLink *link); | 395 | int avfilter_default_end_frame(AVFilterLink *link); |
| 389 | 396 | ||
| 390 | /** | 397 | /** |
| 391 | * Filter definition. This defines the pads a filter contains, and all the | 398 | * Filter definition. This defines the pads a filter contains, and all the |
| @@ -47,20 +47,16 @@ static av_cold void uninit(AVFilterContext *ctx) · 46 unmodified lines | |||
| 47 | av_audio_fifo_free(sink->audio_fifo); | 47 | av_audio_fifo_free(sink->audio_fifo); |
| 48 | } | 48 | } |
| 49 | 49 | ||
| 50 | static void start_frame(AVFilterLink *link, AVFilterBufferRef *buf) | 50 | static int start_frame(AVFilterLink *link, AVFilterBufferRef *buf) |
| 51 | { | 51 | { |
| 52 | BufferSinkContext *s = link->dst->priv; | 52 | BufferSinkContext *s = link->dst->priv; |
| 53 | 53 | ||
| 54 | // av_assert0(!s->cur_buf); | 54 | // av_assert0(!s->cur_buf); |
| 55 | s->cur_buf = buf; | 55 | s->cur_buf = buf; |
| 56 | link->cur_buf = NULL; | 56 | link->cur_buf = NULL; |
| 57 | }; | ||
| 58 | 57 | ||
| 59 | static int filter_samples(AVFilterLink *link, AVFilterBufferRef *buf) | ||
| 60 | { | ||
| 61 | start_frame(link, buf); | ||
| 62 | return 0; | 58 | return 0; |
| 63 | } | 59 | }; |
| 64 | 60 | ||
| 65 | int av_buffersink_read(AVFilterContext *ctx, AVFilterBufferRef **buf) | 61 | int av_buffersink_read(AVFilterContext *ctx, AVFilterBufferRef **buf) |
| 66 | { | 62 | { |
| @@ -166,7 +162,7 @@ AVFilter avfilter_asink_abuffer = { · 99 unmodified lines | |||
| 166 | 162 | ||
| 167 | .inputs = (const AVFilterPad[]) {{ .name = "default", | 163 | .inputs = (const AVFilterPad[]) {{ .name = "default", |
| 168 | .type = AVMEDIA_TYPE_AUDIO, | 164 | .type = AVMEDIA_TYPE_AUDIO, |
| 169 | .filter_samples = filter_samples, | 165 | .filter_samples = start_frame, |
| 170 | .min_perms = AV_PERM_READ, | 166 | .min_perms = AV_PERM_READ, |
| 171 | .needs_fifo = 1 }, | 167 | .needs_fifo = 1 }, |
| 172 | { .name = NULL }}, | 168 | { .name = NULL }}, |
| @@ -382,19 +382,19 @@ static int request_frame(AVFilterLink *link) · 381 unmodified lines | |||
| 382 | 382 | ||
| 383 | switch (link->type) { | 383 | switch (link->type) { |
| 384 | case AVMEDIA_TYPE_VIDEO: | 384 | case AVMEDIA_TYPE_VIDEO: |
| 385 | ff_start_frame(link, avfilter_ref_buffer(buf, ~0)); | 385 | if ((ret = ff_start_frame(link, buf)) < 0 || |
| 386 | ff_draw_slice(link, 0, link->h, 1); | 386 | (ret = ff_draw_slice(link, 0, link->h, 1)) < 0 || |
| 387 | ff_end_frame(link); | 387 | (ret = ff_end_frame(link)) < 0) |
| 388 | return ret; | ||
| 388 | break; | 389 | break; |
| 389 | case AVMEDIA_TYPE_AUDIO: | 390 | case AVMEDIA_TYPE_AUDIO: |
| 390 | ret = ff_filter_samples(link, avfilter_ref_buffer(buf, ~0)); | 391 | ret = ff_filter_samples(link, buf); |
| 391 | break; | 392 | break; |
| 392 | default: | 393 | default: |
| 394 | avfilter_unref_bufferp(&buf); | ||
| 393 | return AVERROR(EINVAL); | 395 | return AVERROR(EINVAL); |
| 394 | } | 396 | } |
| 395 | 397 | ||
| 396 | avfilter_unref_buffer(buf); | ||
| 397 | |||
| 398 | return ret; | 398 | return ret; |
| 399 | } | 399 | } |
| 400 | 400 | ||
| @@ -99,7 +99,7 @@ static int config_output_props(AVFilterLink *outlink) · 98 unmodified lines | |||
| 99 | return 0; | 99 | return 0; |
| 100 | } | 100 | } |
| 101 | 101 | ||
| 102 | static void start_frame(AVFilterLink *inlink, AVFilterBufferRef *picref) | 102 | static int start_frame(AVFilterLink *inlink, AVFilterBufferRef *picref) |
| 103 | { | 103 | { |
| 104 | AVFilterContext *ctx = inlink->dst; | 104 | AVFilterContext *ctx = inlink->dst; |
| 105 | AVFilterLink *outlink = ctx->outputs[0]; | 105 | AVFilterLink *outlink = ctx->outputs[0]; |
| @@ -113,7 +113,7 @@ static void start_frame(AVFilterLink *inlink, AVFilterBufferRef *picref) · 7 unmodified lines | |||
| 113 | } | 113 | } |
| 114 | inlink->cur_buf = NULL; | 114 | inlink->cur_buf = NULL; |
| 115 | 115 | ||
| 116 | ff_start_frame(outlink, picref); | 116 | return ff_start_frame(outlink, picref); |
| 117 | } | 117 | } |
| 118 | 118 | ||
| 119 | static int filter_samples(AVFilterLink *inlink, AVFilterBufferRef *insamples) | 119 | static int filter_samples(AVFilterLink *inlink, AVFilterBufferRef *insamples) |
| @@ -65,17 +65,18 @@ static av_cold void uninit(AVFilterContext *ctx) · 64 unmodified lines | |||
| 65 | 65 | ||
| 66 | for (buf = fifo->root.next; buf; buf = tmp) { | 66 | for (buf = fifo->root.next; buf; buf = tmp) { |
| 67 | tmp = buf->next; | 67 | tmp = buf->next; |
| 68 | avfilter_unref_buffer(buf->buf); | 68 | avfilter_unref_bufferp(&buf->buf); |
| 69 | av_free(buf); | 69 | av_free(buf); |
| 70 | } | 70 | } |
| 71 | 71 | ||
| 72 | avfilter_unref_buffer(fifo->buf_out); | 72 | avfilter_unref_bufferp(&fifo->buf_out); |
| 73 | } | 73 | } |
| 74 | 74 | ||
| 75 | static int add_to_queue(AVFilterLink *inlink, AVFilterBufferRef *buf) | 75 | static int add_to_queue(AVFilterLink *inlink, AVFilterBufferRef *buf) |
| 76 | { | 76 | { |
| 77 | FifoContext *fifo = inlink->dst->priv; | 77 | FifoContext *fifo = inlink->dst->priv; |
| 78 | 78 | ||
| 79 | inlink->cur_buf = NULL; | ||
| 79 | fifo->last->next = av_mallocz(sizeof(Buf)); | 80 | fifo->last->next = av_mallocz(sizeof(Buf)); |
| 80 | if (!fifo->last->next) { | 81 | if (!fifo->last->next) { |
| 81 | avfilter_unref_buffer(buf); | 82 | avfilter_unref_buffer(buf); |
| @@ -88,12 +89,6 @@ static int add_to_queue(AVFilterLink *inlink, AVFilterBufferRef *buf) · 6 unmodified lines | |||
| 88 | return 0; | 89 | return 0; |
| 89 | } | 90 | } |
| 90 | 91 | ||
| 91 | static void start_frame(AVFilterLink *inlink, AVFilterBufferRef *buf) | ||
| 92 | { | ||
| 93 | add_to_queue(inlink, buf); | ||
| 94 | inlink->cur_buf = NULL; | ||
| 95 | } | ||
| 96 | |||
| 97 | static void queue_pop(FifoContext *s) | 92 | static void queue_pop(FifoContext *s) |
| 98 | { | 93 | { |
| 99 | Buf *tmp = s->root.next->next; | 94 | Buf *tmp = s->root.next->next; |
| @@ -103,9 +98,15 @@ static void queue_pop(FifoContext *s) · 3 unmodified lines | |||
| 103 | s->root.next = tmp; | 98 | s->root.next = tmp; |
| 104 | } | 99 | } |
| 105 | 100 | ||
| 106 | static void end_frame(AVFilterLink *inlink) { } | 101 | static int end_frame(AVFilterLink *inlink) |
| 102 | { | ||
| 103 | return 0; | ||
| 104 | } | ||
| 107 | 105 | ||
| 108 | static void draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir) { } | 106 | static int draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir) |
| 107 | { | ||
| 108 | return 0; | ||
| 109 | } | ||
| 109 | 110 | ||
| 110 | /** | 111 | /** |
| 111 | * Move data pointers and pts offset samples forward. | 112 | * Move data pointers and pts offset samples forward. |
| @@ -168,6 +169,9 @@ static int return_audio_frame(AVFilterContext *ctx) · 56 unmodified lines | |||
| 168 | queue_pop(s); | 169 | queue_pop(s); |
| 169 | } else { | 170 | } else { |
| 170 | buf_out = avfilter_ref_buffer(head, AV_PERM_READ); | 171 | buf_out = avfilter_ref_buffer(head, AV_PERM_READ); |
| 172 | if (!buf_out) | ||
| 173 | return AVERROR(ENOMEM); | ||
| 174 | |||
| 171 | buf_out->audio->nb_samples = link->request_samples; | 175 | buf_out->audio->nb_samples = link->request_samples; |
| 172 | buffer_offset(link, head, link->request_samples); | 176 | buffer_offset(link, head, link->request_samples); |
| 173 | } | 177 | } |
| @@ -240,9 +244,11 @@ static int request_frame(AVFilterLink *outlink) · 66 unmodified lines | |||
| 240 | * so we don't have to worry about dereferencing it ourselves. */ | 244 | * so we don't have to worry about dereferencing it ourselves. */ |
| 241 | switch (outlink->type) { | 245 | switch (outlink->type) { |
| 242 | case AVMEDIA_TYPE_VIDEO: | 246 | case AVMEDIA_TYPE_VIDEO: |
| 243 | ff_start_frame(outlink, fifo->root.next->buf); | 247 | if ((ret = ff_start_frame(outlink, fifo->root.next->buf)) < 0 || |
| 244 | ff_draw_slice (outlink, 0, outlink->h, 1); | 248 | (ret = ff_draw_slice(outlink, 0, outlink->h, 1)) < 0 || |
| 245 | ff_end_frame (outlink); | 249 | (ret = ff_end_frame(outlink)) < 0) |
| 250 | return ret; | ||
| 251 | |||
| 246 | queue_pop(fifo); | 252 | queue_pop(fifo); |
| 247 | break; | 253 | break; |
| 248 | case AVMEDIA_TYPE_AUDIO: | 254 | case AVMEDIA_TYPE_AUDIO: |
| @@ -272,7 +278,7 @@ AVFilter avfilter_vf_fifo = { · 23 unmodified lines | |||
| 272 | .inputs = (const AVFilterPad[]) {{ .name = "default", | 278 | .inputs = (const AVFilterPad[]) {{ .name = "default", |
| 273 | .type = AVMEDIA_TYPE_VIDEO, | 279 | .type = AVMEDIA_TYPE_VIDEO, |
| 274 | .get_video_buffer= ff_null_get_video_buffer, | 280 | .get_video_buffer= ff_null_get_video_buffer, |
| 275 | .start_frame = start_frame, | 281 | .start_frame = add_to_queue, |
| 276 | .draw_slice = draw_slice, | 282 | .draw_slice = draw_slice, |
| 277 | .end_frame = end_frame, | 283 | .end_frame = end_frame, |
| 278 | .rej_perms = AV_PERM_REUSE2, }, | 284 | .rej_perms = AV_PERM_REUSE2, }, |
| @@ -93,6 +93,9 @@ struct AVFilterPad { · 92 unmodified lines | |||
| 93 | * picture inside the link structure. | 93 | * picture inside the link structure. |
| 94 | * | 94 | * |
| 95 | * Input video pads only. | 95 | * Input video pads only. |
| 96 | * | ||
| 97 | * @return >= 0 on success, a negative AVERROR on error. picref will be | ||
| 98 | * unreferenced by the caller in case of error. | ||
| 96 | */ | 99 | */ |
| 97 | void (*start_frame)(AVFilterLink *link, AVFilterBufferRef *picref); | 100 | void (*start_frame)(AVFilterLink *link, AVFilterBufferRef *picref); |
| 98 | 101 | ||
| @@ -119,16 +122,20 @@ struct AVFilterPad { · 20 unmodified lines | |||
| 119 | * in the link structure during start_frame(). | 122 | * in the link structure during start_frame(). |
| 120 | * | 123 | * |
| 121 | * Input video pads only. | 124 | * Input video pads only. |
| 125 | * | ||
| 126 | * @return >= 0 on success, a negative AVERROR on error. | ||
| 122 | */ | 127 | */ |
| 123 | void (*end_frame)(AVFilterLink *link); | 128 | int (*end_frame)(AVFilterLink *link); |
| 124 | 129 | ||
| 125 | /** | 130 | /** |
| 126 | * Slice drawing callback. This is where a filter receives video data | 131 | * Slice drawing callback. This is where a filter receives video data |
| 127 | * and should do its processing. | 132 | * and should do its processing. |
| 128 | * | 133 | * |
| 129 | * Input video pads only. | 134 | * Input video pads only. |
| 135 | * | ||
| 136 | * @return >= 0 on success, a negative AVERROR on error. | ||
| 130 | */ | 137 | */ |
| 131 | void (*draw_slice)(AVFilterLink *link, int y, int height, int slice_dir); | 138 | int (*draw_slice)(AVFilterLink *link, int y, int height, int slice_dir); |
| 132 | 139 | ||
| 133 | /** | 140 | /** |
| 134 | * Samples filtering callback. This is where a filter receives audio data | 141 | * Samples filtering callback. This is where a filter receives audio data |
| @@ -96,7 +96,7 @@ static av_cold void common_uninit(AVFilterContext *ctx) · 95 unmodified lines | |||
| 96 | } | 96 | } |
| 97 | } | 97 | } |
| 98 | 98 | ||
| 99 | static void end_frame(AVFilterLink *inlink) | 99 | static int end_frame(AVFilterLink *inlink) |
| 100 | { | 100 | { |
| 101 | AVFilterContext *ctx = inlink->dst; | 101 | AVFilterContext *ctx = inlink->dst; |
| 102 | BufferSinkContext *buf = inlink->dst->priv; | 102 | BufferSinkContext *buf = inlink->dst->priv; |
| @@ -108,7 +108,7 @@ static void end_frame(AVFilterLink *inlink) · 5 unmodified lines | |||
| 108 | av_log(ctx, AV_LOG_ERROR, | 108 | av_log(ctx, AV_LOG_ERROR, |
| 109 | "Cannot buffer more frames. Consume some available frames " | 109 | "Cannot buffer more frames. Consume some available frames " |
| 110 | "before adding new ones.\n"); | 110 | "before adding new ones.\n"); |
| 111 | return; | 111 | return AVERROR(ENOMEM); |
| 112 | } | 112 | } |
| 113 | } | 113 | } |
| 114 | 114 | ||
| @@ -124,6 +124,7 @@ static void end_frame(AVFilterLink *inlink) · 9 unmodified lines | |||
| 124 | (char *)av_x_if_null(ctx->name, ctx->filter->name)); | 124 | (char *)av_x_if_null(ctx->name, ctx->filter->name)); |
| 125 | buf->warning_limit *= 10; | 125 | buf->warning_limit *= 10; |
| 126 | } | 126 | } |
| 127 | return 0; | ||
| 127 | } | 128 | } |
| 128 | 129 | ||
| 129 | void av_buffersink_set_frame_size(AVFilterContext *ctx, unsigned frame_size) | 130 | void av_buffersink_set_frame_size(AVFilterContext *ctx, unsigned frame_size) |
| @@ -63,32 +63,47 @@ static void split_uninit(AVFilterContext *ctx) · 62 unmodified lines | |||
| 63 | av_freep(&ctx->output_pads[i].name); | 63 | av_freep(&ctx->output_pads[i].name); |
| 64 | } | 64 | } |
| 65 | 65 | ||
| 66 | static void start_frame(AVFilterLink *inlink, AVFilterBufferRef *picref) | 66 | static int start_frame(AVFilterLink *inlink, AVFilterBufferRef *picref) |
| 67 | { | 67 | { |
| 68 | AVFilterContext *ctx = inlink->dst; | 68 | AVFilterContext *ctx = inlink->dst; |
| 69 | int i; | 69 | int i, ret = 0; |
| 70 | 70 | ||
| 71 | for (i = 0; i < ctx->nb_outputs; i++) | 71 | for (i = 0; i < ctx->nb_outputs; i++) { |
| 72 | ff_start_frame(ctx->outputs[i], | 72 | AVFilterBufferRef *buf_out = avfilter_ref_buffer(picref, ~AV_PERM_WRITE); |
| 73 | avfilter_ref_buffer(picref, ~AV_PERM_WRITE)); | 73 | if (!buf_out) |
| 74 | return AVERROR(ENOMEM); | ||
| 75 | |||
| 76 | ret = ff_start_frame(ctx->outputs[i], buf_out); | ||
| 77 | if (ret < 0) | ||
| 78 | break; | ||
| 79 | } | ||
| 80 | return ret; | ||
| 74 | } | 81 | } |
| 75 | 82 | ||
| 76 | static void draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir) | 83 | static int draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir) |
| 77 | { | 84 | { |
| 78 | AVFilterContext *ctx = inlink->dst; | 85 | AVFilterContext *ctx = inlink->dst; |
| 79 | int i; | 86 | int i, ret = 0; |
| 80 | 87 | ||
| 81 | for (i = 0; i < ctx->nb_outputs; i++) | 88 | for (i = 0; i < ctx->nb_outputs; i++) { |
| 82 | ff_draw_slice(ctx->outputs[i], y, h, slice_dir); | 89 | ret = ff_draw_slice(ctx->outputs[i], y, h, slice_dir); |
| 90 | if (ret < 0) | ||
| 91 | break; | ||
| 92 | } | ||
| 93 | return ret; | ||
| 83 | } | 94 | } |
| 84 | 95 | ||
| 85 | static void end_frame(AVFilterLink *inlink) | 96 | static int end_frame(AVFilterLink *inlink) |
| 86 | { | 97 | { |
| 87 | AVFilterContext *ctx = inlink->dst; | 98 | AVFilterContext *ctx = inlink->dst; |
| 88 | int i; | 99 | int i, ret = 0; |
| 89 | 100 | ||
| 90 | for (i = 0; i < ctx->nb_outputs; i++) | 101 | for (i = 0; i < ctx->nb_outputs; i++) { |
| 91 | ff_end_frame(ctx->outputs[i]); | 102 | ret = ff_end_frame(ctx->outputs[i]); |
| 103 | if (ret < 0) | ||
| 104 | break; | ||
| 105 | } | ||
| 106 | return ret; | ||
| 92 | } | 107 | } |
| 93 | 108 | ||
| 94 | AVFilter avfilter_vf_split = { | 109 | AVFilter avfilter_vf_split = { |
| @@ -114,8 +129,14 @@ static int filter_samples(AVFilterLink *inlink, AVFilterBufferRef *samplesref) · 19 unmodified lines | |||
| 114 | int i, ret = 0; | 129 | int i, ret = 0; |
| 115 | 130 | ||
| 116 | for (i = 0; i < ctx->nb_outputs; i++) { | 131 | for (i = 0; i < ctx->nb_outputs; i++) { |
| 117 | ret = ff_filter_samples(inlink->dst->outputs[i], | 132 | AVFilterBufferRef *buf_out = avfilter_ref_buffer(samplesref, |
| 118 | avfilter_ref_buffer(samplesref, ~AV_PERM_WRITE)); | 133 | ~AV_PERM_WRITE); |
| 134 | if (!buf_out) { | ||
| 135 | ret = AVERROR(ENOMEM); | ||
| 136 | break; | ||
| 137 | } | ||
| 138 | |||
| 139 | ret = ff_filter_samples(inlink->dst->outputs[i], buf_out); | ||
| 119 | if (ret < 0) | 140 | if (ret < 0) |
| 120 | break; | 141 | break; |
| 121 | } | 142 | } |
| @@ -326,13 +326,24 @@ static int movie_request_frame(AVFilterLink *outlink) · 325 unmodified lines | |||
| 326 | return ret; | 326 | return ret; |
| 327 | 327 | ||
| 328 | outpicref = avfilter_ref_buffer(movie->picref, ~0); | 328 | outpicref = avfilter_ref_buffer(movie->picref, ~0); |
| 329 | ff_start_frame(outlink, outpicref); | 329 | if (!outpicref) { |
| 330 | ff_draw_slice(outlink, 0, outlink->h, 1); | 330 | ret = AVERROR(ENOMEM); |
| 331 | ff_end_frame(outlink); | 331 | goto fail; |
| 332 | avfilter_unref_buffer(movie->picref); | 332 | } |
| 333 | movie->picref = NULL; | ||
| 334 | 333 | ||
| 335 | return 0; | 334 | ret = ff_start_frame(outlink, outpicref); |
| 335 | if (ret < 0) | ||
| 336 | goto fail; | ||
| 337 | |||
| 338 | ret = ff_draw_slice(outlink, 0, outlink->h, 1); | ||
| 339 | if (ret < 0) | ||
| 340 | goto fail; | ||
| 341 | |||
| 342 | ret = ff_end_frame(outlink); | ||
| 343 | fail: | ||
| 344 | avfilter_unref_bufferp(&movie->picref); | ||
| 345 | |||
| 346 | return ret; | ||
| 336 | } | 347 | } |
| 337 | 348 | ||
| 338 | AVFilter avfilter_vsrc_movie = { | 349 | AVFilter avfilter_vsrc_movie = { |
| @@ -59,7 +59,7 @@ static int config_input(AVFilterLink *inlink) · 58 unmodified lines | |||
| 59 | return 0; | 59 | return 0; |
| 60 | } | 60 | } |
| 61 | 61 | ||
| 62 | static void draw_slice(AVFilterLink *inlink, int y0, int h, int slice_dir) | 62 | static int draw_slice(AVFilterLink *inlink, int y0, int h, int slice_dir) |
| 63 | { | 63 | { |
| 64 | AlphaExtractContext *extract = inlink->dst->priv; | 64 | AlphaExtractContext *extract = inlink->dst->priv; |
| 65 | AVFilterBufferRef *cur_buf = inlink->cur_buf; | 65 | AVFilterBufferRef *cur_buf = inlink->cur_buf; |
| @@ -91,7 +91,7 @@ static void draw_slice(AVFilterLink *inlink, int y0, int h, int slice_dir) · 25 unmodified lines | |||
| 91 | linesize); | 91 | linesize); |
| 92 | } | 92 | } |
| 93 | } | 93 | } |
| 94 | ff_draw_slice(inlink->dst->outputs[0], y0, h, slice_dir); | 94 | return ff_draw_slice(inlink->dst->outputs[0], y0, h, slice_dir); |
| 95 | } | 95 | } |
| 96 | 96 | ||
| 97 | AVFilter avfilter_vf_alphaextract = { | 97 | AVFilter avfilter_vf_alphaextract = { |
| @@ -95,8 +95,8 @@ static int config_output(AVFilterLink *outlink) · 94 unmodified lines | |||
| 95 | return 0; | 95 | return 0; |
| 96 | } | 96 | } |
| 97 | 97 | ||
| 98 | static void start_frame(AVFilterLink *inlink, AVFilterBufferRef *picref) {} | 98 | static int start_frame(AVFilterLink *inlink, AVFilterBufferRef *picref) {return 0;} |
| 99 | static void draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir) {} | 99 | static int draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir) {return 0;} |
| 100 | 100 | ||
| 101 | static void draw_frame(AVFilterContext *ctx, | 101 | static void draw_frame(AVFilterContext *ctx, |
| 102 | AVFilterBufferRef *main_buf, | 102 | AVFilterBufferRef *main_buf, |
| @@ -130,7 +130,7 @@ static void draw_frame(AVFilterContext *ctx, · 27 unmodified lines | |||
| 130 | ff_draw_slice(ctx->outputs[0], 0, h, 1); | 130 | ff_draw_slice(ctx->outputs[0], 0, h, 1); |
| 131 | } | 131 | } |
| 132 | 132 | ||
| 133 | static void end_frame(AVFilterLink *inlink) | 133 | static int end_frame(AVFilterLink *inlink) |
| 134 | { | 134 | { |
| 135 | AVFilterContext *ctx = inlink->dst; | 135 | AVFilterContext *ctx = inlink->dst; |
| 136 | AlphaMergeContext *merge = ctx->priv; | 136 | AlphaMergeContext *merge = ctx->priv; |
| @@ -157,6 +157,7 @@ static void end_frame(AVFilterLink *inlink) · 20 unmodified lines | |||
| 157 | ff_end_frame(ctx->outputs[0]); | 157 | ff_end_frame(ctx->outputs[0]); |
| 158 | avfilter_unref_buffer(alpha_buf); | 158 | avfilter_unref_buffer(alpha_buf); |
| 159 | } | 159 | } |
| 160 | return 0; | ||
| 160 | } | 161 | } |
| 161 | 162 | ||
| 162 | static int request_frame(AVFilterLink *outlink) | 163 | static int request_frame(AVFilterLink *outlink) |
| @@ -51,13 +51,13 @@ static av_cold int init(AVFilterContext *ctx, const char *args) · 50 unmodified lines | |||
| 51 | return 0; | 51 | return 0; |
| 52 | } | 52 | } |
| 53 | 53 | ||
| 54 | static void start_frame(AVFilterLink *link, AVFilterBufferRef *picref) | 54 | static int start_frame(AVFilterLink *link, AVFilterBufferRef *picref) |
| 55 | { | 55 | { |
| 56 | AspectContext *aspect = link->dst->priv; | 56 | AspectContext *aspect = link->dst->priv; |
| 57 | 57 | ||
| 58 | picref->video->sample_aspect_ratio = aspect->ratio; | 58 | picref->video->sample_aspect_ratio = aspect->ratio; |
| 59 | link->cur_buf = NULL; | 59 | link->cur_buf = NULL; |
| 60 | ff_start_frame(link->dst->outputs[0], picref); | 60 | return ff_start_frame(link->dst->outputs[0], picref); |
| 61 | } | 61 | } |
| 62 | 62 | ||
| 63 | #if CONFIG_SETDAR_FILTER | 63 | #if CONFIG_SETDAR_FILTER |
| @@ -157,7 +157,7 @@ static int config_input(AVFilterLink *inlink) · 156 unmodified lines | |||
| 157 | return 0; | 157 | return 0; |
| 158 | } | 158 | } |
| 159 | 159 | ||
| 160 | static void null_draw_slice(AVFilterLink *link, int y, int h, int slice_dir) { } | 160 | static int null_draw_slice(AVFilterLink *link, int y, int h, int slice_dir) { return 0; } |
| 161 | 161 | ||
| 162 | /* libass stores an RGBA color in the format RRGGBBTT, where TT is the transparency level */ | 162 | /* libass stores an RGBA color in the format RRGGBBTT, where TT is the transparency level */ |
| 163 | #define AR(c) ( (c)>>24) | 163 | #define AR(c) ( (c)>>24) |
| @@ -180,7 +180,7 @@ static void overlay_ass_image(AssContext *ass, AVFilterBufferRef *picref, · 16 unmodified lines | |||
| 180 | } | 180 | } |
| 181 | } | 181 | } |
| 182 | 182 | ||
| 183 | static void end_frame(AVFilterLink *inlink) | 183 | static int end_frame(AVFilterLink *inlink) |
| 184 | { | 184 | { |
| 185 | AVFilterContext *ctx = inlink->dst; | 185 | AVFilterContext *ctx = inlink->dst; |
| 186 | AVFilterLink *outlink = ctx->outputs[0]; | 186 | AVFilterLink *outlink = ctx->outputs[0]; |
| @@ -197,7 +197,7 @@ static void end_frame(AVFilterLink *inlink) · 10 unmodified lines | |||
| 197 | overlay_ass_image(ass, picref, image); | 197 | overlay_ass_image(ass, picref, image); |
| 198 | 198 | ||
| 199 | ff_draw_slice(outlink, 0, picref->video->h, 1); | 199 | ff_draw_slice(outlink, 0, picref->video->h, 1); |
| 200 | ff_end_frame(outlink); | 200 | return ff_end_frame(outlink); |
| 201 | } | 201 | } |
| 202 | 202 | ||
| 203 | AVFilter avfilter_vf_ass = { | 203 | AVFilter avfilter_vf_ass = { |
| @@ -56,7 +56,7 @@ static int query_formats(AVFilterContext *ctx) · 55 unmodified lines | |||
| 56 | return 0; | 56 | return 0; |
| 57 | } | 57 | } |
| 58 | 58 | ||
| 59 | static void end_frame(AVFilterLink *inlink) | 59 | static int end_frame(AVFilterLink *inlink) |
| 60 | { | 60 | { |
| 61 | AVFilterContext *ctx = inlink->dst; | 61 | AVFilterContext *ctx = inlink->dst; |
| 62 | BBoxContext *bbox = ctx->priv; | 62 | BBoxContext *bbox = ctx->priv; |
| @@ -86,7 +86,7 @@ static void end_frame(AVFilterLink *inlink) · 23 unmodified lines | |||
| 86 | av_log(ctx, AV_LOG_INFO, "\n"); | 86 | av_log(ctx, AV_LOG_INFO, "\n"); |
| 87 | 87 | ||
| 88 | bbox->frame++; | 88 | bbox->frame++; |
| 89 | ff_end_frame(inlink->dst->outputs[0]); | 89 | return ff_end_frame(inlink->dst->outputs[0]); |
| 90 | } | 90 | } |
| 91 | 91 | ||
| 92 | AVFilter avfilter_vf_bbox = { | 92 | AVFilter avfilter_vf_bbox = { |
| @@ -146,7 +146,7 @@ static int request_frame(AVFilterLink *outlink) · 145 unmodified lines | |||
| 146 | return ret; | 146 | return ret; |
| 147 | } | 147 | } |
| 148 | 148 | ||
| 149 | static void draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir) | 149 | static int draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir) |
| 150 | { | 150 | { |
| 151 | AVFilterContext *ctx = inlink->dst; | 151 | AVFilterContext *ctx = inlink->dst; |
| 152 | BlackDetectContext *blackdetect = ctx->priv; | 152 | BlackDetectContext *blackdetect = ctx->priv; |
| @@ -160,10 +160,10 @@ static void draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir) · 7 unmodified lines | |||
| 160 | p += picref->linesize[0]; | 160 | p += picref->linesize[0]; |
| 161 | } | 161 | } |
| 162 | 162 | ||
| 163 | ff_draw_slice(ctx->outputs[0], y, h, slice_dir); | 163 | return ff_draw_slice(ctx->outputs[0], y, h, slice_dir); |
| 164 | } | 164 | } |
| 165 | 165 | ||
| 166 | static void end_frame(AVFilterLink *inlink) | 166 | static int end_frame(AVFilterLink *inlink) |
| 167 | { | 167 | { |
| 168 | AVFilterContext *ctx = inlink->dst; | 168 | AVFilterContext *ctx = inlink->dst; |
| 169 | BlackDetectContext *blackdetect = ctx->priv; | 169 | BlackDetectContext *blackdetect = ctx->priv; |
| @@ -194,7 +194,7 @@ static void end_frame(AVFilterLink *inlink) · 24 unmodified lines | |||
| 194 | blackdetect->last_picref_pts = picref->pts; | 194 | blackdetect->last_picref_pts = picref->pts; |
| 195 | blackdetect->frame_count++; | 195 | blackdetect->frame_count++; |
| 196 | blackdetect->nb_black_pixels = 0; | 196 | blackdetect->nb_black_pixels = 0; |
| 197 | ff_end_frame(inlink->dst->outputs[0]); | 197 | return ff_end_frame(inlink->dst->outputs[0]); |
| 198 | } | 198 | } |
| 199 | 199 | ||
| 200 | AVFilter avfilter_vf_blackdetect = { | 200 | AVFilter avfilter_vf_blackdetect = { |
| @@ -77,7 +77,7 @@ static av_cold int init(AVFilterContext *ctx, const char *args) · 76 unmodified lines | |||
| 77 | return 0; | 77 | return 0; |
| 78 | } | 78 | } |
| 79 | 79 | ||
| 80 | static void draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir) | 80 | static int draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir) |
| 81 | { | 81 | { |
| 82 | AVFilterContext *ctx = inlink->dst; | 82 | AVFilterContext *ctx = inlink->dst; |
| 83 | BlackFrameContext *blackframe = ctx->priv; | 83 | BlackFrameContext *blackframe = ctx->priv; |
| @@ -91,10 +91,10 @@ static void draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir) · 7 unmodified lines | |||
| 91 | p += picref->linesize[0]; | 91 | p += picref->linesize[0]; |
| 92 | } | 92 | } |
| 93 | 93 | ||
| 94 | ff_draw_slice(ctx->outputs[0], y, h, slice_dir); | 94 | return ff_draw_slice(ctx->outputs[0], y, h, slice_dir); |
| 95 | } | 95 | } |
| 96 | 96 | ||
| 97 | static void end_frame(AVFilterLink *inlink) | 97 | static int end_frame(AVFilterLink *inlink) |
| 98 | { | 98 | { |
| 99 | AVFilterContext *ctx = inlink->dst; | 99 | AVFilterContext *ctx = inlink->dst; |
| 100 | BlackFrameContext *blackframe = ctx->priv; | 100 | BlackFrameContext *blackframe = ctx->priv; |
| @@ -114,7 +114,7 @@ static void end_frame(AVFilterLink *inlink) · 13 unmodified lines | |||
| 114 | 114 | ||
| 115 | blackframe->frame++; | 115 | blackframe->frame++; |
| 116 | blackframe->nblack = 0; | 116 | blackframe->nblack = 0; |
| 117 | ff_end_frame(inlink->dst->outputs[0]); | 117 | return ff_end_frame(inlink->dst->outputs[0]); |
| 118 | } | 118 | } |
| 119 | 119 | ||
| 120 | AVFilter avfilter_vf_blackframe = { | 120 | AVFilter avfilter_vf_blackframe = { |
| @@ -301,9 +301,9 @@ static void vblur(uint8_t *dst, int dst_linesize, const uint8_t *src, int src_li · 300 unmodified lines | |||
| 301 | h, radius, power, temp); | 301 | h, radius, power, temp); |
| 302 | } | 302 | } |
| 303 | 303 | ||
| 304 | static void null_draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir) { } | 304 | static int null_draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir) { return 0; } |
| 305 | 305 | ||
| 306 | static void end_frame(AVFilterLink *inlink) | 306 | static int end_frame(AVFilterLink *inlink) |
| 307 | { | 307 | { |
| 308 | AVFilterContext *ctx = inlink->dst; | 308 | AVFilterContext *ctx = inlink->dst; |
| 309 | BoxBlurContext *boxblur = ctx->priv; | 309 | BoxBlurContext *boxblur = ctx->priv; |
| @@ -328,7 +328,7 @@ static void end_frame(AVFilterLink *inlink) · 18 unmodified lines | |||
| 328 | boxblur->temp); | 328 | boxblur->temp); |
| 329 | 329 | ||
| 330 | ff_draw_slice(outlink, 0, inlink->h, 1); | 330 | ff_draw_slice(outlink, 0, inlink->h, 1); |
| 331 | avfilter_default_end_frame(inlink); | 331 | return avfilter_default_end_frame(inlink); |
| 332 | } | 332 | } |
| 333 | 333 | ||
| 334 | AVFilter avfilter_vf_boxblur = { | 334 | AVFilter avfilter_vf_boxblur = { |
| @@ -340,7 +340,7 @@ static AVFilterBufferRef *get_video_buffer(AVFilterLink *inlink, int perms, int · 339 unmodified lines | |||
| 340 | return picref; | 340 | return picref; |
| 341 | } | 341 | } |
| 342 | 342 | ||
| 343 | static void start_frame(AVFilterLink *link, AVFilterBufferRef *picref) | 343 | static int start_frame(AVFilterLink *link, AVFilterBufferRef *picref) |
| 344 | { | 344 | { |
| 345 | AVFilterContext *ctx = link->dst; | 345 | AVFilterContext *ctx = link->dst; |
| 346 | ColorMatrixContext *color = ctx->priv; | 346 | ColorMatrixContext *color = ctx->priv; |
| @@ -348,10 +348,10 @@ static void start_frame(AVFilterLink *link, AVFilterBufferRef *picref) · 1 unmodified line | |||
| 348 | 348 | ||
| 349 | color->outpicref = outpicref; | 349 | color->outpicref = outpicref; |
| 350 | 350 | ||
| 351 | ff_start_frame(link->dst->outputs[0], outpicref); | 351 | return ff_start_frame(link->dst->outputs[0], outpicref); |
| 352 | } | 352 | } |
| 353 | 353 | ||
| 354 | static void end_frame(AVFilterLink *link) | 354 | static int end_frame(AVFilterLink *link) |
| 355 | { | 355 | { |
| 356 | AVFilterContext *ctx = link->dst; | 356 | AVFilterContext *ctx = link->dst; |
| 357 | ColorMatrixContext *color = ctx->priv; | 357 | ColorMatrixContext *color = ctx->priv; |
| @@ -365,10 +365,10 @@ static void end_frame(AVFilterLink *link) · 7 unmodified lines | |||
| 365 | process_frame_uyvy422(color, out, link->cur_buf); | 365 | process_frame_uyvy422(color, out, link->cur_buf); |
| 366 | 366 | ||
| 367 | ff_draw_slice(ctx->outputs[0], 0, link->dst->outputs[0]->h, 1); | 367 | ff_draw_slice(ctx->outputs[0], 0, link->dst->outputs[0]->h, 1); |
| 368 | ff_end_frame(ctx->outputs[0]); | 368 | return ff_end_frame(ctx->outputs[0]); |
| 369 | } | 369 | } |
| 370 | 370 | ||
| 371 | static void null_draw_slice(AVFilterLink *link, int y, int h, int slice_dir) { } | 371 | static int null_draw_slice(AVFilterLink *link, int y, int h, int slice_dir) { return 0; } |
| 372 | 372 | ||
| 373 | AVFilter avfilter_vf_colormatrix = { | 373 | AVFilter avfilter_vf_colormatrix = { |
| 374 | .name = "colormatrix", | 374 | .name = "colormatrix", |
| @@ -259,7 +259,7 @@ static int config_output(AVFilterLink *link) · 258 unmodified lines | |||
| 259 | return 0; | 259 | return 0; |
| 260 | } | 260 | } |
| 261 | 261 | ||
| 262 | static void start_frame(AVFilterLink *link, AVFilterBufferRef *picref) | 262 | static int start_frame(AVFilterLink *link, AVFilterBufferRef *picref) |
| 263 | { | 263 | { |
| 264 | AVFilterContext *ctx = link->dst; | 264 | AVFilterContext *ctx = link->dst; |
| 265 | CropContext *crop = ctx->priv; | 265 | CropContext *crop = ctx->priv; |
| @@ -267,6 +267,9 @@ static void start_frame(AVFilterLink *link, AVFilterBufferRef *picref) · 1 unmodified line | |||
| 267 | int i; | 267 | int i; |
| 268 | 268 | ||
| 269 | ref2 = avfilter_ref_buffer(picref, ~0); | 269 | ref2 = avfilter_ref_buffer(picref, ~0); |
| 270 | if (!ref2) | ||
| 271 | return AVERROR(ENOMEM); | ||
| 272 | |||
| 270 | ref2->video->w = crop->w; | 273 | ref2->video->w = crop->w; |
| 271 | ref2->video->h = crop->h; | 274 | ref2->video->h = crop->h; |
| 272 | 275 | ||
| @@ -310,16 +313,16 @@ static void start_frame(AVFilterLink *link, AVFilterBufferRef *picref) · 37 unmodified lines | |||
| 310 | ref2->data[3] += crop->x * crop->max_step[3]; | 313 | ref2->data[3] += crop->x * crop->max_step[3]; |
| 311 | } | 314 | } |
| 312 | 315 | ||
| 313 | ff_start_frame(link->dst->outputs[0], ref2); | 316 | return ff_start_frame(link->dst->outputs[0], ref2); |
| 314 | } | 317 | } |
| 315 | 318 | ||
| 316 | static void draw_slice(AVFilterLink *link, int y, int h, int slice_dir) | 319 | static int draw_slice(AVFilterLink *link, int y, int h, int slice_dir) |
| 317 | { | 320 | { |
| 318 | AVFilterContext *ctx = link->dst; | 321 | AVFilterContext *ctx = link->dst; |
| 319 | CropContext *crop = ctx->priv; | 322 | CropContext *crop = ctx->priv; |
| 320 | 323 | ||
| 321 | if (y >= crop->y + crop->h || y + h <= crop->y) | 324 | if (y >= crop->y + crop->h || y + h <= crop->y) |
| 322 | return; | 325 | return 0; |
| 323 | 326 | ||
| 324 | if (y < crop->y) { | 327 | if (y < crop->y) { |
| 325 | h -= crop->y - y; | 328 | h -= crop->y - y; |
| @@ -328,15 +331,15 @@ static void draw_slice(AVFilterLink *link, int y, int h, int slice_dir) · 2 unmodified lines | |||
| 328 | if (y + h > crop->y + crop->h) | 331 | if (y + h > crop->y + crop->h) |
| 329 | h = crop->y + crop->h - y; | 332 | h = crop->y + crop->h - y; |
| 330 | 333 | ||
| 331 | ff_draw_slice(ctx->outputs[0], y - crop->y, h, slice_dir); | 334 | return ff_draw_slice(ctx->outputs[0], y - crop->y, h, slice_dir); |
| 332 | } | 335 | } |
| 333 | 336 | ||
| 334 | static void end_frame(AVFilterLink *link) | 337 | static int end_frame(AVFilterLink *link) |
| 335 | { | 338 | { |
| 336 | CropContext *crop = link->dst->priv; | 339 | CropContext *crop = link->dst->priv; |
| 337 | 340 | ||
| 338 | crop->var_values[VAR_N] += 1.0; | 341 | crop->var_values[VAR_N] += 1.0; |
| 339 | ff_end_frame(link->dst->outputs[0]); | 342 | return ff_end_frame(link->dst->outputs[0]); |
| 340 | } | 343 | } |
| 341 | 344 | ||
| 342 | AVFilter avfilter_vf_crop = { | 345 | AVFilter avfilter_vf_crop = { |
| @@ -114,7 +114,7 @@ static int config_input(AVFilterLink *inlink) · 113 unmodified lines | |||
| 114 | return 0; | 114 | return 0; |
| 115 | } | 115 | } |
| 116 | 116 | ||
| 117 | static void end_frame(AVFilterLink *inlink) | 117 | static int end_frame(AVFilterLink *inlink) |
| 118 | { | 118 | { |
| 119 | AVFilterContext *ctx = inlink->dst; | 119 | AVFilterContext *ctx = inlink->dst; |
| 120 | CropDetectContext *cd = ctx->priv; | 120 | CropDetectContext *cd = ctx->priv; |
| @@ -191,7 +191,7 @@ static void end_frame(AVFilterLink *inlink) · 70 unmodified lines | |||
| 191 | w, h, x, y); | 191 | w, h, x, y); |
| 192 | } | 192 | } |
| 193 | 193 | ||
| 194 | ff_end_frame(inlink->dst->outputs[0]); | 194 | return ff_end_frame(inlink->dst->outputs[0]); |
| 195 | } | 195 | } |
| 196 | 196 | ||
| 197 | AVFilter avfilter_vf_cropdetect = { | 197 | AVFilter avfilter_vf_cropdetect = { |
| @@ -209,27 +209,48 @@ static av_cold int init(AVFilterContext *ctx, const char *args) · 208 unmodified lines | |||
| 209 | return 0; | 209 | return 0; |
| 210 | } | 210 | } |
| 211 | 211 | ||
| 212 | static void start_frame(AVFilterLink *inlink, AVFilterBufferRef *inpicref) | 212 | static int start_frame(AVFilterLink *inlink, AVFilterBufferRef *inpicref) |
| 213 | { | 213 | { |
| 214 | AVFilterLink *outlink = inlink->dst->outputs[0]; | 214 | AVFilterLink *outlink = inlink->dst->outputs[0]; |
| 215 | AVFilterBufferRef *outpicref; | 215 | AVFilterBufferRef *outpicref = NULL, *for_next_filter; |
| 216 | int ret = 0; | ||
| 216 | 217 | ||
| 217 | if (inpicref->perms & AV_PERM_PRESERVE) { | 218 | if (inpicref->perms & AV_PERM_PRESERVE) { |
| 218 | outpicref = ff_get_video_buffer(outlink, AV_PERM_WRITE, | 219 | outpicref = ff_get_video_buffer(outlink, AV_PERM_WRITE, |
| 219 | outlink->w, outlink->h); | 220 | outlink->w, outlink->h); |
| 221 | if (!outpicref) | ||
| 222 | return AVERROR(ENOMEM); | ||
| 223 | |||
| 220 | avfilter_copy_buffer_ref_props(outpicref, inpicref); | 224 | avfilter_copy_buffer_ref_props(outpicref, inpicref); |
| 221 | outpicref->video->w = outlink->w; | 225 | outpicref->video->w = outlink->w; |
| 222 | outpicref->video->h = outlink->h; | 226 | outpicref->video->h = outlink->h; |
| 223 | } else | 227 | } else { |
| 224 | outpicref = avfilter_ref_buffer(inpicref, ~0); | 228 | outpicref = avfilter_ref_buffer(inpicref, ~0); |
| 229 | if (!outpicref) | ||
| 230 | return AVERROR(ENOMEM); | ||
| 231 | } | ||
| 232 | |||
| 233 | for_next_filter = avfilter_ref_buffer(outpicref, ~0); | ||
| 234 | if (for_next_filter) | ||
| 235 | ret = ff_start_frame(outlink, for_next_filter); | ||
| 236 | else | ||
| 237 | ret = AVERROR(ENOMEM); | ||
| 238 | |||
| 239 | if (ret < 0) { | ||
| 240 | avfilter_unref_bufferp(&outpicref); | ||
| 241 | return ret; | ||
| 242 | } | ||
| 225 | 243 | ||
| 226 | outlink->out_buf = outpicref; | 244 | outlink->out_buf = outpicref; |
| 227 | ff_start_frame(outlink, avfilter_ref_buffer(outpicref, ~0)); | 245 | return 0; |
| 228 | } | 246 | } |
| 229 | 247 | ||
| 230 | static void null_draw_slice(AVFilterLink *link, int y, int h, int slice_dir) { } | 248 | static int null_draw_slice(AVFilterLink *link, int y, int h, int slice_dir) |
| 249 | { | ||
| 250 | return 0; | ||
| 251 | } | ||
| 231 | 252 | ||
| 232 | static void end_frame(AVFilterLink *inlink) | 253 | static int end_frame(AVFilterLink *inlink) |
| 233 | { | 254 | { |
| 234 | DelogoContext *delogo = inlink->dst->priv; | 255 | DelogoContext *delogo = inlink->dst->priv; |
| 235 | AVFilterLink *outlink = inlink->dst->outputs[0]; | 256 | AVFilterLink *outlink = inlink->dst->outputs[0]; |
| @@ -239,6 +260,7 @@ static void end_frame(AVFilterLink *inlink) · 3 unmodified lines | |||
| 239 | int hsub0 = av_pix_fmt_descriptors[inlink->format].log2_chroma_w; | 260 | int hsub0 = av_pix_fmt_descriptors[inlink->format].log2_chroma_w; |
| 240 | int vsub0 = av_pix_fmt_descriptors[inlink->format].log2_chroma_h; | 261 | int vsub0 = av_pix_fmt_descriptors[inlink->format].log2_chroma_h; |
| 241 | int plane; | 262 | int plane; |
| 263 | int ret; | ||
| 242 | 264 | ||
| 243 | for (plane = 0; plane < 4 && inpicref->data[plane]; plane++) { | 265 | for (plane = 0; plane < 4 && inpicref->data[plane]; plane++) { |
| 244 | int hsub = plane == 1 || plane == 2 ? hsub0 : 0; | 266 | int hsub = plane == 1 || plane == 2 ? hsub0 : 0; |
| @@ -253,8 +275,10 @@ static void end_frame(AVFilterLink *inlink) · 8 unmodified lines | |||
| 253 | delogo->show, direct); | 275 | delogo->show, direct); |
| 254 | } | 276 | } |
| 255 | 277 | ||
| 256 | ff_draw_slice(outlink, 0, inlink->h, 1); | 278 | if ((ret = ff_draw_slice(outlink, 0, inlink->h, 1)) < 0 || |
| 257 | ff_end_frame(outlink); | 279 | (ret = ff_end_frame(outlink)) < 0) |
| 280 | return ret; | ||
| 281 | return 0; | ||
| 258 | } | 282 | } |
| 259 | 283 | ||
| 260 | AVFilter avfilter_vf_delogo = { | 284 | AVFilter avfilter_vf_delogo = { |
| @@ -425,7 +425,7 @@ static av_cold void uninit(AVFilterContext *ctx) · 424 unmodified lines | |||
| 425 | av_freep(&deshake->avctx); | 425 | av_freep(&deshake->avctx); |
| 426 | } | 426 | } |
| 427 | 427 | ||
| 428 | static void end_frame(AVFilterLink *link) | 428 | static int end_frame(AVFilterLink *link) |
| 429 | { | 429 | { |
| 430 | DeshakeContext *deshake = link->dst->priv; | 430 | DeshakeContext *deshake = link->dst->priv; |
| 431 | AVFilterBufferRef *in = link->cur_buf; | 431 | AVFilterBufferRef *in = link->cur_buf; |
| @@ -529,11 +529,12 @@ static void end_frame(AVFilterLink *link) · 97 unmodified lines | |||
| 529 | 529 | ||
| 530 | // Draw the transformed frame information | 530 | // Draw the transformed frame information |
| 531 | ff_draw_slice(link->dst->outputs[0], 0, link->h, 1); | 531 | ff_draw_slice(link->dst->outputs[0], 0, link->h, 1); |
| 532 | ff_end_frame(link->dst->outputs[0]); | 532 | return ff_end_frame(link->dst->outputs[0]); |
| 533 | } | 533 | } |
| 534 | 534 | ||
| 535 | static void draw_slice(AVFilterLink *link, int y, int h, int slice_dir) | 535 | static int draw_slice(AVFilterLink *link, int y, int h, int slice_dir) |
| 536 | { | 536 | { |
| 537 | return 0; | ||
| 537 | } | 538 | } |
| 538 | 539 | ||
| 539 | AVFilter avfilter_vf_deshake = { | 540 | AVFilter avfilter_vf_deshake = { |
| @@ -94,7 +94,7 @@ static int config_input(AVFilterLink *inlink) · 93 unmodified lines | |||
| 94 | return 0; | 94 | return 0; |
| 95 | } | 95 | } |
| 96 | 96 | ||
| 97 | static void draw_slice(AVFilterLink *inlink, int y0, int h, int slice_dir) | 97 | static int draw_slice(AVFilterLink *inlink, int y0, int h, int slice_dir) |
| 98 | { | 98 | { |
| 99 | DrawBoxContext *drawbox = inlink->dst->priv; | 99 | DrawBoxContext *drawbox = inlink->dst->priv; |
| 100 | int plane, x, y, xb = drawbox->x, yb = drawbox->y; | 100 | int plane, x, y, xb = drawbox->x, yb = drawbox->y; |
| @@ -120,7 +120,7 @@ static void draw_slice(AVFilterLink *inlink, int y0, int h, int slice_dir) · 19 unmodified lines | |||
| 120 | } | 120 | } |
| 121 | } | 121 | } |
| 122 | 122 | ||
| 123 | ff_draw_slice(inlink->dst->outputs[0], y0, h, 1); | 123 | return ff_draw_slice(inlink->dst->outputs[0], y0, h, 1); |
| 124 | } | 124 | } |
| 125 | 125 | ||
| 126 | AVFilter avfilter_vf_drawbox = { | 126 | AVFilter avfilter_vf_drawbox = { |
| @@ -780,14 +780,18 @@ static int draw_text(AVFilterContext *ctx, AVFilterBufferRef *picref, · 779 unmodified lines | |||
| 780 | return 0; | 780 | return 0; |
| 781 | } | 781 | } |
| 782 | 782 | ||
| 783 | static void null_draw_slice(AVFilterLink *link, int y, int h, int slice_dir) { } | 783 | static int null_draw_slice(AVFilterLink *link, int y, int h, int slice_dir) |
| 784 | { | ||
| 785 | return 0; | ||
| 786 | } | ||
| 784 | 787 | ||
| 785 | static void end_frame(AVFilterLink *inlink) | 788 | static int end_frame(AVFilterLink *inlink) |
| 786 | { | 789 | { |
| 787 | AVFilterContext *ctx = inlink->dst; | 790 | AVFilterContext *ctx = inlink->dst; |
| 788 | AVFilterLink *outlink = ctx->outputs[0]; | 791 | AVFilterLink *outlink = ctx->outputs[0]; |
| 789 | DrawTextContext *dtext = ctx->priv; | 792 | DrawTextContext *dtext = ctx->priv; |
| 790 | AVFilterBufferRef *picref = inlink->cur_buf; | 793 | AVFilterBufferRef *picref = inlink->cur_buf; |
| 794 | int ret; | ||
| 791 | 795 | ||
| 792 | dtext->var_values[VAR_T] = picref->pts == AV_NOPTS_VALUE ? | 796 | dtext->var_values[VAR_T] = picref->pts == AV_NOPTS_VALUE ? |
| 793 | NAN : picref->pts * av_q2d(inlink->time_base); | 797 | NAN : picref->pts * av_q2d(inlink->time_base); |
| @@ -801,8 +805,10 @@ static void end_frame(AVFilterLink *inlink) · 7 unmodified lines | |||
| 801 | 805 | ||
| 802 | dtext->var_values[VAR_N] += 1.0; | 806 | dtext->var_values[VAR_N] += 1.0; |
| 803 | 807 | ||
| 804 | ff_draw_slice(outlink, 0, picref->video->h, 1); | 808 | if ((ret = ff_draw_slice(outlink, 0, picref->video->h, 1)) < 0 || |
| 805 | ff_end_frame(outlink); | 809 | (ret = ff_end_frame(outlink)) < 0) |
| 810 | return ret; | ||
| 811 | return 0; | ||
| 806 | } | 812 | } |
| 807 | 813 | ||
| 808 | AVFilter avfilter_vf_drawtext = { | 814 | AVFilter avfilter_vf_drawtext = { |
| @@ -214,7 +214,7 @@ static void fade_plane(int y, int h, int w, · 213 unmodified lines | |||
| 214 | } | 214 | } |
| 215 | } | 215 | } |
| 216 | 216 | ||
| 217 | static void draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir) | 217 | static int draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir) |
| 218 | { | 218 | { |
| 219 | FadeContext *fade = inlink->dst->priv; | 219 | FadeContext *fade = inlink->dst->priv; |
| 220 | AVFilterBufferRef *outpic = inlink->cur_buf; | 220 | AVFilterBufferRef *outpic = inlink->cur_buf; |
| @@ -255,20 +255,23 @@ static void draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir) · 34 unmodified lines | |||
| 255 | } | 255 | } |
| 256 | } | 256 | } |
| 257 | 257 | ||
| 258 | ff_draw_slice(inlink->dst->outputs[0], y, h, slice_dir); | 258 | return ff_draw_slice(inlink->dst->outputs[0], y, h, slice_dir); |
| 259 | } | 259 | } |
| 260 | 260 | ||
| 261 | static void end_frame(AVFilterLink *inlink) | 261 | static int end_frame(AVFilterLink *inlink) |
| 262 | { | 262 | { |
| 263 | FadeContext *fade = inlink->dst->priv; | 263 | FadeContext *fade = inlink->dst->priv; |
| 264 | int ret; | ||
| 264 | 265 | ||
| 265 | ff_end_frame(inlink->dst->outputs[0]); | 266 | ret = ff_end_frame(inlink->dst->outputs[0]); |
| 266 | 267 | ||
| 267 | if (fade->frame_index >= fade->start_frame && | 268 | if (fade->frame_index >= fade->start_frame && |
| 268 | fade->frame_index <= fade->stop_frame) | 269 | fade->frame_index <= fade->stop_frame) |
| 269 | fade->factor += fade->fade_per_frame; | 270 | fade->factor += fade->fade_per_frame; |
| 270 | fade->factor = av_clip_uint16(fade->factor); | 271 | fade->factor = av_clip_uint16(fade->factor); |
| 271 | fade->frame_index++; | 272 | fade->frame_index++; |
| 273 | |||
| 274 | return ret; | ||
| 272 | } | 275 | } |
| 273 | 276 | ||
| 274 | AVFilter avfilter_vf_fade = { | 277 | AVFilter avfilter_vf_fade = { |
| @@ -116,21 +116,35 @@ static AVFilterBufferRef *get_video_buffer(AVFilterLink *inlink, int perms, int · 115 unmodified lines | |||
| 116 | return ff_get_video_buffer(outlink, perms, w, h); | 116 | return ff_get_video_buffer(outlink, perms, w, h); |
| 117 | } | 117 | } |
| 118 | 118 | ||
| 119 | static void start_frame(AVFilterLink *inlink, AVFilterBufferRef *inpicref) | 119 | static int start_frame(AVFilterLink *inlink, AVFilterBufferRef *inpicref) |
| 120 | { | 120 | { |
| 121 | AVFilterContext *ctx = inlink->dst; | 121 | AVFilterContext *ctx = inlink->dst; |
| 122 | AVFilterLink *outlink = ctx->outputs[0]; | 122 | AVFilterLink *outlink = ctx->outputs[0]; |
| 123 | 123 | ||
| 124 | AVFilterBufferRef *outpicref, *for_next_filter; | 124 | AVFilterBufferRef *outpicref, *for_next_filter; |
| 125 | int ret = 0; | ||
| 125 | 126 | ||
| 126 | outpicref = avfilter_ref_buffer(inpicref, ~0); | 127 | outpicref = avfilter_ref_buffer(inpicref, ~0); |
| 127 | outlink->out_buf = outpicref; | 128 | if (!outpicref) |
| 129 | return AVERROR(ENOMEM); | ||
| 128 | 130 | ||
| 129 | for_next_filter = avfilter_ref_buffer(outpicref, ~0); | 131 | for_next_filter = avfilter_ref_buffer(outpicref, ~0); |
| 130 | ff_start_frame(outlink, for_next_filter); | 132 | if (!for_next_filter) { |
| 133 | avfilter_unref_bufferp(&outpicref); | ||
| 134 | return AVERROR(ENOMEM); | ||
| 135 | } | ||
| 136 | |||
| 137 | ret = ff_start_frame(outlink, for_next_filter); | ||
| 138 | if (ret < 0) { | ||
| 139 | avfilter_unref_bufferp(&outpicref); | ||
| 140 | return ret; | ||
| 141 | } | ||
| 142 | |||
| 143 | outlink->out_buf = outpicref; | ||
| 144 | return 0; | ||
| 131 | } | 145 | } |
| 132 | 146 | ||
| 133 | static void draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir) | 147 | static int draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir) |
| 134 | { | 148 | { |
| 135 | AVFilterContext *ctx = inlink->dst; | 149 | AVFilterContext *ctx = inlink->dst; |
| 136 | FieldOrderContext *fieldorder = ctx->priv; | 150 | FieldOrderContext *fieldorder = ctx->priv; |
| @@ -144,11 +158,12 @@ static void draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir) · 7 unmodified lines | |||
| 144 | * and that complexity will be added later */ | 158 | * and that complexity will be added later */ |
| 145 | if ( !inpicref->video->interlaced | 159 | if ( !inpicref->video->interlaced |
| 146 | || inpicref->video->top_field_first == fieldorder->dst_tff) { | 160 | || inpicref->video->top_field_first == fieldorder->dst_tff) { |
| 147 | ff_draw_slice(outlink, y, h, slice_dir); | 161 | return ff_draw_slice(outlink, y, h, slice_dir); |
| 148 | } | 162 | } |
| 163 | return 0; | ||
| 149 | } | 164 | } |
| 150 | 165 | ||
| 151 | static void end_frame(AVFilterLink *inlink) | 166 | static int end_frame(AVFilterLink *inlink) |
| 152 | { | 167 | { |
| 153 | AVFilterContext *ctx = inlink->dst; | 168 | AVFilterContext *ctx = inlink->dst; |
| 154 | FieldOrderContext *fieldorder = ctx->priv; | 169 | FieldOrderContext *fieldorder = ctx->priv; |
| @@ -212,7 +227,7 @@ static void end_frame(AVFilterLink *inlink) · 57 unmodified lines | |||
| 212 | "not interlaced or field order already correct\n"); | 227 | "not interlaced or field order already correct\n"); |
| 213 | } | 228 | } |
| 214 | 229 | ||
| 215 | ff_end_frame(outlink); | 230 | return ff_end_frame(outlink); |
| 216 | } | 231 | } |
| 217 | 232 | ||
| 218 | AVFilter avfilter_vf_fieldorder = { | 233 | AVFilter avfilter_vf_fieldorder = { |
| @@ -143,9 +143,11 @@ static int request_frame(AVFilterLink *outlink) · 142 unmodified lines | |||
| 143 | buf->pts = av_rescale_q(s->first_pts, ctx->inputs[0]->time_base, | 143 | buf->pts = av_rescale_q(s->first_pts, ctx->inputs[0]->time_base, |
| 144 | outlink->time_base) + s->frames_out; | 144 | outlink->time_base) + s->frames_out; |
| 145 | 145 | ||
| 146 | ff_start_frame(outlink, buf); | 146 | if ((ret = ff_start_frame(outlink, buf)) < 0 || |
| 147 | ff_draw_slice(outlink, 0, outlink->h, 1); | 147 | (ret = ff_draw_slice(outlink, 0, outlink->h, 1)) < 0 || |
| 148 | ff_end_frame(outlink); | 148 | (ret = ff_end_frame(outlink)) < 0) |
| 149 | return ret; | ||
| 150 | |||
| 149 | s->frames_out++; | 151 | s->frames_out++; |
| 150 | } | 152 | } |
| 151 | return 0; | 153 | return 0; |
| @@ -159,28 +161,33 @@ static int write_to_fifo(AVFifoBuffer *fifo, AVFilterBufferRef *buf) · 7 unmodified lines | |||
| 159 | int ret; | 161 | int ret; |
| 160 | 162 | ||
| 161 | if (!av_fifo_space(fifo) && | 163 | if (!av_fifo_space(fifo) && |
| 162 | (ret = av_fifo_realloc2(fifo, 2*av_fifo_size(fifo)))) | 164 | (ret = av_fifo_realloc2(fifo, 2*av_fifo_size(fifo)))) { |
| 165 | avfilter_unref_bufferp(&buf); | ||
| 163 | return ret; | 166 | return ret; |
| 167 | } | ||
| 164 | 168 | ||
| 165 | av_fifo_generic_write(fifo, &buf, sizeof(buf), NULL); | 169 | av_fifo_generic_write(fifo, &buf, sizeof(buf), NULL); |
| 166 | return 0; | 170 | return 0; |
| 167 | } | 171 | } |
| 168 | 172 | ||
| 169 | static void end_frame(AVFilterLink *inlink) | 173 | static int end_frame(AVFilterLink *inlink) |
| 170 | { | 174 | { |
| 171 | AVFilterContext *ctx = inlink->dst; | 175 | AVFilterContext *ctx = inlink->dst; |
| 172 | FPSContext *s = ctx->priv; | 176 | FPSContext *s = ctx->priv; |
| 173 | AVFilterLink *outlink = ctx->outputs[0]; | 177 | AVFilterLink *outlink = ctx->outputs[0]; |
| 174 | AVFilterBufferRef *buf = inlink->cur_buf; | 178 | AVFilterBufferRef *buf = inlink->cur_buf; |
| 175 | int64_t delta; | 179 | int64_t delta; |
| 176 | int i; | 180 | int i, ret; |
| 177 | 181 | ||
| 178 | inlink->cur_buf = NULL; | 182 | inlink->cur_buf = NULL; |
| 179 | s->frames_in++; | 183 | s->frames_in++; |
| 180 | /* discard frames until we get the first timestamp */ | 184 | /* discard frames until we get the first timestamp */ |
| 181 | if (s->pts == AV_NOPTS_VALUE) { | 185 | if (s->pts == AV_NOPTS_VALUE) { |
| 182 | if (buf->pts != AV_NOPTS_VALUE) { | 186 | if (buf->pts != AV_NOPTS_VALUE) { |
| 183 | write_to_fifo(s->fifo, buf); | 187 | ret = write_to_fifo(s->fifo, buf); |
| 188 | if (ret < 0) | ||
| 189 | return ret; | ||
| 190 | |||
| 184 | s->first_pts = s->pts = buf->pts; | 191 | s->first_pts = s->pts = buf->pts; |
| 185 | } else { | 192 | } else { |
| 186 | av_log(ctx, AV_LOG_WARNING, "Discarding initial frame(s) with no " | 193 | av_log(ctx, AV_LOG_WARNING, "Discarding initial frame(s) with no " |
| @@ -188,13 +195,12 @@ static void end_frame(AVFilterLink *inlink) · 1 unmodified line | |||
| 188 | avfilter_unref_buffer(buf); | 195 | avfilter_unref_buffer(buf); |
| 189 | s->drop++; | 196 | s->drop++; |
| 190 | } | 197 | } |
| 191 | return; | 198 | return 0; |
| 192 | } | 199 | } |
| 193 | 200 | ||
| 194 | /* now wait for the next timestamp */ | 201 | /* now wait for the next timestamp */ |
| 195 | if (buf->pts == AV_NOPTS_VALUE) { | 202 | if (buf->pts == AV_NOPTS_VALUE) { |
| 196 | write_to_fifo(s->fifo, buf); | 203 | return write_to_fifo(s->fifo, buf); |
| 197 | return; | ||
| 198 | } | 204 | } |
| 199 | 205 | ||
| 200 | /* number of output frames */ | 206 | /* number of output frames */ |
| @@ -211,10 +217,10 @@ static void end_frame(AVFilterLink *inlink) · 10 unmodified lines | |||
| 211 | 217 | ||
| 212 | av_fifo_generic_read(s->fifo, &tmp, sizeof(tmp), NULL); | 218 | av_fifo_generic_read(s->fifo, &tmp, sizeof(tmp), NULL); |
| 213 | flush_fifo(s->fifo); | 219 | flush_fifo(s->fifo); |
| 214 | write_to_fifo(s->fifo, tmp); | 220 | ret = write_to_fifo(s->fifo, tmp); |
| 215 | 221 | ||
| 216 | avfilter_unref_buffer(buf); | 222 | avfilter_unref_buffer(buf); |
| 217 | return; | 223 | return ret; |
| 218 | } | 224 | } |
| 219 | 225 | ||
| 220 | /* can output >= 1 frames */ | 226 | /* can output >= 1 frames */ |
| @@ -224,31 +230,51 @@ static void end_frame(AVFilterLink *inlink) · 3 unmodified lines | |||
| 224 | 230 | ||
| 225 | /* duplicate the frame if needed */ | 231 | /* duplicate the frame if needed */ |
| 226 | if (!av_fifo_size(s->fifo) && i < delta - 1) { | 232 | if (!av_fifo_size(s->fifo) && i < delta - 1) { |
| 233 | AVFilterBufferRef *dup = avfilter_ref_buffer(buf_out, AV_PERM_READ); | ||
| 234 | |||
| 227 | av_log(ctx, AV_LOG_DEBUG, "Duplicating frame.\n"); | 235 | av_log(ctx, AV_LOG_DEBUG, "Duplicating frame.\n"); |
| 228 | write_to_fifo(s->fifo, avfilter_ref_buffer(buf_out, AV_PERM_READ)); | 236 | if (dup) |
| 237 | ret = write_to_fifo(s->fifo, dup); | ||
| 238 | else | ||
| 239 | ret = AVERROR(ENOMEM); | ||
| 240 | |||
| 241 | if (ret < 0) { | ||
| 242 | avfilter_unref_bufferp(&buf_out); | ||
| 243 | avfilter_unref_bufferp(&buf); | ||
| 244 | return ret; | ||
| 245 | } | ||
| 246 | |||
| 229 | s->dup++; | 247 | s->dup++; |
| 230 | } | 248 | } |
| 231 | 249 | ||
| 232 | buf_out->pts = av_rescale_q(s->first_pts, inlink->time_base, | 250 | buf_out->pts = av_rescale_q(s->first_pts, inlink->time_base, |
| 233 | outlink->time_base) + s->frames_out; | 251 | outlink->time_base) + s->frames_out; |
| 234 | 252 | ||
| 235 | ff_start_frame(outlink, buf_out); | 253 | if ((ret = ff_start_frame(outlink, buf_out)) < 0 || |
| 236 | ff_draw_slice(outlink, 0, outlink->h, 1); | 254 | (ret = ff_draw_slice(outlink, 0, outlink->h, 1)) < 0 || |
| 237 | ff_end_frame(outlink); | 255 | (ret = ff_end_frame(outlink)) < 0) { |
| 256 | avfilter_unref_bufferp(&buf); | ||
| 257 | return ret; | ||
| 258 | } | ||
| 259 | |||
| 238 | s->frames_out++; | 260 | s->frames_out++; |
| 239 | } | 261 | } |
| 240 | flush_fifo(s->fifo); | 262 | flush_fifo(s->fifo); |
| 241 | 263 | ||
| 242 | write_to_fifo(s->fifo, buf); | 264 | ret = write_to_fifo(s->fifo, buf); |
| 243 | s->pts = s->first_pts + av_rescale_q(s->frames_out, outlink->time_base, inlink->time_base); | 265 | s->pts = s->first_pts + av_rescale_q(s->frames_out, outlink->time_base, inlink->time_base); |
| 266 | |||
| 267 | return ret; | ||
| 244 | } | 268 | } |
| 245 | 269 | ||
| 246 | static void null_start_frame(AVFilterLink *link, AVFilterBufferRef *buf) | 270 | static int null_start_frame(AVFilterLink *link, AVFilterBufferRef *buf) |
| 247 | { | 271 | { |
| 272 | return 0; | ||
| 248 | } | 273 | } |
| 249 | 274 | ||
| 250 | static void null_draw_slice(AVFilterLink *link, int y, int h, int slice_dir) | 275 | static int null_draw_slice(AVFilterLink *link, int y, int h, int slice_dir) |
| 251 | { | 276 | { |
| 277 | return 0; | ||
| 252 | } | 278 | } |
| 253 | 279 | ||
| 254 | AVFilter avfilter_vf_fps = { | 280 | AVFilter avfilter_vf_fps = { |
| @@ -340,20 +340,26 @@ static int query_formats(AVFilterContext *ctx) · 339 unmodified lines | |||
| 340 | return 0; | 340 | return 0; |
| 341 | } | 341 | } |
| 342 | 342 | ||
| 343 | static void null_draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir) { } | 343 | static int null_draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir) |
| 344 | { | ||
| 345 | return 0; | ||
| 346 | } | ||
| 344 | 347 | ||
| 345 | static void end_frame(AVFilterLink *inlink) | 348 | static int end_frame(AVFilterLink *inlink) |
| 346 | { | 349 | { |
| 347 | Frei0rContext *frei0r = inlink->dst->priv; | 350 | Frei0rContext *frei0r = inlink->dst->priv; |
| 348 | AVFilterLink *outlink = inlink->dst->outputs[0]; | 351 | AVFilterLink *outlink = inlink->dst->outputs[0]; |
| 349 | AVFilterBufferRef *inpicref = inlink->cur_buf; | 352 | AVFilterBufferRef *inpicref = inlink->cur_buf; |
| 350 | AVFilterBufferRef *outpicref = outlink->out_buf; | 353 | AVFilterBufferRef *outpicref = outlink->out_buf; |
| 354 | int ret; | ||
| 351 | 355 | ||
| 352 | frei0r->update(frei0r->instance, inpicref->pts * av_q2d(inlink->time_base) * 1000, | 356 | frei0r->update(frei0r->instance, inpicref->pts * av_q2d(inlink->time_base) * 1000, |
| 353 | (const uint32_t *)inpicref->data[0], | 357 | (const uint32_t *)inpicref->data[0], |
| 354 | (uint32_t *)outpicref->data[0]); | 358 | (uint32_t *)outpicref->data[0]); |
| 355 | ff_draw_slice(outlink, 0, outlink->h, 1); | 359 | if ((ret = ff_draw_slice(outlink, 0, outlink->h, 1)) || |
| 356 | ff_end_frame(outlink); | 360 | (ret = ff_end_frame(outlink)) < 0) |
| 361 | return ret; | ||
| 362 | return 0; | ||
| 357 | } | 363 | } |
| 358 | 364 | ||
| 359 | AVFilter avfilter_vf_frei0r = { | 365 | AVFilter avfilter_vf_frei0r = { |
| @@ -432,18 +438,38 @@ static int source_request_frame(AVFilterLink *outlink) · 72 unmodified lines | |||
| 432 | { | 438 | { |
| 433 | Frei0rContext *frei0r = outlink->src->priv; | 439 | Frei0rContext *frei0r = outlink->src->priv; |
| 434 | AVFilterBufferRef *picref = ff_get_video_buffer(outlink, AV_PERM_WRITE, outlink->w, outlink->h); | 440 | AVFilterBufferRef *picref = ff_get_video_buffer(outlink, AV_PERM_WRITE, outlink->w, outlink->h); |
| 441 | AVFilterBufferRef *buf_out; | ||
| 442 | int ret; | ||
| 443 | |||
| 444 | if (!picref) | ||
| 445 | return AVERROR(ENOMEM); | ||
| 446 | |||
| 435 | picref->video->sample_aspect_ratio = (AVRational) {1, 1}; | 447 | picref->video->sample_aspect_ratio = (AVRational) {1, 1}; |
| 436 | picref->pts = frei0r->pts++; | 448 | picref->pts = frei0r->pts++; |
| 437 | picref->pos = -1; | 449 | picref->pos = -1; |
| 438 | 450 | ||
| 439 | ff_start_frame(outlink, avfilter_ref_buffer(picref, ~0)); | 451 | buf_out = avfilter_ref_buffer(picref, ~0); |
| 452 | if (!buf_out) { | ||
| 453 | ret = AVERROR(ENOMEM); | ||
| 454 | goto fail; | ||
| 455 | } | ||
| 456 | |||
| 457 | ret = ff_start_frame(outlink, buf_out); | ||
| 458 | if (ret < 0) | ||
| 459 | goto fail; | ||
| 460 | |||
| 440 | frei0r->update(frei0r->instance, av_rescale_q(picref->pts, frei0r->time_base, (AVRational){1,1000}), | 461 | frei0r->update(frei0r->instance, av_rescale_q(picref->pts, frei0r->time_base, (AVRational){1,1000}), |
| 441 | NULL, (uint32_t *)picref->data[0]); | 462 | NULL, (uint32_t *)picref->data[0]); |
| 442 | ff_draw_slice(outlink, 0, outlink->h, 1); | 463 | ret = ff_draw_slice(outlink, 0, outlink->h, 1); |
| 443 | ff_end_frame(outlink); | 464 | if (ret < 0) |
| 465 | goto fail; | ||
| 466 | |||
| 467 | ret = ff_end_frame(outlink); | ||
| 468 | |||
| 469 | fail: | ||
| 444 | avfilter_unref_buffer(picref); | 470 | avfilter_unref_buffer(picref); |
| 445 | 471 | ||
| 446 | return 0; | 472 | return ret; |
| 447 | } | 473 | } |
| 448 | 474 | ||
| 449 | AVFilter avfilter_vsrc_frei0r_src = { | 475 | AVFilter avfilter_vsrc_frei0r_src = { |
| @@ -180,32 +180,53 @@ static int config_input(AVFilterLink *inlink) · 179 unmodified lines | |||
| 180 | return 0; | 180 | return 0; |
| 181 | } | 181 | } |
| 182 | 182 | ||
| 183 | static void start_frame(AVFilterLink *inlink, AVFilterBufferRef *inpicref) | 183 | static int start_frame(AVFilterLink *inlink, AVFilterBufferRef *inpicref) |
| 184 | { | 184 | { |
| 185 | AVFilterLink *outlink = inlink->dst->outputs[0]; | 185 | AVFilterLink *outlink = inlink->dst->outputs[0]; |
| 186 | AVFilterBufferRef *outpicref; | 186 | AVFilterBufferRef *outpicref = NULL, *for_next_filter; |
| 187 | int ret = 0; | ||
| 187 | 188 | ||
| 188 | if (inpicref->perms & AV_PERM_PRESERVE) { | 189 | if (inpicref->perms & AV_PERM_PRESERVE) { |
| 189 | outpicref = ff_get_video_buffer(outlink, AV_PERM_WRITE, outlink->w, outlink->h); | 190 | outpicref = ff_get_video_buffer(outlink, AV_PERM_WRITE, outlink->w, outlink->h); |
| 191 | if (!outpicref) | ||
| 192 | return AVERROR(ENOMEM); | ||
| 193 | |||
| 190 | avfilter_copy_buffer_ref_props(outpicref, inpicref); | 194 | avfilter_copy_buffer_ref_props(outpicref, inpicref); |
| 191 | outpicref->video->w = outlink->w; | 195 | outpicref->video->w = outlink->w; |
| 192 | outpicref->video->h = outlink->h; | 196 | outpicref->video->h = outlink->h; |
| 193 | } else | 197 | } else { |
| 194 | outpicref = avfilter_ref_buffer(inpicref, ~0); | 198 | outpicref = avfilter_ref_buffer(inpicref, ~0); |
| 199 | if (!outpicref) | ||
| 200 | return AVERROR(ENOMEM); | ||
| 201 | } | ||
| 202 | |||
| 203 | for_next_filter = avfilter_ref_buffer(outpicref, ~0); | ||
| 204 | if (for_next_filter) | ||
| 205 | ret = ff_start_frame(outlink, for_next_filter); | ||
| 206 | else | ||
| 207 | ret = AVERROR(ENOMEM); | ||
| 208 | |||
| 209 | if (ret < 0) { | ||
| 210 | avfilter_unref_bufferp(&outpicref); | ||
| 211 | return ret; | ||
| 212 | } | ||
| 195 | 213 | ||
| 196 | outlink->out_buf = outpicref; | 214 | outlink->out_buf = outpicref; |
| 197 | ff_start_frame(outlink, avfilter_ref_buffer(outpicref, ~0)); | 215 | return 0; |
| 198 | } | 216 | } |
| 199 | 217 | ||
| 200 | static void null_draw_slice(AVFilterLink *link, int y, int h, int slice_dir) { } | 218 | static int null_draw_slice(AVFilterLink *link, int y, int h, int slice_dir) |
| 219 | { | ||
| 220 | return 0; | ||
| 221 | } | ||
| 201 | 222 | ||
| 202 | static void end_frame(AVFilterLink *inlink) | 223 | static int end_frame(AVFilterLink *inlink) |
| 203 | { | 224 | { |
| 204 | GradFunContext *gf = inlink->dst->priv; | 225 | GradFunContext *gf = inlink->dst->priv; |
| 205 | AVFilterBufferRef *inpic = inlink->cur_buf; | 226 | AVFilterBufferRef *inpic = inlink->cur_buf; |
| 206 | AVFilterLink *outlink = inlink->dst->outputs[0]; | 227 | AVFilterLink *outlink = inlink->dst->outputs[0]; |
| 207 | AVFilterBufferRef *outpic = outlink->out_buf; | 228 | AVFilterBufferRef *outpic = outlink->out_buf; |
| 208 | int p; | 229 | int p, ret; |
| 209 | 230 | ||
| 210 | for (p = 0; p < 4 && inpic->data[p]; p++) { | 231 | for (p = 0; p < 4 && inpic->data[p]; p++) { |
| 211 | int w = inlink->w; | 232 | int w = inlink->w; |
| @@ -223,8 +244,10 @@ static void end_frame(AVFilterLink *inlink) · 11 unmodified lines | |||
| 223 | av_image_copy_plane(outpic->data[p], outpic->linesize[p], inpic->data[p], inpic->linesize[p], w, h); | 244 | av_image_copy_plane(outpic->data[p], outpic->linesize[p], inpic->data[p], inpic->linesize[p], w, h); |
| 224 | } | 245 | } |
| 225 | 246 | ||
| 226 | ff_draw_slice(outlink, 0, inlink->h, 1); | 247 | if ((ret = ff_draw_slice(outlink, 0, inlink->h, 1)) < 0 || |
| 227 | ff_end_frame(outlink); | 248 | (ret = ff_end_frame(outlink)) < 0) |
| 249 | return ret; | ||
| 250 | return 0; | ||
| 228 | } | 251 | } |
| 229 | 252 | ||
| 230 | AVFilter avfilter_vf_gradfun = { | 253 | AVFilter avfilter_vf_gradfun = { |
| @@ -83,7 +83,7 @@ static int config_props(AVFilterLink *inlink) · 82 unmodified lines | |||
| 83 | return 0; | 83 | return 0; |
| 84 | } | 84 | } |
| 85 | 85 | ||
| 86 | static void start_frame(AVFilterLink *inlink, AVFilterBufferRef *picref) | 86 | static int start_frame(AVFilterLink *inlink, AVFilterBufferRef *picref) |
| 87 | { | 87 | { |
| 88 | AVFilterLink *outlink = inlink->dst->outputs[0]; | 88 | AVFilterLink *outlink = inlink->dst->outputs[0]; |
| 89 | 89 | ||
| @@ -95,10 +95,10 @@ static void start_frame(AVFilterLink *inlink, AVFilterBufferRef *picref) · 5 unmodified lines | |||
| 95 | if (av_pix_fmt_descriptors[inlink->format].flags & PIX_FMT_PAL) | 95 | if (av_pix_fmt_descriptors[inlink->format].flags & PIX_FMT_PAL) |
| 96 | memcpy(inlink->dst->outputs[0]->out_buf->data[1], picref->data[1], AVPALETTE_SIZE); | 96 | memcpy(inlink->dst->outputs[0]->out_buf->data[1], picref->data[1], AVPALETTE_SIZE); |
| 97 | 97 | ||
| 98 | ff_start_frame(outlink, avfilter_ref_buffer(outlink->out_buf, ~0)); | 98 | return ff_start_frame(outlink, avfilter_ref_buffer(outlink->out_buf, ~0)); |
| 99 | } | 99 | } |
| 100 | 100 | ||
| 101 | static void draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir) | 101 | static int draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir) |
| 102 | { | 102 | { |
| 103 | FlipContext *flip = inlink->dst->priv; | 103 | FlipContext *flip = inlink->dst->priv; |
| 104 | AVFilterBufferRef *inpic = inlink->cur_buf; | 104 | AVFilterBufferRef *inpic = inlink->cur_buf; |
| @@ -159,7 +159,7 @@ static void draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir) · 54 unmodified lines | |||
| 159 | } | 159 | } |
| 160 | } | 160 | } |
| 161 | 161 | ||
| 162 | ff_draw_slice(inlink->dst->outputs[0], y, h, slice_dir); | 162 | return ff_draw_slice(inlink->dst->outputs[0], y, h, slice_dir); |
| 163 | } | 163 | } |
| 164 | 164 | ||
| 165 | AVFilter avfilter_vf_hflip = { | 165 | AVFilter avfilter_vf_hflip = { |
| @@ -290,9 +290,12 @@ static int config_input(AVFilterLink *inlink) · 289 unmodified lines | |||
| 290 | return 0; | 290 | return 0; |
| 291 | } | 291 | } |
| 292 | 292 | ||
| 293 | static void null_draw_slice(AVFilterLink *link, int y, int h, int slice_dir) { } | 293 | static int null_draw_slice(AVFilterLink *link, int y, int h, int slice_dir) |
| 294 | { | ||
| 295 | return 0; | ||
| 296 | } | ||
| 294 | 297 | ||
| 295 | static void end_frame(AVFilterLink *inlink) | 298 | static int end_frame(AVFilterLink *inlink) |
| 296 | { | 299 | { |
| 297 | HQDN3DContext *hqdn3d = inlink->dst->priv; | 300 | HQDN3DContext *hqdn3d = inlink->dst->priv; |
| 298 | AVFilterLink *outlink = inlink->dst->outputs[0]; | 301 | AVFilterLink *outlink = inlink->dst->outputs[0]; |
| @@ -300,6 +303,7 @@ static void end_frame(AVFilterLink *inlink) · 1 unmodified line | |||
| 300 | AVFilterBufferRef *outpic = outlink->out_buf; | 303 | AVFilterBufferRef *outpic = outlink->out_buf; |
| 301 | int cw = inpic->video->w >> hqdn3d->hsub; | 304 | int cw = inpic->video->w >> hqdn3d->hsub; |
| 302 | int ch = inpic->video->h >> hqdn3d->vsub; | 305 | int ch = inpic->video->h >> hqdn3d->vsub; |
| 306 | int ret; | ||
| 303 | 307 | ||
| 304 | deNoise(inpic->data[0], outpic->data[0], | 308 | deNoise(inpic->data[0], outpic->data[0], |
| 305 | hqdn3d->Line, &hqdn3d->Frame[0], inpic->video->w, inpic->video->h, | 309 | hqdn3d->Line, &hqdn3d->Frame[0], inpic->video->w, inpic->video->h, |
| @@ -320,8 +324,10 @@ static void end_frame(AVFilterLink *inlink) · 14 unmodified lines | |||
| 320 | hqdn3d->Coefs[2], | 324 | hqdn3d->Coefs[2], |
| 321 | hqdn3d->Coefs[3]); | 325 | hqdn3d->Coefs[3]); |
| 322 | 326 | ||
| 323 | ff_draw_slice(outlink, 0, inpic->video->h, 1); | 327 | if ((ret = ff_draw_slice(outlink, 0, inpic->video->h, 1)) < 0 || |
| 324 | ff_end_frame(outlink); | 328 | (ret = ff_end_frame(outlink)) < 0) |
| 329 | return ret; | ||
| 330 | return 0; | ||
| 325 | } | 331 | } |
| 326 | 332 | ||
| 327 | AVFilter avfilter_vf_hqdn3d = { | 333 | AVFilter avfilter_vf_hqdn3d = { |
| @@ -169,7 +169,7 @@ static void filter(AVFilterContext *ctx) · 168 unmodified lines | |||
| 169 | av_log(ctx, AV_LOG_DEBUG, "Single frame:%s, Multi frame:%s\n", type2str(type), type2str(idet->last_type)); | 169 | av_log(ctx, AV_LOG_DEBUG, "Single frame:%s, Multi frame:%s\n", type2str(type), type2str(idet->last_type)); |
| 170 | } | 170 | } |
| 171 | 171 | ||
| 172 | static void start_frame(AVFilterLink *link, AVFilterBufferRef *picref) | 172 | static int start_frame(AVFilterLink *link, AVFilterBufferRef *picref) |
| 173 | { | 173 | { |
| 174 | AVFilterContext *ctx = link->dst; | 174 | AVFilterContext *ctx = link->dst; |
| 175 | IDETContext *idet = ctx->priv; | 175 | IDETContext *idet = ctx->priv; |
| @@ -181,21 +181,21 @@ static void start_frame(AVFilterLink *link, AVFilterBufferRef *picref) · 5 unmodified lines | |||
| 181 | idet->next = picref; | 181 | idet->next = picref; |
| 182 | 182 | ||
| 183 | if (!idet->cur) | 183 | if (!idet->cur) |
| 184 | return; | 184 | return 0; |
| 185 | 185 | ||
| 186 | if (!idet->prev) | 186 | if (!idet->prev) |
| 187 | idet->prev = avfilter_ref_buffer(idet->cur, AV_PERM_READ); | 187 | idet->prev = avfilter_ref_buffer(idet->cur, AV_PERM_READ); |
| 188 | 188 | ||
| 189 | ff_start_frame(ctx->outputs[0], avfilter_ref_buffer(idet->cur, AV_PERM_READ)); | 189 | return ff_start_frame(ctx->outputs[0], avfilter_ref_buffer(idet->cur, AV_PERM_READ)); |
| 190 | } | 190 | } |
| 191 | 191 | ||
| 192 | static void end_frame(AVFilterLink *link) | 192 | static int end_frame(AVFilterLink *link) |
| 193 | { | 193 | { |
| 194 | AVFilterContext *ctx = link->dst; | 194 | AVFilterContext *ctx = link->dst; |
| 195 | IDETContext *idet = ctx->priv; | 195 | IDETContext *idet = ctx->priv; |
| 196 | 196 | ||
| 197 | if (!idet->cur) | 197 | if (!idet->cur) |
| 198 | return; | 198 | return 0; |
| 199 | 199 | ||
| 200 | if (!idet->csp) | 200 | if (!idet->csp) |
| 201 | idet->csp = &av_pix_fmt_descriptors[link->format]; | 201 | idet->csp = &av_pix_fmt_descriptors[link->format]; |
| @@ -205,7 +205,7 @@ static void end_frame(AVFilterLink *link) · 3 unmodified lines | |||
| 205 | filter(ctx); | 205 | filter(ctx); |
| 206 | 206 | ||
| 207 | ff_draw_slice(ctx->outputs[0], 0, link->h, 1); | 207 | ff_draw_slice(ctx->outputs[0], 0, link->h, 1); |
| 208 | ff_end_frame(ctx->outputs[0]); | 208 | return ff_end_frame(ctx->outputs[0]); |
| 209 | } | 209 | } |
| 210 | 210 | ||
| 211 | static int request_frame(AVFilterLink *link) | 211 | static int request_frame(AVFilterLink *link) |
| @@ -311,7 +311,7 @@ static av_cold int init(AVFilterContext *ctx, const char *args) · 99 unmodified lines | |||
| 311 | return 0; | 311 | return 0; |
| 312 | } | 312 | } |
| 313 | 313 | ||
| 314 | static void null_draw_slice(AVFilterLink *link, int y, int h, int slice_dir) { } | 314 | static int null_draw_slice(AVFilterLink *link, int y, int h, int slice_dir) { return 0; } |
| 315 | 315 | ||
| 316 | AVFilter avfilter_vf_idet = { | 316 | AVFilter avfilter_vf_idet = { |
| 317 | .name = "idet", | 317 | .name = "idet", |
| @@ -67,7 +67,10 @@ static int query_formats(AVFilterContext *ctx) · 66 unmodified lines | |||
| 67 | return 0; | 67 | return 0; |
| 68 | } | 68 | } |
| 69 | 69 | ||
| 70 | static void null_draw_slice(AVFilterLink *link, int y, int h, int slice_dir) { } | 70 | static int null_draw_slice(AVFilterLink *link, int y, int h, int slice_dir) |
| 71 | { | ||
| 72 | return 0; | ||
| 73 | } | ||
| 71 | 74 | ||
| 72 | typedef struct { | 75 | typedef struct { |
| 73 | const char *name; | 76 | const char *name; |
| @@ -351,7 +354,7 @@ static av_cold void uninit(AVFilterContext *ctx) · 277 unmodified lines | |||
| 351 | memset(ocv, 0, sizeof(*ocv)); | 354 | memset(ocv, 0, sizeof(*ocv)); |
| 352 | } | 355 | } |
| 353 | 356 | ||
| 354 | static void end_frame(AVFilterLink *inlink) | 357 | static int end_frame(AVFilterLink *inlink) |
| 355 | { | 358 | { |
| 356 | AVFilterContext *ctx = inlink->dst; | 359 | AVFilterContext *ctx = inlink->dst; |
| 357 | OCVContext *ocv = ctx->priv; | 360 | OCVContext *ocv = ctx->priv; |
| @@ -359,14 +362,17 @@ static void end_frame(AVFilterLink *inlink) · 1 unmodified line | |||
| 359 | AVFilterBufferRef *inpicref = inlink ->cur_buf; | 362 | AVFilterBufferRef *inpicref = inlink ->cur_buf; |
| 360 | AVFilterBufferRef *outpicref = outlink->out_buf; | 363 | AVFilterBufferRef *outpicref = outlink->out_buf; |
| 361 | IplImage inimg, outimg; | 364 | IplImage inimg, outimg; |
| 365 | int ret; | ||
| 362 | 366 | ||
| 363 | fill_iplimage_from_picref(&inimg , inpicref , inlink->format); | 367 | fill_iplimage_from_picref(&inimg , inpicref , inlink->format); |
| 364 | fill_iplimage_from_picref(&outimg, outpicref, inlink->format); | 368 | fill_iplimage_from_picref(&outimg, outpicref, inlink->format); |
| 365 | ocv->end_frame_filter(ctx, &inimg, &outimg); | 369 | ocv->end_frame_filter(ctx, &inimg, &outimg); |
| 366 | fill_picref_from_iplimage(outpicref, &outimg, inlink->format); | 370 | fill_picref_from_iplimage(outpicref, &outimg, inlink->format); |
| 367 | 371 | ||
| 368 | ff_draw_slice(outlink, 0, outlink->h, 1); | 372 | if ((ret = ff_draw_slice(outlink, 0, outlink->h, 1)) < 0 || |
| 369 | ff_end_frame(outlink); | 373 | (ret = ff_end_frame(outlink)) < 0) |
| 374 | return ret; | ||
| 375 | return 0; | ||
| 370 | } | 376 | } |
| 371 | 377 | ||
| 372 | AVFilter avfilter_vf_ocv = { | 378 | AVFilter avfilter_vf_ocv = { |
| @@ -275,7 +275,7 @@ static int config_props(AVFilterLink *inlink) · 274 unmodified lines | |||
| 275 | return 0; | 275 | return 0; |
| 276 | } | 276 | } |
| 277 | 277 | ||
| 278 | static void draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir) | 278 | static int draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir) |
| 279 | { | 279 | { |
| 280 | AVFilterContext *ctx = inlink->dst; | 280 | AVFilterContext *ctx = inlink->dst; |
| 281 | LutContext *lut = ctx->priv; | 281 | LutContext *lut = ctx->priv; |
| @@ -332,7 +332,7 @@ static void draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir) · 50 unmodified lines | |||
| 332 | } | 332 | } |
| 333 | } | 333 | } |
| 334 | 334 | ||
| 335 | ff_draw_slice(outlink, y, h, slice_dir); | 335 | return ff_draw_slice(outlink, y, h, slice_dir); |
| 336 | } | 336 | } |
| 337 | 337 | ||
| 338 | static const AVFilterPad inputs[] = { | 338 | static const AVFilterPad inputs[] = { |
| @@ -848,15 +848,17 @@ static int request_frame(AVFilterLink *outlink) · 847 unmodified lines | |||
| 848 | return ret; | 848 | return ret; |
| 849 | } | 849 | } |
| 850 | 850 | ||
| 851 | static void start_frame(AVFilterLink *inlink, AVFilterBufferRef *picref) | 851 | static int start_frame(AVFilterLink *inlink, AVFilterBufferRef *picref) |
| 852 | { | 852 | { |
| 853 | return 0; | ||
| 853 | } | 854 | } |
| 854 | 855 | ||
| 855 | static void null_draw_slice(AVFilterLink *link, int y, int h, int slice_dir) | 856 | static int null_draw_slice(AVFilterLink *link, int y, int h, int slice_dir) |
| 856 | { | 857 | { |
| 858 | return 0; | ||
| 857 | } | 859 | } |
| 858 | 860 | ||
| 859 | static void end_frame(AVFilterLink *inlink) | 861 | static int end_frame(AVFilterLink *inlink) |
| 860 | { | 862 | { |
| 861 | MPContext *m = inlink->dst->priv; | 863 | MPContext *m = inlink->dst->priv; |
| 862 | AVFilterBufferRef *inpic = inlink->cur_buf; | 864 | AVFilterBufferRef *inpic = inlink->cur_buf; |
| @@ -883,6 +885,7 @@ static void end_frame(AVFilterLink *inlink) · 20 unmodified lines | |||
| 883 | av_log(m->avfctx, AV_LOG_DEBUG, "put_image() says skip\n"); | 885 | av_log(m->avfctx, AV_LOG_DEBUG, "put_image() says skip\n"); |
| 884 | } | 886 | } |
| 885 | free_mp_image(mpi); | 887 | free_mp_image(mpi); |
| 888 | return 0; | ||
| 886 | } | 889 | } |
| 887 | 890 | ||
| 888 | AVFilter avfilter_vf_mp = { | 891 | AVFilter avfilter_vf_mp = { |
| @@ -145,8 +145,7 @@ static av_cold void uninit(AVFilterContext *ctx) · 144 unmodified lines | |||
| 145 | av_freep(&over->x_expr); | 145 | av_freep(&over->x_expr); |
| 146 | av_freep(&over->y_expr); | 146 | av_freep(&over->y_expr); |
| 147 | 147 | ||
| 148 | if (over->overpicref) | 148 | avfilter_unref_bufferp(&over->overpicref); |
| 149 | avfilter_unref_bufferp(&over->overpicref); | ||
| 150 | ff_bufqueue_discard_all(&over->queue_main); | 149 | ff_bufqueue_discard_all(&over->queue_main); |
| 151 | ff_bufqueue_discard_all(&over->queue_over); | 150 | ff_bufqueue_discard_all(&over->queue_over); |
| 152 | } | 151 | } |
| @@ -506,7 +505,7 @@ static void flush_frames(AVFilterContext *ctx) · 353 unmodified lines | |||
| 506 | while (!try_push_frame(ctx)); | 505 | while (!try_push_frame(ctx)); |
| 507 | } | 506 | } |
| 508 | 507 | ||
| 509 | static void start_frame_main(AVFilterLink *inlink, AVFilterBufferRef *inpicref) | 508 | static int start_frame_main(AVFilterLink *inlink, AVFilterBufferRef *inpicref) |
| 510 | { | 509 | { |
| 511 | AVFilterContext *ctx = inlink->dst; | 510 | AVFilterContext *ctx = inlink->dst; |
| 512 | OverlayContext *over = ctx->priv; | 511 | OverlayContext *over = ctx->priv; |
| @@ -519,9 +518,10 @@ static void start_frame_main(AVFilterLink *inlink, AVFilterBufferRef *inpicref) · 6 unmodified lines | |||
| 519 | av_assert1(inpicref == inlink->cur_buf); | 518 | av_assert1(inpicref == inlink->cur_buf); |
| 520 | inlink->cur_buf = NULL; | 519 | inlink->cur_buf = NULL; |
| 521 | } | 520 | } |
| 521 | return 0; | ||
| 522 | } | 522 | } |
| 523 | 523 | ||
| 524 | static void draw_slice_main(AVFilterLink *inlink, int y, int h, int slice_dir) | 524 | static int draw_slice_main(AVFilterLink *inlink, int y, int h, int slice_dir) |
| 525 | { | 525 | { |
| 526 | AVFilterContext *ctx = inlink->dst; | 526 | AVFilterContext *ctx = inlink->dst; |
| 527 | OverlayContext *over = ctx->priv; | 527 | OverlayContext *over = ctx->priv; |
| @@ -536,10 +536,10 @@ static void draw_slice_main(AVFilterLink *inlink, int y, int h, int slice_dir) · 8 unmodified lines | |||
| 536 | over->overpicref->video->w, over->overpicref->video->h, | 536 | over->overpicref->video->w, over->overpicref->video->h, |
| 537 | y, outpicref->video->w, h); | 537 | y, outpicref->video->w, h); |
| 538 | } | 538 | } |
| 539 | ff_draw_slice(outlink, y, h, slice_dir); | 539 | return ff_draw_slice(outlink, y, h, slice_dir); |
| 540 | } | 540 | } |
| 541 | 541 | ||
| 542 | static void end_frame_main(AVFilterLink *inlink) | 542 | static int end_frame_main(AVFilterLink *inlink) |
| 543 | { | 543 | { |
| 544 | AVFilterContext *ctx = inlink->dst; | 544 | AVFilterContext *ctx = inlink->dst; |
| 545 | AVFilterLink *outlink = ctx->outputs[0]; | 545 | AVFilterLink *outlink = ctx->outputs[0]; |
| @@ -547,15 +547,16 @@ static void end_frame_main(AVFilterLink *inlink) · 1 unmodified line | |||
| 547 | flush_frames(ctx); | 547 | flush_frames(ctx); |
| 548 | 548 | ||
| 549 | if (!outpicref) | 549 | if (!outpicref) |
| 550 | return; | 550 | return 0; |
| 551 | ff_end_frame(ctx->outputs[0]); | 551 | return ff_end_frame(ctx->outputs[0]); |
| 552 | } | 552 | } |
| 553 | 553 | ||
| 554 | static void start_frame_over(AVFilterLink *inlink, AVFilterBufferRef *inpicref) | 554 | static int start_frame_over(AVFilterLink *inlink, AVFilterBufferRef *inpicref) |
| 555 | { | 555 | { |
| 556 | return 0; | ||
| 556 | } | 557 | } |
| 557 | 558 | ||
| 558 | static void end_frame_over(AVFilterLink *inlink) | 559 | static int end_frame_over(AVFilterLink *inlink) |
| 559 | { | 560 | { |
| 560 | AVFilterContext *ctx = inlink->dst; | 561 | AVFilterContext *ctx = inlink->dst; |
| 561 | OverlayContext *over = ctx->priv; | 562 | OverlayContext *over = ctx->priv; |
| @@ -566,7 +567,7 @@ static void end_frame_over(AVFilterLink *inlink) · 4 unmodified lines | |||
| 566 | inpicref->pts = av_rescale_q(inpicref->pts, ctx->inputs[OVERLAY]->time_base, | 567 | inpicref->pts = av_rescale_q(inpicref->pts, ctx->inputs[OVERLAY]->time_base, |
| 567 | ctx->outputs[0]->time_base); | 568 | ctx->outputs[0]->time_base); |
| 568 | ff_bufqueue_add(ctx, &over->queue_over, inpicref); | 569 | ff_bufqueue_add(ctx, &over->queue_over, inpicref); |
| 569 | try_push_frame(ctx); | 570 | return try_push_frame(ctx); |
| 570 | } | 571 | } |
| 571 | 572 | ||
| 572 | static int request_frame(AVFilterLink *outlink) | 573 | static int request_frame(AVFilterLink *outlink) |
| @@ -597,7 +598,10 @@ static int request_frame(AVFilterLink *outlink) · 24 unmodified lines | |||
| 597 | return 0; | 598 | return 0; |
| 598 | } | 599 | } |
| 599 | 600 | ||
| 600 | static void null_draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir) { } | 601 | static int null_draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir) |
| 602 | { | ||
| 603 | return 0; | ||
| 604 | } | ||
| 601 | 605 | ||
| 602 | AVFilter avfilter_vf_overlay = { | 606 | AVFilter avfilter_vf_overlay = { |
| 603 | .name = "overlay", | 607 | .name = "overlay", |
| @@ -226,6 +226,9 @@ static AVFilterBufferRef *get_video_buffer(AVFilterLink *inlink, int perms, int · 225 unmodified lines | |||
| 226 | h + (pad->h - pad->in_h)); | 226 | h + (pad->h - pad->in_h)); |
| 227 | int plane; | 227 | int plane; |
| 228 | 228 | ||
| 229 | if (!picref) | ||
| 230 | return NULL; | ||
| 231 | |||
| 229 | picref->video->w = w; | 232 | picref->video->w = w; |
| 230 | picref->video->h = h; | 233 | picref->video->h = h; |
| 231 | 234 | ||
| @@ -259,12 +262,15 @@ static int does_clip(PadContext *pad, AVFilterBufferRef *outpicref, int plane, i · 27 unmodified lines | |||
| 259 | return 0; | 262 | return 0; |
| 260 | } | 263 | } |
| 261 | 264 | ||
| 262 | static void start_frame(AVFilterLink *inlink, AVFilterBufferRef *inpicref) | 265 | static int start_frame(AVFilterLink *inlink, AVFilterBufferRef *inpicref) |
| 263 | { | 266 | { |
| 264 | PadContext *pad = inlink->dst->priv; | 267 | PadContext *pad = inlink->dst->priv; |
| 265 | AVFilterBufferRef *outpicref = avfilter_ref_buffer(inpicref, ~0); | 268 | AVFilterBufferRef *outpicref = avfilter_ref_buffer(inpicref, ~0); |
| 266 | AVFilterBufferRef *for_next_filter; | 269 | AVFilterBufferRef *for_next_filter; |
| 267 | int plane; | 270 | int plane, ret = 0; |
| 271 | |||
| 272 | if (!outpicref) | ||
| 273 | return AVERROR(ENOMEM); | ||
| 268 | 274 | ||
| 269 | for (plane = 0; plane < 4 && outpicref->data[plane] && pad->draw.pixelstep[plane]; plane++) { | 275 | for (plane = 0; plane < 4 && outpicref->data[plane] && pad->draw.pixelstep[plane]; plane++) { |
| 270 | int hsub = pad->draw.hsub[plane]; | 276 | int hsub = pad->draw.hsub[plane]; |
| @@ -292,22 +298,37 @@ static void start_frame(AVFilterLink *inlink, AVFilterBufferRef *inpicref) · 21 unmodified lines | |||
| 292 | outpicref = ff_get_video_buffer(inlink->dst->outputs[0], AV_PERM_WRITE | AV_PERM_NEG_LINESIZES, | 298 | outpicref = ff_get_video_buffer(inlink->dst->outputs[0], AV_PERM_WRITE | AV_PERM_NEG_LINESIZES, |
| 293 | FFMAX(inlink->w, pad->w), | 299 | FFMAX(inlink->w, pad->w), |
| 294 | FFMAX(inlink->h, pad->h)); | 300 | FFMAX(inlink->h, pad->h)); |
| 301 | if (!outpicref) | ||
| 302 | return AVERROR(ENOMEM); | ||
| 303 | |||
| 295 | avfilter_copy_buffer_ref_props(outpicref, inpicref); | 304 | avfilter_copy_buffer_ref_props(outpicref, inpicref); |
| 296 | } | 305 | } |
| 297 | 306 | ||
| 298 | inlink->dst->outputs[0]->out_buf = outpicref; | ||
| 299 | |||
| 300 | outpicref->video->w = pad->w; | 307 | outpicref->video->w = pad->w; |
| 301 | outpicref->video->h = pad->h; | 308 | outpicref->video->h = pad->h; |
| 302 | 309 | ||
| 303 | for_next_filter = avfilter_ref_buffer(outpicref, ~0); | 310 | for_next_filter = avfilter_ref_buffer(outpicref, ~0); |
| 304 | ff_start_frame(inlink->dst->outputs[0], for_next_filter); | 311 | if (!for_next_filter) { |
| 312 | ret = AVERROR(ENOMEM); | ||
| 313 | goto fail; | ||
| 314 | } | ||
| 315 | |||
| 316 | ret = ff_start_frame(inlink->dst->outputs[0], for_next_filter); | ||
| 317 | if (ret < 0) | ||
| 318 | goto fail; | ||
| 319 | |||
| 320 | inlink->dst->outputs[0]->out_buf = outpicref; | ||
| 321 | return 0; | ||
| 322 | |||
| 323 | fail: | ||
| 324 | avfilter_unref_bufferp(&outpicref); | ||
| 325 | return ret; | ||
| 305 | } | 326 | } |
| 306 | 327 | ||
| 307 | static void draw_send_bar_slice(AVFilterLink *link, int y, int h, int slice_dir, int before_slice) | 328 | static int draw_send_bar_slice(AVFilterLink *link, int y, int h, int slice_dir, int before_slice) |
| 308 | { | 329 | { |
| 309 | PadContext *pad = link->dst->priv; | 330 | PadContext *pad = link->dst->priv; |
| 310 | int bar_y, bar_h = 0; | 331 | int bar_y, bar_h = 0, ret = 0; |
| 311 | 332 | ||
| 312 | if (slice_dir * before_slice == 1 && y == pad->y) { | 333 | if (slice_dir * before_slice == 1 && y == pad->y) { |
| 313 | /* top bar */ | 334 | /* top bar */ |
| @@ -324,15 +345,17 @@ static void draw_send_bar_slice(AVFilterLink *link, int y, int h, int slice_dir, · 10 unmodified lines | |||
| 324 | link->dst->outputs[0]->out_buf->data, | 345 | link->dst->outputs[0]->out_buf->data, |
| 325 | link->dst->outputs[0]->out_buf->linesize, | 346 | link->dst->outputs[0]->out_buf->linesize, |
| 326 | 0, bar_y, pad->w, bar_h); | 347 | 0, bar_y, pad->w, bar_h); |
| 327 | ff_draw_slice(link->dst->outputs[0], bar_y, bar_h, slice_dir); | 348 | ret = ff_draw_slice(link->dst->outputs[0], bar_y, bar_h, slice_dir); |
| 328 | } | 349 | } |
| 350 | return ret; | ||
| 329 | } | 351 | } |
| 330 | 352 | ||
| 331 | static void draw_slice(AVFilterLink *link, int y, int h, int slice_dir) | 353 | static int draw_slice(AVFilterLink *link, int y, int h, int slice_dir) |
| 332 | { | 354 | { |
| 333 | PadContext *pad = link->dst->priv; | 355 | PadContext *pad = link->dst->priv; |
| 334 | AVFilterBufferRef *outpic = link->dst->outputs[0]->out_buf; | 356 | AVFilterBufferRef *outpic = link->dst->outputs[0]->out_buf; |
| 335 | AVFilterBufferRef *inpic = link->cur_buf; | 357 | AVFilterBufferRef *inpic = link->cur_buf; |
| 358 | int ret; | ||
| 336 | 359 | ||
| 337 | y += pad->y; | 360 | y += pad->y; |
| 338 | 361 | ||
| @@ -340,7 +363,7 @@ static void draw_slice(AVFilterLink *link, int y, int h, int slice_dir) · 1 unmodified line | |||
| 340 | h = ff_draw_round_to_sub(&pad->draw, 1, -1, h); | 363 | h = ff_draw_round_to_sub(&pad->draw, 1, -1, h); |
| 341 | 364 | ||
| 342 | if (!h) | 365 | if (!h) |
| 343 | return; | 366 | return 0; |
| 344 | draw_send_bar_slice(link, y, h, slice_dir, 1); | 367 | draw_send_bar_slice(link, y, h, slice_dir, 1); |
| 345 | 368 | ||
| 346 | /* left border */ | 369 | /* left border */ |
| @@ -357,9 +380,11 @@ static void draw_slice(AVFilterLink *link, int y, int h, int slice_dir) · 10 unmodified lines | |||
| 357 | /* right border */ | 380 | /* right border */ |
| 358 | ff_fill_rectangle(&pad->draw, &pad->color, outpic->data, outpic->linesize, | 381 | ff_fill_rectangle(&pad->draw, &pad->color, outpic->data, outpic->linesize, |
| 359 | pad->x + pad->in_w, y, pad->w - pad->x - pad->in_w, h); | 382 | pad->x + pad->in_w, y, pad->w - pad->x - pad->in_w, h); |
| 360 | ff_draw_slice(link->dst->outputs[0], y, h, slice_dir); | 383 | ret = ff_draw_slice(link->dst->outputs[0], y, h, slice_dir); |
| 384 | if (ret < 0) | ||
| 385 | return ret; | ||
| 361 | 386 | ||
| 362 | draw_send_bar_slice(link, y, h, slice_dir, -1); | 387 | return draw_send_bar_slice(link, y, h, slice_dir, -1); |
| 363 | } | 388 | } |
| 364 | 389 | ||
| 365 | AVFilter avfilter_vf_pad = { | 390 | AVFilter avfilter_vf_pad = { |
| @@ -51,16 +51,18 @@ static int config_props(AVFilterLink *inlink) · 50 unmodified lines | |||
| 51 | return 0; | 51 | return 0; |
| 52 | } | 52 | } |
| 53 | 53 | ||
| 54 | static void start_frame(AVFilterLink *inlink, AVFilterBufferRef *picref) | 54 | static int start_frame(AVFilterLink *inlink, AVFilterBufferRef *picref) |
| 55 | { | 55 | { |
| 56 | PixdescTestContext *priv = inlink->dst->priv; | 56 | PixdescTestContext *priv = inlink->dst->priv; |
| 57 | AVFilterLink *outlink = inlink->dst->outputs[0]; | 57 | AVFilterLink *outlink = inlink->dst->outputs[0]; |
| 58 | AVFilterBufferRef *outpicref; | 58 | AVFilterBufferRef *outpicref, *for_next_filter; |
| 59 | int i; | 59 | int i, ret = 0; |
| 60 | |||
| 61 | outpicref = ff_get_video_buffer(outlink, AV_PERM_WRITE, | ||
| 62 | outlink->w, outlink->h); | ||
| 63 | if (!outpicref) | ||
| 64 | return AVERROR(ENOMEM); | ||
| 60 | 65 | ||
| 61 | outlink->out_buf = ff_get_video_buffer(outlink, AV_PERM_WRITE, | ||
| 62 | outlink->w, outlink->h); | ||
| 63 | outpicref = outlink->out_buf; | ||
| 64 | avfilter_copy_buffer_ref_props(outpicref, picref); | 66 | avfilter_copy_buffer_ref_props(outpicref, picref); |
| 65 | 67 | ||
| 66 | for (i = 0; i < 4; i++) { | 68 | for (i = 0; i < 4; i++) { |
| @@ -78,10 +80,22 @@ static void start_frame(AVFilterLink *inlink, AVFilterBufferRef *picref) · 11 unmodified lines | |||
| 78 | priv->pix_desc->flags & PIX_FMT_PSEUDOPAL) | 80 | priv->pix_desc->flags & PIX_FMT_PSEUDOPAL) |
| 79 | memcpy(outpicref->data[1], picref->data[1], AVPALETTE_SIZE); | 81 | memcpy(outpicref->data[1], picref->data[1], AVPALETTE_SIZE); |
| 80 | 82 | ||
| 81 | ff_start_frame(outlink, avfilter_ref_buffer(outpicref, ~0)); | 83 | for_next_filter = avfilter_ref_buffer(outpicref, ~0); |
| 84 | if (for_next_filter) | ||
| 85 | ret = ff_start_frame(outlink, for_next_filter); | ||
| 86 | else | ||
| 87 | ret = AVERROR(ENOMEM); | ||
| 88 | |||
| 89 | if (ret < 0) { | ||
| 90 | avfilter_unref_bufferp(&outpicref); | ||
| 91 | return ret; | ||
| 92 | } | ||
| 93 | |||
| 94 | outlink->out_buf = outpicref; | ||
| 95 | return 0; | ||
| 82 | } | 96 | } |
| 83 | 97 | ||
| 84 | static void draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir) | 98 | static int draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir) |
| 85 | { | 99 | { |
| 86 | PixdescTestContext *priv = inlink->dst->priv; | 100 | PixdescTestContext *priv = inlink->dst->priv; |
| 87 | AVFilterBufferRef *inpic = inlink->cur_buf; | 101 | AVFilterBufferRef *inpic = inlink->cur_buf; |
| @@ -108,7 +122,7 @@ static void draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir) · 20 unmodified lines | |||
| 108 | } | 122 | } |
| 109 | } | 123 | } |
| 110 | 124 | ||
| 111 | ff_draw_slice(inlink->dst->outputs[0], y, h, slice_dir); | 125 | return ff_draw_slice(inlink->dst->outputs[0], y, h, slice_dir); |
| 112 | } | 126 | } |
| 113 | 127 | ||
| 114 | AVFilter avfilter_vf_pixdesctest = { | 128 | AVFilter avfilter_vf_pixdesctest = { |
| @@ -472,7 +472,7 @@ static void blur_image(int ***mask, · 471 unmodified lines | |||
| 472 | } | 472 | } |
| 473 | } | 473 | } |
| 474 | 474 | ||
| 475 | static void start_frame(AVFilterLink *inlink, AVFilterBufferRef *inpicref) | 475 | static int start_frame(AVFilterLink *inlink, AVFilterBufferRef *inpicref) |
| 476 | { | 476 | { |
| 477 | AVFilterLink *outlink = inlink->dst->outputs[0]; | 477 | AVFilterLink *outlink = inlink->dst->outputs[0]; |
| 478 | AVFilterBufferRef *outpicref; | 478 | AVFilterBufferRef *outpicref; |
| @@ -487,10 +487,10 @@ static void start_frame(AVFilterLink *inlink, AVFilterBufferRef *inpicref) · 8 unmodified lines | |||
| 487 | outpicref = inpicref; | 487 | outpicref = inpicref; |
| 488 | 488 | ||
| 489 | outlink->out_buf = outpicref; | 489 | outlink->out_buf = outpicref; |
| 490 | ff_start_frame(outlink, avfilter_ref_buffer(outpicref, ~0)); | 490 | return ff_start_frame(outlink, avfilter_ref_buffer(outpicref, ~0)); |
| 491 | } | 491 | } |
| 492 | 492 | ||
| 493 | static void end_frame(AVFilterLink *inlink) | 493 | static int end_frame(AVFilterLink *inlink) |
| 494 | { | 494 | { |
| 495 | RemovelogoContext *removelogo = inlink->dst->priv; | 495 | RemovelogoContext *removelogo = inlink->dst->priv; |
| 496 | AVFilterLink *outlink = inlink->dst->outputs[0]; | 496 | AVFilterLink *outlink = inlink->dst->outputs[0]; |
| @@ -515,7 +515,7 @@ static void end_frame(AVFilterLink *inlink) · 18 unmodified lines | |||
| 515 | inlink->w/2, inlink->h/2, direct, &removelogo->half_mask_bbox); | 515 | inlink->w/2, inlink->h/2, direct, &removelogo->half_mask_bbox); |
| 516 | 516 | ||
| 517 | ff_draw_slice(outlink, 0, inlink->h, 1); | 517 | ff_draw_slice(outlink, 0, inlink->h, 1); |
| 518 | ff_end_frame(outlink); | 518 | return ff_end_frame(outlink); |
| 519 | } | 519 | } |
| 520 | 520 | ||
| 521 | static void uninit(AVFilterContext *ctx) | 521 | static void uninit(AVFilterContext *ctx) |
| @@ -540,7 +540,7 @@ static void uninit(AVFilterContext *ctx) · 18 unmodified lines | |||
| 540 | } | 540 | } |
| 541 | } | 541 | } |
| 542 | 542 | ||
| 543 | static void null_draw_slice(AVFilterLink *link, int y, int h, int slice_dir) { } | 543 | static int null_draw_slice(AVFilterLink *link, int y, int h, int slice_dir) { return 0; } |
| 544 | 544 | ||
| 545 | AVFilter avfilter_vf_removelogo = { | 545 | AVFilter avfilter_vf_removelogo = { |
| 546 | .name = "removelogo", | 546 | .name = "removelogo", |
| @@ -272,11 +272,12 @@ fail: · 271 unmodified lines | |||
| 272 | return ret; | 272 | return ret; |
| 273 | } | 273 | } |
| 274 | 274 | ||
| 275 | static void start_frame(AVFilterLink *link, AVFilterBufferRef *picref) | 275 | static int start_frame(AVFilterLink *link, AVFilterBufferRef *picref) |
| 276 | { | 276 | { |
| 277 | ScaleContext *scale = link->dst->priv; | 277 | ScaleContext *scale = link->dst->priv; |
| 278 | AVFilterLink *outlink = link->dst->outputs[0]; | 278 | AVFilterLink *outlink = link->dst->outputs[0]; |
| 279 | AVFilterBufferRef *outpicref; | 279 | AVFilterBufferRef *outpicref, *for_next_filter; |
| 280 | int ret = 0; | ||
| 280 | 281 | ||
| 281 | if( picref->video->w != link->w | 282 | if( picref->video->w != link->w |
| 282 | || picref->video->h != link->h | 283 | || picref->video->h != link->h |
| @@ -295,19 +296,23 @@ static void start_frame(AVFilterLink *link, AVFilterBufferRef *picref) · 12 unmodified lines | |||
| 295 | 296 | ||
| 296 | 297 | ||
| 297 | if (!scale->sws) { | 298 | if (!scale->sws) { |
| 298 | ff_start_frame(outlink, avfilter_ref_buffer(picref, ~0)); | 299 | outpicref = avfilter_ref_buffer(picref, ~0); |
| 299 | return; | 300 | if (!outpicref) |
| 301 | return AVERROR(ENOMEM); | ||
| 302 | return ff_start_frame(outlink, outpicref); | ||
| 300 | } | 303 | } |
| 301 | 304 | ||
| 302 | scale->hsub = av_pix_fmt_descriptors[link->format].log2_chroma_w; | 305 | scale->hsub = av_pix_fmt_descriptors[link->format].log2_chroma_w; |
| 303 | scale->vsub = av_pix_fmt_descriptors[link->format].log2_chroma_h; | 306 | scale->vsub = av_pix_fmt_descriptors[link->format].log2_chroma_h; |
| 304 | 307 | ||
| 305 | outpicref = ff_get_video_buffer(outlink, AV_PERM_WRITE|AV_PERM_ALIGN, outlink->w, outlink->h); | 308 | outpicref = ff_get_video_buffer(outlink, AV_PERM_WRITE|AV_PERM_ALIGN, outlink->w, outlink->h); |
| 309 | if (!outpicref) | ||
| 310 | return AVERROR(ENOMEM); | ||
| 311 | |||
| 306 | avfilter_copy_buffer_ref_props(outpicref, picref); | 312 | avfilter_copy_buffer_ref_props(outpicref, picref); |
| 307 | outpicref->video->w = outlink->w; | 313 | outpicref->video->w = outlink->w; |
| 308 | outpicref->video->h = outlink->h; | 314 | outpicref->video->h = outlink->h; |
| 309 | 315 | ||
| 310 | outlink->out_buf = outpicref; | ||
| 311 | if(scale->output_is_pal) | 316 | if(scale->output_is_pal) |
| 312 | ff_set_systematic_pal2(outpicref->data[1], outlink->format == PIX_FMT_PAL8 ? PIX_FMT_BGR8 : outlink->format); | 317 | ff_set_systematic_pal2(outpicref->data[1], outlink->format == PIX_FMT_PAL8 ? PIX_FMT_BGR8 : outlink->format); |
| 313 | 318 | ||
| @@ -317,7 +322,19 @@ static void start_frame(AVFilterLink *link, AVFilterBufferRef *picref) · 3 unmodified lines | |||
| 317 | INT_MAX); | 322 | INT_MAX); |
| 318 | 323 | ||
| 319 | scale->slice_y = 0; | 324 | scale->slice_y = 0; |
| 320 | ff_start_frame(outlink, avfilter_ref_buffer(outpicref, ~0)); | 325 | for_next_filter = avfilter_ref_buffer(outpicref, ~0); |
| 326 | if (for_next_filter) | ||
| 327 | ret = ff_start_frame(outlink, for_next_filter); | ||
| 328 | else | ||
| 329 | ret = AVERROR(ENOMEM); | ||
| 330 | |||
| 331 | if (ret < 0) { | ||
| 332 | avfilter_unref_bufferp(&outpicref); | ||
| 333 | return ret; | ||
| 334 | } | ||
| 335 | |||
| 336 | outlink->out_buf = outpicref; | ||
| 337 | return 0; | ||
| 321 | } | 338 | } |
| 322 | 339 | ||
| 323 | static int scale_slice(AVFilterLink *link, struct SwsContext *sws, int y, int h, int mul, int field) | 340 | static int scale_slice(AVFilterLink *link, struct SwsContext *sws, int y, int h, int mul, int field) |
| @@ -346,14 +363,13 @@ static int scale_slice(AVFilterLink *link, struct SwsContext *sws, int y, int h, · 22 unmodified lines | |||
| 346 | out,out_stride); | 363 | out,out_stride); |
| 347 | } | 364 | } |
| 348 | 365 | ||
| 349 | static void draw_slice(AVFilterLink *link, int y, int h, int slice_dir) | 366 | static int draw_slice(AVFilterLink *link, int y, int h, int slice_dir) |
| 350 | { | 367 | { |
| 351 | ScaleContext *scale = link->dst->priv; | 368 | ScaleContext *scale = link->dst->priv; |
| 352 | int out_h; | 369 | int out_h, ret; |
| 353 | 370 | ||
| 354 | if (!scale->sws) { | 371 | if (!scale->sws) { |
| 355 | ff_draw_slice(link->dst->outputs[0], y, h, slice_dir); | 372 | return ff_draw_slice(link->dst->outputs[0], y, h, slice_dir); |
| 356 | return; | ||
| 357 | } | 373 | } |
| 358 | 374 | ||
| 359 | if (scale->slice_y == 0 && slice_dir == -1) | 375 | if (scale->slice_y == 0 && slice_dir == -1) |
| @@ -369,9 +385,10 @@ static void draw_slice(AVFilterLink *link, int y, int h, int slice_dir) · 9 unmodified lines | |||
| 369 | 385 | ||
| 370 | if (slice_dir == -1) | 386 | if (slice_dir == -1) |
| 371 | scale->slice_y -= out_h; | 387 | scale->slice_y -= out_h; |
| 372 | ff_draw_slice(link->dst->outputs[0], scale->slice_y, out_h, slice_dir); | 388 | ret = ff_draw_slice(link->dst->outputs[0], scale->slice_y, out_h, slice_dir); |
| 373 | if (slice_dir == 1) | 389 | if (slice_dir == 1) |
| 374 | scale->slice_y += out_h; | 390 | scale->slice_y += out_h; |
| 391 | return ret; | ||
| 375 | } | 392 | } |
| 376 | 393 | ||
| 377 | AVFilter avfilter_vf_scale = { | 394 | AVFilter avfilter_vf_scale = { |
| @@ -269,12 +269,13 @@ static int select_frame(AVFilterContext *ctx, AVFilterBufferRef *picref) · 268 unmodified lines | |||
| 269 | return res; | 269 | return res; |
| 270 | } | 270 | } |
| 271 | 271 | ||
| 272 | static void start_frame(AVFilterLink *inlink, AVFilterBufferRef *picref) | 272 | static int start_frame(AVFilterLink *inlink, AVFilterBufferRef *picref) |
| 273 | { | 273 | { |
| 274 | SelectContext *select = inlink->dst->priv; | 274 | SelectContext *select = inlink->dst->priv; |
| 275 | 275 | ||
| 276 | select->select = select_frame(inlink->dst, picref); | 276 | select->select = select_frame(inlink->dst, picref); |
| 277 | if (select->select) { | 277 | if (select->select) { |
| 278 | AVFilterBufferRef *buf_out; | ||
| 278 | /* frame was requested through poll_frame */ | 279 | /* frame was requested through poll_frame */ |
| 279 | if (select->cache_frames) { | 280 | if (select->cache_frames) { |
| 280 | if (!av_fifo_space(select->pending_frames)) | 281 | if (!av_fifo_space(select->pending_frames)) |
| @@ -283,29 +284,36 @@ static void start_frame(AVFilterLink *inlink, AVFilterBufferRef *picref) · 2 unmodified lines | |||
| 283 | else | 284 | else |
| 284 | av_fifo_generic_write(select->pending_frames, &picref, | 285 | av_fifo_generic_write(select->pending_frames, &picref, |
| 285 | sizeof(picref), NULL); | 286 | sizeof(picref), NULL); |
| 286 | return; | 287 | return 0; |
| 287 | } | 288 | } |
| 288 | ff_start_frame(inlink->dst->outputs[0], avfilter_ref_buffer(picref, ~0)); | 289 | buf_out = avfilter_ref_buffer(picref, ~0); |
| 290 | if (!buf_out) | ||
| 291 | return AVERROR(ENOMEM); | ||
| 292 | return ff_start_frame(inlink->dst->outputs[0], buf_out); | ||
| 289 | } | 293 | } |
| 294 | |||
| 295 | return 0; | ||
| 290 | } | 296 | } |
| 291 | 297 | ||
| 292 | static void draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir) | 298 | static int draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir) |
| 293 | { | 299 | { |
| 294 | SelectContext *select = inlink->dst->priv; | 300 | SelectContext *select = inlink->dst->priv; |
| 295 | 301 | ||
| 296 | if (select->select && !select->cache_frames) | 302 | if (select->select && !select->cache_frames) |
| 297 | ff_draw_slice(inlink->dst->outputs[0], y, h, slice_dir); | 303 | return ff_draw_slice(inlink->dst->outputs[0], y, h, slice_dir); |
| 304 | return 0; | ||
| 298 | } | 305 | } |
| 299 | 306 | ||
| 300 | static void end_frame(AVFilterLink *inlink) | 307 | static int end_frame(AVFilterLink *inlink) |
| 301 | { | 308 | { |
| 302 | SelectContext *select = inlink->dst->priv; | 309 | SelectContext *select = inlink->dst->priv; |
| 303 | 310 | ||
| 304 | if (select->select) { | 311 | if (select->select) { |
| 305 | if (select->cache_frames) | 312 | if (select->cache_frames) |
| 306 | return; | 313 | return 0; |
| 307 | ff_end_frame(inlink->dst->outputs[0]); | 314 | return ff_end_frame(inlink->dst->outputs[0]); |
| 308 | } | 315 | } |
| 316 | return 0; | ||
| 309 | } | 317 | } |
| 310 | 318 | ||
| 311 | static int request_frame(AVFilterLink *outlink) | 319 | static int request_frame(AVFilterLink *outlink) |
| @@ -317,12 +325,14 @@ static int request_frame(AVFilterLink *outlink) · 5 unmodified lines | |||
| 317 | 325 | ||
| 318 | if (av_fifo_size(select->pending_frames)) { | 326 | if (av_fifo_size(select->pending_frames)) { |
| 319 | AVFilterBufferRef *picref; | 327 | AVFilterBufferRef *picref; |
| 328 | int ret; | ||
| 329 | |||
| 320 | av_fifo_generic_read(select->pending_frames, &picref, sizeof(picref), NULL); | 330 | av_fifo_generic_read(select->pending_frames, &picref, sizeof(picref), NULL); |
| 321 | ff_start_frame(outlink, avfilter_ref_buffer(picref, ~0)); | 331 | if ((ret = ff_start_frame(outlink, picref)) < 0 || |
| 322 | ff_draw_slice(outlink, 0, outlink->h, 1); | 332 | (ret = ff_draw_slice(outlink, 0, outlink->h, 1)) < 0 || |
| 323 | ff_end_frame(outlink); | 333 | (ret = ff_end_frame(outlink)) < 0); |
| 324 | avfilter_unref_buffer(picref); | 334 | |
| 325 | return 0; | 335 | return ret; |
| 326 | } | 336 | } |
| 327 | 337 | ||
| 328 | while (!select->select) { | 338 | while (!select->select) { |
| @@ -69,7 +69,7 @@ static av_cold int init(AVFilterContext *ctx, const char *args) · 68 unmodified lines | |||
| 69 | return 0; | 69 | return 0; |
| 70 | } | 70 | } |
| 71 | 71 | ||
| 72 | static void start_frame(AVFilterLink *inlink, AVFilterBufferRef *inpicref) | 72 | static int start_frame(AVFilterLink *inlink, AVFilterBufferRef *inpicref) |
| 73 | { | 73 | { |
| 74 | SetFieldContext *setfield = inlink->dst->priv; | 74 | SetFieldContext *setfield = inlink->dst->priv; |
| 75 | AVFilterBufferRef *outpicref = avfilter_ref_buffer(inpicref, ~0); | 75 | AVFilterBufferRef *outpicref = avfilter_ref_buffer(inpicref, ~0); |
| @@ -80,7 +80,7 @@ static void start_frame(AVFilterLink *inlink, AVFilterBufferRef *inpicref) · 4 unmodified lines | |||
| 80 | outpicref->video->interlaced = 1; | 80 | outpicref->video->interlaced = 1; |
| 81 | outpicref->video->top_field_first = setfield->mode; | 81 | outpicref->video->top_field_first = setfield->mode; |
| 82 | } | 82 | } |
| 83 | ff_start_frame(inlink->dst->outputs[0], outpicref); | 83 | return ff_start_frame(inlink->dst->outputs[0], outpicref); |
| 84 | } | 84 | } |
| 85 | 85 | ||
| 86 | AVFilter avfilter_vf_setfield = { | 86 | AVFilter avfilter_vf_setfield = { |
| @@ -92,12 +92,15 @@ static int config_input(AVFilterLink *inlink) · 91 unmodified lines | |||
| 92 | #define D2TS(d) (isnan(d) ? AV_NOPTS_VALUE : (int64_t)(d)) | 92 | #define D2TS(d) (isnan(d) ? AV_NOPTS_VALUE : (int64_t)(d)) |
| 93 | #define TS2D(ts) ((ts) == AV_NOPTS_VALUE ? NAN : (double)(ts)) | 93 | #define TS2D(ts) ((ts) == AV_NOPTS_VALUE ? NAN : (double)(ts)) |
| 94 | 94 | ||
| 95 | static void start_frame(AVFilterLink *inlink, AVFilterBufferRef *inpicref) | 95 | static int start_frame(AVFilterLink *inlink, AVFilterBufferRef *inpicref) |
| 96 | { | 96 | { |
| 97 | SetPTSContext *setpts = inlink->dst->priv; | 97 | SetPTSContext *setpts = inlink->dst->priv; |
| 98 | double d; | 98 | double d; |
| 99 | AVFilterBufferRef *outpicref = avfilter_ref_buffer(inpicref, ~0); | 99 | AVFilterBufferRef *outpicref = avfilter_ref_buffer(inpicref, ~0); |
| 100 | 100 | ||
| 101 | if (!outpicref) | ||
| 102 | return AVERROR(ENOMEM); | ||
| 103 | |||
| 101 | if (isnan(setpts->var_values[VAR_STARTPTS])) | 104 | if (isnan(setpts->var_values[VAR_STARTPTS])) |
| 102 | setpts->var_values[VAR_STARTPTS] = TS2D(inpicref->pts); | 105 | setpts->var_values[VAR_STARTPTS] = TS2D(inpicref->pts); |
| 103 | 106 | ||
| @@ -121,7 +124,7 @@ static void start_frame(AVFilterLink *inlink, AVFilterBufferRef *inpicref) · 17 unmodified lines | |||
| 121 | setpts->var_values[VAR_N] += 1.0; | 124 | setpts->var_values[VAR_N] += 1.0; |
| 122 | setpts->var_values[VAR_PREV_INPTS ] = TS2D(inpicref ->pts); | 125 | setpts->var_values[VAR_PREV_INPTS ] = TS2D(inpicref ->pts); |
| 123 | setpts->var_values[VAR_PREV_OUTPTS] = TS2D(outpicref->pts); | 126 | setpts->var_values[VAR_PREV_OUTPTS] = TS2D(outpicref->pts); |
| 124 | ff_start_frame(inlink->dst->outputs[0], outpicref); | 127 | return ff_start_frame(inlink->dst->outputs[0], outpicref); |
| 125 | } | 128 | } |
| 126 | 129 | ||
| 127 | static av_cold void uninit(AVFilterContext *ctx) | 130 | static av_cold void uninit(AVFilterContext *ctx) |
| @@ -41,7 +41,7 @@ static av_cold int init(AVFilterContext *ctx, const char *args) · 40 unmodified lines | |||
| 41 | return 0; | 41 | return 0; |
| 42 | } | 42 | } |
| 43 | 43 | ||
| 44 | static void end_frame(AVFilterLink *inlink) | 44 | static int end_frame(AVFilterLink *inlink) |
| 45 | { | 45 | { |
| 46 | AVFilterContext *ctx = inlink->dst; | 46 | AVFilterContext *ctx = inlink->dst; |
| 47 | ShowInfoContext *showinfo = ctx->priv; | 47 | ShowInfoContext *showinfo = ctx->priv; |
| @@ -81,7 +81,7 @@ static void end_frame(AVFilterLink *inlink) · 33 unmodified lines | |||
| 81 | av_log(ctx, AV_LOG_INFO, "]\n"); | 81 | av_log(ctx, AV_LOG_INFO, "]\n"); |
| 82 | 82 | ||
| 83 | showinfo->frame++; | 83 | showinfo->frame++; |
| 84 | ff_end_frame(inlink->dst->outputs[0]); | 84 | return ff_end_frame(inlink->dst->outputs[0]); |
| 85 | } | 85 | } |
| 86 | 86 | ||
| 87 | AVFilter avfilter_vf_showinfo = { | 87 | AVFilter avfilter_vf_showinfo = { |
| @@ -59,7 +59,7 @@ static int config_props(AVFilterLink *link) · 58 unmodified lines | |||
| 59 | return 0; | 59 | return 0; |
| 60 | } | 60 | } |
| 61 | 61 | ||
| 62 | static void start_frame(AVFilterLink *link, AVFilterBufferRef *picref) | 62 | static int start_frame(AVFilterLink *link, AVFilterBufferRef *picref) |
| 63 | { | 63 | { |
| 64 | SliceContext *slice = link->dst->priv; | 64 | SliceContext *slice = link->dst->priv; |
| 65 | 65 | ||
| @@ -75,27 +75,34 @@ static void start_frame(AVFilterLink *link, AVFilterBufferRef *picref) · 9 unmodified lines | |||
| 75 | av_log(link->dst, AV_LOG_DEBUG, "h:%d\n", slice->h); | 75 | av_log(link->dst, AV_LOG_DEBUG, "h:%d\n", slice->h); |
| 76 | link->cur_buf = NULL; | 76 | link->cur_buf = NULL; |
| 77 | 77 | ||
| 78 | ff_start_frame(link->dst->outputs[0], picref); | 78 | return ff_start_frame(link->dst->outputs[0], picref); |
| 79 | } | 79 | } |
| 80 | 80 | ||
| 81 | static void draw_slice(AVFilterLink *link, int y, int h, int slice_dir) | 81 | static int draw_slice(AVFilterLink *link, int y, int h, int slice_dir) |
| 82 | { | 82 | { |
| 83 | SliceContext *slice = link->dst->priv; | 83 | SliceContext *slice = link->dst->priv; |
| 84 | int y2; | 84 | int y2, ret = 0; |
| 85 | 85 | ||
| 86 | if (slice_dir == 1) { | 86 | if (slice_dir == 1) { |
| 87 | for (y2 = y; y2 + slice->h <= y + h; y2 += slice->h) | 87 | for (y2 = y; y2 + slice->h <= y + h; y2 += slice->h) { |
| 88 | ff_draw_slice(link->dst->outputs[0], y2, slice->h, slice_dir); | 88 | ret = ff_draw_slice(link->dst->outputs[0], y2, slice->h, slice_dir); |
| 89 | if (ret < 0) | ||
| 90 | return ret; | ||
| 91 | } | ||
| 89 | 92 | ||
| 90 | if (y2 < y + h) | 93 | if (y2 < y + h) |
| 91 | ff_draw_slice(link->dst->outputs[0], y2, y + h - y2, slice_dir); | 94 | return ff_draw_slice(link->dst->outputs[0], y2, y + h - y2, slice_dir); |
| 92 | } else if (slice_dir == -1) { | 95 | } else if (slice_dir == -1) { |
| 93 | for (y2 = y + h; y2 - slice->h >= y; y2 -= slice->h) | 96 | for (y2 = y + h; y2 - slice->h >= y; y2 -= slice->h) { |
| 94 | ff_draw_slice(link->dst->outputs[0], y2 - slice->h, slice->h, slice_dir); | 97 | ret = ff_draw_slice(link->dst->outputs[0], y2 - slice->h, slice->h, slice_dir); |
| 98 | if (ret < 0) | ||
| 99 | return ret; | ||
| 100 | } | ||
| 95 | 101 | ||
| 96 | if (y2 > y) | 102 | if (y2 > y) |
| 97 | ff_draw_slice(link->dst->outputs[0], y, y2 - y, slice_dir); | 103 | return ff_draw_slice(link->dst->outputs[0], y, y2 - y, slice_dir); |
| 98 | } | 104 | } |
| 105 | return 0; | ||
| 99 | } | 106 | } |
| 100 | 107 | ||
| 101 | AVFilter avfilter_vf_slicify = { | 108 | AVFilter avfilter_vf_slicify = { |
| @@ -302,9 +302,9 @@ static int config_output(AVFilterLink *outlink) · 301 unmodified lines | |||
| 302 | return 0; | 302 | return 0; |
| 303 | } | 303 | } |
| 304 | 304 | ||
| 305 | static void null_draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir) { } | 305 | static int null_draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir) { return 0; } |
| 306 | 306 | ||
| 307 | static void end_frame(AVFilterLink *inlink) | 307 | static int end_frame(AVFilterLink *inlink) |
| 308 | { | 308 | { |
| 309 | AVFilterLink *outlink = inlink->dst->outputs[0]; | 309 | AVFilterLink *outlink = inlink->dst->outputs[0]; |
| 310 | AVFilterBufferRef *inpicref = inlink->cur_buf; | 310 | AVFilterBufferRef *inpicref = inlink->cur_buf; |
| @@ -315,7 +315,7 @@ static void end_frame(AVFilterLink *inlink) · 4 unmodified lines | |||
| 315 | inlink->w, inlink->h); | 315 | inlink->w, inlink->h); |
| 316 | 316 | ||
| 317 | ff_draw_slice(outlink, 0, outlink->h, 1); | 317 | ff_draw_slice(outlink, 0, outlink->h, 1); |
| 318 | ff_end_frame(outlink); | 318 | return ff_end_frame(outlink); |
| 319 | } | 319 | } |
| 320 | 320 | ||
| 321 | AVFilter avfilter_vf_super2xsai = { | 321 | AVFilter avfilter_vf_super2xsai = { |
| @@ -46,7 +46,7 @@ static AVFilterBufferRef *get_video_buffer(AVFilterLink *link, int perms, · 45 unmodified lines | |||
| 46 | return picref; | 46 | return picref; |
| 47 | } | 47 | } |
| 48 | 48 | ||
| 49 | static void start_frame(AVFilterLink *link, AVFilterBufferRef *inpicref) | 49 | static int start_frame(AVFilterLink *link, AVFilterBufferRef *inpicref) |
| 50 | { | 50 | { |
| 51 | AVFilterBufferRef *outpicref = avfilter_ref_buffer(inpicref, ~0); | 51 | AVFilterBufferRef *outpicref = avfilter_ref_buffer(inpicref, ~0); |
| 52 | 52 | ||
| @@ -56,7 +56,7 @@ static void start_frame(AVFilterLink *link, AVFilterBufferRef *inpicref) · 3 unmodified lines | |||
| 56 | outpicref->linesize[1] = inpicref->linesize[2]; | 56 | outpicref->linesize[1] = inpicref->linesize[2]; |
| 57 | outpicref->linesize[2] = inpicref->linesize[1]; | 57 | outpicref->linesize[2] = inpicref->linesize[1]; |
| 58 | 58 | ||
| 59 | ff_start_frame(link->dst->outputs[0], outpicref); | 59 | return ff_start_frame(link->dst->outputs[0], outpicref); |
| 60 | } | 60 | } |
| 61 | 61 | ||
| 62 | static int query_formats(AVFilterContext *ctx) | 62 | static int query_formats(AVFilterContext *ctx) |
| @@ -68,7 +68,7 @@ static av_cold int init(AVFilterContext *ctx, const char *args) · 67 unmodified lines | |||
| 68 | return 0; | 68 | return 0; |
| 69 | } | 69 | } |
| 70 | 70 | ||
| 71 | static void draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir) | 71 | static int draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir) |
| 72 | { | 72 | { |
| 73 | int i, j; | 73 | int i, j; |
| 74 | AVFilterContext *ctx = inlink->dst; | 74 | AVFilterContext *ctx = inlink->dst; |
| @@ -86,6 +86,7 @@ static void draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir) · 11 unmodified lines | |||
| 86 | } | 86 | } |
| 87 | p += picref->linesize[0]; | 87 | p += picref->linesize[0]; |
| 88 | } | 88 | } |
| 89 | return 0; | ||
| 89 | } | 90 | } |
| 90 | 91 | ||
| 91 | /** | 92 | /** |
| @@ -106,7 +107,7 @@ static double frame_sum_square_err(const int *hist, const double *median) · 14 unmodified lines | |||
| 106 | return sum_sq_err; | 107 | return sum_sq_err; |
| 107 | } | 108 | } |
| 108 | 109 | ||
| 109 | static void end_frame(AVFilterLink *inlink) | 110 | static int end_frame(AVFilterLink *inlink) |
| 110 | { | 111 | { |
| 111 | int i, j, best_frame_idx = 0; | 112 | int i, j, best_frame_idx = 0; |
| 112 | double avg_hist[HIST_SIZE] = {0}, sq_err, min_sq_err = -1; | 113 | double avg_hist[HIST_SIZE] = {0}, sq_err, min_sq_err = -1; |
| @@ -122,7 +123,7 @@ static void end_frame(AVFilterLink *inlink) · 9 unmodified lines | |||
| 122 | // no selection until the buffer of N frames is filled up | 123 | // no selection until the buffer of N frames is filled up |
| 123 | if (thumb->n < thumb->n_frames - 1) { | 124 | if (thumb->n < thumb->n_frames - 1) { |
| 124 | thumb->n++; | 125 | thumb->n++; |
| 125 | return; | 126 | return 0; |
| 126 | } | 127 | } |
| 127 | 128 | ||
| 128 | // average histogram of the N frames | 129 | // average histogram of the N frames |
| @@ -156,7 +157,7 @@ static void end_frame(AVFilterLink *inlink) · 27 unmodified lines | |||
| 156 | ff_start_frame(outlink, picref); | 157 | ff_start_frame(outlink, picref); |
| 157 | thumb->frames[best_frame_idx].buf = NULL; | 158 | thumb->frames[best_frame_idx].buf = NULL; |
| 158 | ff_draw_slice(outlink, 0, inlink->h, 1); | 159 | ff_draw_slice(outlink, 0, inlink->h, 1); |
| 159 | ff_end_frame(outlink); | 160 | return ff_end_frame(outlink); |
| 160 | } | 161 | } |
| 161 | 162 | ||
| 162 | static av_cold void uninit(AVFilterContext *ctx) | 163 | static av_cold void uninit(AVFilterContext *ctx) |
| @@ -170,7 +171,7 @@ static av_cold void uninit(AVFilterContext *ctx) · 7 unmodified lines | |||
| 170 | av_freep(&thumb->frames); | 171 | av_freep(&thumb->frames); |
| 171 | } | 172 | } |
| 172 | 173 | ||
| 173 | static void null_start_frame(AVFilterLink *link, AVFilterBufferRef *picref) { } | 174 | static int null_start_frame(AVFilterLink *link, AVFilterBufferRef *picref) { return 0; } |
| 174 | 175 | ||
| 175 | static int request_frame(AVFilterLink *link) | 176 | static int request_frame(AVFilterLink *link) |
| 176 | { | 177 | { |
| @@ -96,23 +96,23 @@ static int config_props(AVFilterLink *outlink) · 95 unmodified lines | |||
| 96 | * buffers are fed to start_frame in the order they were obtained from | 96 | * buffers are fed to start_frame in the order they were obtained from |
| 97 | * get_buffer (think B-frames). */ | 97 | * get_buffer (think B-frames). */ |
| 98 | 98 | ||
| 99 | static void start_frame(AVFilterLink *inlink, AVFilterBufferRef *picref) | 99 | static int start_frame(AVFilterLink *inlink, AVFilterBufferRef *picref) |
| 100 | { | 100 | { |
| 101 | AVFilterContext *ctx = inlink->dst; | 101 | AVFilterContext *ctx = inlink->dst; |
| 102 | TileContext *tile = ctx->priv; | 102 | TileContext *tile = ctx->priv; |
| 103 | AVFilterLink *outlink = ctx->outputs[0]; | 103 | AVFilterLink *outlink = ctx->outputs[0]; |
| 104 | 104 | ||
| 105 | if (tile->current) | 105 | if (tile->current) |
| 106 | return; | 106 | return 0; |
| 107 | outlink->out_buf = ff_get_video_buffer(outlink, AV_PERM_WRITE, | 107 | outlink->out_buf = ff_get_video_buffer(outlink, AV_PERM_WRITE, |
| 108 | outlink->w, outlink->h); | 108 | outlink->w, outlink->h); |
| 109 | avfilter_copy_buffer_ref_props(outlink->out_buf, picref); | 109 | avfilter_copy_buffer_ref_props(outlink->out_buf, picref); |
| 110 | outlink->out_buf->video->w = outlink->w; | 110 | outlink->out_buf->video->w = outlink->w; |
| 111 | outlink->out_buf->video->h = outlink->h; | 111 | outlink->out_buf->video->h = outlink->h; |
| 112 | ff_start_frame(outlink, outlink->out_buf); | 112 | return ff_start_frame(outlink, outlink->out_buf); |
| 113 | } | 113 | } |
| 114 | 114 | ||
| 115 | static void draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir) | 115 | static int draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir) |
| 116 | { | 116 | { |
| 117 | AVFilterContext *ctx = inlink->dst; | 117 | AVFilterContext *ctx = inlink->dst; |
| 118 | TileContext *tile = ctx->priv; | 118 | TileContext *tile = ctx->priv; |
| @@ -126,6 +126,7 @@ static void draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir) · 7 unmodified lines | |||
| 126 | x0, y0 + y, 0, y, inlink->cur_buf->video->w, h); | 126 | x0, y0 + y, 0, y, inlink->cur_buf->video->w, h); |
| 127 | /* TODO if tile->w == 1 && slice_dir is always 1, we could draw_slice | 127 | /* TODO if tile->w == 1 && slice_dir is always 1, we could draw_slice |
| 128 | * immediately. */ | 128 | * immediately. */ |
| 129 | return 0; | ||
| 129 | } | 130 | } |
| 130 | 131 | ||
| 131 | static void draw_blank_frame(AVFilterContext *ctx) | 132 | static void draw_blank_frame(AVFilterContext *ctx) |
| @@ -153,14 +154,15 @@ static void end_last_frame(AVFilterContext *ctx) · 21 unmodified lines | |||
| 153 | tile->current = 0; | 154 | tile->current = 0; |
| 154 | } | 155 | } |
| 155 | 156 | ||
| 156 | static void end_frame(AVFilterLink *inlink) | 157 | static int end_frame(AVFilterLink *inlink) |
| 157 | { | 158 | { |
| 158 | AVFilterContext *ctx = inlink->dst; | 159 | AVFilterContext *ctx = inlink->dst; |
| 159 | TileContext *tile = ctx->priv; | 160 | TileContext *tile = ctx->priv; |
| 160 | 161 | ||
| 161 | avfilter_unref_buffer(inlink->cur_buf); | 162 | avfilter_unref_bufferp(&inlink->cur_buf); |
| 162 | if (++tile->current == tile->w * tile->h) | 163 | if (++tile->current == tile->w * tile->h) |
| 163 | end_last_frame(ctx); | 164 | end_last_frame(ctx); |
| 165 | return 0; | ||
| 164 | } | 166 | } |
| 165 | 167 | ||
| 166 | static int request_frame(AVFilterLink *outlink) | 168 | static int request_frame(AVFilterLink *outlink) |
| @@ -198,7 +198,7 @@ void copy_picture_field(uint8_t *dst[4], int dst_linesize[4], · 197 unmodified lines | |||
| 198 | } | 198 | } |
| 199 | } | 199 | } |
| 200 | 200 | ||
| 201 | static void start_frame(AVFilterLink *inlink, AVFilterBufferRef *picref) | 201 | static int start_frame(AVFilterLink *inlink, AVFilterBufferRef *picref) |
| 202 | { | 202 | { |
| 203 | AVFilterContext *ctx = inlink->dst; | 203 | AVFilterContext *ctx = inlink->dst; |
| 204 | TInterlaceContext *tinterlace = ctx->priv; | 204 | TInterlaceContext *tinterlace = ctx->priv; |
| @@ -206,9 +206,10 @@ static void start_frame(AVFilterLink *inlink, AVFilterBufferRef *picref) · 1 unmodified line | |||
| 206 | avfilter_unref_buffer(tinterlace->cur); | 206 | avfilter_unref_buffer(tinterlace->cur); |
| 207 | tinterlace->cur = tinterlace->next; | 207 | tinterlace->cur = tinterlace->next; |
| 208 | tinterlace->next = picref; | 208 | tinterlace->next = picref; |
| 209 | return 0; | ||
| 209 | } | 210 | } |
| 210 | 211 | ||
| 211 | static void end_frame(AVFilterLink *inlink) | 212 | static int end_frame(AVFilterLink *inlink) |
| 212 | { | 213 | { |
| 213 | AVFilterContext *ctx = inlink->dst; | 214 | AVFilterContext *ctx = inlink->dst; |
| 214 | AVFilterLink *outlink = ctx->outputs[0]; | 215 | AVFilterLink *outlink = ctx->outputs[0]; |
| @@ -220,7 +221,7 @@ static void end_frame(AVFilterLink *inlink) · 5 unmodified lines | |||
| 220 | 221 | ||
| 221 | /* we need at least two frames */ | 222 | /* we need at least two frames */ |
| 222 | if (!tinterlace->cur) | 223 | if (!tinterlace->cur) |
| 223 | return; | 224 | return 0; |
| 224 | 225 | ||
| 225 | switch (tinterlace->mode) { | 226 | switch (tinterlace->mode) { |
| 226 | case MODE_MERGE: /* move the odd frame into the upper field of the new image, even into | 227 | case MODE_MERGE: /* move the odd frame into the upper field of the new image, even into |
| @@ -324,6 +325,8 @@ static void end_frame(AVFilterLink *inlink) · 97 unmodified lines | |||
| 324 | ff_end_frame(outlink); | 325 | ff_end_frame(outlink); |
| 325 | 326 | ||
| 326 | tinterlace->frame++; | 327 | tinterlace->frame++; |
| 328 | |||
| 329 | return 0; | ||
| 327 | } | 330 | } |
| 328 | 331 | ||
| 329 | static int poll_frame(AVFilterLink *outlink) | 332 | static int poll_frame(AVFilterLink *outlink) |
| @@ -359,7 +362,7 @@ static int request_frame(AVFilterLink *outlink) · 29 unmodified lines | |||
| 359 | return 0; | 362 | return 0; |
| 360 | } | 363 | } |
| 361 | 364 | ||
| 362 | static void null_draw_slice(AVFilterLink *link, int y, int h, int slice_dir) { } | 365 | static int null_draw_slice(AVFilterLink *link, int y, int h, int slice_dir) { return 0; } |
| 363 | 366 | ||
| 364 | AVFilter avfilter_vf_tinterlace = { | 367 | AVFilter avfilter_vf_tinterlace = { |
| 365 | .name = "tinterlace", | 368 | .name = "tinterlace", |
| @@ -114,12 +114,16 @@ static int config_props_output(AVFilterLink *outlink) · 113 unmodified lines | |||
| 114 | return 0; | 114 | return 0; |
| 115 | } | 115 | } |
| 116 | 116 | ||
| 117 | static void start_frame(AVFilterLink *inlink, AVFilterBufferRef *picref) | 117 | static int start_frame(AVFilterLink *inlink, AVFilterBufferRef *picref) |
| 118 | { | 118 | { |
| 119 | AVFilterLink *outlink = inlink->dst->outputs[0]; | 119 | AVFilterLink *outlink = inlink->dst->outputs[0]; |
| 120 | AVFilterBufferRef *buf_out; | ||
| 120 | 121 | ||
| 121 | outlink->out_buf = ff_get_video_buffer(outlink, AV_PERM_WRITE, | 122 | outlink->out_buf = ff_get_video_buffer(outlink, AV_PERM_WRITE, |
| 122 | outlink->w, outlink->h); | 123 | outlink->w, outlink->h); |
| 124 | if (!outlink->out_buf) | ||
| 125 | return AVERROR(ENOMEM); | ||
| 126 | |||
| 123 | outlink->out_buf->pts = picref->pts; | 127 | outlink->out_buf->pts = picref->pts; |
| 124 | 128 | ||
| 125 | if (picref->video->sample_aspect_ratio.num == 0) { | 129 | if (picref->video->sample_aspect_ratio.num == 0) { |
| @@ -129,16 +133,19 @@ static void start_frame(AVFilterLink *inlink, AVFilterBufferRef *picref) · 3 unmodified lines | |||
| 129 | outlink->out_buf->video->sample_aspect_ratio.den = picref->video->sample_aspect_ratio.num; | 133 | outlink->out_buf->video->sample_aspect_ratio.den = picref->video->sample_aspect_ratio.num; |
| 130 | } | 134 | } |
| 131 | 135 | ||
| 132 | ff_start_frame(outlink, avfilter_ref_buffer(outlink->out_buf, ~0)); | 136 | buf_out = avfilter_ref_buffer(outlink->out_buf, ~0); |
| 137 | if (!buf_out) | ||
| 138 | return AVERROR(ENOMEM); | ||
| 139 | return ff_start_frame(outlink, buf_out); | ||
| 133 | } | 140 | } |
| 134 | 141 | ||
| 135 | static void end_frame(AVFilterLink *inlink) | 142 | static int end_frame(AVFilterLink *inlink) |
| 136 | { | 143 | { |
| 137 | TransContext *trans = inlink->dst->priv; | 144 | TransContext *trans = inlink->dst->priv; |
| 138 | AVFilterBufferRef *inpic = inlink->cur_buf; | 145 | AVFilterBufferRef *inpic = inlink->cur_buf; |
| 139 | AVFilterBufferRef *outpic = inlink->dst->outputs[0]->out_buf; | 146 | AVFilterBufferRef *outpic = inlink->dst->outputs[0]->out_buf; |
| 140 | AVFilterLink *outlink = inlink->dst->outputs[0]; | 147 | AVFilterLink *outlink = inlink->dst->outputs[0]; |
| 141 | int plane; | 148 | int plane, ret; |
| 142 | 149 | ||
| 143 | for (plane = 0; outpic->data[plane]; plane++) { | 150 | for (plane = 0; outpic->data[plane]; plane++) { |
| 144 | int hsub = plane == 1 || plane == 2 ? trans->hsub : 0; | 151 | int hsub = plane == 1 || plane == 2 ? trans->hsub : 0; |
| @@ -189,11 +196,13 @@ static void end_frame(AVFilterLink *inlink) · 44 unmodified lines | |||
| 189 | } | 196 | } |
| 190 | } | 197 | } |
| 191 | 198 | ||
| 192 | ff_draw_slice(outlink, 0, outpic->video->h, 1); | 199 | if ((ret = ff_draw_slice(outlink, 0, outpic->video->h, 1)) < 0 || |
| 193 | ff_end_frame(outlink); | 200 | (ret = ff_end_frame(outlink)) < 0) |
| 201 | return ret; | ||
| 202 | return 0; | ||
| 194 | } | 203 | } |
| 195 | 204 | ||
| 196 | static void null_draw_slice(AVFilterLink *link, int y, int h, int slice_dir) { } | 205 | static int null_draw_slice(AVFilterLink *link, int y, int h, int slice_dir) { return 0; } |
| 197 | 206 | ||
| 198 | AVFilter avfilter_vf_transpose = { | 207 | AVFilter avfilter_vf_transpose = { |
| 199 | .name = "transpose", | 208 | .name = "transpose", |
| @@ -213,24 +213,28 @@ static av_cold void uninit(AVFilterContext *ctx) · 212 unmodified lines | |||
| 213 | free_filter_param(&unsharp->chroma); | 213 | free_filter_param(&unsharp->chroma); |
| 214 | } | 214 | } |
| 215 | 215 | ||
| 216 | static void end_frame(AVFilterLink *link) | 216 | static int end_frame(AVFilterLink *link) |
| 217 | { | 217 | { |
| 218 | UnsharpContext *unsharp = link->dst->priv; | 218 | UnsharpContext *unsharp = link->dst->priv; |
| 219 | AVFilterBufferRef *in = link->cur_buf; | 219 | AVFilterBufferRef *in = link->cur_buf; |
| 220 | AVFilterBufferRef *out = link->dst->outputs[0]->out_buf; | 220 | AVFilterBufferRef *out = link->dst->outputs[0]->out_buf; |
| 221 | int cw = SHIFTUP(link->w, unsharp->hsub); | 221 | int cw = SHIFTUP(link->w, unsharp->hsub); |
| 222 | int ch = SHIFTUP(link->h, unsharp->vsub); | 222 | int ch = SHIFTUP(link->h, unsharp->vsub); |
| 223 | int ret; | ||
| 223 | 224 | ||
| 224 | apply_unsharp(out->data[0], out->linesize[0], in->data[0], in->linesize[0], link->w, link->h, &unsharp->luma); | 225 | apply_unsharp(out->data[0], out->linesize[0], in->data[0], in->linesize[0], link->w, link->h, &unsharp->luma); |
| 225 | apply_unsharp(out->data[1], out->linesize[1], in->data[1], in->linesize[1], cw, ch, &unsharp->chroma); | 226 | apply_unsharp(out->data[1], out->linesize[1], in->data[1], in->linesize[1], cw, ch, &unsharp->chroma); |
| 226 | apply_unsharp(out->data[2], out->linesize[2], in->data[2], in->linesize[2], cw, ch, &unsharp->chroma); | 227 | apply_unsharp(out->data[2], out->linesize[2], in->data[2], in->linesize[2], cw, ch, &unsharp->chroma); |
| 227 | 228 | ||
| 228 | ff_draw_slice(link->dst->outputs[0], 0, link->h, 1); | 229 | if ((ret = ff_draw_slice(link->dst->outputs[0], 0, link->h, 1)) < 0 || |
| 229 | ff_end_frame(link->dst->outputs[0]); | 230 | (ret = ff_end_frame(link->dst->outputs[0])) < 0) |
| 231 | return ret; | ||
| 232 | return 0; | ||
| 230 | } | 233 | } |
| 231 | 234 | ||
| 232 | static void draw_slice(AVFilterLink *link, int y, int h, int slice_dir) | 235 | static int draw_slice(AVFilterLink *link, int y, int h, int slice_dir) |
| 233 | { | 236 | { |
| 237 | return 0; | ||
| 234 | } | 238 | } |
| 235 | 239 | ||
| 236 | AVFilter avfilter_vf_unsharp = { | 240 | AVFilter avfilter_vf_unsharp = { |
| @@ -52,6 +52,9 @@ static AVFilterBufferRef *get_video_buffer(AVFilterLink *link, int perms, · 51 unmodified lines | |||
| 52 | return ff_default_get_video_buffer(link, perms, w, h); | 52 | return ff_default_get_video_buffer(link, perms, w, h); |
| 53 | 53 | ||
| 54 | picref = ff_get_video_buffer(link->dst->outputs[0], perms, w, h); | 54 | picref = ff_get_video_buffer(link->dst->outputs[0], perms, w, h); |
| 55 | if (!picref) | ||
| 56 | return NULL; | ||
| 57 | |||
| 55 | for (i = 0; i < 4; i ++) { | 58 | for (i = 0; i < 4; i ++) { |
| 56 | int vsub = i == 1 || i == 2 ? flip->vsub : 0; | 59 | int vsub = i == 1 || i == 2 ? flip->vsub : 0; |
| 57 | 60 | ||
| @@ -64,12 +67,15 @@ static AVFilterBufferRef *get_video_buffer(AVFilterLink *link, int perms, · 6 unmodified lines | |||
| 64 | return picref; | 67 | return picref; |
| 65 | } | 68 | } |
| 66 | 69 | ||
| 67 | static void start_frame(AVFilterLink *link, AVFilterBufferRef *inpicref) | 70 | static int start_frame(AVFilterLink *link, AVFilterBufferRef *inpicref) |
| 68 | { | 71 | { |
| 69 | FlipContext *flip = link->dst->priv; | 72 | FlipContext *flip = link->dst->priv; |
| 70 | AVFilterBufferRef *outpicref = avfilter_ref_buffer(inpicref, ~0); | 73 | AVFilterBufferRef *outpicref = avfilter_ref_buffer(inpicref, ~0); |
| 71 | int i; | 74 | int i; |
| 72 | 75 | ||
| 76 | if (!outpicref) | ||
| 77 | return AVERROR(ENOMEM); | ||
| 78 | |||
| 73 | for (i = 0; i < 4; i ++) { | 79 | for (i = 0; i < 4; i ++) { |
| 74 | int vsub = i == 1 || i == 2 ? flip->vsub : 0; | 80 | int vsub = i == 1 || i == 2 ? flip->vsub : 0; |
| 75 | 81 | ||
| @@ -79,14 +85,14 @@ static void start_frame(AVFilterLink *link, AVFilterBufferRef *inpicref) · 3 unmodified lines | |||
| 79 | } | 85 | } |
| 80 | } | 86 | } |
| 81 | 87 | ||
| 82 | ff_start_frame(link->dst->outputs[0], outpicref); | 88 | return ff_start_frame(link->dst->outputs[0], outpicref); |
| 83 | } | 89 | } |
| 84 | 90 | ||
| 85 | static void draw_slice(AVFilterLink *link, int y, int h, int slice_dir) | 91 | static int draw_slice(AVFilterLink *link, int y, int h, int slice_dir) |
| 86 | { | 92 | { |
| 87 | AVFilterContext *ctx = link->dst; | 93 | AVFilterContext *ctx = link->dst; |
| 88 | 94 | ||
| 89 | ff_draw_slice(ctx->outputs[0], link->h - (y+h), h, -1 * slice_dir); | 95 | return ff_draw_slice(ctx->outputs[0], link->h - (y+h), h, -1 * slice_dir); |
| 90 | } | 96 | } |
| 91 | 97 | ||
| 92 | AVFilter avfilter_vf_vflip = { | 98 | AVFilter avfilter_vf_vflip = { |
| @@ -156,11 +156,11 @@ static AVFilterBufferRef *get_video_buffer(AVFilterLink *link, int perms, int w, · 155 unmodified lines | |||
| 156 | return picref; | 156 | return picref; |
| 157 | } | 157 | } |
| 158 | 158 | ||
| 159 | static void return_frame(AVFilterContext *ctx, int is_second) | 159 | static int return_frame(AVFilterContext *ctx, int is_second) |
| 160 | { | 160 | { |
| 161 | YADIFContext *yadif = ctx->priv; | 161 | YADIFContext *yadif = ctx->priv; |
| 162 | AVFilterLink *link= ctx->outputs[0]; | 162 | AVFilterLink *link= ctx->outputs[0]; |
| 163 | int tff; | 163 | int tff, ret; |
| 164 | 164 | ||
| 165 | if (yadif->parity == -1) { | 165 | if (yadif->parity == -1) { |
| 166 | tff = yadif->cur->video->interlaced ? | 166 | tff = yadif->cur->video->interlaced ? |
| @@ -172,6 +172,9 @@ static void return_frame(AVFilterContext *ctx, int is_second) · 5 unmodified lines | |||
| 172 | if (is_second) { | 172 | if (is_second) { |
| 173 | yadif->out = ff_get_video_buffer(link, AV_PERM_WRITE | AV_PERM_PRESERVE | | 173 | yadif->out = ff_get_video_buffer(link, AV_PERM_WRITE | AV_PERM_PRESERVE | |
| 174 | AV_PERM_REUSE, link->w, link->h); | 174 | AV_PERM_REUSE, link->w, link->h); |
| 175 | if (!yadif->out) | ||
| 176 | return AVERROR(ENOMEM); | ||
| 177 | |||
| 175 | avfilter_copy_buffer_ref_props(yadif->out, yadif->cur); | 178 | avfilter_copy_buffer_ref_props(yadif->out, yadif->cur); |
| 176 | yadif->out->video->interlaced = 0; | 179 | yadif->out->video->interlaced = 0; |
| 177 | } | 180 | } |
| @@ -192,15 +195,19 @@ static void return_frame(AVFilterContext *ctx, int is_second) · 14 unmodified lines | |||
| 192 | } else { | 195 | } else { |
| 193 | yadif->out->pts = AV_NOPTS_VALUE; | 196 | yadif->out->pts = AV_NOPTS_VALUE; |
| 194 | } | 197 | } |
| 195 | ff_start_frame(ctx->outputs[0], yadif->out); | 198 | ret = ff_start_frame(ctx->outputs[0], yadif->out); |
| 199 | if (ret < 0) | ||
| 200 | return ret; | ||
| 196 | } | 201 | } |
| 197 | ff_draw_slice(ctx->outputs[0], 0, link->h, 1); | 202 | if ((ret = ff_draw_slice(ctx->outputs[0], 0, link->h, 1)) < 0 || |
| 198 | ff_end_frame(ctx->outputs[0]); | 203 | (ret = ff_end_frame(ctx->outputs[0])) < 0) |
| 204 | return ret; | ||
| 199 | 205 | ||
| 200 | yadif->frame_pending = (yadif->mode&1) && !is_second; | 206 | yadif->frame_pending = (yadif->mode&1) && !is_second; |
| 207 | return 0; | ||
| 201 | } | 208 | } |
| 202 | 209 | ||
| 203 | static void start_frame(AVFilterLink *link, AVFilterBufferRef *picref) | 210 | static int start_frame(AVFilterLink *link, AVFilterBufferRef *picref) |
| 204 | { | 211 | { |
| 205 | AVFilterContext *ctx = link->dst; | 212 | AVFilterContext *ctx = link->dst; |
| 206 | YADIFContext *yadif = ctx->priv; | 213 | YADIFContext *yadif = ctx->priv; |
| @@ -217,46 +224,52 @@ static void start_frame(AVFilterLink *link, AVFilterBufferRef *picref) · 10 unmodified lines | |||
| 217 | yadif->next = picref; | 224 | yadif->next = picref; |
| 218 | 225 | ||
| 219 | if (!yadif->cur) | 226 | if (!yadif->cur) |
| 220 | return; | 227 | return 0; |
| 221 | 228 | ||
| 222 | if (yadif->auto_enable && !yadif->cur->video->interlaced) { | 229 | if (yadif->auto_enable && !yadif->cur->video->interlaced) { |
| 223 | yadif->out = avfilter_ref_buffer(yadif->cur, AV_PERM_READ); | 230 | yadif->out = avfilter_ref_buffer(yadif->cur, AV_PERM_READ); |
| 224 | avfilter_unref_buffer(yadif->prev); | 231 | if (!yadif->out) |
| 225 | yadif->prev = NULL; | 232 | return AVERROR(ENOMEM); |
| 233 | |||
| 234 | avfilter_unref_bufferp(&yadif->prev); | ||
| 226 | if (yadif->out->pts != AV_NOPTS_VALUE) | 235 | if (yadif->out->pts != AV_NOPTS_VALUE) |
| 227 | yadif->out->pts *= 2; | 236 | yadif->out->pts *= 2; |
| 228 | ff_start_frame(ctx->outputs[0], yadif->out); | 237 | return ff_start_frame(ctx->outputs[0], yadif->out); |
| 229 | return; | ||
| 230 | } | 238 | } |
| 231 | 239 | ||
| 232 | if (!yadif->prev) | 240 | if (!yadif->prev && |
| 233 | yadif->prev = avfilter_ref_buffer(yadif->cur, AV_PERM_READ); | 241 | !(yadif->prev = avfilter_ref_buffer(yadif->cur, AV_PERM_READ))) |
| 242 | return AVERROR(ENOMEM); | ||
| 234 | 243 | ||
| 235 | yadif->out = ff_get_video_buffer(ctx->outputs[0], AV_PERM_WRITE | AV_PERM_PRESERVE | | 244 | yadif->out = ff_get_video_buffer(ctx->outputs[0], AV_PERM_WRITE | AV_PERM_PRESERVE | |
| 236 | AV_PERM_REUSE, link->w, link->h); | 245 | AV_PERM_REUSE, link->w, link->h); |
| 246 | if (!yadif->out) | ||
| 247 | return AVERROR(ENOMEM); | ||
| 237 | 248 | ||
| 238 | avfilter_copy_buffer_ref_props(yadif->out, yadif->cur); | 249 | avfilter_copy_buffer_ref_props(yadif->out, yadif->cur); |
| 239 | yadif->out->video->interlaced = 0; | 250 | yadif->out->video->interlaced = 0; |
| 240 | if (yadif->out->pts != AV_NOPTS_VALUE) | 251 | if (yadif->out->pts != AV_NOPTS_VALUE) |
| 241 | yadif->out->pts *= 2; | 252 | yadif->out->pts *= 2; |
| 242 | ff_start_frame(ctx->outputs[0], yadif->out); | 253 | return ff_start_frame(ctx->outputs[0], yadif->out); |
| 243 | } | 254 | } |
| 244 | 255 | ||
| 245 | static void end_frame(AVFilterLink *link) | 256 | static int end_frame(AVFilterLink *link) |
| 246 | { | 257 | { |
| 247 | AVFilterContext *ctx = link->dst; | 258 | AVFilterContext *ctx = link->dst; |
| 248 | YADIFContext *yadif = ctx->priv; | 259 | YADIFContext *yadif = ctx->priv; |
| 249 | 260 | ||
| 250 | if (!yadif->out) | 261 | if (!yadif->out) |
| 251 | return; | 262 | return 0; |
| 252 | 263 | ||
| 253 | if (yadif->auto_enable && !yadif->cur->video->interlaced) { | 264 | if (yadif->auto_enable && !yadif->cur->video->interlaced) { |
| 254 | ff_draw_slice(ctx->outputs[0], 0, link->h, 1); | 265 | int ret = ff_draw_slice(ctx->outputs[0], 0, link->h, 1); |
| 255 | ff_end_frame(ctx->outputs[0]); | 266 | if (ret >= 0) |
| 256 | return; | 267 | ret = ff_end_frame(ctx->outputs[0]); |
| 268 | return ret; | ||
| 257 | } | 269 | } |
| 258 | 270 | ||
| 259 | return_frame(ctx, 0); | 271 | return_frame(ctx, 0); |
| 272 | return 0; | ||
| 260 | } | 273 | } |
| 261 | 274 | ||
| 262 | static int request_frame(AVFilterLink *link) | 275 | static int request_frame(AVFilterLink *link) |
| @@ -279,6 +292,9 @@ static int request_frame(AVFilterLink *link) · 16 unmodified lines | |||
| 279 | 292 | ||
| 280 | if (ret == AVERROR_EOF && yadif->cur) { | 293 | if (ret == AVERROR_EOF && yadif->cur) { |
| 281 | AVFilterBufferRef *next = avfilter_ref_buffer(yadif->next, AV_PERM_READ); | 294 | AVFilterBufferRef *next = avfilter_ref_buffer(yadif->next, AV_PERM_READ); |
| 295 | if (!next) | ||
| 296 | return AVERROR(ENOMEM); | ||
| 297 | |||
| 282 | next->pts = yadif->next->pts * 2 - yadif->cur->pts; | 298 | next->pts = yadif->next->pts * 2 - yadif->cur->pts; |
| 283 | 299 | ||
| 284 | start_frame(link->src->inputs[0], next); | 300 | start_frame(link->src->inputs[0], next); |
| @@ -323,9 +339,9 @@ static av_cold void uninit(AVFilterContext *ctx) · 38 unmodified lines | |||
| 323 | { | 339 | { |
| 324 | YADIFContext *yadif = ctx->priv; | 340 | YADIFContext *yadif = ctx->priv; |
| 325 | 341 | ||
| 326 | if (yadif->prev) avfilter_unref_buffer(yadif->prev); | 342 | if (yadif->prev) avfilter_unref_bufferp(&yadif->prev); |
| 327 | if (yadif->cur ) avfilter_unref_buffer(yadif->cur ); | 343 | if (yadif->cur ) avfilter_unref_bufferp(&yadif->cur ); |
| 328 | if (yadif->next) avfilter_unref_buffer(yadif->next); | 344 | if (yadif->next) avfilter_unref_bufferp(&yadif->next); |
| 329 | } | 345 | } |
| 330 | 346 | ||
| 331 | static int query_formats(AVFilterContext *ctx) | 347 | static int query_formats(AVFilterContext *ctx) |
| @@ -381,7 +397,10 @@ static av_cold int init(AVFilterContext *ctx, const char *args) · 49 unmodified lines | |||
| 381 | return 0; | 397 | return 0; |
| 382 | } | 398 | } |
| 383 | 399 | ||
| 384 | static void null_draw_slice(AVFilterLink *link, int y, int h, int slice_dir) { } | 400 | static int null_draw_slice(AVFilterLink *link, int y, int h, int slice_dir) |
| 401 | { | ||
| 402 | return 0; | ||
| 403 | } | ||
| 385 | 404 | ||
| 386 | static int config_props(AVFilterLink *link) | 405 | static int config_props(AVFilterLink *link) |
| 387 | { | 406 | { |
| @@ -149,13 +149,15 @@ AVFilterBufferRef *ff_get_video_buffer(AVFilterLink *link, int perms, int w, int · 148 unmodified lines | |||
| 149 | return ret; | 149 | return ret; |
| 150 | } | 150 | } |
| 151 | 151 | ||
| 152 | void ff_null_start_frame(AVFilterLink *link, AVFilterBufferRef *picref) | 152 | int ff_null_start_frame(AVFilterLink *link, AVFilterBufferRef *picref) |
| 153 | { | 153 | { |
| 154 | AVFilterBufferRef *buf_out = avfilter_ref_buffer(picref, ~0); | 154 | AVFilterBufferRef *buf_out = avfilter_ref_buffer(picref, ~0); |
| 155 | ff_start_frame(link->dst->outputs[0], buf_out); | 155 | if (!buf_out) |
| 156 | return AVERROR(ENOMEM); | ||
| 157 | return ff_start_frame(link->dst->outputs[0], buf_out); | ||
| 156 | } | 158 | } |
| 157 | 159 | ||
| 158 | static void default_start_frame(AVFilterLink *inlink, AVFilterBufferRef *picref) | 160 | static int default_start_frame(AVFilterLink *inlink, AVFilterBufferRef *picref) |
| 159 | { | 161 | { |
| 160 | AVFilterLink *outlink = NULL; | 162 | AVFilterLink *outlink = NULL; |
| 161 | 163 | ||
| @@ -163,21 +165,37 @@ static void default_start_frame(AVFilterLink *inlink, AVFilterBufferRef *picref) · 1 unmodified line | |||
| 163 | outlink = inlink->dst->outputs[0]; | 165 | outlink = inlink->dst->outputs[0]; |
| 164 | 166 | ||
| 165 | if (outlink) { | 167 | if (outlink) { |
| 168 | AVFilterBufferRef *buf_out; | ||
| 166 | outlink->out_buf = ff_get_video_buffer(outlink, AV_PERM_WRITE, outlink->w, outlink->h); | 169 | outlink->out_buf = ff_get_video_buffer(outlink, AV_PERM_WRITE, outlink->w, outlink->h); |
| 170 | if (!outlink->out_buf) | ||
| 171 | return AVERROR(ENOMEM); | ||
| 172 | |||
| 167 | avfilter_copy_buffer_ref_props(outlink->out_buf, picref); | 173 | avfilter_copy_buffer_ref_props(outlink->out_buf, picref); |
| 168 | outlink->out_buf->video->w = outlink->w; | 174 | outlink->out_buf->video->w = outlink->w; |
| 169 | outlink->out_buf->video->h = outlink->h; | 175 | outlink->out_buf->video->h = outlink->h; |
| 170 | ff_start_frame(outlink, avfilter_ref_buffer(outlink->out_buf, ~0)); | 176 | buf_out = avfilter_ref_buffer(outlink->out_buf, ~0); |
| 177 | if (!buf_out) | ||
| 178 | return AVERROR(ENOMEM); | ||
| 179 | |||
| 180 | return ff_start_frame(outlink, buf_out); | ||
| 171 | } | 181 | } |
| 182 | return 0; | ||
| 183 | } | ||
| 184 | |||
| 185 | static void clear_link(AVFilterLink *link) | ||
| 186 | { | ||
| 187 | avfilter_unref_bufferp(&link->cur_buf); | ||
| 188 | avfilter_unref_bufferp(&link->src_buf); | ||
| 189 | avfilter_unref_bufferp(&link->out_buf); | ||
| 172 | } | 190 | } |
| 173 | 191 | ||
| 174 | /* XXX: should we do the duplicating of the picture ref here, instead of | 192 | /* XXX: should we do the duplicating of the picture ref here, instead of |
| 175 | * forcing the source filter to do it? */ | 193 | * forcing the source filter to do it? */ |
| 176 | void ff_start_frame(AVFilterLink *link, AVFilterBufferRef *picref) | 194 | int ff_start_frame(AVFilterLink *link, AVFilterBufferRef *picref) |
| 177 | { | 195 | { |
| 178 | void (*start_frame)(AVFilterLink *, AVFilterBufferRef *); | 196 | int (*start_frame)(AVFilterLink *, AVFilterBufferRef *); |
| 179 | AVFilterPad *dst = link->dstpad; | 197 | AVFilterPad *dst = link->dstpad; |
| 180 | int perms = picref->perms; | 198 | int ret, perms = picref->perms; |
| 181 | AVFilterCommand *cmd= link->dst->command_queue; | 199 | AVFilterCommand *cmd= link->dst->command_queue; |
| 182 | int64_t pts; | 200 | int64_t pts; |
| 183 | 201 | ||
| @@ -196,6 +214,11 @@ void ff_start_frame(AVFilterLink *link, AVFilterBufferRef *picref) · 12 unmodified lines | |||
| 196 | link->dstpad->min_perms, link->dstpad->rej_perms); | 214 | link->dstpad->min_perms, link->dstpad->rej_perms); |
| 197 | 215 | ||
| 198 | link->cur_buf = ff_get_video_buffer(link, dst->min_perms, link->w, link->h); | 216 | link->cur_buf = ff_get_video_buffer(link, dst->min_perms, link->w, link->h); |
| 217 | if (!link->cur_buf) { | ||
| 218 | avfilter_unref_bufferp(&picref); | ||
| 219 | return AVERROR(ENOMEM); | ||
| 220 | } | ||
| 221 | |||
| 199 | link->src_buf = picref; | 222 | link->src_buf = picref; |
| 200 | avfilter_copy_buffer_ref_props(link->cur_buf, link->src_buf); | 223 | avfilter_copy_buffer_ref_props(link->cur_buf, link->src_buf); |
| 201 | 224 | ||
| @@ -215,22 +238,26 @@ void ff_start_frame(AVFilterLink *link, AVFilterBufferRef *picref) · 13 unmodified lines | |||
| 215 | cmd= link->dst->command_queue; | 238 | cmd= link->dst->command_queue; |
| 216 | } | 239 | } |
| 217 | pts = link->cur_buf->pts; | 240 | pts = link->cur_buf->pts; |
| 218 | start_frame(link, link->cur_buf); | 241 | ret = start_frame(link, link->cur_buf); |
| 219 | ff_update_link_current_pts(link,link->cur_buf ? link->cur_buf->pts : pts); | 242 | ff_update_link_current_pts(link,link->cur_buf ? link->cur_buf->pts : pts); |
| 243 | if (ret < 0) | ||
| 244 | clear_link(link); | ||
| 245 | |||
| 246 | return ret; | ||
| 220 | } | 247 | } |
| 221 | 248 | ||
| 222 | void ff_null_start_frame_keep_ref(AVFilterLink *inlink, | 249 | int ff_null_start_frame_keep_ref(AVFilterLink *inlink, |
| 223 | AVFilterBufferRef *picref) | 250 | AVFilterBufferRef *picref) |
| 224 | { | 251 | { |
| 225 | ff_start_frame(inlink->dst->outputs[0], avfilter_ref_buffer(picref, ~0)); | 252 | return ff_start_frame(inlink->dst->outputs[0], avfilter_ref_buffer(picref, ~0)); |
| 226 | } | 253 | } |
| 227 | 254 | ||
| 228 | void ff_null_end_frame(AVFilterLink *link) | 255 | int ff_null_end_frame(AVFilterLink *link) |
| 229 | { | 256 | { |
| 230 | ff_end_frame(link->dst->outputs[0]); | 257 | return ff_end_frame(link->dst->outputs[0]); |
| 231 | } | 258 | } |
| 232 | 259 | ||
| 233 | static void default_end_frame(AVFilterLink *inlink) | 260 | static int default_end_frame(AVFilterLink *inlink) |
| 234 | { | 261 | { |
| 235 | AVFilterLink *outlink = NULL; | 262 | AVFilterLink *outlink = NULL; |
| 236 | 263 | ||
| @@ -238,37 +265,32 @@ static void default_end_frame(AVFilterLink *inlink) · 1 unmodified line | |||
| 238 | outlink = inlink->dst->outputs[0]; | 265 | outlink = inlink->dst->outputs[0]; |
| 239 | 266 | ||
| 240 | if (outlink) { | 267 | if (outlink) { |
| 241 | ff_end_frame(outlink); | 268 | return ff_end_frame(outlink); |
| 242 | } | 269 | } |
| 270 | return 0; | ||
| 243 | } | 271 | } |
| 244 | 272 | ||
| 245 | void ff_end_frame(AVFilterLink *link) | 273 | int ff_end_frame(AVFilterLink *link) |
| 246 | { | 274 | { |
| 247 | void (*end_frame)(AVFilterLink *); | 275 | int (*end_frame)(AVFilterLink *); |
| 276 | int ret; | ||
| 248 | 277 | ||
| 249 | if (!(end_frame = link->dstpad->end_frame)) | 278 | if (!(end_frame = link->dstpad->end_frame)) |
| 250 | end_frame = default_end_frame; | 279 | end_frame = default_end_frame; |
| 251 | 280 | ||
| 252 | end_frame(link); | 281 | ret = end_frame(link); |
| 253 | 282 | ||
| 254 | /* unreference the source picture if we're feeding the destination filter | 283 | clear_link(link); |
| 255 | * a copied version dues to permission issues */ | 284 | |
| 256 | if (link->src_buf) { | 285 | return ret; |
| 257 | avfilter_unref_buffer(link->src_buf); | ||
| 258 | link->src_buf = NULL; | ||
| 259 | } | ||
| 260 | if(link->cur_buf != link->out_buf) | ||
| 261 | avfilter_unref_bufferp(&link->cur_buf); | ||
| 262 | link->cur_buf = NULL; | ||
| 263 | avfilter_unref_bufferp(&link->out_buf); | ||
| 264 | } | 286 | } |
| 265 | 287 | ||
| 266 | void ff_null_draw_slice(AVFilterLink *link, int y, int h, int slice_dir) | 288 | int ff_null_draw_slice(AVFilterLink *link, int y, int h, int slice_dir) |
| 267 | { | 289 | { |
| 268 | ff_draw_slice(link->dst->outputs[0], y, h, slice_dir); | 290 | return ff_draw_slice(link->dst->outputs[0], y, h, slice_dir); |
| 269 | } | 291 | } |
| 270 | 292 | ||
| 271 | static void default_draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir) | 293 | static int default_draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir) |
| 272 | { | 294 | { |
| 273 | AVFilterLink *outlink = NULL; | 295 | AVFilterLink *outlink = NULL; |
| 274 | 296 | ||
| @@ -276,14 +298,15 @@ static void default_draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir · 1 unmodified line | |||
| 276 | outlink = inlink->dst->outputs[0]; | 298 | outlink = inlink->dst->outputs[0]; |
| 277 | 299 | ||
| 278 | if (outlink) | 300 | if (outlink) |
| 279 | ff_draw_slice(outlink, y, h, slice_dir); | 301 | return ff_draw_slice(outlink, y, h, slice_dir); |
| 302 | return 0; | ||
| 280 | } | 303 | } |
| 281 | 304 | ||
| 282 | void ff_draw_slice(AVFilterLink *link, int y, int h, int slice_dir) | 305 | int ff_draw_slice(AVFilterLink *link, int y, int h, int slice_dir) |
| 283 | { | 306 | { |
| 284 | uint8_t *src[4], *dst[4]; | 307 | uint8_t *src[4], *dst[4]; |
| 285 | int i, j, vsub; | 308 | int i, j, vsub, ret; |
| 286 | void (*draw_slice)(AVFilterLink *, int, int, int); | 309 | int (*draw_slice)(AVFilterLink *, int, int, int); |
| 287 | 310 | ||
| 288 | FF_TPRINTF_START(NULL, draw_slice); ff_tlog_link(NULL, link, 0); ff_tlog(NULL, " y:%d h:%d dir:%d\n", y, h, slice_dir); | 311 | FF_TPRINTF_START(NULL, draw_slice); ff_tlog_link(NULL, link, 0); ff_tlog(NULL, " y:%d h:%d dir:%d\n", y, h, slice_dir); |
| 289 | 312 | ||
| @@ -317,11 +340,14 @@ void ff_draw_slice(AVFilterLink *link, int y, int h, int slice_dir) · 27 unmodified lines | |||
| 317 | 340 | ||
| 318 | if (!(draw_slice = link->dstpad->draw_slice)) | 341 | if (!(draw_slice = link->dstpad->draw_slice)) |
| 319 | draw_slice = default_draw_slice; | 342 | draw_slice = default_draw_slice; |
| 320 | draw_slice(link, y, h, slice_dir); | 343 | ret = draw_slice(link, y, h, slice_dir); |
| 344 | if (ret < 0) | ||
| 345 | clear_link(link); | ||
| 346 | return ret; | ||
| 321 | } | 347 | } |
| 322 | 348 | ||
| 323 | void avfilter_default_end_frame(AVFilterLink *inlink) | 349 | int avfilter_default_end_frame(AVFilterLink *inlink) |
| 324 | { | 350 | { |
| 325 | default_end_frame(inlink); | 351 | return default_end_frame(inlink); |
| 326 | } | 352 | } |
| 327 | 353 | ||
| @@ -42,9 +42,9 @@ AVFilterBufferRef *ff_null_get_video_buffer(AVFilterLink *link, int perms, int w · 41 unmodified lines | |||
| 42 | AVFilterBufferRef *ff_get_video_buffer(AVFilterLink *link, int perms, | 42 | AVFilterBufferRef *ff_get_video_buffer(AVFilterLink *link, int perms, |
| 43 | int w, int h); | 43 | int w, int h); |
| 44 | 44 | ||
| 45 | void ff_null_start_frame(AVFilterLink *link, AVFilterBufferRef *picref); | 45 | int ff_null_start_frame(AVFilterLink *link, AVFilterBufferRef *picref); |
| 46 | void ff_null_draw_slice(AVFilterLink *link, int y, int h, int slice_dir); | 46 | int ff_null_draw_slice(AVFilterLink *link, int y, int h, int slice_dir); |
| 47 | void ff_null_end_frame(AVFilterLink *link); | 47 | int ff_null_end_frame(AVFilterLink *link); |
| 48 | 48 | ||
| 49 | /** | 49 | /** |
| 50 | * Notify the next filter of the start of a frame. | 50 | * Notify the next filter of the start of a frame. |
| @@ -54,20 +54,25 @@ void ff_null_end_frame(AVFilterLink *link); · 3 unmodified lines | |||
| 54 | * frame need only be valid once draw_slice() is called for that | 54 | * frame need only be valid once draw_slice() is called for that |
| 55 | * portion. The receiving filter will free this reference when | 55 | * portion. The receiving filter will free this reference when |
| 56 | * it no longer needs it. | 56 | * it no longer needs it. |
| 57 | * | ||
| 58 | * @return >= 0 on success, a negative AVERROR on error. This function will | ||
| 59 | * unreference picref in case of error. | ||
| 57 | */ | 60 | */ |
| 58 | void ff_start_frame(AVFilterLink *link, AVFilterBufferRef *picref); | 61 | int ff_start_frame(AVFilterLink *link, AVFilterBufferRef *picref); |
| 59 | 62 | ||
| 60 | /** | 63 | /** |
| 61 | * Pass video frame along and keep an internal reference for later use. | 64 | * Pass video frame along and keep an internal reference for later use. |
| 62 | */ | 65 | */ |
| 63 | void ff_null_start_frame_keep_ref(AVFilterLink *inlink, AVFilterBufferRef *picref); | 66 | int ff_null_start_frame_keep_ref(AVFilterLink *inlink, AVFilterBufferRef *picref); |
| 64 | 67 | ||
| 65 | /** | 68 | /** |
| 66 | * Notify the next filter that the current frame has finished. | 69 | * Notify the next filter that the current frame has finished. |
| 67 | * | 70 | * |
| 68 | * @param link the output link the frame was sent over | 71 | * @param link the output link the frame was sent over |
| 72 | * | ||
| 73 | * @return >= 0 on success, a negative AVERROR on error | ||
| 69 | */ | 74 | */ |
| 70 | void ff_end_frame(AVFilterLink *link); | 75 | int ff_end_frame(AVFilterLink *link); |
| 71 | 76 | ||
| 72 | /** | 77 | /** |
| 73 | * Send a slice to the next filter. | 78 | * Send a slice to the next filter. |
| @@ -83,7 +88,9 @@ void ff_end_frame(AVFilterLink *link); · 9 unmodified lines | |||
| 83 | * from the top slice to the bottom slice if the value is 1, | 88 | * from the top slice to the bottom slice if the value is 1, |
| 84 | * from the bottom slice to the top slice if the value is -1, | 89 | * from the bottom slice to the top slice if the value is -1, |
| 85 | * for other values the behavior of the function is undefined. | 90 | * for other values the behavior of the function is undefined. |
| 91 | * | ||
| 92 | * @return >= 0 on success, a negative AVERROR on error. | ||
| 86 | */ | 93 | */ |
| 87 | void ff_draw_slice(AVFilterLink *link, int y, int h, int slice_dir); | 94 | int ff_draw_slice(AVFilterLink *link, int y, int h, int slice_dir); |
| 88 | 95 | ||
| 89 | #endif /* AVFILTER_VIDEO_H */ | 96 | #endif /* AVFILTER_VIDEO_H */ |
| @@ -19,12 +19,14 @@ · 18 unmodified lines | |||
| 19 | #include "avfilter.h" | 19 | #include "avfilter.h" |
| 20 | #include "internal.h" | 20 | #include "internal.h" |
| 21 | 21 | ||
| 22 | static void start_frame(AVFilterLink *link, AVFilterBufferRef *picref) | 22 | static int start_frame(AVFilterLink *link, AVFilterBufferRef *picref) |
| 23 | { | 23 | { |
| 24 | return 0; | ||
| 24 | } | 25 | } |
| 25 | 26 | ||
| 26 | static void end_frame(AVFilterLink *link) | 27 | static int end_frame(AVFilterLink *link) |
| 27 | { | 28 | { |
| 29 | return 0; | ||
| 28 | } | 30 | } |
| 29 | 31 | ||
| 30 | AVFilter avfilter_vsink_nullsink = { | 32 | AVFilter avfilter_vsink_nullsink = { |
| @@ -149,18 +149,38 @@ static int color_request_frame(AVFilterLink *link) · 148 unmodified lines | |||
| 149 | { | 149 | { |
| 150 | ColorContext *color = link->src->priv; | 150 | ColorContext *color = link->src->priv; |
| 151 | AVFilterBufferRef *picref = ff_get_video_buffer(link, AV_PERM_WRITE, color->w, color->h); | 151 | AVFilterBufferRef *picref = ff_get_video_buffer(link, AV_PERM_WRITE, color->w, color->h); |
| 152 | AVFilterBufferRef *buf_out; | ||
| 153 | int ret; | ||
| 154 | |||
| 155 | if (!picref) | ||
| 156 | return AVERROR(ENOMEM); | ||
| 157 | |||
| 152 | picref->video->sample_aspect_ratio = (AVRational) {1, 1}; | 158 | picref->video->sample_aspect_ratio = (AVRational) {1, 1}; |
| 153 | picref->pts = color->pts++; | 159 | picref->pts = color->pts++; |
| 154 | picref->pos = -1; | 160 | picref->pos = -1; |
| 155 | 161 | ||
| 156 | ff_start_frame(link, avfilter_ref_buffer(picref, ~0)); | 162 | buf_out = avfilter_ref_buffer(picref, ~0); |
| 163 | if (!buf_out) { | ||
| 164 | ret = AVERROR(ENOMEM); | ||
| 165 | goto fail; | ||
| 166 | } | ||
| 167 | |||
| 168 | ret = ff_start_frame(link, buf_out); | ||
| 169 | if (ret < 0) | ||
| 170 | goto fail; | ||
| 171 | |||
| 157 | ff_fill_rectangle(&color->draw, &color->color, picref->data, picref->linesize, | 172 | ff_fill_rectangle(&color->draw, &color->color, picref->data, picref->linesize, |
| 158 | 0, 0, color->w, color->h); | 173 | 0, 0, color->w, color->h); |
| 159 | ff_draw_slice(link, 0, color->h, 1); | 174 | ret = ff_draw_slice(link, 0, color->h, 1); |
| 160 | ff_end_frame(link); | 175 | if (ret < 0) |
| 176 | goto fail; | ||
| 177 | |||
| 178 | ret = ff_end_frame(link); | ||
| 179 | |||
| 180 | fail: | ||
| 161 | avfilter_unref_buffer(picref); | 181 | avfilter_unref_buffer(picref); |
| 162 | 182 | ||
| 163 | return 0; | 183 | return ret; |
| 164 | } | 184 | } |
| 165 | 185 | ||
| 166 | AVFilter avfilter_vsrc_color = { | 186 | AVFilter avfilter_vsrc_color = { |
| @@ -134,10 +134,14 @@ static int request_frame(AVFilterLink *outlink) · 133 unmodified lines | |||
| 134 | { | 134 | { |
| 135 | TestSourceContext *test = outlink->src->priv; | 135 | TestSourceContext *test = outlink->src->priv; |
| 136 | AVFilterBufferRef *picref; | 136 | AVFilterBufferRef *picref; |
| 137 | int ret; | ||
| 137 | 138 | ||
| 138 | if (test->max_pts >= 0 && test->pts >= test->max_pts) | 139 | if (test->max_pts >= 0 && test->pts >= test->max_pts) |
| 139 | return AVERROR_EOF; | 140 | return AVERROR_EOF; |
| 140 | picref = ff_get_video_buffer(outlink, AV_PERM_WRITE, test->w, test->h); | 141 | picref = ff_get_video_buffer(outlink, AV_PERM_WRITE, test->w, test->h); |
| 142 | if (!picref) | ||
| 143 | return AVERROR(ENOMEM); | ||
| 144 | |||
| 141 | picref->pts = test->pts++; | 145 | picref->pts = test->pts++; |
| 142 | picref->pos = -1; | 146 | picref->pos = -1; |
| 143 | picref->video->key_frame = 1; | 147 | picref->video->key_frame = 1; |
| @@ -147,9 +151,10 @@ static int request_frame(AVFilterLink *outlink) · 3 unmodified lines | |||
| 147 | test->fill_picture_fn(outlink->src, picref); | 151 | test->fill_picture_fn(outlink->src, picref); |
| 148 | test->nb_frame++; | 152 | test->nb_frame++; |
| 149 | 153 | ||
| 150 | ff_start_frame(outlink, picref); | 154 | if ((ret = ff_start_frame(outlink, picref)) < 0 || |
| 151 | ff_draw_slice(outlink, 0, test->h, 1); | 155 | (ret = ff_draw_slice(outlink, 0, test->h, 1)) < 0 || |
| 152 | ff_end_frame(outlink); | 156 | (ret = ff_end_frame(outlink)) < 0) |
| 157 | return ret; | ||
| 153 | 158 | ||
| 154 | return 0; | 159 | return 0; |
| 155 | } | 160 | } |
| @@ -656,8 +656,9 @@ static int ebml_read_num(MatroskaDemuxContext *matroska, AVIOContext *pb, · 655 unmodified lines | |||
| 656 | av_log(matroska->ctx, AV_LOG_ERROR, | 656 | av_log(matroska->ctx, AV_LOG_ERROR, |
| 657 | "Read error at pos. %"PRIu64" (0x%"PRIx64")\n", | 657 | "Read error at pos. %"PRIu64" (0x%"PRIx64")\n", |
| 658 | pos, pos); | 658 | pos, pos); |
| 659 | return pb->error ? pb->error : AVERROR(EIO); | ||
| 659 | } | 660 | } |
| 660 | return AVERROR(EIO); /* EOS or actual I/O error */ | 661 | return AVERROR_EOF; |
| 661 | } | 662 | } |
| 662 | 663 | ||
| 663 | /* get the length of the EBML number */ | 664 | /* get the length of the EBML number */ |
| @@ -54,6 +54,7 @@ include $(SRC_PATH)/tests/fate/demux.mak · 53 unmodified lines | |||
| 54 | include $(SRC_PATH)/tests/fate/dfa.mak | 54 | include $(SRC_PATH)/tests/fate/dfa.mak |
| 55 | include $(SRC_PATH)/tests/fate/dpcm.mak | 55 | include $(SRC_PATH)/tests/fate/dpcm.mak |
| 56 | include $(SRC_PATH)/tests/fate/ea.mak | 56 | include $(SRC_PATH)/tests/fate/ea.mak |
| 57 | include $(SRC_PATH)/tests/fate/filter.mak | ||
| 57 | include $(SRC_PATH)/tests/fate/flac.mak | 58 | include $(SRC_PATH)/tests/fate/flac.mak |
| 58 | include $(SRC_PATH)/tests/fate/fft.mak | 59 | include $(SRC_PATH)/tests/fate/fft.mak |
| 59 | include $(SRC_PATH)/tests/fate/h264.mak | 60 | include $(SRC_PATH)/tests/fate/h264.mak |
| @@ -0,0 +1,10 @@ | |||
| 1 | FATE_ASYNCTS += fate-filter-asyncts | ||
| 2 | fate-filter-asyncts: SRC = $(SAMPLES)/nellymoser/nellymoser-discont.flv | ||
| 3 | fate-filter-asyncts: CMD = pcm -i $(SRC) -af aresample=min_comp=0.001:min_hard_comp=0.1 | ||
| 4 | fate-filter-asyncts: CMP = oneoff | ||
| 5 | fate-filter-asyncts: REF = $(SAMPLES)/nellymoser/nellymoser-discont.pcm | ||
| 6 | |||
| 7 | FATE_FILTER += $(FATE_ASYNCTS) | ||
| 8 | FATE_SAMPLES_AVCONV += $(FATE_ASYNCTS) | ||
| 9 | |||
| 10 | fate-filter: $(FATE_FILTER) | ||