[FFmpeg-devel] [PATCH 4/6] sink_buffer: make consistency assert more readable.

Nicolas George nicolas.george at normalesup.org
Mon Jun 25 00:35:58 CEST 2012


Using strcmp in the assert yields a message with the full
expansion of the strcmp macro, completely unreadable.
This version is also more efficient.

Signed-off-by: Nicolas George <nicolas.george at normalesup.org>
---
 libavfilter/sink_buffer.c |    9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/libavfilter/sink_buffer.c b/libavfilter/sink_buffer.c
index 5c85638..2ee3886 100644
--- a/libavfilter/sink_buffer.c
+++ b/libavfilter/sink_buffer.c
@@ -29,6 +29,9 @@
 #include "buffersink.h"
 #include "internal.h"
 
+extern AVFilter avfilter_vsink_buffersink;
+extern AVFilter avfilter_asink_abuffersink;
+
 AVBufferSinkParams *av_buffersink_params_alloc(void)
 {
     static const int pixel_fmts[] = { -1 };
@@ -123,7 +126,7 @@ int av_buffersink_get_buffer_ref(AVFilterContext *ctx,
     int ret;
     *bufref = NULL;
 
-    av_assert0(!strcmp(ctx->filter->name, "buffersink") || !strcmp(ctx->filter->name, "abuffersink"));
+    av_assert1(ctx->filter == &avfilter_vsink_buffersink || ctx->filter == &avfilter_asink_abuffersink);
 
     /* no picref available, fetch it from the filterchain */
     if (!av_fifo_size(buf->fifo)) {
@@ -146,7 +149,7 @@ int av_buffersink_get_buffer_ref(AVFilterContext *ctx,
 
 AVRational av_buffersink_get_frame_rate(AVFilterContext *ctx)
 {
-    av_assert0(!strcmp(ctx->filter->name, "buffersink"));
+    av_assert1(ctx->filter == &avfilter_vsink_buffersink);
 
     return ctx->inputs[0]->frame_rate;
 }
@@ -156,7 +159,7 @@ int av_buffersink_poll_frame(AVFilterContext *ctx)
     BufferSinkContext *buf = ctx->priv;
     AVFilterLink *inlink = ctx->inputs[0];
 
-    av_assert0(!strcmp(ctx->filter->name, "buffersink") || !strcmp(ctx->filter->name, "abuffersink"));
+    av_assert1(ctx->filter == &avfilter_vsink_buffersink || ctx->filter == &avfilter_asink_abuffersink);
 
     return av_fifo_size(buf->fifo)/sizeof(AVFilterBufferRef *) + ff_poll_frame(inlink);
 }
-- 
1.7.10



More information about the ffmpeg-devel mailing list