annotate libmpcodecs/vd_sgi.c @ 28921:62f0032e736a

Get rid of pointless preprocessor condition indirection and use ARCH_X86 directly instead of CAN_COMPILE_X86_ASM.
author diego
date Sun, 15 Mar 2009 10:01:02 +0000
parents fa99b3d31d13
children 0f1b5b68af32
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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"
21372
1767c271d710 Remove bswap.h, use libavutil/bswap.h instead.
diego
parents: 18856
diff changeset
10 #include "libavutil/common.h"
21507
fa99b3d31d13 Hack around libavutil/bswap.h compilation problems due to always_inline undefined.
reimar
parents: 21372
diff changeset
11 #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
12 #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
13
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
14 #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
15 #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
16
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
17 #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
18 #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
19 #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
20
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
21 #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
22
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 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
25 {
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
26 "SGI Image decoder",
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
27 "sgi",
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 "Todd Kirby",
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
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
33 LIBVD_EXTERN(sgi)
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
34
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
35 typedef struct {
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
36 short magic;
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
37 char rle;
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
38 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
39 unsigned short dimension;
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
40 unsigned short xsize;
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
41 unsigned short ysize;
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
42 unsigned short zsize;
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
43 } SGIInfo;
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
44
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
45 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
46
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_x = -1;
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
48 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
49
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 /* 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
52 static int
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
53 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
54 {
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
55 switch (cmd)
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
56 {
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
57 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
58 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
59 return CONTROL_TRUE;
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 return CONTROL_FALSE;
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 return CONTROL_UNKNOWN;
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
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
67 /* init driver */
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 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
70 {
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
71 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
72 last_x = -1;
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
73
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
74 return 1;
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
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
78 /* uninit driver */
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
79 static void
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
80 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
81 {
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
82 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
83 free(info);
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
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
87 /* 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
88 static void
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
89 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
90 {
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
91 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
92 optr += chan_offset;
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 while (1) {
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
95 pixel = *iptr++;
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
96
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
97 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
98 return;
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
99 }
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
100 if(pixel & 0x80) {
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
101 while (count--) {
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
102 *optr = *iptr;
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
103 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
104 iptr++;
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
105 }
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
106 } else {
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
107 pixel = *iptr++;
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
108
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
109 while (count--) {
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
110 *optr = pixel;
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
111 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
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
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
118 /* 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
119 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
120 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
121 static void
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
122 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
123 {
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
124 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
125
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
126 while (1) {
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
127 pixel = *iptr++;
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 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
130 return;
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 if(pixel & 0x80) {
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
133 while (count--) {
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
134 optr[0] = *iptr;
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
135 optr[1] = *iptr;
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
136 optr[2] = *iptr;
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
137 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
138 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 } else {
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
141 pixel = *iptr++;
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
142
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
143 while (count--) {
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
144 optr[0] = pixel;
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
145 optr[1] = pixel;
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
146 optr[2] = pixel;
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
147 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
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
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
154 /* 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
155 static void
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
156 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
157 {
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
158 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
159 uint32_t *starttab;
9534
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
160 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
161 long start_offset;
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
162
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
163 xsize = info->xsize;
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
164 ysize = info->ysize;
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
165 zsize = info->zsize;
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 /* rle offset table is right after the header */
18856
8f3099900d8c correct handling of sgi compressed images on amd64, patch by Paul-Francois Fontigny - pff AT filmik-be
reynaldo
parents: 9534
diff changeset
168 starttab = (uint32_t*)(data + SGI_HEADER_LEN);
9534
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 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
171
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
172 /* 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
173 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
174
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
175 /* 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
176 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
177 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
178 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
179
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
180 /* set start of next run (offsets are from start of header) */
18856
8f3099900d8c correct handling of sgi compressed images on amd64, patch by Paul-Francois Fontigny - pff AT filmik-be
reynaldo
parents: 9534
diff changeset
181 start_offset = be2me_32(*(uint32_t*) &starttab[y + z * ysize]);
9534
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
182
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
183 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
184
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
185 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
186 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
187 } else {
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
188 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
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
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
195 /* 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
196 static void
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
197 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
198 {
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
199 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
200 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
201
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
202 xsize = info->xsize;
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
203 ysize = info->ysize;
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
204 zsize = info->zsize;
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 /* skip header */
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
207 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
208
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
209 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
210
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
211 /* 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
212 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
213
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
214 /* 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
215 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
216
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
217 /* 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
218 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
219 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
220 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
221 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
222
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
223 /* 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
224 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
225 /* 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
226 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
227 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
228 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
229 } else {
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
230 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
231 }
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
232
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
233 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
234 }
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
235
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
236 /* 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
237 src_row += xsize;
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
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
243 /* 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
244 static void
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
245 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
246 {
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
247 /* 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
248 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
249 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
250 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
251 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
252 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
253 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
254 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
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 /* decode a frame */
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
259 static
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
260 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
261 {
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
262 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
263 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
264 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
265
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
266 if (len <= 0) {
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
267 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
268 }
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
269
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
270 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
271
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
272 /* 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
273 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
274 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
275 return NULL;
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
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
278 /* check image depth */
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
279 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
280 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
281 "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
282 return NULL;
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
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
285 /* check image dimension */
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
286 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
287 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
288 info->dimension);
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
289 return NULL;
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
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
292 /* 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
293 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
294 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
295 }
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
296
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
297 /* check image depth */
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
298 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
299 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
300 return NULL;
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
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
303 /* (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
304 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
305 {
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
306 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
307 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
308
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
309 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
310 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
311 return NULL;
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
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
315 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
316 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
317 return NULL;
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
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
320 if (info->rle) {
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
321 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
322 } else {
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
323 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
324 }
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
325
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
326 return mpi;
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