You've already forked FFmpeg
							
							
				mirror of
				https://github.com/FFmpeg/FFmpeg.git
				synced 2025-10-30 23:18:11 +02:00 
			
		
		
		
	avfilter: use ff_inlink_make_frame_writable()
This commit is contained in:
		| @@ -213,6 +213,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *insamples) | ||||
|     AVFilterLink *outlink = ctx->outputs[0]; | ||||
|     AudioBitScopeContext *s = ctx->priv; | ||||
|     AVFrame *outpicref; | ||||
|     int ret; | ||||
|  | ||||
|     if (s->mode == 0 || !s->outpicref) { | ||||
|         outpicref = ff_get_video_buffer(outlink, outlink->w, outlink->h); | ||||
| @@ -228,10 +229,16 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *insamples) | ||||
|     } | ||||
|  | ||||
|     if (s->mode == 1) { | ||||
|         av_frame_make_writable(s->outpicref); | ||||
|         ret = ff_inlink_make_frame_writable(outlink, &s->outpicref); | ||||
|         if (ret < 0) { | ||||
|             av_frame_free(&insamples); | ||||
|             return ret; | ||||
|         } | ||||
|         outpicref = av_frame_clone(s->outpicref); | ||||
|         if (!outpicref) | ||||
|         if (!outpicref) { | ||||
|             av_frame_free(&insamples); | ||||
|             return AVERROR(ENOMEM); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     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) | ||||
|     AudioHistogramContext *s = ctx->priv; | ||||
|     const int H = s->histogram_h; | ||||
|     const int w = s->w; | ||||
|     int c, y, n, p, bin; | ||||
|     int c, y, n, p, bin, ret; | ||||
|     uint64_t acmax = 1; | ||||
|     AVFrame *clone; | ||||
|  | ||||
| @@ -229,7 +229,12 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     av_frame_make_writable(s->out); | ||||
|     ret = ff_inlink_make_frame_writable(outlink, &s->out); | ||||
|     if (ret < 0) { | ||||
|         av_frame_free(&in); | ||||
|         return ret; | ||||
|     } | ||||
|  | ||||
|     if (s->dmode == SEPARATE) { | ||||
|         for (y = 0; y < w; y++) { | ||||
|             s->combine_buffer[3 * y    ] = 0; | ||||
|   | ||||
| @@ -29,6 +29,7 @@ | ||||
| #include "libavutil/parseutils.h" | ||||
| #include "libavutil/timestamp.h" | ||||
| #include "avfilter.h" | ||||
| #include "filters.h" | ||||
| #include "formats.h" | ||||
| #include "audio.h" | ||||
| #include "video.h" | ||||
| @@ -246,7 +247,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) | ||||
|     float fphase = 0; | ||||
|     AVFrame *out; | ||||
|     uint8_t *dst; | ||||
|     int i; | ||||
|     int i, ret; | ||||
|     int mono_measurement; | ||||
|     int out_phase_measurement; | ||||
|     float tolerance = 1.0f - s->tolerance; | ||||
| @@ -265,8 +266,12 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) | ||||
|         for (i = 0; i < outlink->h; i++) | ||||
|             memset(out->data[0] + i * out->linesize[0], 0, outlink->w * 4); | ||||
|     } else if (s->do_video) { | ||||
|         ret = ff_inlink_make_frame_writable(outlink, &s->out); | ||||
|         if (ret < 0) { | ||||
|             av_frame_free(&in); | ||||
|             return ret; | ||||
|         } | ||||
|         out = s->out; | ||||
|         av_frame_make_writable(s->out); | ||||
|         for (i = outlink->h - 1; i >= 10; i--) | ||||
|             memmove(out->data[0] + (i  ) * out->linesize[0], | ||||
|                     out->data[0] + (i-1) * out->linesize[0], | ||||
|   | ||||
| @@ -297,6 +297,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *insamples) | ||||
|     unsigned x, y; | ||||
|     unsigned prev_x = s->prev_x, prev_y = s->prev_y; | ||||
|     double zoom = s->zoom; | ||||
|     int ret; | ||||
|  | ||||
|     if (!s->outpicref || s->outpicref->width  != outlink->w || | ||||
|                          s->outpicref->height != outlink->h) { | ||||
| @@ -314,7 +315,11 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *insamples) | ||||
|     s->outpicref->pts = av_rescale_q(insamples->pts, inlink->time_base, outlink->time_base); | ||||
|     s->outpicref->duration = 1; | ||||
|  | ||||
|     av_frame_make_writable(s->outpicref); | ||||
|     ret = ff_inlink_make_frame_writable(outlink, &s->outpicref); | ||||
|     if (ret < 0) { | ||||
|         av_frame_free(&insamples); | ||||
|         return ret; | ||||
|     } | ||||
|     ff_filter_execute(ctx, fade, NULL, NULL, FFMIN(outlink->h, ff_filter_get_nb_threads(ctx))); | ||||
|  | ||||
|     if (zoom < 1) { | ||||
|   | ||||
| @@ -1441,7 +1441,10 @@ static int plot_spectrum_column(AVFilterLink *inlink, AVFrame *insamples) | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     av_frame_make_writable(s->outpicref); | ||||
|     ret = ff_inlink_make_frame_writable(outlink, &s->outpicref); | ||||
|     if (ret < 0) | ||||
|         return ret; | ||||
|     outpicref = s->outpicref; | ||||
|     /* copy to output */ | ||||
|     if (s->orientation == VERTICAL) { | ||||
|         if (s->sliding == SCROLL) { | ||||
|   | ||||
| @@ -324,7 +324,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *insamples) | ||||
|     AVFilterLink *outlink = ctx->outputs[0]; | ||||
|     ShowVolumeContext *s = ctx->priv; | ||||
|     const int step = s->step; | ||||
|     int c, j, k, max_draw; | ||||
|     int c, j, k, max_draw, ret; | ||||
|     char channel_name[64]; | ||||
|     AVFrame *out; | ||||
|  | ||||
| @@ -434,7 +434,11 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *insamples) | ||||
|     out = av_frame_clone(s->out); | ||||
|     if (!out) | ||||
|         return AVERROR(ENOMEM); | ||||
|     av_frame_make_writable(out); | ||||
|     ret = ff_inlink_make_frame_writable(outlink, &out); | ||||
|     if (ret < 0) { | ||||
|         av_frame_free(&out); | ||||
|         return ret; | ||||
|     } | ||||
|  | ||||
|     /* draw volume level */ | ||||
|     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, | ||||
|  | ||||
| static int filter_frame(AVFilterLink *inlink, AVFrame *insamples) | ||||
| { | ||||
|     int i, ch, idx_insample; | ||||
|     int i, ch, idx_insample, ret; | ||||
|     AVFilterContext *ctx = inlink->dst; | ||||
|     EBUR128Context *ebur128 = ctx->priv; | ||||
|     const int nb_channels = ebur128->nb_channels; | ||||
|     const int nb_samples  = insamples->nb_samples; | ||||
|     const double *samples = (double *)insamples->data[0]; | ||||
|     AVFrame *pic = ebur128->outpicref; | ||||
|     AVFrame *pic; | ||||
|  | ||||
| #if CONFIG_SWRESAMPLE | ||||
|     if (ebur128->peak_mode & PEAK_MODE_TRUE_PEAKS && ebur128->idx_insample == 0) { | ||||
| @@ -821,7 +821,13 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *insamples) | ||||
|                 y_loudness_lu_graph = lu_to_y(ebur128, loudness_3000 - ebur128->target); | ||||
|                 y_loudness_lu_gauge = lu_to_y(ebur128, gauge_value); | ||||
|  | ||||
|                 av_frame_make_writable(pic); | ||||
|                 ret = ff_inlink_make_frame_writable(outlink, &ebur128->outpicref); | ||||
|                 if (ret < 0) { | ||||
|                     av_frame_free(&insamples); | ||||
|                     ebur128->insamples = NULL; | ||||
|                     return ret; | ||||
|                 } | ||||
|                 pic = ebur128->outpicref; | ||||
|                 /* draw the graph using the short-term loudness */ | ||||
|                 p = pic->data[0] + ebur128->graph.y*pic->linesize[0] + ebur128->graph.x*3; | ||||
|                 for (y = 0; y < ebur128->graph.h; y++) { | ||||
|   | ||||
| @@ -24,6 +24,7 @@ | ||||
| #include "libavutil/opt.h" | ||||
| #include "libavutil/random_seed.h" | ||||
| #include "audio.h" | ||||
| #include "filters.h" | ||||
| #include "video.h" | ||||
|  | ||||
| enum mode { | ||||
| @@ -96,8 +97,9 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame) | ||||
|            in_perm == out_perm ? " (no-op)" : ""); | ||||
|  | ||||
|     if (in_perm == RO && out_perm == RW) { | ||||
|         if ((ret = av_frame_make_writable(frame)) < 0) | ||||
|         if ((ret = ff_inlink_make_frame_writable(inlink, &frame)) < 0) | ||||
|             return ret; | ||||
|         out = frame; | ||||
|     } else if (in_perm == RW && out_perm == RO) { | ||||
|         out = av_frame_clone(frame); | ||||
|         if (!out) | ||||
|   | ||||
| @@ -288,7 +288,7 @@ int ff_framesync_get_frame(FFFrameSync *fs, unsigned in, AVFrame **rframe, | ||||
|         if (need_copy) { | ||||
|             if (!(frame = av_frame_clone(frame))) | ||||
|                 return AVERROR(ENOMEM); | ||||
|             if ((ret = av_frame_make_writable(frame)) < 0) { | ||||
|             if ((ret = ff_inlink_make_frame_writable(fs->parent->inputs[in], &frame) < 0)) { | ||||
|                 av_frame_free(&frame); | ||||
|                 return ret; | ||||
|             } | ||||
|   | ||||
| @@ -24,6 +24,7 @@ | ||||
|  | ||||
| #include "libavutil/imgutils.h" | ||||
| #include "libavutil/opt.h" | ||||
| #include "filters.h" | ||||
| #include "internal.h" | ||||
|  | ||||
| #include "lavfutils.h" | ||||
| @@ -125,7 +126,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) | ||||
|     AVFilterContext *ctx = inlink->dst; | ||||
|     CoverContext *cover = ctx->priv; | ||||
|     AVDictionaryEntry *ex, *ey, *ew, *eh; | ||||
|     int x = -1, y = -1, w = -1, h = -1; | ||||
|     int ret, x = -1, y = -1, w = -1, h = -1; | ||||
|     char *xendptr = NULL, *yendptr = NULL, *wendptr = NULL, *hendptr = NULL; | ||||
|  | ||||
|     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) | ||||
|     x = av_clip(x, 0, in->width  - w); | ||||
|     y = av_clip(y, 0, in->height - h); | ||||
|  | ||||
|     av_frame_make_writable(in); | ||||
|     ret = ff_inlink_make_frame_writable(inlink, &in); | ||||
|     if (ret < 0) { | ||||
|         av_frame_free(&in); | ||||
|         return ret; | ||||
|     } | ||||
|  | ||||
|     if (cover->mode == MODE_BLUR) { | ||||
|         blur (cover, in, x, y); | ||||
|   | ||||
| @@ -289,7 +289,7 @@ static int activate(AVFilterContext *ctx) | ||||
|             s->frames[4]) { | ||||
|             out = av_frame_clone(s->frames[2]); | ||||
|             if (out && !ctx->is_disabled) { | ||||
|                 ret = av_frame_make_writable(out); | ||||
|                 ret = ff_inlink_make_frame_writable(inlink, &out); | ||||
|                 if (ret >= 0) { | ||||
|                     if (s->m & 1) | ||||
|                         ff_filter_execute(ctx, s->dedotcrawl, out, NULL, | ||||
|   | ||||
| @@ -22,6 +22,7 @@ | ||||
| #include "libavutil/imgutils.h" | ||||
| #include "libavutil/intreadwrite.h" | ||||
| #include "avfilter.h" | ||||
| #include "filters.h" | ||||
| #include "formats.h" | ||||
| #include "internal.h" | ||||
| #include "video.h" | ||||
| @@ -315,8 +316,10 @@ static int filter_frame(AVFilterLink *link, AVFrame *frame) | ||||
|             s->front++; | ||||
|         } | ||||
|  | ||||
|         if (ret = av_frame_make_writable(frame)) | ||||
|         if (ret = ff_inlink_make_frame_writable(link, &frame)) { | ||||
|             av_frame_free(&frame); | ||||
|             return ret; | ||||
|         } | ||||
|  | ||||
|         while (s->front > s->back) { | ||||
|             int x, y; | ||||
|   | ||||
| @@ -32,6 +32,7 @@ | ||||
| #include "libavutil/opt.h" | ||||
| #include "libswscale/swscale.h" | ||||
| #include "avfilter.h" | ||||
| #include "filters.h" | ||||
| #include "formats.h" | ||||
| #include "internal.h" | ||||
| #include "video.h" | ||||
| @@ -443,9 +444,14 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) | ||||
|     AVFrame *out; | ||||
|     VignettingThreadData vignetting_thread_data; | ||||
|     DistortionCorrectionThreadData distortion_correction_thread_data; | ||||
|     int ret; | ||||
|  | ||||
|     if (lensfun->mode & VIGNETTING) { | ||||
|         av_frame_make_writable(in); | ||||
|         ret = ff_inlink_make_frame_writable(inlink, &in); | ||||
|         if (ret < 0) { | ||||
|             av_frame_free(&in); | ||||
|             return ret; | ||||
|         } | ||||
|  | ||||
|         vignetting_thread_data = (VignettingThreadData) { | ||||
|             .width = inlink->w, | ||||
|   | ||||
| @@ -32,6 +32,7 @@ | ||||
| #include "libavutil/eval.h" | ||||
|  | ||||
| #include "avfilter.h" | ||||
| #include "filters.h" | ||||
| #include "framesync.h" | ||||
| #include "internal.h" | ||||
|  | ||||
| @@ -252,7 +253,7 @@ static int overlay_cuda_blend(FFFrameSync *fs) | ||||
|     if (!input_overlay) | ||||
|         return ff_filter_frame(outlink, input_main); | ||||
|  | ||||
|     ret = av_frame_make_writable(input_main); | ||||
|     ret = ff_inlink_make_frame_writable(inlink, &input_main); | ||||
|     if (ret < 0) { | ||||
|         av_frame_free(&input_main); | ||||
|         return ret; | ||||
|   | ||||
| @@ -783,7 +783,7 @@ static int apply_palette(AVFilterLink *inlink, AVFrame *in, AVFrame **outf) | ||||
|     av_frame_unref(s->last_out); | ||||
|     if ((ret = av_frame_ref(s->last_in, in))       < 0 || | ||||
|         (ret = av_frame_ref(s->last_out, out))     < 0 || | ||||
|         (ret = av_frame_make_writable(s->last_in)) < 0) { | ||||
|         (ret = ff_inlink_make_frame_writable(inlink, &s->last_in)) < 0) { | ||||
|         av_frame_free(&out); | ||||
|         *outf = NULL; | ||||
|         return ret; | ||||
|   | ||||
| @@ -25,6 +25,7 @@ | ||||
| #include "libavutil/pixdesc.h" | ||||
| #include "avfilter.h" | ||||
|  | ||||
| #include "filters.h" | ||||
| #include "formats.h" | ||||
| #include "internal.h" | ||||
| #include "video.h" | ||||
| @@ -243,7 +244,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) | ||||
|             /* just duplicate the frame */ | ||||
|             s->history[s->history_pos] = 0; /* frame was duplicated, thus, delta is zero */ | ||||
|         } else { | ||||
|             res = av_frame_make_writable(s->last_frame_av); | ||||
|             res = ff_inlink_make_frame_writable(inlink, &s->last_frame_av); | ||||
|             if (res) { | ||||
|                 av_frame_free(&in); | ||||
|                 return res; | ||||
|   | ||||
| @@ -20,6 +20,7 @@ | ||||
|  | ||||
| #include "libavutil/imgutils.h" | ||||
| #include "avfilter.h" | ||||
| #include "filters.h" | ||||
| #include "internal.h" | ||||
|  | ||||
| typedef struct RepeatFieldsContext { | ||||
| @@ -75,23 +76,23 @@ static void update_pts(AVFilterLink *link, AVFrame *f, int64_t pts, int fields) | ||||
|         f->pts = AV_NOPTS_VALUE; | ||||
| } | ||||
|  | ||||
| static int filter_frame(AVFilterLink *inlink, AVFrame *in) { | ||||
| static int filter_frame(AVFilterLink *inlink, AVFrame *in) | ||||
| { | ||||
|     AVFilterContext *ctx = inlink->dst; | ||||
|     AVFilterLink *outlink = inlink->dst->outputs[0]; | ||||
|     RepeatFieldsContext *s = ctx->priv; | ||||
|     AVFrame *out; | ||||
|     int ret, i; | ||||
|     int state = s->state; | ||||
|  | ||||
|     if (!s->frame) { | ||||
|         s->frame = av_frame_clone(in); | ||||
|         if (!s->frame) | ||||
|         if (!s->frame) { | ||||
|             av_frame_free(&in); | ||||
|             return AVERROR(ENOMEM); | ||||
|         } | ||||
|         s->frame->pts = AV_NOPTS_VALUE; | ||||
|     } | ||||
|  | ||||
|     out = s->frame; | ||||
|  | ||||
|     if ((state == 0 && !in->top_field_first) || | ||||
|         (state == 1 &&  in->top_field_first)) { | ||||
|         av_log(ctx, AV_LOG_WARNING, "Unexpected field flags: " | ||||
| @@ -104,16 +105,22 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) { | ||||
|         AVFrame *new; | ||||
|  | ||||
|         new = av_frame_clone(in); | ||||
|         if (!new) | ||||
|         if (!new) { | ||||
|             av_frame_free(&in); | ||||
|             return AVERROR(ENOMEM); | ||||
|         } | ||||
|  | ||||
|         ret = ff_filter_frame(outlink, new); | ||||
|  | ||||
|         if (in->repeat_pict) { | ||||
|             av_frame_make_writable(out); | ||||
|             update_pts(outlink, out, in->pts, 2); | ||||
|             ret = ff_inlink_make_frame_writable(inlink, &s->frame); | ||||
|             if (ret < 0) { | ||||
|                 av_frame_free(&in); | ||||
|                 return ret; | ||||
|             } | ||||
|             update_pts(outlink, s->frame, in->pts, 2); | ||||
|             for (i = 0; i < s->nb_planes; i++) { | ||||
|                 av_image_copy_plane(out->data[i], out->linesize[i] * 2, | ||||
|                 av_image_copy_plane(s->frame->data[i], s->frame->linesize[i] * 2, | ||||
|                                     in->data[i], in->linesize[i] * 2, | ||||
|                                     s->linesize[i], s->planeheight[i] / 2); | ||||
|             } | ||||
| @@ -121,28 +128,38 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) { | ||||
|         } | ||||
|     } else { | ||||
|         for (i = 0; i < s->nb_planes; i++) { | ||||
|             av_frame_make_writable(out); | ||||
|             av_image_copy_plane(out->data[i] + out->linesize[i], out->linesize[i] * 2, | ||||
|             ret = ff_inlink_make_frame_writable(inlink, &s->frame); | ||||
|             if (ret < 0) { | ||||
|                 av_frame_free(&in); | ||||
|                 return ret; | ||||
|             } | ||||
|             av_image_copy_plane(s->frame->data[i] + s->frame->linesize[i], s->frame->linesize[i] * 2, | ||||
|                                 in->data[i] + in->linesize[i], in->linesize[i] * 2, | ||||
|                                 s->linesize[i], s->planeheight[i] / 2); | ||||
|         } | ||||
|  | ||||
|         ret = ff_filter_frame(outlink, av_frame_clone(out)); | ||||
|         ret = ff_filter_frame(outlink, av_frame_clone(s->frame)); | ||||
|  | ||||
|         if (in->repeat_pict) { | ||||
|             AVFrame *new; | ||||
|  | ||||
|             new = av_frame_clone(in); | ||||
|             if (!new) | ||||
|             if (!new) { | ||||
|                 av_frame_free(&in); | ||||
|                 return AVERROR(ENOMEM); | ||||
|             } | ||||
|  | ||||
|             ret = ff_filter_frame(outlink, new); | ||||
|             state = 0; | ||||
|         } else { | ||||
|             av_frame_make_writable(out); | ||||
|             update_pts(outlink, out, in->pts, 1); | ||||
|             ret = ff_inlink_make_frame_writable(inlink, &s->frame); | ||||
|             if (ret < 0) { | ||||
|                 av_frame_free(&in); | ||||
|                 return ret; | ||||
|             } | ||||
|             update_pts(outlink, s->frame, in->pts, 1); | ||||
|             for (i = 0; i < s->nb_planes; i++) { | ||||
|                 av_image_copy_plane(out->data[i], out->linesize[i] * 2, | ||||
|                 av_image_copy_plane(s->frame->data[i], s->frame->linesize[i] * 2, | ||||
|                                     in->data[i], in->linesize[i] * 2, | ||||
|                                     s->linesize[i], s->planeheight[i] / 2); | ||||
|             } | ||||
|   | ||||
| @@ -23,6 +23,7 @@ | ||||
| #include "libavutil/intreadwrite.h" | ||||
| #include "libavutil/opt.h" | ||||
| #include "libavutil/pixdesc.h" | ||||
| #include "filters.h" | ||||
| #include "internal.h" | ||||
|  | ||||
| enum FilterMode { | ||||
| @@ -565,7 +566,7 @@ static int filter_frame8(AVFilterLink *link, AVFrame *in) | ||||
|     int tothue = 0; | ||||
|     int dify = 0, difu = 0, difv = 0; | ||||
|     uint16_t masky = 0, masku = 0, maskv = 0; | ||||
|  | ||||
|     int ret; | ||||
|     int filtot[FILT_NUMB] = {0}; | ||||
|     AVFrame *prev; | ||||
|  | ||||
| @@ -588,7 +589,16 @@ static int filter_frame8(AVFilterLink *link, AVFrame *in) | ||||
|  | ||||
|     if (s->outfilter != FILTER_NONE) { | ||||
|         out = av_frame_clone(in); | ||||
|         av_frame_make_writable(out); | ||||
|         if (!out) { | ||||
|             av_frame_free(&in); | ||||
|             return AVERROR(ENOMEM); | ||||
|         } | ||||
|         ret = ff_inlink_make_frame_writable(link, &out); | ||||
|         if (ret < 0) { | ||||
|             av_frame_free(&out); | ||||
|             av_frame_free(&in); | ||||
|             return ret; | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     ff_filter_execute(ctx, compute_sat_hue_metrics8, &td_huesat, | ||||
| @@ -790,7 +800,7 @@ static int filter_frame16(AVFilterLink *link, AVFrame *in) | ||||
|  | ||||
|     int filtot[FILT_NUMB] = {0}; | ||||
|     AVFrame *prev; | ||||
|  | ||||
|     int ret; | ||||
|     AVFrame *sat = s->frame_sat; | ||||
|     AVFrame *hue = s->frame_hue; | ||||
|     const uint16_t *p_sat = (uint16_t *)sat->data[0]; | ||||
| @@ -810,7 +820,16 @@ static int filter_frame16(AVFilterLink *link, AVFrame *in) | ||||
|  | ||||
|     if (s->outfilter != FILTER_NONE) { | ||||
|         out = av_frame_clone(in); | ||||
|         av_frame_make_writable(out); | ||||
|         if (!out) { | ||||
|             av_frame_free(&in); | ||||
|             return AVERROR(ENOMEM); | ||||
|         } | ||||
|         ret = ff_inlink_make_frame_writable(link, &out); | ||||
|         if (ret < 0) { | ||||
|             av_frame_free(&out); | ||||
|             av_frame_free(&in); | ||||
|             return ret; | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     ff_filter_execute(ctx, compute_sat_hue_metrics16, &td_huesat, | ||||
|   | ||||
| @@ -29,6 +29,7 @@ | ||||
| #include "libavutil/opt.h" | ||||
| #include "libavutil/pixdesc.h" | ||||
| #include "avfilter.h" | ||||
| #include "filters.h" | ||||
| #include "formats.h" | ||||
| #include "internal.h" | ||||
| #include "video.h" | ||||
| @@ -182,7 +183,11 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *inpicref) | ||||
|     } | ||||
|  | ||||
|     if (s->occupied) { | ||||
|         av_frame_make_writable(s->frame[nout]); | ||||
|         ret = ff_inlink_make_frame_writable(inlink, &s->frame[nout]); | ||||
|         if (ret < 0) { | ||||
|             av_frame_free(&inpicref); | ||||
|             return ret; | ||||
|         } | ||||
|         for (i = 0; i < s->nb_planes; i++) { | ||||
|             // fill in the EARLIER field from the buffered pic | ||||
|             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) | ||||
|  | ||||
|     while (len >= 2) { | ||||
|         // output THIS image as-is | ||||
|         av_frame_make_writable(s->frame[nout]); | ||||
|         ret = ff_inlink_make_frame_writable(inlink, &s->frame[nout]); | ||||
|         if (ret < 0) { | ||||
|             av_frame_free(&inpicref); | ||||
|             return ret; | ||||
|         } | ||||
|         for (i = 0; i < s->nb_planes; i++) | ||||
|             av_image_copy_plane(s->frame[nout]->data[i], s->frame[nout]->linesize[i], | ||||
|                                 inpicref->data[i], inpicref->linesize[i], | ||||
|   | ||||
| @@ -27,6 +27,7 @@ | ||||
| #include "libavutil/opt.h" | ||||
| #include "libavutil/pixdesc.h" | ||||
| #include "avfilter.h" | ||||
| #include "filters.h" | ||||
| #include "internal.h" | ||||
|  | ||||
| #include "vidstabutils.h" | ||||
| @@ -149,10 +150,15 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) | ||||
|  | ||||
|     AVFilterLink *outlink = inlink->dst->outputs[0]; | ||||
|     VSFrame frame; | ||||
|     int plane; | ||||
|     int plane, ret; | ||||
|  | ||||
|     if (s->conf.show > 0 && !av_frame_is_writable(in)) | ||||
|         av_frame_make_writable(in); | ||||
|     if (s->conf.show > 0 && !av_frame_is_writable(in)) { | ||||
|         ret = ff_inlink_make_frame_writable(inlink, &in); | ||||
|         if (ret < 0) { | ||||
|             av_frame_free(&in); | ||||
|             return ret; | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     for (plane = 0; plane < md->fi.planes; plane++) { | ||||
|         frame.data[plane] = in->data[plane]; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user