History

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.)

Andreas Rheinhardt committed 2 years ago

Commit 32538da1 parent 4a732995 files · +27 −26Browse files

Showing the changes to libavfilter (5 of 5 files). Show all

Unified · Split

5 files
  1. libavfilter/audio.c +12 −10
  2. libavfilter/avfilter.c +1 −1
  3. libavfilter/avfilter.h +0 −5
  4. libavfilter/avfilter_internal.h +2 −0
  5. libavfilter/video.c +12 −10
libavfilter/audio.c+12−10
@@ -26,6 +26,7 @@ · 25 unmodified lines
2626
2727 #include "audio.h"
2828 #include "avfilter.h"
29+#include "avfilter_internal.h"
2930 #include "framepool.h"
3031 #include "internal.h"
3132
@@ -44,6 +45,7 @@ AVFrame *ff_null_get_audio_buffer(AVFilterLink *link, int nb_samples) · 12 unmodified lines
4445 AVFrame *ff_default_get_audio_buffer(AVFilterLink *link, int nb_samples)
4546 {
4647 AVFrame *frame = NULL;
48+ FilterLinkInternal *const li = ff_link_internal(link);
4749 int channels = link->ch_layout.nb_channels;
4850 int align = av_cpu_max_align();
4951 #if FF_API_OLD_CHANNEL_LAYOUT
@@ -54,10 +56,10 @@ FF_DISABLE_DEPRECATION_WARNINGS · 4 unmodified lines
5456 FF_ENABLE_DEPRECATION_WARNINGS
5557 #endif
5658
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)
6163 return NULL;
6264 } else {
6365 int pool_channels = 0;
@@ -65,7 +67,7 @@ FF_ENABLE_DEPRECATION_WARNINGS · 1 unmodified line
6567 int pool_align = 0;
6668 enum AVSampleFormat pool_format = AV_SAMPLE_FMT_NONE;
6769
68− if (ff_frame_pool_get_audio_config(link->frame_pool,
70+ if (ff_frame_pool_get_audio_config(li->frame_pool,
6971 &pool_channels, &pool_nb_samples,
7072 &pool_format, &pool_align) < 0) {
7173 return NULL;
@@ -74,15 +76,15 @@ FF_ENABLE_DEPRECATION_WARNINGS · 2 unmodified lines
7476 if (pool_channels != channels || pool_nb_samples < nb_samples ||
7577 pool_format != link->format || pool_align != align) {
7678
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)
8183 return NULL;
8284 }
8385 }
8486
85− frame = ff_frame_pool_get(link->frame_pool);
87+ frame = ff_frame_pool_get(li->frame_pool);
8688 if (!frame)
8789 return NULL;
8890
libavfilter/avfilter.c+1−1
@@ -201,7 +201,7 @@ void avfilter_link_free(AVFilterLink **link) · 200 unmodified lines
201201 li = ff_link_internal(*link);
202202
203203 ff_framequeue_free(&li->fifo);
204− ff_frame_pool_uninit((FFFramePool**)&(*link)->frame_pool);
204+ ff_frame_pool_uninit(&li->frame_pool);
205205 av_channel_layout_uninit(&(*link)->ch_layout);
206206
207207 av_freep(link);
libavfilter/avfilter.h+0−5
@@ -666,11 +666,6 @@ struct AVFilterLink { · 665 unmodified lines
666666 */
667667 int64_t sample_count_in, sample_count_out;
668668
669− /**
670− * A pointer to a FFFramePool struct.
671− */
672− void *frame_pool;
673−
674669 /**
675670 * True if a frame is currently wanted on the output of this filter.
676671 * Set when ff_request_frame() is called by the output,
libavfilter/avfilter_internal.h+2−0
@@ -33,6 +33,8 @@ · 32 unmodified lines
3333 typedef struct FilterLinkInternal {
3434 AVFilterLink l;
3535
36+ struct FFFramePool *frame_pool;
37+
3638 /**
3739 * Queue of frames waiting to be filtered.
3840 */
libavfilter/video.c+12−10
@@ -29,6 +29,7 @@ · 28 unmodified lines
2929 #include "libavutil/imgutils.h"
3030
3131 #include "avfilter.h"
32+#include "avfilter_internal.h"
3233 #include "framepool.h"
3334 #include "internal.h"
3435 #include "video.h"
@@ -47,6 +48,7 @@ AVFrame *ff_null_get_video_buffer(AVFilterLink *link, int w, int h) · 12 unmodified lines
4748
4849 AVFrame *ff_default_get_video_buffer2(AVFilterLink *link, int w, int h, int align)
4950 {
51+ FilterLinkInternal *const li = ff_link_internal(link);
5052 AVFrame *frame = NULL;
5153 int pool_width = 0;
5254 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
6870 return frame;
6971 }
7072
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)
7577 return NULL;
7678 } else {
77− if (ff_frame_pool_get_video_config(link->frame_pool,
79+ if (ff_frame_pool_get_video_config(li->frame_pool,
7880 &pool_width, &pool_height,
7981 &pool_format, &pool_align) < 0) {
8082 return NULL;
@@ -83,15 +85,15 @@ AVFrame *ff_default_get_video_buffer2(AVFilterLink *link, int w, int h, int alig · 2 unmodified lines
8385 if (pool_width != w || pool_height != h ||
8486 pool_format != link->format || pool_align != align) {
8587
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)
9092 return NULL;
9193 }
9294 }
9395
94− frame = ff_frame_pool_get(link->frame_pool);
96+ frame = ff_frame_pool_get(li->frame_pool);
9597 if (!frame)
9698 return NULL;
9799

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t