[Mplayerxp-cvslog] SF.net SVN: mplayerxp:[211] mplayerxp
Brought to you by:
olov
From: <nic...@us...> - 2012-10-26 06:43:14
|
Revision: 211 http://mplayerxp.svn.sourceforge.net/mplayerxp/?rev=211&view=rev Author: nickols_k Date: 2012-10-26 06:43:08 +0000 (Fri, 26 Oct 2012) Log Message: ----------- fix vobsub seeking Modified Paths: -------------- mplayerxp/libmpdemux/demuxer.h mplayerxp/libmpdemux/demuxer_r.c mplayerxp/libmpdemux/demuxer_r.h mplayerxp/libmpsub/vobsub.c mplayerxp/libmpsub/vobsub.h mplayerxp/mplayer.c Modified: mplayerxp/libmpdemux/demuxer.h =================================================================== --- mplayerxp/libmpdemux/demuxer.h 2012-10-25 17:23:43 UTC (rev 210) +++ mplayerxp/libmpdemux/demuxer.h 2012-10-26 06:43:08 UTC (rev 211) @@ -1,6 +1,8 @@ #ifndef __DEMUXER_H #define __DEMUXER_H 1 +#include "stream.h" + #define MAX_PACK_BYTES (0x1024*0x1024*4) #define DEMUXER_TYPE_UNKNOWN 0 Modified: mplayerxp/libmpdemux/demuxer_r.c =================================================================== --- mplayerxp/libmpdemux/demuxer_r.c 2012-10-25 17:23:43 UTC (rev 210) +++ mplayerxp/libmpdemux/demuxer_r.c 2012-10-26 06:43:08 UTC (rev 211) @@ -178,9 +178,9 @@ return retval; } -void vobsub_seek_r(any_t* vobhandle, float pts) { +void vobsub_seek_r(any_t* vobhandle,const seek_args_t* seeka) { LOCK_DEMUXER(); - vobsub_seek(vobhandle,pts); + vobsub_seek(vobhandle,seeka); UNLOCK_DEMUXER(); } Modified: mplayerxp/libmpdemux/demuxer_r.h =================================================================== --- mplayerxp/libmpdemux/demuxer_r.h 2012-10-25 17:23:43 UTC (rev 210) +++ mplayerxp/libmpdemux/demuxer_r.h 2012-10-26 06:43:08 UTC (rev 211) @@ -20,7 +20,7 @@ extern int ds_get_packet_sub_r(demux_stream_t *ds,unsigned char **start); extern int demux_seek_r(demuxer_t *demuxer,const seek_args_t* seeka); -extern void vobsub_seek_r(any_t* vobhandle, float pts); +extern void vobsub_seek_r(any_t* vobhandle,const seek_args_t* seeka); extern int demuxer_switch_audio_r(demuxer_t *, int id); extern int demuxer_switch_video_r(demuxer_t *, int id); Modified: mplayerxp/libmpsub/vobsub.c =================================================================== --- mplayerxp/libmpsub/vobsub.c 2012-10-25 17:23:43 UTC (rev 210) +++ mplayerxp/libmpsub/vobsub.c 2012-10-26 06:43:08 UTC (rev 211) @@ -410,12 +410,12 @@ } vobsub_t; /* Make sure that the spu stream idx exists. */ -static int __FASTCALL__ vobsub_ensure_spu_stream(vobsub_t *vob, unsigned int index) +static int __FASTCALL__ vobsub_ensure_spu_stream(vobsub_t *vob, unsigned int _index) { - if (index >= vob->spu_streams_size) { + if (_index >= vob->spu_streams_size) { /* This is a new stream */ if (vob->spu_streams) { - packet_queue_t *tmp = realloc(vob->spu_streams, (index + 1) * sizeof(packet_queue_t)); + packet_queue_t *tmp = realloc(vob->spu_streams, (_index + 1) * sizeof(packet_queue_t)); if (tmp == NULL) { MSG_ERR("vobsub_ensure_spu_stream: realloc failure"); return -1; @@ -423,13 +423,13 @@ vob->spu_streams = tmp; } else { - vob->spu_streams = malloc((index + 1) * sizeof(packet_queue_t)); + vob->spu_streams = malloc((_index + 1) * sizeof(packet_queue_t)); if (vob->spu_streams == NULL) { MSG_ERR("vobsub_ensure_spu_stream: malloc failure"); return -1; } } - while (vob->spu_streams_size <= index) { + while (vob->spu_streams_size <= _index) { packet_queue_construct(vob->spu_streams + vob->spu_streams_size); ++vob->spu_streams_size; } @@ -437,25 +437,25 @@ return 0; } -static int __FASTCALL__ vobsub_add_id(vobsub_t *vob, const char *id, size_t idlen, const unsigned int index) +static int __FASTCALL__ vobsub_add_id(vobsub_t *vob, const char *id, size_t idlen, const unsigned int _index) { - if (vobsub_ensure_spu_stream(vob, index) < 0) + if (vobsub_ensure_spu_stream(vob, _index) < 0) return -1; if (id && idlen) { - if (vob->spu_streams[index].id) - free(vob->spu_streams[index].id); - vob->spu_streams[index].id = malloc(idlen + 1); - if (vob->spu_streams[index].id == NULL) { + if (vob->spu_streams[_index].id) + free(vob->spu_streams[_index].id); + vob->spu_streams[_index].id = malloc(idlen + 1); + if (vob->spu_streams[_index].id == NULL) { MSG_ERR("vobsub_add_id: malloc failure"); return -1; } - vob->spu_streams[index].id[idlen] = 0; - memcpy(vob->spu_streams[index].id, id, idlen); + vob->spu_streams[_index].id[idlen] = 0; + memcpy(vob->spu_streams[_index].id, id, idlen); } - vob->spu_streams_current = index; + vob->spu_streams_current = _index; if (mp_conf.verbose) MSG_ERR( "[vobsub] subtitle (vobsubid): %d language %s\n", - index, vob->spu_streams[index].id); + _index, vob->spu_streams[_index].id); return 0; } @@ -986,10 +986,10 @@ } } -char * __FASTCALL__ vobsub_get_id(any_t*vobhandle, unsigned int index) +char * __FASTCALL__ vobsub_get_id(any_t*vobhandle, unsigned int _index) { vobsub_t *vob = (vobsub_t *) vobhandle; - return (index < vob->spu_streams_size) ? vob->spu_streams[index].id : NULL; + return (_index < vob->spu_streams_size) ? vob->spu_streams[_index].id : NULL; } unsigned int __FASTCALL__ vobsub_get_forced_subs_flag(void const * const vobhandle) @@ -1000,9 +1000,9 @@ return 0; } -int __FASTCALL__ vobsub_set_from_lang(any_t*vobhandle, unsigned char * lang) +int __FASTCALL__ vobsub_set_from_lang(any_t*vobhandle,const char * lang) { - int i; + unsigned i; vobsub_t *vob= (vobsub_t *) vobhandle; while(lang && strlen(lang) >= 2){ for(i=0; i < vob->spu_streams_size; i++) @@ -1018,24 +1018,29 @@ return -1; } -void __FASTCALL__ vobsub_seek(any_t* vobhandle, float pts) +void __FASTCALL__ vobsub_seek(any_t* vobhandle,const seek_args_t* seeka) { - vobsub_t * vob = (vobsub_t *)vobhandle; - packet_queue_t * queue; - int seek_pts100 = (int)pts * 90000; - - if (vob->spu_streams && 0 <= mp_conf.vobsub_id && (unsigned) mp_conf.vobsub_id < vob->spu_streams_size) { - /* do not seek if we don't know the id */ - if (vobsub_get_id(vob, mp_conf.vobsub_id) == NULL) - return; - queue = vob->spu_streams + mp_conf.vobsub_id; - queue->current_index = 0; - while (queue->current_index < queue->packets_size - && (queue->packets + queue->current_index)->pts100 < seek_pts100) - ++queue->current_index; - if (queue->current_index > 0) - --queue->current_index; - } + vobsub_t * vob = (vobsub_t *)vobhandle; + packet_queue_t * queue; + unsigned seek_pts100; + if(seeka->flags&DEMUX_SEEK_SET) seek_pts100 = (unsigned)seeka->secs * 90000; + else { + int cur_pts; + queue = vob->spu_streams + mp_conf.vobsub_id; + cur_pts=(queue->packets + queue->current_index)->pts100; + seek_pts100 = cur_pts+(unsigned)seeka->secs*90000; + } + if (vob->spu_streams && 0 <= mp_conf.vobsub_id && (unsigned) mp_conf.vobsub_id < vob->spu_streams_size) { + /* do not seek if we don't know the id */ + if (vobsub_get_id(vob, mp_conf.vobsub_id) == NULL) return; + queue = vob->spu_streams + mp_conf.vobsub_id; + queue->current_index = 0; + while (queue->current_index < queue->packets_size + && (queue->packets + queue->current_index)->pts100 < seek_pts100) + ++queue->current_index; + if (queue->current_index > 0) + --queue->current_index; + } } int __FASTCALL__ vobsub_get_packet(any_t*vobhandle, float pts,any_t** data, int* timestamp) { @@ -1053,7 +1058,7 @@ return pkt->size; } else break; else - ++queue->current_index; + ++queue->current_index; } } return -1; Modified: mplayerxp/libmpsub/vobsub.h =================================================================== --- mplayerxp/libmpsub/vobsub.h 2012-10-25 17:23:43 UTC (rev 210) +++ mplayerxp/libmpsub/vobsub.h 2012-10-26 06:43:08 UTC (rev 211) @@ -1,15 +1,17 @@ #ifndef MPLAYER_VOBSUB_H #define MPLAYER_VOBSUB_H +#include "libmpdemux/demuxer.h" // for seek_args_t + extern any_t* __FASTCALL__ vobsub_open(const char *subname, const char *const ifo, const int force, any_t** spu); extern void __FASTCALL__ vobsub_close(any_t*this); extern void __FASTCALL__ vobsub_reset(any_t*vob); extern int __FASTCALL__ vobsub_get_packet(any_t*vobhandle, float pts,any_t** data, int* timestamp); extern int __FASTCALL__ vobsub_parse_ifo(any_t* vob, const char *const name, unsigned int *palette, unsigned int *width, unsigned int *height, int force, int sid, char *langid); extern char * __FASTCALL__ vobsub_get_id(any_t* vob, unsigned int index); -extern int __FASTCALL__ vobsub_set_from_lang(any_t*vobhandle, unsigned char * lang); +extern int __FASTCALL__ vobsub_set_from_lang(any_t*vobhandle,const char * lang); extern unsigned int __FASTCALL__ vobsub_get_forced_subs_flag(void const * const vobhandle); -extern void __FASTCALL__ vobsub_seek(any_t* vob, float pts); +extern void __FASTCALL__ vobsub_seek(any_t* vob,const seek_args_t* seek); /// Convert palette value in idx file to yuv. extern unsigned int vobsub_palette_to_yuv(unsigned int pal); extern unsigned int vobsub_rgb_to_yuv(unsigned int rgb); Modified: mplayerxp/mplayer.c =================================================================== --- mplayerxp/mplayer.c 2012-10-25 17:23:43 UTC (rev 210) +++ mplayerxp/mplayer.c 2012-10-26 06:43:08 UTC (rev 211) @@ -1448,7 +1448,7 @@ if (vo_data->vobsub) { pinfo[_xp_id].current_module = "seek_vobsub_reset"; - vobsub_seek_r(vo_data->vobsub, seek->secs); // <-- TODO: replace with full pts + vobsub_seek_r(vo_data->vobsub, seek); } #ifdef USE_OSD This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |