Mercurial > libavformat.hg
comparison utils.c @ 810:2a84386ed2a8 libavformat
avformat/av_seek_frame_binary with growing file patch by (Kenneth Aafly: kenneth, aafloy net)
author | michael |
---|---|
date | Fri, 08 Jul 2005 09:14:05 +0000 |
parents | bae563a91a57 |
children | a6c035e7f429 |
comparison
equal
deleted
inserted
replaced
809:bae563a91a57 | 810:2a84386ed2a8 |
---|---|
1196 */ | 1196 */ |
1197 int av_seek_frame_binary(AVFormatContext *s, int stream_index, int64_t target_ts, int flags){ | 1197 int av_seek_frame_binary(AVFormatContext *s, int stream_index, int64_t target_ts, int flags){ |
1198 AVInputFormat *avif= s->iformat; | 1198 AVInputFormat *avif= s->iformat; |
1199 int64_t pos_min, pos_max, pos, pos_limit; | 1199 int64_t pos_min, pos_max, pos, pos_limit; |
1200 int64_t ts_min, ts_max, ts; | 1200 int64_t ts_min, ts_max, ts; |
1201 int64_t start_pos; | 1201 int64_t start_pos, filesize; |
1202 int index, no_change; | 1202 int index, no_change; |
1203 AVStream *st; | 1203 AVStream *st; |
1204 | 1204 |
1205 if (stream_index < 0) | 1205 if (stream_index < 0) |
1206 return -1; | 1206 return -1; |
1254 return -1; | 1254 return -1; |
1255 } | 1255 } |
1256 | 1256 |
1257 if(ts_max == AV_NOPTS_VALUE){ | 1257 if(ts_max == AV_NOPTS_VALUE){ |
1258 int step= 1024; | 1258 int step= 1024; |
1259 pos_max = url_fsize(&s->pb) - 1; | 1259 filesize = url_fsize(&s->pb); |
1260 pos_max = filesize - 1; | |
1260 do{ | 1261 do{ |
1261 pos_max -= step; | 1262 pos_max -= step; |
1262 ts_max = avif->read_timestamp(s, stream_index, &pos_max, pos_max + step); | 1263 ts_max = avif->read_timestamp(s, stream_index, &pos_max, pos_max + step); |
1263 step += step; | 1264 step += step; |
1264 }while(ts_max == AV_NOPTS_VALUE && pos_max >= step); | 1265 }while(ts_max == AV_NOPTS_VALUE && pos_max >= step); |
1270 int64_t tmp_ts= avif->read_timestamp(s, stream_index, &tmp_pos, INT64_MAX); | 1271 int64_t tmp_ts= avif->read_timestamp(s, stream_index, &tmp_pos, INT64_MAX); |
1271 if(tmp_ts == AV_NOPTS_VALUE) | 1272 if(tmp_ts == AV_NOPTS_VALUE) |
1272 break; | 1273 break; |
1273 ts_max= tmp_ts; | 1274 ts_max= tmp_ts; |
1274 pos_max= tmp_pos; | 1275 pos_max= tmp_pos; |
1276 if(tmp_pos >= filesize) | |
1277 break; | |
1275 } | 1278 } |
1276 pos_limit= pos_max; | 1279 pos_limit= pos_max; |
1277 } | 1280 } |
1278 | 1281 |
1279 no_change=0; | 1282 no_change=0; |