From: Jan Sebechlebsky <sebechlebsky...@gmail.com> Add custom item name function for bsf list, which will construct string description of filter chain. This is done using lazy-initialization, so there is no overhead if item name is never accessed.
Signed-off-by: Jan Sebechlebsky <sebechlebsky...@gmail.com> Conflicts: libavcodec/bsf.c --- This allows to get some text representation of list BSF filter for logging purposes. libavcodec/bsf.c | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/libavcodec/bsf.c b/libavcodec/bsf.c index 3ae0a2b..c2e13f7 100644 --- a/libavcodec/bsf.c +++ b/libavcodec/bsf.c @@ -23,6 +23,7 @@ #include "libavutil/opt.h" #include "libavutil/avassert.h" #include "libavutil/avstring.h" +#include "libavutil/bprint.h" #include "avcodec.h" #include "bsf.h" @@ -247,6 +248,7 @@ typedef struct BSFListContext { int idx; // index of currently processed BSF int flushed_idx; // index of BSF being flushed + char * item_name; } BSFListContext; @@ -370,11 +372,37 @@ static void bsf_list_close(AVBSFContext *bsf) for (i = 0; i < lst->ctx_nr; ++i) av_bsf_free(&lst->bsf_lst[i]); av_freep(&lst->bsf_lst); + av_freep(&lst->item_name); +} + +static const char *bsf_list_item_name(void *ctx) +{ + static const char *null_filter_name = "null"; + AVBSFContext *bsf_ctx = ctx; + BSFListContext *lst = bsf_ctx->priv_data; + + if (!lst->ctx_nr) + return null_filter_name; + + if (!lst->item_name) { + int i; + AVBPrint bp; + av_bprint_init(&bp, 16, 128); + + av_bprintf(&bp, "bsf_list("); + for (i = 0; i < lst->ctx_nr; i++) + av_bprintf(&bp, i ? ",%s" : "%s", lst->bsf_lst[i]->filter->name); + av_bprintf(&bp, ")"); + + av_bprint_finalize(&bp, &lst->item_name); + } + + return lst->item_name; } static const AVClass bsf_list_class = { .class_name = "bsf_list", - .item_name = av_default_item_name, + .item_name = bsf_list_item_name, .version = LIBAVUTIL_VERSION_INT, }; -- 1.9.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel