diff mbox series

[FFmpeg-devel] avformat/utils: constrain the guaranteed lifetime of the pointer returned by avformat_index_get_entry()

Message ID 20210408172116.4634-1-jamrial@gmail.com
State Accepted
Commit 74dce63f9ad5801018ee3d863712f652e4bf0081
Headers show
Series [FFmpeg-devel] avformat/utils: constrain the guaranteed lifetime of the pointer returned by avformat_index_get_entry() | expand

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate success Make fate finished

Commit Message

James Almer April 8, 2021, 5:21 p.m. UTC
This will give us more room to improve the implementation later.

Suggested-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: James Almer <jamrial@gmail.com>
---
 libavformat/avformat.h | 12 ++++++------
 libavformat/utils.c    |  4 ++--
 2 files changed, 8 insertions(+), 8 deletions(-)

Comments

James Almer May 6, 2021, 1:28 p.m. UTC | #1
On 4/8/2021 2:21 PM, James Almer wrote:
> This will give us more room to improve the implementation later.
> 
> Suggested-by: Anton Khirnov <anton@khirnov.net>
> Signed-off-by: James Almer <jamrial@gmail.com>
> ---
>   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)
>   {

Will apply.
diff mbox series

Patch

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)
 {