1 /*
2 * Intel Indeo 2 codec
3 * Copyright (c) 2005 Konstantin Shishkov
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 * Intel Indeo 2 decoder.
25 */
26
27 #define BITSTREAM_READER_LE
34
41
42 #define CODE_VLC_BITS 14
44
45 /* Indeo 2 codes are in range 0x01..0x7F and 0x81..0x90 */
47 {
49 }
50
53 {
54 int i;
55 int j;
58 int t;
59
60 if (width & 1)
62
63 /* first line contain absolute values, other lines contain deltas */
64 while (out < width) {
66 if (c >= 0x80) { /* we have a run */
67 c -= 0x7F;
68 if (out + c*2 > width)
70 for (i = 0; i < c * 2; i++)
71 dst[out++] = 0x80;
72 } else { /* copy two values from table */
73 dst[out++] = table[c * 2];
74 dst[out++] = table[(c * 2) + 1];
75 }
76 }
77 dst += pitch;
78
79 for (j = 1; j <
height; j++) {
80 out = 0;
81 while (out < width) {
83 if (c >= 0x80) { /* we have a skip */
84 c -= 0x7F;
85 if (out + c*2 > width)
87 for (i = 0; i < c * 2; i++) {
88 dst[
out] = dst[out - pitch];
89 out++;
90 }
91 } else { /* add two deltas from table */
92 t = dst[out - pitch] + (table[c * 2] - 128);
93 t = av_clip_uint8(t);
95 out++;
96 t = dst[out - pitch] + (table[(c * 2) + 1] - 128);
97 t = av_clip_uint8(t);
99 out++;
100 }
101 }
102 dst += pitch;
103 }
104 return 0;
105 }
106
109 {
110 int j;
113 int t;
114
115 if (width & 1)
117
118 for (j = 0; j <
height; j++) {
119 out = 0;
120 while (out < width) {
122 if (c >= 0x80) { /* we have a skip */
123 c -= 0x7F;
124 out += c * 2;
125 } else { /* add two deltas from table */
126 t = dst[
out] + (((table[c * 2] - 128)*3) >> 2);
127 t = av_clip_uint8(t);
129 out++;
130 t = dst[
out] + (((table[(c * 2) + 1] - 128)*3) >> 2);
131 t = av_clip_uint8(t);
133 out++;
134 }
135 }
136 dst += pitch;
137 }
138 return 0;
139 }
140
142 void *
data,
int *got_frame,
144 {
147 int buf_size = avpkt->
size;
151
154
155 start = 48; /* hardcoded for now */
156
157 if (start >= buf_size) {
160 }
161
163
164 /* decide whether frame uses deltas or not */
165 #ifndef BITSTREAM_READER_LE
166 for (i = 0; i < buf_size; i++)
168 #endif
169
171
177
178 /* swapped U and V */
187 } else { /* interframe */
192 /* swapped U and V */
201 }
202
205
206 *got_frame = 1;
207
208 return buf_size;
209 }
210
212 {
215
217
219
223
226 #ifdef BITSTREAM_READER_LE
230 #else
234 #endif
235
236 return 0;
237 }
238
240 {
242
244
245 return 0;
246 }
247
258 };