Mercurial > libavformat.hg
comparison raw.c @ 558:89bd76208427 libavformat
100l (forgoten seeking functions)
author | michael |
---|---|
date | Mon, 11 Oct 2004 23:53:53 +0000 |
parents | 558a093b04db |
children | 23b915bb10f5 |
comparison
equal
deleted
inserted
replaced
557:084de726b4d0 | 558:89bd76208427 |
---|---|
124 { | 124 { |
125 return 0; | 125 return 0; |
126 } | 126 } |
127 | 127 |
128 int pcm_read_seek(AVFormatContext *s, | 128 int pcm_read_seek(AVFormatContext *s, |
129 int stream_index, int64_t timestamp) | 129 int stream_index, int64_t timestamp, int flags) |
130 { | 130 { |
131 AVStream *st; | 131 AVStream *st; |
132 int block_align, byte_rate; | 132 int block_align, byte_rate; |
133 int64_t pos; | 133 int64_t pos; |
134 | 134 |
156 | 156 |
157 if (block_align <= 0 || byte_rate <= 0) | 157 if (block_align <= 0 || byte_rate <= 0) |
158 return -1; | 158 return -1; |
159 | 159 |
160 /* compute the position by aligning it to block_align */ | 160 /* compute the position by aligning it to block_align */ |
161 pos = av_rescale(timestamp * byte_rate, st->time_base.num, st->time_base.den); | 161 pos = av_rescale_rnd(timestamp * byte_rate, |
162 pos = (pos / block_align) * block_align; | 162 st->time_base.num, |
163 st->time_base.den * (int64_t)block_align, | |
164 (flags & AVSEEK_FLAG_BACKWARD) ? AV_ROUND_DOWN : AV_ROUND_UP); | |
165 pos *= block_align; | |
163 | 166 |
164 /* recompute exact position */ | 167 /* recompute exact position */ |
165 st->cur_dts = av_rescale(pos, st->time_base.den, byte_rate * (int64_t)st->time_base.num); | 168 st->cur_dts = av_rescale(pos, st->time_base.den, byte_rate * (int64_t)st->time_base.num); |
166 url_fseek(&s->pb, pos + s->data_offset, SEEK_SET); | 169 url_fseek(&s->pb, pos + s->data_offset, SEEK_SET); |
167 return 0; | 170 return 0; |