1 /*
2 * Brute Force & Ignorance (BFI) video decoder
3 * Copyright (c) 2008 Sisir Koppaka
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 * @brief Brute Force & Ignorance (.bfi) video decoder
25 * @author Sisir Koppaka ( sisir.koppaka at gmail dot com )
26 * @see http://wiki.multimedia.cx/index.php?title=BFI
27 */
28
34
39
41 {
47 return 0;
48 }
49
52 {
54 int buf_size = avpkt->
size;
57 uint8_t *
src, *dst_offset, colour1, colour2;
59 uint32_t *pal;
61
64
66
67 /* Set frame parameters and palette, if necessary */
71 /* Setting the palette */
75 }
76 pal = (uint32_t *)
frame->data[1];
80 for (j = 0; j < 3; j++,
shift -= 8)
83 pal++;
84 }
86 } else {
90 }
91
93
95 static const uint8_t lentab[4] = { 0, 2, 0, 1 };
97 unsigned int code =
byte >> 6;
98 unsigned int length = byte & ~0xC0;
99
102 "Input resolution larger than actual frame.\n");
104 }
105
106 /* Get length and offset (if required) */
107 if (length == 0) {
109 length = bytestream2_get_byte(&
g);
110 offset = bytestream2_get_le16(&
g);
111 } else {
112 length = bytestream2_get_le16(&
g);
113 if (
code == 2 && length == 0)
114 break;
115 }
116 } else {
118 offset = bytestream2_get_byte(&
g);
119 }
120
121 /* Do boundary check */
123 break;
124
126 case 0: // normal chain
130 }
133 break;
134 case 1: // back chain
136 length *= 4; // Convert dwords to bytes.
137 if (dst_offset < bfi->
dst)
138 break;
139 while (length--)
140 *
dst++ = *dst_offset++;
141 break;
142 case 2: // skip chain
144 break;
145 case 3: // fill chain
146 colour1 = bytestream2_get_byte(&
g);
147 colour2 = bytestream2_get_byte(&
g);
148 while (length--) {
151 }
152 break;
153 }
154 }
155
162 }
163 *got_frame = 1;
164
165 return buf_size;
166 }
167
169 {
172 return 0;
173 }
174
185 };