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
27
29 {
31
32 return 0;
33 }
34
36 {
37 if (x >= 'a')
38 x -= 87;
39 else if (x >= 'A')
40 x -= 55;
41 else
42 x -= '0';
43 return x;
44 }
45
48 {
52 int ret, linesize, i, j;
53
58
59 ptr += strcspn(ptr, "#");
60 if (sscanf(ptr, "#define %255s %u", name, &number) != 2) {
63 }
64
65 len = strlen(name);
66 if ((len > 6) && !avctx->
height && !memcmp(name + len - 7,
"_height", 7)) {
68 }
else if ((len > 5) && !avctx->
width && !memcmp(name + len - 6,
"_width", 6)) {
69 avctx->
width = number;
70 } else {
73 }
74 ptr += strcspn(ptr, "\n\r") + 1;
75 }
76
79
80 // goto start of image data
81 ptr += strcspn(ptr, "{") + 1;
82
83 linesize = (avctx->
width + 7) / 8;
84 for (i = 0; i < avctx->
height; i++) {
86 for (j = 0; j < linesize; j++) {
88
89 ptr += strcspn(ptr, "x") + 1;
92 ptr++;
94 val = (val << 4) +
convert(*ptr);
96 } else {
99 }
100 }
101 }
102
105
106 *got_frame = 1;
107
109 }
110
119 };