]> git.sesse.net Git - ffmpeg/blobdiff - libavfilter/avfilter.c
h264: only ref cur_pic in update_thread_context if it is initialized
[ffmpeg] / libavfilter / avfilter.c
index 88e39bf720cc16a7be79b5710183cba6637152f9..40989731cff5417ba9e2c5dda24eca3ea342185e 100644 (file)
@@ -152,6 +152,11 @@ int avfilter_config_links(AVFilterContext *filter)
         AVFilterLink *link = filter->inputs[i];
 
         if (!link) continue;
+        if (!link->src || !link->dst) {
+            av_log(filter, AV_LOG_ERROR,
+                   "Not all input and output are properly linked (%d).\n", i);
+            return AVERROR(EINVAL);
+        }
 
         switch (link->init_state) {
         case AVLINK_INIT:
@@ -181,7 +186,7 @@ int avfilter_config_links(AVFilterContext *filter)
             }
 
             if (link->time_base.num == 0 && link->time_base.den == 0)
-                link->time_base = link->src && link->src->nb_inputs ?
+                link->time_base = link->src->nb_inputs ?
                     link->src->inputs[0]->time_base : AV_TIME_BASE_Q;
 
             if (link->type == AVMEDIA_TYPE_VIDEO) {
@@ -204,7 +209,7 @@ int avfilter_config_links(AVFilterContext *filter)
 
             if ((config_link = link->dstpad->config_props))
                 if ((ret = config_link(link)) < 0) {
-                    av_log(link->src, AV_LOG_ERROR,
+                    av_log(link->dst, AV_LOG_ERROR,
                            "Failed to configure input pad on %s\n",
                            link->dst->name);
                     return ret;
@@ -272,9 +277,12 @@ int ff_poll_frame(AVFilterLink *link)
 
 static AVFilter *first_filter;
 
+#if !FF_API_NOCONST_GET_NAME
+const
+#endif
 AVFilter *avfilter_get_by_name(const char *name)
 {
-    AVFilter *f = NULL;
+    const AVFilter *f = NULL;
 
     if (!name)
         return NULL;
@@ -340,7 +348,7 @@ static void *filter_child_next(void *obj, void *prev)
 
 static const AVClass *filter_child_class_next(const AVClass *prev)
 {
-    AVFilter *f = NULL;
+    const AVFilter *f = NULL;
 
     while (prev && (f = avfilter_next(f)))
         if (f->priv_class == prev)
@@ -726,7 +734,8 @@ int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
 {
     int (*filter_frame)(AVFilterLink *, AVFrame *);
     AVFilterPad *dst = link->dstpad;
-    AVFrame *out;
+    AVFrame *out = NULL;
+    int ret;
 
     FF_DPRINTF_START(NULL, filter_frame);
     ff_dlog_link(NULL, link, 1);
@@ -745,13 +754,18 @@ int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
         case AVMEDIA_TYPE_AUDIO:
             out = ff_get_audio_buffer(link, frame->nb_samples);
             break;
-        default: return AVERROR(EINVAL);
+        default:
+            ret = AVERROR(EINVAL);
+            goto fail;
         }
         if (!out) {
-            av_frame_free(&frame);
-            return AVERROR(ENOMEM);
+            ret = AVERROR(ENOMEM);
+            goto fail;
         }
-        av_frame_copy_props(out, frame);
+
+        ret = av_frame_copy_props(out, frame);
+        if (ret < 0)
+            goto fail;
 
         switch (link->type) {
         case AVMEDIA_TYPE_VIDEO:
@@ -764,7 +778,9 @@ int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
                             av_get_channel_layout_nb_channels(frame->channel_layout),
                             frame->format);
             break;
-        default: return AVERROR(EINVAL);
+        default:
+            ret = AVERROR(EINVAL);
+            goto fail;
         }
 
         av_frame_free(&frame);
@@ -772,6 +788,11 @@ int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
         out = frame;
 
     return filter_frame(link, out);
+
+fail:
+    av_frame_free(&out);
+    av_frame_free(&frame);
+    return ret;
 }
 
 const AVClass *avfilter_get_class(void)