1 /*
2 * Silicon Graphics RLE 8-bit video 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 * Silicon Graphics RLE 8-bit video decoder
25 * @note Data is packed in rbg323 with rle, contained in mv or mov.
26 * The algorithm and pixfmt are subtly different from SGI images.
27 */
28
30
33
35 {
37 return 0;
38 }
39
40 /**
41 * Convert SGI RBG323 pixel into AV_PIX_FMT_BGR8
42 * SGI RGB data is packed as 8bpp, (msb)3R 2B 3G(lsb)
43 */
44 #define RBG323_TO_BGR8(x) ((((x) << 3) & 0xC0) | \
45 (((x) << 3) & 0x38) | \
46 (((x) >> 5) & 7))
49 {
53 }
54
55 /**
56 * @param[out] dst Destination buffer
57 * @param[in] src Source buffer
58 * @param src_size Source buffer size (bytes)
59 * @param width Width of destination buffer (pixels)
60 * @param height Height of destination buffer (pixels)
61 * @param linesize Line size of destination buffer (bytes)
62 *
63 * @return <0 on error
64 */
66 const uint8_t *
src,
int src_size,
68 {
69 const uint8_t *src_end =
src + src_size;
70 int x = 0, y = 0;
71
72 #define INC_XY(n) \
73 x += n; \
74 if (x >= width) { \
75 y++; \
76 if (y >= height) \
77 return 0; \
78 x = 0; \
79 }
80
81 while (src_end -
src >= 2) {
83 if (v > 0 && v < 0xC0) {
84 do {
86 if (length <= 0)
87 break;
90 v -= length;
91 } while (v > 0);
93 } else if (v >= 0xC1) {
94 v -= 0xC0;
95 do {
97 if (src_end -
src < length || length <= 0)
98 break;
102 v -= length;
103 } while (v > 0);
104 } else {
107 }
108 }
109 return 0;
110 }
111
114 {
117
120
125
127 frame->key_frame = 1;
128
129 *got_frame = 1;
130
132 }
133
143 };