You've already forked FFmpeg
							
							
				mirror of
				https://github.com/FFmpeg/FFmpeg.git
				synced 2025-10-30 23:18:11 +02:00 
			
		
		
		
	avcodec/bsf: 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: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
		
				
					committed by
					
						 Michael Niedermayer
						Michael Niedermayer
					
				
			
			
				
	
			
			
			
						parent
						
							4d7d74802d
						
					
				
				
					commit
					57503fab4f
				
			| @@ -248,6 +248,7 @@ typedef struct BSFListContext { | ||||
|     unsigned idx;           // index of currently processed BSF | ||||
|     unsigned flushed_idx;   // index of BSF being flushed | ||||
|  | ||||
|     char * item_name; | ||||
| } BSFListContext; | ||||
|  | ||||
|  | ||||
| @@ -345,11 +346,37 @@ static void bsf_list_close(AVBSFContext *bsf) | ||||
|     for (i = 0; i < lst->nb_bsfs; ++i) | ||||
|         av_bsf_free(&lst->bsfs[i]); | ||||
|     av_freep(&lst->bsfs); | ||||
|     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->nb_bsfs) | ||||
|         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->nb_bsfs; i++) | ||||
|             av_bprintf(&bp, i ? ",%s" : "%s", lst->bsfs[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, | ||||
| }; | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user