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
33
40
42 {
47 return 0;
48 }
49
50 /**
51 * Decode 2x2 block
52 */
54 {
56
58 case 1:
60 for (j = 0; j < 2; j++)
61 memset(dst + j*linesize, v[0], 2);
62 break;
63 case 2:
66 for (j = 0; j < 2; j++)
67 for (i = 0; i < 2; i++)
69 break;
70 case 3:
71 for (j = 0; j < 2; j++)
72 for (i = 0; i < 2; i++)
73 dst[j*linesize + i] =
get_bits(gb, 8);
74 }
75 }
76
77 /**
78 * Decode 4x4 block
79 */
81 {
83
85 case 1:
87 for (j = 0; j < 4; j++)
88 memset(dst + j*linesize, v[0], 4);
89 break;
90 case 2:
93 for (j = 2; j >= 0; j -= 2) {
94 for (i = 0; i < 4; i++)
96 for (i = 0; i < 4; i++)
97 dst[(j+1)*linesize + i] = v[
get_bits1(gb)];
98 }
99 break;
100 case 3:
101 for (j = 0; j < 4; j += 2)
102 for (i = 0; i < 4; i += 2)
103 decode2x2(gb, dst + j*linesize + i, linesize);
104 }
105 }
106
107 /**
108 * Decode 8x8 block
109 */
111 {
113
115 case 1:
118 break;
119 case 2:
122 for (j = 7; j >= 0; j--)
123 for (i = 0; i < 8; i++)
125 break;
126 case 3:
127 for (j = 0; j < 8; j += 4)
128 for (i = 0; i < 8; i += 4)
129 decode4x4(gb, dst + j*linesize + i, linesize);
130 }
131 }
132
134 void *
data,
int *got_frame,
136 {
141
144
146 video_type = buf[4];
147 buf += 5;
148
149 if (video_size) {
150 if (video_size < 0 || video_size > avpkt->
size - 5) {
153 }
156
157 if (video_type == 0 || video_type == 1) {
160
161 for (j = 0; j < avctx->
height; j += 8)
162 for (i = 0; i < avctx->
width; i += 8)
165
167 } else if (video_type == 2) {
169 for (j = 0; j < avctx->
height; j++)
171 } else {
174 }
175 }
176
180 s->
palette[i] = 0xFFU << 24 | pal << 2 | ((pal >> 4) & 0x30303);
181 buf += 3;
182 }
184 }
185
186 if (video_size) {
192
195 *got_frame = 1;
196 }
197
199 }
200
202 {
204
206
207 return 0;
208 }
209
220 };