Imported Upstream version 6.1
[platform/upstream/ffmpeg.git] / libavfilter / avfiltergraph.c
index b7dbfc0..68daa93 100644 (file)
@@ -441,7 +441,7 @@ static int query_formats(AVFilterGraph *graph, void *log_ctx)
 
             neg = ff_filter_get_negotiation(link);
             av_assert0(neg);
-            for (neg_step = 1; neg_step < neg->nb_mergers; neg_step++) {
+            for (neg_step = 0; neg_step < neg->nb_mergers; neg_step++) {
                 const AVFilterFormatsMerger *m = &neg->mergers[neg_step];
                 void *a = FF_FIELD_AT(void *, m->offset, link->incfg);
                 void *b = FF_FIELD_AT(void *, m->offset, link->outcfg);
@@ -729,12 +729,12 @@ static int reduce_formats_on_filter(AVFilterContext *filter)
     /* reduce channel layouts */
     for (i = 0; i < filter->nb_inputs; i++) {
         AVFilterLink *inlink = filter->inputs[i];
-        AVChannelLayout fmt = { 0 };
+        const AVChannelLayout *fmt;
 
         if (!inlink->outcfg.channel_layouts ||
             inlink->outcfg.channel_layouts->nb_channel_layouts != 1)
             continue;
-        av_channel_layout_copy(&fmt, &inlink->outcfg.channel_layouts->channel_layouts[0]);
+        fmt = &inlink->outcfg.channel_layouts->channel_layouts[0];
 
         for (j = 0; j < filter->nb_outputs; j++) {
             AVFilterLink *outlink = filter->outputs[j];
@@ -745,24 +745,27 @@ static int reduce_formats_on_filter(AVFilterContext *filter)
                 continue;
 
             if (fmts->all_layouts &&
-                (KNOWN(&fmt) || fmts->all_counts)) {
+                (KNOWN(fmt) || fmts->all_counts)) {
                 /* Turn the infinite list into a singleton */
                 fmts->all_layouts = fmts->all_counts  = 0;
-                if (ff_add_channel_layout(&outlink->incfg.channel_layouts, &fmt) < 0)
-                    ret = 1;
+                ret = ff_add_channel_layout(&outlink->incfg.channel_layouts, fmt);
+                if (ret < 0)
+                    return ret;
+                ret = 1;
                 break;
             }
 
             for (k = 0; k < outlink->incfg.channel_layouts->nb_channel_layouts; k++) {
-                if (!av_channel_layout_compare(&fmts->channel_layouts[k], &fmt)) {
-                    av_channel_layout_copy(&fmts->channel_layouts[0], &fmt);
+                if (!av_channel_layout_compare(&fmts->channel_layouts[k], fmt)) {
+                    ret = av_channel_layout_copy(&fmts->channel_layouts[0], fmt);
+                    if (ret < 0)
+                        return ret;
                     fmts->nb_channel_layouts = 1;
                     ret = 1;
                     break;
                 }
             }
         }
-        av_channel_layout_uninit(&fmt);
     }
 
     return ret;
@@ -1300,7 +1303,6 @@ int avfilter_graph_request_oldest(AVFilterGraph *graph)
     while (graph->sink_links_count) {
         oldest = graph->sink_links[0];
         if (oldest->dst->filter->activate) {
-            /* For now, buffersink is the only filter implementing activate. */
             r = av_buffersink_get_frame_flags(oldest->dst, NULL,
                                               AV_BUFFERSINK_FLAG_PEEK);
             if (r != AVERROR_EOF)