diff options
Diffstat (limited to 'sub/subreader.c')
-rw-r--r-- | sub/subreader.c | 259 |
1 files changed, 0 insertions, 259 deletions
diff --git a/sub/subreader.c b/sub/subreader.c index 6c12ba08a4..ae6f009bc4 100644 --- a/sub/subreader.c +++ b/sub/subreader.c @@ -1790,265 +1790,6 @@ if ((suboverlap_enabled == 2) || return subt_data; } -void list_sub_file(sub_data* subd){ - int i,j; - subtitle *subs = subd->subtitles; - - for(j=0; j < subd->sub_num; j++){ - subtitle* egysub=&subs[j]; - mp_msg(MSGT_SUBREADER,MSGL_INFO,"%i line%c (%li-%li)\n", - egysub->lines, - (1==egysub->lines)?' ':'s', - egysub->start, - egysub->end); - for (i=0; i<egysub->lines; i++) { - mp_msg(MSGT_SUBREADER,MSGL_INFO,"\t\t%d: %s%s", i,egysub->text[i], i==egysub->lines-1?"":" \n "); - } - mp_msg(MSGT_SUBREADER,MSGL_INFO,"\n"); - } - - mp_msg(MSGT_SUBREADER,MSGL_INFO,"Subtitle format %s time.\n", - subd->sub_uses_time ? "uses":"doesn't use"); - mp_msg(MSGT_SUBREADER,MSGL_INFO,"Read %i subtitles, %i errors.\n", subd->sub_num, subd->sub_errs); -} - -void dump_srt(sub_data* subd, float fps){ - int i,j; - int h,m,s,ms; - FILE * fd; - subtitle * onesub; - unsigned long temp; - subtitle *subs = subd->subtitles; - - if (!subd->sub_uses_time && sub_fps == 0) - sub_fps = fps; - fd=fopen("dumpsub.srt","w"); - if(!fd) - { - perror("dump_srt: fopen"); - return; - } - for(i=0; i < subd->sub_num; i++) - { - onesub=subs+i; //=&subs[i]; - fprintf(fd,"%d\n",i+1);//line number - - temp=onesub->start; - if (!subd->sub_uses_time) - temp = temp * 100 / sub_fps; - temp -= sub_delay * 100; - h=temp/360000;temp%=360000; //h =1*100*60*60 - m=temp/6000; temp%=6000; //m =1*100*60 - s=temp/100; temp%=100; //s =1*100 - ms=temp*10; //ms=1*10 - fprintf(fd,"%02d:%02d:%02d,%03d --> ",h,m,s,ms); - - temp=onesub->end; - if (!subd->sub_uses_time) - temp = temp * 100 / sub_fps; - temp -= sub_delay * 100; - h=temp/360000;temp%=360000; - m=temp/6000; temp%=6000; - s=temp/100; temp%=100; - ms=temp*10; - fprintf(fd,"%02d:%02d:%02d,%03d\n",h,m,s,ms); - - for(j=0;j<onesub->lines;j++) - fprintf(fd,"%s\n",onesub->text[j]); - - fprintf(fd,"\n"); - } - fclose(fd); - mp_msg(MSGT_SUBREADER,MSGL_INFO,"SUB: Subtitles dumped in \'dumpsub.srt\'.\n"); -} - -void dump_mpsub(sub_data* subd, float fps){ - int i,j; - FILE *fd; - float a,b; - subtitle *subs = subd->subtitles; - - mpsub_position = subd->sub_uses_time? (sub_delay*100) : (sub_delay*fps); - if (sub_fps==0) sub_fps=fps; - - fd=fopen ("dump.mpsub", "w"); - if (!fd) { - perror ("dump_mpsub: fopen"); - return; - } - - - if (subd->sub_uses_time) fprintf (fd,"FORMAT=TIME\n\n"); - else fprintf (fd, "FORMAT=%5.2f\n\n", fps); - - for(j=0; j < subd->sub_num; j++){ - subtitle* egysub=&subs[j]; - if (subd->sub_uses_time) { - a=((egysub->start-mpsub_position)/100.0); - b=((egysub->end-egysub->start)/100.0); - if ( (float)((int)a) == a) - fprintf (fd, "%.0f",a); - else - fprintf (fd, "%.2f",a); - - if ( (float)((int)b) == b) - fprintf (fd, " %.0f\n",b); - else - fprintf (fd, " %.2f\n",b); - } else { - fprintf (fd, "%ld %ld\n", (long)((egysub->start*(fps/sub_fps))-((mpsub_position*(fps/sub_fps)))), - (long)(((egysub->end)-(egysub->start))*(fps/sub_fps))); - } - - mpsub_position = egysub->end; - for (i=0; i<egysub->lines; i++) { - fprintf (fd, "%s\n",egysub->text[i]); - } - fprintf (fd, "\n"); - } - fclose (fd); - mp_msg(MSGT_SUBREADER,MSGL_INFO,"SUB: Subtitles dumped in \'dump.mpsub\'.\n"); -} - -void dump_microdvd(sub_data* subd, float fps) { - int i, delay; - FILE *fd; - subtitle *subs = subd->subtitles; - if (sub_fps == 0) - sub_fps = fps; - fd = fopen("dumpsub.sub", "w"); - if (!fd) { - perror("dumpsub.sub: fopen"); - return; - } - delay = sub_delay * sub_fps; - for (i = 0; i < subd->sub_num; ++i) { - int j, start, end; - start = subs[i].start; - end = subs[i].end; - if (subd->sub_uses_time) { - start = start * sub_fps / 100 ; - end = end * sub_fps / 100; - } - else { - start = start * sub_fps / fps; - end = end * sub_fps / fps; - } - start -= delay; - end -= delay; - fprintf(fd, "{%d}{%d}", start, end); - for (j = 0; j < subs[i].lines; ++j) - fprintf(fd, "%s%s", j ? "|" : "", subs[i].text[j]); - fprintf(fd, "\n"); - } - fclose(fd); - mp_msg(MSGT_SUBREADER,MSGL_INFO,"SUB: Subtitles dumped in \'dumpsub.sub\'.\n"); -} - -void dump_jacosub(sub_data* subd, float fps) { - int i,j; - int h,m,s,cs; - FILE * fd; - subtitle * onesub; - unsigned long temp; - subtitle *subs = subd->subtitles; - - if (!subd->sub_uses_time && sub_fps == 0) - sub_fps = fps; - fd=fopen("dumpsub.jss","w"); - if(!fd) - { - perror("dump_jacosub: fopen"); - return; - } - fprintf(fd, "#TIMERES %d\n", (subd->sub_uses_time) ? 100 : (int)sub_fps); - for(i=0; i < subd->sub_num; i++) - { - onesub=subs+i; //=&subs[i]; - - temp=onesub->start; - if (!subd->sub_uses_time) - temp = temp * 100 / sub_fps; - temp -= sub_delay * 100; - h=temp/360000;temp%=360000; //h =1*100*60*60 - m=temp/6000; temp%=6000; //m =1*100*60 - s=temp/100; temp%=100; //s =1*100 - cs=temp; //cs=1*10 - fprintf(fd,"%02d:%02d:%02d.%02d ",h,m,s,cs); - - temp=onesub->end; - if (!subd->sub_uses_time) - temp = temp * 100 / sub_fps; - temp -= sub_delay * 100; - h=temp/360000;temp%=360000; - m=temp/6000; temp%=6000; - s=temp/100; temp%=100; - cs=temp; - fprintf(fd,"%02d:%02d:%02d.%02d {~} ",h,m,s,cs); - - for(j=0;j<onesub->lines;j++) - fprintf(fd,"%s%s",j ? "\\n" : "", onesub->text[j]); - - fprintf(fd,"\n"); - } - fclose(fd); - mp_msg(MSGT_SUBREADER,MSGL_INFO,"SUB: Subtitles dumped in \'dumpsub.js\'.\n"); -} - -void dump_sami(sub_data* subd, float fps) { - int i,j; - FILE * fd; - subtitle * onesub; - unsigned long temp; - subtitle *subs = subd->subtitles; - - if (!subd->sub_uses_time && sub_fps == 0) - sub_fps = fps; - fd=fopen("dumpsub.smi","w"); - if(!fd) - { - perror("dump_jacosub: fopen"); - return; - } - fprintf(fd, "<SAMI>\n" - "<HEAD>\n" - " <STYLE TYPE=\"Text/css\">\n" - " <!--\n" - " P {margin-left: 29pt; margin-right: 29pt; font-size: 24pt; text-align: center; font-family: Tahoma; font-weight: bold; color: #FCDD03; background-color: #000000;}\n" - " .SUBTTL {Name: 'Subtitles'; Lang: en-US; SAMIType: CC;}\n" - " -->\n" - " </STYLE>\n" - "</HEAD>\n" - "<BODY>\n"); - for(i=0; i < subd->sub_num; i++) - { - onesub=subs+i; //=&subs[i]; - - temp=onesub->start; - if (!subd->sub_uses_time) - temp = temp * 100 / sub_fps; - temp -= sub_delay * 100; - fprintf(fd,"\t<SYNC Start=%lu>\n" - "\t <P>", temp * 10); - - for(j=0;j<onesub->lines;j++) - fprintf(fd,"%s%s",j ? "<br>" : "", onesub->text[j]); - - fprintf(fd,"\n"); - - temp=onesub->end; - if (!subd->sub_uses_time) - temp = temp * 100 / sub_fps; - temp -= sub_delay * 100; - fprintf(fd,"\t<SYNC Start=%lu>\n" - "\t <P> \n", temp * 10); - } - fprintf(fd, "</BODY>\n" - "</SAMI>\n"); - fclose(fd); - mp_msg(MSGT_SUBREADER,MSGL_INFO,"SUB: Subtitles dumped in \'dumpsub.smi\'.\n"); -} - void sub_free( sub_data * subd ) { int i, j; |