1 /*
2 * SGI RLE 8-bit decoder
3 * Copyright (c) 2012 Peter Ross
4 *
5 * This file is part of FFmpeg.
6 *
7 * FFmpeg is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * FFmpeg is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with FFmpeg; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
22 /**
23 * @file
24 * SGI RLE 8-bit decoder
25 */
26
29
33
35 {
41 return 0;
42 }
43
44 /**
45 * Convert SGI RGB332 pixel into AV_PIX_FMT_BGR8
46 * SGI RGB332 is packed RGB 3:3:2, 8bpp, (msb)3R 2B 3G(lsb)
47 */
48 #define RGB332_TO_BGR8(x) (((x << 3) & 0xC0) | ((x << 3) & 0x38) | ((x >> 5) & 7))
49
51 {
52 int i;
53 for (i = 0; i <
size; i++)
55 }
56
57 /**
58 * @param[out] dst Destination buffer
59 * @param[in] src Source buffer
60 * @param src_size Source buffer size (bytes)
61 * @param width Width of destination buffer (pixels)
62 * @param height Height of destination buffer (pixels)
63 * @param linesize Line size of destination buffer (bytes)
64 * @return <0 on error
65 */
67 {
68 const uint8_t *src_end = src + src_size;
70
71 #define INC_XY(n) \
72 x += n; \
73 if (x >= width) { \
74 y++; \
75 if (y >= height) \
76 return 0; \
77 x = 0; \
78 }
79
80 while (src_end - src >= 2) {
82 if (v > 0 && v < 0xC0) {
83 do {
85 if (length <= 0)
86 break;
90 } while (v > 0);
91 src++;
92 } else if (v >= 0xC1) {
93 v -= 0xC0;
94 do {
96 if (src_end - src < length || length <= 0)
97 break;
102 } while (v > 0);
103 } else {
106 }
107 }
108 return 0;
109 }
110
112 void *
data,
int *got_frame,
114 {
117
120
122 if (ret < 0)
124
125 *got_frame = 1;
128
130 }
131
133 {
135
137
138 return 0;
139 }
140
151 };