1 /*
2 * Bitmap Brothers JV video decoder
3 * Copyright (c) 2011 Peter Ross <pross@xvid.org>
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 * Bitmap Brothers JV video decoder
25 * @author Peter Ross <pross@xvid.org>
26 */
27
29
34
41
43 {
45
49
52 return 0;
53 }
54
55 /**
56 * Decode 2x2 block
57 */
59 {
61
63 case 1:
65 for (j = 0; j < 2; j++)
66 memset(dst + j * linesize, v[0], 2);
67 break;
68 case 2:
71 for (j = 0; j < 2; j++)
72 for (i = 0; i < 2; i++)
74 break;
75 case 3:
76 for (j = 0; j < 2; j++)
77 for (i = 0; i < 2; i++)
78 dst[j * linesize + i] =
get_bits(gb, 8);
79 }
80 }
81
82 /**
83 * Decode 4x4 block
84 */
86 {
88
90 case 1:
92 for (j = 0; j < 4; j++)
93 memset(dst + j * linesize, v[0], 4);
94 break;
95 case 2:
98 for (j = 2; j >= 0; j -= 2) {
99 for (i = 0; i < 4; i++)
100 dst[j * linesize + i] = v[
get_bits1(gb)];
101 for (i = 0; i < 4; i++)
102 dst[(j + 1) * linesize + i] = v[
get_bits1(gb)];
103 }
104 break;
105 case 3:
106 for (j = 0; j < 4; j += 2)
107 for (i = 0; i < 4; i += 2)
108 decode2x2(gb, dst + j * linesize + i, linesize);
109 }
110 }
111
112 /**
113 * Decode 8x8 block
114 */
117 {
119
121 case 1:
124 break;
125 case 2:
128 for (j = 7; j >= 0; j--)
129 for (i = 0; i < 8; i++)
130 dst[j * linesize + i] = v[
get_bits1(gb)];
131 break;
132 case 3:
133 for (j = 0; j < 8; j += 4)
134 for (i = 0; i < 8; i += 4)
135 decode4x4(gb, dst + j * linesize + i, linesize);
136 }
137 }
138
141 {
145 int video_size, video_type, i, j,
ret;
146
149
151 video_type = buf[4];
152 buf += 5;
153
154 if (video_size) {
155 if (video_size < 0 || video_size > avpkt->
size - 5) {
158 }
161
162 if (video_type == 0 || video_type == 1) {
165
166 for (j = 0; j < avctx->
height; j += 8)
167 for (i = 0; i < avctx->
width; i += 8)
171
172 buf += video_size;
173 } else if (video_type == 2) {
175 for (j = 0; j < avctx->
height; j++)
178 } else {
180 "unsupported frame type %i\n", video_type);
182 }
183 }
184
188 s->
palette[i] = 0xFFU << 24 | pal << 2 | ((pal >> 4) & 0x30303);
189 buf += 3;
190 }
192 }
193
194 if (video_size) {
200
203 *got_frame = 1;
204 }
205
207 }
208
210 {
212
214
215 return 0;
216 }
217
228 };