Mercurial > mplayer.hg
comparison libvo/sub.c @ 29263:0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
author | diego |
---|---|
date | Wed, 13 May 2009 02:58:57 +0000 |
parents | df67d03dde3b |
children | 1331380992e2 |
comparison
equal
deleted
inserted
replaced
29262:7d545a6b8aff | 29263:0f1b5b68af32 |
---|---|
130 fprintf(stderr, "osd text out of range: bbox [%d %d %d %d], txt [%d %d %d %d]\n", | 130 fprintf(stderr, "osd text out of range: bbox [%d %d %d %d], txt [%d %d %d %d]\n", |
131 obj->bbox.x1, obj->bbox.x2, obj->bbox.y1, obj->bbox.y2, | 131 obj->bbox.x1, obj->bbox.x2, obj->bbox.y1, obj->bbox.y2, |
132 x0, x0+w, y0, y0+h); | 132 x0, x0+w, y0, y0+h); |
133 return; | 133 return; |
134 } | 134 } |
135 | 135 |
136 for (i = 0; i < h; i++) { | 136 for (i = 0; i < h; i++) { |
137 for (j = 0; j < w; j++, b++, a++, bs++, as++) { | 137 for (j = 0; j < w; j++, b++, a++, bs++, as++) { |
138 if (*b < *bs) *b = *bs; | 138 if (*b < *bs) *b = *bs; |
139 if (*as) { | 139 if (*as) { |
140 if (*a == 0 || *a > *as) *a = *as; | 140 if (*a == 0 || *a > *as) *a = *as; |
205 uint16_t c=utf8_get_char(&cp); | 205 uint16_t c=utf8_get_char(&cp); |
206 render_one_glyph(vo_font, c); | 206 render_one_glyph(vo_font, c); |
207 x+=vo_font->width[c]+vo_font->charspace; | 207 x+=vo_font->width[c]+vo_font->charspace; |
208 h=get_height(c,h); | 208 h=get_height(c,h); |
209 } | 209 } |
210 | 210 |
211 obj->bbox.x2=x-vo_font->charspace; | 211 obj->bbox.x2=x-vo_font->charspace; |
212 obj->bbox.y2=obj->bbox.y1+h; | 212 obj->bbox.y2=obj->bbox.y1+h; |
213 obj->flags|=OSDFLAG_BBOX; | 213 obj->flags|=OSDFLAG_BBOX; |
214 | 214 |
215 alloc_buf(obj); | 215 alloc_buf(obj); |
261 | 261 |
262 obj->bbox.x1 = obj->x = sx; | 262 obj->bbox.x1 = obj->x = sx; |
263 obj->bbox.y1 = obj->y = sy; | 263 obj->bbox.y1 = obj->y = sy; |
264 obj->bbox.x2 = ex; | 264 obj->bbox.x2 = ex; |
265 obj->bbox.y2 = ey; | 265 obj->bbox.y2 = ey; |
266 | 266 |
267 alloc_buf (obj); | 267 alloc_buf (obj); |
268 len = obj->stride * (obj->bbox.y2 - obj->bbox.y1); | 268 len = obj->stride * (obj->bbox.y2 - obj->bbox.y1); |
269 memset (obj->bitmap_buffer, OSD_NAV_BOX_ALPHA, len); | 269 memset (obj->bitmap_buffer, OSD_NAV_BOX_ALPHA, len); |
270 memset (obj->alpha_buffer, OSD_NAV_BOX_ALPHA, len); | 270 memset (obj->alpha_buffer, OSD_NAV_BOX_ALPHA, len); |
271 obj->flags |= OSDFLAG_BBOX | OSDFLAG_CHANGED; | 271 obj->flags |= OSDFLAG_BBOX | OSDFLAG_CHANGED; |
463 | 463 |
464 (0:wm/2) (wm/2:wm-wm/2) | 464 (0:wm/2) (wm/2:wm-wm/2) |
465 | 465 |
466 ********** *********** (0:hm/3) | 466 ********** *********** (0:hm/3) |
467 *** **** **** **** | 467 *** **** **** **** |
468 *** 1 **** **** 2 **** | 468 *** 1 **** **** 2 **** |
469 *** **** **** **** | 469 *** **** **** **** |
470 ********** *********** | 470 ********** *********** |
471 ********** *********** | 471 ********** *********** |
472 | 472 |
473 ********** *********** (hm/3:hm-2*hm/3) | 473 ********** *********** (hm/3:hm-2*hm/3) |
480 ********** *********** | 480 ********** *********** |
481 | 481 |
482 ********** *********** (hm-hm/3:hm/3) | 482 ********** *********** (hm-hm/3:hm/3) |
483 *** **** **** **** | 483 *** **** **** **** |
484 *** 5 **** **** 6 **** | 484 *** 5 **** **** 6 **** |
485 *** **** **** **** | 485 *** **** **** **** |
486 ********** *********** | |
487 ********** *********** | 486 ********** *********** |
488 | 487 ********** *********** |
489 */ | 488 |
489 */ | |
490 if(tc.gfx>1){ //separated gfx | 490 if(tc.gfx>1){ //separated gfx |
491 for(b=0;b<6;b++){ | 491 for(b=0;b<6;b++){ |
492 color=(tc.unicode>>b)&1?tc.fg:tc.bg; | 492 color=(tc.unicode>>b)&1?tc.fg:tc.bg; |
493 draw_alpha_buf(obj,x+ax[b]+1,y+ay[b]+1,aw[b]-2,ah[b]-2,buf[color],buf[8],wm); | 493 draw_alpha_buf(obj,x+ax[b]+1,y+ay[b]+1,aw[b]-2,ah[b]-2,buf[color],buf[8],wm); |
494 } | 494 } |
520 | 520 |
521 int vo_osd_progbar_type=-1; | 521 int vo_osd_progbar_type=-1; |
522 int vo_osd_progbar_value=100; // 0..256 | 522 int vo_osd_progbar_value=100; // 0..256 |
523 | 523 |
524 // if we have n=256 bars then OSD progbar looks like below | 524 // if we have n=256 bars then OSD progbar looks like below |
525 // | 525 // |
526 // 0 1 2 3 ... 256 <= vo_osd_progbar_value | 526 // 0 1 2 3 ... 256 <= vo_osd_progbar_value |
527 // | | | | | | 527 // | | | | | |
528 // [ === === === ... === ] | 528 // [ === === === ... === ] |
529 // | 529 // |
530 // the above schema is rescalled to n=elems bars | 530 // the above schema is rescalled to n=elems bars |
531 | 531 |
532 inline static void vo_update_text_progbar(mp_osd_obj_t* obj,int dxs,int dys){ | 532 inline static void vo_update_text_progbar(mp_osd_obj_t* obj,int dxs,int dys){ |
533 | 533 |
534 obj->flags|=OSDFLAG_CHANGED|OSDFLAG_VISIBLE; | 534 obj->flags|=OSDFLAG_CHANGED|OSDFLAG_VISIBLE; |
535 | 535 |
536 if(vo_osd_progbar_type<0 || !vo_font){ | 536 if(vo_osd_progbar_type<0 || !vo_font){ |
537 obj->flags&=~OSDFLAG_VISIBLE; | 537 obj->flags&=~OSDFLAG_VISIBLE; |
538 return; | 538 return; |
539 } | 539 } |
540 | 540 |
541 render_one_glyph(vo_font, OSD_PB_START); | 541 render_one_glyph(vo_font, OSD_PB_START); |
542 render_one_glyph(vo_font, OSD_PB_END); | 542 render_one_glyph(vo_font, OSD_PB_END); |
543 render_one_glyph(vo_font, OSD_PB_0); | 543 render_one_glyph(vo_font, OSD_PB_0); |
544 render_one_glyph(vo_font, OSD_PB_1); | 544 render_one_glyph(vo_font, OSD_PB_1); |
545 render_one_glyph(vo_font, vo_osd_progbar_type); | 545 render_one_glyph(vo_font, vo_osd_progbar_type); |
546 | 546 |
547 // calculate bbox corners: | 547 // calculate bbox corners: |
548 { int h=0; | 548 { int h=0; |
549 int y=(dys-vo_font->height)/2; | 549 int y=(dys-vo_font->height)/2; |
550 int delimw=vo_font->width[OSD_PB_START] | 550 int delimw=vo_font->width[OSD_PB_START] |
551 +vo_font->width[OSD_PB_END] | 551 +vo_font->width[OSD_PB_END] |
552 +vo_font->charspace; | 552 +vo_font->charspace; |
572 obj->params.progbar.elems=elems; | 572 obj->params.progbar.elems=elems; |
573 obj->bbox.x1-=delta; // space for an icon | 573 obj->bbox.x1-=delta; // space for an icon |
574 } | 574 } |
575 | 575 |
576 alloc_buf(obj); | 576 alloc_buf(obj); |
577 | 577 |
578 { | 578 { |
579 int minw = vo_font->width[OSD_PB_START]+vo_font->width[OSD_PB_END]+vo_font->width[OSD_PB_0]; | 579 int minw = vo_font->width[OSD_PB_START]+vo_font->width[OSD_PB_END]+vo_font->width[OSD_PB_0]; |
580 if (vo_osd_progbar_type>0 && vo_font->font[vo_osd_progbar_type]>=0){ | 580 if (vo_osd_progbar_type>0 && vo_font->font[vo_osd_progbar_type]>=0){ |
581 minw += vo_font->width[vo_osd_progbar_type]+vo_font->charspace+vo_font->spacewidth; | 581 minw += vo_font->width[vo_osd_progbar_type]+vo_font->charspace+vo_font->spacewidth; |
582 } | 582 } |
583 if (obj->bbox.x2 - obj->bbox.x1 < minw) return; // space too small, don't render anything | 583 if (obj->bbox.x2 - obj->bbox.x1 < minw) return; // space too small, don't render anything |
584 } | 584 } |
585 | 585 |
586 // render it: | 586 // render it: |
587 { unsigned char *s; | 587 { unsigned char *s; |
588 unsigned char *sa; | 588 unsigned char *sa; |
589 int i,w,h,st,mark; | 589 int i,w,h,st,mark; |
590 int x=obj->x; | 590 int x=obj->x; |
599 int ev=vo_osd_progbar_value*elems; | 599 int ev=vo_osd_progbar_value*elems; |
600 mark=ev>>8; | 600 mark=ev>>8; |
601 if (ev & 0xFF) mark++; | 601 if (ev & 0xFF) mark++; |
602 if (mark>elems) mark=elems; | 602 if (mark>elems) mark=elems; |
603 } | 603 } |
604 | 604 |
605 | 605 |
606 // printf("osd.progbar width=%d xpos=%d\n",width,x); | 606 // printf("osd.progbar width=%d xpos=%d\n",width,x); |
607 | 607 |
608 c=vo_osd_progbar_type; | 608 c=vo_osd_progbar_type; |
609 if(vo_osd_progbar_type>0 && (font=vo_font->font[c])>=0) { | 609 if(vo_osd_progbar_type>0 && (font=vo_font->font[c])>=0) { |
613 vo_font->pic_a[font]->h, | 613 vo_font->pic_a[font]->h, |
614 vo_font->pic_b[font]->bmp+vo_font->start[c], | 614 vo_font->pic_b[font]->bmp+vo_font->start[c], |
615 vo_font->pic_a[font]->bmp+vo_font->start[c], | 615 vo_font->pic_a[font]->bmp+vo_font->start[c], |
616 vo_font->pic_a[font]->w); | 616 vo_font->pic_a[font]->w); |
617 } | 617 } |
618 | 618 |
619 c=OSD_PB_START; | 619 c=OSD_PB_START; |
620 if ((font=vo_font->font[c])>=0) | 620 if ((font=vo_font->font[c])>=0) |
621 draw_alpha_buf(obj,x,y, | 621 draw_alpha_buf(obj,x,y, |
622 vo_font->width[c], | 622 vo_font->width[c], |
623 vo_font->pic_a[font]->h, | 623 vo_font->pic_a[font]->h, |
676 int lastStripPosition; | 676 int lastStripPosition; |
677 int xsize; | 677 int xsize; |
678 int xmin=dxs,xmax=0; | 678 int xmin=dxs,xmax=0; |
679 int h,lasth; | 679 int h,lasth; |
680 int xtblc, utblc; | 680 int xtblc, utblc; |
681 | 681 |
682 obj->flags|=OSDFLAG_CHANGED|OSDFLAG_VISIBLE; | 682 obj->flags|=OSDFLAG_CHANGED|OSDFLAG_VISIBLE; |
683 | 683 |
684 if(!vo_sub || !sub_font || !sub_visibility || (sub_font->font[40]<0)){ | 684 if(!vo_sub || !sub_font || !sub_visibility || (sub_font->font[40]<0)){ |
685 obj->flags&=~OSDFLAG_VISIBLE; | 685 obj->flags&=~OSDFLAG_VISIBLE; |
686 return; | 686 return; |
687 } | 687 } |
688 | 688 |
689 obj->bbox.y2=obj->y=dys; | 689 obj->bbox.y2=obj->y=dys; |
690 obj->params.subtitle.lines=0; | 690 obj->params.subtitle.lines=0; |
691 | 691 |
692 // too long lines divide into a smaller ones | 692 // too long lines divide into a smaller ones |
693 i=k=lasth=0; | 693 i=k=lasth=0; |
702 int *char_seq, char_position, xlimit = dxs * sub_width_p / 100, counter; | 702 int *char_seq, char_position, xlimit = dxs * sub_width_p / 100, counter; |
703 | 703 |
704 while (l) { | 704 while (l) { |
705 xsize = -sub_font->charspace; | 705 xsize = -sub_font->charspace; |
706 l--; | 706 l--; |
707 t=vo_sub->text[i++]; | 707 t=vo_sub->text[i++]; |
708 char_position = 0; | 708 char_position = 0; |
709 char_seq = calloc(strlen(t), sizeof(int)); | 709 char_seq = calloc(strlen(t), sizeof(int)); |
710 | 710 |
711 prevc = -1; | 711 prevc = -1; |
712 | 712 |
747 char_position = 0; | 747 char_position = 0; |
748 xsize = 0; | 748 xsize = 0; |
749 prevc = c; | 749 prevc = c; |
750 } else { | 750 } else { |
751 int delta_xsize = sub_font->width[c] + sub_font->charspace + kerning(sub_font, prevc, c); | 751 int delta_xsize = sub_font->width[c] + sub_font->charspace + kerning(sub_font, prevc, c); |
752 | 752 |
753 if (xsize + delta_xsize <= dxs) { | 753 if (xsize + delta_xsize <= dxs) { |
754 if (!x) x = 1; | 754 if (!x) x = 1; |
755 prevc = c; | 755 prevc = c; |
756 char_seq[char_position++] = c; | 756 char_seq[char_position++] = c; |
757 xsize += delta_xsize; | 757 xsize += delta_xsize; |
938 obj->params.subtitle.utbl[utblc - 1] = 0; | 938 obj->params.subtitle.utbl[utblc - 1] = 0; |
939 obj->y -= sub_font->height; | 939 obj->y -= sub_font->height; |
940 } | 940 } |
941 if(obj->params.subtitle.lines) | 941 if(obj->params.subtitle.lines) |
942 obj->y = dys - ((obj->params.subtitle.lines - 1) * sub_font->height + sub_font->pic_a[sub_font->font[40]]->h); | 942 obj->y = dys - ((obj->params.subtitle.lines - 1) * sub_font->height + sub_font->pic_a[sub_font->font[40]]->h); |
943 | 943 |
944 // free memory | 944 // free memory |
945 if (otp_sub != NULL) { | 945 if (otp_sub != NULL) { |
946 for (tmp = otp_sub->ott; tmp->next != NULL; free(tmp->prev)) { | 946 for (tmp = otp_sub->ott; tmp->next != NULL; free(tmp->prev)) { |
947 free(tmp->text); | 947 free(tmp->text); |
948 tmp = tmp->next; | 948 tmp = tmp->next; |
949 } | 949 } |
950 free(tmp->text); | 950 free(tmp->text); |
951 free(tmp); | 951 free(tmp); |
952 | 952 |
953 for(pmt = otp_sub; pmt->next != NULL; free(pmt->prev)) { | 953 for(pmt = otp_sub; pmt->next != NULL; free(pmt->prev)) { |
954 pmt = pmt->next; | 954 pmt = pmt->next; |
955 } | 955 } |
956 free(pmt); | 956 free(pmt); |
957 } | 957 } |
958 | 958 |
959 } | 959 } |
960 /// vertical alignment | 960 /// vertical alignment |
961 h = dys - obj->y; | 961 h = dys - obj->y; |
962 if (sub_alignment == 2) | 962 if (sub_alignment == 2) |
963 obj->y = dys * sub_pos / 100 - h; | 963 obj->y = dys * sub_pos / 100 - h; |
982 obj->flags|=OSDFLAG_BBOX; | 982 obj->flags|=OSDFLAG_BBOX; |
983 | 983 |
984 alloc_buf(obj); | 984 alloc_buf(obj); |
985 | 985 |
986 y = obj->y; | 986 y = obj->y; |
987 | 987 |
988 obj->alignment = 0; | 988 obj->alignment = 0; |
989 switch(vo_sub->alignment) { | 989 switch(vo_sub->alignment) { |
990 case SUB_ALIGNMENT_BOTTOMLEFT: | 990 case SUB_ALIGNMENT_BOTTOMLEFT: |
991 case SUB_ALIGNMENT_MIDDLELEFT: | 991 case SUB_ALIGNMENT_MIDDLELEFT: |
992 case SUB_ALIGNMENT_TOPLEFT: | 992 case SUB_ALIGNMENT_TOPLEFT: |
1036 prevc = c; | 1036 prevc = c; |
1037 } | 1037 } |
1038 y+=sub_font->height; | 1038 y+=sub_font->height; |
1039 } | 1039 } |
1040 } | 1040 } |
1041 | 1041 |
1042 } | 1042 } |
1043 | 1043 |
1044 inline static void vo_update_spudec_sub(mp_osd_obj_t* obj, int dxs, int dys) | 1044 inline static void vo_update_spudec_sub(mp_osd_obj_t* obj, int dxs, int dys) |
1045 { | 1045 { |
1046 unsigned int bbox[4]; | 1046 unsigned int bbox[4]; |
1128 load_font_ft(dxs, dys, &sub_font, font_name, text_font_scale_factor); | 1128 load_font_ft(dxs, dys, &sub_font, font_name, text_font_scale_factor); |
1129 prev_dxs = dxs; | 1129 prev_dxs = dxs; |
1130 prev_dys = dys; | 1130 prev_dys = dys; |
1131 defer_counter = 0; | 1131 defer_counter = 0; |
1132 } else { | 1132 } else { |
1133 if (!vo_font) | 1133 if (!vo_font) |
1134 load_font_ft(dxs, dys, &vo_font, font_name, osd_font_scale_factor); | 1134 load_font_ft(dxs, dys, &vo_font, font_name, osd_font_scale_factor); |
1135 if (!sub_font) { | 1135 if (!sub_font) { |
1136 if (sub_font_name) | 1136 if (sub_font_name) |
1137 load_font_ft(dxs, dys, &sub_font, sub_font_name, text_font_scale_factor); | 1137 load_font_ft(dxs, dys, &sub_font, sub_font_name, text_font_scale_factor); |
1138 else | 1138 else |
1242 | 1242 |
1243 void vo_remove_text(int dxs,int dys,void (*remove)(int x0,int y0, int w,int h)){ | 1243 void vo_remove_text(int dxs,int dys,void (*remove)(int x0,int y0, int w,int h)){ |
1244 mp_osd_obj_t* obj=vo_osd_list; | 1244 mp_osd_obj_t* obj=vo_osd_list; |
1245 vo_update_osd(dxs,dys); | 1245 vo_update_osd(dxs,dys); |
1246 while(obj){ | 1246 while(obj){ |
1247 if(((obj->flags&OSDFLAG_CHANGED) || (obj->flags&OSDFLAG_VISIBLE)) && | 1247 if(((obj->flags&OSDFLAG_CHANGED) || (obj->flags&OSDFLAG_VISIBLE)) && |
1248 (obj->flags&OSDFLAG_OLD_BBOX)){ | 1248 (obj->flags&OSDFLAG_OLD_BBOX)){ |
1249 int w=obj->old_bbox.x2-obj->old_bbox.x1; | 1249 int w=obj->old_bbox.x2-obj->old_bbox.x1; |
1250 int h=obj->old_bbox.y2-obj->old_bbox.y1; | 1250 int h=obj->old_bbox.y2-obj->old_bbox.y1; |
1251 if(w>0 && h>0){ | 1251 if(w>0 && h>0){ |
1252 vo_osd_changed_flag=obj->flags&OSDFLAG_CHANGED; // temp hack | 1252 vo_osd_changed_flag=obj->flags&OSDFLAG_CHANGED; // temp hack |