From patchwork Thu Apr 8 17:21:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Almer X-Patchwork-Id: 26810 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 310AE44B4B7 for ; Thu, 8 Apr 2021 20:21:46 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 0B432680A7C; Thu, 8 Apr 2021 20:21:46 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-qt1-f176.google.com (mail-qt1-f176.google.com [209.85.160.176]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id AB5936802C2 for ; Thu, 8 Apr 2021 20:21:39 +0300 (EEST) Received: by mail-qt1-f176.google.com with SMTP id 1so2038789qtb.0 for ; Thu, 08 Apr 2021 10:21:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=IE/8jQbxGe8/Pkrw1iQVYZxIQBgJTX7HC+fMdKOdra0=; b=myke8g3myckj6cnVUpCld7pH3NpOwJ9d/xyXEaZ/q4FtQBONG2c73YwQun0b9qmG4g kRCTQ78E1q088QNKjeH8SGwImAoX8J1g0+zSKFj8XSi1xnPqSMiyGv/b4zA5wj7N2qKZ vSb1aHx2LsfbWIzrjLRKWjjaA7TaWC6UFr1UIZj3B9csOajHi8pAYstjf3evjwogxnYr 99XqhEZXePSF5MyIilso178J4ok5umwRaVmmeLwA+U+wsqdUPK4NapHj0DVPHSA8jw0K s1eTEhlp5HVVIf++ECHrln85Bmf/BMA/9sNOndDp+5EM/4lfwKJpS2z/RY+QWWQctmlX laKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=IE/8jQbxGe8/Pkrw1iQVYZxIQBgJTX7HC+fMdKOdra0=; b=m7dRT+bfH4k7AOfy78msVUwbmDBiuKZ5MzVsWmiLQ6glNV34v7GIYY/9OvFcNw+J3R oqycjpoyCuTXb81Sx8RU5xxyX2GUE2/wuqSFqd5MQ5YIE3/lrk8BlgEk8R/1yYpMUOjN +pbUulLAgqmA1L7+C4lVcDtdRS4wy4uZN9H+XAChG/tsmywGlGirqAFA2yIX9wyIKOQH SQqV5wGMqCnO55abGGem+5rZk/Qtq2Rsjo+SozAJn85DffRbrAprpAeonzDEMF4a90Uq DywoPLJ0c6ubAqITxdKY4kaLOBF9jdDJfOyPa97rhxEp55x1mRjbXuEqUlSX8Th8GmUU 3R9w== X-Gm-Message-State: AOAM5337NftaTooGM8ib+BpKNz0g0V6ZD+jlGe87qBJDCy4SqKUkX1ZY hxMCCfprxmzUw8MaQfVj1LenXVuN3fQ= X-Google-Smtp-Source: ABdhPJxtv1F91woz1IndstRDGBgJnZ+tmmaGI2X1snN+J20XZ3pWW38uECaU1nv1EfUezQ1Pm664ig== X-Received: by 2002:ac8:4809:: with SMTP id g9mr8306896qtq.295.1617902498024; Thu, 08 Apr 2021 10:21:38 -0700 (PDT) Received: from localhost.localdomain ([191.83.208.158]) by smtp.gmail.com with ESMTPSA id z6sm1336156qkc.73.2021.04.08.10.21.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Apr 2021 10:21:37 -0700 (PDT) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Thu, 8 Apr 2021 14:21:16 -0300 Message-Id: <20210408172116.4634-1-jamrial@gmail.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] avformat/utils: constrain the guaranteed lifetime of the pointer returned by avformat_index_get_entry() X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" This will give us more room to improve the implementation later. Suggested-by: Anton Khirnov Signed-off-by: James Almer --- libavformat/avformat.h | 12 ++++++------ libavformat/utils.c | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/libavformat/avformat.h b/libavformat/avformat.h index 8600ee1bf7..8b49871cdc 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -2770,10 +2770,10 @@ int avformat_index_get_entries_count(const AVStream *st); * @return A pointer to the requested AVIndexEntry if it exists, NULL otherwise. * * @note The pointer returned by this function is only guaranteed to be valid - * until any function that could alter the stream or the AVFormatContext - * that contains it is called. + * until any function that takes the stream or the parent AVFormatContext + * as input argument is called. */ -const AVIndexEntry *avformat_index_get_entry(const AVStream *st, int idx); +const AVIndexEntry *avformat_index_get_entry(AVStream *st, int idx); /** * Get the AVIndexEntry corresponding to the given timestamp. @@ -2787,10 +2787,10 @@ const AVIndexEntry *avformat_index_get_entry(const AVStream *st, int idx); * @return A pointer to the requested AVIndexEntry if it exists, NULL otherwise. * * @note The pointer returned by this function is only guaranteed to be valid - * until any function that could alter the stream or the AVFormatContext - * that contains it is called. + * until any function that takes the stream or the parent AVFormatContext + * as input argument is called. */ -const AVIndexEntry *avformat_index_get_entry_from_timestamp(const AVStream *st, +const AVIndexEntry *avformat_index_get_entry_from_timestamp(AVStream *st, int64_t wanted_timestamp, int flags); /** diff --git a/libavformat/utils.c b/libavformat/utils.c index d9971d7fd3..3ea34fa042 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -2169,7 +2169,7 @@ int avformat_index_get_entries_count(const AVStream *st) return st->internal->nb_index_entries; } -const AVIndexEntry *avformat_index_get_entry(const AVStream *st, int idx) +const AVIndexEntry *avformat_index_get_entry(AVStream *st, int idx) { if (idx < 0 || idx >= st->internal->nb_index_entries) return NULL; @@ -2177,7 +2177,7 @@ const AVIndexEntry *avformat_index_get_entry(const AVStream *st, int idx) return &st->internal->index_entries[idx]; } -const AVIndexEntry *avformat_index_get_entry_from_timestamp(const AVStream *st, +const AVIndexEntry *avformat_index_get_entry_from_timestamp(AVStream *st, int64_t wanted_timestamp, int flags) {