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