]> git.sesse.net Git - ffmpeg/blobdiff - libavfilter/avcodec.c
Merge commit 'bf5f46b4cc47b7a4568119f224057d4ff91b6cdd'
[ffmpeg] / libavfilter / avcodec.c
index 313080dc01b518e410ca36754b566ad7b25b4eef..5ace9d9686869bddbbf4f97cdd6677f89c803483 100644 (file)
@@ -33,6 +33,9 @@ int avfilter_copy_frame_props(AVFilterBufferRef *dst, const AVFrame *src)
     dst->pos    = av_frame_get_pkt_pos(src);
     dst->format = src->format;
 
+    av_dict_free(&dst->metadata);
+    av_dict_copy(&dst->metadata, av_frame_get_metadata(src), 0);
+
     switch (dst->type) {
     case AVMEDIA_TYPE_VIDEO:
         dst->video->w                   = src->width;
@@ -57,6 +60,11 @@ int avfilter_copy_frame_props(AVFilterBufferRef *dst, const AVFrame *src)
     case AVMEDIA_TYPE_AUDIO:
         dst->audio->sample_rate         = src->sample_rate;
         dst->audio->channel_layout      = src->channel_layout;
+        dst->audio->channels            = src->channels;
+        if(src->channels != av_get_channel_layout_nb_channels(src->channel_layout)) {
+            av_log(0, AV_LOG_ERROR, "libavfilter does not support this channel layout\n");
+            return AVERROR(EINVAL);
+        }
         break;
     default:
         return AVERROR(EINVAL);
@@ -74,7 +82,10 @@ AVFilterBufferRef *avfilter_get_video_buffer_ref_from_frame(const AVFrame *frame
                                                   frame->format);
     if (!picref)
         return NULL;
-    avfilter_copy_frame_props(picref, frame);
+    if (avfilter_copy_frame_props(picref, frame) < 0) {
+        picref->buf->data[0] = NULL;
+        avfilter_unref_bufferp(&picref);
+    }
     return picref;
 }
 
@@ -87,7 +98,10 @@ AVFilterBufferRef *avfilter_get_audio_buffer_ref_from_frame(const AVFrame *frame
                                                   av_frame_get_channel_layout(frame));
     if (!samplesref)
         return NULL;
-    avfilter_copy_frame_props(samplesref, frame);
+    if (avfilter_copy_frame_props(samplesref, frame) < 0) {
+        samplesref->buf->data[0] = NULL;
+        avfilter_unref_bufferp(&samplesref);
+    }
     return samplesref;
 }
 
@@ -148,6 +162,7 @@ int avfilter_copy_buf_props(AVFrame *dst, const AVFilterBufferRef *src)
         dst->nb_samples          = src->audio->nb_samples;
         av_frame_set_sample_rate   (dst, src->audio->sample_rate);
         av_frame_set_channel_layout(dst, src->audio->channel_layout);
+        av_frame_set_channels      (dst, src->audio->channels);
         break;
     default:
         return AVERROR(EINVAL);