]> git.sesse.net Git - ffmpeg/blobdiff - libavfilter/avcodec.c
lavfi/blackdetect: switch to new ff_filter_frame() API
[ffmpeg] / libavfilter / avcodec.c
index 2a173b2c91f288309b3ca35b6c6b0b92dfd5a2d0..688f1b397aaeda68ea9862403f1c966856b60f0f 100644 (file)
@@ -60,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(NULL, AV_LOG_ERROR, "libavfilter does not support this channel layout\n");
+            return AVERROR(EINVAL);
+        }
         break;
     default:
         return AVERROR(EINVAL);
@@ -77,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;
 }
 
@@ -90,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;
 }
 
@@ -151,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);