Mercurial > mplayer.hg
comparison subreader.c @ 2495:d767086efcda
mpsub, FORMAT=<frame> alpha version
author | laaz |
---|---|
date | Fri, 26 Oct 2001 22:14:19 +0000 |
parents | 24427e03cd66 |
children | ec672ea5ac2c |
comparison
equal
deleted
inserted
replaced
2494:e5e2b7a8b154 | 2495:d767086efcda |
---|---|
402 | 402 |
403 for (q=p; !eol(*q); q++); | 403 for (q=p; !eol(*q); q++); |
404 *q='\0'; | 404 *q='\0'; |
405 if (strlen(p)) { | 405 if (strlen(p)) { |
406 current->text[num]=strdup(p); | 406 current->text[num]=strdup(p); |
407 printf (">%s<\n",p); | |
407 current->lines = ++num; | 408 current->lines = ++num; |
408 } else { | 409 } else { |
409 if (num) return current; | 410 if (num) return current; |
410 else return NULL; | 411 else return NULL; |
411 } | 412 } |
479 // Please someone who knows the format of RT... FIX IT!!! | 480 // Please someone who knows the format of RT... FIX IT!!! |
480 // It may conflict with other sub formats in the future (actually it doesn't) | 481 // It may conflict with other sub formats in the future (actually it doesn't) |
481 if ( *line == '<' ) | 482 if ( *line == '<' ) |
482 {sub_uses_time=1;return 5;} | 483 {sub_uses_time=1;return 5;} |
483 | 484 |
484 // I have only seen only 1 piece of .ssa file. | |
485 // It may be not correct (tell me if it's not) | |
486 if (!memcmp(line, "Dialogue: Marked", 16)) | 485 if (!memcmp(line, "Dialogue: Marked", 16)) |
487 {sub_uses_time=1; return 6;} | 486 {sub_uses_time=1; return 6;} |
488 if (sscanf (line, "%d,%d,\"%c", &i, &i, (char *) &i) == 3) | 487 if (sscanf (line, "%d,%d,\"%c", &i, &i, (char *) &i) == 3) |
489 {sub_uses_time=0;return 7;} | 488 {sub_uses_time=0;return 7;} |
490 if (sscanf (line, "FORMAT=%d", &i) == 1) | 489 if (sscanf (line, "FORMAT=%d", &i) == 1) |
745 return; | 744 return; |
746 } | 745 } |
747 | 746 |
748 | 747 |
749 if (sub_uses_time) fprintf (fd,"FORMAT=TIME\n\n"); | 748 if (sub_uses_time) fprintf (fd,"FORMAT=TIME\n\n"); |
750 else fprintf (fd, "FORMAT=25"); // FIXME: fps | 749 else fprintf (fd, "FORMAT=25\n\n"); // FIXME: fps |
751 | 750 |
752 for(j=0;j<sub_num;j++){ | 751 for(j=0;j<sub_num;j++){ |
753 subtitle* egysub=&subs[j]; | 752 subtitle* egysub=&subs[j]; |
754 a=((egysub->start-mpsub_position)/100.0); | 753 if (sub_uses_time) { |
755 b=((egysub->end-egysub->start)/100.0); | 754 a=((egysub->start-mpsub_position)/100.0); |
756 if ( (float)((int)a) == a) | 755 b=((egysub->end-egysub->start)/100.0); |
757 fprintf (fd, "%.0f",a); | 756 if ( (float)((int)a) == a) |
758 else | 757 fprintf (fd, "%.0f",a); |
759 fprintf (fd, "%.2f",a); | 758 else |
760 | 759 fprintf (fd, "%.2f",a); |
761 if ( (float)((int)b) == b) | 760 |
762 fprintf (fd, " %.0f\n",b); | 761 if ( (float)((int)b) == b) |
763 else | 762 fprintf (fd, " %.0f\n",b); |
764 fprintf (fd, " %.2f\n",b); | 763 else |
765 | 764 fprintf (fd, " %.2f\n",b); |
766 mpsub_position = egysub->end; | 765 } else { |
767 for (i=0; i<egysub->lines; i++) { | 766 fprintf (fd, "%ld %ld\n", egysub->start-mpsub_position, |
768 fprintf (fd, "%s\n",egysub->text[i]); | 767 egysub->end-egysub->start); |
769 } | 768 } |
770 fprintf (fd, "\n"); | 769 |
770 mpsub_position = egysub->end; | |
771 for (i=0; i<egysub->lines; i++) { | |
772 fprintf (fd, "%s\n",egysub->text[i]); | |
773 } | |
774 fprintf (fd, "\n"); | |
771 } | 775 } |
772 fclose (fd); | 776 fclose (fd); |
773 printf ("Subtitles dumped in \'dump.mpsub\'.\n"); | 777 printf ("Subtitles dumped in \'dump.mpsub\'.\n"); |
774 } | 778 } |
775 | 779 |