comparison codec-cfg.c @ 1305:0a8237e28ce0

Use FOURCC macro to encode fcc values. Avoids accessing 32-bit data from unaligned memory locations and improves portability
author jkeil
date Thu, 12 Jul 2001 15:10:06 +0000
parents 200c03672178
children 3db173705860
comparison
equal deleted inserted replaced
1304:ecb834719dc9 1305:0a8237e28ce0
13 #include <errno.h> 13 #include <errno.h>
14 #include <ctype.h> 14 #include <ctype.h>
15 #include <assert.h> 15 #include <assert.h>
16 #include <string.h> 16 #include <string.h>
17 17
18 #include "loader.h" // loader+avifmt for mmioFOURCC
19 #include "wine/avifmt.h"
20
18 #include "libvo/img_format.h" 21 #include "libvo/img_format.h"
19 #include "codec-cfg.h" 22 #include "codec-cfg.h"
20 23
21 #define PRINT_LINENUM printf(" at line %d\n", line_num) 24 #define PRINT_LINENUM printf(" at line %d\n", line_num)
22 25
32 35
33 static int add_to_fourcc(char *s, char *alias, unsigned int *fourcc, 36 static int add_to_fourcc(char *s, char *alias, unsigned int *fourcc,
34 unsigned int *map) 37 unsigned int *map)
35 { 38 {
36 int i, j, freeslots; 39 int i, j, freeslots;
37 char **aliasp; 40 char *aliasp;
38 unsigned int tmp; 41 unsigned int tmp;
39 42
40 /* find first unused slot */ 43 /* find first unused slot */
41 for (i = 0; i < CODECS_MAX_FOURCC && fourcc[i] != 0xffffffff; i++) 44 for (i = 0; i < CODECS_MAX_FOURCC && fourcc[i] != 0xffffffff; i++)
42 /* NOTHING */; 45 /* NOTHING */;
43 freeslots = CODECS_MAX_FOURCC - i; 46 freeslots = CODECS_MAX_FOURCC - i;
44 if (!freeslots) 47 if (!freeslots)
45 goto err_out_too_many; 48 goto err_out_too_many;
46 49
47 aliasp = (alias) ? &alias : &s; 50 aliasp = (alias) ? alias : s;
48 do { 51 do {
49 tmp = *((unsigned int *) s); 52 tmp = mmioFOURCC(s[0], s[1], s[2], s[3]);
50 for (j = 0; j < i; j++) 53 for (j = 0; j < i; j++)
51 if (tmp == fourcc[j]) 54 if (tmp == fourcc[j])
52 goto err_out_duplicated; 55 goto err_out_duplicated;
53 fourcc[i] = tmp; 56 fourcc[i] = tmp;
54 map[i] = *((unsigned int *) (*aliasp)); 57 map[i] = mmioFOURCC(aliasp[0], aliasp[1], aliasp[2], aliasp[3]);
55 s += 4; 58 s += 4;
56 i++; 59 i++;
57 } while ((*(s++) == ',') && --freeslots); 60 } while ((*(s++) == ',') && --freeslots);
58 61
59 if (!freeslots) 62 if (!freeslots)