diff options
author | James Almer <jamrial@gmail.com> | 2021-03-23 15:36:22 -0300 |
---|---|---|
committer | James Almer <jamrial@gmail.com> | 2021-04-07 09:51:44 -0300 |
commit | 557953a397dfdd9c7a3d8c2f60d1204599e3d3ac (patch) | |
tree | 5f116dae965937ecd41358e35c92f500b4de6eb7 /libavformat/utils.c | |
parent | c06465a70bd6e3a746f670e1d46d850d9233bfde (diff) |
avformat/utils: add helper functions to retrieve index entries from an AVStream
Signed-off-by: James Almer <jamrial@gmail.com>
Diffstat (limited to 'libavformat/utils.c')
-rw-r--r-- | libavformat/utils.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/libavformat/utils.c b/libavformat/utils.c index 13b1bc7c78..b671fa75b3 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -2164,6 +2164,33 @@ int av_index_search_timestamp(AVStream *st, int64_t wanted_timestamp, int flags) wanted_timestamp, flags); } +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) +{ + if (idx < 0 || idx >= st->internal->nb_index_entries) + return NULL; + + return &st->internal->index_entries[idx]; +} + +const AVIndexEntry *avformat_index_get_entry_from_timestamp(const AVStream *st, + int64_t wanted_timestamp, + int flags) +{ + int idx = ff_index_search_timestamp(st->internal->index_entries, + st->internal->nb_index_entries, + wanted_timestamp, flags); + + if (idx < 0) + return NULL; + + return &st->internal->index_entries[idx]; +} + static int64_t ff_read_timestamp(AVFormatContext *s, int stream_index, int64_t *ppos, int64_t pos_limit, int64_t (*read_timestamp)(struct AVFormatContext *, int , int64_t *, int64_t )) { |