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 720A44A0BF for ; Thu, 21 Mar 2024 03:52:29 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 6848768D538; Thu, 21 Mar 2024 05:52:21 +0200 (EET) Received: from mail-ua1-f98.google.com (mail-ua1-f98.google.com [209.85.222.98]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id CEB0168D4BD for ; Thu, 21 Mar 2024 05:52:13 +0200 (EET) Received: by mail-ua1-f98.google.com with SMTP id a1e0cc1a2514c-7e09e1871fdso226416241.0 for ; Wed, 20 Mar 2024 20:52:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=proxyid.net; s=google; t=1710993132; x=1711597932; darn=ffmpeg.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=C7ddoKYHF75u8902kbMzlTKnC0vB8Euy1Yn0XRjjHJ8=; b=SQba/0FfefpWJzss8YGBbE6mFSTexje7gzuRTdsQyEb0Dhw5Rq2nlAfH5AuztEsYj4 Lr6Ob7R9s0fudsznlEbAKS01+qxMAMRlzWDSHIvg4Z5qKDKFTmCndXnfpXTbs7ct6DV0 EzAHLKBViKq12WwjPgcf/uOe25uVIpC2HEp8AYCkLLK5eiVKfxPj5IWLDyz922iho+wG Jp0GnyBzNd9GnZOaIMG1WVedTp6Qv1VI4FAA8K0ojWblzdX2r+Uqgkm/1L8EtgEXdbVT /h7eyojhMsvAILjC7eK4GlL3huy4ogKryd6rQA74Cn74QFF1IFMdk3FznvPJwQ14A7Ew aIdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710993132; x=1711597932; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=C7ddoKYHF75u8902kbMzlTKnC0vB8Euy1Yn0XRjjHJ8=; b=mQreH6s1hAoJocKzF7thXsJlttUkY618kbrZGAhgaGXbgbKLnipU/Lp+IRVdVqvu0i sKlc+uhDEIKWGANDRzrGQGJJYG2HMZoRpRxt4MQE7rDHUzWmW52juUwkMOJym8Q9+Mh6 4EjX2Iw5/EtCixew3XmWHXReGwjW6BAFx1BjiaFGwfq/fztAMTIqVw9uXbIiRMdKbkQP YLU0Z/bJ+kJqB/CdeU0RJDvJmI5FyvEkhryE15X3q3w7X8lK7vviMEjVItBeAHPzE7gw e6J+5ggvqZrE4ZO4AJkR+uTkmpsbEjEq9XSilOGPtmzsvQWQPdha+w0IfSjmhZ3VWJto DVcw== X-Gm-Message-State: AOJu0YzyrazZHZfpp9c0aSahmm25uHDBBc8MSsjju+aXcNocSjEEDIAB fSoNwuh4dm4MKaTbPM7q1S1DvymUKSVa8DmGc3enMpZifTAs8PCMmObgX8KvP1gfARqZQID5gKJ IUwqDCOPNIak42e8nw7izpcR4JIM9/z2gu1kmxMbN X-Google-Smtp-Source: AGHT+IHYS/hR9XJhrN1YgJnQmVkMBfGs27XvQgkxE+8vSBN+wYchfKVjDjb8x9ZqSrwRWddrPWf2Y6iDZLc/ X-Received: by 2002:a1f:f28a:0:b0:4d4:3fa5:e19e with SMTP id q132-20020a1ff28a000000b004d43fa5e19emr742271vkh.2.1710993132398; Wed, 20 Mar 2024 20:52:12 -0700 (PDT) Received: from wsx-cc1-001.. (c-76-141-249-38.hsd1.il.comcast.net. [76.141.249.38]) by smtp-relay.gmail.com with ESMTPS id x125-20020a1f7c83000000b004d14fb3e0b7sm1204250vkc.14.2024.03.20.20.52.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Mar 2024 20:52:12 -0700 (PDT) X-Relaying-Domain: proxyid.net From: Marth64 To: ffmpeg-devel@ffmpeg.org Date: Wed, 20 Mar 2024 22:52:03 -0500 Message-Id: <20240321035207.3849560-2-marth64@proxyid.net> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240321035207.3849560-1-marth64@proxyid.net> References: <20240321035207.3849560-1-marth64@proxyid.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v7 1/5] avformat/subtitles: extend ff_subtitles_queue_insert() to support empty events 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 Cc: Marth64 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: If ff_subtitles_queue_insert() were to given a NULL buffer with 0 length, it would still attempt to grow the packet or memcpy depending on if merge option is enabled. In this commit, consider a NULL buffer with 0 length as an empty event and do not attempt to modify the packet. This way, if a subtitle demuxer happens to pass an empty cue or wants to use av_get_packet() to read bytes, there are no unnecessary operations on the packet after it is allocated. Signed-off-by: Marth64 --- libavformat/subtitles.c | 4 ++++ libavformat/subtitles.h | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/libavformat/subtitles.c b/libavformat/subtitles.c index 3413763c7b..38d2ffb8a9 100644 --- a/libavformat/subtitles.c +++ b/libavformat/subtitles.c @@ -117,6 +117,8 @@ AVPacket *ff_subtitles_queue_insert(FFDemuxSubtitlesQueue *q, int old_len; sub = q->subs[q->nb_subs - 1]; old_len = sub->size; + if (event == NULL && len == 0) + return sub; if (av_grow_packet(sub, len) < 0) return NULL; memcpy(sub->data + old_len, event, len); @@ -140,6 +142,8 @@ AVPacket *ff_subtitles_queue_insert(FFDemuxSubtitlesQueue *q, subs[q->nb_subs++] = sub; sub->flags |= AV_PKT_FLAG_KEY; sub->pts = sub->dts = 0; + if (event == NULL && len == 0) + return sub; memcpy(sub->data, event, len); } return sub; diff --git a/libavformat/subtitles.h b/libavformat/subtitles.h index 88665663c5..ba162fa503 100644 --- a/libavformat/subtitles.h +++ b/libavformat/subtitles.h @@ -112,7 +112,7 @@ typedef struct { /** * Insert a new subtitle event. * - * @param event the subtitle line, may not be zero terminated + * @param event the subtitle line (not zero terminated), or NULL on empty event * @param len the length of the event (in strlen() sense, so without '\0') * @param merge set to 1 if the current event should be concatenated with the * previous one instead of adding a new entry, 0 otherwise -- 2.34.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".