comparison asf.c @ 350:9a6c7a56405c libavformat

unused
author michael
date Wed, 14 Jan 2004 18:32:49 +0000
parents 2bed194f8362
children c072833fe7f4
comparison
equal deleted inserted replaced
349:2bed194f8362 350:9a6c7a56405c
1376 } 1376 }
1377 1377
1378 static int asf_read_seek(AVFormatContext *s, int stream_index, int64_t pts) 1378 static int asf_read_seek(AVFormatContext *s, int stream_index, int64_t pts)
1379 { 1379 {
1380 ASFContext *asf = s->priv_data; 1380 ASFContext *asf = s->priv_data;
1381 AVStream *st;
1382 AVPacket pkt1, *pkt;
1383 int block_align;
1384 int64_t pos; 1381 int64_t pos;
1385 int64_t pos_min, pos_max, pts_min, pts_max, cur_pts, pos_limit; 1382 int64_t pos_min, pos_max, pts_min, pts_max, cur_pts, pos_limit;
1386
1387 pkt = &pkt1;
1388
1389 // Validate pts
1390 if (pts < 0)
1391 pts = 0;
1392 1383
1393 if (stream_index == -1) 1384 if (stream_index == -1)
1394 stream_index= av_find_default_stream_index(s); 1385 stream_index= av_find_default_stream_index(s);
1395 1386
1396 st = s->streams[stream_index]; 1387 if (asf->packet_size <= 0)
1397
1398 // ASF files have fixed block sizes, store this to determine offset
1399 block_align = asf->packet_size;
1400
1401 if (block_align <= 0)
1402 return -1; 1388 return -1;
1403 1389
1404 pos_min = 0; 1390 pos_min = 0;
1405 pts_min = asf_read_pts(s, &pos_min, stream_index); 1391 pts_min = asf_read_pts(s, &pos_min, stream_index);
1406 if (pts_min == AV_NOPTS_VALUE) return -1; 1392 if (pts_min == AV_NOPTS_VALUE) return -1;
1411 1397
1412 while (pos_min < pos_limit) { 1398 while (pos_min < pos_limit) {
1413 int64_t start_pos; 1399 int64_t start_pos;
1414 1400
1415 assert(pos_limit <= pos_max); 1401 assert(pos_limit <= pos_max);
1402 assert(pos_limit % asf->packet_size == 0);
1403 assert(pos_max % asf->packet_size == 0);
1404 assert(pos_min % asf->packet_size == 0);
1416 1405
1417 // interpolate position (better than dichotomy) 1406 // interpolate position (better than dichotomy)
1418 pos = (int64_t)((double)(pos_limit - pos_min) * 1407 pos = (int64_t)((double)(pos_limit - pos_min) *
1419 (double)(pts - pts_min) / 1408 (double)(pts - pts_min) /
1420 (double)(pts_max - pts_min)) + pos_min; 1409 (double)(pts_max - pts_min)) + pos_min;