From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.ffmpeg.org (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTPS id DF40845940 for ; Mon, 14 Jul 2025 20:30:55 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTP id 0201C68EEBF; Mon, 14 Jul 2025 23:30:52 +0300 (EEST) Received: from iq.passwd.hu (iq.passwd.hu [217.27.212.140]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTP id 6DD3968EE93 for ; Mon, 14 Jul 2025 23:30:45 +0300 (EEST) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 19740EB75A for ; Mon, 14 Jul 2025 22:28:14 +0200 (CEST) X-Virus-Scanned: amavisd-new at passwd.hu Received: from iq.passwd.hu ([127.0.0.1]) by localhost (iq.passwd.hu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id zRqFO8_ib-Yf for ; Mon, 14 Jul 2025 22:28:10 +0200 (CEST) Received: from iq (iq [217.27.212.140]) by iq.passwd.hu (Postfix) with ESMTPS id A285FEB755 for ; Mon, 14 Jul 2025 22:28:10 +0200 (CEST) Date: Mon, 14 Jul 2025 22:28:10 +0200 (CEST) From: Marton Balint To: FFmpeg development discussions and patches In-Reply-To: <20250706220011.5799-1-cus@passwd.hu> Message-ID: <15bf3458-e0e4-7711-3c93-fae07ab5444a@passwd.hu> References: <20250706220011.5799-1-cus@passwd.hu> MIME-Version: 1.0 Subject: Re: [FFmpeg-devel] [PATCH 1/4] avfilter/framequeue: add support for limiting and tracking buffered frames in the queues X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: On Mon, 7 Jul 2025, Marton Balint wrote: > Signed-off-by: Marton Balint > --- > libavfilter/framequeue.c | 7 +++++++ > libavfilter/framequeue.h | 18 +++++++++++++++--- > 2 files changed, 22 insertions(+), 3 deletions(-) Will apply the series. Regards, Marton > > diff --git a/libavfilter/framequeue.c b/libavfilter/framequeue.c > index 79255fe532..3363406ba7 100644 > --- a/libavfilter/framequeue.c > +++ b/libavfilter/framequeue.c > @@ -30,6 +30,8 @@ static inline FFFrameBucket *bucket(FFFrameQueue *fq, size_t idx) > > void ff_framequeue_global_init(FFFrameQueueGlobal *fqg) > { > + fqg->max_queued = SIZE_MAX; > + fqg->queued = 0; > } > > static void check_consistency(FFFrameQueue *fq) > @@ -49,6 +51,7 @@ void ff_framequeue_init(FFFrameQueue *fq, FFFrameQueueGlobal *fqg) > { > fq->queue = &fq->first_bucket; > fq->allocated = 1; > + fq->global = fqg; > } > > void ff_framequeue_free(FFFrameQueue *fq) > @@ -66,6 +69,8 @@ int ff_framequeue_add(FFFrameQueue *fq, AVFrame *frame) > FFFrameBucket *b; > > check_consistency(fq); > + if (fq->global->queued >= fq->global->max_queued) > + return AVERROR(ENOMEM); > if (fq->queued == fq->allocated) { > if (fq->allocated == 1) { > size_t na = 8; > @@ -89,6 +94,7 @@ int ff_framequeue_add(FFFrameQueue *fq, AVFrame *frame) > b = bucket(fq, fq->queued); > b->frame = frame; > fq->queued++; > + fq->global->queued++; > fq->total_frames_head++; > fq->total_samples_head += frame->nb_samples; > check_consistency(fq); > @@ -103,6 +109,7 @@ AVFrame *ff_framequeue_take(FFFrameQueue *fq) > av_assert1(fq->queued); > b = bucket(fq, 0); > fq->queued--; > + fq->global->queued--; > fq->tail++; > fq->tail &= fq->allocated - 1; > fq->total_frames_tail++; > diff --git a/libavfilter/framequeue.h b/libavfilter/framequeue.h > index c49d872e85..405a43c65d 100644 > --- a/libavfilter/framequeue.h > +++ b/libavfilter/framequeue.h > @@ -40,11 +40,18 @@ typedef struct FFFrameBucket { > * > * This structure is intended to allow implementing global control of the > * frame queues, including memory consumption caps. > - * > - * It is currently empty. > */ > typedef struct FFFrameQueueGlobal { > - char dummy; /* C does not allow empty structs */ > + > + /** > + * Maximum number of allowed frames in the queues combined. > + */ > + size_t max_queued; > + > + /** > + * Total number of queued frames in the queues combined. > + */ > + size_t queued; > } FFFrameQueueGlobal; > > /** > @@ -52,6 +59,11 @@ typedef struct FFFrameQueueGlobal { > */ > typedef struct FFFrameQueue { > > + /** > + * Pointer to the global frame queue struct holding statistics and limits > + */ > + FFFrameQueueGlobal *global; > + > /** > * Array of allocated buckets, used as a circular buffer. > */ > -- > 2.43.0 > > _______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". > _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".