Mercurial > mplayer.hg
annotate libmpcodecs/vd_sgi.c @ 33971:922771be85f6
Cosmetic: Rename fntRender() fntTextRender().
author | ib |
---|---|
date | Mon, 05 Sep 2011 16:19:04 +0000 |
parents | d6367dc367b9 |
children |
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 /* |
30421
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
29263
diff
changeset
|
2 * Copyright (c) 2003 Todd Kirby <slapcat@pacbell.net> |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
29263
diff
changeset
|
3 * |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
29263
diff
changeset
|
4 * This file is part of MPlayer. |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
29263
diff
changeset
|
5 * |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
29263
diff
changeset
|
6 * MPlayer is free software; you can redistribute it and/or modify |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
29263
diff
changeset
|
7 * it under the terms of the GNU General Public License as published by |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
29263
diff
changeset
|
8 * the Free Software Foundation; either version 2 of the License, or |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
29263
diff
changeset
|
9 * (at your option) any later version. |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
29263
diff
changeset
|
10 * |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
29263
diff
changeset
|
11 * MPlayer is distributed in the hope that it will be useful, |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
29263
diff
changeset
|
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
29263
diff
changeset
|
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
29263
diff
changeset
|
14 * GNU General Public License for more details. |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
29263
diff
changeset
|
15 * |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
29263
diff
changeset
|
16 * You should have received a copy of the GNU General Public License along |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
29263
diff
changeset
|
17 * with MPlayer; if not, write to the Free Software Foundation, Inc., |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
29263
diff
changeset
|
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
9534
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 |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
21 #include <stdio.h> |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
22 #include <stdlib.h> |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
23 |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
24 #include "config.h" |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
25 #include "mp_msg.h" |
31614
b40d593a463f
Use AV_RL* macros instead of typecasts where appropriate.
reimar
parents:
30702
diff
changeset
|
26 #include "libavutil/intreadwrite.h" |
21507
fa99b3d31d13
Hack around libavutil/bswap.h compilation problems due to always_inline undefined.
reimar
parents:
21372
diff
changeset
|
27 #include "mpbswap.h" |
9534
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
28 #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
|
29 |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
30 #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
|
31 #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
|
32 |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
33 #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
|
34 #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
|
35 #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
|
36 |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
37 #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
|
38 |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
39 |
30504
cc27da5d7286
Mark all ad_info_t/vd_info_t structure declarations as const.
diego
parents:
30421
diff
changeset
|
40 static const vd_info_t info = |
9534
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
41 { |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
42 "SGI Image decoder", |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
43 "sgi", |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
44 "Todd Kirby", |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
45 "Todd Kirby", |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
46 "" |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
47 }; |
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 LIBVD_EXTERN(sgi) |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
50 |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
51 typedef struct { |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
52 short magic; |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
53 char rle; |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
54 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
|
55 unsigned short dimension; |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
56 unsigned short xsize; |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
57 unsigned short ysize; |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
58 unsigned short zsize; |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
59 } SGIInfo; |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
60 |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
61 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
|
62 |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
63 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
|
64 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
|
65 |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
66 |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
67 /* 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
|
68 static int |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
69 control(sh_video_t* sh, int cmd, void *arg, ...) |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
21507
diff
changeset
|
70 { |
9534
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
71 switch (cmd) |
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 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
|
74 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
|
75 return CONTROL_TRUE; |
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 return CONTROL_FALSE; |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
78 } |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
79 return CONTROL_UNKNOWN; |
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 |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
82 |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
83 /* init driver */ |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
84 static int |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
85 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
|
86 { |
30702 | 87 sh->context = calloc(1, sizeof(SGIInfo)); |
9534
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
88 last_x = -1; |
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 return 1; |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
91 } |
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 |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
94 /* uninit driver */ |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
95 static void |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
96 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
|
97 { |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
98 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
|
99 free(info); |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
100 } |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
101 |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
102 |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
103 /* 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
|
104 static void |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
105 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
|
106 { |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
107 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
|
108 optr += chan_offset; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
21507
diff
changeset
|
109 |
9534
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
110 while (1) { |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
111 pixel = *iptr++; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
21507
diff
changeset
|
112 |
9534
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
113 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
|
114 return; |
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 if(pixel & 0x80) { |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
117 while (count--) { |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
118 *optr = *iptr; |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
119 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
|
120 iptr++; |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
121 } |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
122 } else { |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
123 pixel = *iptr++; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
21507
diff
changeset
|
124 |
9534
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
125 while (count--) { |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
126 *optr = pixel; |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
127 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
|
128 } |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
129 } |
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 } |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
132 |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
133 |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
134 /* expand an rle row into all 3 channels. |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
21507
diff
changeset
|
135 a separate function for grayscale so we don't slow down the |
9534
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
136 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
|
137 static void |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
138 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
|
139 { |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
140 unsigned char pixel, count; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
21507
diff
changeset
|
141 |
9534
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
142 while (1) { |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
143 pixel = *iptr++; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
21507
diff
changeset
|
144 |
9534
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
145 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
|
146 return; |
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 if(pixel & 0x80) { |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
149 while (count--) { |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
150 optr[0] = *iptr; |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
151 optr[1] = *iptr; |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
152 optr[2] = *iptr; |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
153 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
|
154 iptr++; |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
155 } |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
156 } else { |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
157 pixel = *iptr++; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
21507
diff
changeset
|
158 |
9534
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
159 while (count--) { |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
160 optr[0] = pixel; |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
161 optr[1] = pixel; |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
162 optr[2] = pixel; |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
163 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
|
164 } |
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 } |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
167 } |
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 |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
170 /* 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
|
171 static void |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
172 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
|
173 { |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
174 unsigned char *rle_data, *dest_row; |
18856
8f3099900d8c
correct handling of sgi compressed images on amd64, patch by Paul-Francois Fontigny - pff AT filmik-be
reynaldo
parents:
9534
diff
changeset
|
175 uint32_t *starttab; |
33329 | 176 int y, z, ysize, zsize, chan_offset; |
9534
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
177 long start_offset; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
21507
diff
changeset
|
178 |
9534
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
179 ysize = info->ysize; |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
180 zsize = info->zsize; |
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 offset table is right after the header */ |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
21507
diff
changeset
|
183 starttab = (uint32_t*)(data + SGI_HEADER_LEN); |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
21507
diff
changeset
|
184 |
9534
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
185 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
|
186 |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
187 /* 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
|
188 chan_offset = (zsize - 1) - z; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
21507
diff
changeset
|
189 |
9534
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
190 /* 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
|
191 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
|
192 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
|
193 dest_row = mpi->planes[0] + mpi->stride[0] * (ysize - 1 - y); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
21507
diff
changeset
|
194 |
9534
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
195 /* set start of next run (offsets are from start of header) */ |
31614
b40d593a463f
Use AV_RL* macros instead of typecasts where appropriate.
reimar
parents:
30702
diff
changeset
|
196 start_offset = AV_RB32(&starttab[y + z * ysize]); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
21507
diff
changeset
|
197 |
9534
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
198 rle_data = &data[start_offset]; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
21507
diff
changeset
|
199 |
9534
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
200 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
|
201 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
|
202 } else { |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
203 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
|
204 } |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
205 } |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
206 } |
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 |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
21507
diff
changeset
|
209 |
9534
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
210 /* 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
|
211 static void |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
212 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
|
213 { |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
214 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
|
215 int x, y, z, xsize, ysize, zsize, chan_offset; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
21507
diff
changeset
|
216 |
9534
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
217 xsize = info->xsize; |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
218 ysize = info->ysize; |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
219 zsize = info->zsize; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
21507
diff
changeset
|
220 |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
21507
diff
changeset
|
221 /* skip header */ |
9534
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
222 data += SGI_HEADER_LEN; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
21507
diff
changeset
|
223 |
9534
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
224 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
|
225 |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
226 /* 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
|
227 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
|
228 |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
229 /* 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
|
230 chan_offset = (zsize - 1) - z; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
21507
diff
changeset
|
231 |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
21507
diff
changeset
|
232 /* the origin for SGI images is the lower-left corner |
9534
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
233 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
|
234 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
|
235 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
|
236 for (x = 0; x < xsize; x++) { |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
21507
diff
changeset
|
237 |
9534
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
238 /* 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
|
239 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
|
240 /* 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
|
241 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
|
242 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
|
243 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
|
244 } else { |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
245 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
|
246 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
21507
diff
changeset
|
247 |
9534
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
248 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
|
249 } |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
250 |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
251 /* 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
|
252 src_row += xsize; |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
253 } |
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 |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
258 /* 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
|
259 static void |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
260 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
|
261 { |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
262 /* sgi data is always stored in big endian byte order */ |
31614
b40d593a463f
Use AV_RL* macros instead of typecasts where appropriate.
reimar
parents:
30702
diff
changeset
|
263 info->magic = AV_RB16(&buf[0]); |
9534
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
264 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
|
265 info->bytes_per_channel = buf[3]; |
31614
b40d593a463f
Use AV_RL* macros instead of typecasts where appropriate.
reimar
parents:
30702
diff
changeset
|
266 info->dimension = AV_RB16(&buf[4]); |
b40d593a463f
Use AV_RL* macros instead of typecasts where appropriate.
reimar
parents:
30702
diff
changeset
|
267 info->xsize = AV_RB16(&buf[6]); |
b40d593a463f
Use AV_RL* macros instead of typecasts where appropriate.
reimar
parents:
30702
diff
changeset
|
268 info->ysize = AV_RB16(&buf[8]); |
b40d593a463f
Use AV_RL* macros instead of typecasts where appropriate.
reimar
parents:
30702
diff
changeset
|
269 info->zsize = AV_RB16(&buf[10]); |
9534
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 |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
272 |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
273 /* decode a frame */ |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
274 static |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
275 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
|
276 { |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
277 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
|
278 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
|
279 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
|
280 |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
281 if (len <= 0) { |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
282 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
|
283 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
21507
diff
changeset
|
284 |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
21507
diff
changeset
|
285 read_sgi_header(data, info); |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
21507
diff
changeset
|
286 |
9534
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
287 /* 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
|
288 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
|
289 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
|
290 return NULL; |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
291 } |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
292 |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
293 /* check image depth */ |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
294 if (info->bytes_per_channel != 1) { |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
21507
diff
changeset
|
295 mp_msg(MSGT_DECVIDEO, MSGL_INFO, |
9534
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
296 "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
|
297 return NULL; |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
298 } |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
299 |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
300 /* check image dimension */ |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
301 if (info->dimension != 2 && info->dimension != 3) { |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
21507
diff
changeset
|
302 mp_msg(MSGT_DECVIDEO, MSGL_INFO, "Unsupported image dimension %i.\n", |
9534
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
303 info->dimension); |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
304 return NULL; |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
305 } |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
306 |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
21507
diff
changeset
|
307 /* change rgba images to rgb so alpha channel will be ignored */ |
9534
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
308 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
|
309 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
|
310 } |
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 /* check image depth */ |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
313 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
|
314 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
|
315 return NULL; |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
316 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
21507
diff
changeset
|
317 |
9534
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
318 /* (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
|
319 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
|
320 { |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
321 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
|
322 last_y = info->ysize; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
21507
diff
changeset
|
323 |
9534
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
324 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
|
325 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
|
326 return NULL; |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
327 } |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
328 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
21507
diff
changeset
|
329 |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
21507
diff
changeset
|
330 if (!(mpi = mpcodecs_get_image(sh, MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE, |
9534
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
331 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
|
332 return NULL; |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
333 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
21507
diff
changeset
|
334 |
9534
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
335 if (info->rle) { |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
336 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
|
337 } else { |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
338 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
|
339 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
21507
diff
changeset
|
340 |
9534
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
341 return mpi; |
87e03d96a4cd
add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff
changeset
|
342 } |