Mercurial > libavformat.hg
comparison mov.c @ 5063:dcaea581e24d libavformat
mov_read_packet: extract code that searches for the stream/sample to demux next
into a separate function.
author | reimar |
---|---|
date | Wed, 24 Jun 2009 08:57:53 +0000 |
parents | 8d81bf3822ac |
children | 1ed8004a3ef5 |
comparison
equal
deleted
inserted
replaced
5062:8d81bf3822ac | 5063:dcaea581e24d |
---|---|
2053 dprintf(mov->fc, "on_parse_exit_offset=%lld\n", url_ftell(pb)); | 2053 dprintf(mov->fc, "on_parse_exit_offset=%lld\n", url_ftell(pb)); |
2054 | 2054 |
2055 return 0; | 2055 return 0; |
2056 } | 2056 } |
2057 | 2057 |
2058 static int mov_read_packet(AVFormatContext *s, AVPacket *pkt) | 2058 static AVIndexEntry *mov_find_next_sample(AVFormatContext *s, AVStream **st) |
2059 { | 2059 { |
2060 MOVContext *mov = s->priv_data; | 2060 AVIndexEntry *sample = NULL; |
2061 MOVStreamContext *sc = 0; | |
2062 AVIndexEntry *sample = 0; | |
2063 AVStream *st = NULL; | |
2064 int64_t best_dts = INT64_MAX; | 2061 int64_t best_dts = INT64_MAX; |
2065 int i, ret; | 2062 int i; |
2066 retry: | |
2067 for (i = 0; i < s->nb_streams; i++) { | 2063 for (i = 0; i < s->nb_streams; i++) { |
2068 AVStream *avst = s->streams[i]; | 2064 AVStream *avst = s->streams[i]; |
2069 MOVStreamContext *msc = avst->priv_data; | 2065 MOVStreamContext *msc = avst->priv_data; |
2070 if (avst->discard != AVDISCARD_ALL && msc->pb && msc->current_sample < avst->nb_index_entries) { | 2066 if (avst->discard != AVDISCARD_ALL && msc->pb && msc->current_sample < avst->nb_index_entries) { |
2071 AVIndexEntry *current_sample = &avst->index_entries[msc->current_sample]; | 2067 AVIndexEntry *current_sample = &avst->index_entries[msc->current_sample]; |
2076 ((msc->pb != s->pb && dts < best_dts) || (msc->pb == s->pb && | 2072 ((msc->pb != s->pb && dts < best_dts) || (msc->pb == s->pb && |
2077 ((FFABS(best_dts - dts) <= AV_TIME_BASE && current_sample->pos < sample->pos) || | 2073 ((FFABS(best_dts - dts) <= AV_TIME_BASE && current_sample->pos < sample->pos) || |
2078 (FFABS(best_dts - dts) > AV_TIME_BASE && dts < best_dts)))))) { | 2074 (FFABS(best_dts - dts) > AV_TIME_BASE && dts < best_dts)))))) { |
2079 sample = current_sample; | 2075 sample = current_sample; |
2080 best_dts = dts; | 2076 best_dts = dts; |
2081 st = avst; | 2077 *st = avst; |
2082 } | 2078 } |
2083 } | 2079 } |
2084 } | 2080 } |
2081 return sample; | |
2082 } | |
2083 | |
2084 static int mov_read_packet(AVFormatContext *s, AVPacket *pkt) | |
2085 { | |
2086 MOVContext *mov = s->priv_data; | |
2087 MOVStreamContext *sc; | |
2088 AVIndexEntry *sample; | |
2089 AVStream *st = NULL; | |
2090 int ret; | |
2091 retry: | |
2092 sample = mov_find_next_sample(s, &st); | |
2085 if (!sample) { | 2093 if (!sample) { |
2086 mov->found_mdat = 0; | 2094 mov->found_mdat = 0; |
2087 if (!url_is_streamed(s->pb) || | 2095 if (!url_is_streamed(s->pb) || |
2088 mov_read_default(mov, s->pb, (MOVAtom){ 0, 0, INT64_MAX }) < 0 || | 2096 mov_read_default(mov, s->pb, (MOVAtom){ 0, 0, INT64_MAX }) < 0 || |
2089 url_feof(s->pb)) | 2097 url_feof(s->pb)) |