1 /*
2 * Copyright (c) 1990 James Ashton - Sydney University
3 * Copyright (c) 2012 Stefano Sabatini
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 * X-Face decoder, based on libcompface, by James Ashton.
25 */
26
32
34 {
36 int i;
37
38 /* extract the last byte into r, and shift right b by 8 bits */
40
41 i = 0;
43 pranges++;
44 i++;
45 }
48 return i;
49 }
50
52 {
53 if (w > 3) {
54 w /= 2;
55 h /= 2;
60 } else {
62 if (w & 1) bitmap[0] = 1;
63 if (w & 2) bitmap[1] = 1;
66 }
67 }
68
70 {
73 return;
76 return;
77 default:
78 w /= 2;
79 h /= 2;
80 level++;
84 decode_block(b, bitmap + w + h * XFACE_WIDTH, w, h, level);
85 return;
86 }
87 }
88
92
94 {
98 "Size value %dx%d not supported, only accepts a size of %dx%d\n",
101 }
102 }
103
107
108 return 0;
109 }
110
112 void *
data,
int *got_frame,
114 {
122
125
126 for (i = 0, k = 0; avpkt->
data[i] && i < avpkt->
size; i++) {
128
129 /* ignore invalid digits */
131 continue;
132
135 "Buffer is longer than expected, truncating at byte %d\n", i);
136 break;
137 }
140 }
141
142 /* decode image and put it in bitmap */
154
156
157 /* convert image from 1=black 0=white bitmap to MONOWHITE */
158 buf = frame->
data[0];
159 for (i = 0, j = 0, k = 0, byte = 0; i <
XFACE_PIXELS; i++) {
161 if (k == 7) {
163 byte = k = 0;
164 } else {
165 k++;
166 byte <<= 1;
167 }
169 j = 0;
171 }
172 }
173
174 *got_frame = 1;
175
177 }
178
188 };