From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 99089496B0 for ; Sat, 17 Feb 2024 22:04:28 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 9DAE568D2F4; Sun, 18 Feb 2024 00:03:48 +0200 (EET) Received: from mail-pg1-f180.google.com (mail-pg1-f180.google.com [209.85.215.180]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 5A49F68CF80 for ; Sun, 18 Feb 2024 00:03:41 +0200 (EET) Received: by mail-pg1-f180.google.com with SMTP id 41be03b00d2f7-5d8b519e438so2967831a12.1 for ; Sat, 17 Feb 2024 14:03:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708207419; x=1708812219; darn=ffmpeg.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=X8PT7E1/b09Ng5aXU70n8IJ+x2Fw7IJkJtQiwez3r+U=; b=YMC0nl+uDBEYR0a+RPlXCo8QkpN/GHR0uGpKYSvoQR1mZLINfqaAgQL0rWUvNMFUsy LzvxBRFRRA8VxVqdRN61Qhum0MV1gaCD48SGbJswqnmg03GR9M4h1otYCEgfT5W99D6T fqHUsqrGU4MaL0Y8H0kBWEYY8ZfcjalE2v7D3+so0uc6UsI0Yd7YOv30+qoziR+Z0fLR MQ1X23sUDKhLDqQUFqApCI5ing4c1ZFmmuUx+6TQyN17IGGKZwb8g3VNWmSQE0LyAqJw Gfx7fOV/JPelDLcHPLeNjIucOCMwjZ6N8mhkZVIgXqYkklL3+m5Z84RmK8Tqzb/eGiOw N12g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708207419; x=1708812219; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=X8PT7E1/b09Ng5aXU70n8IJ+x2Fw7IJkJtQiwez3r+U=; b=Jn9Y9XSYpWdbFbF4GSII5gH2l9ddlJcpds0T+jZeSK/guDHeCPLCYfIWk2vN5zLw/u g/plVQu6SUtCueWxpY4tWK2gi0h10mLd3i+xchGDADlfgPrNjEjjm5E9yXq6auGZb70v aou4be4xC8VZ2I7HhIbbxE/d6DiPxPtzIcb8uUP30RSP7mcKmZLStqJY2Ei5UWNXru0m dpI6s3E3LOUZeCWb0wpvpNjNqE4vEvImKIZ9DR8cQdTAdRML4W9CVPc59umi/u9dasQk XqAcR82PGr/KidJoWZqG07ca0lH4NdmJy8h/8zfbb85KVaalbNWd6jM/htdrSZjrhsm8 q0IQ== X-Gm-Message-State: AOJu0YyroExZSWBgjciBUkLD7MfAuI5OnTzWBbvrdk+tkyMKGKQGi4lJ Mdr52DqVdi2pB0h8XMN7XuyRahV0TRxChbpCohglGOCx4bfSZ4xVRFYRispW X-Google-Smtp-Source: AGHT+IFFH6JN2c1NSZ2gumwu3KcLfhylcdev9cSJGpZ4v3CWCy0du5SLK9Egl8x606btSOwJCqXBrg== X-Received: by 2002:a17:902:d548:b0:1db:4419:e933 with SMTP id z8-20020a170902d54800b001db4419e933mr10032481plf.17.1708207418756; Sat, 17 Feb 2024 14:03:38 -0800 (PST) Received: from localhost.localdomain (host197.190-225-105.telecom.net.ar. [190.225.105.197]) by smtp.gmail.com with ESMTPSA id e6-20020a17090301c600b001d77a0e1374sm1850326plh.151.2024.02.17.14.03.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 17 Feb 2024 14:03:38 -0800 (PST) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Sat, 17 Feb 2024 19:02:38 -0300 Message-ID: <20240217220242.62035-4-jamrial@gmail.com> X-Mailer: git-send-email 2.43.1 In-Reply-To: <20240217220242.62035-1-jamrial@gmail.com> References: <20240217220242.62035-1-jamrial@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 4/8] avformat/mov: make MOVStreamContext refcounted 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-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: This will be useful in the next commit. Signed-off-by: James Almer --- libavformat/isom.h | 1 + libavformat/mov.c | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/libavformat/isom.h b/libavformat/isom.h index a4cca4c798..eee94d0449 100644 --- a/libavformat/isom.h +++ b/libavformat/isom.h @@ -166,6 +166,7 @@ typedef struct MOVIndexRange { typedef struct MOVStreamContext { AVIOContext *pb; + int refcount; int pb_is_copied; int ffindex; ///< AVStream index int next_chunk; diff --git a/libavformat/mov.c b/libavformat/mov.c index e548f93f17..66b36eaa4a 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -212,6 +212,7 @@ static int mov_read_covr(MOVContext *c, AVIOContext *pb, int type, int len) } st = c->fc->streams[c->fc->nb_streams - 1]; st->priv_data = sc; + sc->refcount = 1; if (st->attached_pic.size >= 8 && id != AV_CODEC_ID_BMP) { if (AV_RB64(st->attached_pic.data) == 0x89504e470d0a1a0a) { @@ -4672,6 +4673,7 @@ static int mov_read_trak(MOVContext *c, AVIOContext *pb, MOVAtom atom) st->codecpar->codec_type = AVMEDIA_TYPE_DATA; sc->ffindex = st->index; c->trak_index = st->index; + sc->refcount = 1; if ((ret = mov_read_default(c, pb, atom)) < 0) return ret; @@ -4959,6 +4961,7 @@ static int heif_add_stream(MOVContext *c, HEIFItem *item) sc = st->priv_data; sc->pb = c->fc->pb; sc->pb_is_copied = 1; + sc->refcount = 1; // Populate the necessary fields used by mov_build_index. sc->stsc_count = 1; @@ -8660,8 +8663,10 @@ static void mov_free_stream_context(AVFormatContext *s, AVStream *st) { MOVStreamContext *sc = st->priv_data; - if (!sc) + if (!sc || --sc->refcount) { + st->priv_data = NULL; return; + } av_freep(&sc->ctts_data); for (int i = 0; i < sc->drefs_count; i++) { -- 2.43.1 _______________________________________________ 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".