Changeset 55320a77c20c9855c67c9f07598daee5804e57d6
- Timestamp:
- 11/13/03 14:31:12 (5 years ago)
- git-parent:
- Files:
-
- modules/demux/util/sub.c (modified) (10 diffs)
- modules/demux/util/sub.h (modified) (9 diffs)
- src/input/input.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
modules/demux/util/sub.c
re53ac06 r55320a7 3 3 ***************************************************************************** 4 4 * Copyright (C) 1999-2003 VideoLAN 5 * $Id: sub.c,v 1.3 5 2003/11/05 00:39:16 gbazinExp $5 * $Id: sub.c,v 1.36 2003/11/13 13:31:12 fenrir Exp $ 6 6 * 7 7 * Authors: Laurent Aimar <fenrir@via.ecp.fr> … … 238 238 while (*p_pos) 239 239 { 240 if (toupper(*p_pos) == toupper(*psz_little))241 { 242 char * psz_cur1 = p_pos + 1;243 char * psz_cur2 = psz_little + 1;244 while (*psz_cur1 && *psz_cur2 && toupper(*psz_cur1) == toupper(*psz_cur2))245 { 246 psz_cur1++;247 psz_cur2++;248 }249 if (!*psz_cur2) return p_pos;250 }251 p_pos++;240 if (toupper(*p_pos) == toupper(*psz_little)) 241 { 242 char * psz_cur1 = p_pos + 1; 243 char * psz_cur2 = psz_little + 1; 244 while (*psz_cur1 && *psz_cur2 && toupper(*psz_cur1) == toupper(*psz_cur2)) 245 { 246 psz_cur1++; 247 psz_cur2++; 248 } 249 if (!*psz_cur2) return p_pos; 250 } 251 p_pos++; 252 252 } 253 253 return NULL; … … 265 265 text_t txt; 266 266 vlc_value_t val; 267 es_format_t fmt; 267 268 268 269 int i; … … 470 471 471 472 /* *** add subtitle ES *** */ 472 vlc_mutex_lock( &p_input->stream.stream_lock );473 p_sub->p_es = input_AddES( p_input, p_input->stream.p_selected_program,474 0xff - i_track_id, /* FIXME */475 SPU_ES, NULL, 0 );476 vlc_mutex_unlock( &p_input->stream.stream_lock );477 478 p_sub->p_es->i_stream_id = 0xff - i_track_id; /* FIXME */479 480 if( p_sub->psz_header != NULL )481 {482 p_sub->p_es->p_demux_data = malloc( sizeof( subtitle_data_t ) );483 p_sub->p_es->p_demux_data->psz_header = strdup( p_sub->psz_header );484 free( p_sub->psz_header );485 }486 487 473 if( p_sub->i_sub_type == SUB_TYPE_VOBSUB ) 488 474 { 489 p_sub->p_es->i_fourcc = VLC_FOURCC( 's','p','u',' ' ); 490 /* open vobsub file */ 475 es_format_Init( &fmt, SPU_ES, VLC_FOURCC( 's','p','u',' ' ) ); 491 476 } 492 477 else if( p_sub->i_sub_type == SUB_TYPE_SSA1 || 493 478 p_sub->i_sub_type == SUB_TYPE_SSA2_4 ) 494 479 { 495 p_sub->p_es->i_fourcc = VLC_FOURCC( 's','s','a',' ');480 es_format_Init( &fmt, SPU_ES, VLC_FOURCC( 's','s','a',' ' ) ); 496 481 } 497 482 else 498 483 { 499 p_sub->p_es->i_fourcc = VLC_FOURCC( 's','u','b','t' ); 500 } 484 es_format_Init( &fmt, SPU_ES, VLC_FOURCC( 's','u','b','t' ) ); 485 } 486 if( p_sub->psz_header != NULL ) 487 { 488 fmt.i_extra_type = ES_EXTRA_TYPE_SUBHEADER; 489 fmt.i_extra = strlen( p_sub->psz_header ) + 1; 490 fmt.p_extra = strdup( p_sub->psz_header ); 491 } 492 p_sub->p_es = es_out_Add( p_input->p_es_out, &fmt ); 501 493 502 494 p_sub->i_previously_selected = 0; … … 509 501 static int sub_demux( subtitle_demux_t *p_sub, mtime_t i_maxdate ) 510 502 { 511 if( p_sub->p_es->p_decoder_fifo && !p_sub->i_previously_selected ) 503 input_thread_t *p_input = p_sub->p_input; 504 vlc_bool_t b; 505 506 es_out_Control( p_input->p_es_out, ES_OUT_GET_SELECT, p_sub->p_es, &b ); 507 if( b && !p_sub->i_previously_selected ) 512 508 { 513 509 p_sub->i_previously_selected = 1; … … 515 511 return VLC_SUCCESS; 516 512 } 517 else if( ! p_sub->p_es->p_decoder_fifo&& p_sub->i_previously_selected )513 else if( !b && p_sub->i_previously_selected ) 518 514 { 519 515 p_sub->i_previously_selected = 0; … … 573 569 p_pes->i_nb_data = 1; 574 570 p_pes->p_first = 575 p_pes->p_last = p_data;571 p_pes->p_last = p_data; 576 572 p_pes->i_pes_size = i_len; 577 573 … … 579 575 p_sub->subtitle[p_sub->i_subtitle].psz_text, 580 576 i_len ); 581 if( p_sub->p_es->p_decoder_fifo && p_pes->i_pts > 0 ) 582 {583 584 input_DecodePES( p_sub->p_es->p_decoder_fifo, p_pes );577 578 if( p_pes->i_pts > 0 ) 579 { 580 es_out_Send( p_input->p_es_out, p_sub->p_es, p_pes ); 585 581 } 586 582 else … … 591 587 p_sub->i_subtitle++; 592 588 } 593 return ( 0 );589 return VLC_SUCCESS; 594 590 } 595 591 … … 606 602 p_sub->i_subtitle++; 607 603 } 608 609 604 return( 0 ); 610 605 } modules/demux/util/sub.h
r354c7ab r55320a7 3 3 ***************************************************************************** 4 4 * Copyright (C) 2001-2003 VideoLAN 5 * $Id: sub.h,v 1.1 0 2003/11/05 00:17:50 hartmanExp $5 * $Id: sub.h,v 1.11 2003/11/13 13:31:12 fenrir Exp $ 6 6 * 7 7 * Authors: Laurent Aimar <fenrir@via.ecp.fr> 8 * 8 * 9 9 * This program is free software; you can redistribute it and/or modify 10 10 * it under the terms of the GNU General Public License as published by 11 11 * the Free Software Foundation; either version 2 of the License, or 12 12 * (at your option) any later version. 13 * 13 * 14 14 * This program is distributed in the hope that it will be useful, 15 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of … … 41 41 } subtitle_t; 42 42 43 typedef struct subtitle_track_s 43 #if 0 44 typedef struct 44 45 { 45 46 int i_track_id; … … 52 53 int i_previously_selected; /* to make pf_seek */ 53 54 es_descriptor_t *p_es; 54 55 55 56 } subtitle_track_t; 57 #endif 56 58 57 59 typedef struct subtitle_demux_s 58 60 { 59 61 VLC_COMMON_MEMBERS 60 62 61 63 module_t *p_module; 62 63 int (*pf_open) ( struct subtitle_demux_s *p_sub, 64 input_thread_t*p_input, 64 65 int (*pf_open) ( struct subtitle_demux_s *p_sub, 66 input_thread_t*p_input, 65 67 char *psz_name, 66 68 mtime_t i_microsecperframe, … … 69 71 int (*pf_seek) ( struct subtitle_demux_s *p_sub, mtime_t i_date ); 70 72 void (*pf_close)( struct subtitle_demux_s *p_sub ); 71 72 73 73 74 /* *** private *** */ … … 79 80 int i_subtitles; 80 81 subtitle_t *subtitle; 81 es_ descriptor_t*p_es;82 es_out_id_t *p_es; 82 83 int i_previously_selected; /* to make pf_seek */ 83 84 84 /*unsigned int i_tracks;85 subtitle_track_t *p_tracks85 /*unsigned int i_tracks; 86 subtitle_track_t *p_tracks 86 87 */ 87 88 88 89 89 } subtitle_demux_t; 90 90 91 91 /***************************************************************************** 92 * 93 * I made somes wrappers : So use them ! 94 * I think you shouldn't need access to subtitle_demux_t members else said 95 * it to me. 96 * 97 *****************************************************************************/ 98 99 100 /***************************************************************************** 101 * subtitle_New: Start a new subtitle demux instance (but subtitle ES isn't 92 * subtitle_New: Start a new subtitle demux instance (but subtitle ES isn't 102 93 * selected by default. 103 94 ***************************************************************************** … … 113 104 char *psz_name, 114 105 mtime_t i_microsecperframe, 115 int i_track_id ); 116 /***************************************************************************** 117 * subtitle_Select: Select the related subtitle ES. 118 *****************************************************************************/ 119 static inline void subtitle_Select( subtitle_demux_t *p_sub ); 120 121 /***************************************************************************** 122 * subtitle_Unselect: Unselect the related subtitle ES. 123 *****************************************************************************/ 124 static inline void subtitle_Unselect( subtitle_demux_t *p_sub ); 125 126 /***************************************************************************** 127 * subtitle_Demux: send subtitle to decoder from last date to i_max 128 *****************************************************************************/ 129 static inline int subtitle_Demux( subtitle_demux_t *p_sub, mtime_t i_max ); 130 131 /***************************************************************************** 132 * subtitle_Seek: Seek to i_date 133 *****************************************************************************/ 134 static inline int subtitle_Seek( subtitle_demux_t *p_sub, mtime_t i_date ); 135 136 /***************************************************************************** 137 * subtitle_Close: Stop ES decoder and free all memory included p_sub. 138 *****************************************************************************/ 139 static inline void subtitle_Close( subtitle_demux_t *p_sub ); 140 141 142 143 144 145 /*****************************************************************************/ 146 /*****************************************************************************/ 147 /*****************************************************************************/ 148 149 150 static inline 151 subtitle_demux_t *subtitle_New( input_thread_t *p_input, 152 char *psz_name, 153 mtime_t i_microsecperframe, 154 int i_track_id ) 106 int i_track_id ) 155 107 { 156 108 subtitle_demux_t *p_sub; … … 186 138 } 187 139 188 static inline void subtitle_Select( subtitle_demux_t *p_sub ) 189 { 190 if( p_sub && p_sub->p_es ) 191 { 192 vlc_mutex_lock( &p_sub->p_input->stream.stream_lock ); 193 input_SelectES( p_sub->p_input, p_sub->p_es ); 194 vlc_mutex_unlock( &p_sub->p_input->stream.stream_lock ); 195 p_sub->i_previously_selected = 0; 196 } 197 } 198 static inline void subtitle_Unselect( subtitle_demux_t *p_sub ) 199 { 200 if( p_sub && p_sub->p_es ) 201 { 202 vlc_mutex_lock( &p_sub->p_input->stream.stream_lock ); 203 input_UnselectES( p_sub->p_input, p_sub->p_es ); 204 vlc_mutex_unlock( &p_sub->p_input->stream.stream_lock ); 205 p_sub->i_previously_selected = 0; 206 } 207 } 208 140 /***************************************************************************** 141 * subtitle_Demux: send subtitle to decoder from last date to i_max 142 *****************************************************************************/ 209 143 static inline int subtitle_Demux( subtitle_demux_t *p_sub, mtime_t i_max ) 210 144 { … … 212 146 } 213 147 148 /***************************************************************************** 149 * subtitle_Seek: Seek to i_date 150 *****************************************************************************/ 214 151 static inline int subtitle_Seek( subtitle_demux_t *p_sub, mtime_t i_date ) 215 152 { 216 return( p_sub->pf_ demux( p_sub, i_date ) );153 return( p_sub->pf_seek( p_sub, i_date ) ); 217 154 } 218 155 156 /***************************************************************************** 157 * subtitle_Close: Stop ES decoder and free all memory included p_sub. 158 *****************************************************************************/ 219 159 static inline void subtitle_Close( subtitle_demux_t *p_sub ) 220 160 { … … 230 170 } 231 171 } 172 src/input/input.c
r3f71e77 r55320a7 5 5 ***************************************************************************** 6 6 * Copyright (C) 1998-2002 VideoLAN 7 * $Id: input.c,v 1.25 3 2003/11/13 12:28:34fenrir Exp $7 * $Id: input.c,v 1.254 2003/11/13 13:31:12 fenrir Exp $ 8 8 * 9 9 * Authors: Christophe Massiot <massiot@via.ecp.fr> … … 746 746 if( ( p_sub = subtitle_New( p_input, strdup(val.psz_string), i_microsecondperframe, 0 ) ) ) 747 747 { 748 /* Select this ES by default */ 749 es_out_Control( p_input->p_es_out, ES_OUT_SET_SELECT, p_sub->p_es, VLC_TRUE ); 750 748 751 TAB_APPEND( p_input->p_sys->i_sub, p_input->p_sys->sub, p_sub ); 749 subtitle_Select( p_sub );750 752 } 751 753 } 752 754 if( val.psz_string ) free( val.psz_string ); 753 755 754 756 var_Get( p_input, "sub-autodetect-file", &val ); 755 757 if( val.b_bool ) … … 1110 1112 } 1111 1113 id->p_es->p_bitmapinfoheader = p_bih; 1114 break; 1115 } 1116 case SPU_ES: 1117 { 1118 subtitle_data_t *p_sub = malloc( sizeof( subtitle_data_t ) ); 1119 memset( p_sub, 0, sizeof( subtitle_data_t ) ); 1120 if( fmt->i_extra > 0 ) 1121 { 1122 if( fmt->i_extra_type == ES_EXTRA_TYPE_SUBHEADER ) 1123 { 1124 p_sub->psz_header = malloc( fmt->i_extra ); 1125 memcpy( p_sub->psz_header, fmt->p_extra , fmt->i_extra ); 1126 } 1127 } 1128 /* FIXME beuuuuuurk */ 1129 id->p_es->p_demux_data = p_sub; 1112 1130 break; 1113 1131 } … … 1239 1257 { 1240 1258 case ES_OUT_SET_SELECT: 1259 vlc_mutex_lock( &p_sys->p_input->stream.stream_lock ); 1241 1260 id = (es_out_id_t*) va_arg( args, es_out_id_t * ); 1242 1261 b = (vlc_bool_t) va_arg( args, vlc_bool_t ); … … 1244 1263 { 1245 1264 input_SelectES( p_sys->p_input, id->p_es ); 1265 vlc_mutex_unlock( &p_sys->p_input->stream.stream_lock ); 1246 1266 return id->p_es->p_decoder_fifo ? VLC_SUCCESS : VLC_EGENERIC; 1247 1267 } … … 1249 1269 { 1250 1270 input_UnselectES( p_sys->p_input, id->p_es ); 1251 }1252 return VLC_SUCCESS;1253 1271 vlc_mutex_unlock( &p_sys->p_input->stream.stream_lock ); 1272 return VLC_SUCCESS; 1273 } 1254 1274 case ES_OUT_GET_SELECT: 1255 1275 id = (es_out_id_t*) va_arg( args, es_out_id_t * );
