History

avfilter: use ff_inlink_make_frame_writable()

Paul B Mahol committed 3 years ago

Commit e506ea31 parent 78f460620 files · +152 −48Browse files

Unified · Split

20 files
  1. libavfilter/avf_abitscope.c +9 −2
  2. libavfilter/avf_ahistogram.c +7 −2
  3. libavfilter/avf_aphasemeter.c +7 −2
  4. libavfilter/avf_avectorscope.c +6 −1
  5. libavfilter/avf_showspectrum.c +4 −1
  6. libavfilter/avf_showvolume.c +6 −2
  7. libavfilter/f_ebur128.c +9 −3
  8. libavfilter/f_perms.c +3 −1
  9. libavfilter/framesync.c +1 −1
  10. libavfilter/vf_cover_rect.c +7 −2
  11. libavfilter/vf_dedot.c +1 −1
  12. libavfilter/vf_floodfill.c +4 −1
  13. libavfilter/vf_lensfun.c +7 −1
  14. libavfilter/vf_overlay_cuda.c +2 −1
  15. libavfilter/vf_paletteuse.c +1 −1
  16. libavfilter/vf_photosensitivity.c +2 −1
  17. libavfilter/vf_repeatfields.c +33 −16
  18. libavfilter/vf_signalstats.c +23 −4
  19. libavfilter/vf_telecine.c +11 −2
  20. libavfilter/vf_vidstabdetect.c +9 −3
libavfilter/avf_abitscope.c+9−2
@@ -213,6 +213,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *insamples) · 212 unmodified lines
213213 AVFilterLink *outlink = ctx->outputs[0];
214214 AudioBitScopeContext *s = ctx->priv;
215215 AVFrame *outpicref;
216+ int ret;
216217
217218 if (s->mode == 0 || !s->outpicref) {
218219 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
228229 }
229230
230231 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+ }
232237 outpicref = av_frame_clone(s->outpicref);
233− if (!outpicref)
238+ if (!outpicref) {
239+ av_frame_free(&insamples);
234240 return AVERROR(ENOMEM);
241+ }
235242 }
236243
237244 outpicref->pts = av_rescale_q(insamples->pts, inlink->time_base, outlink->time_base);
libavfilter/avf_ahistogram.c+7−2
@@ -209,7 +209,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) · 208 unmodified lines
209209 AudioHistogramContext *s = ctx->priv;
210210 const int H = s->histogram_h;
211211 const int w = s->w;
212− int c, y, n, p, bin;
212+ int c, y, n, p, bin, ret;
213213 uint64_t acmax = 1;
214214 AVFrame *clone;
215215
@@ -229,7 +229,12 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) · 13 unmodified lines
229229 }
230230 }
231231
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+
233238 if (s->dmode == SEPARATE) {
234239 for (y = 0; y < w; y++) {
235240 s->combine_buffer[3 * y ] = 0;
libavfilter/avf_aphasemeter.c+7−2
@@ -29,6 +29,7 @@ · 28 unmodified lines
2929 #include "libavutil/parseutils.h"
3030 #include "libavutil/timestamp.h"
3131 #include "avfilter.h"
32+#include "filters.h"
3233 #include "formats.h"
3334 #include "audio.h"
3435 #include "video.h"
@@ -246,7 +247,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) · 211 unmodified lines
246247 float fphase = 0;
247248 AVFrame *out;
248249 uint8_t *dst;
249− int i;
250+ int i, ret;
250251 int mono_measurement;
251252 int out_phase_measurement;
252253 float tolerance = 1.0f - s->tolerance;
@@ -265,8 +266,12 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) · 12 unmodified lines
265266 for (i = 0; i < outlink->h; i++)
266267 memset(out->data[0] + i * out->linesize[0], 0, outlink->w * 4);
267268 } 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+ }
268274 out = s->out;
269− av_frame_make_writable(s->out);
270275 for (i = outlink->h - 1; i >= 10; i--)
271276 memmove(out->data[0] + (i ) * out->linesize[0],
272277 out->data[0] + (i-1) * out->linesize[0],
libavfilter/avf_avectorscope.c+6−1
@@ -297,6 +297,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *insamples) · 296 unmodified lines
297297 unsigned x, y;
298298 unsigned prev_x = s->prev_x, prev_y = s->prev_y;
299299 double zoom = s->zoom;
300+ int ret;
300301
301302 if (!s->outpicref || s->outpicref->width != outlink->w ||
302303 s->outpicref->height != outlink->h) {
@@ -314,7 +315,11 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *insamples) · 11 unmodified lines
314315 s->outpicref->pts = av_rescale_q(insamples->pts, inlink->time_base, outlink->time_base);
315316 s->outpicref->duration = 1;
316317
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+ }
318323 ff_filter_execute(ctx, fade, NULL, NULL, FFMIN(outlink->h, ff_filter_get_nb_threads(ctx)));
319324
320325 if (zoom < 1) {
libavfilter/avf_showspectrum.c+4−1
@@ -1441,7 +1441,10 @@ static int plot_spectrum_column(AVFilterLink *inlink, AVFrame *insamples) · 1440 unmodified lines
14411441 }
14421442 }
14431443
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;
14451448 /* copy to output */
14461449 if (s->orientation == VERTICAL) {
14471450 if (s->sliding == SCROLL) {
libavfilter/avf_showvolume.c+6−2
@@ -324,7 +324,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *insamples) · 323 unmodified lines
324324 AVFilterLink *outlink = ctx->outputs[0];
325325 ShowVolumeContext *s = ctx->priv;
326326 const int step = s->step;
327− int c, j, k, max_draw;
327+ int c, j, k, max_draw, ret;
328328 char channel_name[64];
329329 AVFrame *out;
330330
@@ -434,7 +434,11 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *insamples) · 103 unmodified lines
434434 out = av_frame_clone(s->out);
435435 if (!out)
436436 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+ }
438442
439443 /* draw volume level */
440444 for (c = 0; c < inlink->ch_layout.nb_channels && s->h >= 8 && s->draw_volume; c++) {
libavfilter/f_ebur128.c+9−3
@@ -618,13 +618,13 @@ static int gate_update(struct integrator *integ, double power, · 617 unmodified lines
618618
619619 static int filter_frame(AVFilterLink *inlink, AVFrame *insamples)
620620 {
621− int i, ch, idx_insample;
621+ int i, ch, idx_insample, ret;
622622 AVFilterContext *ctx = inlink->dst;
623623 EBUR128Context *ebur128 = ctx->priv;
624624 const int nb_channels = ebur128->nb_channels;
625625 const int nb_samples = insamples->nb_samples;
626626 const double *samples = (double *)insamples->data[0];
627− AVFrame *pic = ebur128->outpicref;
627+ AVFrame *pic;
628628
629629 #if CONFIG_SWRESAMPLE
630630 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
821821 y_loudness_lu_graph = lu_to_y(ebur128, loudness_3000 - ebur128->target);
822822 y_loudness_lu_gauge = lu_to_y(ebur128, gauge_value);
823823
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;
825831 /* draw the graph using the short-term loudness */
826832 p = pic->data[0] + ebur128->graph.y*pic->linesize[0] + ebur128->graph.x*3;
827833 for (y = 0; y < ebur128->graph.h; y++) {
libavfilter/f_perms.c+3−1
@@ -24,6 +24,7 @@ · 23 unmodified lines
2424 #include "libavutil/opt.h"
2525 #include "libavutil/random_seed.h"
2626 #include "audio.h"
27+#include "filters.h"
2728 #include "video.h"
2829
2930 enum mode {
@@ -96,8 +97,9 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame) · 66 unmodified lines
9697 in_perm == out_perm ? " (no-op)" : "");
9798
9899 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)
100101 return ret;
102+ out = frame;
101103 } else if (in_perm == RW && out_perm == RO) {
102104 out = av_frame_clone(frame);
103105 if (!out)
libavfilter/framesync.c+1−1
@@ -288,7 +288,7 @@ int ff_framesync_get_frame(FFFrameSync *fs, unsigned in, AVFrame **rframe, · 287 unmodified lines
288288 if (need_copy) {
289289 if (!(frame = av_frame_clone(frame)))
290290 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)) {
292292 av_frame_free(&frame);
293293 return ret;
294294 }
libavfilter/vf_cover_rect.c+7−2
@@ -24,6 +24,7 @@ · 23 unmodified lines
2424
2525 #include "libavutil/imgutils.h"
2626 #include "libavutil/opt.h"
27+#include "filters.h"
2728 #include "internal.h"
2829
2930 #include "lavfutils.h"
@@ -125,7 +126,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) · 95 unmodified lines
125126 AVFilterContext *ctx = inlink->dst;
126127 CoverContext *cover = ctx->priv;
127128 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;
129130 char *xendptr = NULL, *yendptr = NULL, *wendptr = NULL, *hendptr = NULL;
130131
131132 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
170171 x = av_clip(x, 0, in->width - w);
171172 y = av_clip(y, 0, in->height - h);
172173
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+ }
174179
175180 if (cover->mode == MODE_BLUR) {
176181 blur (cover, in, x, y);
libavfilter/vf_dedot.c+1−1
@@ -289,7 +289,7 @@ static int activate(AVFilterContext *ctx) · 288 unmodified lines
289289 s->frames[4]) {
290290 out = av_frame_clone(s->frames[2]);
291291 if (out && !ctx->is_disabled) {
292− ret = av_frame_make_writable(out);
292+ ret = ff_inlink_make_frame_writable(inlink, &out);
293293 if (ret >= 0) {
294294 if (s->m & 1)
295295 ff_filter_execute(ctx, s->dedotcrawl, out, NULL,
libavfilter/vf_floodfill.c+4−1
@@ -22,6 +22,7 @@ · 21 unmodified lines
2222 #include "libavutil/imgutils.h"
2323 #include "libavutil/intreadwrite.h"
2424 #include "avfilter.h"
25+#include "filters.h"
2526 #include "formats.h"
2627 #include "internal.h"
2728 #include "video.h"
@@ -315,8 +316,10 @@ static int filter_frame(AVFilterLink *link, AVFrame *frame) · 287 unmodified lines
315316 s->front++;
316317 }
317318
318− if (ret = av_frame_make_writable(frame))
319+ if (ret = ff_inlink_make_frame_writable(link, &frame)) {
320+ av_frame_free(&frame);
319321 return ret;
322+ }
320323
321324 while (s->front > s->back) {
322325 int x, y;
libavfilter/vf_lensfun.c+7−1
@@ -32,6 +32,7 @@ · 31 unmodified lines
3232 #include "libavutil/opt.h"
3333 #include "libswscale/swscale.h"
3434 #include "avfilter.h"
35+#include "filters.h"
3536 #include "formats.h"
3637 #include "internal.h"
3738 #include "video.h"
@@ -443,9 +444,14 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) · 405 unmodified lines
443444 AVFrame *out;
444445 VignettingThreadData vignetting_thread_data;
445446 DistortionCorrectionThreadData distortion_correction_thread_data;
447+ int ret;
446448
447449 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+ }
449455
450456 vignetting_thread_data = (VignettingThreadData) {
451457 .width = inlink->w,
libavfilter/vf_overlay_cuda.c+2−1
@@ -32,6 +32,7 @@ · 31 unmodified lines
3232 #include "libavutil/eval.h"
3333
3434 #include "avfilter.h"
35+#include "filters.h"
3536 #include "framesync.h"
3637 #include "internal.h"
3738
@@ -252,7 +253,7 @@ static int overlay_cuda_blend(FFFrameSync *fs) · 214 unmodified lines
252253 if (!input_overlay)
253254 return ff_filter_frame(outlink, input_main);
254255
255− ret = av_frame_make_writable(input_main);
256+ ret = ff_inlink_make_frame_writable(inlink, &input_main);
256257 if (ret < 0) {
257258 av_frame_free(&input_main);
258259 return ret;
libavfilter/vf_paletteuse.c+1−1
@@ -783,7 +783,7 @@ static int apply_palette(AVFilterLink *inlink, AVFrame *in, AVFrame **outf) · 782 unmodified lines
783783 av_frame_unref(s->last_out);
784784 if ((ret = av_frame_ref(s->last_in, in)) < 0 ||
785785 (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) {
787787 av_frame_free(&out);
788788 *outf = NULL;
789789 return ret;
libavfilter/vf_photosensitivity.c+2−1
@@ -25,6 +25,7 @@ · 24 unmodified lines
2525 #include "libavutil/pixdesc.h"
2626 #include "avfilter.h"
2727
28+#include "filters.h"
2829 #include "formats.h"
2930 #include "internal.h"
3031 #include "video.h"
@@ -243,7 +244,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) · 212 unmodified lines
243244 /* just duplicate the frame */
244245 s->history[s->history_pos] = 0; /* frame was duplicated, thus, delta is zero */
245246 } else {
246− res = av_frame_make_writable(s->last_frame_av);
247+ res = ff_inlink_make_frame_writable(inlink, &s->last_frame_av);
247248 if (res) {
248249 av_frame_free(&in);
249250 return res;
libavfilter/vf_repeatfields.c+33−16
@@ -20,6 +20,7 @@ · 19 unmodified lines
2020
2121 #include "libavutil/imgutils.h"
2222 #include "avfilter.h"
23+#include "filters.h"
2324 #include "internal.h"
2425
2526 typedef struct RepeatFieldsContext {
@@ -75,23 +76,23 @@ static void update_pts(AVFilterLink *link, AVFrame *f, int64_t pts, int fields) · 49 unmodified lines
7576 f->pts = AV_NOPTS_VALUE;
7677 }
7778
78−static int filter_frame(AVFilterLink *inlink, AVFrame *in) {
79+static int filter_frame(AVFilterLink *inlink, AVFrame *in)
80+{
7981 AVFilterContext *ctx = inlink->dst;
8082 AVFilterLink *outlink = inlink->dst->outputs[0];
8183 RepeatFieldsContext *s = ctx->priv;
82− AVFrame *out;
8384 int ret, i;
8485 int state = s->state;
8586
8687 if (!s->frame) {
8788 s->frame = av_frame_clone(in);
88− if (!s->frame)
89+ if (!s->frame) {
90+ av_frame_free(&in);
8991 return AVERROR(ENOMEM);
92+ }
9093 s->frame->pts = AV_NOPTS_VALUE;
9194 }
9295
93− out = s->frame;
94−
9596 if ((state == 0 && !in->top_field_first) ||
9697 (state == 1 && in->top_field_first)) {
9798 av_log(ctx, AV_LOG_WARNING, "Unexpected field flags: "
@@ -104,16 +105,22 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) { · 6 unmodified lines
104105 AVFrame *new;
105106
106107 new = av_frame_clone(in);
107− if (!new)
108+ if (!new) {
109+ av_frame_free(&in);
108110 return AVERROR(ENOMEM);
111+ }
109112
110113 ret = ff_filter_frame(outlink, new);
111114
112115 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);
115122 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,
117124 in->data[i], in->linesize[i] * 2,
118125 s->linesize[i], s->planeheight[i] / 2);
119126 }
@@ -121,28 +128,38 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) { · 1 unmodified line
121128 }
122129 } else {
123130 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,
126137 in->data[i] + in->linesize[i], in->linesize[i] * 2,
127138 s->linesize[i], s->planeheight[i] / 2);
128139 }
129140
130− ret = ff_filter_frame(outlink, av_frame_clone(out));
141+ ret = ff_filter_frame(outlink, av_frame_clone(s->frame));
131142
132143 if (in->repeat_pict) {
133144 AVFrame *new;
134145
135146 new = av_frame_clone(in);
136− if (!new)
147+ if (!new) {
148+ av_frame_free(&in);
137149 return AVERROR(ENOMEM);
150+ }
138151
139152 ret = ff_filter_frame(outlink, new);
140153 state = 0;
141154 } 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);
144161 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,
146163 in->data[i], in->linesize[i] * 2,
147164 s->linesize[i], s->planeheight[i] / 2);
148165 }
libavfilter/vf_signalstats.c+23−4
@@ -23,6 +23,7 @@ · 22 unmodified lines
2323 #include "libavutil/intreadwrite.h"
2424 #include "libavutil/opt.h"
2525 #include "libavutil/pixdesc.h"
26+#include "filters.h"
2627 #include "internal.h"
2728
2829 enum FilterMode {
@@ -565,7 +566,7 @@ static int filter_frame8(AVFilterLink *link, AVFrame *in) · 536 unmodified lines
565566 int tothue = 0;
566567 int dify = 0, difu = 0, difv = 0;
567568 uint16_t masky = 0, masku = 0, maskv = 0;
568−
569+ int ret;
569570 int filtot[FILT_NUMB] = {0};
570571 AVFrame *prev;
571572
@@ -588,7 +589,16 @@ static int filter_frame8(AVFilterLink *link, AVFrame *in) · 16 unmodified lines
588589
589590 if (s->outfilter != FILTER_NONE) {
590591 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+ }
592602 }
593603
594604 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
790800
791801 int filtot[FILT_NUMB] = {0};
792802 AVFrame *prev;
793−
803+ int ret;
794804 AVFrame *sat = s->frame_sat;
795805 AVFrame *hue = s->frame_hue;
796806 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
810820
811821 if (s->outfilter != FILTER_NONE) {
812822 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+ }
814833 }
815834
816835 ff_filter_execute(ctx, compute_sat_hue_metrics16, &td_huesat,
libavfilter/vf_telecine.c+11−2
@@ -29,6 +29,7 @@ · 28 unmodified lines
2929 #include "libavutil/opt.h"
3030 #include "libavutil/pixdesc.h"
3131 #include "avfilter.h"
32+#include "filters.h"
3233 #include "formats.h"
3334 #include "internal.h"
3435 #include "video.h"
@@ -182,7 +183,11 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *inpicref) · 147 unmodified lines
182183 }
183184
184185 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+ }
186191 for (i = 0; i < s->nb_planes; i++) {
187192 // fill in the EARLIER field from the buffered pic
188193 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
208213
209214 while (len >= 2) {
210215 // 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+ }
212221 for (i = 0; i < s->nb_planes; i++)
213222 av_image_copy_plane(s->frame[nout]->data[i], s->frame[nout]->linesize[i],
214223 inpicref->data[i], inpicref->linesize[i],
libavfilter/vf_vidstabdetect.c+9−3
@@ -27,6 +27,7 @@ · 26 unmodified lines
2727 #include "libavutil/opt.h"
2828 #include "libavutil/pixdesc.h"
2929 #include "avfilter.h"
30+#include "filters.h"
3031 #include "internal.h"
3132
3233 #include "vidstabutils.h"
@@ -149,10 +150,15 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) · 116 unmodified lines
149150
150151 AVFilterLink *outlink = inlink->dst->outputs[0];
151152 VSFrame frame;
152− int plane;
153+ int plane, ret;
153154
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+ }
156162
157163 for (plane = 0; plane < md->fi.planes; plane++) {
158164 frame.data[plane] = in->data[plane];

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t