Mercurial > mplayer.hg
comparison vobsub.c @ 25791:5448bd27b954
Fix vobsub_seek use same reseek method as vobsub_get_packet did.
author | ulion |
---|---|
date | Sun, 20 Jan 2008 15:43:10 +0000 |
parents | 330af0160c2d |
children | 401426ba1ecf |
comparison
equal
deleted
inserted
replaced
25790:6aad76cd84d3 | 25791:5448bd27b954 |
---|---|
1277 lang+=2;while (lang[0]==',' || lang[0]==' ') ++lang; | 1277 lang+=2;while (lang[0]==',' || lang[0]==' ') ++lang; |
1278 } | 1278 } |
1279 mp_msg(MSGT_VOBSUB, MSGL_WARN, "No matching VOBSUB language found!\n"); | 1279 mp_msg(MSGT_VOBSUB, MSGL_WARN, "No matching VOBSUB language found!\n"); |
1280 return -1; | 1280 return -1; |
1281 } | 1281 } |
1282 | 1282 |
1283 int | 1283 /// make sure we seek to the first packet of packets having same pts values. |
1284 vobsub_get_packet(void *vobhandle, float pts,void** data, int* timestamp) { | 1284 static void vobsub_queue_reseek(packet_queue_t *queue, unsigned int pts100) { |
1285 vobsub_t *vob = (vobsub_t *)vobhandle; | |
1286 unsigned int pts100 = 90000 * pts; | |
1287 if (vob->spu_streams && 0 <= vobsub_id && (unsigned) vobsub_id < vob->spu_streams_size) { | |
1288 packet_queue_t *queue = vob->spu_streams + vobsub_id; | |
1289 | |
1290 int reseek_count = 0; | 1285 int reseek_count = 0; |
1291 unsigned int lastpts = 0; | 1286 unsigned int lastpts = 0; |
1292 while (queue->current_index < queue->packets_size | 1287 while (queue->current_index < queue->packets_size |
1293 && queue->packets[queue->current_index].pts100 <= pts100) { | 1288 && queue->packets[queue->current_index].pts100 <= pts100) { |
1294 lastpts = queue->packets[queue->current_index].pts100; | 1289 lastpts = queue->packets[queue->current_index].pts100; |
1298 while (reseek_count-- && --queue->current_index) { | 1293 while (reseek_count-- && --queue->current_index) { |
1299 if (queue->packets[queue->current_index-1].pts100 != UINT_MAX && | 1294 if (queue->packets[queue->current_index-1].pts100 != UINT_MAX && |
1300 queue->packets[queue->current_index-1].pts100 != lastpts) | 1295 queue->packets[queue->current_index-1].pts100 != lastpts) |
1301 break; | 1296 break; |
1302 } | 1297 } |
1298 } | |
1299 | |
1300 int | |
1301 vobsub_get_packet(void *vobhandle, float pts,void** data, int* timestamp) { | |
1302 vobsub_t *vob = (vobsub_t *)vobhandle; | |
1303 unsigned int pts100 = 90000 * pts; | |
1304 if (vob->spu_streams && 0 <= vobsub_id && (unsigned) vobsub_id < vob->spu_streams_size) { | |
1305 packet_queue_t *queue = vob->spu_streams + vobsub_id; | |
1306 | |
1307 vobsub_queue_reseek(queue, pts100); | |
1303 | 1308 |
1304 while (queue->current_index < queue->packets_size) { | 1309 while (queue->current_index < queue->packets_size) { |
1305 packet_t *pkt = queue->packets + queue->current_index; | 1310 packet_t *pkt = queue->packets + queue->current_index; |
1306 if (pkt->pts100 != UINT_MAX) | 1311 if (pkt->pts100 != UINT_MAX) |
1307 if (pkt->pts100 <= pts100) { | 1312 if (pkt->pts100 <= pts100) { |
1344 /* do not seek if we don't know the id */ | 1349 /* do not seek if we don't know the id */ |
1345 if (vobsub_get_id(vob, vobsub_id) == NULL) | 1350 if (vobsub_get_id(vob, vobsub_id) == NULL) |
1346 return; | 1351 return; |
1347 queue = vob->spu_streams + vobsub_id; | 1352 queue = vob->spu_streams + vobsub_id; |
1348 queue->current_index = 0; | 1353 queue->current_index = 0; |
1349 while (queue->current_index < queue->packets_size | 1354 vobsub_queue_reseek(queue, seek_pts100); |
1350 && (queue->packets + queue->current_index)->pts100 < seek_pts100) | |
1351 ++queue->current_index; | |
1352 if (queue->current_index > 0) | |
1353 --queue->current_index; | |
1354 } | 1355 } |
1355 } | 1356 } |
1356 | 1357 |
1357 void | 1358 void |
1358 vobsub_reset(void *vobhandle) | 1359 vobsub_reset(void *vobhandle) |