annotate libmpcodecs/vd_sgi.c @ 30526:68e260df472b

Just use goto instead of reimplementing it badly with a do { } while (0) and break.
author reimar
date Sun, 14 Feb 2010 11:17:12 +0000
parents cc27da5d7286
children 32725ca88fed
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 /*
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"
21372
1767c271d710 Remove bswap.h, use libavutil/bswap.h instead.
diego
parents: 18856
diff changeset
26 #include "libavutil/common.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 {
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
87 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
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;
9534
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
176 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
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 xsize = info->xsize;
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
180 ysize = info->ysize;
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
181 zsize = info->zsize;
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 offset table is right after the header */
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 21507
diff changeset
184 starttab = (uint32_t*)(data + SGI_HEADER_LEN);
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 21507
diff changeset
185
9534
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
186 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
187
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
188 /* 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
189 chan_offset = (zsize - 1) - z;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 21507
diff changeset
190
9534
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
191 /* 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
192 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
193 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
194 dest_row = mpi->planes[0] + mpi->stride[0] * (ysize - 1 - y);
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 21507
diff changeset
195
9534
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
196 /* 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
197 start_offset = be2me_32(*(uint32_t*) &starttab[y + z * ysize]);
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 21507
diff changeset
198
9534
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
199 rle_data = &data[start_offset];
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 21507
diff changeset
200
9534
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
201 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
202 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
203 } else {
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
204 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
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 }
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
209
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 21507
diff changeset
210
9534
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
211 /* 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
212 static void
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
213 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
214 {
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
215 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
216 int x, y, z, xsize, ysize, zsize, chan_offset;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 21507
diff changeset
217
9534
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
218 xsize = info->xsize;
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
219 ysize = info->ysize;
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
220 zsize = info->zsize;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 21507
diff changeset
221
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 21507
diff changeset
222 /* skip header */
9534
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
223 data += SGI_HEADER_LEN;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 21507
diff changeset
224
9534
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
225 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
226
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
227 /* 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
228 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
229
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
230 /* 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
231 chan_offset = (zsize - 1) - z;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 21507
diff changeset
232
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 21507
diff changeset
233 /* 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
234 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
235 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
236 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
237 for (x = 0; x < xsize; x++) {
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 21507
diff changeset
238
9534
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
239 /* 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
240 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
241 /* 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
242 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
243 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
244 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
245 } else {
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
246 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
247 }
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 21507
diff changeset
248
9534
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
249 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
250 }
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
251
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
252 /* 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
253 src_row += xsize;
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
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
259 /* 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
260 static void
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
261 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
262 {
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
263 /* sgi data is always stored in big endian byte order */
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 21507
diff changeset
264 info->magic = be2me_16(*(unsigned short *) &buf[0]);
9534
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
265 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
266 info->bytes_per_channel = buf[3];
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 21507
diff changeset
267 info->dimension = be2me_16(*(unsigned short *) &buf[4]);
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 21507
diff changeset
268 info->xsize = be2me_16(*(unsigned short *) &buf[6]);
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 21507
diff changeset
269 info->ysize = be2me_16(*(unsigned short *) &buf[8]);
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 21507
diff changeset
270 info->zsize = be2me_16(*(unsigned short *) &buf[10]);
9534
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
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
274 /* decode a frame */
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
275 static
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
276 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
277 {
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
278 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
279 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
280 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
281
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
282 if (len <= 0) {
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
283 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
284 }
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 21507
diff changeset
285
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 21507
diff changeset
286 read_sgi_header(data, info);
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 21507
diff changeset
287
9534
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
288 /* 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
289 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
290 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
291 return NULL;
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
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
294 /* check image depth */
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
295 if (info->bytes_per_channel != 1) {
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 21507
diff changeset
296 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
297 "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
298 return NULL;
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
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
301 /* check image dimension */
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
302 if (info->dimension != 2 && info->dimension != 3) {
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 21507
diff changeset
303 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
304 info->dimension);
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
305 return NULL;
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
306 }
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
307
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 21507
diff changeset
308 /* 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
309 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
310 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
311 }
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
312
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
313 /* check image depth */
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
314 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
315 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
316 return NULL;
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
317 }
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 21507
diff changeset
318
9534
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
319 /* (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
320 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
321 {
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
322 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
323 last_y = info->ysize;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 21507
diff changeset
324
9534
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
325 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
326 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
327 return NULL;
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
328 }
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
329 }
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 21507
diff changeset
330
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 21507
diff changeset
331 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
332 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
333 return NULL;
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
334 }
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 21507
diff changeset
335
9534
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
336 if (info->rle) {
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
337 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
338 } else {
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
339 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
340 }
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 21507
diff changeset
341
9534
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
342 return mpi;
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
343 }
87e03d96a4cd add support for sgi files to mencoder patch by (Todd Kirby <slapcat at pacbell dot net>)
michael
parents:
diff changeset
344