Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Raja Rathour via ffmpeg-devel <ffmpeg-devel@ffmpeg.org>
To: ffmpeg-devel@ffmpeg.org
Cc: Raja Rathour <imraja729@gmail.com>
Subject: [FFmpeg-devel] [PATCH 3/4] avfilter/dnn_backend_torch: add support for dynamic input shapes
Date: Tue, 20 Jan 2026 19:39:38 +0530
Message-ID: <20260120140939.32403-3-imraja729@gmail.com> (raw)
In-Reply-To: <20260120140939.32403-1-imraja729@gmail.com>

---
 libavfilter/dnn/dnn_backend_torch.cpp | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/libavfilter/dnn/dnn_backend_torch.cpp b/libavfilter/dnn/dnn_backend_torch.cpp
index fee1cfb3a7..4f7ae17aab 100644
--- a/libavfilter/dnn/dnn_backend_torch.cpp
+++ b/libavfilter/dnn/dnn_backend_torch.cpp
@@ -206,8 +206,12 @@ static int fill_model_input_th(THModel *th_model, THRequestItem *request)
     size_t cur_size = input.dims[height_idx] * input.dims[width_idx] *
                       input.dims[channel_idx] * sizeof(float);
 
-    // Initial allocation
-    if (!infer_request->input_data) {
+    /**
+     * Dynamic Resizing Logic:
+     * Only reallocate if the existing buffer is too small or doesn't exist.
+     */
+    if (!infer_request->input_data || infer_request->input_data_size < cur_size) {
+        av_freep(&infer_request->input_data);
         infer_request->input_data = av_malloc(cur_size);
         if (!infer_request->input_data)
             return AVERROR(ENOMEM);
-- 
2.51.0

_______________________________________________
ffmpeg-devel mailing list -- ffmpeg-devel@ffmpeg.org
To unsubscribe send an email to ffmpeg-devel-leave@ffmpeg.org

  parent reply	other threads:[~2026-01-20 14:11 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-20 14:09 [FFmpeg-devel] [PATCH 1/4] avfilter/dnn_backend_torch: implement common async infrastructure Raja Rathour via ffmpeg-devel
2026-01-20 14:09 ` [FFmpeg-devel] [PATCH 2/4] avfilter/dnn_backend_torch: fix memory leak with persistent input buffer Raja Rathour via ffmpeg-devel
2026-01-20 14:09 ` Raja Rathour via ffmpeg-devel [this message]
2026-01-20 14:09 ` [FFmpeg-devel] [PATCH 4/4] avfilter/dnn_backend_torch: improve device selection and error handling Raja Rathour via ffmpeg-devel
2026-01-21  2:08 ` [FFmpeg-devel] Re: [PATCH 1/4] avfilter/dnn_backend_torch: implement common async infrastructure Guo, Yejun via ffmpeg-devel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260120140939.32403-3-imraja729@gmail.com \
    --to=ffmpeg-devel@ffmpeg.org \
    --cc=imraja729@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git