]> git.sesse.net Git - ffmpeg/blobdiff - libavfilter/vf_copy.c
avfilter: Constify all AVFilters
[ffmpeg] / libavfilter / vf_copy.c
index b0159cff00e1142af1a1c8436682bc9fd370e2c3..f50ac70c922f336626d7d4980c6a5c794c27d47a 100644 (file)
 static int query_formats(AVFilterContext *ctx)
 {
     AVFilterFormats *formats = NULL;
-    int fmt;
-
-    for (fmt = 0; av_pix_fmt_desc_get(fmt); fmt++) {
-        const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(fmt);
-        int ret;
-        if (desc->flags & AV_PIX_FMT_FLAG_HWACCEL)
-            continue;
-        if ((ret = ff_add_format(&formats, fmt)) < 0)
-            return ret;
-    }
+    int ret;
 
+    ret = ff_formats_pixdesc_filter(&formats, 0,
+                                    AV_PIX_FMT_FLAG_HWACCEL);
+    if (ret < 0)
+        return ret;
     return ff_set_common_formats(ctx, formats);
 }
 
@@ -48,15 +43,25 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
 {
     AVFilterLink *outlink = inlink->dst->outputs[0];
     AVFrame *out = ff_get_video_buffer(outlink, in->width, in->height);
+    int ret;
 
     if (!out) {
-        av_frame_free(&in);
-        return AVERROR(ENOMEM);
+        ret = AVERROR(ENOMEM);
+        goto fail;
     }
-    av_frame_copy_props(out, in);
-    av_frame_copy(out, in);
+
+    ret = av_frame_copy_props(out, in);
+    if (ret < 0)
+        goto fail;
+    ret = av_frame_copy(out, in);
+    if (ret < 0)
+        goto fail;
     av_frame_free(&in);
     return ff_filter_frame(outlink, out);
+fail:
+    av_frame_free(&in);
+    av_frame_free(&out);
+    return ret;
 }
 
 static const AVFilterPad avfilter_vf_copy_inputs[] = {
@@ -76,7 +81,7 @@ static const AVFilterPad avfilter_vf_copy_outputs[] = {
     { NULL }
 };
 
-AVFilter ff_vf_copy = {
+const AVFilter ff_vf_copy = {
     .name        = "copy",
     .description = NULL_IF_CONFIG_SMALL("Copy the input video unchanged to the output."),
     .inputs      = avfilter_vf_copy_inputs,