2 * This library is free software; you can redistribute it and/or modify it
3 * under the terms of the GNU Lesser General Public License as published
4 * by the Free Software Foundation; either version 2 of the License, or
5 * (at your option) any later version.
7 * This library is distributed in the hope that it will be useful, but
8 * WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10 * Lesser General Public License for more details.
12 * You should have received a copy of the GNU Lesser General Public
13 * License along with this library; if not, write to the Free Software
14 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
24 #endif /* HAVE_STDINT_H */
26 #include "mjpegtools/yuv4mpeg.h"
27 #include "interlacemodes.h"
29 // AUTO FIX METHOD ====================
31 void ilaceautofixoption_to_text(char *string, int autofixoption)
34 switch(autofixoption) {
35 case ILACE_AUTOFIXOPTION_AUTO: cp = ILACE_AUTOFIXOPTION_AUTO_T; break;
36 case ILACE_AUTOFIXOPTION_MANUAL: cp = ILACE_AUTOFIXOPTION_MANUAL_T; break;
37 default: cp = ILACE_UNKNOWN_T; break;
39 strcpy(string, _(cp));
42 int ilaceautofixoption_from_text(const char *text, int thedefault)
44 if(!strcasecmp(text, _(ILACE_AUTOFIXOPTION_AUTO_T))) return ILACE_AUTOFIXOPTION_AUTO;
45 if(!strcasecmp(text, _(ILACE_AUTOFIXOPTION_MANUAL_T))) return ILACE_AUTOFIXOPTION_MANUAL;
49 // INTERLACE MODE ====================
51 void ilacemode_to_text(char *string, int ilacemode)
55 case ILACE_MODE_UNDETECTED: cp = ILACE_MODE_UNDETECTED_T; break;
56 case ILACE_MODE_TOP_FIRST: cp = ILACE_MODE_TOP_FIRST_T; break;
57 case ILACE_MODE_BOTTOM_FIRST: cp = ILACE_MODE_BOTTOM_FIRST_T; break;
58 case ILACE_MODE_NOTINTERLACED: cp = ILACE_MODE_NOTINTERLACED_T; break;
59 default: cp = ILACE_UNKNOWN_T; break;
61 strcpy(string, _(cp));
64 int ilacemode_from_text(const char *text, int thedefault)
66 if(!strcasecmp(text, _(ILACE_MODE_UNDETECTED_T))) return ILACE_MODE_UNDETECTED;
67 if(!strcasecmp(text, _(ILACE_MODE_TOP_FIRST_T))) return ILACE_MODE_TOP_FIRST;
68 if(!strcasecmp(text, _(ILACE_MODE_BOTTOM_FIRST_T))) return ILACE_MODE_BOTTOM_FIRST;
69 if(!strcasecmp(text, _(ILACE_MODE_NOTINTERLACED_T))) return ILACE_MODE_NOTINTERLACED;
73 void ilacemode_to_xmltext(char *string, int ilacemode)
76 case ILACE_MODE_UNDETECTED: strcpy(string, ILACE_MODE_UNDETECTED_XMLT); return;
77 case ILACE_MODE_TOP_FIRST: strcpy(string, ILACE_MODE_TOP_FIRST_XMLT); return;
78 case ILACE_MODE_BOTTOM_FIRST: strcpy(string, ILACE_MODE_BOTTOM_FIRST_XMLT); return;
79 case ILACE_MODE_NOTINTERLACED: strcpy(string, ILACE_MODE_NOTINTERLACED_XMLT); return;
81 strcpy(string, ILACE_UNKNOWN_T);
84 int ilacemode_from_xmltext(const char *text, int thedefault)
87 if(!strcasecmp(text, ILACE_MODE_UNDETECTED_XMLT)) return ILACE_MODE_UNDETECTED;
88 if(!strcasecmp(text, ILACE_MODE_TOP_FIRST_XMLT)) return ILACE_MODE_TOP_FIRST;
89 if(!strcasecmp(text, ILACE_MODE_BOTTOM_FIRST_XMLT)) return ILACE_MODE_BOTTOM_FIRST;
90 if(!strcasecmp(text, ILACE_MODE_NOTINTERLACED_XMLT)) return ILACE_MODE_NOTINTERLACED;
95 // INTERLACE FIX METHOD ====================
97 void ilacefixmethod_to_text(char *string, int fixmethod)
101 case ILACE_FIXMETHOD_NONE: cp = ILACE_FIXMETHOD_NONE_T; break;
102 case ILACE_FIXMETHOD_UPONE: cp = ILACE_FIXMETHOD_UPONE_T; break;
103 case ILACE_FIXMETHOD_DOWNONE: cp = ILACE_FIXMETHOD_DOWNONE_T; break;
104 default: cp = ILACE_UNKNOWN_T; break;
106 strcpy(string, _(cp));
109 int ilacefixmethod_from_text(const char *text, int thedefault)
111 if(!strcasecmp(text, _(ILACE_FIXMETHOD_NONE_T))) return ILACE_FIXMETHOD_NONE;
112 if(!strcasecmp(text, _(ILACE_FIXMETHOD_UPONE_T))) return ILACE_FIXMETHOD_UPONE;
113 if(!strcasecmp(text, _(ILACE_FIXMETHOD_DOWNONE_T))) return ILACE_FIXMETHOD_DOWNONE;
117 void ilacefixmethod_to_xmltext(char *string, int fixmethod)
120 case ILACE_FIXMETHOD_NONE: strcpy(string, ILACE_FIXMETHOD_NONE_XMLT); return;
121 case ILACE_FIXMETHOD_UPONE: strcpy(string, ILACE_FIXMETHOD_UPONE_XMLT); return;
122 case ILACE_FIXMETHOD_DOWNONE: strcpy(string, ILACE_FIXMETHOD_DOWNONE_XMLT); return;
124 strcpy(string, ILACE_UNKNOWN_T);
127 int ilacefixmethod_from_xmltext(const char *text, int thedefault)
129 if(!strcasecmp(text, ILACE_FIXMETHOD_NONE_XMLT)) return ILACE_FIXMETHOD_NONE;
130 if(!strcasecmp(text, ILACE_FIXMETHOD_UPONE_XMLT)) return ILACE_FIXMETHOD_UPONE;
131 if(!strcasecmp(text, ILACE_FIXMETHOD_DOWNONE_XMLT)) return ILACE_FIXMETHOD_DOWNONE;
135 int ilaceautofixmethod(int projectmode, int assetmode)
137 if (projectmode == assetmode)
138 return ILACE_FIXMETHOD_NONE;
139 if( (projectmode == ILACE_MODE_BOTTOM_FIRST && assetmode == ILACE_MODE_TOP_FIRST ) ||
140 (projectmode == ILACE_MODE_TOP_FIRST && assetmode == ILACE_MODE_BOTTOM_FIRST) )
141 return ILACE_FIXDEFAULT;
142 // still to implement anything else...
143 return ILACE_FIXMETHOD_NONE;
146 int ilaceautofixmethod2(int projectilacemode, int assetautofixoption, int assetilacemode, int assetfixmethod)
148 if (assetautofixoption == ILACE_AUTOFIXOPTION_AUTO)
149 return (ilaceautofixmethod(projectilacemode, assetilacemode));
150 return (assetfixmethod);
153 int ilace_bc_to_yuv4mpeg(int ilacemode)
156 case ILACE_MODE_UNDETECTED: return(Y4M_UNKNOWN);
157 case ILACE_MODE_TOP_FIRST: return(Y4M_ILACE_TOP_FIRST);
158 case ILACE_MODE_BOTTOM_FIRST: return(Y4M_ILACE_BOTTOM_FIRST);
159 case ILACE_MODE_NOTINTERLACED: return(Y4M_ILACE_NONE);
164 int ilace_yuv4mpeg_to_bc(int ilacemode)
167 case Y4M_UNKNOWN: return (ILACE_MODE_UNDETECTED);
168 case Y4M_ILACE_NONE: return (ILACE_MODE_NOTINTERLACED);
169 case Y4M_ILACE_TOP_FIRST: return (ILACE_MODE_TOP_FIRST);
170 case Y4M_ILACE_BOTTOM_FIRST: return (ILACE_MODE_BOTTOM_FIRST);
171 // case Y4M_ILACE_MIXED: return (ILACE_MODE_UNDETECTED); // fixme!!
173 return (ILACE_MODE_UNDETECTED);
177 void ilace_yuv4mpeg_mode_to_text(char *string, int ilacemode)
181 case Y4M_UNKNOWN: cp = ILACE_Y4M_UKNOWN_T; break;
182 case Y4M_ILACE_NONE: cp = ILACE_Y4M_NONE_T; break;
183 case Y4M_ILACE_TOP_FIRST: cp = ILACE_Y4M_TOP_FIRST_T; break;
184 case Y4M_ILACE_BOTTOM_FIRST: cp = ILACE_Y4M_BOTTOM_FIRST_T; break;
185 // case Y4M_ILACE_MIXED: cp = ILACE_Y4M_MIXED_T; break;
186 default: cp = ILACE_UNKNOWN_T; break;
188 strcpy(string, _(cp));