annotate libass/ass_utils.c @ 19275:625c00dfd809

don't use vaspect on mpeg1 video streams
author nicodvb
date Mon, 31 Jul 2006 20:07:21 +0000
parents 9dc06456af0f
children 0797e1b4a4be
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
18937
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
1 #include "config.h"
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
2
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
3 #include <stdlib.h>
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
4 #include <stdint.h>
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
5 #include <sys/time.h>
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
6 #include <time.h>
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
7
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
8 #include "mp_msg.h"
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
9 #include "ass_utils.h"
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
10
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
11 int mystrtoi(char** p, int base, int* res)
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
12 {
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
13 char* start = *p;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
14 *res = strtol(*p, p, base);
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
15 if (*p != start) return 1;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
16 else return 0;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
17 }
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
18
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
19 int mystrtou32(char** p, int base, uint32_t* res)
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
20 {
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
21 char* start = *p;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
22 *res = strtoll(*p, p, base);
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
23 if (*p != start) return 1;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
24 else return 0;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
25 }
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
26
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
27 int mystrtod(char** p, double* res)
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
28 {
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
29 char* start = *p;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
30 *res = strtod(*p, p);
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
31 if (*p != start) return 1;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
32 else return 0;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
33 }
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
34
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
35 int strtocolor(char** q, uint32_t* res)
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
36 {
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
37 uint32_t color = 0;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
38 int result;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
39 char* p = *q;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
40
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
41 if (*p == '&') ++p;
19003
9dc06456af0f Support some recently discovered color formats.
eugeni
parents: 18937
diff changeset
42 else mp_msg(MSGT_GLOBAL, MSGL_DBG2, "suspicious color format: \"%s\"\n", p);
18937
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
43
19003
9dc06456af0f Support some recently discovered color formats.
eugeni
parents: 18937
diff changeset
44 if (*p == 'H' || *p == 'h') {
18937
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
45 ++p;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
46 result = mystrtou32(&p, 16, &color);
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
47 } else {
19003
9dc06456af0f Support some recently discovered color formats.
eugeni
parents: 18937
diff changeset
48 result = mystrtou32(&p, 0, &color);
18937
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
49 }
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
50
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
51 {
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
52 unsigned char* tmp = (unsigned char*)(&color);
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
53 unsigned char b;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
54 b = tmp[0]; tmp[0] = tmp[3]; tmp[3] = b;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
55 b = tmp[1]; tmp[1] = tmp[2]; tmp[2] = b;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
56 }
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
57 if (*p == '&') ++p;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
58 *q = p;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
59
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
60 *res = color;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
61 return result;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
62 }
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
63