📄 subtitle_subrip.c.svn-base
字号:
/*PMP ModCopyright (C) 2006 RaphaelE-mail: raphael@fx-world.orgThis program is free software; you can redistribute it and/or modifyit under the terms of the GNU General Public License as published bythe Free Software Foundation; either version 2 of the License, or(at your option) any later version.This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See theGNU General Public License for more details.You should have received a copy of the GNU General Public Licensealong with this program; if not, write to the Free SoftwareFoundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.*//*subrip subtitle format parser*///a little modify by cooleyes#include<psptypes.h>#include<string.h>#include "subtitle_subrip.h"#include "common/mem64.h"#include "common/libminiconv.h"struct subtitle_frame_struct* subtitle_parse_subrip( FILE *f, char* charset, unsigned int rate, unsigned int scale ) { if (!f) return(0); struct subtitle_frame_struct *p = (struct subtitle_frame_struct*)malloc_64( sizeof(struct subtitle_frame_struct) ); if (p==0) return(0); p->p_string[0] = '\0'; char line[1024]; char c; u64 temp; int a1,a2,a3,a4,b1,b2,b3,b4; int i, j = 0; while (1) { if (!fgets(line, 1024, f)) return(0); if (sscanf(line, "%d:%d:%d%[,.:]%d --> %d:%d:%d%[,.:]%d",&a1,&a2,&a3,(char *)&i,&a4,&b1,&b2,&b3,(char *)&i,&b4) >= 10) break; } //modify by cooleyes 2006/12/11 temp = 1; temp = temp * (a1*360000+a2*6000+a3*100+a4/10) * rate; //p->p_start_frame = (a1*360000+a2*6000+a3*100+a4/10) * rate / (scale*100); p->p_start_frame = temp/scale/100; temp = 1; temp = temp * (b1*360000+b2*6000+b3*100+b4/10) * rate; //p->p_end_frame = (b1*360000+b2*6000+b3*100+b4/10) * rate / (scale*100); p->p_end_frame = temp/scale/100; //modify end p->p_num_lines = 0; j = 0; while (j<max_subtitle_string) { if (!fgets (line, 1023, f)) break; if (line[0]=='\n' || line[0]=='\r') break; p->p_num_lines++; i = 0; while (i<1024) { c = line[i++]; if (c=='<') { while (line[i]!='>') i++; i++; } else if (c=='\n' || c=='\r' || c==EOF) break; else { p->p_string[j++]=c; } } p->p_string[j++]='\n'; } p->p_string[j-1] = '\0'; if ( miniConvHaveSubtitleConv(charset) ) { char* temp_str = miniConvSubtitleConv(p->p_string, charset); if( temp_str != NULL ) { strncpy(p->p_string, temp_str, max_subtitle_string-1); } } else if ( miniConvHaveDefaultSubtitleConv() ){ char* temp_str = miniConvDefaultSubtitleConv(p->p_string); if( temp_str != NULL ) { strncpy(p->p_string, temp_str, max_subtitle_string-1); } } return(p); }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -