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.)
Showing the changes to libavfilter (5 of 5 files). Show all
Unified · Split
| @@ -26,6 +26,7 @@ · 25 unmodified lines | |||
| 26 | 26 | ||
| 27 | #include "audio.h" | 27 | #include "audio.h" |
| 28 | #include "avfilter.h" | 28 | #include "avfilter.h" |
| 29 | #include "avfilter_internal.h" | ||
| 29 | #include "framepool.h" | 30 | #include "framepool.h" |
| 30 | #include "internal.h" | 31 | #include "internal.h" |
| 31 | 32 | ||
| @@ -44,6 +45,7 @@ AVFrame *ff_null_get_audio_buffer(AVFilterLink *link, int nb_samples) · 12 unmodified lines | |||
| 44 | AVFrame *ff_default_get_audio_buffer(AVFilterLink *link, int nb_samples) | 45 | AVFrame *ff_default_get_audio_buffer(AVFilterLink *link, int nb_samples) |
| 45 | { | 46 | { |
| 46 | AVFrame *frame = NULL; | 47 | AVFrame *frame = NULL; |
| 48 | FilterLinkInternal *const li = ff_link_internal(link); | ||
| 47 | int channels = link->ch_layout.nb_channels; | 49 | int channels = link->ch_layout.nb_channels; |
| 48 | int align = av_cpu_max_align(); | 50 | int align = av_cpu_max_align(); |
| 49 | #if FF_API_OLD_CHANNEL_LAYOUT | 51 | #if FF_API_OLD_CHANNEL_LAYOUT |
| @@ -54,10 +56,10 @@ FF_DISABLE_DEPRECATION_WARNINGS · 4 unmodified lines | |||
| 54 | FF_ENABLE_DEPRECATION_WARNINGS | 56 | FF_ENABLE_DEPRECATION_WARNINGS |
| 55 | #endif | 57 | #endif |
| 56 | 58 | ||
| 57 | if (!link->frame_pool) { | 59 | if (!li->frame_pool) { |
| 58 | link->frame_pool = ff_frame_pool_audio_init(av_buffer_allocz, channels, | 60 | li->frame_pool = ff_frame_pool_audio_init(av_buffer_allocz, channels, |
| 59 | nb_samples, link->format, align); | 61 | nb_samples, link->format, align); |
| 60 | if (!link->frame_pool) | 62 | if (!li->frame_pool) |
| 61 | return NULL; | 63 | return NULL; |
| 62 | } else { | 64 | } else { |
| 63 | int pool_channels = 0; | 65 | int pool_channels = 0; |
| @@ -65,7 +67,7 @@ FF_ENABLE_DEPRECATION_WARNINGS · 1 unmodified line | |||
| 65 | int pool_align = 0; | 67 | int pool_align = 0; |
| 66 | enum AVSampleFormat pool_format = AV_SAMPLE_FMT_NONE; | 68 | enum AVSampleFormat pool_format = AV_SAMPLE_FMT_NONE; |
| 67 | 69 | ||
| 68 | if (ff_frame_pool_get_audio_config(link->frame_pool, | 70 | if (ff_frame_pool_get_audio_config(li->frame_pool, |
| 69 | &pool_channels, &pool_nb_samples, | 71 | &pool_channels, &pool_nb_samples, |
| 70 | &pool_format, &pool_align) < 0) { | 72 | &pool_format, &pool_align) < 0) { |
| 71 | return NULL; | 73 | return NULL; |
| @@ -74,15 +76,15 @@ FF_ENABLE_DEPRECATION_WARNINGS · 2 unmodified lines | |||
| 74 | if (pool_channels != channels || pool_nb_samples < nb_samples || | 76 | if (pool_channels != channels || pool_nb_samples < nb_samples || |
| 75 | pool_format != link->format || pool_align != align) { | 77 | pool_format != link->format || pool_align != align) { |
| 76 | 78 | ||
| 77 | ff_frame_pool_uninit((FFFramePool **)&link->frame_pool); | 79 | ff_frame_pool_uninit(&li->frame_pool); |
| 78 | link->frame_pool = ff_frame_pool_audio_init(av_buffer_allocz, channels, | 80 | li->frame_pool = ff_frame_pool_audio_init(av_buffer_allocz, channels, |
| 79 | nb_samples, link->format, align); | 81 | nb_samples, link->format, align); |
| 80 | if (!link->frame_pool) | 82 | if (!li->frame_pool) |
| 81 | return NULL; | 83 | return NULL; |
| 82 | } | 84 | } |
| 83 | } | 85 | } |
| 84 | 86 | ||
| 85 | frame = ff_frame_pool_get(link->frame_pool); | 87 | frame = ff_frame_pool_get(li->frame_pool); |
| 86 | if (!frame) | 88 | if (!frame) |
| 87 | return NULL; | 89 | return NULL; |
| 88 | 90 | ||
| @@ -201,7 +201,7 @@ void avfilter_link_free(AVFilterLink **link) · 200 unmodified lines | |||
| 201 | li = ff_link_internal(*link); | 201 | li = ff_link_internal(*link); |
| 202 | 202 | ||
| 203 | ff_framequeue_free(&li->fifo); | 203 | ff_framequeue_free(&li->fifo); |
| 204 | ff_frame_pool_uninit((FFFramePool**)&(*link)->frame_pool); | 204 | ff_frame_pool_uninit(&li->frame_pool); |
| 205 | av_channel_layout_uninit(&(*link)->ch_layout); | 205 | av_channel_layout_uninit(&(*link)->ch_layout); |
| 206 | 206 | ||
| 207 | av_freep(link); | 207 | av_freep(link); |
| @@ -666,11 +666,6 @@ struct AVFilterLink { · 665 unmodified lines | |||
| 666 | */ | 666 | */ |
| 667 | int64_t sample_count_in, sample_count_out; | 667 | int64_t sample_count_in, sample_count_out; |
| 668 | 668 | ||
| 669 | /** | ||
| 670 | * A pointer to a FFFramePool struct. | ||
| 671 | */ | ||
| 672 | void *frame_pool; | ||
| 673 | |||
| 674 | /** | 669 | /** |
| 675 | * True if a frame is currently wanted on the output of this filter. | 670 | * True if a frame is currently wanted on the output of this filter. |
| 676 | * Set when ff_request_frame() is called by the output, | 671 | * Set when ff_request_frame() is called by the output, |
| @@ -33,6 +33,8 @@ · 32 unmodified lines | |||
| 33 | typedef struct FilterLinkInternal { | 33 | typedef struct FilterLinkInternal { |
| 34 | AVFilterLink l; | 34 | AVFilterLink l; |
| 35 | 35 | ||
| 36 | struct FFFramePool *frame_pool; | ||
| 37 | |||
| 36 | /** | 38 | /** |
| 37 | * Queue of frames waiting to be filtered. | 39 | * Queue of frames waiting to be filtered. |
| 38 | */ | 40 | */ |
| @@ -29,6 +29,7 @@ · 28 unmodified lines | |||
| 29 | #include "libavutil/imgutils.h" | 29 | #include "libavutil/imgutils.h" |
| 30 | 30 | ||
| 31 | #include "avfilter.h" | 31 | #include "avfilter.h" |
| 32 | #include "avfilter_internal.h" | ||
| 32 | #include "framepool.h" | 33 | #include "framepool.h" |
| 33 | #include "internal.h" | 34 | #include "internal.h" |
| 34 | #include "video.h" | 35 | #include "video.h" |
| @@ -47,6 +48,7 @@ AVFrame *ff_null_get_video_buffer(AVFilterLink *link, int w, int h) · 12 unmodified lines | |||
| 47 | 48 | ||
| 48 | AVFrame *ff_default_get_video_buffer2(AVFilterLink *link, int w, int h, int align) | 49 | AVFrame *ff_default_get_video_buffer2(AVFilterLink *link, int w, int h, int align) |
| 49 | { | 50 | { |
| 51 | FilterLinkInternal *const li = ff_link_internal(link); | ||
| 50 | AVFrame *frame = NULL; | 52 | AVFrame *frame = NULL; |
| 51 | int pool_width = 0; | 53 | int pool_width = 0; |
| 52 | int pool_height = 0; | 54 | int pool_height = 0; |
| @@ -68,13 +70,13 @@ AVFrame *ff_default_get_video_buffer2(AVFilterLink *link, int w, int h, int alig · 15 unmodified lines | |||
| 68 | return frame; | 70 | return frame; |
| 69 | } | 71 | } |
| 70 | 72 | ||
| 71 | if (!link->frame_pool) { | 73 | if (!li->frame_pool) { |
| 72 | link->frame_pool = ff_frame_pool_video_init(av_buffer_allocz, w, h, | 74 | li->frame_pool = ff_frame_pool_video_init(av_buffer_allocz, w, h, |
| 73 | link->format, align); | 75 | link->format, align); |
| 74 | if (!link->frame_pool) | 76 | if (!li->frame_pool) |
| 75 | return NULL; | 77 | return NULL; |
| 76 | } else { | 78 | } else { |
| 77 | if (ff_frame_pool_get_video_config(link->frame_pool, | 79 | if (ff_frame_pool_get_video_config(li->frame_pool, |
| 78 | &pool_width, &pool_height, | 80 | &pool_width, &pool_height, |
| 79 | &pool_format, &pool_align) < 0) { | 81 | &pool_format, &pool_align) < 0) { |
| 80 | return NULL; | 82 | return NULL; |
| @@ -83,15 +85,15 @@ AVFrame *ff_default_get_video_buffer2(AVFilterLink *link, int w, int h, int alig · 2 unmodified lines | |||
| 83 | if (pool_width != w || pool_height != h || | 85 | if (pool_width != w || pool_height != h || |
| 84 | pool_format != link->format || pool_align != align) { | 86 | pool_format != link->format || pool_align != align) { |
| 85 | 87 | ||
| 86 | ff_frame_pool_uninit((FFFramePool **)&link->frame_pool); | 88 | ff_frame_pool_uninit(&li->frame_pool); |
| 87 | link->frame_pool = ff_frame_pool_video_init(av_buffer_allocz, w, h, | 89 | li->frame_pool = ff_frame_pool_video_init(av_buffer_allocz, w, h, |
| 88 | link->format, align); | 90 | link->format, align); |
| 89 | if (!link->frame_pool) | 91 | if (!li->frame_pool) |
| 90 | return NULL; | 92 | return NULL; |
| 91 | } | 93 | } |
| 92 | } | 94 | } |
| 93 | 95 | ||
| 94 | frame = ff_frame_pool_get(link->frame_pool); | 96 | frame = ff_frame_pool_get(li->frame_pool); |
| 95 | if (!frame) | 97 | if (!frame) |
| 96 | return NULL; | 98 | return NULL; |
| 97 | 99 | ||