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 8F71C49241 for ; Tue, 6 Feb 2024 13:05:53 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 5A4A868D12E; Tue, 6 Feb 2024 15:05:33 +0200 (EET) Received: from mail-pg1-f176.google.com (mail-pg1-f176.google.com [209.85.215.176]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id DB91C68CE3D for ; Tue, 6 Feb 2024 15:05:26 +0200 (EET) Received: by mail-pg1-f176.google.com with SMTP id 41be03b00d2f7-5ce07cf1e5dso4657061a12.2 for ; Tue, 06 Feb 2024 05:05:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707224724; x=1707829524; 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=MHp9RhkcQLl9FbNSrcV2ui8pSsssS0EUFGDnu8NgIb4=; b=KE6rdN5DlkvrXYHZFigvbh/5wgd7dowRUMk4T8eJABxQPIDX3iPVgAAFj+P9SogqAl 8Ekj81V0hkeZKY0dituZXbqiyYNKI95Z+4N4BVBeotlHqzBuC+VLFqUobz2t+lFrk+hP JwiBthMERbtbDYa0+ZDTP8XZUkE8WCHj+JD3CPrOgNECyYtKFEuXEtrMSQFsYRoMB4cM 5eHjegNWh1dBnnQ+0DymhtGodk7AGqh631ddZdJM2wTnOTrJwvRgXHBzitQkXMn/6tD7 2ZjPWXJzeLz7Z0WNi9p7qsrRbzRv4bQIQH3OPDROluu5+0vEEgDiulnkPUN0IMPmogU0 8Siw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707224724; x=1707829524; 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=MHp9RhkcQLl9FbNSrcV2ui8pSsssS0EUFGDnu8NgIb4=; b=n2/vPuAQB996eKdMZgjmN0K2oCFoOrpZ0LtE9HimMl+E2wp423cTrN+NNYhMNZvT7w STUvIrRhInl/uYvLNnUeVz98ggrTuy5e7vru+mWv2mwyA6ETSh3eEhIYVf/Bw9DiU7nf 8NMc04ois+y4pENURB3idSRHD5CwjMpbbkviKd5L/qjN22Jg1Xquo8h667XiAOYbnYBa FdyWWBLa7AVLQrs4nxit4qLDVl9TI5EwILRs+Ud4gbqB2d7Be0DTq4K8XOTEOpL1Zm/L o8kYXC7XPgiy8W5VivTNvoayOB5c79YUbb6QAhlfyimgrDV6WL79thNHbrRgMqamjbZI AT7w== X-Gm-Message-State: AOJu0Yw51Fu5fT8EZ/3DNJ4Eimu9VkbZGqlJ4JgrPOAPmJmrPvdGur60 FYV6c8aUxNkaleXXrNXC5QumWwMiwfOTC1JkzRBbRCx3Rx13LtsNH2VLCay6 X-Google-Smtp-Source: AGHT+IE4skYFNGn2wLQdLXn2Vs87ioGt2ZPniapqAIhJ8pMcHyBSP8vbHFa7wUCmyb+qko9POTBRbg== X-Received: by 2002:a05:6a21:99a6:b0:19c:8d73:7212 with SMTP id ve38-20020a056a2199a600b0019c8d737212mr1751027pzb.13.1707224723950; Tue, 06 Feb 2024 05:05:23 -0800 (PST) Received: from localhost.localdomain (host197.190-225-105.telecom.net.ar. [190.225.105.197]) by smtp.gmail.com with ESMTPSA id f10-20020a056a001aca00b006dae568baedsm1814773pfv.24.2024.02.06.05.05.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 05:05:23 -0800 (PST) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Tue, 6 Feb 2024 10:05:17 -0300 Message-ID: <20240206130521.4551-3-jamrial@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240206130521.4551-1-jamrial@gmail.com> References: <20240206130521.4551-1-jamrial@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 3/7 v4] 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 --- No changes since last version 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 42b0135987..8ecc4869bb 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.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".