Mercurial > mplayer.hg
comparison spudec.c @ 10917:d45870f67728
Forced subtitles patch by Arne Driescher <driescher@mpi-magdeburg.mpg.de>
For a given subtitle language you can now chose to display
only the forced subtitles. Defaut is set to "show all subtitles"
so that current mplayer behaviour is not changed.
For DVD:
Use -forced_subs_only additionally to e.g. -slang en
if you are only interested in the forced subtitles.
For VobSub:
The idx file is now parsed for the "forced subs: ON/OFF" tag
and used according to its settings.
Key:
You can toggle the display of forced subtitles by pressing
"F" (upper case letter).
author | attila |
---|---|
date | Sun, 21 Sep 2003 14:21:43 +0000 |
parents | 543ab3909b78 |
children | 6e35326c742f |
comparison
equal
deleted
inserted
replaced
10916:c36db88bfbc4 | 10917:d45870f67728 |
---|---|
87 unsigned char *scaled_aimage; | 87 unsigned char *scaled_aimage; |
88 int auto_palette; /* 1 if we lack a palette and must use an heuristic. */ | 88 int auto_palette; /* 1 if we lack a palette and must use an heuristic. */ |
89 int font_start_level; /* Darkest value used for the computed font */ | 89 int font_start_level; /* Darkest value used for the computed font */ |
90 vo_functions_t *hw_spu; | 90 vo_functions_t *hw_spu; |
91 int spu_changed; | 91 int spu_changed; |
92 unsigned int forced_subs_only; /* flag: 0=display all subtitle, !0 display only forced subtitles */ | |
93 unsigned int is_forced_sub; /* true if current subtitle is a forced subtitle */ | |
92 } spudec_handle_t; | 94 } spudec_handle_t; |
93 | 95 |
94 static void spudec_queue_packet(spudec_handle_t *this, packet_t *packet) | 96 static void spudec_queue_packet(spudec_handle_t *this, packet_t *packet) |
95 { | 97 { |
96 if (this->queue_head == NULL) | 98 if (this->queue_head == NULL) |
369 switch(type) { | 371 switch(type) { |
370 case 0x00: | 372 case 0x00: |
371 /* Menu ID, 1 byte */ | 373 /* Menu ID, 1 byte */ |
372 mp_msg(MSGT_SPUDEC,MSGL_DBG2,"Menu ID\n"); | 374 mp_msg(MSGT_SPUDEC,MSGL_DBG2,"Menu ID\n"); |
373 /* shouldn't a Menu ID type force display start? */ | 375 /* shouldn't a Menu ID type force display start? */ |
374 //this->start_pts = pts100 + date; | 376 start_pts = pts100 + date; |
375 //this->end_pts = UINT_MAX; | 377 end_pts = UINT_MAX; |
378 display = 1; | |
379 this->is_forced_sub=~0; // current subtitle is forced | |
376 break; | 380 break; |
377 case 0x01: | 381 case 0x01: |
378 /* Start display */ | 382 /* Start display */ |
379 mp_msg(MSGT_SPUDEC,MSGL_DBG2,"Start display!\n"); | 383 mp_msg(MSGT_SPUDEC,MSGL_DBG2,"Start display!\n"); |
380 start_pts = pts100 + date; | 384 start_pts = pts100 + date; |
381 end_pts = UINT_MAX; | 385 end_pts = UINT_MAX; |
382 display = 1; | 386 display = 1; |
387 this->is_forced_sub=0; | |
383 break; | 388 break; |
384 case 0x02: | 389 case 0x02: |
385 /* Stop display */ | 390 /* Stop display */ |
386 mp_msg(MSGT_SPUDEC,MSGL_DBG2,"Stop display!\n"); | 391 mp_msg(MSGT_SPUDEC,MSGL_DBG2,"Stop display!\n"); |
387 end_pts = pts100 + date; | 392 end_pts = pts100 + date; |
602 spu->height > 0); | 607 spu->height > 0); |
603 // printf("spu visible: %d \n",ret); | 608 // printf("spu visible: %d \n",ret); |
604 return ret; | 609 return ret; |
605 } | 610 } |
606 | 611 |
612 void spudec_set_forced_subs_only(void * const this, const unsigned int flag) | |
613 { | |
614 if(this){ | |
615 ((spudec_handle_t *)this)->forced_subs_only=flag; | |
616 mp_msg(MSGT_SPUDEC,MSGL_DBG2,"SPU: Display only forced subs now %s\n", flag ? "enabled": "disabled"); | |
617 } | |
618 } | |
619 | |
607 void spudec_draw(void *this, void (*draw_alpha)(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride)) | 620 void spudec_draw(void *this, void (*draw_alpha)(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride)) |
608 { | 621 { |
609 spudec_handle_t *spu = (spudec_handle_t *)this; | 622 spudec_handle_t *spu = (spudec_handle_t *)this; |
610 if (spu->start_pts <= spu->now_pts && spu->now_pts < spu->end_pts && spu->image) | 623 if (spu->start_pts <= spu->now_pts && spu->now_pts < spu->end_pts && spu->image) |
611 { | 624 { |
750 void spudec_draw_scaled(void *me, unsigned int dxs, unsigned int dys, void (*draw_alpha)(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride)) | 763 void spudec_draw_scaled(void *me, unsigned int dxs, unsigned int dys, void (*draw_alpha)(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride)) |
751 { | 764 { |
752 spudec_handle_t *spu = (spudec_handle_t *)me; | 765 spudec_handle_t *spu = (spudec_handle_t *)me; |
753 scale_pixel *table_x; | 766 scale_pixel *table_x; |
754 scale_pixel *table_y; | 767 scale_pixel *table_y; |
768 | |
755 if (spu->start_pts <= spu->now_pts && spu->now_pts < spu->end_pts) { | 769 if (spu->start_pts <= spu->now_pts && spu->now_pts < spu->end_pts) { |
770 | |
771 // check if only forced subtitles are requested | |
772 if( (spu->forced_subs_only) && !(spu->is_forced_sub) ){ | |
773 return; | |
774 } | |
775 | |
756 if (!(spu_aamode&16) && (spu->orig_frame_width == 0 || spu->orig_frame_height == 0 | 776 if (!(spu_aamode&16) && (spu->orig_frame_width == 0 || spu->orig_frame_height == 0 |
757 || (spu->orig_frame_width == dxs && spu->orig_frame_height == dys))) { | 777 || (spu->orig_frame_width == dxs && spu->orig_frame_height == dys))) { |
758 if (spu->image) | 778 if (spu->image) |
759 { | 779 { |
760 draw_alpha(spu->start_col, spu->start_row, spu->width, spu->height, | 780 draw_alpha(spu->start_col, spu->start_row, spu->width, spu->height, |
1123 this->custom = custom; | 1143 this->custom = custom; |
1124 if (custom && cuspal) { | 1144 if (custom && cuspal) { |
1125 memcpy(this->cuspal, cuspal, sizeof(this->cuspal)); | 1145 memcpy(this->cuspal, cuspal, sizeof(this->cuspal)); |
1126 this->auto_palette = 0; | 1146 this->auto_palette = 0; |
1127 } | 1147 } |
1148 // forced subtitles default: show all subtitles | |
1149 this->forced_subs_only=0; | |
1150 this->is_forced_sub=0; | |
1128 } | 1151 } |
1129 else | 1152 else |
1130 mp_msg(MSGT_SPUDEC,MSGL_FATAL, "FATAL: spudec_init: calloc"); | 1153 mp_msg(MSGT_SPUDEC,MSGL_FATAL, "FATAL: spudec_init: calloc"); |
1131 return this; | 1154 return this; |
1132 } | 1155 } |