diff mbox series

[FFmpeg-devel,2/2] avformat/utils: Add const where appropriate

Message ID AM7PR03MB66605C9FC5EB307FB288F97A8F6E9@AM7PR03MB6660.eurprd03.prod.outlook.com
State Accepted
Commit 408b974796c55a3a2ca0bba2c3ac473e0bdfcd3f
Headers show
Series [FFmpeg-devel,1/2] avformat/utils: Fix wrong indentation | expand

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished
andriy/make_ppc success Make finished
andriy/make_fate_ppc success Make fate finished

Commit Message

Andreas Rheinhardt Dec. 7, 2021, 9:56 a.m. UTC
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavformat/internal.h |  2 +-
 libavformat/utils.c    | 15 ++++++++-------
 2 files changed, 9 insertions(+), 8 deletions(-)
diff mbox series

Patch

diff --git a/libavformat/internal.h b/libavformat/internal.h
index 20e93d9267..cdc398c49e 100644
--- a/libavformat/internal.h
+++ b/libavformat/internal.h
@@ -619,7 +619,7 @@  void ff_parse_key_value(const char *str, ff_parse_key_val_cb callback_get_buf,
  * Find stream index based on format-specific stream ID
  * @return stream index, or < 0 on error
  */
-int ff_find_stream_index(AVFormatContext *s, int id);
+int ff_find_stream_index(const AVFormatContext *s, int id);
 
 /**
  * Internal version of av_index_search_timestamp
diff --git a/libavformat/utils.c b/libavformat/utils.c
index 827e7c8d5a..fe1699136c 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -1263,7 +1263,7 @@  void ff_parse_key_value(const char *str, ff_parse_key_val_cb callback_get_buf,
     }
 }
 
-int ff_find_stream_index(AVFormatContext *s, int id)
+int ff_find_stream_index(const AVFormatContext *s, int id)
 {
     for (unsigned i = 0; i < s->nb_streams; i++)
         if (s->streams[i]->id == id)
@@ -1406,8 +1406,9 @@  AVRational av_guess_frame_rate(AVFormatContext *format, AVStream *st, AVFrame *f
  *         0  if st is NOT a matching stream
  *         >0 if st is a matching stream
  */
-static int match_stream_specifier(AVFormatContext *s, AVStream *st,
-                                  const char *spec, const char **indexptr, AVProgram **p)
+static int match_stream_specifier(const AVFormatContext *s, const AVStream *st,
+                                  const char *spec, const char **indexptr,
+                                  const AVProgram **p)
 {
     int match = 1;                      /* Stores if the specifier matches so far. */
     while (*spec) {
@@ -1474,7 +1475,7 @@  static int match_stream_specifier(AVFormatContext *s, AVStream *st,
                 return AVERROR(EINVAL);
             return match && (stream_id == st->id);
         } else if (*spec == 'm' && *(spec + 1) == ':') {
-            AVDictionaryEntry *tag;
+            const AVDictionaryEntry *tag;
             char *key, *val;
             int ret;
 
@@ -1499,7 +1500,7 @@  static int match_stream_specifier(AVFormatContext *s, AVStream *st,
             }
             return match && ret;
         } else if (*spec == 'u' && *(spec + 1) == '\0') {
-            AVCodecParameters *par = st->codecpar;
+            const AVCodecParameters *par = st->codecpar;
             int val;
             switch (par->codec_type) {
             case AVMEDIA_TYPE_AUDIO:
@@ -1535,7 +1536,7 @@  int avformat_match_stream_specifier(AVFormatContext *s, AVStream *st,
     int ret, index;
     char *endptr;
     const char *indexptr = NULL;
-    AVProgram *p = NULL;
+    const AVProgram *p = NULL;
     int nb_streams;
 
     ret = match_stream_specifier(s, st, spec, &indexptr, &p);
@@ -1558,7 +1559,7 @@  int avformat_match_stream_specifier(AVFormatContext *s, AVStream *st,
     /* If we requested a matching stream index, we have to ensure st is that. */
     nb_streams = p ? p->nb_stream_indexes : s->nb_streams;
     for (int i = 0; i < nb_streams && index >= 0; i++) {
-        AVStream *candidate = p ? s->streams[p->stream_index[i]] : s->streams[i];
+        const AVStream *candidate = s->streams[p ? p->stream_index[i] : i];
         ret = match_stream_specifier(s, candidate, spec, NULL, NULL);
         if (ret < 0)
             goto error;