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
23 #endif /* HAVE_STDINT_H */
25 #include <mjpegtools/yuv4mpeg.h>
27 #include "interlacemodes.h"
29 // AUTO FIX METHOD ====================
31 void ilaceautofixoption_to_text(char *string
, int autofixoption
)
35 case BC_ILACE_AUTOFIXOPTION_AUTO
: strcpy(string
, BC_ILACE_AUTOFIXOPTION_AUTO_T
); break;
36 case BC_ILACE_AUTOFIXOPTION_MANUAL
: strcpy(string
, BC_ILACE_AUTOFIXOPTION_MANUAL_T
); break;
37 default: strcpy(string
, BC_ILACE_UNKNOWN_T
); break;
41 int ilaceautofixoption_from_text(char *text
, int thedefault
)
43 if(!strcasecmp(text
, BC_ILACE_AUTOFIXOPTION_AUTO_T
)) return BC_ILACE_AUTOFIXOPTION_AUTO
;
44 if(!strcasecmp(text
, BC_ILACE_AUTOFIXOPTION_MANUAL_T
)) return BC_ILACE_AUTOFIXOPTION_MANUAL
;
48 // INTERLACE MODE ====================
50 void ilacemode_to_text(char *string
, int ilacemode
)
54 case BC_ILACE_MODE_UNDETECTED
: strcpy(string
, BC_ILACE_MODE_UNDETECTED_T
); break;
55 case BC_ILACE_MODE_TOP_FIRST
: strcpy(string
, BC_ILACE_MODE_TOP_FIRST_T
); break;
56 case BC_ILACE_MODE_BOTTOM_FIRST
: strcpy(string
, BC_ILACE_MODE_BOTTOM_FIRST_T
); break;
57 case BC_ILACE_MODE_NOTINTERLACED
: strcpy(string
, BC_ILACE_MODE_NOTINTERLACED_T
); break;
58 default: strcpy(string
, BC_ILACE_UNKNOWN_T
); break;
62 int ilacemode_from_text(char *text
, int thedefault
)
64 if(!strcasecmp(text
, BC_ILACE_MODE_UNDETECTED_T
)) return BC_ILACE_MODE_UNDETECTED
;
65 if(!strcasecmp(text
, BC_ILACE_MODE_TOP_FIRST_T
)) return BC_ILACE_MODE_TOP_FIRST
;
66 if(!strcasecmp(text
, BC_ILACE_MODE_BOTTOM_FIRST_T
)) return BC_ILACE_MODE_BOTTOM_FIRST
;
67 if(!strcasecmp(text
, BC_ILACE_MODE_NOTINTERLACED_T
)) return BC_ILACE_MODE_NOTINTERLACED
;
71 void ilacemode_to_xmltext(char *string
, int ilacemode
)
75 case BC_ILACE_MODE_UNDETECTED
: strcpy(string
, BC_ILACE_MODE_UNDETECTED_XMLT
); break;
76 case BC_ILACE_MODE_TOP_FIRST
: strcpy(string
, BC_ILACE_MODE_TOP_FIRST_XMLT
); break;
77 case BC_ILACE_MODE_BOTTOM_FIRST
: strcpy(string
, BC_ILACE_MODE_BOTTOM_FIRST_XMLT
); break;
78 case BC_ILACE_MODE_NOTINTERLACED
: strcpy(string
, BC_ILACE_MODE_NOTINTERLACED_XMLT
); break;
79 default: strcpy(string
, BC_ILACE_UNKNOWN_T
); break;
83 int ilacemode_from_xmltext(char *text
, int thedefault
)
85 if(!text
) return thedefault
;
86 if(!strcasecmp(text
, BC_ILACE_MODE_UNDETECTED_XMLT
)) return BC_ILACE_MODE_UNDETECTED
;
87 if(!strcasecmp(text
, BC_ILACE_MODE_TOP_FIRST_XMLT
)) return BC_ILACE_MODE_TOP_FIRST
;
88 if(!strcasecmp(text
, BC_ILACE_MODE_BOTTOM_FIRST_XMLT
)) return BC_ILACE_MODE_BOTTOM_FIRST
;
89 if(!strcasecmp(text
, BC_ILACE_MODE_NOTINTERLACED_XMLT
)) return BC_ILACE_MODE_NOTINTERLACED
;
93 // INTERLACE FIX METHOD ====================
95 void ilacefixmethod_to_text(char *string
, int fixmethod
)
99 case BC_ILACE_FIXMETHOD_NONE
: strcpy(string
, BC_ILACE_FIXMETHOD_NONE_T
); break;
100 case BC_ILACE_FIXMETHOD_UPONE
: strcpy(string
, BC_ILACE_FIXMETHOD_UPONE_T
); break;
101 case BC_ILACE_FIXMETHOD_DOWNONE
: strcpy(string
, BC_ILACE_FIXMETHOD_DOWNONE_T
); break;
102 default: strcpy(string
, BC_ILACE_UNKNOWN_T
); break;
106 int ilacefixmethod_from_text(char *text
, int thedefault
)
108 if(!strcasecmp(text
, BC_ILACE_FIXMETHOD_NONE_T
)) return BC_ILACE_FIXMETHOD_NONE
;
109 if(!strcasecmp(text
, BC_ILACE_FIXMETHOD_UPONE_T
)) return BC_ILACE_FIXMETHOD_UPONE
;
110 if(!strcasecmp(text
, BC_ILACE_FIXMETHOD_DOWNONE_T
)) return BC_ILACE_FIXMETHOD_DOWNONE
;
114 void ilacefixmethod_to_xmltext(char *string
, int fixmethod
)
118 case BC_ILACE_FIXMETHOD_NONE
: strcpy(string
, BC_ILACE_FIXMETHOD_NONE_XMLT
); break;
119 case BC_ILACE_FIXMETHOD_UPONE
: strcpy(string
, BC_ILACE_FIXMETHOD_UPONE_XMLT
); break;
120 case BC_ILACE_FIXMETHOD_DOWNONE
: strcpy(string
, BC_ILACE_FIXMETHOD_DOWNONE_XMLT
); break;
121 default: strcpy(string
, BC_ILACE_UNKNOWN_T
); break;
125 int ilacefixmethod_from_xmltext(char *text
, int thedefault
)
127 if(!strcasecmp(text
, BC_ILACE_FIXMETHOD_NONE_XMLT
)) return BC_ILACE_FIXMETHOD_NONE
;
128 if(!strcasecmp(text
, BC_ILACE_FIXMETHOD_UPONE_XMLT
)) return BC_ILACE_FIXMETHOD_UPONE
;
129 if(!strcasecmp(text
, BC_ILACE_FIXMETHOD_DOWNONE_XMLT
)) return BC_ILACE_FIXMETHOD_DOWNONE
;
133 int ilaceautofixmethod(int projectmode
, int assetmode
)
135 if (projectmode
== assetmode
)
136 return BC_ILACE_FIXMETHOD_NONE
;
139 (projectmode
== BC_ILACE_MODE_BOTTOM_FIRST
&& assetmode
== BC_ILACE_MODE_TOP_FIRST
)
141 (projectmode
== BC_ILACE_MODE_TOP_FIRST
&& assetmode
== BC_ILACE_MODE_BOTTOM_FIRST
)
143 return BC_ILACE_FIXDEFAULT
;
145 // still to implement anything else...
146 return BC_ILACE_FIXMETHOD_NONE
;
149 int ilaceautofixmethod2(int projectilacemode
, int assetautofixoption
, int assetilacemode
, int assetfixmethod
)
151 if (assetautofixoption
== BC_ILACE_AUTOFIXOPTION_AUTO
)
152 return (ilaceautofixmethod(projectilacemode
, assetilacemode
));
154 return (assetfixmethod
);
157 int ilace_bc_to_yuv4mpeg(int ilacemode
)
161 case BC_ILACE_MODE_UNDETECTED
:
164 case BC_ILACE_MODE_TOP_FIRST
:
165 return(Y4M_ILACE_TOP_FIRST
);
167 case BC_ILACE_MODE_BOTTOM_FIRST
:
168 return(Y4M_ILACE_BOTTOM_FIRST
);
170 case BC_ILACE_MODE_NOTINTERLACED
:
171 return(Y4M_ILACE_NONE
);
176 int ilace_yuv4mpeg_to_bc(int ilacemode
)
181 return (BC_ILACE_MODE_UNDETECTED
);
184 return (BC_ILACE_MODE_NOTINTERLACED
);
186 case Y4M_ILACE_TOP_FIRST
:
187 return (BC_ILACE_MODE_TOP_FIRST
);
189 case Y4M_ILACE_BOTTOM_FIRST
:
190 return (BC_ILACE_MODE_BOTTOM_FIRST
);
192 // case Y4M_ILACE_MIXED:
193 // return (BC_ILACE_MODE_UNDETECTED); // fixme!!
196 return (BC_ILACE_MODE_UNDETECTED
);
201 void ilace_yuv4mpeg_mode_to_text(char *string
, int ilacemode
)
205 case Y4M_UNKNOWN
: strcpy(string
, BC_ILACE_Y4M_UKNOWN_T
); break;
206 case Y4M_ILACE_NONE
: strcpy(string
, BC_ILACE_Y4M_NONE_T
); break;
207 case Y4M_ILACE_TOP_FIRST
: strcpy(string
, BC_ILACE_Y4M_TOP_FIRST_T
); break;
208 case Y4M_ILACE_BOTTOM_FIRST
: strcpy(string
, BC_ILACE_Y4M_BOTTOM_FIRST_T
); break;
209 // case Y4M_ILACE_MIXED: strcpy(string, BC_ILACE_Y4M_MIXED_T); break;
211 default: strcpy(string
, BC_ILACE_UNKNOWN_T
); break;