add x10tv ati remote rework, android remote rework, wintv remote tweaks
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / interlacemodes.C
1 /*
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.
6  *
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.
11  *
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
15  * USA
16  */
17
18 #include <stdlib.h>
19 #include <stdint.h>
20 #include <string.h>
21
22 #ifndef HAVE_STDINT_H
23 #define HAVE_STDINT_H
24 #endif /* HAVE_STDINT_H */
25
26 #define Y4M_UNKNOWN -1
27 #define Y4M_ILACE_NONE          0   /* non-interlaced, progressive frame */
28 #define Y4M_ILACE_TOP_FIRST     1   /* interlaced, top-field first       */
29 #define Y4M_ILACE_BOTTOM_FIRST  2   /* interlaced, bottom-field first    */
30 #define Y4M_ILACE_MIXED         3   /* mixed, "refer to frame header"    */
31
32 #include "interlacemodes.h"
33
34 void ilacemode_to_text(char *string, int ilacemode)
35 {
36         const char *cp = 0;
37         switch(ilacemode) {
38         case ILACE_MODE_UNDETECTED:     cp = ILACE_MODE_UNDETECTED_T;      break;
39         case ILACE_MODE_TOP_FIRST:      cp = ILACE_MODE_TOP_FIRST_T;       break;
40         case ILACE_MODE_BOTTOM_FIRST:   cp = ILACE_MODE_BOTTOM_FIRST_T;    break;
41         case ILACE_MODE_NOTINTERLACED:  cp = ILACE_MODE_NOTINTERLACED_T;   break;
42         default: cp = ILACE_UNKNOWN_T;  break;
43         }
44         strcpy(string, _(cp));
45 }
46
47 int ilacemode_from_text(const char *text, int thedefault)
48 {
49         if(!strcasecmp(text, _(ILACE_MODE_UNDETECTED_T)))     return ILACE_MODE_UNDETECTED;
50         if(!strcasecmp(text, _(ILACE_MODE_TOP_FIRST_T)))      return ILACE_MODE_TOP_FIRST;
51         if(!strcasecmp(text, _(ILACE_MODE_BOTTOM_FIRST_T)))   return ILACE_MODE_BOTTOM_FIRST;
52         if(!strcasecmp(text, _(ILACE_MODE_NOTINTERLACED_T)))  return ILACE_MODE_NOTINTERLACED;
53         return thedefault;
54 }
55
56 void ilacemode_to_xmltext(char *string, int ilacemode)
57 {
58         switch(ilacemode) {
59         case ILACE_MODE_UNDETECTED:     strcpy(string, ILACE_MODE_UNDETECTED_XMLT);      return;
60         case ILACE_MODE_TOP_FIRST:      strcpy(string, ILACE_MODE_TOP_FIRST_XMLT);       return;
61         case ILACE_MODE_BOTTOM_FIRST:   strcpy(string, ILACE_MODE_BOTTOM_FIRST_XMLT);    return;
62         case ILACE_MODE_NOTINTERLACED:  strcpy(string, ILACE_MODE_NOTINTERLACED_XMLT);   return;
63         }
64         strcpy(string, ILACE_UNKNOWN_T);
65 }
66
67 int ilacemode_from_xmltext(const char *text, int thedefault)
68 {
69         if( text ) {
70                 if(!strcasecmp(text, ILACE_MODE_UNDETECTED_XMLT))     return ILACE_MODE_UNDETECTED;
71                 if(!strcasecmp(text, ILACE_MODE_TOP_FIRST_XMLT))      return ILACE_MODE_TOP_FIRST;
72                 if(!strcasecmp(text, ILACE_MODE_BOTTOM_FIRST_XMLT))   return ILACE_MODE_BOTTOM_FIRST;
73                 if(!strcasecmp(text, ILACE_MODE_NOTINTERLACED_XMLT))  return ILACE_MODE_NOTINTERLACED;
74         }
75         return thedefault;
76 }
77