1 /*
2 * XBM image format
3 *
4 * Copyright (c) 2012 Paul B Mahol
5 *
6 * This file is part of FFmpeg.
7 *
8 * FFmpeg is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * FFmpeg is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with FFmpeg; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 */
22
24
28
30 {
31 #define TIMES256(idx) \
32 TIMES64(4 * (idx)) TIMES64(4 * (idx) + 1) TIMES64(4 * (idx) + 2) TIMES64(4 * (idx) + 3)
33 #define TIMES64(idx) \
34 TIMES16(4 * (idx)) TIMES16(4 * (idx) + 1) TIMES16(4 * (idx) + 2) TIMES16(4 * (idx) + 3)
35 #define TIMES16(idx) \
36 TIMES4(4 * (idx)) TIMES4(4 * (idx) + 1) TIMES4(4 * (idx) + 2) TIMES4(4 * (idx) + 3)
37 #define TIMES4(idx) \
38 ENTRY(4 * (idx)) ENTRY(4 * (idx) + 1) ENTRY(4 * (idx) + 2) ENTRY(4 * (idx) + 3)
39 #define ENTRY(x) [x] = ((x) >= 'a' && (x) <= 'f') ? (x) - ('a' - 10) : \
40 ((x) >= 'A' && (x) <= 'F') ? (x) - ('A' - 10) : \
41 ((x) >= '0' && (x) <= '9') ? (x) - '0' : 255,
42
43 static const uint8_t lut[] = {
45 };
46 return lut[x];
47 }
48
50 {
51 int keylen = strlen(
key);
52 const uint8_t *e = end - keylen;
53
55 if (!memcmp(
p,
key, keylen))
56 break;
57 }
60 return INT_MIN;
61
63 char *eptr;
65 if ((
const uint8_t *)eptr !=
p)
67 }
68 return INT_MIN;
69 }
70
73 {
74 int ret, linesize,
i, j;
77 const uint8_t *end, *ptr = avpkt->
data;
78 const uint8_t *next;
80
83
86
89
92
95
96 // goto start of image data
97 next = memchr(ptr,
'{', avpkt->
size);
98 if (!next)
99 next = memchr(ptr,
'(', avpkt->
size);
100 if (!next)
102 ptr = next + 1;
103
104 linesize = (avctx->
width + 7) / 8;
106 dst =
p->data[0] +
i *
p->linesize[0];
107 for (j = 0; j < linesize; j++) {
109
110 while (ptr < end && *ptr != 'x' && *ptr != '$')
111 ptr++;
112
113 ptr ++;
115 ptr++;
118 ptr++;
119 }
122 j++;
123 ptr++;
126 ptr++;
127 }
129 }
130 } else {
132 "Unexpected data at %.8s.\n", ptr);
134 }
135 }
136 }
137
138 *got_frame = 1;
139
141 }
142
151 };