OSDN Git Service

stop using trunk directory in rectool
[rec10/rec10-git.git] / tstools / DtsEdit / src / DtsEdit.cpp
1 // DTSRepair.cpp : \83R\83\93\83\\81[\83\8b \83A\83v\83\8a\83P\81[\83V\83\87\83\93\82Ì\83G\83\93\83g\83\8a \83|\83C\83\93\83g\82ð\92è\8b`\82µ\82Ü\82·\81B\r
2 //\r
3 \r
4 #include "stdafx.h"\r
5 #include "Help.h"\r
6 #include "EditMain.h"\r
7 #include "windows.h"\r
8 \r
9 #define EXIST(s) (GetFileAttributes(s) != 0xFFFFFFFF)\r
10 \r
11 int main(int argc, char* argv[])\r
12 {\r
13         int ret = -1;\r
14         T_EDIT_PARAM prm;\r
15 \r
16         ZeroMemory(&prm, sizeof(T_EDIT_PARAM));\r
17 \r
18         // \83R\83}\83\93\83h\83\89\83C\83\93\83`\83F\83b\83N\r
19         if (argc < 2){\r
20                 Help();\r
21                 return ret;\r
22         }\r
23 \r
24         // \8f\89\8aú\92l\r
25         prm.i_mode = MODE_OUT;\r
26         prm.i_tcv = 2;\r
27         prm.i_timescale = 0;\r
28         prm.i_timerate = 0;\r
29         prm.f_scaleFct = 0;\r
30         prm.f_mlt = 4.0;\r
31         prm.i_delayFrame = -1;\r
32         prm.b_dc = TRUE;\r
33 \r
34         for(int i=1; i<argc; i++){\r
35                 char *name = argv[i];\r
36                 char *value = NULL;\r
37                 char *value2 = NULL;\r
38                 if((i+1)<argc)\r
39                         value = argv[i+1];\r
40 \r
41                 if(0){}\r
42 \r
43 #define OPT(x) else if (!_stricmp(x, name))\r
44 \r
45                 // \83^\83C\83\80\83R\81[\83h\r
46                 OPT("-tc"){\r
47                         if(!value || prm.p_tcfile) goto _ERROR_ARG;\r
48                         prm.p_tcfile = new char[strlen(value) + 1];\r
49                         strcpy(prm.p_tcfile, value);\r
50                         prm.i_mode = MODE_IN;\r
51                         i++;            \r
52                 }\r
53 \r
54                 // \83^\83C\83\80\83R\81[\83h\r
55                 OPT("-tv"){\r
56                         if(!value) goto _ERROR_ARG;\r
57                         prm.i_tcv = atoi(value);\r
58                         i++;\r
59                 }\r
60 \r
61                 // \83^\83C\83\80\83X\83P\81[\83\8b\r
62                 OPT("-s"){\r
63                         if(!value) goto _ERROR_ARG;\r
64                         prm.i_timescale = atol(value);\r
65                         i++;\r
66                 }\r
67 \r
68                 // \94{\90\94\r
69                 OPT("-mlt"){\r
70                         if(!value) goto _ERROR_ARG;\r
71                         prm.f_mlt = atof(value);\r
72                         i++;\r
73                 }\r
74 \r
75                 // \8dÅ\8f¬\83^\83C\83\80\83\8c\81[\83g\r
76                 OPT("-r"){\r
77                         if(!value) goto _ERROR_ARG;\r
78                         prm.i_timerate = atol(value);\r
79                         i++;\r
80                 }\r
81 \r
82                 // \8f\89\8aú\83f\83B\83\8c\83C\83J\83b\83g\r
83                 OPT("-no-dc"){\r
84                         prm.b_dc = FALSE;\r
85                 }\r
86 \r
87                 // \83f\83B\83\8c\83C\83t\83\8c\81[\83\80\90\94\r
88                 OPT("-df"){\r
89                         if(!value) goto _ERROR_ARG;\r
90                         prm.i_delayFrame = atol(value);\r
91                         i++;\r
92                 }\r
93 \r
94                 // \8fo\97Í\83t\83@\83C\83\8b\96¼\r
95                 OPT("-o"){\r
96                         if(!value || prm.p_outfile) goto _ERROR_ARG;\r
97                         prm.p_outfile = new char[strlen(value) + 1];\r
98                         strcpy(prm.p_outfile, value);\r
99                         i++;\r
100                 }\r
101 \r
102                 // \93ü\97Í\83t\83@\83C\83\8b\r
103                 else if(EXIST(name)){\r
104                         if(prm.p_infile) goto _ERROR_ARG;\r
105                         prm.p_infile = new char[strlen(name) + 1];\r
106                         strcpy(prm.p_infile, name);\r
107                 }\r
108 \r
109                 else {\r
110 _ERROR_ARG:\r
111                         Help();\r
112                         goto _ERROR_RET;\r
113                 }\r
114         }\r
115 \r
116         // \83`\83F\83b\83N\8f\88\97\9d\r
117         if(prm.i_mode == MODE_IN && !EXIST(prm.p_tcfile)){\r
118                 Help();\r
119                 goto _ERROR_RET;\r
120         }\r
121 \r
122         if(!prm.p_outfile){\r
123                 prm.p_outfile = new char[strlen(prm.p_infile) + 20];\r
124                 strcpy(prm.p_outfile, prm.p_infile);\r
125 \r
126                 if(prm.i_mode == MODE_IN)\r
127                         strcat(prm.p_outfile, "_tc_input.mp4");\r
128                 if(prm.i_mode == MODE_OUT)\r
129                         strcat(prm.p_outfile, "_timecode.txt");\r
130         }\r
131 \r
132         // \83\81\83C\83\93\8f\88\97\9d\r
133         EditMain(&prm);\r
134         ret = 0;\r
135 \r
136 _ERROR_RET:\r
137         if(prm.p_tcfile)        delete [] prm.p_tcfile;\r
138         if(prm.p_outfile)       delete [] prm.p_outfile;\r
139         if(prm.p_infile)        delete [] prm.p_infile;\r
140         return ret;\r
141 }\r
142 \r