diff mbox series

[FFmpeg-devel] Patch: avformat_index_get_entry and avformat_index_get_entry_from_timestamp const correctness

Message ID 2301e206486a2a0c513542ba2358d3cd3fdc1574.camel@resolume.com
State New
Headers show
Series [FFmpeg-devel] Patch: avformat_index_get_entry and avformat_index_get_entry_from_timestamp const correctness | expand

Checks

Context Check Description
yinshiyou/configure_loongarch64 warning Failed to apply patch
andriy/commit_msg_x86 warning The first line of the commit message must start with a context terminated by a colon and a space, for example "lavu/opt: " or "doc: ".
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Martijn Otto Nov. 7, 2022, 3:11 p.m. UTC
With this patch it's now possible to call avformat_index_get_entry and
avformat_index_get_entry_from_timestamp with a const-qualified
AVStream.
diff mbox series

Patch

From cbf7880c230ccff35b8b6d1fab192a07c6083307 Mon Sep 17 00:00:00 2001
From: Martijn Otto <martijn@resolume.com>
Date: Mon, 7 Nov 2022 16:06:30 +0100
Subject: [PATCH] avformat_index_get_entry and *_from_timestamp const
 correctness

These functions don't need a mutable pointer to the stream, as they
don't modify anything, and only return const-qualified pointers
themselves.

Signed-off-by: Martijn Otto <martijn@resolume.com>
---
 libavformat/avformat.h | 4 ++--
 libavformat/internal.h | 2 +-
 libavformat/seek.c     | 8 ++++----
 3 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index 1d97d56ac5..aa216ca11e 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -2676,7 +2676,7 @@  int avformat_index_get_entries_count(const AVStream *st);
  *       until any function that takes the stream or the parent AVFormatContext
  *       as input argument is called.
  */
-const AVIndexEntry *avformat_index_get_entry(AVStream *st, int idx);
+const AVIndexEntry *avformat_index_get_entry(const AVStream *st, int idx);
 
 /**
  * Get the AVIndexEntry corresponding to the given timestamp.
@@ -2693,7 +2693,7 @@  const AVIndexEntry *avformat_index_get_entry(AVStream *st, int idx);
  *       until any function that takes the stream or the parent AVFormatContext
  *       as input argument is called.
  */
-const AVIndexEntry *avformat_index_get_entry_from_timestamp(AVStream *st,
+const AVIndexEntry *avformat_index_get_entry_from_timestamp(const AVStream *st,
                                                             int64_t wanted_timestamp,
                                                             int flags);
 /**
diff --git a/libavformat/internal.h b/libavformat/internal.h
index ce837fefc7..5931b1cf14 100644
--- a/libavformat/internal.h
+++ b/libavformat/internal.h
@@ -417,7 +417,7 @@  static av_always_inline FFStream *ffstream(AVStream *st)
 
 static av_always_inline const FFStream *cffstream(const AVStream *st)
 {
-    return (FFStream*)st;
+    return (const FFStream*)st;
 }
 
 #ifdef __GNUC__
diff --git a/libavformat/seek.c b/libavformat/seek.c
index a236e285c0..2db7ba0bd3 100644
--- a/libavformat/seek.c
+++ b/libavformat/seek.c
@@ -249,20 +249,20 @@  int avformat_index_get_entries_count(const AVStream *st)
     return cffstream(st)->nb_index_entries;
 }
 
-const AVIndexEntry *avformat_index_get_entry(AVStream *st, int idx)
+const AVIndexEntry *avformat_index_get_entry(const AVStream *st, int idx)
 {
-    const FFStream *const sti = ffstream(st);
+    const FFStream *const sti = cffstream(st);
     if (idx < 0 || idx >= sti->nb_index_entries)
         return NULL;
 
     return &sti->index_entries[idx];
 }
 
-const AVIndexEntry *avformat_index_get_entry_from_timestamp(AVStream *st,
+const AVIndexEntry *avformat_index_get_entry_from_timestamp(const AVStream *st,
                                                             int64_t wanted_timestamp,
                                                             int flags)
 {
-    const FFStream *const sti = ffstream(st);
+    const FFStream *const sti = cffstream(st);
     int idx = ff_index_search_timestamp(sti->index_entries,
                                         sti->nb_index_entries,
                                         wanted_timestamp, flags);
-- 
2.34.1