Added gst-plugins-base-subtitles0.10-0.10.34 for Meego Harmattan 1.2
[mafwsubrenderer] / gst-plugins-base-subtitles0.10 / gst-libs / gst / tag / gsttageditingprivate.c
1 /* GStreamer
2  * Copyright (C) 2010 Thiago Santos <thiago.sousa.santos@collabora.co.uk>
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */
19
20 #include "gsttageditingprivate.h"
21
22 #include <string.h>
23
24 gint
25 __exif_tag_image_orientation_to_exif_value (const gchar * str)
26 {
27   if (str == NULL)
28     goto end;
29
30   if (strcmp (str, "rotate-0") == 0)
31     return 1;
32   else if (strcmp (str, "flip-rotate-0") == 0)
33     return 2;
34   else if (strcmp (str, "rotate-180") == 0)
35     return 3;
36   else if (strcmp (str, "flip-rotate-180") == 0)
37     return 4;
38   else if (strcmp (str, "flip-rotate-270") == 0)
39     return 5;
40   else if (strcmp (str, "rotate-90") == 0)
41     return 6;
42   else if (strcmp (str, "flip-rotate-90") == 0)
43     return 7;
44   else if (strcmp (str, "rotate-270") == 0)
45     return 8;
46
47 end:
48   GST_WARNING ("Invalid image orientation tag: %s", str);
49   return -1;
50 }
51
52 const gchar *
53 __exif_tag_image_orientation_from_exif_value (gint value)
54 {
55   switch (value) {
56     case 1:
57       return "rotate-0";
58     case 2:
59       return "flip-rotate-0";
60     case 3:
61       return "rotate-180";
62     case 4:
63       return "flip-rotate-180";
64     case 5:
65       return "flip-rotate-270";
66     case 6:
67       return "rotate-90";
68     case 7:
69       return "flip-rotate-90";
70     case 8:
71       return "rotate-270";
72     default:
73       GST_WARNING ("Invalid tiff orientation tag value: %d", value);
74       return NULL;
75   }
76 }
77
78 gint
79 __exif_tag_capturing_exposure_program_to_exif_value (const gchar * str)
80 {
81   if (str == NULL)
82     goto end;
83
84   if (strcmp (str, "undefined") == 0)
85     return 0;
86   else if (strcmp (str, "manual") == 0)
87     return 1;
88   else if (strcmp (str, "normal") == 0)
89     return 2;
90   else if (strcmp (str, "aperture-priority") == 0)
91     return 3;
92   else if (strcmp (str, "shutter-priority") == 0)
93     return 4;
94   else if (strcmp (str, "creative") == 0)
95     return 5;
96   else if (strcmp (str, "action") == 0)
97     return 6;
98   else if (strcmp (str, "portrait") == 0)
99     return 7;
100   else if (strcmp (str, "landscape") == 0)
101     return 8;
102
103 end:
104   GST_WARNING ("Invalid capturing exposure program tag: %s", str);
105   return -1;
106 }
107
108 const gchar *
109 __exif_tag_capturing_exposure_program_from_exif_value (gint value)
110 {
111   switch (value) {
112     case 0:
113       return "undefined";
114     case 1:
115       return "manual";
116     case 2:
117       return "normal";
118     case 3:
119       return "aperture-priority";
120     case 4:
121       return "shutter-priority";
122     case 5:
123       return "creative";
124     case 6:
125       return "action";
126     case 7:
127       return "portrait";
128     case 8:
129       return "landscape";
130     default:
131       GST_WARNING ("Invalid exif exposure program: %d", value);
132       return NULL;
133   }
134 }
135
136 gint
137 __exif_tag_capturing_exposure_mode_to_exif_value (const gchar * str)
138 {
139   if (str == NULL)
140     goto end;
141
142   if (strcmp (str, "auto-exposure") == 0)
143     return 0;
144   else if (strcmp (str, "manual-exposure") == 0)
145     return 1;
146   else if (strcmp (str, "auto-bracket") == 0)
147     return 2;
148
149 end:
150   GST_WARNING ("Invalid capturing exposure mode tag: %s", str);
151   return -1;
152 }
153
154 const gchar *
155 __exif_tag_capturing_exposure_mode_from_exif_value (gint value)
156 {
157   switch (value) {
158     case 0:
159       return "auto-exposure";
160     case 1:
161       return "manual-exposure";
162     case 2:
163       return "auto-bracket";
164     default:
165       GST_WARNING ("Invalid exif exposure mode: %d", value);
166       return NULL;
167   }
168 }
169
170 gint
171 __exif_tag_capturing_scene_capture_type_to_exif_value (const gchar * str)
172 {
173   if (str == NULL)
174     goto end;
175
176   if (strcmp (str, "standard") == 0)
177     return 0;
178   else if (strcmp (str, "landscape") == 0)
179     return 1;
180   else if (strcmp (str, "portrait") == 0)
181     return 2;
182   else if (strcmp (str, "night-scene") == 0)
183     return 3;
184
185 end:
186   GST_WARNING ("Invalid capturing scene capture type: %s", str);
187   return -1;
188 }
189
190 const gchar *
191 __exif_tag_capturing_scene_capture_type_from_exif_value (gint value)
192 {
193   switch (value) {
194     case 0:
195       return "standard";
196     case 1:
197       return "landscape";
198     case 2:
199       return "portrait";
200     case 3:
201       return "night-scene";
202     default:
203       GST_WARNING ("Invalid exif scene capture type: %d", value);
204       return NULL;
205   }
206 }
207
208 gint
209 __exif_tag_capturing_gain_adjustment_to_exif_value (const gchar * str)
210 {
211   if (str == NULL)
212     goto end;
213
214   if (strcmp (str, "none") == 0)
215     return 0;
216   else if (strcmp (str, "low-gain-up") == 0)
217     return 1;
218   else if (strcmp (str, "high-gain-up") == 0)
219     return 2;
220   else if (strcmp (str, "low-gain-down") == 0)
221     return 3;
222   else if (strcmp (str, "high-gain-down") == 0)
223     return 4;
224
225 end:
226   GST_WARNING ("Invalid capturing gain adjustment type: %s", str);
227   return -1;
228 }
229
230 const gchar *
231 __exif_tag_capturing_gain_adjustment_from_exif_value (gint value)
232 {
233   switch (value) {
234     case 0:
235       return "none";
236     case 1:
237       return "low-gain-up";
238     case 2:
239       return "high-gain-up";
240     case 3:
241       return "low-gain-down";
242     case 4:
243       return "high-gain-down";
244     default:
245       GST_WARNING ("Invalid exif gain control type: %d", value);
246       return NULL;
247   }
248 }
249
250 gint
251 __exif_tag_capturing_white_balance_to_exif_value (const gchar * str)
252 {
253   if (str == NULL)
254     goto end;
255
256   if (strcmp (str, "auto") == 0)
257     return 0;
258   else                          /* everything else is just manual */
259     return 1;
260
261 end:
262   GST_WARNING ("Invalid white balance: %s", str);
263   return -1;
264 }
265
266 const gchar *
267 __exif_tag_capturing_white_balance_from_exif_value (gint value)
268 {
269   switch (value) {
270     case 0:
271       return "auto";
272     case 1:
273       return "manual";
274     default:
275       GST_WARNING ("Invalid white balance type: %d", value);
276       return NULL;
277   }
278 }
279
280 static gint
281 __exif_tag_capturing_contrast_sharpness_to_exif_value (const gchar * str,
282     const gchar * tag_name)
283 {
284   if (str == NULL)
285     goto end;
286
287   if (strcmp (str, "normal") == 0)
288     return 0;
289   else if (strcmp (str, "soft") == 0)
290     return 1;
291   else if (strcmp (str, "hard") == 0)
292     return 2;
293
294 end:
295   GST_WARNING ("Invalid %s type: %s", tag_name, str);
296   return -1;
297 }
298
299 static const gchar *
300 __exif_tag_capturing_contrast_sharpness_from_exif_value (gint value,
301     const gchar * tag_name)
302 {
303   switch (value) {
304     case 0:
305       return "normal";
306     case 1:
307       return "soft";
308     case 2:
309       return "hard";
310     default:
311       GST_WARNING ("Invalid %s type: %d", tag_name, value);
312       return NULL;
313   }
314 }
315
316 gint
317 __exif_tag_capturing_contrast_to_exif_value (const gchar * str)
318 {
319   return __exif_tag_capturing_contrast_sharpness_to_exif_value (str,
320       "contrast");
321 }
322
323 const gchar *
324 __exif_tag_capturing_contrast_from_exif_value (gint value)
325 {
326   return __exif_tag_capturing_contrast_sharpness_from_exif_value (value,
327       "contrast");
328 }
329
330 gint
331 __exif_tag_capturing_saturation_to_exif_value (const gchar * str)
332 {
333   if (str == NULL)
334     goto end;
335
336   if (strcmp (str, "normal") == 0)
337     return 0;
338   else if (strcmp (str, "low-saturation") == 0)
339     return 1;
340   else if (strcmp (str, "high-saturation") == 0)
341     return 2;
342
343 end:
344   GST_WARNING ("Invalid saturation type: %s", str);
345   return -1;
346 }
347
348 const gchar *
349 __exif_tag_capturing_saturation_from_exif_value (gint value)
350 {
351   switch (value) {
352     case 0:
353       return "normal";
354     case 1:
355       return "low-saturation";
356     case 2:
357       return "high-saturation";
358     default:
359       GST_WARNING ("Invalid saturation type: %d", value);
360       return NULL;
361   }
362 }
363
364 gint
365 __exif_tag_capturing_sharpness_to_exif_value (const gchar * str)
366 {
367   return __exif_tag_capturing_contrast_sharpness_to_exif_value (str,
368       "sharpness");
369 }
370
371 const gchar *
372 __exif_tag_capturing_sharpness_from_exif_value (gint value)
373 {
374   return __exif_tag_capturing_contrast_sharpness_from_exif_value (value,
375       "sharpness");
376 }
377
378 gint
379 __exif_tag_capturing_metering_mode_to_exif_value (const gchar * str)
380 {
381   if (str == NULL)
382     goto end;
383
384   if (strcmp (str, "unknown") == 0)
385     return 0;
386   else if (strcmp (str, "average") == 0)
387     return 1;
388   else if (strcmp (str, "center-weighted-average") == 0)
389     return 2;
390   else if (strcmp (str, "spot") == 0)
391     return 3;
392   else if (strcmp (str, "multi-spot") == 0)
393     return 4;
394   else if (strcmp (str, "pattern") == 0)
395     return 5;
396   else if (strcmp (str, "partial") == 0)
397     return 6;
398   else if (strcmp (str, "other") == 0)
399     return 255;
400
401 end:
402   GST_WARNING ("Invalid metering mode type: %s", str);
403   return -1;
404 }
405
406 const gchar *
407 __exif_tag_capturing_metering_mode_from_exif_value (gint value)
408 {
409   switch (value) {
410     case 0:
411       return "unknown";
412     case 1:
413       return "average";
414     case 2:
415       return "center-weighted-average";
416     case 3:
417       return "spot";
418     case 4:
419       return "multi-spot";
420     case 5:
421       return "pattern";
422     case 6:
423       return "partial";
424     case 255:
425       return "other";
426     default:
427       GST_WARNING ("Invalid metering mode type: %d", value);
428       return NULL;
429   }
430 }
431
432 gint
433 __exif_tag_capturing_source_to_exif_value (const gchar * str)
434 {
435   if (str == NULL)
436     goto end;
437
438   if (strcmp (str, "dsc") == 0)
439     return 3;
440   else if (strcmp (str, "other") == 0)
441     return 0;
442   else if (strcmp (str, "transparent-scanner") == 0)
443     return 1;
444   else if (strcmp (str, "reflex-scanner") == 0)
445     return 2;
446
447 end:
448   GST_WARNING ("Invalid capturing source type: %s", str);
449   return -1;
450 }
451
452 const gchar *
453 __exif_tag_capturing_source_from_exif_value (gint value)
454 {
455   switch (value) {
456     case 0:
457       return "other";
458     case 1:
459       return "transparent-scanner";
460     case 2:
461       return "reflex-scanner";
462     case 3:
463       return "dsc";
464     default:
465       GST_WARNING ("Invalid capturing source type: %d", value);
466       return NULL;
467   }
468 }