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