avfilter/avfilter: Move frame_pool to FilterLinkInternal
Avoids ugly casts when uninitializing. (One could actually avoid allocating this separately if one were willing to expose FFFramePool to those files including link_internal.h.) Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
		
							parent
							
								
									4a7329994a
								
							
						
					
					
						commit
						32538dafca
					
				| @ -26,6 +26,7 @@ | |||||||
| 
 | 
 | ||||||
| #include "audio.h" | #include "audio.h" | ||||||
| #include "avfilter.h" | #include "avfilter.h" | ||||||
|  | #include "avfilter_internal.h" | ||||||
| #include "framepool.h" | #include "framepool.h" | ||||||
| #include "internal.h" | #include "internal.h" | ||||||
| 
 | 
 | ||||||
| @ -44,6 +45,7 @@ AVFrame *ff_null_get_audio_buffer(AVFilterLink *link, int nb_samples) | |||||||
| AVFrame *ff_default_get_audio_buffer(AVFilterLink *link, int nb_samples) | AVFrame *ff_default_get_audio_buffer(AVFilterLink *link, int nb_samples) | ||||||
| { | { | ||||||
|     AVFrame *frame = NULL; |     AVFrame *frame = NULL; | ||||||
|  |     FilterLinkInternal *const li = ff_link_internal(link); | ||||||
|     int channels = link->ch_layout.nb_channels; |     int channels = link->ch_layout.nb_channels; | ||||||
|     int align = av_cpu_max_align(); |     int align = av_cpu_max_align(); | ||||||
| #if FF_API_OLD_CHANNEL_LAYOUT | #if FF_API_OLD_CHANNEL_LAYOUT | ||||||
| @ -54,10 +56,10 @@ FF_DISABLE_DEPRECATION_WARNINGS | |||||||
| FF_ENABLE_DEPRECATION_WARNINGS | FF_ENABLE_DEPRECATION_WARNINGS | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
|     if (!link->frame_pool) { |     if (!li->frame_pool) { | ||||||
|         link->frame_pool = ff_frame_pool_audio_init(av_buffer_allocz, channels, |         li->frame_pool = ff_frame_pool_audio_init(av_buffer_allocz, channels, | ||||||
|                                                   nb_samples, link->format, align); |                                                   nb_samples, link->format, align); | ||||||
|         if (!link->frame_pool) |         if (!li->frame_pool) | ||||||
|             return NULL; |             return NULL; | ||||||
|     } else { |     } else { | ||||||
|         int pool_channels = 0; |         int pool_channels = 0; | ||||||
| @ -65,7 +67,7 @@ FF_ENABLE_DEPRECATION_WARNINGS | |||||||
|         int pool_align = 0; |         int pool_align = 0; | ||||||
|         enum AVSampleFormat pool_format = AV_SAMPLE_FMT_NONE; |         enum AVSampleFormat pool_format = AV_SAMPLE_FMT_NONE; | ||||||
| 
 | 
 | ||||||
|         if (ff_frame_pool_get_audio_config(link->frame_pool, |         if (ff_frame_pool_get_audio_config(li->frame_pool, | ||||||
|                                            &pool_channels, &pool_nb_samples, |                                            &pool_channels, &pool_nb_samples, | ||||||
|                                            &pool_format, &pool_align) < 0) { |                                            &pool_format, &pool_align) < 0) { | ||||||
|             return NULL; |             return NULL; | ||||||
| @ -74,15 +76,15 @@ FF_ENABLE_DEPRECATION_WARNINGS | |||||||
|         if (pool_channels != channels || pool_nb_samples < nb_samples || |         if (pool_channels != channels || pool_nb_samples < nb_samples || | ||||||
|             pool_format != link->format || pool_align != align) { |             pool_format != link->format || pool_align != align) { | ||||||
| 
 | 
 | ||||||
|             ff_frame_pool_uninit((FFFramePool **)&link->frame_pool); |             ff_frame_pool_uninit(&li->frame_pool); | ||||||
|             link->frame_pool = ff_frame_pool_audio_init(av_buffer_allocz, channels, |             li->frame_pool = ff_frame_pool_audio_init(av_buffer_allocz, channels, | ||||||
|                                                       nb_samples, link->format, align); |                                                       nb_samples, link->format, align); | ||||||
|             if (!link->frame_pool) |             if (!li->frame_pool) | ||||||
|                 return NULL; |                 return NULL; | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     frame = ff_frame_pool_get(link->frame_pool); |     frame = ff_frame_pool_get(li->frame_pool); | ||||||
|     if (!frame) |     if (!frame) | ||||||
|         return NULL; |         return NULL; | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -201,7 +201,7 @@ void avfilter_link_free(AVFilterLink **link) | |||||||
|     li = ff_link_internal(*link); |     li = ff_link_internal(*link); | ||||||
| 
 | 
 | ||||||
|     ff_framequeue_free(&li->fifo); |     ff_framequeue_free(&li->fifo); | ||||||
|     ff_frame_pool_uninit((FFFramePool**)&(*link)->frame_pool); |     ff_frame_pool_uninit(&li->frame_pool); | ||||||
|     av_channel_layout_uninit(&(*link)->ch_layout); |     av_channel_layout_uninit(&(*link)->ch_layout); | ||||||
| 
 | 
 | ||||||
|     av_freep(link); |     av_freep(link); | ||||||
|  | |||||||
| @ -666,11 +666,6 @@ struct AVFilterLink { | |||||||
|      */ |      */ | ||||||
|     int64_t sample_count_in, sample_count_out; |     int64_t sample_count_in, sample_count_out; | ||||||
| 
 | 
 | ||||||
|     /**
 |  | ||||||
|      * A pointer to a FFFramePool struct. |  | ||||||
|      */ |  | ||||||
|     void *frame_pool; |  | ||||||
| 
 |  | ||||||
|     /**
 |     /**
 | ||||||
|      * True if a frame is currently wanted on the output of this filter. |      * True if a frame is currently wanted on the output of this filter. | ||||||
|      * Set when ff_request_frame() is called by the output, |      * Set when ff_request_frame() is called by the output, | ||||||
|  | |||||||
| @ -33,6 +33,8 @@ | |||||||
| typedef struct FilterLinkInternal { | typedef struct FilterLinkInternal { | ||||||
|     AVFilterLink l; |     AVFilterLink l; | ||||||
| 
 | 
 | ||||||
|  |     struct FFFramePool *frame_pool; | ||||||
|  | 
 | ||||||
|     /**
 |     /**
 | ||||||
|      * Queue of frames waiting to be filtered. |      * Queue of frames waiting to be filtered. | ||||||
|      */ |      */ | ||||||
|  | |||||||
| @ -29,6 +29,7 @@ | |||||||
| #include "libavutil/imgutils.h" | #include "libavutil/imgutils.h" | ||||||
| 
 | 
 | ||||||
| #include "avfilter.h" | #include "avfilter.h" | ||||||
|  | #include "avfilter_internal.h" | ||||||
| #include "framepool.h" | #include "framepool.h" | ||||||
| #include "internal.h" | #include "internal.h" | ||||||
| #include "video.h" | #include "video.h" | ||||||
| @ -47,6 +48,7 @@ AVFrame *ff_null_get_video_buffer(AVFilterLink *link, int w, int h) | |||||||
| 
 | 
 | ||||||
| AVFrame *ff_default_get_video_buffer2(AVFilterLink *link, int w, int h, int align) | AVFrame *ff_default_get_video_buffer2(AVFilterLink *link, int w, int h, int align) | ||||||
| { | { | ||||||
|  |     FilterLinkInternal *const li = ff_link_internal(link); | ||||||
|     AVFrame *frame = NULL; |     AVFrame *frame = NULL; | ||||||
|     int pool_width = 0; |     int pool_width = 0; | ||||||
|     int pool_height = 0; |     int pool_height = 0; | ||||||
| @ -68,13 +70,13 @@ AVFrame *ff_default_get_video_buffer2(AVFilterLink *link, int w, int h, int alig | |||||||
|         return frame; |         return frame; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     if (!link->frame_pool) { |     if (!li->frame_pool) { | ||||||
|         link->frame_pool = ff_frame_pool_video_init(av_buffer_allocz, w, h, |         li->frame_pool = ff_frame_pool_video_init(av_buffer_allocz, w, h, | ||||||
|                                                   link->format, align); |                                                   link->format, align); | ||||||
|         if (!link->frame_pool) |         if (!li->frame_pool) | ||||||
|             return NULL; |             return NULL; | ||||||
|     } else { |     } else { | ||||||
|         if (ff_frame_pool_get_video_config(link->frame_pool, |         if (ff_frame_pool_get_video_config(li->frame_pool, | ||||||
|                                            &pool_width, &pool_height, |                                            &pool_width, &pool_height, | ||||||
|                                            &pool_format, &pool_align) < 0) { |                                            &pool_format, &pool_align) < 0) { | ||||||
|             return NULL; |             return NULL; | ||||||
| @ -83,15 +85,15 @@ AVFrame *ff_default_get_video_buffer2(AVFilterLink *link, int w, int h, int alig | |||||||
|         if (pool_width != w || pool_height != h || |         if (pool_width != w || pool_height != h || | ||||||
|             pool_format != link->format || pool_align != align) { |             pool_format != link->format || pool_align != align) { | ||||||
| 
 | 
 | ||||||
|             ff_frame_pool_uninit((FFFramePool **)&link->frame_pool); |             ff_frame_pool_uninit(&li->frame_pool); | ||||||
|             link->frame_pool = ff_frame_pool_video_init(av_buffer_allocz, w, h, |             li->frame_pool = ff_frame_pool_video_init(av_buffer_allocz, w, h, | ||||||
|                                                       link->format, align); |                                                       link->format, align); | ||||||
|             if (!link->frame_pool) |             if (!li->frame_pool) | ||||||
|                 return NULL; |                 return NULL; | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     frame = ff_frame_pool_get(link->frame_pool); |     frame = ff_frame_pool_get(li->frame_pool); | ||||||
|     if (!frame) |     if (!frame) | ||||||
|         return NULL; |         return NULL; | ||||||
| 
 | 
 | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user