Skip to content

Commit

Permalink
avformat/utils: Add const where appropriate
Browse files Browse the repository at this point in the history
Signed-off-by: Andreas Rheinhardt <[email protected]>
  • Loading branch information
mkver committed Dec 9, 2021
1 parent a33e0ed commit 408b974
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion libavformat/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,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
Expand Down
15 changes: 8 additions & 7 deletions libavformat/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -1264,7 +1264,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)
Expand Down Expand Up @@ -1407,8 +1407,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) {
Expand Down Expand Up @@ -1475,7 +1476,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;

Expand All @@ -1500,7 +1501,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:
Expand Down Expand Up @@ -1536,7 +1537,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);
Expand All @@ -1559,7 +1560,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;
Expand Down

0 comments on commit 408b974

Please sign in to comment.