]> git.sesse.net Git - ffmpeg/blobdiff - libavfilter/sink_buffer.c
Merge remote-tracking branch 'qatar/master'
[ffmpeg] / libavfilter / sink_buffer.c
index 926362bef8817d7565395815460dceec50a06731..3eb66ca7d5c0249b261eb8ec9d68fe0264eb4895 100644 (file)
@@ -42,7 +42,6 @@ AVBufferSinkParams *av_buffersink_params_alloc(void)
 AVABufferSinkParams *av_abuffersink_params_alloc(void)
 {
     static const int sample_fmts[] = { -1 };
-    static const int packing_fmts[] = { -1 };
     static const int64_t channel_layouts[] = { -1 };
     AVABufferSinkParams *params = av_malloc(sizeof(AVABufferSinkParams));
 
@@ -51,7 +50,6 @@ AVABufferSinkParams *av_abuffersink_params_alloc(void)
 
     params->sample_fmts = sample_fmts;
     params->channel_layouts = channel_layouts;
-    params->packing_fmts = packing_fmts;
     return params;
 }
 
@@ -64,7 +62,6 @@ typedef struct {
     /* only used for audio */
     enum AVSampleFormat *sample_fmts;       ///< list of accepted sample formats, terminated by AV_SAMPLE_FMT_NONE
     int64_t *channel_layouts;               ///< list of accepted channel layouts, terminated by -1
-    int *packing_fmts;                      ///< list of accepted packing formats, terminated by -1
 } BufferSinkContext;
 
 #define FIFO_INIT_SIZE 8
@@ -126,6 +123,8 @@ int av_buffersink_get_buffer_ref(AVFilterContext *ctx,
 
     /* no picref available, fetch it from the filterchain */
     if (!av_fifo_size(buf->fifo)) {
+        if (flags & AV_BUFFERSINK_FLAG_NO_REQUEST)
+            return AVERROR(EAGAIN);
         if ((ret = avfilter_request_frame(inlink)) < 0)
             return ret;
     }
@@ -165,9 +164,9 @@ static av_cold int vsink_init(AVFilterContext *ctx, const char *args, void *opaq
     av_unused AVBufferSinkParams *params;
 
     if (!opaque) {
-        av_log(ctx, AV_LOG_ERROR,
+        av_log(ctx, AV_LOG_WARNING,
                "No opaque field provided\n");
-        return AVERROR(EINVAL);
+        buf->pixel_fmts = NULL;
     } else {
 #if FF_API_OLD_VSINK_API
         const int *pixel_fmts = (const enum PixelFormat *)opaque;
@@ -194,7 +193,11 @@ static int vsink_query_formats(AVFilterContext *ctx)
 {
     BufferSinkContext *buf = ctx->priv;
 
-    avfilter_set_common_pixel_formats(ctx, avfilter_make_format_list(buf->pixel_fmts));
+    if (buf->pixel_fmts)
+        avfilter_set_common_pixel_formats(ctx, avfilter_make_format_list(buf->pixel_fmts));
+    else
+        avfilter_default_query_formats(ctx);
+
     return 0;
 }
 
@@ -238,11 +241,9 @@ static av_cold int asink_init(AVFilterContext *ctx, const char *args, void *opaq
 
     buf->sample_fmts     = ff_copy_int_list  (params->sample_fmts);
     buf->channel_layouts = ff_copy_int64_list(params->channel_layouts);
-    buf->packing_fmts    = ff_copy_int_list  (params->packing_fmts);
-    if (!buf->sample_fmts || !buf->channel_layouts || !buf->sample_fmts) {
+    if (!buf->sample_fmts || !buf->channel_layouts) {
         av_freep(&buf->sample_fmts);
         av_freep(&buf->channel_layouts);
-        av_freep(&buf->packing_fmts);
         return AVERROR(ENOMEM);
     }
 
@@ -255,7 +256,6 @@ static av_cold void asink_uninit(AVFilterContext *ctx)
 
     av_freep(&buf->sample_fmts);
     av_freep(&buf->channel_layouts);
-    av_freep(&buf->packing_fmts);
     return common_uninit(ctx);
 }
 
@@ -263,18 +263,16 @@ static int asink_query_formats(AVFilterContext *ctx)
 {
     BufferSinkContext *buf = ctx->priv;
     AVFilterFormats *formats = NULL;
+    AVFilterChannelLayouts *layouts = NULL;
 
     if (!(formats = avfilter_make_format_list(buf->sample_fmts)))
         return AVERROR(ENOMEM);
     avfilter_set_common_sample_formats(ctx, formats);
 
-    if (!(formats = avfilter_make_format64_list(buf->channel_layouts)))
-        return AVERROR(ENOMEM);
-    avfilter_set_common_channel_layouts(ctx, formats);
-
-    if (!(formats = avfilter_make_format_list(buf->packing_fmts)))
+    if (!(layouts = avfilter_make_format64_list(buf->channel_layouts)))
         return AVERROR(ENOMEM);
-    avfilter_set_common_packing_formats(ctx, formats);
+    ff_set_common_channel_layouts(ctx, layouts);
+    ff_set_common_samplerates          (ctx, ff_all_samplerates());
 
     return 0;
 }