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 encoder, based on libcompface, by James Ashton.
25 */
26
32
39
41 {
43 int x;
44
47 row = bitmap;
49 while (x--)
51 return 0;
53 }
54 return 1;
55 }
56
58 {
65 } else {
66 /* at least one pixel in the 2x2 grid is non-zero */
67 return *bitmap || *(bitmap + 1) ||
69 }
70 }
71
73 {
75 }
76
81
83 {
85 return -1;
87 return 0;
88 }
89
91 {
99 } else {
101 *bitmap +
102 2 * *(bitmap + 1) +
106 }
107 }
108
110 {
116 } else {
125 }
126 }
127
129 {
131
135 }
136
139 {
144 int i, j, k,
ret = 0;
145 const uint8_t *buf;
146 uint8_t *p;
148
152 "Size value %dx%d not supported, only accepts a size of %dx%d\n",
155 }
156 }
159
160 /* convert image from MONOWHITE to 1=black 0=white bitmap */
161 buf =
frame->data[0];
163 do {
164 for (k = 0; k < 8; k++)
165 xface->
bitmap[
i++] = (buf[j]>>(7-k))&1;
167 buf +=
frame->linesize[0];
168 j = 0;
169 }
171
172 /* create a copy of bitmap */
175
185
188
189 /* write the inverted big integer in b to intbuf */
197 }
198
201
202 /* revert the number, and close the buffer */
206 *(p++) = '\n';
207 *(p++) = 0;
208
209 *got_packet = 1;
210
211 return 0;
212 }
213
223 };