Mercurial > mplayer.hg
annotate libmpcodecs/vd_sgi.c @ 12182:f18f862c2c19
libmpflac was removed.
author | diego |
---|---|
date | Tue, 13 Apr 2004 00:08:41 +0000 |
parents | 87e03d96a4cd |
children | 8f3099900d8c |
rev | line source |
---|---|
9534
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
1 /* |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
2 * author: Todd Kirby <slapcat@pacbell.net> |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
3 */ |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
4 |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
5 #include <stdio.h> |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
6 #include <stdlib.h> |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
7 |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
8 #include "config.h" |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
9 #include "mp_msg.h" |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
10 #include "bswap.h" |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
11 #include "vd_internal.h" |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
12 |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
13 #define SGI_HEADER_LEN 512 |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
14 #define SGI_MAGIC 474 |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
15 |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
16 #define SGI_GRAYSCALE_IMAGE 1 |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
17 #define SGI_RGB_IMAGE 3 |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
18 #define SGI_RGBA_IMAGE 4 |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
19 |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
20 #define OUT_PIXEL_STRIDE 3 /* RGB */ |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
21 |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
22 |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
23 static vd_info_t info = |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
24 { |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
25 "SGI Image decoder", |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
26 "sgi", |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
27 "Todd Kirby", |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
28 "Todd Kirby", |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
29 "" |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
30 }; |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
31 |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
32 LIBVD_EXTERN(sgi) |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
33 |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
34 typedef struct { |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
35 short magic; |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
36 char rle; |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
37 char bytes_per_channel; |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
38 unsigned short dimension; |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
39 unsigned short xsize; |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
40 unsigned short ysize; |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
41 unsigned short zsize; |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
42 } SGIInfo; |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
43 |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
44 static unsigned int outfmt = IMGFMT_BGR24; |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
45 |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
46 static unsigned short last_x = -1; |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
47 static unsigned short last_y = -1; |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
48 |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
49 |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
50 /* to set/get/query special features/parameters */ |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
51 static int |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
52 control(sh_video_t* sh, int cmd, void *arg, ...) |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
53 { |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
54 switch (cmd) |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
55 { |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
56 case VDCTRL_QUERY_FORMAT: |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
57 if (*((unsigned int *) arg) == outfmt) { |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
58 return CONTROL_TRUE; |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
59 } |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
60 return CONTROL_FALSE; |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
61 } |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
62 return CONTROL_UNKNOWN; |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
63 } |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
64 |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
65 |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
66 /* init driver */ |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
67 static int |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
68 init(sh_video_t *sh) |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
69 { |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
70 sh->context = (SGIInfo *) calloc(1, sizeof(SGIInfo)); |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
71 last_x = -1; |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
72 |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
73 return 1; |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
74 } |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
75 |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
76 |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
77 /* uninit driver */ |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
78 static void |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
79 uninit(sh_video_t *sh) |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
80 { |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
81 SGIInfo *info = sh->context; |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
82 free(info); |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
83 } |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
84 |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
85 |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
86 /* expand an rle row into a channel */ |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
87 static void |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
88 expandrow(unsigned char *optr, unsigned char *iptr, int chan_offset) |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
89 { |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
90 unsigned char pixel, count; |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
91 optr += chan_offset; |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
92 |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
93 while (1) { |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
94 pixel = *iptr++; |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
95 |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
96 if (!(count = (pixel & 0x7f))) { |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
97 return; |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
98 } |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
99 if(pixel & 0x80) { |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
100 while (count--) { |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
101 *optr = *iptr; |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
102 optr += OUT_PIXEL_STRIDE; |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
103 iptr++; |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
104 } |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
105 } else { |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
106 pixel = *iptr++; |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
107 |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
108 while (count--) { |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
109 *optr = pixel; |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
110 optr += OUT_PIXEL_STRIDE; |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
111 } |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
112 } |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
113 } |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
114 } |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
115 |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
116 |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
117 /* expand an rle row into all 3 channels. |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
118 a separate function for grayscale so we don't slow down the |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
119 more common case rgb function with a bunch of ifs. */ |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
120 static void |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
121 expandrow_gs(unsigned char *optr, unsigned char *iptr) |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
122 { |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
123 unsigned char pixel, count; |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
124 |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
125 while (1) { |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
126 pixel = *iptr++; |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
127 |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
128 if (!(count = (pixel & 0x7f))) { |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
129 return; |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
130 } |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
131 if(pixel & 0x80) { |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
132 while (count--) { |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
133 optr[0] = *iptr; |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
134 optr[1] = *iptr; |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
135 optr[2] = *iptr; |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
136 optr += OUT_PIXEL_STRIDE; |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
137 iptr++; |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
138 } |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
139 } else { |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
140 pixel = *iptr++; |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
141 |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
142 while (count--) { |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
143 optr[0] = pixel; |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
144 optr[1] = pixel; |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
145 optr[2] = pixel; |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
146 optr += OUT_PIXEL_STRIDE; |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
147 } |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
148 } |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
149 } |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
150 } |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
151 |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
152 |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
153 /* decode a run length encoded sgi image */ |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
154 static void |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
155 decode_rle_sgi(SGIInfo *info, unsigned char *data, mp_image_t *mpi) |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
156 { |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
157 unsigned char *rle_data, *dest_row; |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
158 unsigned long *starttab; |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
159 int y, z, xsize, ysize, zsize, chan_offset; |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
160 long start_offset; |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
161 |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
162 xsize = info->xsize; |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
163 ysize = info->ysize; |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
164 zsize = info->zsize; |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
165 |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
166 /* rle offset table is right after the header */ |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
167 starttab = (long*)(data + SGI_HEADER_LEN); |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
168 |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
169 for (z = 0; z < zsize; z++) { |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
170 |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
171 /* set chan_offset so RGB ends up BGR */ |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
172 chan_offset = (zsize - 1) - z; |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
173 |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
174 /* The origin for SGI images is the lower-left corner |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
175 so read scan lines from bottom to top */ |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
176 for (y = ysize - 1; y >= 0; y--) { |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
177 dest_row = mpi->planes[0] + mpi->stride[0] * (ysize - 1 - y); |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
178 |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
179 /* set start of next run (offsets are from start of header) */ |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
180 start_offset = be2me_32(*(unsigned long*) &starttab[y + z * ysize]); |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
181 |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
182 rle_data = &data[start_offset]; |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
183 |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
184 if(info->zsize == SGI_GRAYSCALE_IMAGE) { |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
185 expandrow_gs(dest_row, rle_data); |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
186 } else { |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
187 expandrow(dest_row, rle_data, chan_offset); |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
188 } |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
189 } |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
190 } |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
191 } |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
192 |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
193 |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
194 /* decode an sgi image */ |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
195 static void |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
196 decode_uncompressed_sgi(SGIInfo *info, unsigned char *data, mp_image_t *mpi) |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
197 { |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
198 unsigned char *src_row, *dest_row; |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
199 int x, y, z, xsize, ysize, zsize, chan_offset; |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
200 |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
201 xsize = info->xsize; |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
202 ysize = info->ysize; |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
203 zsize = info->zsize; |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
204 |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
205 /* skip header */ |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
206 data += SGI_HEADER_LEN; |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
207 |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
208 for (z = 0; z < zsize; z++) { |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
209 |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
210 /* set row ptr to start of current plane */ |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
211 src_row = data + (xsize * ysize * z); |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
212 |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
213 /* set chan_offset for RGB -> BGR */ |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
214 chan_offset = (zsize - 1) - z; |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
215 |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
216 /* the origin for SGI images is the lower-left corner |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
217 so read scan lines from bottom to top. */ |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
218 for (y = ysize - 1; y >= 0; y--) { |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
219 dest_row = mpi->planes[0] + mpi->stride[0] * y; |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
220 for (x = 0; x < xsize; x++) { |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
221 |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
222 /* we only do 24 bit output so promote 8 bit pixels to 24 */ |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
223 if (zsize == SGI_GRAYSCALE_IMAGE) { |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
224 /* write greyscale value into all channels */ |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
225 dest_row[0] = src_row[x]; |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
226 dest_row[1] = src_row[x]; |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
227 dest_row[2] = src_row[x]; |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
228 } else { |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
229 dest_row[chan_offset] = src_row[x]; |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
230 } |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
231 |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
232 dest_row += OUT_PIXEL_STRIDE; |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
233 } |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
234 |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
235 /* move to next row of the current source plane */ |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
236 src_row += xsize; |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
237 } |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
238 } |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
239 } |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
240 |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
241 |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
242 /* read sgi header fields */ |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
243 static void |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
244 read_sgi_header(unsigned char *buf, SGIInfo *info) |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
245 { |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
246 /* sgi data is always stored in big endian byte order */ |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
247 info->magic = be2me_16(*(unsigned short *) &buf[0]); |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
248 info->rle = buf[2]; |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
249 info->bytes_per_channel = buf[3]; |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
250 info->dimension = be2me_16(*(unsigned short *) &buf[4]); |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
251 info->xsize = be2me_16(*(unsigned short *) &buf[6]); |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
252 info->ysize = be2me_16(*(unsigned short *) &buf[8]); |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
253 info->zsize = be2me_16(*(unsigned short *) &buf[10]); |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
254 } |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
255 |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
256 |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
257 /* decode a frame */ |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
258 static |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
259 mp_image_t *decode(sh_video_t *sh, void *raw, int len, int flags) |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
260 { |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
261 SGIInfo *info = sh->context; |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
262 unsigned char *data = raw; |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
263 mp_image_t *mpi; |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
264 |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
265 if (len <= 0) { |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
266 return NULL; /* skip frame */ |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
267 } |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
268 |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
269 read_sgi_header(data, info); |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
270 |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
271 /* make sure this is an SGI image file */ |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
272 if (info->magic != SGI_MAGIC) { |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
273 mp_msg(MSGT_DECVIDEO, MSGL_INFO, "Bad magic number in image.\n"); |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
274 return NULL; |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
275 } |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
276 |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
277 /* check image depth */ |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
278 if (info->bytes_per_channel != 1) { |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
279 mp_msg(MSGT_DECVIDEO, MSGL_INFO, |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
280 "Unsupported bytes per channel value %i.\n", info->bytes_per_channel); |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
281 return NULL; |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
282 } |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
283 |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
284 /* check image dimension */ |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
285 if (info->dimension != 2 && info->dimension != 3) { |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
286 mp_msg(MSGT_DECVIDEO, MSGL_INFO, "Unsupported image dimension %i.\n", |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
287 info->dimension); |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
288 return NULL; |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
289 } |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
290 |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
291 /* change rgba images to rgb so alpha channel will be ignored */ |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
292 if (info->zsize == SGI_RGBA_IMAGE) { |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
293 info->zsize = SGI_RGB_IMAGE; |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
294 } |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
295 |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
296 /* check image depth */ |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
297 if (info->zsize != SGI_RGB_IMAGE && info->zsize != SGI_GRAYSCALE_IMAGE) { |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
298 mp_msg(MSGT_DECVIDEO, MSGL_INFO, "Unsupported image depth.\n"); |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
299 return NULL; |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
300 } |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
301 |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
302 /* (re)init libvo if image size is changed */ |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
303 if (last_x != info->xsize || last_y != info->ysize) |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
304 { |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
305 last_x = info->xsize; |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
306 last_y = info->ysize; |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
307 |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
308 if (!mpcodecs_config_vo(sh, info->xsize, info->ysize, outfmt)) { |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
309 mp_msg(MSGT_DECVIDEO, MSGL_INFO, "Config vo failed:\n"); |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
310 return NULL; |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
311 } |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
312 } |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
313 |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
314 if (!(mpi = mpcodecs_get_image(sh, MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE, |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
315 info->xsize, info->ysize))) { |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
316 return NULL; |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
317 } |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
318 |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
319 if (info->rle) { |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
320 decode_rle_sgi(info, data, mpi); |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
321 } else { |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
322 decode_uncompressed_sgi(info, data, mpi); |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
323 } |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
324 |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
325 return mpi; |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
326 } |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
327 |