Unified · Split
| @@ -213,6 +213,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *insamples) · 212 unmodified lines | ||
| 213 | 213 | AVFilterLink *outlink = ctx->outputs[0]; |
| 214 | 214 | AudioBitScopeContext *s = ctx->priv; |
| 215 | 215 | AVFrame *outpicref; |
| 216 | + int ret; | |
| 216 | 217 | |
| 217 | 218 | if (s->mode == 0 || !s->outpicref) { |
| 218 | 219 | outpicref = ff_get_video_buffer(outlink, outlink->w, outlink->h); |
| @@ -228,10 +229,16 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *insamples) · 9 unmodified lines | ||
| 228 | 229 | } |
| 229 | 230 | |
| 230 | 231 | if (s->mode == 1) { |
| 231 | − av_frame_make_writable(s->outpicref); | |
| 232 | + ret = ff_inlink_make_frame_writable(outlink, &s->outpicref); | |
| 233 | + if (ret < 0) { | |
| 234 | + av_frame_free(&insamples); | |
| 235 | + return ret; | |
| 236 | + } | |
| 232 | 237 | outpicref = av_frame_clone(s->outpicref); |
| 233 | − if (!outpicref) | |
| 238 | + if (!outpicref) { | |
| 239 | + av_frame_free(&insamples); | |
| 234 | 240 | return AVERROR(ENOMEM); |
| 241 | + } | |
| 235 | 242 | } |
| 236 | 243 | |
| 237 | 244 | outpicref->pts = av_rescale_q(insamples->pts, inlink->time_base, outlink->time_base); |
| @@ -209,7 +209,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) · 208 unmodified lines | ||
| 209 | 209 | AudioHistogramContext *s = ctx->priv; |
| 210 | 210 | const int H = s->histogram_h; |
| 211 | 211 | const int w = s->w; |
| 212 | − int c, y, n, p, bin; | |
| 212 | + int c, y, n, p, bin, ret; | |
| 213 | 213 | uint64_t acmax = 1; |
| 214 | 214 | AVFrame *clone; |
| 215 | 215 | |
| @@ -229,7 +229,12 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) · 13 unmodified lines | ||
| 229 | 229 | } |
| 230 | 230 | } |
| 231 | 231 | |
| 232 | − av_frame_make_writable(s->out); | |
| 232 | + ret = ff_inlink_make_frame_writable(outlink, &s->out); | |
| 233 | + if (ret < 0) { | |
| 234 | + av_frame_free(&in); | |
| 235 | + return ret; | |
| 236 | + } | |
| 237 | + | |
| 233 | 238 | if (s->dmode == SEPARATE) { |
| 234 | 239 | for (y = 0; y < w; y++) { |
| 235 | 240 | s->combine_buffer[3 * y ] = 0; |
| @@ -29,6 +29,7 @@ · 28 unmodified lines | ||
| 29 | 29 | #include "libavutil/parseutils.h" |
| 30 | 30 | #include "libavutil/timestamp.h" |
| 31 | 31 | #include "avfilter.h" |
| 32 | +#include "filters.h" | |
| 32 | 33 | #include "formats.h" |
| 33 | 34 | #include "audio.h" |
| 34 | 35 | #include "video.h" |
| @@ -246,7 +247,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) · 211 unmodified lines | ||
| 246 | 247 | float fphase = 0; |
| 247 | 248 | AVFrame *out; |
| 248 | 249 | uint8_t *dst; |
| 249 | − int i; | |
| 250 | + int i, ret; | |
| 250 | 251 | int mono_measurement; |
| 251 | 252 | int out_phase_measurement; |
| 252 | 253 | float tolerance = 1.0f - s->tolerance; |
| @@ -265,8 +266,12 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) · 12 unmodified lines | ||
| 265 | 266 | for (i = 0; i < outlink->h; i++) |
| 266 | 267 | memset(out->data[0] + i * out->linesize[0], 0, outlink->w * 4); |
| 267 | 268 | } else if (s->do_video) { |
| 269 | + ret = ff_inlink_make_frame_writable(outlink, &s->out); | |
| 270 | + if (ret < 0) { | |
| 271 | + av_frame_free(&in); | |
| 272 | + return ret; | |
| 273 | + } | |
| 268 | 274 | out = s->out; |
| 269 | − av_frame_make_writable(s->out); | |
| 270 | 275 | for (i = outlink->h - 1; i >= 10; i--) |
| 271 | 276 | memmove(out->data[0] + (i ) * out->linesize[0], |
| 272 | 277 | out->data[0] + (i-1) * out->linesize[0], |
| @@ -297,6 +297,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *insamples) · 296 unmodified lines | ||
| 297 | 297 | unsigned x, y; |
| 298 | 298 | unsigned prev_x = s->prev_x, prev_y = s->prev_y; |
| 299 | 299 | double zoom = s->zoom; |
| 300 | + int ret; | |
| 300 | 301 | |
| 301 | 302 | if (!s->outpicref || s->outpicref->width != outlink->w || |
| 302 | 303 | s->outpicref->height != outlink->h) { |
| @@ -314,7 +315,11 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *insamples) · 11 unmodified lines | ||
| 314 | 315 | s->outpicref->pts = av_rescale_q(insamples->pts, inlink->time_base, outlink->time_base); |
| 315 | 316 | s->outpicref->duration = 1; |
| 316 | 317 | |
| 317 | − av_frame_make_writable(s->outpicref); | |
| 318 | + ret = ff_inlink_make_frame_writable(outlink, &s->outpicref); | |
| 319 | + if (ret < 0) { | |
| 320 | + av_frame_free(&insamples); | |
| 321 | + return ret; | |
| 322 | + } | |
| 318 | 323 | ff_filter_execute(ctx, fade, NULL, NULL, FFMIN(outlink->h, ff_filter_get_nb_threads(ctx))); |
| 319 | 324 | |
| 320 | 325 | if (zoom < 1) { |
| @@ -1441,7 +1441,10 @@ static int plot_spectrum_column(AVFilterLink *inlink, AVFrame *insamples) · 1440 unmodified lines | ||
| 1441 | 1441 | } |
| 1442 | 1442 | } |
| 1443 | 1443 | |
| 1444 | − av_frame_make_writable(s->outpicref); | |
| 1444 | + ret = ff_inlink_make_frame_writable(outlink, &s->outpicref); | |
| 1445 | + if (ret < 0) | |
| 1446 | + return ret; | |
| 1447 | + outpicref = s->outpicref; | |
| 1445 | 1448 | /* copy to output */ |
| 1446 | 1449 | if (s->orientation == VERTICAL) { |
| 1447 | 1450 | if (s->sliding == SCROLL) { |
| @@ -324,7 +324,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *insamples) · 323 unmodified lines | ||
| 324 | 324 | AVFilterLink *outlink = ctx->outputs[0]; |
| 325 | 325 | ShowVolumeContext *s = ctx->priv; |
| 326 | 326 | const int step = s->step; |
| 327 | − int c, j, k, max_draw; | |
| 327 | + int c, j, k, max_draw, ret; | |
| 328 | 328 | char channel_name[64]; |
| 329 | 329 | AVFrame *out; |
| 330 | 330 | |
| @@ -434,7 +434,11 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *insamples) · 103 unmodified lines | ||
| 434 | 434 | out = av_frame_clone(s->out); |
| 435 | 435 | if (!out) |
| 436 | 436 | return AVERROR(ENOMEM); |
| 437 | − av_frame_make_writable(out); | |
| 437 | + ret = ff_inlink_make_frame_writable(outlink, &out); | |
| 438 | + if (ret < 0) { | |
| 439 | + av_frame_free(&out); | |
| 440 | + return ret; | |
| 441 | + } | |
| 438 | 442 | |
| 439 | 443 | /* draw volume level */ |
| 440 | 444 | for (c = 0; c < inlink->ch_layout.nb_channels && s->h >= 8 && s->draw_volume; c++) { |
| @@ -618,13 +618,13 @@ static int gate_update(struct integrator *integ, double power, · 617 unmodified lines | ||
| 618 | 618 | |
| 619 | 619 | static int filter_frame(AVFilterLink *inlink, AVFrame *insamples) |
| 620 | 620 | { |
| 621 | − int i, ch, idx_insample; | |
| 621 | + int i, ch, idx_insample, ret; | |
| 622 | 622 | AVFilterContext *ctx = inlink->dst; |
| 623 | 623 | EBUR128Context *ebur128 = ctx->priv; |
| 624 | 624 | const int nb_channels = ebur128->nb_channels; |
| 625 | 625 | const int nb_samples = insamples->nb_samples; |
| 626 | 626 | const double *samples = (double *)insamples->data[0]; |
| 627 | − AVFrame *pic = ebur128->outpicref; | |
| 627 | + AVFrame *pic; | |
| 628 | 628 | |
| 629 | 629 | #if CONFIG_SWRESAMPLE |
| 630 | 630 | if (ebur128->peak_mode & PEAK_MODE_TRUE_PEAKS && ebur128->idx_insample == 0) { |
| @@ -821,7 +821,13 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *insamples) · 190 unmodified lines | ||
| 821 | 821 | y_loudness_lu_graph = lu_to_y(ebur128, loudness_3000 - ebur128->target); |
| 822 | 822 | y_loudness_lu_gauge = lu_to_y(ebur128, gauge_value); |
| 823 | 823 | |
| 824 | − av_frame_make_writable(pic); | |
| 824 | + ret = ff_inlink_make_frame_writable(outlink, &ebur128->outpicref); | |
| 825 | + if (ret < 0) { | |
| 826 | + av_frame_free(&insamples); | |
| 827 | + ebur128->insamples = NULL; | |
| 828 | + return ret; | |
| 829 | + } | |
| 830 | + pic = ebur128->outpicref; | |
| 825 | 831 | /* draw the graph using the short-term loudness */ |
| 826 | 832 | p = pic->data[0] + ebur128->graph.y*pic->linesize[0] + ebur128->graph.x*3; |
| 827 | 833 | for (y = 0; y < ebur128->graph.h; y++) { |
| @@ -24,6 +24,7 @@ · 23 unmodified lines | ||
| 24 | 24 | #include "libavutil/opt.h" |
| 25 | 25 | #include "libavutil/random_seed.h" |
| 26 | 26 | #include "audio.h" |
| 27 | +#include "filters.h" | |
| 27 | 28 | #include "video.h" |
| 28 | 29 | |
| 29 | 30 | enum mode { |
| @@ -96,8 +97,9 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame) · 66 unmodified lines | ||
| 96 | 97 | in_perm == out_perm ? " (no-op)" : ""); |
| 97 | 98 | |
| 98 | 99 | if (in_perm == RO && out_perm == RW) { |
| 99 | − if ((ret = av_frame_make_writable(frame)) < 0) | |
| 100 | + if ((ret = ff_inlink_make_frame_writable(inlink, &frame)) < 0) | |
| 100 | 101 | return ret; |
| 102 | + out = frame; | |
| 101 | 103 | } else if (in_perm == RW && out_perm == RO) { |
| 102 | 104 | out = av_frame_clone(frame); |
| 103 | 105 | if (!out) |
| @@ -288,7 +288,7 @@ int ff_framesync_get_frame(FFFrameSync *fs, unsigned in, AVFrame **rframe, · 287 unmodified lines | ||
| 288 | 288 | if (need_copy) { |
| 289 | 289 | if (!(frame = av_frame_clone(frame))) |
| 290 | 290 | return AVERROR(ENOMEM); |
| 291 | − if ((ret = av_frame_make_writable(frame)) < 0) { | |
| 291 | + if ((ret = ff_inlink_make_frame_writable(fs->parent->inputs[in], &frame) < 0)) { | |
| 292 | 292 | av_frame_free(&frame); |
| 293 | 293 | return ret; |
| 294 | 294 | } |
| @@ -24,6 +24,7 @@ · 23 unmodified lines | ||
| 24 | 24 | |
| 25 | 25 | #include "libavutil/imgutils.h" |
| 26 | 26 | #include "libavutil/opt.h" |
| 27 | +#include "filters.h" | |
| 27 | 28 | #include "internal.h" |
| 28 | 29 | |
| 29 | 30 | #include "lavfutils.h" |
| @@ -125,7 +126,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) · 95 unmodified lines | ||
| 125 | 126 | AVFilterContext *ctx = inlink->dst; |
| 126 | 127 | CoverContext *cover = ctx->priv; |
| 127 | 128 | AVDictionaryEntry *ex, *ey, *ew, *eh; |
| 128 | − int x = -1, y = -1, w = -1, h = -1; | |
| 129 | + int ret, x = -1, y = -1, w = -1, h = -1; | |
| 129 | 130 | char *xendptr = NULL, *yendptr = NULL, *wendptr = NULL, *hendptr = NULL; |
| 130 | 131 | |
| 131 | 132 | ex = av_dict_get(in->metadata, "lavfi.rect.x", NULL, AV_DICT_MATCH_CASE); |
| @@ -170,7 +171,11 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) · 38 unmodified lines | ||
| 170 | 171 | x = av_clip(x, 0, in->width - w); |
| 171 | 172 | y = av_clip(y, 0, in->height - h); |
| 172 | 173 | |
| 173 | − av_frame_make_writable(in); | |
| 174 | + ret = ff_inlink_make_frame_writable(inlink, &in); | |
| 175 | + if (ret < 0) { | |
| 176 | + av_frame_free(&in); | |
| 177 | + return ret; | |
| 178 | + } | |
| 174 | 179 | |
| 175 | 180 | if (cover->mode == MODE_BLUR) { |
| 176 | 181 | blur (cover, in, x, y); |
| @@ -289,7 +289,7 @@ static int activate(AVFilterContext *ctx) · 288 unmodified lines | ||
| 289 | 289 | s->frames[4]) { |
| 290 | 290 | out = av_frame_clone(s->frames[2]); |
| 291 | 291 | if (out && !ctx->is_disabled) { |
| 292 | − ret = av_frame_make_writable(out); | |
| 292 | + ret = ff_inlink_make_frame_writable(inlink, &out); | |
| 293 | 293 | if (ret >= 0) { |
| 294 | 294 | if (s->m & 1) |
| 295 | 295 | ff_filter_execute(ctx, s->dedotcrawl, out, NULL, |
| @@ -22,6 +22,7 @@ · 21 unmodified lines | ||
| 22 | 22 | #include "libavutil/imgutils.h" |
| 23 | 23 | #include "libavutil/intreadwrite.h" |
| 24 | 24 | #include "avfilter.h" |
| 25 | +#include "filters.h" | |
| 25 | 26 | #include "formats.h" |
| 26 | 27 | #include "internal.h" |
| 27 | 28 | #include "video.h" |
| @@ -315,8 +316,10 @@ static int filter_frame(AVFilterLink *link, AVFrame *frame) · 287 unmodified lines | ||
| 315 | 316 | s->front++; |
| 316 | 317 | } |
| 317 | 318 | |
| 318 | − if (ret = av_frame_make_writable(frame)) | |
| 319 | + if (ret = ff_inlink_make_frame_writable(link, &frame)) { | |
| 320 | + av_frame_free(&frame); | |
| 319 | 321 | return ret; |
| 322 | + } | |
| 320 | 323 | |
| 321 | 324 | while (s->front > s->back) { |
| 322 | 325 | int x, y; |
| @@ -32,6 +32,7 @@ · 31 unmodified lines | ||
| 32 | 32 | #include "libavutil/opt.h" |
| 33 | 33 | #include "libswscale/swscale.h" |
| 34 | 34 | #include "avfilter.h" |
| 35 | +#include "filters.h" | |
| 35 | 36 | #include "formats.h" |
| 36 | 37 | #include "internal.h" |
| 37 | 38 | #include "video.h" |
| @@ -443,9 +444,14 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) · 405 unmodified lines | ||
| 443 | 444 | AVFrame *out; |
| 444 | 445 | VignettingThreadData vignetting_thread_data; |
| 445 | 446 | DistortionCorrectionThreadData distortion_correction_thread_data; |
| 447 | + int ret; | |
| 446 | 448 | |
| 447 | 449 | if (lensfun->mode & VIGNETTING) { |
| 448 | − av_frame_make_writable(in); | |
| 450 | + ret = ff_inlink_make_frame_writable(inlink, &in); | |
| 451 | + if (ret < 0) { | |
| 452 | + av_frame_free(&in); | |
| 453 | + return ret; | |
| 454 | + } | |
| 449 | 455 | |
| 450 | 456 | vignetting_thread_data = (VignettingThreadData) { |
| 451 | 457 | .width = inlink->w, |
| @@ -32,6 +32,7 @@ · 31 unmodified lines | ||
| 32 | 32 | #include "libavutil/eval.h" |
| 33 | 33 | |
| 34 | 34 | #include "avfilter.h" |
| 35 | +#include "filters.h" | |
| 35 | 36 | #include "framesync.h" |
| 36 | 37 | #include "internal.h" |
| 37 | 38 | |
| @@ -252,7 +253,7 @@ static int overlay_cuda_blend(FFFrameSync *fs) · 214 unmodified lines | ||
| 252 | 253 | if (!input_overlay) |
| 253 | 254 | return ff_filter_frame(outlink, input_main); |
| 254 | 255 | |
| 255 | − ret = av_frame_make_writable(input_main); | |
| 256 | + ret = ff_inlink_make_frame_writable(inlink, &input_main); | |
| 256 | 257 | if (ret < 0) { |
| 257 | 258 | av_frame_free(&input_main); |
| 258 | 259 | return ret; |
| @@ -783,7 +783,7 @@ static int apply_palette(AVFilterLink *inlink, AVFrame *in, AVFrame **outf) · 782 unmodified lines | ||
| 783 | 783 | av_frame_unref(s->last_out); |
| 784 | 784 | if ((ret = av_frame_ref(s->last_in, in)) < 0 || |
| 785 | 785 | (ret = av_frame_ref(s->last_out, out)) < 0 || |
| 786 | − (ret = av_frame_make_writable(s->last_in)) < 0) { | |
| 786 | + (ret = ff_inlink_make_frame_writable(inlink, &s->last_in)) < 0) { | |
| 787 | 787 | av_frame_free(&out); |
| 788 | 788 | *outf = NULL; |
| 789 | 789 | return ret; |
| @@ -25,6 +25,7 @@ · 24 unmodified lines | ||
| 25 | 25 | #include "libavutil/pixdesc.h" |
| 26 | 26 | #include "avfilter.h" |
| 27 | 27 | |
| 28 | +#include "filters.h" | |
| 28 | 29 | #include "formats.h" |
| 29 | 30 | #include "internal.h" |
| 30 | 31 | #include "video.h" |
| @@ -243,7 +244,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) · 212 unmodified lines | ||
| 243 | 244 | /* just duplicate the frame */ |
| 244 | 245 | s->history[s->history_pos] = 0; /* frame was duplicated, thus, delta is zero */ |
| 245 | 246 | } else { |
| 246 | − res = av_frame_make_writable(s->last_frame_av); | |
| 247 | + res = ff_inlink_make_frame_writable(inlink, &s->last_frame_av); | |
| 247 | 248 | if (res) { |
| 248 | 249 | av_frame_free(&in); |
| 249 | 250 | return res; |
| @@ -20,6 +20,7 @@ · 19 unmodified lines | ||
| 20 | 20 | |
| 21 | 21 | #include "libavutil/imgutils.h" |
| 22 | 22 | #include "avfilter.h" |
| 23 | +#include "filters.h" | |
| 23 | 24 | #include "internal.h" |
| 24 | 25 | |
| 25 | 26 | typedef struct RepeatFieldsContext { |
| @@ -75,23 +76,23 @@ static void update_pts(AVFilterLink *link, AVFrame *f, int64_t pts, int fields) · 49 unmodified lines | ||
| 75 | 76 | f->pts = AV_NOPTS_VALUE; |
| 76 | 77 | } |
| 77 | 78 | |
| 78 | −static int filter_frame(AVFilterLink *inlink, AVFrame *in) { | |
| 79 | +static int filter_frame(AVFilterLink *inlink, AVFrame *in) | |
| 80 | +{ | |
| 79 | 81 | AVFilterContext *ctx = inlink->dst; |
| 80 | 82 | AVFilterLink *outlink = inlink->dst->outputs[0]; |
| 81 | 83 | RepeatFieldsContext *s = ctx->priv; |
| 82 | − AVFrame *out; | |
| 83 | 84 | int ret, i; |
| 84 | 85 | int state = s->state; |
| 85 | 86 | |
| 86 | 87 | if (!s->frame) { |
| 87 | 88 | s->frame = av_frame_clone(in); |
| 88 | − if (!s->frame) | |
| 89 | + if (!s->frame) { | |
| 90 | + av_frame_free(&in); | |
| 89 | 91 | return AVERROR(ENOMEM); |
| 92 | + } | |
| 90 | 93 | s->frame->pts = AV_NOPTS_VALUE; |
| 91 | 94 | } |
| 92 | 95 | |
| 93 | − out = s->frame; | |
| 94 | − | |
| 95 | 96 | if ((state == 0 && !in->top_field_first) || |
| 96 | 97 | (state == 1 && in->top_field_first)) { |
| 97 | 98 | av_log(ctx, AV_LOG_WARNING, "Unexpected field flags: " |
| @@ -104,16 +105,22 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) { · 6 unmodified lines | ||
| 104 | 105 | AVFrame *new; |
| 105 | 106 | |
| 106 | 107 | new = av_frame_clone(in); |
| 107 | − if (!new) | |
| 108 | + if (!new) { | |
| 109 | + av_frame_free(&in); | |
| 108 | 110 | return AVERROR(ENOMEM); |
| 111 | + } | |
| 109 | 112 | |
| 110 | 113 | ret = ff_filter_frame(outlink, new); |
| 111 | 114 | |
| 112 | 115 | if (in->repeat_pict) { |
| 113 | − av_frame_make_writable(out); | |
| 114 | − update_pts(outlink, out, in->pts, 2); | |
| 116 | + ret = ff_inlink_make_frame_writable(inlink, &s->frame); | |
| 117 | + if (ret < 0) { | |
| 118 | + av_frame_free(&in); | |
| 119 | + return ret; | |
| 120 | + } | |
| 121 | + update_pts(outlink, s->frame, in->pts, 2); | |
| 115 | 122 | for (i = 0; i < s->nb_planes; i++) { |
| 116 | − av_image_copy_plane(out->data[i], out->linesize[i] * 2, | |
| 123 | + av_image_copy_plane(s->frame->data[i], s->frame->linesize[i] * 2, | |
| 117 | 124 | in->data[i], in->linesize[i] * 2, |
| 118 | 125 | s->linesize[i], s->planeheight[i] / 2); |
| 119 | 126 | } |
| @@ -121,28 +128,38 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) { · 1 unmodified line | ||
| 121 | 128 | } |
| 122 | 129 | } else { |
| 123 | 130 | for (i = 0; i < s->nb_planes; i++) { |
| 124 | − av_frame_make_writable(out); | |
| 125 | − av_image_copy_plane(out->data[i] + out->linesize[i], out->linesize[i] * 2, | |
| 131 | + ret = ff_inlink_make_frame_writable(inlink, &s->frame); | |
| 132 | + if (ret < 0) { | |
| 133 | + av_frame_free(&in); | |
| 134 | + return ret; | |
| 135 | + } | |
| 136 | + av_image_copy_plane(s->frame->data[i] + s->frame->linesize[i], s->frame->linesize[i] * 2, | |
| 126 | 137 | in->data[i] + in->linesize[i], in->linesize[i] * 2, |
| 127 | 138 | s->linesize[i], s->planeheight[i] / 2); |
| 128 | 139 | } |
| 129 | 140 | |
| 130 | − ret = ff_filter_frame(outlink, av_frame_clone(out)); | |
| 141 | + ret = ff_filter_frame(outlink, av_frame_clone(s->frame)); | |
| 131 | 142 | |
| 132 | 143 | if (in->repeat_pict) { |
| 133 | 144 | AVFrame *new; |
| 134 | 145 | |
| 135 | 146 | new = av_frame_clone(in); |
| 136 | − if (!new) | |
| 147 | + if (!new) { | |
| 148 | + av_frame_free(&in); | |
| 137 | 149 | return AVERROR(ENOMEM); |
| 150 | + } | |
| 138 | 151 | |
| 139 | 152 | ret = ff_filter_frame(outlink, new); |
| 140 | 153 | state = 0; |
| 141 | 154 | } else { |
| 142 | − av_frame_make_writable(out); | |
| 143 | − update_pts(outlink, out, in->pts, 1); | |
| 155 | + ret = ff_inlink_make_frame_writable(inlink, &s->frame); | |
| 156 | + if (ret < 0) { | |
| 157 | + av_frame_free(&in); | |
| 158 | + return ret; | |
| 159 | + } | |
| 160 | + update_pts(outlink, s->frame, in->pts, 1); | |
| 144 | 161 | for (i = 0; i < s->nb_planes; i++) { |
| 145 | − av_image_copy_plane(out->data[i], out->linesize[i] * 2, | |
| 162 | + av_image_copy_plane(s->frame->data[i], s->frame->linesize[i] * 2, | |
| 146 | 163 | in->data[i], in->linesize[i] * 2, |
| 147 | 164 | s->linesize[i], s->planeheight[i] / 2); |
| 148 | 165 | } |
| @@ -23,6 +23,7 @@ · 22 unmodified lines | ||
| 23 | 23 | #include "libavutil/intreadwrite.h" |
| 24 | 24 | #include "libavutil/opt.h" |
| 25 | 25 | #include "libavutil/pixdesc.h" |
| 26 | +#include "filters.h" | |
| 26 | 27 | #include "internal.h" |
| 27 | 28 | |
| 28 | 29 | enum FilterMode { |
| @@ -565,7 +566,7 @@ static int filter_frame8(AVFilterLink *link, AVFrame *in) · 536 unmodified lines | ||
| 565 | 566 | int tothue = 0; |
| 566 | 567 | int dify = 0, difu = 0, difv = 0; |
| 567 | 568 | uint16_t masky = 0, masku = 0, maskv = 0; |
| 568 | − | |
| 569 | + int ret; | |
| 569 | 570 | int filtot[FILT_NUMB] = {0}; |
| 570 | 571 | AVFrame *prev; |
| 571 | 572 | |
| @@ -588,7 +589,16 @@ static int filter_frame8(AVFilterLink *link, AVFrame *in) · 16 unmodified lines | ||
| 588 | 589 | |
| 589 | 590 | if (s->outfilter != FILTER_NONE) { |
| 590 | 591 | out = av_frame_clone(in); |
| 591 | − av_frame_make_writable(out); | |
| 592 | + if (!out) { | |
| 593 | + av_frame_free(&in); | |
| 594 | + return AVERROR(ENOMEM); | |
| 595 | + } | |
| 596 | + ret = ff_inlink_make_frame_writable(link, &out); | |
| 597 | + if (ret < 0) { | |
| 598 | + av_frame_free(&out); | |
| 599 | + av_frame_free(&in); | |
| 600 | + return ret; | |
| 601 | + } | |
| 592 | 602 | } |
| 593 | 603 | |
| 594 | 604 | ff_filter_execute(ctx, compute_sat_hue_metrics8, &td_huesat, |
| @@ -790,7 +800,7 @@ static int filter_frame16(AVFilterLink *link, AVFrame *in) · 195 unmodified lines | ||
| 790 | 800 | |
| 791 | 801 | int filtot[FILT_NUMB] = {0}; |
| 792 | 802 | AVFrame *prev; |
| 793 | − | |
| 803 | + int ret; | |
| 794 | 804 | AVFrame *sat = s->frame_sat; |
| 795 | 805 | AVFrame *hue = s->frame_hue; |
| 796 | 806 | const uint16_t *p_sat = (uint16_t *)sat->data[0]; |
| @@ -810,7 +820,16 @@ static int filter_frame16(AVFilterLink *link, AVFrame *in) · 13 unmodified lines | ||
| 810 | 820 | |
| 811 | 821 | if (s->outfilter != FILTER_NONE) { |
| 812 | 822 | out = av_frame_clone(in); |
| 813 | − av_frame_make_writable(out); | |
| 823 | + if (!out) { | |
| 824 | + av_frame_free(&in); | |
| 825 | + return AVERROR(ENOMEM); | |
| 826 | + } | |
| 827 | + ret = ff_inlink_make_frame_writable(link, &out); | |
| 828 | + if (ret < 0) { | |
| 829 | + av_frame_free(&out); | |
| 830 | + av_frame_free(&in); | |
| 831 | + return ret; | |
| 832 | + } | |
| 814 | 833 | } |
| 815 | 834 | |
| 816 | 835 | ff_filter_execute(ctx, compute_sat_hue_metrics16, &td_huesat, |
| @@ -29,6 +29,7 @@ · 28 unmodified lines | ||
| 29 | 29 | #include "libavutil/opt.h" |
| 30 | 30 | #include "libavutil/pixdesc.h" |
| 31 | 31 | #include "avfilter.h" |
| 32 | +#include "filters.h" | |
| 32 | 33 | #include "formats.h" |
| 33 | 34 | #include "internal.h" |
| 34 | 35 | #include "video.h" |
| @@ -182,7 +183,11 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *inpicref) · 147 unmodified lines | ||
| 182 | 183 | } |
| 183 | 184 | |
| 184 | 185 | if (s->occupied) { |
| 185 | − av_frame_make_writable(s->frame[nout]); | |
| 186 | + ret = ff_inlink_make_frame_writable(inlink, &s->frame[nout]); | |
| 187 | + if (ret < 0) { | |
| 188 | + av_frame_free(&inpicref); | |
| 189 | + return ret; | |
| 190 | + } | |
| 186 | 191 | for (i = 0; i < s->nb_planes; i++) { |
| 187 | 192 | // fill in the EARLIER field from the buffered pic |
| 188 | 193 | av_image_copy_plane(s->frame[nout]->data[i] + s->frame[nout]->linesize[i] * s->first_field, |
| @@ -208,7 +213,11 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *inpicref) · 19 unmodified lines | ||
| 208 | 213 | |
| 209 | 214 | while (len >= 2) { |
| 210 | 215 | // output THIS image as-is |
| 211 | − av_frame_make_writable(s->frame[nout]); | |
| 216 | + ret = ff_inlink_make_frame_writable(inlink, &s->frame[nout]); | |
| 217 | + if (ret < 0) { | |
| 218 | + av_frame_free(&inpicref); | |
| 219 | + return ret; | |
| 220 | + } | |
| 212 | 221 | for (i = 0; i < s->nb_planes; i++) |
| 213 | 222 | av_image_copy_plane(s->frame[nout]->data[i], s->frame[nout]->linesize[i], |
| 214 | 223 | inpicref->data[i], inpicref->linesize[i], |
| @@ -27,6 +27,7 @@ · 26 unmodified lines | ||
| 27 | 27 | #include "libavutil/opt.h" |
| 28 | 28 | #include "libavutil/pixdesc.h" |
| 29 | 29 | #include "avfilter.h" |
| 30 | +#include "filters.h" | |
| 30 | 31 | #include "internal.h" |
| 31 | 32 | |
| 32 | 33 | #include "vidstabutils.h" |
| @@ -149,10 +150,15 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) · 116 unmodified lines | ||
| 149 | 150 | |
| 150 | 151 | AVFilterLink *outlink = inlink->dst->outputs[0]; |
| 151 | 152 | VSFrame frame; |
| 152 | − int plane; | |
| 153 | + int plane, ret; | |
| 153 | 154 | |
| 154 | − if (s->conf.show > 0 && !av_frame_is_writable(in)) | |
| 155 | − av_frame_make_writable(in); | |
| 155 | + if (s->conf.show > 0 && !av_frame_is_writable(in)) { | |
| 156 | + ret = ff_inlink_make_frame_writable(inlink, &in); | |
| 157 | + if (ret < 0) { | |
| 158 | + av_frame_free(&in); | |
| 159 | + return ret; | |
| 160 | + } | |
| 161 | + } | |
| 156 | 162 | |
| 157 | 163 | for (plane = 0; plane < md->fi.planes; plane++) { |
| 158 | 164 | frame.data[plane] = in->data[plane]; |