Browse code

lavc: add xface image decoder and encoder

Based on libcompface code by James Ashton <James.Ashton@anu.edu.au>, and
relicensed to LGPL with the author's consent.

Stefano Sabatini authored on 2012/07/25 19:23:31
Showing 14 changed files
... ...
@@ -11,6 +11,7 @@ version next:
11 11
 - TAK demuxer, decoder and parser
12 12
 - DTS-HD demuxer
13 13
 - remove -same_quant, it hasn't worked for years
14
+- X-Face image encoder and decoder
14 15
 
15 16
 
16 17
 version 1.0:
... ...
@@ -441,6 +441,8 @@ following image formats are supported:
441 441
     @tab Targa (.TGA) image format
442 442
 @item XBM  @tab X @tab X
443 443
     @tab X BitMap image format
444
+@item XFace @tab X @tab X
445
+    @tab X-Face image format
444 446
 @item XWD  @tab X @tab X
445 447
     @tab X Window Dump image format
446 448
 @end multitable
... ...
@@ -482,6 +482,8 @@ OBJS-$(CONFIG_XAN_WC4_DECODER)         += xxan.o
482 482
 OBJS-$(CONFIG_XBIN_DECODER)            += bintext.o cga_data.o
483 483
 OBJS-$(CONFIG_XBM_DECODER)             += xbmdec.o
484 484
 OBJS-$(CONFIG_XBM_ENCODER)             += xbmenc.o
485
+OBJS-$(CONFIG_XFACE_DECODER)           += xfacedec.o xface.o
486
+OBJS-$(CONFIG_XFACE_ENCODER)           += xfaceenc.o xface.o
485 487
 OBJS-$(CONFIG_XL_DECODER)              += xl.o
486 488
 OBJS-$(CONFIG_XSUB_DECODER)            += xsubdec.o
487 489
 OBJS-$(CONFIG_XSUB_ENCODER)            += xsubenc.o
... ...
@@ -265,6 +265,7 @@ void avcodec_register_all(void)
265 265
     REGISTER_DECODER (XAN_WC3, xan_wc3);
266 266
     REGISTER_DECODER (XAN_WC4, xan_wc4);
267 267
     REGISTER_ENCDEC  (XBM, xbm);
268
+    REGISTER_ENCDEC  (XFACE, xface);
268 269
     REGISTER_DECODER (XL, xl);
269 270
     REGISTER_ENCDEC  (XWD, xwd);
270 271
     REGISTER_ENCDEC  (Y41P, y41p);
... ...
@@ -283,6 +283,7 @@ enum AVCodecID {
283 283
     AV_CODEC_ID_PAF_VIDEO  = MKBETAG('P','A','F','V'),
284 284
     AV_CODEC_ID_AVRN       = MKBETAG('A','V','R','n'),
285 285
     AV_CODEC_ID_CPIA       = MKBETAG('C','P','I','A'),
286
+    AV_CODEC_ID_XFACE      = MKBETAG('X','F','A','C'),
286 287
 
287 288
     /* various PCM "codecs" */
288 289
     AV_CODEC_ID_FIRST_AUDIO = 0x10000,     ///< A dummy id pointing at the start of audio codecs
... ...
@@ -1315,6 +1315,12 @@ static const AVCodecDescriptor codec_descriptors[] = {
1315 1315
         .name      = "cpia",
1316 1316
         .long_name = NULL_IF_CONFIG_SMALL("CPiA video format"),
1317 1317
     },
1318
+    {
1319
+        .id        = AV_CODEC_ID_XFACE,
1320
+        .type      = AVMEDIA_TYPE_VIDEO,
1321
+        .name      = "xface",
1322
+        .long_name = NULL_IF_CONFIG_SMALL("X-face image"),
1323
+    },
1318 1324
 
1319 1325
     /* various PCM "codecs" */
1320 1326
     {
... ...
@@ -29,7 +29,7 @@
29 29
 #include "libavutil/avutil.h"
30 30
 
31 31
 #define LIBAVCODEC_VERSION_MAJOR 54
32
-#define LIBAVCODEC_VERSION_MINOR 65
32
+#define LIBAVCODEC_VERSION_MINOR 66
33 33
 #define LIBAVCODEC_VERSION_MICRO 100
34 34
 
35 35
 #define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
36 36
new file mode 100644
... ...
@@ -0,0 +1,381 @@
0
+/*
1
+ * Copyright (c) 1990 James Ashton - Sydney University
2
+ * Copyright (c) 2012 Stefano Sabatini
3
+ *
4
+ * This file is part of FFmpeg.
5
+ *
6
+ * FFmpeg is free software; you can redistribute it and/or
7
+ * modify it under the terms of the GNU Lesser General Public
8
+ * License as published by the Free Software Foundation; either
9
+ * version 2.1 of the License, or (at your option) any later version.
10
+ *
11
+ * FFmpeg is distributed in the hope that it will be useful,
12
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14
+ * Lesser General Public License for more details.
15
+ *
16
+ * You should have received a copy of the GNU Lesser General Public
17
+ * License along with FFmpeg; if not, write to the Free Software
18
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19
+ */
20
+
21
+/**
22
+ * @file
23
+ * X-Face common data and utilities definition.
24
+ */
25
+
26
+#include "xface.h"
27
+
28
+void ff_big_add(BigInt *b, uint8_t a)
29
+{
30
+    int i;
31
+    uint8_t *w;
32
+    uint16_t c;
33
+
34
+    a &= XFACE_WORDMASK;
35
+    if (a == 0)
36
+        return;
37
+    w = b->words;
38
+    c = a;
39
+    for (i = 0; i < b->nb_words && c; i++) {
40
+        c += *w;
41
+        *w++ = c & XFACE_WORDMASK;
42
+        c >>= XFACE_BITSPERWORD;
43
+    }
44
+    if (i == b->nb_words && c) {
45
+        b->nb_words++;
46
+        *w = c & XFACE_WORDMASK;
47
+    }
48
+}
49
+
50
+void ff_big_div(BigInt *b, uint8_t a, uint8_t *r)
51
+{
52
+    int i;
53
+    uint8_t *w;
54
+    uint16_t c, d;
55
+
56
+    a &= XFACE_WORDMASK;
57
+    if (a == 1 || b->nb_words == 0) {
58
+        *r = 0;
59
+        return;
60
+    }
61
+
62
+    /* treat this as a == WORDCARRY and just shift everything right a WORD */
63
+    if (a == 0) {
64
+        i = --b->nb_words;
65
+        w = b->words;
66
+        *r = *w;
67
+        while (i--) {
68
+            *w = *(w + 1);
69
+            w++;
70
+        }
71
+        *w = 0;
72
+        return;
73
+    }
74
+    i = b->nb_words;
75
+    w = b->words + i;
76
+    c = 0;
77
+    while (i--) {
78
+        c <<= XFACE_BITSPERWORD;
79
+        c += *--w;
80
+        d = c / (uint16_t)a;
81
+        c = c % (uint16_t)a;
82
+        *w = d & XFACE_WORDMASK;
83
+    }
84
+    *r = c;
85
+    if (b->words[b->nb_words - 1] == 0)
86
+        b->nb_words--;
87
+}
88
+
89
+void ff_big_mul(BigInt *b, uint8_t a)
90
+{
91
+    int i;
92
+    uint8_t *w;
93
+    uint16_t c;
94
+
95
+    a &= XFACE_WORDMASK;
96
+    if (a == 1 || b->nb_words == 0)
97
+        return;
98
+    if (a == 0) {
99
+        /* treat this as a == WORDCARRY and just shift everything left a WORD */
100
+        i = b->nb_words++;
101
+        w = b->words + i;
102
+        while (i--) {
103
+            *w = *(w - 1);
104
+            w--;
105
+        }
106
+        *w = 0;
107
+        return;
108
+    }
109
+    i = b->nb_words;
110
+    w = b->words;
111
+    c = 0;
112
+    while (i--) {
113
+        c += (uint16_t)*w * (uint16_t)a;
114
+        *(w++) = c & XFACE_WORDMASK;
115
+        c >>= XFACE_BITSPERWORD;
116
+    }
117
+    if (c) {
118
+        b->nb_words++;
119
+        *w = c & XFACE_WORDMASK;
120
+    }
121
+}
122
+
123
+const ProbRange ff_xface_probranges_per_level[4][3] = {
124
+    //  black      grey       white
125
+    { {  1, 255}, {251, 0}, {  4, 251} }, /* Top of tree almost always grey */
126
+    { {  1, 255}, {200, 0}, { 55, 200} },
127
+    { { 33, 223}, {159, 0}, { 64, 159} },
128
+    { {131,   0}, {  0, 0}, {125, 131} }, /* Grey disallowed at bottom */
129
+};
130
+
131
+const ProbRange ff_xface_probranges_2x2[16] = {
132
+    { 0,   0},  {38,   0}, {38,  38},  {13, 152},
133
+    {38,  76},  {13, 165}, {13, 178},  { 6, 230},
134
+    {38, 114},  {13, 191}, {13, 204},  { 6, 236},
135
+    {13, 217},  { 6, 242}, { 5, 248},  { 3, 253},
136
+};
137
+
138
+/*
139
+ * The "guess the next pixel" tables follow. Normally there are 12
140
+ * neighbour pixels used to give 1<<12 cases as we get closer to the
141
+ * upper left corner lesser numbers of neighbours are available.
142
+ *
143
+ * Each byte in the tables represents 8 boolean values starting from
144
+ * the most significant bit.
145
+ */
146
+
147
+static const uint8_t g_00[] = {
148
+    0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0xe3, 0xdf, 0x05, 0x17,
149
+    0x05, 0x0f, 0x00, 0x1b, 0x0f, 0xdf, 0x00, 0x04, 0x00, 0x00,
150
+    0x0d, 0x0f, 0x03, 0x7f, 0x00, 0x00, 0x00, 0x01, 0x00, 0x1d,
151
+    0x45, 0x2f, 0x00, 0x00, 0x00, 0x0d, 0x00, 0x0a, 0xff, 0xff,
152
+    0x00, 0x04, 0x00, 0x05, 0x01, 0x3f, 0xcf, 0xff, 0x10, 0x01,
153
+    0x80, 0xc9, 0x0f, 0x0f, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,
154
+    0x1b, 0x1f, 0xff, 0xff, 0x4f, 0x54, 0x07, 0x1f, 0x57, 0x47,
155
+    0xd7, 0x3d, 0xff, 0xff, 0x5f, 0x1f, 0x7f, 0xff, 0x7f, 0x7f,
156
+    0x05, 0x0f, 0x01, 0x0f, 0x0f, 0x5f, 0x9b, 0xdf, 0x7f, 0xff,
157
+    0x5f, 0x1d, 0x5f, 0xff, 0x0f, 0x1f, 0x0f, 0x5f, 0x03, 0x1f,
158
+    0x4f, 0x5f, 0xf7, 0x7f, 0x7f, 0xff, 0x0d, 0x0f, 0xfb, 0xff,
159
+    0xf7, 0xbf, 0x0f, 0x4f, 0xd7, 0x3f, 0x4f, 0x7f, 0xff, 0xff,
160
+    0x67, 0xbf, 0x56, 0x25, 0x1f, 0x7f, 0x9f, 0xff, 0x00, 0x00,
161
+    0x00, 0x05, 0x5f, 0x7f, 0x01, 0xdf, 0x14, 0x00, 0x05, 0x0f,
162
+    0x07, 0xa2, 0x09, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x5f,
163
+    0x18, 0xd7, 0x94, 0x71, 0x00, 0x05, 0x1f, 0xb7, 0x0c, 0x07,
164
+    0x0f, 0x0f, 0x00, 0x0f, 0x0f, 0x1f, 0x84, 0x8f, 0x05, 0x15,
165
+    0x05, 0x0f, 0x4f, 0xff, 0x87, 0xdf, 0x05, 0x01, 0x10, 0x00,
166
+    0x0f, 0x0f, 0x00, 0x08, 0x05, 0x04, 0x04, 0x01, 0x4f, 0xff,
167
+    0x9f, 0x8f, 0x4a, 0x40, 0x5f, 0x5f, 0xff, 0xfe, 0xdf, 0xff,
168
+    0x7f, 0xf7, 0xff, 0x7f, 0xff, 0xff, 0x7b, 0xff, 0x0f, 0xfd,
169
+    0xd7, 0x5f, 0x4f, 0x7f, 0x7f, 0xdf, 0xff, 0xff, 0xff, 0xff,
170
+    0xff, 0x77, 0xdf, 0x7f, 0x4f, 0xef, 0xff, 0xff, 0x77, 0xff,
171
+    0xff, 0xff, 0x6f, 0xff, 0x0f, 0x4f, 0xff, 0xff, 0x9d, 0xff,
172
+    0x0f, 0xef, 0xff, 0xdf, 0x6f, 0xff, 0xff, 0xff, 0x4f, 0xff,
173
+    0xcd, 0x0f, 0x4f, 0xff, 0xff, 0xdf, 0x00, 0x00, 0x00, 0x0b,
174
+    0x05, 0x02, 0x02, 0x0f, 0x04, 0x00, 0x00, 0x0c, 0x01, 0x06,
175
+    0x00, 0x0f, 0x20, 0x03, 0x00, 0x00, 0x05, 0x0f, 0x40, 0x08,
176
+    0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x0c, 0x0f, 0x01, 0x00,
177
+    0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x14, 0x01, 0x05,
178
+    0x01, 0x15, 0xaf, 0x0f, 0x00, 0x01, 0x10, 0x00, 0x08, 0x00,
179
+    0x46, 0x0c, 0x20, 0x00, 0x88, 0x00, 0x0f, 0x15, 0xff, 0xdf,
180
+    0x02, 0x00, 0x00, 0x0f, 0x7f, 0x5f, 0xdb, 0xff, 0x4f, 0x3e,
181
+    0x05, 0x0f, 0x7f, 0xf7, 0x95, 0x4f, 0x0d, 0x0f, 0x01, 0x0f,
182
+    0x4f, 0x5f, 0x9f, 0xdf, 0x25, 0x0e, 0x0d, 0x0d, 0x4f, 0x7f,
183
+    0x8f, 0x0f, 0x0f, 0xfa, 0x04, 0x4f, 0x4f, 0xff, 0xf7, 0x77,
184
+    0x47, 0xed, 0x05, 0x0f, 0xff, 0xff, 0xdf, 0xff, 0x4f, 0x6f,
185
+    0xd8, 0x5f, 0x0f, 0x7f, 0xdf, 0x5f, 0x07, 0x0f, 0x94, 0x0d,
186
+    0x1f, 0xff, 0xff, 0xff, 0x00, 0x02, 0x00, 0x03, 0x46, 0x57,
187
+    0x01, 0x0d, 0x01, 0x08, 0x01, 0x0f, 0x47, 0x6c, 0x0d, 0x0f,
188
+    0x02, 0x00, 0x00, 0x00, 0x0b, 0x4f, 0x00, 0x08, 0x05, 0x00,
189
+    0x95, 0x01, 0x0f, 0x7f, 0x0c, 0x0f, 0x01, 0x0e, 0x00, 0x00,
190
+    0x0f, 0x41, 0x00, 0x00, 0x04, 0x24, 0x0d, 0x0f, 0x0f, 0x7f,
191
+    0xcf, 0xdf, 0x00, 0x00, 0x00, 0x00, 0x04, 0x40, 0x00, 0x00,
192
+    0x06, 0x26, 0xcf, 0x05, 0xcf, 0x7f, 0xdf, 0xdf, 0x00, 0x00,
193
+    0x17, 0x5f, 0xff, 0xfd, 0xff, 0xff, 0x46, 0x09, 0x4f, 0x5f,
194
+    0x7f, 0xfd, 0xdf, 0xff, 0x0a, 0x88, 0xa7, 0x7f, 0x7f, 0xff,
195
+    0xff, 0xff, 0x0f, 0x04, 0xdf, 0x7f, 0x4f, 0xff, 0x9f, 0xff,
196
+    0x0e, 0xe6, 0xdf, 0xff, 0x7f, 0xff, 0xff, 0xff, 0x0f, 0xec,
197
+    0x8f, 0x4f, 0x7f, 0xff, 0xdf, 0xff, 0x0f, 0xcf, 0xdf, 0xff,
198
+    0x6f, 0x7f, 0xff, 0xff, 0x03, 0x0c, 0x9d, 0x0f, 0x7f, 0xff,
199
+    0xff, 0xff,
200
+};
201
+
202
+static const uint8_t g_01[] = {
203
+    0x37, 0x73, 0x00, 0x19, 0x57, 0x7f, 0xf5, 0xfb, 0x70, 0x33,
204
+    0xf0, 0xf9, 0x7f, 0xff, 0xff, 0xff,
205
+};
206
+
207
+static const uint8_t g_02[] = {
208
+    0x50,
209
+};
210
+
211
+static const uint8_t g_10[] = {
212
+    0x00, 0x00, 0x00, 0x00, 0x50, 0x00, 0xf3, 0x5f, 0x84, 0x04,
213
+    0x17, 0x9f, 0x04, 0x23, 0x05, 0xff, 0x00, 0x00, 0x00, 0x02,
214
+    0x03, 0x03, 0x33, 0xd7, 0x05, 0x03, 0x5f, 0x3f, 0x17, 0x33,
215
+    0xff, 0xff, 0x00, 0x80, 0x02, 0x04, 0x12, 0x00, 0x11, 0x57,
216
+    0x05, 0x25, 0x05, 0x03, 0x35, 0xbf, 0x9f, 0xff, 0x07, 0x6f,
217
+    0x20, 0x40, 0x17, 0x06, 0xfa, 0xe8, 0x01, 0x07, 0x1f, 0x9f,
218
+    0x1f, 0xff, 0xff, 0xff,
219
+};
220
+
221
+static const uint8_t g_20[] = {
222
+    0x04, 0x00, 0x01, 0x01, 0x43, 0x2e, 0xff, 0x3f,
223
+};
224
+
225
+static const uint8_t g_30[] = {
226
+    0x11, 0x11, 0x11, 0x11, 0x51, 0x11, 0x13, 0x11, 0x11, 0x11,
227
+    0x13, 0x11, 0x11, 0x11, 0x33, 0x11, 0x13, 0x11, 0x13, 0x13,
228
+    0x13, 0x13, 0x31, 0x31, 0x11, 0x01, 0x11, 0x11, 0x71, 0x11,
229
+    0x11, 0x75,
230
+};
231
+
232
+static const uint8_t g_40[] = {
233
+    0x00, 0x0f, 0x00, 0x09, 0x00, 0x0d, 0x00, 0x0d, 0x00, 0x0f,
234
+    0x00, 0x4e, 0xe4, 0x0d, 0x10, 0x0f, 0x00, 0x0f, 0x44, 0x4f,
235
+    0x00, 0x1e, 0x0f, 0x0f, 0xae, 0xaf, 0x45, 0x7f, 0xef, 0xff,
236
+    0x0f, 0xff, 0x00, 0x09, 0x01, 0x11, 0x00, 0x01, 0x1c, 0xdd,
237
+    0x00, 0x15, 0x00, 0xff, 0x00, 0x10, 0x00, 0xfd, 0x00, 0x0f,
238
+    0x4f, 0x5f, 0x3d, 0xff, 0xff, 0xff, 0x4f, 0xff, 0x1c, 0xff,
239
+    0xdf, 0xff, 0x8f, 0xff, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x15,
240
+    0x01, 0x07, 0x00, 0x01, 0x02, 0x1f, 0x01, 0x11, 0x05, 0x7f,
241
+    0x00, 0x1f, 0x41, 0x57, 0x1f, 0xff, 0x05, 0x77, 0x0d, 0x5f,
242
+    0x4d, 0xff, 0x4f, 0xff, 0x0f, 0xff, 0x00, 0x00, 0x02, 0x05,
243
+    0x00, 0x11, 0x05, 0x7d, 0x10, 0x15, 0x2f, 0xff, 0x40, 0x50,
244
+    0x0d, 0xfd, 0x04, 0x0f, 0x07, 0x1f, 0x07, 0x7f, 0x0f, 0xbf,
245
+    0x0d, 0x7f, 0x0f, 0xff, 0x4d, 0x7d, 0x0f, 0xff,
246
+};
247
+
248
+static const uint8_t g_11[] = {
249
+    0x01, 0x13, 0x03, 0x7f,
250
+};
251
+
252
+static const uint8_t g_21[] = {
253
+    0x17,
254
+};
255
+
256
+static const uint8_t g_31[] = {
257
+    0x55, 0x57, 0x57, 0x7f,
258
+};
259
+
260
+static const uint8_t g_41[] = {
261
+    0x01, 0x01, 0x01, 0x1f, 0x03, 0x1f, 0x3f, 0xff,
262
+};
263
+
264
+static const uint8_t g_12[] = {
265
+    0x40,
266
+};
267
+
268
+static const uint8_t g_22[] = {
269
+    0x00,
270
+};
271
+
272
+static const uint8_t g_32[] = {
273
+    0x10,
274
+};
275
+
276
+static const uint8_t g_42[] = {
277
+    0x10,
278
+};
279
+
280
+void ff_xface_generate_face(uint8_t *dst, uint8_t * const src)
281
+{
282
+    int h, i, j, k, l, m;
283
+
284
+    for (j = 0; j < XFACE_HEIGHT; j++) {
285
+        for (i = 0; i < XFACE_WIDTH; i++) {
286
+            h = i + j * XFACE_WIDTH;
287
+            k = 0;
288
+
289
+            /*
290
+               Compute k, encoding the bits *before* the current one, contained in the
291
+               image buffer. That is, given the grid:
292
+
293
+                l      i
294
+                |      |
295
+                v      v
296
+               +--+--+--+--+--+
297
+          m -> | 1| 2| 3| 4| 5|
298
+               +--+--+--+--+--+
299
+               | 6| 7| 8| 9|10|
300
+               +--+--+--+--+--+
301
+          j -> |11|12| *|  |  |
302
+               +--+--+--+--+--+
303
+
304
+               the value k for the pixel marked as "*" will contain the bit encoding of
305
+               the values in the matrix marked from "1" to "12". In case the pixel is
306
+               near the border of the grid, the number of values contained within the
307
+               grid will be lesser than 12.
308
+             */
309
+
310
+            for (l = i - 2; l <= i + 2; l++) {
311
+                for (m = j - 2; m <= j; m++) {
312
+                    if (l >= i && m == j)
313
+                        continue;
314
+                    if (l > 0 && l <= XFACE_WIDTH && m > 0)
315
+                        k = 2*k + src[l + m * XFACE_WIDTH];
316
+                }
317
+            }
318
+
319
+            /*
320
+              Use the guess for the given position and the computed value of k.
321
+
322
+              The following table shows the number of digits in k, depending on
323
+              the position of the pixel, and shows the corresponding guess table
324
+              to use:
325
+
326
+                 i=1  i=2  i=3       i=w-1 i=w
327
+               +----+----+----+ ... +----+----+
328
+           j=1 |  0 |  1 |  2 |     |  2 |  2 |
329
+               |g22 |g12 |g02 |     |g42 |g32 |
330
+               +----+----+----+ ... +----+----+
331
+           j=2 |  3 |  5 |  7 |     |  6 |  5 |
332
+               |g21 |g11 |g01 |     |g41 |g31 |
333
+               +----+----+----+ ... +----+----+
334
+           j=3 |  5 |  9 | 12 |     | 10 |  8 |
335
+               |g20 |g10 |g00 |     |g40 |g30 |
336
+               +----+----+----+ ... +----+----+
337
+            */
338
+
339
+#define GEN(table) dst[h] ^= (table[k>>3]>>(7-(k&7)))&1
340
+
341
+            switch (i) {
342
+            case 1:
343
+                switch (j) {
344
+                case 1:  GEN(g_22); break;
345
+                case 2:  GEN(g_21); break;
346
+                default: GEN(g_20); break;
347
+                }
348
+                break;
349
+            case 2:
350
+                switch (j) {
351
+                case 1:  GEN(g_12); break;
352
+                case 2:  GEN(g_11); break;
353
+                default: GEN(g_10); break;
354
+                }
355
+                break;
356
+            case XFACE_WIDTH - 1:
357
+                switch (j) {
358
+                case 1:  GEN(g_42); break;
359
+                case 2:  GEN(g_41); break;
360
+                default: GEN(g_40); break;
361
+                }
362
+                break;
363
+            case XFACE_WIDTH:
364
+                switch (j) {
365
+                case 1:  GEN(g_32); break;
366
+                case 2:  GEN(g_31); break;
367
+                default: GEN(g_30); break;
368
+                }
369
+                break;
370
+            default:
371
+                switch (j) {
372
+                case 1:  GEN(g_02); break;
373
+                case 2:  GEN(g_01); break;
374
+                default: GEN(g_00); break;
375
+                }
376
+                break;
377
+            }
378
+        }
379
+    }
380
+}
0 381
new file mode 100644
... ...
@@ -0,0 +1,95 @@
0
+/*
1
+ * Copyright (c) 1990 James Ashton - Sydney University
2
+ * Copyright (c) 2012 Stefano Sabatini
3
+ *
4
+ * This file is part of FFmpeg.
5
+ *
6
+ * FFmpeg is free software; you can redistribute it and/or
7
+ * modify it under the terms of the GNU Lesser General Public
8
+ * License as published by the Free Software Foundation; either
9
+ * version 2.1 of the License, or (at your option) any later version.
10
+ *
11
+ * FFmpeg is distributed in the hope that it will be useful,
12
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14
+ * Lesser General Public License for more details.
15
+ *
16
+ * You should have received a copy of the GNU Lesser General Public
17
+ * License along with FFmpeg; if not, write to the Free Software
18
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19
+ */
20
+
21
+/**
22
+ * @file
23
+ * X-Face common definitions.
24
+ */
25
+
26
+#include <stdint.h>
27
+
28
+/* define the face size - 48x48x1 */
29
+#define XFACE_WIDTH  48
30
+#define XFACE_HEIGHT 48
31
+#define XFACE_PIXELS (XFACE_WIDTH * XFACE_HEIGHT)
32
+
33
+/* compressed output uses the full range of printable characters.
34
+ * In ASCII these are in a contiguous block so we just need to know
35
+ * the first and last. The total number of printables is needed too. */
36
+#define XFACE_FIRST_PRINT '!'
37
+#define XFACE_LAST_PRINT '~'
38
+#define XFACE_PRINTS (XFACE_LAST_PRINT - XFACE_FIRST_PRINT + 1)
39
+
40
+/*
41
+ * Image is encoded as a big integer, using characters from '~' to
42
+ * '!', for a total of 92 symbols. In order to express 48x48=2304
43
+ * bits, we need a total of 354 digits, as given by:
44
+ * ceil(lg_92(2^2304)) = 354
45
+ */
46
+#define XFACE_MAX_DIGITS 354
47
+
48
+#define XFACE_BITSPERWORD 8
49
+#define XFACE_WORDCARRY (1 << XFACE_BITSPERWORD)
50
+#define XFACE_WORDMASK (XFACE_WORDCARRY - 1)
51
+
52
+#define XFACE_MAX_WORDS ((XFACE_PIXELS * 2 + XFACE_BITSPERWORD - 1) / XFACE_BITSPERWORD)
53
+
54
+/* Portable, very large unsigned integer arithmetic is needed.
55
+ * Implementation uses arrays of WORDs. */
56
+typedef struct {
57
+    int nb_words;
58
+    uint8_t words[XFACE_MAX_WORDS];
59
+} BigInt;
60
+
61
+/**
62
+ * Add a to b storing the result in b.
63
+ */
64
+void ff_big_add(BigInt *b, uint8_t a);
65
+
66
+/**
67
+ * Divide b by a storing the result in b and the remainder in the word
68
+ * pointed to by r.
69
+ */
70
+void ff_big_div(BigInt *b, uint8_t a, uint8_t *r);
71
+
72
+/**
73
+ * Multiply a by b storing the result in b.
74
+ */
75
+void ff_big_mul(BigInt *b, uint8_t a);
76
+
77
+/* Each face is encoded using 9 octrees of 16x16 each. Each level of the
78
+ * trees has varying probabilities of being white, grey or black.
79
+ * The table below is based on sampling many faces */
80
+enum XFaceColor { XFACE_COLOR_BLACK = 0, XFACE_COLOR_GREY, XFACE_COLOR_WHITE };
81
+
82
+/* Data of varying probabilities are encoded by a value in the range 0 - 255.
83
+ * The probability of the data determines the range of possible encodings.
84
+ * Offset gives the first possible encoding of the range. */
85
+typedef struct {
86
+    int range;
87
+    int offset;
88
+} ProbRange;
89
+
90
+extern const ProbRange ff_xface_probranges_per_level[4][3];
91
+
92
+extern const ProbRange ff_xface_probranges_2x2[16];
93
+
94
+void ff_xface_generate_face(uint8_t *dst, uint8_t * const src);
0 95
new file mode 100644
... ...
@@ -0,0 +1,207 @@
0
+/*
1
+ * Copyright (c) 1990 James Ashton - Sydney University
2
+ * Copyright (c) 2012 Stefano Sabatini
3
+ *
4
+ * This file is part of FFmpeg.
5
+ *
6
+ * FFmpeg is free software; you can redistribute it and/or
7
+ * modify it under the terms of the GNU Lesser General Public
8
+ * License as published by the Free Software Foundation; either
9
+ * version 2.1 of the License, or (at your option) any later version.
10
+ *
11
+ * FFmpeg is distributed in the hope that it will be useful,
12
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14
+ * Lesser General Public License for more details.
15
+ *
16
+ * You should have received a copy of the GNU Lesser General Public
17
+ * License along with FFmpeg; if not, write to the Free Software
18
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19
+ */
20
+
21
+/**
22
+ * @file
23
+ * X-Face decoder, based on libcompface, by James Ashton.
24
+ */
25
+
26
+#include "libavutil/pixdesc.h"
27
+#include "avcodec.h"
28
+#include "bytestream.h"
29
+#include "xface.h"
30
+
31
+static int pop_integer(BigInt *b, const ProbRange *pranges)
32
+{
33
+    uint8_t r;
34
+    int i;
35
+
36
+    /* extract the last byte into r, and shift right b by 8 bits */
37
+    ff_big_div(b, 0, &r);
38
+
39
+    i = 0;
40
+    while (r < pranges->offset || r >= pranges->range + pranges->offset) {
41
+        pranges++;
42
+        i++;
43
+    }
44
+    ff_big_mul(b, pranges->range);
45
+    ff_big_add(b, r - pranges->offset);
46
+    return i;
47
+}
48
+
49
+static void pop_greys(BigInt *b, char *bitmap, int w, int h)
50
+{
51
+    if (w > 3) {
52
+        w /= 2;
53
+        h /= 2;
54
+        pop_greys(b, bitmap,                       w, h);
55
+        pop_greys(b, bitmap + w,                   w, h);
56
+        pop_greys(b, bitmap + XFACE_WIDTH * h,     w, h);
57
+        pop_greys(b, bitmap + XFACE_WIDTH * h + w, w, h);
58
+    } else {
59
+        w = pop_integer(b, ff_xface_probranges_2x2);
60
+        if (w & 1) bitmap[0]               = 1;
61
+        if (w & 2) bitmap[1]               = 1;
62
+        if (w & 4) bitmap[XFACE_WIDTH]     = 1;
63
+        if (w & 8) bitmap[XFACE_WIDTH + 1] = 1;
64
+    }
65
+}
66
+
67
+static void decode_block(BigInt *b, char *bitmap, int w, int h, int level)
68
+{
69
+    switch (pop_integer(b, &ff_xface_probranges_per_level[level][0])) {
70
+    case XFACE_COLOR_WHITE:
71
+        return;
72
+    case XFACE_COLOR_BLACK:
73
+        pop_greys(b, bitmap, w, h);
74
+        return;
75
+    default:
76
+        w /= 2;
77
+        h /= 2;
78
+        level++;
79
+        decode_block(b, bitmap,                       w, h, level);
80
+        decode_block(b, bitmap + w,                   w, h, level);
81
+        decode_block(b, bitmap + h * XFACE_WIDTH,     w, h, level);
82
+        decode_block(b, bitmap + w + h * XFACE_WIDTH, w, h, level);
83
+        return;
84
+    }
85
+}
86
+
87
+typedef struct XFaceContext {
88
+    AVFrame frame;
89
+    uint8_t bitmap[XFACE_PIXELS]; ///< image used internally for decoding
90
+} XFaceContext;
91
+
92
+static av_cold int xface_decode_init(AVCodecContext *avctx)
93
+{
94
+    XFaceContext *xface = avctx->priv_data;
95
+
96
+    avcodec_get_frame_defaults(&xface->frame);
97
+
98
+    if (avctx->width || avctx->height) {
99
+        if (avctx->width != XFACE_WIDTH || avctx->height != XFACE_HEIGHT) {
100
+            av_log(avctx, AV_LOG_ERROR,
101
+                   "Size value %dx%d not supported, only accepts a size of %dx%d\n",
102
+                   avctx->width, avctx->height, XFACE_WIDTH, XFACE_HEIGHT);
103
+            return AVERROR(EINVAL);
104
+        }
105
+    }
106
+
107
+    avctx->width   = XFACE_WIDTH;
108
+    avctx->height  = XFACE_HEIGHT;
109
+    avctx->pix_fmt = AV_PIX_FMT_MONOWHITE;
110
+
111
+    return 0;
112
+}
113
+
114
+static av_cold int xface_decode_close(AVCodecContext *avctx)
115
+{
116
+    XFaceContext *xface = avctx->priv_data;
117
+
118
+    if (xface->frame.data[0])
119
+        avctx->release_buffer(avctx, &xface->frame);
120
+
121
+    return 0;
122
+}
123
+
124
+static int xface_decode_frame(AVCodecContext *avctx,
125
+                              void *data, int *data_size,
126
+                              AVPacket *avpkt)
127
+{
128
+    XFaceContext *xface = avctx->priv_data;
129
+    int ret, i, j, k;
130
+    uint8_t byte;
131
+    BigInt b = {0};
132
+    char *buf;
133
+    int64_t c;
134
+
135
+    if (xface->frame.data[0])
136
+        avctx->release_buffer(avctx, &xface->frame);
137
+    xface->frame.data[0] = NULL;
138
+    if ((ret = avctx->get_buffer(avctx, &xface->frame)) < 0)
139
+        return ret;
140
+    xface->frame.reference = 0;
141
+
142
+    for (i = 0, k = 0; avpkt->data[i] && i < avpkt->size; i++) {
143
+        c = avpkt->data[i];
144
+
145
+        /* ignore invalid digits */
146
+        if (c < XFACE_FIRST_PRINT || c > XFACE_LAST_PRINT)
147
+            continue;
148
+
149
+        if (++k > XFACE_MAX_DIGITS) {
150
+            av_log(avctx, AV_LOG_WARNING,
151
+                   "Buffer is longer than expected, truncating at byte %d\n", i);
152
+            break;
153
+        }
154
+        ff_big_mul(&b, XFACE_PRINTS);
155
+        ff_big_add(&b, c - XFACE_FIRST_PRINT);
156
+    }
157
+
158
+    /* decode image and put it in bitmap */
159
+    memset(xface->bitmap, 0, XFACE_PIXELS);
160
+    buf = xface->bitmap;
161
+    decode_block(&b, buf,                         16, 16, 0);
162
+    decode_block(&b, buf + 16,                    16, 16, 0);
163
+    decode_block(&b, buf + 32,                    16, 16, 0);
164
+    decode_block(&b, buf + XFACE_WIDTH * 16,      16, 16, 0);
165
+    decode_block(&b, buf + XFACE_WIDTH * 16 + 16, 16, 16, 0);
166
+    decode_block(&b, buf + XFACE_WIDTH * 16 + 32, 16, 16, 0);
167
+    decode_block(&b, buf + XFACE_WIDTH * 32     , 16, 16, 0);
168
+    decode_block(&b, buf + XFACE_WIDTH * 32 + 16, 16, 16, 0);
169
+    decode_block(&b, buf + XFACE_WIDTH * 32 + 32, 16, 16, 0);
170
+
171
+    ff_xface_generate_face(xface->bitmap, xface->bitmap);
172
+
173
+    /* convert image from 1=black 0=white bitmap to MONOWHITE */
174
+    buf = xface->frame.data[0];
175
+    for (i = 0, j = 0, k = 0, byte = 0; i < XFACE_PIXELS; i++) {
176
+        byte += xface->bitmap[i];
177
+        if (k == 7) {
178
+            buf[j++] = byte;
179
+            byte = k = 0;
180
+        } else {
181
+            k++;
182
+            byte <<= 1;
183
+        }
184
+        if (j == XFACE_WIDTH/8) {
185
+            j = 0;
186
+            buf += xface->frame.linesize[0];
187
+        }
188
+    }
189
+
190
+    *data_size = sizeof(AVFrame);
191
+    *(AVFrame*)data = xface->frame;
192
+
193
+    return avpkt->size;
194
+}
195
+
196
+AVCodec ff_xface_decoder = {
197
+    .name           = "xface",
198
+    .type           = AVMEDIA_TYPE_VIDEO,
199
+    .id             = AV_CODEC_ID_XFACE,
200
+    .priv_data_size = sizeof(XFaceContext),
201
+    .init           = xface_decode_init,
202
+    .close          = xface_decode_close,
203
+    .decode         = xface_decode_frame,
204
+    .pix_fmts       = (const enum AVPixelFormat[]) { AV_PIX_FMT_MONOWHITE, AV_PIX_FMT_NONE },
205
+    .long_name      = NULL_IF_CONFIG_SMALL("X-face image"),
206
+};
0 207
new file mode 100644
... ...
@@ -0,0 +1,237 @@
0
+/*
1
+ * Copyright (c) 1990 James Ashton - Sydney University
2
+ * Copyright (c) 2012 Stefano Sabatini
3
+ *
4
+ * This file is part of FFmpeg.
5
+ *
6
+ * FFmpeg is free software; you can redistribute it and/or
7
+ * modify it under the terms of the GNU Lesser General Public
8
+ * License as published by the Free Software Foundation; either
9
+ * version 2.1 of the License, or (at your option) any later version.
10
+ *
11
+ * FFmpeg is distributed in the hope that it will be useful,
12
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14
+ * Lesser General Public License for more details.
15
+ *
16
+ * You should have received a copy of the GNU Lesser General Public
17
+ * License along with FFmpeg; if not, write to the Free Software
18
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19
+ */
20
+
21
+/**
22
+ * @file
23
+ * X-Face encoder, based on libcompface, by James Ashton.
24
+ */
25
+
26
+#include "xface.h"
27
+#include "avcodec.h"
28
+#include "internal.h"
29
+
30
+typedef struct XFaceContext {
31
+    AVClass *class;
32
+    uint8_t bitmap[XFACE_PIXELS]; ///< image used internally for decoding
33
+    int max_line_len;             ///< max line length for compressed data
34
+    int set_header;               ///< set X-Face header in the output
35
+} XFaceContext;
36
+
37
+static int all_same(char *bitmap, int w, int h)
38
+{
39
+    char val, *row;
40
+    int x;
41
+
42
+    val = *bitmap;
43
+    while (h--) {
44
+        row = bitmap;
45
+        x = w;
46
+        while (x--)
47
+            if (*(row++) != val)
48
+                return 0;
49
+        bitmap += XFACE_WIDTH;
50
+    }
51
+    return 1;
52
+}
53
+
54
+static int all_black(char *bitmap, int w, int h)
55
+{
56
+    if (w > 3) {
57
+        w /= 2;
58
+        h /= 2;
59
+        return (all_black(bitmap, w, h) && all_black(bitmap + w, w, h) &&
60
+                all_black(bitmap + XFACE_WIDTH * h, w, h) &&
61
+                all_black(bitmap + XFACE_WIDTH * h + w, w, h));
62
+    } else {
63
+        /* at least one pixel in the 2x2 grid is non-zero */
64
+        return *bitmap || *(bitmap + 1) ||
65
+               *(bitmap + XFACE_WIDTH) || *(bitmap + XFACE_WIDTH + 1);
66
+    }
67
+}
68
+
69
+static int all_white(char *bitmap, int w, int h)
70
+{
71
+    return *bitmap == 0 && all_same(bitmap, w, h);
72
+}
73
+
74
+typedef struct {
75
+    const ProbRange *prob_ranges[XFACE_PIXELS*2];
76
+    int prob_ranges_idx;
77
+} ProbRangesQueue;
78
+
79
+static inline int pq_push(ProbRangesQueue *pq, const ProbRange *p)
80
+{
81
+    if (pq->prob_ranges_idx >= XFACE_PIXELS * 2 - 1)
82
+        return -1;
83
+    pq->prob_ranges[pq->prob_ranges_idx++] = p;
84
+    return 0;
85
+}
86
+
87
+static void push_greys(ProbRangesQueue *pq, char *bitmap, int w, int h)
88
+{
89
+    if (w > 3) {
90
+        w /= 2;
91
+        h /= 2;
92
+        push_greys(pq, bitmap,                       w, h);
93
+        push_greys(pq, bitmap + w,                   w, h);
94
+        push_greys(pq, bitmap + XFACE_WIDTH * h,     w, h);
95
+        push_greys(pq, bitmap + XFACE_WIDTH * h + w, w, h);
96
+    } else {
97
+        const ProbRange *p = ff_xface_probranges_2x2 +
98
+                 *bitmap +
99
+            2 * *(bitmap + 1) +
100
+            4 * *(bitmap + XFACE_WIDTH) +
101
+            8 * *(bitmap + XFACE_WIDTH + 1);
102
+        pq_push(pq, p);
103
+    }
104
+}
105
+
106
+static void encode_block(char *bitmap, int w, int h, int level, ProbRangesQueue *pq)
107
+{
108
+    if (all_white(bitmap, w, h)) {
109
+        pq_push(pq, &ff_xface_probranges_per_level[level][XFACE_COLOR_WHITE]);
110
+    } else if (all_black(bitmap, w, h)) {
111
+        pq_push(pq, &ff_xface_probranges_per_level[level][XFACE_COLOR_BLACK]);
112
+        push_greys(pq, bitmap, w, h);
113
+    } else {
114
+        pq_push(pq, &ff_xface_probranges_per_level[level][XFACE_COLOR_GREY]);
115
+        w /= 2;
116
+        h /= 2;
117
+        level++;
118
+        encode_block(bitmap,                       w, h, level, pq);
119
+        encode_block(bitmap + w,                   w, h, level, pq);
120
+        encode_block(bitmap + h * XFACE_WIDTH,     w, h, level, pq);
121
+        encode_block(bitmap + w + h * XFACE_WIDTH, w, h, level, pq);
122
+    }
123
+}
124
+
125
+static av_cold int xface_encode_init(AVCodecContext *avctx)
126
+{
127
+    avctx->coded_frame = avcodec_alloc_frame();
128
+    if (!avctx->coded_frame)
129
+        return AVERROR(ENOMEM);
130
+    avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
131
+
132
+    return 0;
133
+}
134
+
135
+static void push_integer(BigInt *b, const ProbRange *prange)
136
+{
137
+    uint8_t r;
138
+
139
+    ff_big_div(b, prange->range, &r);
140
+    ff_big_mul(b, 0);
141
+    ff_big_add(b, r + prange->offset);
142
+}
143
+
144
+static int xface_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
145
+                              const AVFrame *frame, int *got_packet)
146
+{
147
+    XFaceContext *xface = avctx->priv_data;
148
+    ProbRangesQueue pq = {{ 0 }, 0};
149
+    uint8_t bitmap_copy[XFACE_PIXELS];
150
+    BigInt b = {0};
151
+    int i, j, k, ret = 0;
152
+    const uint8_t *buf;
153
+    uint8_t *p;
154
+    char intbuf[XFACE_MAX_DIGITS];
155
+
156
+    if (avctx->width || avctx->height) {
157
+        if (avctx->width != XFACE_WIDTH || avctx->height != XFACE_HEIGHT) {
158
+            av_log(avctx, AV_LOG_ERROR,
159
+                   "Size value %dx%d not supported, only accepts a size of %dx%d\n",
160
+                   avctx->width, avctx->height, XFACE_WIDTH, XFACE_HEIGHT);
161
+            return AVERROR(EINVAL);
162
+        }
163
+    }
164
+    avctx->width  = XFACE_WIDTH;
165
+    avctx->height = XFACE_HEIGHT;
166
+
167
+    /* convert image from MONOWHITE to 1=black 0=white bitmap */
168
+    buf = frame->data[0];
169
+    for (i = 0, j = 0; i < XFACE_PIXELS; ) {
170
+        for (k = 0; k < 8; k++)
171
+            xface->bitmap[i++] = (buf[j]>>(7-k))&1;
172
+        if (++j == XFACE_WIDTH/8) {
173
+            buf += frame->linesize[0];
174
+            j = 0;
175
+        }
176
+    }
177
+
178
+    /* create a copy of bitmap */
179
+    memcpy(bitmap_copy, xface->bitmap, XFACE_PIXELS);
180
+    ff_xface_generate_face(xface->bitmap, bitmap_copy);
181
+
182
+    encode_block(xface->bitmap,                         16, 16, 0, &pq);
183
+    encode_block(xface->bitmap + 16,                    16, 16, 0, &pq);
184
+    encode_block(xface->bitmap + 32,                    16, 16, 0, &pq);
185
+    encode_block(xface->bitmap + XFACE_WIDTH * 16,      16, 16, 0, &pq);
186
+    encode_block(xface->bitmap + XFACE_WIDTH * 16 + 16, 16, 16, 0, &pq);
187
+    encode_block(xface->bitmap + XFACE_WIDTH * 16 + 32, 16, 16, 0, &pq);
188
+    encode_block(xface->bitmap + XFACE_WIDTH * 32,      16, 16, 0, &pq);
189
+    encode_block(xface->bitmap + XFACE_WIDTH * 32 + 16, 16, 16, 0, &pq);
190
+    encode_block(xface->bitmap + XFACE_WIDTH * 32 + 32, 16, 16, 0, &pq);
191
+
192
+    while (pq.prob_ranges_idx > 0)
193
+        push_integer(&b, pq.prob_ranges[--pq.prob_ranges_idx]);
194
+
195
+    /* write the inverted big integer in b to intbuf */
196
+    i = 0;
197
+    while (b.nb_words) {
198
+        uint8_t r;
199
+        ff_big_div(&b, XFACE_PRINTS, &r);
200
+        intbuf[i++] = r + XFACE_FIRST_PRINT;
201
+    }
202
+
203
+    if ((ret = ff_alloc_packet2(avctx, pkt, i+2)) < 0)
204
+        return ret;
205
+
206
+    /* revert the number, and close the buffer */
207
+    p = pkt->data;
208
+    while (--i >= 0)
209
+        *(p++) = intbuf[i];
210
+    *(p++) = '\n';
211
+    *(p++) = 0;
212
+
213
+    pkt->flags |= AV_PKT_FLAG_KEY;
214
+    *got_packet = 1;
215
+
216
+    return 0;
217
+}
218
+
219
+static av_cold int xface_encode_close(AVCodecContext *avctx)
220
+{
221
+    av_freep(&avctx->coded_frame);
222
+
223
+    return 0;
224
+}
225
+
226
+AVCodec ff_xface_encoder = {
227
+    .name           = "xface",
228
+    .type           = AVMEDIA_TYPE_VIDEO,
229
+    .id             = AV_CODEC_ID_XFACE,
230
+    .priv_data_size = sizeof(XFaceContext),
231
+    .init           = xface_encode_init,
232
+    .close          = xface_encode_close,
233
+    .encode2        = xface_encode_frame,
234
+    .pix_fmts       = (const enum PixelFormat[]) { AV_PIX_FMT_MONOWHITE, AV_PIX_FMT_NONE },
235
+    .long_name      = NULL_IF_CONFIG_SMALL("X-face image"),
236
+};
... ...
@@ -74,6 +74,7 @@ static const IdStrMap img_tags[] = {
74 74
     { AV_CODEC_ID_PICTOR    , "pic"},
75 75
     { AV_CODEC_ID_V210X     , "yuv10"},
76 76
     { AV_CODEC_ID_XBM       , "xbm"},
77
+    { AV_CODEC_ID_XFACE     , "xface"},
77 78
     { AV_CODEC_ID_XWD       , "xwd"},
78 79
     { AV_CODEC_ID_NONE      , NULL}
79 80
 };
... ...
@@ -152,7 +152,7 @@ AVOutputFormat ff_image2_muxer = {
152 152
     .long_name      = NULL_IF_CONFIG_SMALL("image2 sequence"),
153 153
     .extensions     = "bmp,dpx,jls,jpeg,jpg,ljpg,pam,pbm,pcx,pgm,pgmyuv,png,"
154 154
                       "ppm,sgi,tga,tif,tiff,jp2,j2c,xwd,sun,ras,rs,im1,im8,im24,"
155
-                      "sunras,xbm",
155
+                      "sunras,xbm,xface",
156 156
     .priv_data_size = sizeof(VideoMuxData),
157 157
     .video_codec    = AV_CODEC_ID_MJPEG,
158 158
     .write_header   = write_header,
... ...
@@ -31,7 +31,7 @@
31 31
 
32 32
 #define LIBAVFORMAT_VERSION_MAJOR 54
33 33
 #define LIBAVFORMAT_VERSION_MINOR 32
34
-#define LIBAVFORMAT_VERSION_MICRO 100
34
+#define LIBAVFORMAT_VERSION_MICRO 101
35 35
 
36 36
 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
37 37
                                                LIBAVFORMAT_VERSION_MINOR, \